/* This file was generated by the Hex-Rays decompiler version 8.3.0.230608.
   Copyright (c) 2007-2021 Hex-Rays <info@hex-rays.com>

   Detected compiler: GNU C++
*/

#include <defs.h>


//-------------------------------------------------------------------------
// Function declarations

__int64 (**init_proc())(void);
void sub_1020();
void sub_1030();
void sub_1040();
void sub_1050();
void sub_1060();
void sub_1070();
void sub_1080();
// int __fastcall _cxa_finalize(void *);
// int strncmp(const char *s1, const char *s2, size_t n);
// int puts(const char *s);
// void setbuf(FILE *stream, char *buf);
// int printf(const char *format, ...);
// ssize_t read(int fd, void *buf, size_t nbytes);
void __fastcall __noreturn start(__int64 a1, __int64 a2, void (*a3)(void));
void *deregister_tm_clones();
__int64 register_tm_clones(void); // weak
void *_do_global_dtors_aux();
__int64 frame_dummy(); // weak
void init();
int hello();
int __fastcall main(int argc, const char **argv, const char **envp);
void term_proc();
// int __fastcall _libc_start_main(int (__fastcall *main)(int, char **, char **), int argc, char **ubp_av, void (*init)(void), void (*fini)(void), void (*rtld_fini)(void), void *stack_end);
// int __fastcall __cxa_finalize(void *);
// __int64 _gmon_start__(void); weak

//-------------------------------------------------------------------------
// Data declarations

void *_dso_handle = &_dso_handle; // idb
_UNKNOWN _bss_start; // weak
FILE *stdout; // idb
FILE *stdin; // idb
FILE *stderr; // idb
char completed_0; // weak


//----- (0000000000001000) ----------------------------------------------------
__int64 (**init_proc())(void)
{
  __int64 (**result)(void); // rax

  result = &_gmon_start__;
  if ( &_gmon_start__ )
    return (__int64 (**)(void))_gmon_start__();
  return result;
}
// 6130: using guessed type __int64 _gmon_start__(void);

//----- (0000000000001020) ----------------------------------------------------
void sub_1020()
{
  JUMPOUT(0LL);
}
// 1026: control flows out of bounds to 0

//----- (0000000000001030) ----------------------------------------------------
void sub_1030()
{
  sub_1020();
}

//----- (0000000000001040) ----------------------------------------------------
void sub_1040()
{
  sub_1020();
}

//----- (0000000000001050) ----------------------------------------------------
void sub_1050()
{
  sub_1020();
}

//----- (0000000000001060) ----------------------------------------------------
void sub_1060()
{
  sub_1020();
}

//----- (0000000000001070) ----------------------------------------------------
void sub_1070()
{
  sub_1020();
}

//----- (0000000000001080) ----------------------------------------------------
void sub_1080()
{
  sub_1020();
}

//----- (0000000000001100) ----------------------------------------------------
// positive sp value has been detected, the output may be wrong!
void __fastcall __noreturn start(__int64 a1, __int64 a2, void (*a3)(void))
{
  __int64 v3; // rax
  int v4; // esi
  __int64 v5; // [rsp-8h] [rbp-8h] BYREF
  char *retaddr; // [rsp+0h] [rbp+0h] BYREF

  v4 = v5;
  v5 = v3;
  _libc_start_main((int (__fastcall *)(int, char **, char **))main, v4, &retaddr, 0LL, 0LL, a3, &v5);
  __halt();
}
// 110A: positive sp value 8 has been found
// 1111: variable 'v3' is possibly undefined

//----- (0000000000001130) ----------------------------------------------------
void *deregister_tm_clones()
{
  return &_bss_start;
}

//----- (0000000000001160) ----------------------------------------------------
__int64 register_tm_clones()
{
  return 0LL;
}
// 1160: using guessed type __int64 register_tm_clones();

//----- (00000000000011A0) ----------------------------------------------------
void *_do_global_dtors_aux()
{
  void *result; // rax

  if ( !completed_0 )
  {
    if ( &__cxa_finalize )
      _cxa_finalize(_dso_handle);
    result = deregister_tm_clones();
    completed_0 = 1;
  }
  return result;
}
// 4048: using guessed type char completed_0;

//----- (00000000000011E0) ----------------------------------------------------
__int64 frame_dummy()
{
  return register_tm_clones();
}
// 1160: using guessed type __int64 register_tm_clones(void);
// 11E0: using guessed type __int64 frame_dummy();

//----- (00000000000011E9) ----------------------------------------------------
void init()
{
  setbuf(stdin, 0LL);
  setbuf(stdout, 0LL);
  setbuf(stderr, 0LL);
}

//----- (0000000000001230) ----------------------------------------------------
int hello()
{
  char s1[16]; // [rsp+0h] [rbp-30h] BYREF
  char buf[24]; // [rsp+10h] [rbp-20h] BYREF
  unsigned __int64 v3; // [rsp+28h] [rbp-8h]

  v3 = __readfsqword(0x28u);
  puts("Hello. What's your name?");
  read(0, buf, 0x100uLL);
  printf("Is your name `%s` correct (yes/no)?\n", buf);
  read(0, s1, 0x100uLL);
  return strncmp(s1, "yes", 3uLL);
}

//----- (00000000000012D2) ----------------------------------------------------
int __fastcall main(int argc, const char **argv, const char **envp)
{
  init(argc, argv, envp);
  while ( (unsigned int)hello() )
    ;
  puts("See you~");
  return 0;
}
// 11E9: using guessed type __int64 __fastcall init(_QWORD, _QWORD, _QWORD);
// 1230: using guessed type __int64 hello(void);

//----- (000000000000130C) ----------------------------------------------------
void term_proc()
{
  ;
}

// nfuncs=33 queued=17 decompiled=17 lumina nreq=0 worse=0 better=0
// ALL OK, 17 function(s) have been successfully decompiled
