main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // r14
int v4; // ebx
int v5; // eax
struct hostent *v6; // rax
struct hostent *v7; // r12
const void **v8; // r13
int v9; // ebp
__int16 v10; // ax
const void *v11; // rsi
sa_family_t v12; // dx
size_t v13; // rdx
int v14; // er12
int *v16; // rax
const char *v17; // rax
int v18; // eax
const char *v19; // rdx
int errnum; // [rsp+Ch] [rbp-DCh]
struct sockaddr dest; // [rsp+10h] [rbp-D8h] BYREF
__int64 v22[2]; // [rsp+20h] [rbp-C8h] BYREF
__int128 v23; // [rsp+30h] [rbp-B8h]
__int64 v24; // [rsp+40h] [rbp-A8h]
__int64 v25; // [rsp+48h] [rbp-A0h]
__int128 v26; // [rsp+50h] [rbp-98h]
__int64 v27; // [rsp+88h] [rbp-60h]
int fd; // [rsp+90h] [rbp-58h]

v3 = 0LL;
v4 = 0;
program = (__int64)_xpg_basename((char *)*argv);
while ( 1 )
{
v5 = getopt(argc, (char *const *)argv, "h:p:");
if ( v5 == -1 )
break;
if ( v5 == 104 )
{
v3 = optarg;
}
else
{
if ( v5 != 112 )
goto LABEL_21;
v4 = atoi(optarg);
}
}
if ( !v4 || !v3 )
LABEL_21:
usage();
fix_session_cfg_init(v22);
v25 = 0LL;
v24 = 0x454449534C4C4553LL;
v22[0] = 0x45444953595542LL;
v22[1] = 0LL;
v26 = 0LL;
v27 = (__int64)&fix_dialects + 64;
v23 = 0LL;
v6 = gethostbyname(v3);
v7 = v6;
if ( !v6 )
goto LABEL_24;
v8 = (const void **)v6->h_addr_list;
for ( errnum = 0; *v8; ++v8 )
{
fd = socket(v7->h_addrtype, 1, 6);
v9 = fd;
if ( fd < 0 )
{
errnum = *_errno_location();
}
else
{
v3 = (char *)&dest;
v10 = _bswap_16(v4);
dest = 0LL;
v11 = *v8;
dest.sa_family = v12;
v13 = v7->h_length;
*(_WORD *)dest.sa_data = v10;
memcpy(&dest.sa_data[2], v11, v13);
if ( connect(v9, &dest, 0x10u) >= 0 )
break;
errnum = *_errno_location();
close(fd);
fd = -1;
}
}
if ( fd < 0 )
{
LABEL_25:
v18 = (unsigned int)strerror(errnum);
error((int)"Unable to connect to a socket (%s)", v18, v19);
JUMPOUT(0x721LL);
}
if ( socket_setopt_constprop_0(fd) < 0 )
{
LABEL_23:
do_die("%s: cannot set socket option TCP_NODELAY", "main");
LABEL_24:
v16 = _h_errno_location();
v17 = hstrerror(*v16);
error((int)"Unable to look up %s (%s)", (int)v3, v17);
goto LABEL_25;
}
v14 = do_trader(v22);
shutdown(fd, 2);
if ( close(fd) < 0 )
{
do_die("%s: close", "main");
goto LABEL_23;
}
return v14;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // r14
int v4; // ebx
int v5; // eax
struct hostent *v6; // rax
struct hostent *v7; // r12
const void **v8; // r13
int v9; // ebp
__int16 v10; // ax
const void *v11; // rsi
sa_family_t v12; // dx
size_t v13; // rdx
int v14; // er12
int *v16; // rax
const char *v17; // rax
int v18; // eax
const char *v19; // rdx
int errnum; // [rsp+Ch] [rbp-DCh]
struct sockaddr dest; // [rsp+10h] [rbp-D8h] BYREF
__int64 v22[2]; // [rsp+20h] [rbp-C8h] BYREF
__int128 v23; // [rsp+30h] [rbp-B8h]
__int64 v24; // [rsp+40h] [rbp-A8h]
__int64 v25; // [rsp+48h] [rbp-A0h]
__int128 v26; // [rsp+50h] [rbp-98h]
__int64 v27; // [rsp+88h] [rbp-60h]
int fd; // [rsp+90h] [rbp-58h]

v3 = 0LL;
v4 = 0;
program = (__int64)_xpg_basename((char *)*argv);
while ( 1 )
{
v5 = getopt(argc, (char *const *)argv, "h:p:");
if ( v5 == -1 )
break;
if ( v5 == 104 )
{
v3 = optarg;
}
else
{
if ( v5 != 112 )
goto LABEL_21;
v4 = atoi(optarg);
}
}
if ( !v4 || !v3 )
LABEL_21:
func0();
fix_session_cfg_init(v22);
v25 = 0LL;
v24 = 0x454449534C4C4553LL;
v22[0] = 0x45444953595542LL;
v22[1] = 0LL;
v26 = 0LL;
v27 = (__int64)&fix_dialects + 64;
v23 = 0LL;
v6 = gethostbyname(v3);
v7 = v6;
if ( !v6 )
goto LABEL_24;
v8 = (const void **)v6->h_addr_list;
for ( errnum = 0; *v8; ++v8 )
{
fd = socket(v7->h_addrtype, 1, 6);
v9 = fd;
if ( fd < 0 )
{
errnum = *_errno_location();
}
else
{
v3 = (char *)&dest;
v10 = func1(v4);
dest = 0LL;
v11 = *v8;
dest.sa_family = v12;
v13 = v7->h_length;
*(_WORD *)dest.sa_data = v10;
memcpy(&dest.sa_data[2], v11, v13);
if ( connect(v9, &dest, 0x10u) >= 0 )
break;
errnum = *_errno_location();
close(fd);
fd = -1;
}
}
if ( fd < 0 )
{
LABEL_25:
v18 = (unsigned int)strerror(errnum);
error((int)"Unable to connect to a socket (%s)", v18, v19);
JUMPOUT(0x721LL);
}
if ( func3(fd) < 0 )
{
LABEL_23:
do_die("%s: cannot set socket option TCP_NODELAY", "main");
LABEL_24:
v16 = _h_errno_location();
v17 = hstrerror(*v16);
error((int)"Unable to look up %s (%s)", (int)v3, v17);
goto LABEL_25;
}
v14 = func2(v22);
shutdown(fd, 2);
if ( close(fd) < 0 )
{
do_die("%s: close", "main");
goto LABEL_23;
}
return v14;
}

original_code:
int main(int argc, char *argv[])
{
 struct fix_session_cfg cfg;
 const char *host = ((void *)0);
 struct sockaddr_in sa;
 int saved_errno = 0;
 struct hostent *he;
 int port = 0;
 int ret = 0;
 char **ap;
 int opt;
 program = __xpg_basename(argv[0]);
 while ((opt = getopt(argc, argv, "h:p:")) != -1) {
  switch (opt) {
  case 'p':
   port = atoi(optarg);
   break;
  case 'h':
   host = optarg;
   break;
  default:
   usage();
  }
 }
 if (!port || !host)
  usage();
 fix_session_cfg_init(&cfg);
 strncpy(cfg.target_comp_id, "SELLSIDE", (sizeof(cfg.target_comp_id) / sizeof((cfg.target_comp_id)[0])));
 strncpy(cfg.sender_comp_id, "BUYSIDE", (sizeof(cfg.sender_comp_id) / sizeof((cfg.sender_comp_id)[0])));
 cfg.dialect = &fix_dialects[FIX_4_4];
 he = gethostbyname(host);
 if (!he)
  error("Unable to look up %s (%s)", host, hstrerror((*__h_errno_location ())));
 for (ap = he->h_addr_list; *ap; ap++) {
  cfg.sockfd = socket(he->h_addrtype, SOCK_STREAM, IPPROTO_TCP);
  if (cfg.sockfd < 0) {
   saved_errno = (*__errno_location ());
   continue;
  }
  sa = (struct sockaddr_in) {
   .sin_family = he->h_addrtype,
   .sin_port = htons(port),
  };
  memcpy(&sa.sin_addr, *ap, he->h_length);
  if (connect(cfg.sockfd, (const struct sockaddr *)&sa, sizeof(struct sockaddr_in)) < 0) {
   saved_errno = (*__errno_location ());
   close(cfg.sockfd);
   cfg.sockfd = -1;
   continue;
  }
  break;
 }
 if (cfg.sockfd < 0)
  error("Unable to connect to a socket (%s)", strerror(saved_errno));
 if (socket_setopt(cfg.sockfd, IPPROTO_TCP, 1, 1) < 0)
  do_die("%s: " "cannot set socket option TCP_NODELAY", __func__);
 ret = do_trader(&cfg);
 shutdown(cfg.sockfd, SHUT_RDWR);
 if (close(cfg.sockfd) < 0)
  do_die("%s: " "close", __func__);
 return ret;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct fix_session_cfg cfg;
 char *host = ((void *)0);
 struct sockaddr_in sa;
 int saved_errno = 0;
 struct hostent *he;
 int port = 0;
 int ret = 0;
 char **ap;
 int opt;
 program = __xpg_basename(argv[0]);
 while ((opt = getopt(argc, argv, "h:p:")) != -1) {
  switch (opt) {
  case 'p':
   port = atoi(optarg);
   break;
  case 'h':
   host = optarg;
   break;
  default:
   usage();
  }
 }
 if (!port || !host)
  usage();
 fix_session_cfg_init(&cfg);
 strncpy(cfg.target_comp_id, "SELLSIDE", (sizeof(cfg.target_comp_id) / sizeof((cfg.target_comp_id)[0])));
 strncpy(cfg.sender_comp_id, "BUYSIDE", (sizeof(cfg.sender_comp_id) / sizeof((cfg.sender_comp_id)[0])));
 cfg.dialect = &fix_dialects[FIX_4_4];
 he = gethostbyname(host);
 if (!he)
  error("Unable to look up %s (%s)", host, hstrerror((*__h_errno_location ())));
 for (ap = he->h_addr_list; *ap; ap++) {
  cfg.sockfd = socket(he->h_addrtype, SOCK_STREAM, IPPROTO_TCP);
  if (cfg.sockfd < 0) {
   saved_errno = (*__errno_location ());
   continue;
  }
  sa = (struct sockaddr_in) {
   .sin_family = he->h_addrtype,
   .sin_port = htons(port),
  };
  memcpy(&sa.sin_addr, *ap, he->h_length);
  if (connect(cfg.sockfd, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) < 0) {
   saved_errno = (*__errno_location ());
   close(cfg.sockfd);
   cfg.sockfd = -1;
   continue;
  }
  break;
 }
 if (cfg.sockfd < 0)
  error("Unable to connect to a socket (%s)", strerror(saved_errno));
 if (socket_setopt(cfg.sockfd, IPPROTO_TCP, 1, 1) < 0)
  do_die("%s: " "cannot set socket option TCP_NODELAY", __func__);
 ret = do_trader(&cfg);
 shutdown(cfg.sockfd, SHUT_RDWR);
 if (close(cfg.sockfd) < 0)
  do_die("%s: " "close", __func__);
 return ret;
}

variable_types: struct fix_session_cfg { char sender_comp_id[32]; char target_comp_id[32]; char password[32]; int heartbtint; struct fix_dialect { enum fix_version { FIX_4_0=0, FIX_4_1=1, FIX_4_2=2, FIX_4_3=3, FIX_4_4=4, FIX_5_0=5, FIXT_1_1=6 } version; enum fix_type { FIX_TYPE_INT=0, FIX_TYPE_FLOAT=1, FIX_TYPE_CHAR=2, FIX_TYPE_STRING=3, FIX_TYPE_CHECKSUM=4, FIX_TYPE_MSGSEQNUM=5, FIX_TYPE_STRING_8=6 } (*tag_type)(int tag); } *dialect; int sockfd; unsigned long in_msg_seq_num; unsigned long out_msg_seq_num; void *user_data; }

variable_types:
host
char *

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *

variable_types: port int

variable_types:
ap
char **

variable_types: opt int

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


repo: libtrading/libtrading

decompiled_code:
void __fastcall buffer_munmap(void *ptr)
{
munmap(*((void **)ptr + 3), *((_QWORD *)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
munmap(*((void **)ptr + 3), *((_QWORD *)ptr + 2));
free(ptr);
}

original_code:
void buffer_munmap(struct buffer *buf)
{
 munmap(buf->data, buf->capacity);
 free(buf);
}

variable_types: struct buffer { unsigned long start; unsigned long end; unsigned long capacity; char *data; } *

return_type: void


decompiled_code:
void __fastcall xdp_message_decode(__int64 *a1)
{
__int64 v2; // rdi
__int64 v3; // rsi
size_t v4; // r12
size_t v5; // rcx
const void *v6; // rax
void *v7; // r8

v2 = *a1;
if ( buffer_size_isra_0(v2, a1[1]) )
{
v3 = a1[3];
v4 = (unsigned __int16)buffer_peek_le16_isra_0(v2, v3);
if ( v4 <= v5 )
{
v6 = (const void *)buffer_start_isra_0(v2, v3);
memcpy(v7, v6, v4);
buffer_advance(a1, v4);
}
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 *a1)
{
__int64 v2; // rdi
__int64 v3; // rsi
size_t v4; // r12
size_t v5; // rcx
const void *v6; // rax
void *v7; // r8

v2 = *a1;
if ( func1(v2, a1[1]) )
{
v3 = a1[3];
v4 = (unsigned __int16)func3(v2, v3);
if ( v4 <= v5 )
{
v6 = (const void *)func2(v2, v3);
memcpy(v7, v6, v4);
func0(a1, v4);
}
}
}

original_code:
int xdp_message_decode(struct buffer *buf, struct xdp_message *msg, size_t size)
{
 size_t available;
 u16 msg_size;
 available = buffer_size(buf);
 if (!available)
  return -1;
 msg_size = buffer_peek_le16(buf);
 if (msg_size > size)
  return -1;
 memcpy(msg, buffer_start(buf), msg_size);
 buffer_advance(buf, msg_size);
 return 0;
}

canonical_original_code:
int xdp_message_decode(struct buffer *buf, struct xdp_message *msg, unsigned long size)
{
 unsigned long available;
 unsigned short msg_size;
 available = buffer_size(buf);
 if (!available)
  return -1;
 msg_size = buffer_peek_le16(buf);
 if (msg_size > size)
  return -1;
 memcpy(msg, buffer_start(buf), msg_size);
 buffer_advance(buf, msg_size);
 return 0;
}

variable_types: struct xdp_message { unsigned short MsgSize; unsigned short MsgType; } *

variable_types:
size
unsigned long

variable_types:
available
unsigned long

return_type: int

user_defined_types: struct buffer { unsigned long start; unsigned long end; unsigned long capacity; char *data; }


decompiled_code:
void __fastcall signal_handler(int a1)
{
if ( a1 == 2 )
stop = 1;
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
if ( a1 == 2 )
stop = 1;
}

original_code:
static void signal_handler(int signum)
{
 if (signum == 2)
  stop = 1;
}

variable_types: signum int


DEBUG

repo: licko/mywork

decompiled_code:
int DEBUG(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-1D0h] BYREF
char s[256]; // [rsp+20h] [rbp-1B8h] BYREF

result = g_iDebug;
if ( g_iDebug > 0 )
{
memset(s, 0, sizeof(s));
va_start(arg, format);
vsnprintf(s, 0xFFuLL, format, arg);
result = printf("%s", s);
}
return result;
}

canonical_decompiled_code:
int func0(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-1D0h] BYREF
char s[256]; // [rsp+20h] [rbp-1B8h] BYREF

result = g_iDebug;
if ( g_iDebug > 0 )
{
memset(s, 0, sizeof(s));
va_start(arg, format);
vsnprintf(s, 0xFFuLL, format, arg);
result = printf("%s", s);
}
return result;
}

original_code:
static inline void DEBUG(char *str, ...)
{
 if(g_iDebug > 0)
 {
  va_list va;
  char szBuff[256];
  memset(szBuff, 0, sizeof(szBuff));
  __builtin_va_start(va,str);
  vsnprintf(szBuff, sizeof(szBuff)-1, str, va);
  __builtin_va_end(va);
  printf("%s", szBuff);
 }
    return ;
}

canonical_original_code:
static inline void DEBUG(char *str, ...)
{
 if(g_iDebug > 0)
 {
  __builtin_va_list va;
  char szBuff[256];
  memset(szBuff, 0, sizeof(szBuff));
  __builtin_va_start(va,str);
  vsnprintf(szBuff, sizeof(szBuff)-1, str, va);
  __builtin_va_end(va);
  printf("%s", szBuff);
 }
    return ;
}

variable_types:
str
char *

variable_types:
szBuff
char [256]


decompiled_code:
void __fastcall __noreturn monitor_debug(int msqid)
{
__int64 v2; // rbp
int v3; // er14
int v4; // ebx
int *v5; // r15
int v6; // eax
key_t v7; // er12
int v8; // er14
int v9; // eax
int v10; // er14
FILE *v11; // rax
int i; // er14
__int64 v13; // [rsp+0h] [rbp-88h] BYREF
char file[16]; // [rsp+8h] [rbp-80h] BYREF
__int128 v15; // [rsp+18h] [rbp-70h]
__int128 v16; // [rsp+28h] [rbp-60h]
__int16 v17; // [rsp+38h] [rbp-50h]
char nptr[8]; // [rsp+3Ah] [rbp-4Eh] BYREF
__int16 v19; // [rsp+42h] [rbp-46h]

v2 = (unsigned int)getpid();
printf("pid = %d\n", v2);
v19 = 0;
*(_QWORD *)nptr = 0LL;
v17 = 0;
*(_OWORD *)file = 0LL;
v15 = 0LL;
v16 = 0LL;
if ( dup(1) < 0 )
DEBUG("PID = %d :fd_stdout dup", (unsigned int)v2);
if ( dup(2) < 0 )
DEBUG("PID = %d :fd_stderr dup", (unsigned int)v2);
v3 = 0;
v4 = -1;
v5 = _errno_location();
while ( 1 )
{
do
{
while ( msgrcv(msqid, &v13, 0x3CuLL, (int)v2, 0) >= 0 )
{
v6 = atoi(nptr);
if ( v6 == 1 )
{
g_iDebug = 1;
v8 = 0;
if ( file[0] )
{
while ( 1 )
{
v9 = open(file, 1090);
v4 = v9;
if ( v9 >= 0 || v8 == 5 )
break;
++v8;
DEBUG("PID = %d :flie open", (unsigned int)v2);
}
if ( dup2(v9, 1) < 0 )
DEBUG("PID = %d :fd to STDOUT_FILENO dup2", (unsigned int)v2);
if ( dup2(v4, 2) < 0 )
DEBUG("PID = %d :fd to STDOUT_FILENO dup2", (unsigned int)v2);
setbuf(stdout, 0LL);
setbuf(stderr, 0LL);
}
else
{
v10 = 0;
close(1);
close(2);
while ( 1 )
{
v11 = freopen("/dev/tty", "w", stdout);
if ( v10 == 5 || v11 )
break;
++v10;
DEBUG("PID = %d :freopen stdout\n", (unsigned int)v2);
}
for ( i = 0; !freopen("/dev/tty", "w", stderr) && i != 5; ++i )
DEBUG("PID = %d :freopen stderr\n", (unsigned int)v2);
}
v3 = 1;
DEBUG("*****************PID = %d debug*********************\n", (unsigned int)v2);
}
else if ( !v6 && v3 )
{
g_iDebug = 0;
v3 = 0;
close(v4);
if ( msgctl(msqid, 0, 0LL) < 0 )
DEBUG("PID = %d :msgctl", (unsigned int)v2);
}
}
DEBUG("PID = %d :msgrcv", (unsigned int)v2);
}
while ( *v5 != 43 );
v7 = ftok("/root", 97);
if ( v7 == -1 )
DEBUG("PID = %d :fork", (unsigned int)v2);
msqid = msgget(v7, 950);
if ( msqid == -1 )
DEBUG("PID = %d :msgget", (unsigned int)v2);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func1(int msqid)
{
__int64 v2; // rbp
int v3; // er14
int v4; // ebx
int *v5; // r15
int v6; // eax
key_t v7; // er12
int v8; // er14
int v9; // eax
int v10; // er14
FILE *v11; // rax
int i; // er14
__int64 v13; // [rsp+0h] [rbp-88h] BYREF
char file[16]; // [rsp+8h] [rbp-80h] BYREF
__int128 v15; // [rsp+18h] [rbp-70h]
__int128 v16; // [rsp+28h] [rbp-60h]
__int16 v17; // [rsp+38h] [rbp-50h]
char nptr[8]; // [rsp+3Ah] [rbp-4Eh] BYREF
__int16 v19; // [rsp+42h] [rbp-46h]

v2 = (unsigned int)getpid();
printf("pid = %d\n", v2);
v19 = 0;
*(_QWORD *)nptr = 0LL;
v17 = 0;
*(_OWORD *)file = 0LL;
v15 = 0LL;
v16 = 0LL;
if ( dup(1) < 0 )
func0("PID = %d :fd_stdout dup", (unsigned int)v2);
if ( dup(2) < 0 )
func0("PID = %d :fd_stderr dup", (unsigned int)v2);
v3 = 0;
v4 = -1;
v5 = _errno_location();
while ( 1 )
{
do
{
while ( msgrcv(msqid, &v13, 0x3CuLL, (int)v2, 0) >= 0 )
{
v6 = atoi(nptr);
if ( v6 == 1 )
{
g_iDebug = 1;
v8 = 0;
if ( file[0] )
{
while ( 1 )
{
v9 = open(file, 1090);
v4 = v9;
if ( v9 >= 0 || v8 == 5 )
break;
++v8;
func0("PID = %d :flie open", (unsigned int)v2);
}
if ( dup2(v9, 1) < 0 )
func0("PID = %d :fd to STDOUT_FILENO dup2", (unsigned int)v2);
if ( dup2(v4, 2) < 0 )
func0("PID = %d :fd to STDOUT_FILENO dup2", (unsigned int)v2);
setbuf(stdout, 0LL);
setbuf(stderr, 0LL);
}
else
{
v10 = 0;
close(1);
close(2);
while ( 1 )
{
v11 = freopen("/dev/tty", "w", stdout);
if ( v10 == 5 || v11 )
break;
++v10;
func0("PID = %d :freopen stdout\n", (unsigned int)v2);
}
for ( i = 0; !freopen("/dev/tty", "w", stderr) && i != 5; ++i )
func0("PID = %d :freopen stderr\n", (unsigned int)v2);
}
v3 = 1;
func0("*****************PID = %d debug*********************\n", (unsigned int)v2);
}
else if ( !v6 && v3 )
{
g_iDebug = 0;
v3 = 0;
close(v4);
if ( msgctl(msqid, 0, 0LL) < 0 )
func0("PID = %d :msgctl", (unsigned int)v2);
}
}
func0("PID = %d :msgrcv", (unsigned int)v2);
}
while ( *v5 != 43 );
v7 = ftok("/root", 97);
if ( v7 == -1 )
func0("PID = %d :fork", (unsigned int)v2);
msqid = msgget(v7, 950);
if ( msqid == -1 )
func0("PID = %d :msgget", (unsigned int)v2);
}
}

original_code:
int monitor_debug(void *qqid)
{
 int qid = (int) qqid;
 struct message msg;
 int cmd, fd = -1;
 int old_cmd = 0;
 int fd_stdout;
 int fd_stderr;
 pid_t pid;
 pid = getpid();
 printf("pid = %d\n",pid);
 memset(msg.msg_str.str_switch, 0, 10);
 memset(msg.msg_str.str_file, 0, 50);
 if((fd_stdout = dup(1)) < 0)
 {
  DEBUG("PID = %d :fd_stdout dup", pid);
 }
 if((fd_stderr = dup(2)) < 0)
 {
  DEBUG("PID = %d :fd_stderr dup", pid);
 }
 while(1)
 {
  int nu;
  if(msgrcv(qid, &msg, sizeof(msg.msg_str), pid, 0) < 0)
  {
   int q_id;
   key_t key;
   DEBUG("PID = %d :msgrcv", pid);
   if((*__errno_location ()) == 43)
   { if((key=ftok("/root", 'a'))==-1)
    {
     DEBUG("PID = %d :fork", pid);
    }
    if((q_id=msgget(key, 01000|0666))==-1)
    {
     DEBUG("PID = %d :msgget", pid);
    }
    qid = q_id;
   }
  }
  else
  {
   cmd = atoi(msg.msg_str.str_switch);
   if(cmd == 1)
   {
    g_iDebug = 1;
    if(strcmp(msg.msg_str.str_file, "\0") != 0)
    {
     nu = 0;
     while(((fd = open(msg.msg_str.str_file, 02|0100|02000)) < 0) && nu < 5)
     {
      DEBUG("PID = %d :flie open", pid);
      nu++;
     }
      if((dup2(fd, 1)) < 0)
     {
      DEBUG("PID = %d :fd to STDOUT_FILENO dup2", pid);
     }
     if((dup2(fd, 2)) < 0)
     {
      DEBUG("PID = %d :fd to STDOUT_FILENO dup2", pid);
     }
     setbuf(stdout,((void *)0));
     setbuf(stderr,((void *)0));
    }
    else
    {
     close(1);
     close(2);
     nu = 0;
     while((((void *)0) == freopen("/dev/tty","w",stdout)) && nu < 5)
     {
      nu++;
      DEBUG("PID = %d :freopen stdout\n", pid);
     }
     nu = 0;
     while((((void *)0) == freopen("/dev/tty","w",stderr)) && nu < 5)
     {
      nu++;
      DEBUG("PID = %d :freopen stderr\n", pid);
     }
    }
    DEBUG("*****************PID = %d debug*********************\n", pid);
    old_cmd = cmd;
   }
   if((cmd == 0) && (cmd != old_cmd))
   {
    g_iDebug = 0;
    close(fd);
    old_cmd = cmd;
    if(msgctl(qid,0,((void *)0)) < 0)
    {
     DEBUG("PID = %d :msgctl", pid);
    }
   }
  }
 }
 return 0;
}

canonical_original_code:
int monitor_debug(void *qqid)
{
 int qid = (int) qqid;
 struct message msg;
 int cmd; int fd = -1;
 int old_cmd = 0;
 int fd_stdout;
 int fd_stderr;
 int pid;
 pid = getpid();
 printf("pid = %d\n",pid);
 memset(msg.msg_str.str_switch, 0, 10);
 memset(msg.msg_str.str_file, 0, 50);
 if((fd_stdout = dup(1)) < 0)
 {
  DEBUG("PID = %d :fd_stdout dup", pid);
 }
 if((fd_stderr = dup(2)) < 0)
 {
  DEBUG("PID = %d :fd_stderr dup", pid);
 }
 while(1)
 {
  int nu;
  if(msgrcv(qid, &msg, sizeof(msg.msg_str), pid, 0) < 0)
  {
   int q_id;
   int key;
   DEBUG("PID = %d :msgrcv", pid);
   if((*__errno_location ()) == 43)
   { if((key=ftok("/root", 'a'))==-1)
    {
     DEBUG("PID = %d :fork", pid);
    }
    if((q_id=msgget(key, 01000|0666))==-1)
    {
     DEBUG("PID = %d :msgget", pid);
    }
    qid = q_id;
   }
  }
  else
  {
   cmd = atoi(msg.msg_str.str_switch);
   if(cmd == 1)
   {
    g_iDebug = 1;
    if(strcmp(msg.msg_str.str_file, "\0") != 0)
    {
     nu = 0;
     while(((fd = open(msg.msg_str.str_file, 02|0100|02000)) < 0) && nu < 5)
     {
      DEBUG("PID = %d :flie open", pid);
      nu++;
     }
      if((dup2(fd, 1)) < 0)
     {
      DEBUG("PID = %d :fd to STDOUT_FILENO dup2", pid);
     }
     if((dup2(fd, 2)) < 0)
     {
      DEBUG("PID = %d :fd to STDOUT_FILENO dup2", pid);
     }
     setbuf(stdout,((void *)0));
     setbuf(stderr,((void *)0));
    }
    else
    {
     close(1);
     close(2);
     nu = 0;
     while((((void *)0) == freopen("/dev/tty","w",stdout)) && nu < 5)
     {
      nu++;
      DEBUG("PID = %d :freopen stdout\n", pid);
     }
     nu = 0;
     while((((void *)0) == freopen("/dev/tty","w",stderr)) && nu < 5)
     {
      nu++;
      DEBUG("PID = %d :freopen stderr\n", pid);
     }
    }
    DEBUG("*****************PID = %d debug*********************\n", pid);
    old_cmd = cmd;
   }
   if((cmd == 0) && (cmd != old_cmd))
   {
    g_iDebug = 0;
    close(fd);
    old_cmd = cmd;
    if(msgctl(qid,0,((void *)0)) < 0)
    {
     DEBUG("PID = %d :msgctl", pid);
    }
   }
  }
 }
 return 0;
}

variable_types:
qqid
void *

variable_types: qid int

variable_types: struct message { long msg_pid; struct str_str { char str_file[50]; char str_switch[10]; } msg_str; }

variable_types: cmd int

variable_types: fd int

variable_types: pid int

variable_types: nu int

variable_types: key int

user_defined_types: struct message { long msg_pid; struct str_str msg_str; }


help

decompiled_code:
void __noreturn help()
{
puts("**********TURN ON DEBUG**********!");
puts("*Please enter debug program pid(-p pid)!");
puts("*please enter turn on debug(-s 1) or turn off debug(-s 0)!");
puts("*please enter file path (-f path)");
puts("*FORMAT# program -p pid -s 1 -f path ");
puts("**********TURN OFF DEBUG**********!");
puts("*Please enter debug program pid(-p pid)!");
puts("*please enter turn on debug(-s 1) or turn off debug(-s 0)!");
puts("*FORMAT# program -p pid -s 0 ");
exit(0);
}

canonical_decompiled_code:
void __noreturn func0()
{
puts("**********TURN ON DEBUG**********!");
puts("*Please enter debug program pid(-p pid)!");
puts("*please enter turn on debug(-s 1) or turn off debug(-s 0)!");
puts("*please enter file path (-f path)");
puts("*FORMAT# program -p pid -s 1 -f path ");
puts("**********TURN OFF DEBUG**********!");
puts("*Please enter debug program pid(-p pid)!");
puts("*please enter turn on debug(-s 1) or turn off debug(-s 0)!");
puts("*FORMAT# program -p pid -s 0 ");
exit(0);
}

original_code:
void help()
{
 printf("**********TURN ON DEBUG**********!\n");
 printf("*Please enter debug program pid(-p pid)!\n");
 printf("*please enter turn on debug(-s 1) or turn off debug(-s 0)!\n");
 printf("*please enter file path (-f path)\n");
 printf("*FORMAT# program -p pid -s 1 -f path \n");
 printf("**********TURN OFF DEBUG**********!\n");
 printf("*Please enter debug program pid(-p pid)!\n");
 printf("*please enter turn on debug(-s 1) or turn off debug(-s 0)!\n");
 printf("*FORMAT# program -p pid -s 0 \n");
 exit(0);
}


decompiled_code:
__int64 __fastcall get_parameter(int argc, char **argv, __int64 a3)
{
char *v3; // r13
int v5; // eax
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // r8
__int64 v9; // r9
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // r8
__int64 v13; // r9
int v14; // eax
struct option v16; // [rsp+0h] [rbp-88h] BYREF
const char *v17; // [rsp+20h] [rbp-68h]
int v18; // [rsp+28h] [rbp-60h]
__int64 v19; // [rsp+30h] [rbp-58h]
int v20; // [rsp+38h] [rbp-50h]
const char *v21; // [rsp+40h] [rbp-48h]
int v22; // [rsp+48h] [rbp-40h]
__int64 v23; // [rsp+50h] [rbp-38h]
int v24; // [rsp+58h] [rbp-30h]

v3 = (char *)(a3 + 58);
v16.name = "pid";
v16.has_arg = 1;
v16.flag = 0LL;
v16.val = 112;
v17 = "switch";
v18 = 1;
v19 = 0LL;
v20 = 115;
v21 = "file";
v22 = 1;
v23 = 0LL;
v24 = 102;
while ( 1 )
{
v5 = getopt_long(argc, argv, "p:s:f:", &v16, 0LL);
if ( v5 == -1 )
break;
if ( v5 == 112 )
{
*(_QWORD *)a3 = atoi(optarg);
}
else if ( v5 == 115 )
{
strncpy(v3, optarg, 0xAuLL);
}
else
{
if ( v5 != 102 )
{
printf("You should look for help!\n ");
help(
"You should look for help!\n ",
argv,
v10,
v11,
v12,
v13,
v16.name,
v16.has_arg,
v16.flag,
v16.val,
v17,
v18);
}
strncpy((char *)(a3 + 8), optarg, 0x32uLL);
}
}
if ( *(_QWORD *)a3 == -1LL )
goto LABEL_13;
v14 = *(unsigned __int8 *)(a3 + 58);
v6 = a3 + 58;
if ( v14 == 49 && !*(_BYTE *)(a3 + 59) )
return 0LL;
if ( v14 != 48 || *(_BYTE *)(a3 + 59) )
LABEL_13:
help((unsigned int)argc, argv, v6, v7, v8, v9, v16.name, v16.has_arg, v16.flag, v16.val, v17, v18);
return 0LL;
}

original_code:
int get_parameter(int argc, char *argv[], struct message *msg)
{
 int opt;
 struct option long_options[] = {
    {"pid", 1, ((void *)0), 'p'},
    {"switch", 1, ((void *)0), 's'},
    {"file", 1, ((void *)0), 'f'},
 };
 while((opt = getopt_long(argc, argv, "p:s:f:", long_options, ((void *)0))) != -1)
 {
  switch (opt)
  {
   case 'p':
    msg->msg_pid=atoi(optarg);
   break;
   case 's':
    strncpy(msg->msg_str.str_switch, optarg,sizeof(msg->msg_str.str_switch));
   break;
   case 'f':
    strncpy(msg->msg_str.str_file, optarg,sizeof(msg->msg_str.str_file));
   break;
   default:
       printf("You should look for help!\n ");
    help();
   break;
  }
 }
 if(( -1 != msg->msg_pid) && ((strcmp(msg->msg_str.str_switch, "1") == 0 ) ||
    (strcmp(msg->msg_str.str_switch, "0") == 0)));
 else
 {
  help();
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct message { long msg_pid; struct str_str { char str_file[50]; char str_switch[10]; } msg_str; } *

variable_types: struct option { char *name; int has_arg; int *flag; int val; } []


main

canonical_name: main

original_code:
int main(int argc, char *argv[])
{
 int qid;
 key_t key;
 struct message msg;
 msg.msg_pid = -1;
 memset(msg.msg_str.str_file, 0, 50);
 strcpy(msg.msg_str.str_file,"\0");
 if((key=ftok("/root", 'a'))==-1)
 {
  perror("ftok");
  return -1;
 }
 if((qid=msgget(key, 01000|0666))==-1)
 {
  perror("msgget");
  return -1 ;
 }
 get_parameter(argc, argv, &msg);
 if(msgsnd(qid, &msg, sizeof(msg.msg_str), 0)<0)
 {
  perror("msgsnd");
  help();
 }
 printf("Command effective!\n");
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int qid;
 int key;
 struct message msg;
 msg.msg_pid = -1;
 memset(msg.msg_str.str_file, 0, 50);
 strcpy(msg.msg_str.str_file,"\0");
 if((key=ftok("/root", 'a'))==-1)
 {
  perror("ftok");
  return -1;
 }
 if((qid=msgget(key, 01000|0666))==-1)
 {
  perror("msgget");
  return -1 ;
 }
 get_parameter(argc, argv, &msg);
 if(msgsnd(qid, &msg, sizeof(msg.msg_str), 0)<0)
 {
  perror("msgsnd");
  help();
 }
 printf("Command effective!\n");
 return 0;
}

user_defined_types: struct str_str { char str_file[50]; char str_switch[10]; }


decompiled_code:
__int64 init_debug_notify()
{
unsigned int v0; // ebp
key_t v1; // eax
unsigned int v2; // er12
int v3; // eax
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

v0 = getpid();
v1 = ftok("/root", 97);
v2 = v1;
if ( v1 == -1 )
{
printf("PID = %d :fork", v0);
}
else
{
v3 = msgget(v1, 950);
v2 = v3;
if ( v3 == -1 )
{
printf("PID = %d :msgget", v0);
}
else
{
v2 = pthread_create(newthread, 0LL, (void *(*)(void *))&monitor_debug, (void *)v3);
if ( v2 )
{
v2 = -1;
DEBUG_constprop_0((__int64)"PID = %dpthread_create", v0);
}
}
}
return v2;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // ebp
key_t v1; // eax
unsigned int v2; // er12
int v3; // eax
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

v0 = getpid();
v1 = ftok("/root", 97);
v2 = v1;
if ( v1 == -1 )
{
printf("PID = %d :fork", v0);
}
else
{
v3 = msgget(v1, 950);
v2 = v3;
if ( v3 == -1 )
{
printf("PID = %d :msgget", v0);
}
else
{
v2 = pthread_create(newthread, 0LL, (void *(*)(void *))&monitor_debug, (void *)v3);
if ( v2 )
{
v2 = -1;
func0((__int64)"PID = %dpthread_create", v0);
}
}
}
return v2;
}

original_code:
int init_debug_notify()
{
 int qid;
 key_t key;
 pthread_t tid;
 pid_t pid;
 pid = getpid();
 if((key=ftok("/root", 'a'))==-1)
 {
  printf("PID = %d :fork", pid);
  return -1;
 }
 if((qid=msgget(key, 01000|0666))==-1)
 {
  printf("PID = %d :msgget", pid);
  return -1;
 }
 int result = pthread_create(&tid, ((void *)0), (void*)monitor_debug, (void *)qid);
    if(result != 0)
 {
     DEBUG("PID = %dpthread_create", pid);
     return -1;
    }
 return 0;
}

canonical_original_code:
int init_debug_notify()
{
 int qid;
 int key;
 unsigned long tid;
 int pid;
 pid = getpid();
 if((key=ftok("/root", 'a'))==-1)
 {
  printf("PID = %d :fork", pid);
  return -1;
 }
 if((qid=msgget(key, 01000|0666))==-1)
 {
  printf("PID = %d :msgget", pid);
  return -1;
 }
 int result = pthread_create(&tid, ((void *)0), (void*)monitor_debug, (void *)qid);
    if(result != 0)
 {
     DEBUG("PID = %dpthread_create", pid);
     return -1;
    }
 return 0;
}

variable_types:
tid
unsigned long

variable_types: result int


repo: licko/timelib

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
struct tm *v3; // rax
char *v4; // rax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
struct tm *v8; // rax
__int64 v9; // rax
__int64 v10; // rax
time_t timer; // [rsp+8h] [rbp-50h] BYREF
char v13[72]; // [rsp+10h] [rbp-48h] BYREF

timer = GetCurrentTime(argc, argv, envp);
printf("timer = %ld \n", timer);
v3 = localtime(&timer);
v4 = asctime(v3);
printf("%s", v4);
v5 = GetDay(timer);
printf("day = %d \n", v5);
v6 = GetMonth(timer);
printf("month = %d \n", v6);
v7 = GetYear(timer);
printf("year = %d \n", v7);
v8 = localtime(&timer);
v9 = GetTimeByYMDHMS(
(unsigned int)(v8->tm_year + 1900),
(unsigned int)(v8->tm_mon + 1),
(unsigned int)v8->tm_mday,
(unsigned int)v8->tm_hour,
(unsigned int)v8->tm_min,
(unsigned int)v8->tm_sec);
printf("1ptm = %ld\n", v9);
TimeFormat(timer, "Y-*M-D:H-M)S", v13, 21LL);
printf("tmp = %s\n", v13);
v10 = GetTimeByString("2012@03.29.14.23.09");
printf("Getptm = %ld\n", v10);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
struct tm *v3; // rax
char *v4; // rax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
struct tm *v8; // rax
__int64 v9; // rax
__int64 v10; // rax
time_t timer; // [rsp+8h] [rbp-50h] BYREF
char v13[72]; // [rsp+10h] [rbp-48h] BYREF

timer = func12(argc, argv, envp);
printf("timer = %ld \n", timer);
v3 = localtime(&timer);
v4 = asctime(v3);
printf("%s", v4);
v5 = func11(timer);
printf("day = %d \n", v5);
v6 = func10(timer);
printf("month = %d \n", v6);
v7 = func9(timer);
printf("year = %d \n", v7);
v8 = localtime(&timer);
v9 = func14(
(unsigned int)(v8->tm_year + 1900),
(unsigned int)(v8->tm_mon + 1),
(unsigned int)v8->tm_mday,
(unsigned int)v8->tm_hour,
(unsigned int)v8->tm_min,
(unsigned int)v8->tm_sec);
printf("1ptm = %ld\n", v9);
func8(timer, "Y-*M-D:H-M)S", v13, 21LL);
printf("tmp = %s\n", v13);
v10 = func15("2012@03.29.14.23.09");
printf("Getptm = %ld\n", v10);
return 0;
}

original_code:
int main()
{
 time_t timer = GetCurrentTime();
 printf("timer = %ld \n", timer);
 printf("%s", asctime(localtime(&timer)));
 printf("day = %d \n", GetDay(timer));
 printf("month = %d \n", GetMonth(timer));
 printf("year = %d \n", GetYear(timer));
 struct tm *p_tm = localtime(&timer);
 ULONG timm = GetTimeByYMDHMS(p_tm->tm_year + 1900, p_tm->tm_mon + 1,p_tm->tm_mday,
       p_tm->tm_hour,p_tm->tm_min,p_tm->tm_sec);
  printf("1ptm = %ld\n", timm);
 char tmp[50];
 TimeFormat(timer, "Y-*M-D:H-M)S", tmp, 21);
 printf("tmp  = %s\n", tmp);
 printf("Getptm = %ld\n", GetTimeByString("2012@03.29.14.23.09"));
 return 0;
}

canonical_original_code:
int main()
{
 long timer = GetCurrentTime();
 printf("timer = %ld \n", timer);
 printf("%s", asctime(localtime(&timer)));
 printf("day = %d \n", GetDay(timer));
 printf("month = %d \n", GetMonth(timer));
 printf("year = %d \n", GetYear(timer));
 struct tm *p_tm = localtime(&timer);
 unsigned long timm = GetTimeByYMDHMS(p_tm->tm_year + 1900, p_tm->tm_mon + 1,p_tm->tm_mday,
       p_tm->tm_hour,p_tm->tm_min,p_tm->tm_sec);
  printf("1ptm = %ld\n", timm);
 char tmp[50];
 TimeFormat(timer, "Y-*M-D:H-M)S", tmp, 21);
 printf("tmp  = %s\n", tmp);
 printf("Getptm = %ld\n", GetTimeByString("2012@03.29.14.23.09"));
 return 0;
}

variable_types: timer long

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types:
timm
unsigned long

variable_types:
tmp
char [50]


FindMark

original_code:
int FindMark(char *pszFormat)
{
 char *fmat= pszFormat;
 int place = 0;
 while(*fmat != 'Y' && *fmat != 'y' && *fmat != 'M' && *fmat != 'm' && *fmat != 'D' && *fmat != 'd' && *fmat != 'H' && *fmat != 'h' && *fmat != 'S' && *fmat != 's' && *fmat != '\0')
 {
  fmat++;
  place++;
 }
 return place;
}

canonical_original_code:
int FindMark(char *pszFormat)
{
 char *fmat = pszFormat;
 int place = 0;
 while(*fmat != 'Y' && *fmat != 'y' && *fmat != 'M' && *fmat != 'm' && *fmat != 'D' && *fmat != 'd' && *fmat != 'H' && *fmat != 'h' && *fmat != 'S' && *fmat != 's' && *fmat != '\0')
 {
  fmat++;
  place++;
 }
 return place;
}

variable_types:
pszFormat
char *

variable_types:
fmat
char *

variable_types: place int


TimeFormat

decompiled_code:
size_t __fastcall TimeFormat(time_t a1, __int64 a2, const char *a3, int a4)
{
int v5; // er14
int v6; // er13
__int64 v7; // r12
size_t result; // rax
const char *v9; // rbp
char *v10; // rdi
__int64 v11; // rdx
char v12; // r8
int v13; // er14
const char *v14; // rbp
__int64 v15; // rbx
char *v16; // rdi
__int64 v17; // rdx
int v18; // eax
int v19; // [rsp+0h] [rbp-58h]
struct tm *v21; // [rsp+8h] [rbp-50h]
char dest[4]; // [rsp+13h] [rbp-45h] BYREF
char v23; // [rsp+17h] [rbp-41h]
time_t timer; // [rsp+18h] [rbp-40h] BYREF

v5 = a4;
v6 = a4;
v7 = 0LL;
timer = a1;
v21 = localtime(&timer);
result = FindMark(a2);
v19 = 0;
v9 = (const char *)((int)result + a2);
if ( v5 > 0 )
{
do
{
v12 = *v9;
if ( !*v9 )
break;
v13 = v12;
*(_DWORD *)dest = 0;
v23 = 0;
if ( v12 > 96 )
v13 = v12 - 32;
v14 = v9 + 1;
result = FindMark((__int64)v14);
v15 = (int)result;
if ( (int)result > 0 )
{
if ( (int)result > 4 )
return result;
v15 = (int)result;
strncpy(dest, v14, (int)result);
}
v9 = &v14[v15];
result = strlen(dest) + 2;
if ( v19 == 72 && v13 == 77 )
{
if ( result > v6 )
return result;
LABEL_4:
v10 = (char *)&a3[v7];
v11 = (unsigned int)v21->tm_min;
if ( (int)v11 > 9 )
sprintf(v10, "%d%s", v11, dest);
else
sprintf(v10, "0%d%s", v11, dest);
v19 = 78;
}
else
{
if ( result > v6 )
return result;
switch ( v13 )
{
case 'D':
v16 = (char *)&a3[v7];
v17 = (unsigned int)v21->tm_mday;
if ( (int)v17 <= 9 )
goto LABEL_21;
goto LABEL_23;
case 'H':
v16 = (char *)&a3[v7];
v17 = (unsigned int)v21->tm_hour;
if ( (int)v17 <= 9 )
goto LABEL_21;
goto LABEL_23;
case 'M':
v16 = (char *)&a3[v7];
v18 = v21->tm_mon;
v17 = (unsigned int)(v18 + 1);
if ( v18 > 9 )
goto LABEL_23;
goto LABEL_21;
case 'N':
goto LABEL_4;
case 'S':
v16 = (char *)&a3[v7];
v17 = (unsigned int)v21->tm_sec;
if ( (int)v17 > 9 )
{
LABEL_23:
sprintf(v16, "%d%s", v17, dest);
v19 = v13;
}
else
{
LABEL_21:
sprintf(v16, "0%d%s", v17, dest);
v19 = v13;
}
break;
case 'Y':
sprintf((char *)&a3[(int)v7], "%d%s", (unsigned int)(v21->tm_year + 1900), dest);
v19 = v13;
break;
default:
v19 = v13;
break;
}
}
result = strlen(a3);
v7 = (int)result;
v6 = a4 - result;
}
while ( a4 - (int)result > 0 );
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func8(time_t a1, __int64 a2, const char *a3, int a4)
{
int v5; // er14
int v6; // er13
__int64 v7; // r12
size_t result; // rax
const char *v9; // rbp
char *v10; // rdi
__int64 v11; // rdx
char v12; // r8
int v13; // er14
const char *v14; // rbp
__int64 v15; // rbx
char *v16; // rdi
__int64 v17; // rdx
int v18; // eax
int v19; // [rsp+0h] [rbp-58h]
struct tm *v21; // [rsp+8h] [rbp-50h]
char dest[4]; // [rsp+13h] [rbp-45h] BYREF
char v23; // [rsp+17h] [rbp-41h]
time_t timer; // [rsp+18h] [rbp-40h] BYREF

v5 = a4;
v6 = a4;
v7 = 0LL;
timer = a1;
v21 = localtime(&timer);
result = func7(a2);
v19 = 0;
v9 = (const char *)((int)result + a2);
if ( v5 > 0 )
{
do
{
v12 = *v9;
if ( !*v9 )
break;
v13 = v12;
*(_DWORD *)dest = 0;
v23 = 0;
if ( v12 > 96 )
v13 = v12 - 32;
v14 = v9 + 1;
result = func7((__int64)v14);
v15 = (int)result;
if ( (int)result > 0 )
{
if ( (int)result > 4 )
return result;
v15 = (int)result;
strncpy(dest, v14, (int)result);
}
v9 = &v14[v15];
result = strlen(dest) + 2;
if ( v19 == 72 && v13 == 77 )
{
if ( result > v6 )
return result;
LABEL_4:
v10 = (char *)&a3[v7];
v11 = (unsigned int)v21->tm_min;
if ( (int)v11 > 9 )
sprintf(v10, "%d%s", v11, dest);
else
sprintf(v10, "0%d%s", v11, dest);
v19 = 78;
}
else
{
if ( result > v6 )
return result;
switch ( v13 )
{
case 'D':
v16 = (char *)&a3[v7];
v17 = (unsigned int)v21->tm_mday;
if ( (int)v17 <= 9 )
goto LABEL_21;
goto LABEL_23;
case 'H':
v16 = (char *)&a3[v7];
v17 = (unsigned int)v21->tm_hour;
if ( (int)v17 <= 9 )
goto LABEL_21;
goto LABEL_23;
case 'M':
v16 = (char *)&a3[v7];
v18 = v21->tm_mon;
v17 = (unsigned int)(v18 + 1);
if ( v18 > 9 )
goto LABEL_23;
goto LABEL_21;
case 'N':
goto LABEL_4;
case 'S':
v16 = (char *)&a3[v7];
v17 = (unsigned int)v21->tm_sec;
if ( (int)v17 > 9 )
{
LABEL_23:
sprintf(v16, "%d%s", v17, dest);
v19 = v13;
}
else
{
LABEL_21:
sprintf(v16, "0%d%s", v17, dest);
v19 = v13;
}
break;
case 'Y':
sprintf((char *)&a3[(int)v7], "%d%s", (unsigned int)(v21->tm_year + 1900), dest);
v19 = v13;
break;
default:
v19 = v13;
break;
}
}
result = strlen(a3);
v7 = (int)result;
v6 = a4 - result;
}
while ( a4 - (int)result > 0 );
}
return result;
}

original_code:
void TimeFormat(ULONG iTime,char *pszFormat,char *pszTimeString,int iStringLen)
{
 time_t tim = (time_t) iTime;
 char *str = pszTimeString;
 char *fmat= pszFormat;
 struct tm *p_tm;
 p_tm = localtime(&tim);
 int last ;
 int mark = 0;
 int slen = 0;
 fmat = fmat + FindMark(fmat) ;
 while((iStringLen - slen) > 0 && (*fmat != '\0'))
 {
  char delimiter[5]= {0};
  last = mark;
  mark = *fmat;
  if(mark > 96)
  {
   mark -= 32;
  }
  fmat = fmat + 1;
  int next = FindMark(fmat);
  if(next > 0)
  {
   if(next < 5)
   {
    strncpy(delimiter, fmat , next);
   }
   else
   { return;
   }
  }
  if((last == 'H') && (mark == 'M'))
  {
   mark = 'N';
  }
  fmat = fmat + next;
  if(strlen(delimiter) + 2 > (iStringLen - slen))
   return;
  switch (mark)
  {
   case 'Y' :
     sprintf(str+slen,"%d%s",p_tm->tm_year + 1900, delimiter);
     break;
   case 'M' :
    if(p_tm->tm_mon <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_mon + 1, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_mon + 1, delimiter);
     break;
   case 'D' :
    if(p_tm->tm_mday <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_mday, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_mday, delimiter);
     break;
   case 'H' :
    if(p_tm->tm_hour <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_hour, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_hour, delimiter);
     break;
   case 'N' :
    if(p_tm->tm_min <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_min, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_min, delimiter);
     break;
   case 'S' :
    if(p_tm->tm_sec <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_sec, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_sec, delimiter);
     break;
  }
  slen = strlen(str);
 }
}

canonical_original_code:
void TimeFormat(unsigned long iTime, char *pszFormat, char *pszTimeString, int iStringLen)
{
 long tim = (time_t) iTime;
 char *str = pszTimeString;
 char *fmat = pszFormat;
 struct tm *p_tm;
 p_tm = localtime(&tim);
 int last;
 int mark = 0;
 int slen = 0;
 fmat = fmat + FindMark(fmat) ;
 while((iStringLen - slen) > 0 && (*fmat != '\0'))
 {
  char delimiter[5] = {0};
  last = mark;
  mark = *fmat;
  if(mark > 96)
  {
   mark -= 32;
  }
  fmat = fmat + 1;
  int next = FindMark(fmat);
  if(next > 0)
  {
   if(next < 5)
   {
    strncpy(delimiter, fmat , next);
   }
   else
   { return;
   }
  }
  if((last == 'H') && (mark == 'M'))
  {
   mark = 'N';
  }
  fmat = fmat + next;
  if(strlen(delimiter) + 2 > (iStringLen - slen))
   return;
  switch (mark)
  {
   case 'Y' :
     sprintf(str+slen,"%d%s",p_tm->tm_year + 1900, delimiter);
     break;
   case 'M' :
    if(p_tm->tm_mon <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_mon + 1, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_mon + 1, delimiter);
     break;
   case 'D' :
    if(p_tm->tm_mday <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_mday, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_mday, delimiter);
     break;
   case 'H' :
    if(p_tm->tm_hour <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_hour, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_hour, delimiter);
     break;
   case 'N' :
    if(p_tm->tm_min <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_min, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_min, delimiter);
     break;
   case 'S' :
    if(p_tm->tm_sec <10)
     sprintf(str+slen,"0%d%s",p_tm->tm_sec, delimiter);
    else
     sprintf(str+slen,"%d%s",p_tm->tm_sec, delimiter);
     break;
  }
  slen = strlen(str);
 }
}

variable_types:
iTime
unsigned long

variable_types:
pszTimeString
char *

variable_types: iStringLen int

variable_types: tim long

variable_types:
str
char *

variable_types: last int

variable_types: mark int

variable_types: slen int

variable_types:
delimiter
char [5]

variable_types: next int

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


GetYear

decompiled_code:
__int64 __fastcall GetYear(time_t a1)
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
return (unsigned int)(localtime(&timer)->tm_year + 1900);
}

canonical_decompiled_code:
__int64 __fastcall func9(time_t a1)
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
return (unsigned int)(localtime(&timer)->tm_year + 1900);
}

original_code:
int GetYear(ULONG iTime)
{
 time_t tim = (time_t) iTime;
 struct tm *p_tm;
 p_tm = localtime(&tim);
 return (1900 + p_tm->tm_year);
}

canonical_original_code:
int GetYear(unsigned long iTime)
{
 long tim = (time_t) iTime;
 struct tm *p_tm;
 p_tm = localtime(&tim);
 return (1900 + p_tm->tm_year);
}


GetMonth

decompiled_code:
__int64 __fastcall GetMonth(time_t a1)
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
return (unsigned int)(localtime(&timer)->tm_mon + 1);
}

canonical_decompiled_code:
__int64 __fastcall func10(time_t a1)
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
return (unsigned int)(localtime(&timer)->tm_mon + 1);
}

original_code:
int GetMonth(ULONG iTime)
{
 time_t tim = (time_t) iTime;
 struct tm *p_tm;
 p_tm = localtime(&tim);
 return (1 + p_tm->tm_mon);
}

canonical_original_code:
int GetMonth(unsigned long iTime)
{
 long tim = (time_t) iTime;
 struct tm *p_tm;
 p_tm = localtime(&tim);
 return (1 + p_tm->tm_mon);
}


GetDay

decompiled_code:
__int64 __fastcall GetDay(time_t a1)
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
return (unsigned int)localtime(&timer)->tm_mday;
}

canonical_decompiled_code:
__int64 __fastcall func11(time_t a1)
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
return (unsigned int)localtime(&timer)->tm_mday;
}

original_code:
int GetDay(ULONG iTime)
{
 time_t tim = (time_t) iTime;
 struct tm *p_tm;
 p_tm = localtime(&tim);
 return p_tm->tm_mday;
}

canonical_original_code:
int GetDay(unsigned long iTime)
{
 long tim = (time_t) iTime;
 struct tm *p_tm;
 p_tm = localtime(&tim);
 return p_tm->tm_mday;
}


GetCurrentTime

decompiled_code:
time_t GetCurrentTime()
{
return time(0LL);
}

canonical_decompiled_code:
time_t func12()
{
return time(0LL);
}

original_code:
ULONG GetCurrentTime()
{
 ULONG seconds;
 if( (seconds = time(((void *)0))) < 0)
 {
  perror("time\n");
 }
 return seconds;
}

canonical_original_code:
unsigned long GetCurrentTime()
{
 unsigned long seconds;
 if( (seconds = time(((void *)0))) < 0)
 {
  perror("time\n");
 }
 return seconds;
}

variable_types:
seconds
unsigned long

return_type: unsigned long


FindNumber

decompiled_code:
__int64 __fastcall FindNumber(_BYTE *a1)
{
unsigned int v1; // er8
char v2; // al

v1 = 0;
if ( (unsigned __int8)(*a1 - 48) > 9u )
{
do
{
v2 = *++a1;
++v1;
}
while ( (unsigned __int8)(v2 - 48) > 9u );
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func13(_BYTE *a1)
{
unsigned int v1; // er8
char v2; // al

v1 = 0;
if ( (unsigned __int8)(*a1 - 48) > 9u )
{
do
{
v2 = *++a1;
++v1;
}
while ( (unsigned __int8)(v2 - 48) > 9u );
}
return v1;
}

original_code:
int FindNumber(char *pszTimeString)
{
 char *tmp = pszTimeString;
 int place = 0;
 while(*tmp < '0' || *tmp > '9')
 {
  tmp++;
  place++;
 }
 return place;
}

variable_types:
tmp
char *


GetTimeByYMDHMS

decompiled_code:
time_t __fastcall GetTimeByYMDHMS(int a1, int a2, int a3, int a4, int a5, int a6)
{
struct tm v7; // [rsp+0h] [rbp-48h] BYREF

v7.tm_year = a1 - 1900;
v7.tm_sec = a6;
v7.tm_min = a5;
v7.tm_hour = a4;
v7.tm_mday = a3;
v7.tm_mon = a2 - 1;
return mktime(&v7);
}

canonical_decompiled_code:
time_t __fastcall func14(int a1, int a2, int a3, int a4, int a5, int a6)
{
struct tm v7; // [rsp+0h] [rbp-48h] BYREF

v7.tm_year = a1 - 1900;
v7.tm_sec = a6;
v7.tm_min = a5;
v7.tm_hour = a4;
v7.tm_mday = a3;
v7.tm_mon = a2 - 1;
return mktime(&v7);
}

original_code:
ULONG GetTimeByYMDHMS(int iYear,int iMonth,int iDay,int iHour,int iMinute,int iSecond)
{
 struct tm p_tm;
 time_t timep;
 p_tm.tm_sec = iSecond;
 p_tm.tm_min = iMinute;
 p_tm.tm_hour = iHour;
 p_tm.tm_mday = iDay ;
 p_tm.tm_mon = iMonth - 1;
 p_tm.tm_year = iYear - 1900;
 timep = mktime(&p_tm);
 return ((ULONG) timep);
}

canonical_original_code:
unsigned long GetTimeByYMDHMS(int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond)
{
 struct tm p_tm;
 long timep;
 p_tm.tm_sec = iSecond;
 p_tm.tm_min = iMinute;
 p_tm.tm_hour = iHour;
 p_tm.tm_mday = iDay ;
 p_tm.tm_mon = iMonth - 1;
 p_tm.tm_year = iYear - 1900;
 timep = mktime(&p_tm);
 return ((unsigned long) timep);
}

variable_types: iYear int

variable_types: iMonth int

variable_types: iDay int

variable_types: iHour int

variable_types: iMinute int

variable_types: iSecond int

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }

variable_types: timep long


GetTimeByString

decompiled_code:
time_t __fastcall GetTimeByString(char *a1)
{
__int64 i; // r12
int v3; // eax
const char *v4; // rsi
size_t v5; // rdx
char dest[4]; // [rsp+Bh] [rbp-3Dh] BYREF
char v8; // [rsp+Fh] [rbp-39h]
int v9[14]; // [rsp+10h] [rbp-38h]

for ( i = 0LL; i != 6; ++i )
{
v3 = FindNumber(a1);
v8 = 0;
*(_DWORD *)dest = 0;
v4 = &a1[v3];
v5 = i == 0 ? 4LL : 2LL;
a1 = (char *)&v4[v5];
strncpy(dest, v4, v5);
v9[i] = atoi(dest);
}
return GetTimeByYMDHMS(v9[0], v9[1], v9[2], v9[3], v9[4], v9[5]);
}

original_code:
ULONG GetTimeByString(char *pszTimeString)
{
 char *tmp = pszTimeString;
 int time[6] ;
 int i = 0;
 int len ;
 int timers = 6;
 while(timers--)
 {
  tmp = tmp + FindNumber(tmp);
  char str[5] = {0};
  if(i == 0)
  {
   len = 4;
  }
  else
  {
   len = 2;
  }
  strncpy(str, tmp, len);
  tmp = tmp + len;
  time[i] = atoi(str);
  i++;
 }
 ULONG timep = GetTimeByYMDHMS(time[0], time[1], time[2], time[3], time[4], time[5]);
 return timep;
}

canonical_original_code:
unsigned long GetTimeByString(char *pszTimeString)
{
 char *tmp = pszTimeString;
 int time[6];
 int i = 0;
 int len;
 int timers = 6;
 while(timers--)
 {
  tmp = tmp + FindNumber(tmp);
  char str[5] = {0};
  if(i == 0)
  {
   len = 4;
  }
  else
  {
   len = 2;
  }
  strncpy(str, tmp, len);
  tmp = tmp + len;
  time[i] = atoi(str);
  i++;
 }
 unsigned long timep = GetTimeByYMDHMS(time[0], time[1], time[2], time[3], time[4], time[5]);
 return timep;
}

variable_types:
pszTimeString
char *

variable_types:
time
int [6]

variable_types: i int

variable_types: len int

variable_types: timers int

variable_types:
str
char [5]

variable_types:
timep
unsigned long


decompiled_code:
__int64 __fastcall make_atom(int a1, int a2)
{
_DWORD *v2; // rdx
__int64 result; // rax

v2 = (_DWORD *)(the_cons_cells + 8LL * free_point);
result = free_point;
*v2 = a1;
v2[1] = a2;
free_point = result + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
_DWORD *v2; // rdx
__int64 result; // rax

v2 = (_DWORD *)(the_cons_cells + 8LL * free_point);
result = free_point;
*v2 = a1;
v2[1] = a2;
free_point = result + 1;
return result;
}

original_code:
static cellpoint make_atom(uint type, uint val)
{
 the_cons_cells[free_point].car = type;
 the_cons_cells[free_point].cdr = val;
 return free_point++;
}

canonical_original_code:
static unsigned int make_atom(unsigned int type, unsigned int val)
{
 the_cons_cells[free_point].car = type;
 the_cons_cells[free_point].cdr = val;
 return free_point++;
}

variable_types:
type
unsigned int

variable_types:
val
unsigned int

return_type: unsigned int


decompiled_code:
__int64 __fastcall atom_type(unsigned int a1)
{
return *(unsigned int *)(the_cons_cells + 8LL * a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
return *(unsigned int *)(the_cons_cells + 8LL * a1);
}

original_code:
static uint atom_type(cellpoint cp)
{
 return the_cons_cells[cp].car;
}

canonical_original_code:
static unsigned int atom_type(unsigned int cp)
{
 return the_cons_cells[cp].car;
}

variable_types:
cp
unsigned int


decompiled_code:
__int64 __fastcall atom_obj(unsigned int a1)
{
return *(unsigned int *)(the_cons_cells + 8LL * a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return *(unsigned int *)(the_cons_cells + 8LL * a1 + 4);
}

original_code:
static uint atom_obj(cellpoint cp)
{
 return the_cons_cells[cp].cdr;
}

canonical_original_code:
static unsigned int atom_obj(unsigned int cp)
{
 return the_cons_cells[cp].cdr;
}


decompiled_code:
__int64 __fastcall is_atom(unsigned int a1)
{
return (unsigned int)atom_type(a1) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
return (unsigned int)func1(a1) >> 31;
}

original_code:
static int is_atom(cellpoint cp)
{
    return (atom_type(cp) & (1 << (sizeof(uint)*8-1))) ? 1 : 0;
}

canonical_original_code:
static int is_atom(unsigned int cp)
{
    return (atom_type(cp) & (1 << (sizeof(uint)*8-1))) ? 1 : 0;
}


decompiled_code:
__int64 __fastcall compute_obarray_index(_BYTE *a1)
{
int v1; // eax
int v2; // edx

v1 = (char)*a1;
if ( !*a1 )
return 0LL;
v2 = 0;
do
{
++a1;
v2 += v1;
v1 = (char)*a1;
}
while ( *a1 );
return (unsigned int)(v2 % 89);
}

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1)
{
int v1; // eax
int v2; // edx

v1 = (char)*a1;
if ( !*a1 )
return 0LL;
v2 = 0;
do
{
++a1;
v2 += v1;
v1 = (char)*a1;
}
while ( *a1 );
return (unsigned int)(v2 % 89);
}

original_code:
static int compute_obarray_index(char *sym)
{
    int sum = 0;
    while(*sym != '\0'){
        sum += *sym++;
    }
    return sum % 89;
}

variable_types:
sym
char *

variable_types: sum int


decompiled_code:
__int64 __fastcall is_null(int a1)
{
__int64 result; // rax

result = (unsigned int)a_true;
if ( a1 )
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
__int64 result; // rax

result = (unsigned int)a_true;
if ( a1 )
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_null(cellpoint point)
{
    return (point == 0) ? a_true : a_false;
}

canonical_original_code:
unsigned int is_null(unsigned int point)
{
    return (point == 0) ? a_true : a_false;
}

variable_types:
point
unsigned int


decompiled_code:
__int64 __fastcall make_char(char a1)
{
if ( !(unsigned int)memory_enough(1LL) )
garbage_collection();
return make_atom(-2147483616, a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(char a1)
{
if ( !(unsigned int)memory_enough(1LL) )
garbage_collection();
return func0(-2147483616, a1);
}

original_code:
cellpoint make_char(char ch)
{
 if (!memory_enough(1)){
  garbage_collection();
 }
 return make_atom((1 << (sizeof(uint)*8-1))|0x0020, ch);
}

canonical_original_code:
unsigned int make_char(char ch)
{
 if (!memory_enough(1)){
  garbage_collection();
 }
 return make_atom((1 << (sizeof(uint)*8-1))|0x0020, ch);
}

variable_types: ch char


decompiled_code:
__int64 __fastcall is_char(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)is_atom(a1) && (atom_type(v1) & 0x20) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)func3(a1) && (func1(v1) & 0x20) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_char(cellpoint cp)
{
    if (is_atom(cp) && (atom_type(cp) & 0x0020)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_char(unsigned int cp)
{
    if (is_atom(cp) && (atom_type(cp) & 0x0020)){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
// attributes: thunk
__int64 __fastcall get_char(unsigned int a1)
{
return atom_obj(a1);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1)
{
return func2(a1);
}

original_code:
char get_char(cellpoint cp)
{
    return (char)atom_obj(cp);
}

canonical_original_code:
char get_char(unsigned int cp)
{
    return (char)atom_obj(cp);
}

return_type: char


decompiled_code:
__int64 __fastcall make_integer(int a1)
{
if ( !(unsigned int)memory_enough(1LL) )
garbage_collection();
return make_atom(-2147483647, a1);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
if ( !(unsigned int)memory_enough(1LL) )
garbage_collection();
return func0(-2147483647, a1);
}

original_code:
cellpoint make_integer(int arg)
{
 if (!memory_enough(1)){
  garbage_collection();
 }
 return make_atom((1 << (sizeof(uint)*8-1))|0x0001, arg);
}

canonical_original_code:
unsigned int make_integer(int arg)
{
 if (!memory_enough(1)){
  garbage_collection();
 }
 return make_atom((1 << (sizeof(uint)*8-1))|0x0001, arg);
}

variable_types: arg int


decompiled_code:
// attributes: thunk
__int64 __fastcall get_integer(unsigned int a1)
{
return atom_obj(a1);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1)
{
return func2(a1);
}

original_code:
int get_integer(cellpoint point)
{
    return atom_obj(point);
}

canonical_original_code:
int get_integer(unsigned int point)
{
    return atom_obj(point);
}


decompiled_code:
__int64 __fastcall is_integer(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)is_atom(a1) && (atom_type(v1) & 1) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)func3(a1) && (func1(v1) & 1) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_integer(cellpoint point)
{
 if (is_atom(point) && (atom_type(point) & 0x0001)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_integer(unsigned int point)
{
 if (is_atom(point) && (atom_type(point) & 0x0001)){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
// attributes: thunk
__int64 __fastcall is_number(unsigned int a1)
{
return is_integer(a1);
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1)
{
return func11(a1);
}

original_code:
cellpoint is_number(cellpoint point)
{
    return is_integer(point);
}

canonical_original_code:
unsigned int is_number(unsigned int point)
{
    return is_integer(point);
}


decompiled_code:
__int64 bool_init()
{
__int64 result; // rax

a_true = make_atom(-2147483632, 1);
result = make_atom(-2147483632, 0);
a_false = result;
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 result; // rax

a_true = func0(-2147483632, 1);
result = func0(-2147483632, 0);
a_false = result;
return result;
}

original_code:
void bool_init(void)
{
 a_true = make_atom((1 << (sizeof(uint)*8-1))|0x0010, 1);
 a_false = make_atom((1 << (sizeof(uint)*8-1))|0x0010, 0);
}

canonical_original_code:
void bool_init()
{
 a_true = make_atom((1 << (sizeof(uint)*8-1))|0x0010, 1);
 a_false = make_atom((1 << (sizeof(uint)*8-1))|0x0010, 0);
}


decompiled_code:
__int64 __fastcall make_boolean(int a1)
{
__int64 result; // rax

result = (unsigned int)a_true;
if ( a1 != 1 )
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1)
{
__int64 result; // rax

result = (unsigned int)a_true;
if ( a1 != 1 )
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint make_boolean(int b)
{
    if (b == 1){
        return a_true;
    }else {
        return a_false;
    }
}

canonical_original_code:
unsigned int make_boolean(int b)
{
    if (b == 1){
        return a_true;
    }else {
        return a_false;
    }
}

variable_types: b int


decompiled_code:
__int64 __fastcall is_boolean(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)is_atom(a1) && (atom_type(v1) & 0x10) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)func3(a1) && (func1(v1) & 0x10) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_boolean(cellpoint cp)
{
    if (is_atom(cp) && (atom_type(cp) & 0x0010)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_boolean(unsigned int cp)
{
    if (is_atom(cp) && (atom_type(cp) & 0x0010)){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
_BOOL8 __fastcall is_false(int a1)
{
return a_false == a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(int a1)
{
return a_false == a1;
}

original_code:
int is_false(cellpoint cp)
{
 return (cp == a_false) ? 1 : 0;
}

canonical_original_code:
int is_false(unsigned int cp)
{
 return (cp == a_false) ? 1 : 0;
}


decompiled_code:
__int64 __fastcall is_pair(int a1)
{
int v1; // eax
unsigned int v2; // er8
__int64 result; // rax

v1 = is_null(a1);
if ( !is_false(v1) || (unsigned int)is_atom(v2) )
result = (unsigned int)a_false;
else
result = (unsigned int)a_true;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(int a1)
{
int v1; // eax
unsigned int v2; // er8
__int64 result; // rax

v1 = func5(a1);
if ( !func16(v1) || (unsigned int)func3(v2) )
result = (unsigned int)a_false;
else
result = (unsigned int)a_true;
return result;
}

original_code:
cellpoint is_pair(cellpoint cp)
{
 if (is_false(is_null(cp)) && !is_atom(cp)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_pair(unsigned int cp)
{
 if (is_false(is_null(cp)) && !is_atom(cp)){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
_BOOL8 __fastcall is_true(int a1)
{
return !is_false(a1);
}

canonical_decompiled_code:
_BOOL8 __fastcall func18(int a1)
{
return !func16(a1);
}

original_code:
int is_true(cellpoint cp)
{
    return is_false(cp) ? 0 : 1;
}

canonical_original_code:
int is_true(unsigned int cp)
{
    return is_false(cp) ? 0 : 1;
}


decompiled_code:
__int64 __fastcall get_symbol(unsigned int a1)
{
return (unsigned int)atom_obj(a1);
}

canonical_decompiled_code:
__int64 __fastcall func19(unsigned int a1)
{
return (unsigned int)func2(a1);
}

original_code:
char *get_symbol(cellpoint cp)
{
    return (char *)atom_obj(cp);
}

canonical_original_code:
char *get_symbol(unsigned int cp)
{
    return (char *)atom_obj(cp);
}

return_type: char *


decompiled_code:
__int64 __fastcall is_symbol(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)is_atom(a1) && (atom_type(v1) & 0x40) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)func3(a1) && (func1(v1) & 0x40) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_symbol(cellpoint cp)
{
    if (is_atom(cp) && (atom_type(cp) & 0x0040)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_symbol(unsigned int cp)
{
    if (is_atom(cp) && (atom_type(cp) & 0x0040)){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
__int64 __fastcall make_string(int a1, unsigned int a2)
{
unsigned int v2; // ebp
unsigned int v3; // er14
int v4; // ebx
unsigned int v5; // er13

v2 = a2;
if ( !(unsigned int)memory_enough((unsigned int)(a1 / 2 + 1)) )
{
car_set(allocons, a2);
cdr_set(allocons, 0LL);
garbage_collection();
v2 = car(allocons);
}
v3 = make_atom(-2147483520, a1);
if ( a1 > 0 )
{
v4 = 1;
v5 = ((a1 - 1) & 0xFFFFFFFE) + 3;
do
{
while ( v4 != a1 )
{
v4 += 2;
cons(v2, v2);
if ( v4 == v5 )
return v3;
}
v4 += 2;
cons(v2, 0LL);
}
while ( v4 != v5 );
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func21(int a1, unsigned int a2)
{
unsigned int v2; // ebp
unsigned int v3; // er14
int v4; // ebx
unsigned int v5; // er13

v2 = a2;
if ( !(unsigned int)memory_enough((unsigned int)(a1 / 2 + 1)) )
{
car_set(allocons, a2);
cdr_set(allocons, 0LL);
garbage_collection();
v2 = car(allocons);
}
v3 = func0(-2147483520, a1);
if ( a1 > 0 )
{
v4 = 1;
v5 = ((a1 - 1) & 0xFFFFFFFE) + 3;
do
{
while ( v4 != a1 )
{
v4 += 2;
cons(v2, v2);
if ( v4 == v5 )
return v3;
}
v4 += 2;
cons(v2, 0LL);
}
while ( v4 != v5 );
}
return v3;
}

original_code:
cellpoint make_string(int k, cellpoint ch)
{
 if (!memory_enough(k/2 + 1)){
  car_set(allocons, ch);
  cdr_set(allocons, 0);
  garbage_collection();
  ch = car(allocons);
 }
    cellpoint cpstr = make_atom((1 << (sizeof(uint)*8-1))|0x0080, k);
 int i;
 for (i=0; i < k; i += 2){
  if (i+1 == k){
   cons(ch, 0);
  }else {
   cons(ch, ch);
  }
 }
    return cpstr;
}

canonical_original_code:
unsigned int make_string(int k, unsigned int ch)
{
 if (!memory_enough(k/2 + 1)){
  car_set(allocons, ch);
  cdr_set(allocons, 0);
  garbage_collection();
  ch = car(allocons);
 }
    unsigned int cpstr = make_atom((1 << (sizeof(uint)*8-1))|0x0080, k);
 int i;
 for (i=0; i < k; i += 2){
  if (i+1 == k){
   cons(ch, 0);
  }else {
   cons(ch, ch);
  }
 }
    return cpstr;
}

variable_types: k int

variable_types:
ch
unsigned int

variable_types:
cpstr
unsigned int


decompiled_code:
__int64 __fastcall is_string(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)is_atom(a1) && (atom_type(v1) & 0x80u) != 0LL )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func22(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)func3(a1) && (func1(v1) & 0x80u) != 0LL )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_string(cellpoint cp)
{
    if (is_atom(cp) && (atom_type(cp) & 0x0080)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_string(unsigned int cp)
{
    if (is_atom(cp) && (atom_type(cp) & 0x0080)){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
// attributes: thunk
__int64 string_len()
{
return cdr();
}

canonical_decompiled_code:
__int64 func23()
{
return cdr();
}

original_code:
int string_len(cellpoint str)
{
 return cdr(str);
}

canonical_original_code:
int string_len(unsigned int str)
{
 return cdr(str);
}

variable_types:
str
unsigned int


decompiled_code:
__int64 __fastcall string_ref(unsigned int a1, int a2)
{
__int64 v2; // rdi
__int64 result; // rax
unsigned int v4; // eax

if ( a2 < 0 || (int)((__int64 (*)(void))string_len)() <= a2 )
{
v4 = string_len(a1);
printf("Error: the index %d out of the range. The length of string is %d. -- STRING-REF\n", (unsigned int)a2, v4);
error_handler();
}
v2 = a1 + a2 / 2 + 1;
if ( (a2 & 1) != 0 )
result = cdr(v2);
else
result = car(v2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(unsigned int a1, int a2)
{
__int64 v2; // rdi
__int64 result; // rax
unsigned int v4; // eax

if ( a2 < 0 || (int)((__int64 (*)(void))string_len)() <= a2 )
{
v4 = func23(a1);
printf("Error: the index %d out of the range. The length of string is %d. -- STRING-REF\n", (unsigned int)a2, v4);
error_handler();
}
v2 = a1 + a2 / 2 + 1;
if ( (a2 & 1) != 0 )
result = cdr(v2);
else
result = car(v2);
return result;
}

original_code:
cellpoint string_ref(cellpoint str, int ind)
{
 if (ind < 0 || ind >= string_len(str)){
        printf("Error: the index %d out of the range. The length of string is %d. -- STRING-REF\n", ind, string_len(str));
  error_handler();
    }
 cellpoint s = str + ind / 2 + 1;
 if (ind % 2 == 0){
  return car(s);
 }else {
  return cdr(s);
 }
}

canonical_original_code:
unsigned int string_ref(unsigned int str, int ind)
{
 if (ind < 0 || ind >= string_len(str)){
        printf("Error: the index %d out of the range. The length of string is %d. -- STRING-REF\n", ind, string_len(str));
  error_handler();
    }
 unsigned int s = str + ind / 2 + 1;
 if (ind % 2 == 0){
  return car(s);
 }else {
  return cdr(s);
 }
}

variable_types: ind int

variable_types:
s
unsigned int


decompiled_code:
__int64 __fastcall string_set(__int64 a1, int a2, unsigned int a3)
{
__int64 v4; // rdi
__int64 result; // rax
unsigned int v6; // eax

if ( a2 < 0 || (int)string_len(a1) <= a2 )
{
v6 = string_len((unsigned int)a1);
printf("Error: the index %d out of the range. The length of string is %d.-- STRING-SET\n", (unsigned int)a2, v6);
error_handler();
}
v4 = (unsigned int)(a1 + a2 / 2 + 1);
if ( (a2 & 1) != 0 )
result = cdr_set(v4, a3);
else
result = car_set(v4, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func25(__int64 a1, int a2, unsigned int a3)
{
__int64 v4; // rdi
__int64 result; // rax
unsigned int v6; // eax

if ( a2 < 0 || (int)func23(a1) <= a2 )
{
v6 = func23((unsigned int)a1);
printf("Error: the index %d out of the range. The length of string is %d.-- STRING-SET\n", (unsigned int)a2, v6);
error_handler();
}
v4 = (unsigned int)(a1 + a2 / 2 + 1);
if ( (a2 & 1) != 0 )
result = cdr_set(v4, a3);
else
result = car_set(v4, a3);
return result;
}

original_code:
void string_set(cellpoint str, int ind, cellpoint ch)
{
    if (ind < 0 || ind >= string_len(str)){
        printf("Error: the index %d out of the range. The length of string is %d.-- STRING-SET\n", ind, string_len(str));
  error_handler();
    }
 cellpoint s = str + ind / 2 + 1;
 if (ind % 2 == 0){
  car_set(s, ch);
 }else {
  cdr_set(s, ch);
 }
}

canonical_original_code:
void string_set(unsigned int str, int ind, unsigned int ch)
{
    if (ind < 0 || ind >= string_len(str)){
        printf("Error: the index %d out of the range. The length of string is %d.-- STRING-SET\n", ind, string_len(str));
  error_handler();
    }
 unsigned int s = str + ind / 2 + 1;
 if (ind % 2 == 0){
  car_set(s, ch);
 }else {
  cdr_set(s, ch);
 }
}


decompiled_code:
__int64 __fastcall chars_2_string(const char *a1)
{
int v1; // ebx
unsigned int v2; // er12
__int64 v3; // r13
__int64 v4; // rbx
unsigned int v5; // eax
__int64 v6; // rax

v1 = strlen(a1);
v2 = make_string(v1, 0);
if ( v1 > 0 )
{
v3 = (unsigned int)(v1 - 1);
v4 = 0LL;
do
{
v5 = make_char(a1[v4]);
string_set(v2, v4, v5);
v6 = v4++;
}
while ( v6 != v3 );
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func26(const char *a1)
{
int v1; // ebx
unsigned int v2; // er12
__int64 v3; // r13
__int64 v4; // rbx
unsigned int v5; // eax
__int64 v6; // rax

v1 = strlen(a1);
v2 = func21(v1, 0);
if ( v1 > 0 )
{
v3 = (unsigned int)(v1 - 1);
v4 = 0LL;
do
{
v5 = func6(a1[v4]);
func25(v2, v4, v5);
v6 = v4++;
}
while ( v6 != v3 );
}
return v2;
}

original_code:
cellpoint chars_2_string(char *str)
{
    int i,len = strlen(str);
    cellpoint cpstr = make_string(len, '\0');
 for (i=0; i < len; ++i){
  string_set(cpstr, i, make_char(*(str+i)));
 }
    return cpstr;
}

canonical_original_code:
unsigned int chars_2_string(char *str)
{
    int i; int len = strlen(str);
    unsigned int cpstr = make_string(len, '\0');
 for (i=0; i < len; ++i){
  string_set(cpstr, i, make_char(*(str+i)));
 }
    return cpstr;
}

variable_types:
str
char *

variable_types: i int

variable_types: len int


decompiled_code:
__int64 __fastcall make_vector(int a1, unsigned int a2)
{
unsigned int v2; // ebp
unsigned int v3; // er14
int v4; // ebx
unsigned int v5; // er13

v2 = a2;
if ( !(unsigned int)memory_enough((unsigned int)(a1 / 2 + 1)) )
{
car_set(allocons, a2);
cdr_set(allocons, 0LL);
garbage_collection();
v2 = car(allocons);
}
v3 = make_atom(-2147483392, a1);
if ( a1 > 0 )
{
v4 = 1;
v5 = ((a1 - 1) & 0xFFFFFFFE) + 3;
do
{
while ( v4 != a1 )
{
v4 += 2;
cons(v2, v2);
if ( v4 == v5 )
return v3;
}
v4 += 2;
cons(v2, 0LL);
}
while ( v4 != v5 );
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func27(int a1, unsigned int a2)
{
unsigned int v2; // ebp
unsigned int v3; // er14
int v4; // ebx
unsigned int v5; // er13

v2 = a2;
if ( !(unsigned int)memory_enough((unsigned int)(a1 / 2 + 1)) )
{
car_set(allocons, a2);
cdr_set(allocons, 0LL);
garbage_collection();
v2 = car(allocons);
}
v3 = func0(-2147483392, a1);
if ( a1 > 0 )
{
v4 = 1;
v5 = ((a1 - 1) & 0xFFFFFFFE) + 3;
do
{
while ( v4 != a1 )
{
v4 += 2;
cons(v2, v2);
if ( v4 == v5 )
return v3;
}
v4 += 2;
cons(v2, 0LL);
}
while ( v4 != v5 );
}
return v3;
}

original_code:
cellpoint make_vector(int num, cellpoint fill)
{
 if (!memory_enough(num/2 + 1)){
  car_set(allocons, fill);
  cdr_set(allocons, 0);
  garbage_collection();
  fill = car(allocons);
 }
    cellpoint cpv = make_atom((1 << (sizeof(uint)*8-1))|0x0100, num);
    int i;
    for (i=0; i < num; i = i+2){
        if (i+1 == num){
            cons(fill, 0);
        } else{
            cons(fill, fill);
        }
    }
    return cpv;
}

canonical_original_code:
unsigned int make_vector(int num, unsigned int fill)
{
 if (!memory_enough(num/2 + 1)){
  car_set(allocons, fill);
  cdr_set(allocons, 0);
  garbage_collection();
  fill = car(allocons);
 }
    unsigned int cpv = make_atom((1 << (sizeof(uint)*8-1))|0x0100, num);
    int i;
    for (i=0; i < num; i = i+2){
        if (i+1 == num){
            cons(fill, 0);
        } else{
            cons(fill, fill);
        }
    }
    return cpv;
}

variable_types: num int

variable_types:
fill
unsigned int

variable_types:
cpv
unsigned int


decompiled_code:
__int64 init_obarray()
{
__int64 result; // rax

result = make_vector(89, 0);
obarray = result;
return result;
}

canonical_decompiled_code:
__int64 func28()
{
__int64 result; // rax

result = func27(89, 0);
obarray = result;
return result;
}

original_code:
void init_obarray(void)
{
 obarray = make_vector(89, 0);
}

canonical_original_code:
void init_obarray()
{
 obarray = make_vector(89, 0);
}


decompiled_code:
__int64 __fastcall is_vector(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)is_atom(a1) && (atom_type(v1) & 0x100) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func29(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)func3(a1) && (func1(v1) & 0x100) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_vector(cellpoint point)
{
    if (is_atom(point) && (atom_type(point) & 0x0100)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_vector(unsigned int point)
{
    if (is_atom(point) && (atom_type(point) & 0x0100)){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
// attributes: thunk
__int64 __fastcall vector_len(__int64 a1)
{
return string_len(a1);
}

canonical_decompiled_code:
__int64 __fastcall func30(__int64 a1)
{
return func23(a1);
}

original_code:
int vector_len(cellpoint vec)
{
 return cdr(vec);
}

canonical_original_code:
int vector_len(unsigned int vec)
{
 return cdr(vec);
}

variable_types:
vec
unsigned int


decompiled_code:
__int64 __fastcall vector_ref(__int64 a1, int a2)
{
__int64 v2; // rdi
__int64 result; // rax
unsigned int v4; // eax

if ( a2 < 0 || (int)string_len(a1) <= a2 )
{
v4 = string_len((unsigned int)a1);
printf("Error: the index %d out of the range. The length of vector is %d.\n", (unsigned int)a2, v4);
error_handler();
}
v2 = (unsigned int)(a1 + a2 / 2 + 1);
if ( (a2 & 1) != 0 )
result = cdr(v2);
else
result = car(v2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func31(__int64 a1, int a2)
{
__int64 v2; // rdi
__int64 result; // rax
unsigned int v4; // eax

if ( a2 < 0 || (int)func23(a1) <= a2 )
{
v4 = func23((unsigned int)a1);
printf("Error: the index %d out of the range. The length of vector is %d.\n", (unsigned int)a2, v4);
error_handler();
}
v2 = (unsigned int)(a1 + a2 / 2 + 1);
if ( (a2 & 1) != 0 )
result = cdr(v2);
else
result = car(v2);
return result;
}

original_code:
cellpoint vector_ref(cellpoint vec, int ind)
{
    if (ind < 0 || ind >= vector_len(vec)){
        printf("Error: the index %d out of the range. The length of vector is %d.\n", ind, vector_len(vec));
  error_handler();
    }
    cellpoint v = vec + ind/2 + 1;
    if (ind % 2 == 0){
        return car(v);
    } else{
  return cdr(v);
    }
}

canonical_original_code:
unsigned int vector_ref(unsigned int vec, int ind)
{
    if (ind < 0 || ind >= vector_len(vec)){
        printf("Error: the index %d out of the range. The length of vector is %d.\n", ind, vector_len(vec));
  error_handler();
    }
    unsigned int v = vec + ind/2 + 1;
    if (ind % 2 == 0){
        return car(v);
    } else{
  return cdr(v);
    }
}

variable_types:
v
unsigned int


decompiled_code:
__int64 __fastcall lookup_symbol(char *s1)
{
int v1; // eax
unsigned int v2; // eax
unsigned int v3; // ebp
unsigned int v4; // er12
const char *v5; // rax

v1 = compute_obarray_index(s1);
v2 = vector_ref((unsigned int)obarray, v1);
if ( !v2 )
return 0LL;
v3 = v2;
while ( 1 )
{
v4 = car(v3);
v5 = (const char *)get_symbol(v4);
if ( !strcmp(s1, v5) )
break;
v3 = cdr(v3);
if ( !v3 )
return 0LL;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func32(char *s1)
{
int v1; // eax
unsigned int v2; // eax
unsigned int v3; // ebp
unsigned int v4; // er12
const char *v5; // rax

v1 = func4(s1);
v2 = func31((unsigned int)obarray, v1);
if ( !v2 )
return 0LL;
v3 = v2;
while ( 1 )
{
v4 = car(v3);
v5 = (const char *)func19(v4);
if ( !strcmp(s1, v5) )
break;
v3 = cdr(v3);
if ( !v3 )
return 0LL;
}
return v4;
}

original_code:
static cellpoint lookup_symbol(char *sym)
{
    int ind = compute_obarray_index(sym);
    cellpoint p = vector_ref(obarray, ind);
    while(p != 0){
  cellpoint s = car(p);
        if(strcmp(sym, get_symbol(s)) == 0){
            return s;
        }
        p = cdr(p);
    }
    return 0;
}

canonical_original_code:
static unsigned int lookup_symbol(char *sym)
{
    int ind = compute_obarray_index(sym);
    unsigned int p = vector_ref(obarray, ind);
    while(p != 0){
  unsigned int s = car(p);
        if(strcmp(sym, get_symbol(s)) == 0){
            return s;
        }
        p = cdr(p);
    }
    return 0;
}

variable_types:
sym
char *

variable_types:
p
unsigned int


decompiled_code:
__int64 __fastcall vector_set(__int64 a1, int a2, unsigned int a3)
{
__int64 v4; // rdi
__int64 result; // rax
unsigned int v6; // eax

if ( a2 < 0 || (int)string_len(a1) <= a2 )
{
v6 = string_len((unsigned int)a1);
printf("Error: the index %d out of the range. The length of vector is %d.\n", (unsigned int)a2, v6);
error_handler();
}
v4 = (unsigned int)(a1 + a2 / 2 + 1);
if ( (a2 & 1) != 0 )
result = cdr_set(v4, a3);
else
result = car_set(v4, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func33(__int64 a1, int a2, unsigned int a3)
{
__int64 v4; // rdi
__int64 result; // rax
unsigned int v6; // eax

if ( a2 < 0 || (int)func23(a1) <= a2 )
{
v6 = func23((unsigned int)a1);
printf("Error: the index %d out of the range. The length of vector is %d.\n", (unsigned int)a2, v6);
error_handler();
}
v4 = (unsigned int)(a1 + a2 / 2 + 1);
if ( (a2 & 1) != 0 )
result = cdr_set(v4, a3);
else
result = car_set(v4, a3);
return result;
}

original_code:
void vector_set(cellpoint vec, int ind, cellpoint np)
{
    if (ind < 0 || ind >= vector_len(vec)){
        printf("Error: the index %d out of the range. The length of vector is %d.\n", ind, vector_len(vec));
  error_handler();
    }
    cellpoint v = vec + ind/2 + 1;
    if (ind % 2 == 0){
        car_set(v, np);
    } else{
        cdr_set(v, np);
    }
}

canonical_original_code:
void vector_set(unsigned int vec, int ind, unsigned int np)
{
    if (ind < 0 || ind >= vector_len(vec)){
        printf("Error: the index %d out of the range. The length of vector is %d.\n", ind, vector_len(vec));
  error_handler();
    }
    unsigned int v = vec + ind/2 + 1;
    if (ind % 2 == 0){
        car_set(v, np);
    } else{
        cdr_set(v, np);
    }
}

variable_types:
np
unsigned int


decompiled_code:
__int64 __fastcall interning_symbol(_BYTE *a1, unsigned int a2)
{
int v2; // ebp
unsigned int v3; // eax
unsigned int v4; // eax

v2 = compute_obarray_index(a1);
v3 = vector_ref((unsigned int)obarray, v2);
v4 = cons(a2, v3);
return vector_set((unsigned int)obarray, v2, v4);
}

canonical_decompiled_code:
__int64 __fastcall func34(_BYTE *a1, unsigned int a2)
{
int v2; // ebp
unsigned int v3; // eax
unsigned int v4; // eax

v2 = func4(a1);
v3 = func31((unsigned int)obarray, v2);
v4 = cons(a2, v3);
return func33((unsigned int)obarray, v2, v4);
}

original_code:
static void interning_symbol(char *sym, cellpoint cp)
{
    int ind = compute_obarray_index(sym);
 cellpoint p = vector_ref(obarray, ind);
 vector_set(obarray, ind, cons(cp, p));
}

canonical_original_code:
static void interning_symbol(char *sym, unsigned int cp)
{
    int ind = compute_obarray_index(sym);
 unsigned int p = vector_ref(obarray, ind);
 vector_set(obarray, ind, cons(cp, p));
}

variable_types:
cp
unsigned int


decompiled_code:
__int64 __fastcall make_symbol(char *src)
{
__int64 result; // rax
size_t v2; // rax
char *v3; // r13
unsigned int v4; // [rsp+Ch] [rbp-1Ch]

result = lookup_symbol(src);
if ( !(_DWORD)result )
{
if ( !(unsigned int)memory_enough(1LL) )
garbage_collection();
v2 = strlen(src);
v3 = (char *)malloc(v2 + 1);
if ( !v3 )
{
perror("Error:malloc error. -- CREATE_SYMBOL\n");
error_handler();
}
strcpy(v3, src);
v4 = make_atom(-2147483584, (int)v3);
interning_symbol(v3, v4);
result = v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func35(char *src)
{
__int64 result; // rax
size_t v2; // rax
char *v3; // r13
unsigned int v4; // [rsp+Ch] [rbp-1Ch]

result = func32(src);
if ( !(_DWORD)result )
{
if ( !(unsigned int)memory_enough(1LL) )
garbage_collection();
v2 = strlen(src);
v3 = (char *)malloc(v2 + 1);
if ( !v3 )
{
perror("Error:malloc error. -- CREATE_SYMBOL\n");
error_handler();
}
strcpy(v3, src);
v4 = func0(-2147483584, (int)v3);
func34(v3, v4);
result = v4;
}
return result;
}

original_code:
cellpoint make_symbol(char *sym)
{
    cellpoint cp = lookup_symbol(sym);
    if (cp != 0){
        return cp;
    }
 if (!memory_enough(1)){
  garbage_collection();
 }
    char *new_sym = (char *)malloc(strlen(sym)+1);
    if(new_sym == ((void *)0)){
        perror("Error:malloc error. -- CREATE_SYMBOL\n");
  error_handler();
    }
    strcpy(new_sym, sym);
    cp = make_atom((1 << (sizeof(uint)*8-1))|0x0040, (uint)new_sym);
    interning_symbol(new_sym, cp);
    return cp;
}

canonical_original_code:
unsigned int make_symbol(char *sym)
{
    unsigned int cp = lookup_symbol(sym);
    if (cp != 0){
        return cp;
    }
 if (!memory_enough(1)){
  garbage_collection();
 }
    char *new_sym = (char *)malloc(strlen(sym)+1);
    if(new_sym == ((void *)0)){
        perror("Error:malloc error. -- CREATE_SYMBOL\n");
  error_handler();
    }
    strcpy(new_sym, sym);
    cp = make_atom((1 << (sizeof(uint)*8-1))|0x0040, (unsigned int)new_sym);
    interning_symbol(new_sym, cp);
    return cp;
}


decompiled_code:
__int64 __fastcall make_prim_proc(unsigned int a1, unsigned int a2)
{
unsigned int v2; // ebp
int v3; // eax

v2 = a1;
if ( !(unsigned int)memory_enough(1LL) )
{
car_set(allocons, a1);
cdr_set(allocons, 0LL);
garbage_collection();
v2 = car(allocons);
}
v3 = cons(v2, a2);
return make_atom(-2147483136, v3);
}

canonical_decompiled_code:
__int64 __fastcall func36(unsigned int a1, unsigned int a2)
{
unsigned int v2; // ebp
int v3; // eax

v2 = a1;
if ( !(unsigned int)memory_enough(1LL) )
{
car_set(allocons, a1);
cdr_set(allocons, 0LL);
garbage_collection();
v2 = car(allocons);
}
v3 = cons(v2, a2);
return func0(-2147483136, v3);
}

original_code:
cellpoint make_prim_proc(cellpoint pname, prim_proc_t pp)
{
 if (!memory_enough(1)){
  car_set(allocons, pname);
  cdr_set(allocons, 0);
  garbage_collection();
  pname = car(allocons);
 }
 return make_atom((1 << (sizeof(uint)*8-1))|0x0200, cons(pname, (uint)pp));
}

canonical_original_code:
unsigned int make_prim_proc(unsigned int pname, unsigned int (*pp)(unsigned int))
{
 if (!memory_enough(1)){
  car_set(allocons, pname);
  cdr_set(allocons, 0);
  garbage_collection();
  pname = car(allocons);
 }
 return make_atom((1 << (sizeof(uint)*8-1))|0x0200, cons(pname, (unsigned int)pp));
}

variable_types:
pname
unsigned int

variable_types:
pp
unsigned int (*)(unsigned int)


decompiled_code:
__int64 __fastcall is_prim_proc(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)is_atom(a1) && (atom_type(v1) & 0x200) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func37(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)func3(a1) && (func1(v1) & 0x200) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_prim_proc(cellpoint obj)
{
 if (is_atom(obj) && (atom_type(obj) & 0x0200)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_prim_proc(unsigned int obj)
{
 if (is_atom(obj) && (atom_type(obj) & 0x0200)){
  return a_true;
 }else {
  return a_false;
 }
}

variable_types:
obj
unsigned int


decompiled_code:
__int64 __fastcall prim_proc_obj(__int64 a1)
{
unsigned int v1; // eax

v1 = cdr(a1);
return (unsigned int)cdr(v1);
}

canonical_decompiled_code:
__int64 __fastcall func38(__int64 a1)
{
unsigned int v1; // eax

v1 = cdr(a1);
return (unsigned int)cdr(v1);
}

original_code:
prim_proc_t prim_proc_obj(cellpoint obj)
{
 return (prim_proc_t)cdr(cdr(obj));
}

canonical_original_code:
unsigned int (*prim_proc_obj(unsigned int obj))(unsigned int)
{
 return (unsigned int (*)(unsigned int))cdr(cdr(obj));
}

return_type: unsigned int (*)(unsigned int)


decompiled_code:
__int64 make_procedure()
{
unsigned int v0; // eax
unsigned int v1; // ebp
unsigned int v2; // eax
unsigned int v3; // ebp
unsigned int v4; // eax

v0 = args_ref(3LL);
v1 = cons(v0, 0LL);
reg = v1;
v2 = args_ref(2LL);
v3 = cons(v2, v1);
reg = v3;
v4 = args_ref(1LL);
reg = cons(v4, v3);
reg = cons(0LL, reg);
if ( !(unsigned int)memory_enough(1LL) )
garbage_collection();
reg = make_atom(-2147467264, reg);
args_pop(3LL);
return reg;
}

canonical_decompiled_code:
__int64 func39()
{
unsigned int v0; // eax
unsigned int v1; // ebp
unsigned int v2; // eax
unsigned int v3; // ebp
unsigned int v4; // eax

v0 = args_ref(3LL);
v1 = cons(v0, 0LL);
reg = v1;
v2 = args_ref(2LL);
v3 = cons(v2, v1);
reg = v3;
v4 = args_ref(1LL);
reg = cons(v4, v3);
reg = cons(0LL, reg);
if ( !(unsigned int)memory_enough(1LL) )
garbage_collection();
reg = func0(-2147467264, reg);
args_pop(3LL);
return reg;
}

original_code:
cellpoint make_procedure(void)
{
 reg = cons(args_ref(3), 0);
 reg = cons(args_ref(2), reg);
 reg = cons(args_ref(1), reg);
 reg = cons(0, reg);
 if (!memory_enough(1)){
  garbage_collection();
 }
 reg = make_atom((1 << (sizeof(uint)*8-1))|0x04000, reg);
 args_pop(3);
 return reg;
}

canonical_original_code:
unsigned int make_procedure()
{
 reg = cons(args_ref(3), 0);
 reg = cons(args_ref(2), reg);
 reg = cons(args_ref(1), reg);
 reg = cons(0, reg);
 if (!memory_enough(1)){
  garbage_collection();
 }
 reg = make_atom((1 << (sizeof(uint)*8-1))|0x04000, reg);
 args_pop(3);
 return reg;
}


decompiled_code:
__int64 __fastcall is_compound_proc(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)is_atom(a1) && (atom_type(v1) & 0x4000) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func40(unsigned int a1)
{
unsigned int v1; // er8
__int64 result; // rax

if ( (unsigned int)func3(a1) && (func1(v1) & 0x4000) != 0 )
result = (unsigned int)a_true;
else
result = (unsigned int)a_false;
return result;
}

original_code:
cellpoint is_compound_proc(cellpoint obj)
{
 if (is_atom(obj) && (atom_type(obj) & 0x04000)){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_compound_proc(unsigned int obj)
{
 if (is_atom(obj) && (atom_type(obj) & 0x04000)){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
__int64 __fastcall is_procedure(unsigned int a1)
{
unsigned int v1; // eax
__int64 result; // rax
unsigned int v3; // eax

v1 = is_prim_proc();
if ( (unsigned int)is_true(v1) || (v3 = is_compound_proc(a1), (unsigned int)is_true(v3)) )
result = a_true;
else
result = a_false;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
unsigned int v1; // eax
__int64 result; // rax
unsigned int v3; // eax

v1 = is_prim_proc();
if ( (unsigned int)is_true(v1) || (v3 = is_compound_proc(a1), (unsigned int)is_true(v3)) )
result = a_true;
else
result = a_false;
return result;
}

original_code:
cellpoint is_procedure(cellpoint obj)
{
 if (is_true(is_prim_proc(obj)) || is_true(is_compound_proc(obj))){
  return a_true;
 }else {
  return a_false;
 }
}

canonical_original_code:
unsigned int is_procedure(unsigned int obj)
{
 if (is_true(is_prim_proc(obj)) || is_true(is_compound_proc(obj))){
  return a_true;
 }else {
  return a_false;
 }
}


decompiled_code:
__int64 procedure_name()
{
unsigned int v0; // eax
unsigned int v1; // eax

v0 = args_ref(1LL);
v1 = cdr(v0);
reg = car(v1);
args_pop(1LL);
return reg;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // eax
unsigned int v1; // eax

v0 = args_ref(1LL);
v1 = cdr(v0);
reg = car(v1);
args_pop(1LL);
return reg;
}

original_code:
cellpoint procedure_name(void)
{
 reg = car(cdr(args_ref(1)));
 args_pop(1);
 return reg;
}

canonical_original_code:
unsigned int procedure_name()
{
 reg = car(cdr(args_ref(1)));
 args_pop(1);
 return reg;
}


decompiled_code:
__int64 procedure_name_set()
{
unsigned int v0; // ebp
unsigned int v1; // eax
unsigned int v2; // eax

v0 = args_ref(2LL);
v1 = args_ref(1LL);
v2 = cdr(v1);
car_set(v2, v0);
return args_pop(2LL);
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // ebp
unsigned int v1; // eax
unsigned int v2; // eax

v0 = args_ref(2LL);
v1 = args_ref(1LL);
v2 = cdr(v1);
car_set(v2, v0);
return args_pop(2LL);
}

original_code:
void procedure_name_set(void)
{
 car_set(cdr(args_ref(1)), args_ref(2));
 args_pop(2);
}

canonical_original_code:
void procedure_name_set()
{
 car_set(cdr(args_ref(1)), args_ref(2));
 args_pop(2);
}


decompiled_code:
__int64 apply_prim_proc()
{
unsigned int v0; // eax
unsigned int v1; // ebx
unsigned int v2; // eax

v0 = args_ref(1LL);
v1 = prim_proc_obj(v0);
reg = v1;
v2 = args_ref(2LL);
reg = ((__int64 (__fastcall *)(_QWORD))v1)(v2);
args_pop(2LL);
return reg;
}

canonical_decompiled_code:
__int64 func3()
{
unsigned int v0; // eax
unsigned int v1; // ebx
unsigned int v2; // eax

v0 = args_ref(1LL);
v1 = prim_proc_obj(v0);
reg = v1;
v2 = args_ref(2LL);
reg = ((__int64 (__fastcall *)(_QWORD))v1)(v2);
args_pop(2LL);
return reg;
}

original_code:
cellpoint apply_prim_proc(void)
{
 reg = (cellpoint)prim_proc_obj(args_ref(1));
 reg = (*(prim_proc_t)reg)(args_ref(2));
 args_pop(2);
 return reg;
}

canonical_original_code:
unsigned int apply_prim_proc()
{
 reg = (unsigned int)prim_proc_obj(args_ref(1));
 reg = (*(unsigned int (*)(unsigned int))reg)(args_ref(2));
 args_pop(2);
 return reg;
}


decompiled_code:
__int64 procedure_parameters()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax

v0 = args_ref(1LL);
v1 = cdr(v0);
v2 = cdr(v1);
reg = car(v2);
args_pop(1LL);
return reg;
}

canonical_decompiled_code:
__int64 func4()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax

v0 = args_ref(1LL);
v1 = cdr(v0);
v2 = cdr(v1);
reg = car(v2);
args_pop(1LL);
return reg;
}

original_code:
cellpoint procedure_parameters(void)
{
 reg = car(cdr(cdr(args_ref(1))));
 args_pop(1);
 return reg;
}

canonical_original_code:
unsigned int procedure_parameters()
{
 reg = car(cdr(cdr(args_ref(1))));
 args_pop(1);
 return reg;
}


decompiled_code:
__int64 procedure_body()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax

v0 = args_ref(1LL);
v1 = cdr(v0);
v2 = cdr(v1);
v3 = cdr(v2);
reg = car(v3);
args_pop(1LL);
return reg;
}

canonical_decompiled_code:
__int64 func5()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax

v0 = args_ref(1LL);
v1 = cdr(v0);
v2 = cdr(v1);
v3 = cdr(v2);
reg = car(v3);
args_pop(1LL);
return reg;
}

original_code:
cellpoint procedure_body(void)
{
 reg = car(cdr(cdr(cdr(args_ref(1)))));
 args_pop(1);
 return reg;
}

canonical_original_code:
unsigned int procedure_body()
{
 reg = car(cdr(cdr(cdr(args_ref(1)))));
 args_pop(1);
 return reg;
}


decompiled_code:
__int64 procedure_env()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax

v0 = args_ref(1LL);
v1 = cdr(v0);
v2 = cdr(v1);
v3 = cdr(v2);
v4 = cdr(v3);
reg = car(v4);
args_pop(1LL);
return reg;
}

canonical_decompiled_code:
__int64 func6()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax

v0 = args_ref(1LL);
v1 = cdr(v0);
v2 = cdr(v1);
v3 = cdr(v2);
v4 = cdr(v3);
reg = car(v4);
args_pop(1LL);
return reg;
}

original_code:
cellpoint procedure_env(void)
{
 reg = car(cdr(cdr(cdr(cdr(args_ref(1))))));
 args_pop(1);
 return reg;
}

canonical_original_code:
unsigned int procedure_env()
{
 reg = car(cdr(cdr(cdr(cdr(args_ref(1))))));
 args_pop(1);
 return reg;
}


decompiled_code:
__int64 __fastcall cons_infree(int a1, int a2)
{
_DWORD *v2; // rdx
__int64 result; // rax

v2 = (_DWORD *)(free_cons_cells + 8LL * free_point);
result = free_point;
*v2 = a1;
v2[1] = a2;
free_point = result + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
_DWORD *v2; // rdx
__int64 result; // rax

v2 = (_DWORD *)(free_cons_cells + 8LL * free_point);
result = free_point;
*v2 = a1;
v2[1] = a2;
free_point = result + 1;
return result;
}

original_code:
static cellpoint cons_infree(cellpoint addr, cellpoint decre)
{
 free_cons_cells[free_point].car = addr;
 free_cons_cells[free_point].cdr = decre;
 return free_point++;
}

canonical_original_code:
static unsigned int cons_infree(unsigned int addr, unsigned int decre)
{
 free_cons_cells[free_point].car = addr;
 free_cons_cells[free_point].cdr = decre;
 return free_point++;
}

variable_types:
addr
unsigned int

variable_types:
decre
unsigned int


decompiled_code:
__int64 __fastcall car_infree(unsigned int a1)
{
return *(unsigned int *)(free_cons_cells + 8LL * a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
return *(unsigned int *)(free_cons_cells + 8LL * a1);
}

original_code:
static cellpoint car_infree(cellpoint p)
{
 return free_cons_cells[p].car;
}

canonical_original_code:
static unsigned int car_infree(unsigned int p)
{
 return free_cons_cells[p].car;
}


decompiled_code:
__int64 __fastcall cdr_infree(unsigned int a1)
{
return *(unsigned int *)(free_cons_cells + 8LL * a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return *(unsigned int *)(free_cons_cells + 8LL * a1 + 4);
}

original_code:
static cellpoint cdr_infree(cellpoint p)
{
 return free_cons_cells[p].cdr;
}

canonical_original_code:
static unsigned int cdr_infree(unsigned int p)
{
 return free_cons_cells[p].cdr;
}


decompiled_code:
__int64 __fastcall car_set_infree(unsigned int a1, int a2)
{
__int64 result; // rax

result = free_cons_cells;
*(_DWORD *)(free_cons_cells + 8LL * a1) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, int a2)
{
__int64 result; // rax

result = free_cons_cells;
*(_DWORD *)(free_cons_cells + 8LL * a1) = a2;
return result;
}

original_code:
static void car_set_infree(cellpoint p, cellpoint n)
{
 free_cons_cells[p].car = n;
}

canonical_original_code:
static void car_set_infree(unsigned int p, unsigned int n)
{
 free_cons_cells[p].car = n;
}

variable_types:
n
unsigned int


decompiled_code:
__int64 __fastcall cdr_set_infree(unsigned int a1, int a2)
{
__int64 result; // rax

result = free_cons_cells;
*(_DWORD *)(free_cons_cells + 8LL * a1 + 4) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, int a2)
{
__int64 result; // rax

result = free_cons_cells;
*(_DWORD *)(free_cons_cells + 8LL * a1 + 4) = a2;
return result;
}

original_code:
static void cdr_set_infree(cellpoint p, cellpoint n)
{
 free_cons_cells[p].cdr = n;
}

canonical_original_code:
static void cdr_set_infree(unsigned int p, unsigned int n)
{
 free_cons_cells[p].cdr = n;
}


decompiled_code:
_BOOL8 __fastcall is_broken_heart(int a1)
{
return a1 == 0xFFFFFFF;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(int a1)
{
return a1 == 0xFFFFFFF;
}

original_code:
static int is_broken_heart(uint p)
{
 return (p == 0xFFFFFFF) ? 1 : 0;
}

canonical_original_code:
static int is_broken_heart(unsigned int p)
{
 return (p == 0xFFFFFFF) ? 1 : 0;
}


decompiled_code:
_BOOL8 gc_finished()
{
return (unsigned int)scan >= free_point;
}

canonical_decompiled_code:
_BOOL8 func6()
{
return (unsigned int)scan >= free_point;
}

original_code:
static int gc_finished(void)
{
 return (scan >= free_point) ? 1 : 0;
}

canonical_original_code:
static int gc_finished()
{
 return (scan >= free_point) ? 1 : 0;
}


decompiled_code:
__int64 set_root()
{
unsigned int v0; // ebp
unsigned int v1; // ebp
unsigned int v2; // ebp
unsigned int v3; // ebp
unsigned int v4; // ebp
unsigned int v5; // ebp
unsigned int v6; // ebp
unsigned int v7; // ebp
unsigned int v8; // ebp
unsigned int v9; // ebp
unsigned int v10; // ebp
unsigned int v11; // ebp
__int64 v12; // rbp
unsigned int v13; // eax

v0 = root;
car_set((unsigned int)root, the_global_env);
v1 = cdr(v0);
car_set(v1, allocons);
v2 = cdr(v1);
car_set(v2, current_env);
v3 = cdr(v2);
car_set(v3, env_stack);
v4 = cdr(v3);
car_set(v4, args_stack);
v5 = cdr(v4);
car_set(v5, vars_stack);
v6 = cdr(v5);
car_set(v6, parser_stack);
v7 = cdr(v6);
car_set(v7, state_stack);
v8 = cdr(v7);
car_set(v8, current_state);
v9 = cdr(v8);
car_set(v9, state_constants);
v10 = cdr(v9);
car_set(v10, obarray);
v11 = cdr(v10);
car_set(v11, reg);
v12 = (unsigned int)cdr(v11);
car_set(v12, a_true);
v13 = cdr((unsigned int)v12);
return car_set(v13, a_false);
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v0; // ebp
unsigned int v1; // ebp
unsigned int v2; // ebp
unsigned int v3; // ebp
unsigned int v4; // ebp
unsigned int v5; // ebp
unsigned int v6; // ebp
unsigned int v7; // ebp
unsigned int v8; // ebp
unsigned int v9; // ebp
unsigned int v10; // ebp
unsigned int v11; // ebp
__int64 v12; // rbp
unsigned int v13; // eax

v0 = root;
car_set((unsigned int)root, the_global_env);
v1 = cdr(v0);
car_set(v1, allocons);
v2 = cdr(v1);
car_set(v2, current_env);
v3 = cdr(v2);
car_set(v3, env_stack);
v4 = cdr(v3);
car_set(v4, args_stack);
v5 = cdr(v4);
car_set(v5, vars_stack);
v6 = cdr(v5);
car_set(v6, parser_stack);
v7 = cdr(v6);
car_set(v7, state_stack);
v8 = cdr(v7);
car_set(v8, current_state);
v9 = cdr(v8);
car_set(v9, state_constants);
v10 = cdr(v9);
car_set(v10, obarray);
v11 = cdr(v10);
car_set(v11, reg);
v12 = (unsigned int)cdr(v11);
car_set(v12, a_true);
v13 = cdr((unsigned int)v12);
return car_set(v13, a_false);
}

original_code:
static void set_root(void)
{
 cellpoint r = root;
 car_set(r, the_global_env);
 r = cdr(r);
 car_set(r, allocons);
 r = cdr(r);
 car_set(r, current_env);
 r = cdr(r);
 car_set(r, env_stack);
 r = cdr(r);
 car_set(r, args_stack);
 r = cdr(r);
 car_set(r, vars_stack);
 r = cdr(r);
 car_set(r, parser_stack);
 r = cdr(r);
 car_set(r, state_stack);
 r = cdr(r);
 car_set(r, current_state);
 r = cdr(r);
 car_set(r, state_constants);
 r = cdr(r);
 car_set(r, obarray);
 r = cdr(r);
 car_set(r, reg);
 r = cdr(r);
 car_set(r, a_true);
 r = cdr(r);
 car_set(r, a_false);
}

canonical_original_code:
static void set_root()
{
 unsigned int r = root;
 car_set(r, the_global_env);
 r = cdr(r);
 car_set(r, allocons);
 r = cdr(r);
 car_set(r, current_env);
 r = cdr(r);
 car_set(r, env_stack);
 r = cdr(r);
 car_set(r, args_stack);
 r = cdr(r);
 car_set(r, vars_stack);
 r = cdr(r);
 car_set(r, parser_stack);
 r = cdr(r);
 car_set(r, state_stack);
 r = cdr(r);
 car_set(r, current_state);
 r = cdr(r);
 car_set(r, state_constants);
 r = cdr(r);
 car_set(r, obarray);
 r = cdr(r);
 car_set(r, reg);
 r = cdr(r);
 car_set(r, a_true);
 r = cdr(r);
 car_set(r, a_false);
}

variable_types:
r
unsigned int