client

decompiled_code:
void __fastcall __noreturn client(void *a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
__int64 v9; // rbp
__int64 v10; // r12
__int64 v11; // rbx
pthread_t v12; // rax
int v13; // eax
unsigned int v14; // eax
unsigned int v15; // eax
unsigned int v16; // eax
unsigned int v17; // eax
unsigned int v18; // eax
int v19; // eax
int v20; // eax
pthread_mutex_t *mutex; // [rsp+10h] [rbp-1C8h]
int *v22; // [rsp+18h] [rbp-1C0h]
char v23[48]; // [rsp+30h] [rbp-1A8h] BYREF
struct __jmp_buf_tag env; // [rsp+60h] [rbp-178h] BYREF
__pthread_unwind_buf_t buf; // [rsp+140h] [rbp-98h] BYREF

v1 = pthread_mutex_lock(&running_lock);
if ( v1 )
syserr(v1, "Thread mutex lock fail\n");
++running_threads;
v2 = pthread_mutex_unlock(&running_lock);
if ( v2 )
syserr(v2, "Thread mutex unlock fail\n");
v3 = pthread_setcancelstate(0, (int *)&buf.__pad[4] + 1);
if ( v3 )
syserr(v3, "Thread setcancelstate fail\n");
v4 = pthread_setcanceltype(1, (int *)&buf.__pad[4] + 1);
if ( v4 )
syserr(v4, "Thread setcanceltype fail\n");
mutex = (pthread_mutex_t *)((char *)resources + 176 * *((_QWORD *)a1 + 3) - 176);
if ( !_sigsetjmp(&env, 0) )
{
_pthread_register_cancel((__pthread_unwind_buf_t *)&env);
if ( !_sigsetjmp((struct __jmp_buf_tag *)&env.__saved_mask.__val[5], 0) )
{
_pthread_register_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
v5 = pthread_mutex_lock(mutex);
if ( v5 )
syserr(v5, "Thread mutex lock fail\n");
v6 = mutex[2].__owner;
if ( v6 || *((_DWORD *)&mutex[3].__align + 6) == 2 )
{
mutex[2].__owner = v6 + 1;
pthread_cond_wait((pthread_cond_t *)&mutex[1], mutex);
check_int();
--mutex[2].__owner;
}
v7 = *((_DWORD *)&mutex[3].__align + 6);
if ( v7 )
{
*((_DWORD *)&mutex[3].__align + 6) = v7 + 1;
*((_DWORD *)&mutex[3].__align + 9) += *((_QWORD *)a1 + 4);
*((_QWORD *)a1 + 2) = *((int *)&mutex[3].__align + 8);
*((_DWORD *)&mutex[3].__align + 8) = *((_QWORD *)a1 + 1);
if ( *((_DWORD *)&mutex[3].__align + 9) > *((_DWORD *)&mutex[3].__align + 7) )
{
pthread_cond_wait((pthread_cond_t *)(&mutex[2].__align + 2), mutex);
check_int();
}
v8 = *((_DWORD *)&mutex[3].__align + 9);
v9 = (unsigned int)(*((_DWORD *)&mutex[3].__align + 7) - v8);
*((_DWORD *)&mutex[3].__align + 7) = v9;
v10 = *((_QWORD *)a1 + 4);
v11 = v8 - v10;
v12 = pthread_self();
printf(
"Watek %ld przyznal %li+%li zasobow klientom %li %li, pozostalo %i zasobow\n",
v12,
v10,
v11,
*((_QWORD *)a1 + 1),
*((_QWORD *)a1 + 2),
v9);
}
else
{
*(&mutex[4].__align + 1) = (__int64)calloc(4uLL, 1uLL);
*((_DWORD *)&mutex[3].__align + 6) = 1;
*((_DWORD *)&mutex[3].__align + 9) = *((_QWORD *)a1 + 4);
*((_DWORD *)&mutex[3].__align + 8) = *((_QWORD *)a1 + 1);
if ( mutex[2].__owner )
pthread_cond_signal((pthread_cond_t *)&mutex[1]);
pthread_cond_wait((pthread_cond_t *)(&mutex[2].__align + 2), mutex);
check_int();
*((_QWORD *)a1 + 2) = *((int *)&mutex[3].__align + 8);
}
v13 = *((_DWORD *)&mutex[3].__align + 6);
if ( v13 == 2 )
{
*((_DWORD *)&mutex[3].__align + 6) = 1;
pthread_cond_signal((pthread_cond_t *)(&mutex[2].__align + 2));
}
else
{
*((_DWORD *)&mutex[3].__align + 6) = v13 - 1;
pthread_cond_signal((pthread_cond_t *)&mutex[1]);
}
*(_QWORD *)a1 = *((_QWORD *)a1 + 1);
v22 = (int *)*(&mutex[4].__align + 1);
v14 = pthread_mutex_unlock(mutex);
if ( v14 )
syserr(v14, "Thread mutex unlock fail\n");
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
if ( msgsnd(acqu_msg_qid, a1, 0x20uLL, 0) == -1 )
syserr(0LL, "Thread msgsnd fail\n");
check_int();
msgrcv(free_msg_qid, v23, 0x20uLL, *((_QWORD *)a1 + 1), 0);
check_int();
if ( !_sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
_pthread_register_cancel(&buf);
v15 = pthread_mutex_lock(mutex);
if ( v15 )
syserr(v15, "Thread mutex lock fail\n");
if ( *v22 )
{
v19 = *((_DWORD *)a1 + 8) + *v22;
*v22 = v19;
v20 = *((_DWORD *)&mutex[3].__align + 7) + v19;
*((_DWORD *)&mutex[3].__align + 7) = v20;
if ( *((_DWORD *)&mutex[3].__align + 6) == 2 && v20 >= *((_DWORD *)&mutex[3].__align + 9) )
pthread_cond_signal((pthread_cond_t *)(&mutex[2].__align + 2));
}
else
{
*v22 = *((_QWORD *)a1 + 4);
}
v16 = pthread_mutex_unlock(mutex);
if ( v16 )
syserr(v16, "Thread mutex unlock fail\n");
_pthread_unregister_cancel(&buf);
free(a1);
v17 = pthread_mutex_lock(&running_lock);
if ( v17 )
syserr(v17, "Thread mutex lock fail\n");
--running_threads;
v18 = pthread_mutex_unlock(&running_lock);
if ( v18 )
syserr(v18, "Thread mutex unlock fail\n");
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env);
pthread_exit(0LL);
}
client_cleanup(mutex);
_pthread_unwind_next(&buf);
}
client_cleanup(mutex);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
}
client_kill_cleanup((__pid_t *)a1 + 2);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(void *a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
__int64 v9; // rbp
__int64 v10; // r12
__int64 v11; // rbx
pthread_t v12; // rax
int v13; // eax
unsigned int v14; // eax
unsigned int v15; // eax
unsigned int v16; // eax
unsigned int v17; // eax
unsigned int v18; // eax
int v19; // eax
int v20; // eax
pthread_mutex_t *mutex; // [rsp+10h] [rbp-1C8h]
int *v22; // [rsp+18h] [rbp-1C0h]
char v23[48]; // [rsp+30h] [rbp-1A8h] BYREF
struct __jmp_buf_tag env; // [rsp+60h] [rbp-178h] BYREF
__pthread_unwind_buf_t buf; // [rsp+140h] [rbp-98h] BYREF

v1 = pthread_mutex_lock(&running_lock);
if ( v1 )
syserr(v1, "Thread mutex lock fail\n");
++running_threads;
v2 = pthread_mutex_unlock(&running_lock);
if ( v2 )
syserr(v2, "Thread mutex unlock fail\n");
v3 = pthread_setcancelstate(0, (int *)&buf.__pad[4] + 1);
if ( v3 )
syserr(v3, "Thread setcancelstate fail\n");
v4 = pthread_setcanceltype(1, (int *)&buf.__pad[4] + 1);
if ( v4 )
syserr(v4, "Thread setcanceltype fail\n");
mutex = (pthread_mutex_t *)((char *)resources + 176 * *((_QWORD *)a1 + 3) - 176);
if ( !_sigsetjmp(&env, 0) )
{
_pthread_register_cancel((__pthread_unwind_buf_t *)&env);
if ( !_sigsetjmp((struct __jmp_buf_tag *)&env.__saved_mask.__val[5], 0) )
{
_pthread_register_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
v5 = pthread_mutex_lock(mutex);
if ( v5 )
syserr(v5, "Thread mutex lock fail\n");
v6 = mutex[2].__owner;
if ( v6 || *((_DWORD *)&mutex[3].__align + 6) == 2 )
{
mutex[2].__owner = v6 + 1;
pthread_cond_wait((pthread_cond_t *)&mutex[1], mutex);
func6();
--mutex[2].__owner;
}
v7 = *((_DWORD *)&mutex[3].__align + 6);
if ( v7 )
{
*((_DWORD *)&mutex[3].__align + 6) = v7 + 1;
*((_DWORD *)&mutex[3].__align + 9) += *((_QWORD *)a1 + 4);
*((_QWORD *)a1 + 2) = *((int *)&mutex[3].__align + 8);
*((_DWORD *)&mutex[3].__align + 8) = *((_QWORD *)a1 + 1);
if ( *((_DWORD *)&mutex[3].__align + 9) > *((_DWORD *)&mutex[3].__align + 7) )
{
pthread_cond_wait((pthread_cond_t *)(&mutex[2].__align + 2), mutex);
func6();
}
v8 = *((_DWORD *)&mutex[3].__align + 9);
v9 = (unsigned int)(*((_DWORD *)&mutex[3].__align + 7) - v8);
*((_DWORD *)&mutex[3].__align + 7) = v9;
v10 = *((_QWORD *)a1 + 4);
v11 = v8 - v10;
v12 = pthread_self();
printf(
"Watek %ld przyznal %li+%li zasobow klientom %li %li, pozostalo %i zasobow\n",
v12,
v10,
v11,
*((_QWORD *)a1 + 1),
*((_QWORD *)a1 + 2),
v9);
}
else
{
*(&mutex[4].__align + 1) = (__int64)calloc(4uLL, 1uLL);
*((_DWORD *)&mutex[3].__align + 6) = 1;
*((_DWORD *)&mutex[3].__align + 9) = *((_QWORD *)a1 + 4);
*((_DWORD *)&mutex[3].__align + 8) = *((_QWORD *)a1 + 1);
if ( mutex[2].__owner )
pthread_cond_signal((pthread_cond_t *)&mutex[1]);
pthread_cond_wait((pthread_cond_t *)(&mutex[2].__align + 2), mutex);
func6();
*((_QWORD *)a1 + 2) = *((int *)&mutex[3].__align + 8);
}
v13 = *((_DWORD *)&mutex[3].__align + 6);
if ( v13 == 2 )
{
*((_DWORD *)&mutex[3].__align + 6) = 1;
pthread_cond_signal((pthread_cond_t *)(&mutex[2].__align + 2));
}
else
{
*((_DWORD *)&mutex[3].__align + 6) = v13 - 1;
pthread_cond_signal((pthread_cond_t *)&mutex[1]);
}
*(_QWORD *)a1 = *((_QWORD *)a1 + 1);
v22 = (int *)*(&mutex[4].__align + 1);
v14 = pthread_mutex_unlock(mutex);
if ( v14 )
syserr(v14, "Thread mutex unlock fail\n");
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
if ( msgsnd(acqu_msg_qid, a1, 0x20uLL, 0) == -1 )
syserr(0LL, "Thread msgsnd fail\n");
func6();
msgrcv(free_msg_qid, v23, 0x20uLL, *((_QWORD *)a1 + 1), 0);
func6();
if ( !_sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
_pthread_register_cancel(&buf);
v15 = pthread_mutex_lock(mutex);
if ( v15 )
syserr(v15, "Thread mutex lock fail\n");
if ( *v22 )
{
v19 = *((_DWORD *)a1 + 8) + *v22;
*v22 = v19;
v20 = *((_DWORD *)&mutex[3].__align + 7) + v19;
*((_DWORD *)&mutex[3].__align + 7) = v20;
if ( *((_DWORD *)&mutex[3].__align + 6) == 2 && v20 >= *((_DWORD *)&mutex[3].__align + 9) )
pthread_cond_signal((pthread_cond_t *)(&mutex[2].__align + 2));
}
else
{
*v22 = *((_QWORD *)a1 + 4);
}
v16 = pthread_mutex_unlock(mutex);
if ( v16 )
syserr(v16, "Thread mutex unlock fail\n");
_pthread_unregister_cancel(&buf);
free(a1);
v17 = pthread_mutex_lock(&running_lock);
if ( v17 )
syserr(v17, "Thread mutex lock fail\n");
--running_threads;
v18 = pthread_mutex_unlock(&running_lock);
if ( v18 )
syserr(v18, "Thread mutex unlock fail\n");
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env);
pthread_exit(0LL);
}
func0(mutex);
_pthread_unwind_next(&buf);
}
func0(mutex);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
}
func1((__pid_t *)a1 + 2);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env);
}

original_code:
void * client(void * m){
 t_msg * msg = m;
 int err;
 int state;
 int * pair_finished;
 if ((err = pthread_mutex_lock(&(running_lock))) != 0)
  syserr(err, "Thread mutex lock fail\n");
  running_threads ++;
 if ((err = pthread_mutex_unlock(&(running_lock))) != 0)
  syserr(err, "Thread mutex unlock fail\n");
 if ((err = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &state)) != 0)
  syserr(err, "Thread setcancelstate fail\n");
 if ((err = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &state)) != 0)
  syserr(err, "Thread setcanceltype fail\n");
 if (debug)
  printf("Thread with msg %li %li %li %li %li\n",
     msg->mtype,
     msg->my_pid,
     msg->res_number,
     msg->res_quantity,
     msg->partner_pid);
 t_resource * res = &(resources[msg->res_number-1]);
 do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (client_kill_cleanup); void *__cancel_arg = ((void *)&(msg->my_pid)); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {;
 do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (client_cleanup); void *__cancel_arg = ((void *)&(res->mutex)); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {;
 if ((err = pthread_mutex_lock(&(res->mutex))) != 0)
  syserr(err, "Thread mutex lock fail\n");
 if (res->c_res_q != 0 || res->c_res_p == 2){
  res->c_res_q++;
  if (debug)
   printf("Czekamy na miejsce w parze %li\n", msg->my_pid);
  pthread_cond_wait(&(res->res_q), &(res->mutex));
  check_int();
  res->c_res_q--;
 }
 if (res->c_res_p == 0){
  res->partner_finished = calloc(sizeof(int), 1);
  res->c_res_p++;
  res->pair_weight = msg->res_quantity;
  res->pair_pid = msg->my_pid;
  if (res->c_res_q != 0)
   pthread_cond_signal(&(res->res_q));
  if (debug)
   printf("Czekamy na drugiego w parze %li\n", msg->my_pid);
  pthread_cond_wait(&(res->res_p), &(res->mutex));
  check_int();
  msg->partner_pid = res->pair_pid;
 } else {
  res->c_res_p++;
  res->pair_weight += msg->res_quantity;
  msg->partner_pid = res->pair_pid;
  res->pair_pid = msg->my_pid;
  if (res->pair_weight > res->free){
   if (debug)
    printf("Czekamy na wolne zasoby %li\n", msg->my_pid);
   pthread_cond_wait(&(res->res_p), &(res->mutex));
   check_int();
  }
  res->free -= res->pair_weight;
  printf("Watek %ld przyznal %li+%li zasobow klientom %li %li, pozostalo %i zasobow\n",
   pthread_self(),
   msg->res_quantity,
   res->pair_weight - msg->res_quantity,
   msg->my_pid,
   msg->partner_pid,
   res->free);
 }
 if (res->c_res_p == 2){
  res->c_res_p--;
  pthread_cond_signal(&(res->res_p));
 } else {
  res->c_res_p--;
  pthread_cond_signal(&(res->res_q));
 }
 msg->mtype = msg->my_pid;
 pair_finished = res->partner_finished;
 if ((err = pthread_mutex_unlock(&(res->mutex))) != 0)
  syserr(err, "Thread mutex unlock fail\n");
 do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (0) __cancel_routine (__cancel_arg); } while (0);
 if (msgsnd(acqu_msg_qid, msg, sizeof(long) * 4, 0) == -1)
  syserr(0, "Thread msgsnd fail\n");
 if (debug)
  printf("Message sent to klient %li, starting work\n", msg->mtype);
 check_int();
 t_msg msgend;
 if (debug)
  printf("Waiting for klient %li end\n", msg->my_pid);
 msgrcv(free_msg_qid, &msgend, sizeof(long) * 4, msg->my_pid, 0);
 check_int();
 do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (client_cleanup); void *__cancel_arg = ((void *)&(res->mutex)); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {;
 if ((err = pthread_mutex_lock(&(res->mutex))) != 0)
  syserr(err, "Thread mutex lock fail\n");
 if ((*pair_finished) == 0){
  *pair_finished = msg->res_quantity;
 } else {
  *pair_finished += msg->res_quantity;
  res->free += *pair_finished;
  if (res->c_res_p == 2 && res->free >= res->pair_weight)
   pthread_cond_signal(&(res->res_p));
  if (debug)
   printf("Zwolniono %i dostepnych %i\n", *pair_finished, res->free);
 }
 if ((err = pthread_mutex_unlock(&(res->mutex))) != 0)
  syserr(err, "Thread mutex unlock fail\n");
 do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (0) __cancel_routine (__cancel_arg); } while (0);
 if (debug)
  printf("Koniec watku %li\n", msg->my_pid);
 free(msg);
 if ((err = pthread_mutex_lock(&(running_lock))) != 0)
  syserr(err, "Thread mutex lock fail\n");
 running_threads --;
 if ((err = pthread_mutex_unlock(&(running_lock))) != 0)
  syserr(err, "Thread mutex unlock fail\n");
 do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (0) __cancel_routine (__cancel_arg); } while (0);
 pthread_exit(0);
}

canonical_original_code:
void *client(void *m){
 struct msg *msg = m;
 int err;
 int state;
 int *pair_finished;
 if ((err = pthread_mutex_lock(&(running_lock))) != 0)
  syserr(err, "Thread mutex lock fail\n");
  running_threads ++;
 if ((err = pthread_mutex_unlock(&(running_lock))) != 0)
  syserr(err, "Thread mutex unlock fail\n");
 if ((err = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &state)) != 0)
  syserr(err, "Thread setcancelstate fail\n");
 if ((err = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &state)) != 0)
  syserr(err, "Thread setcanceltype fail\n");
 if (debug)
  printf("Thread with msg %li %li %li %li %li\n",
     msg->mtype,
     msg->my_pid,
     msg->res_number,
     msg->res_quantity,
     msg->partner_pid);
 struct resource *res = &(resources[msg->res_number-1]);
 do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (client_kill_cleanup); void *__cancel_arg = ((void *)&(msg->my_pid)); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {;
 do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (client_cleanup); void *__cancel_arg = ((void *)&(res->mutex)); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {;
 if ((err = pthread_mutex_lock(&(res->mutex))) != 0)
  syserr(err, "Thread mutex lock fail\n");
 if (res->c_res_q != 0 || res->c_res_p == 2){
  res->c_res_q++;
  if (debug)
   printf("Czekamy na miejsce w parze %li\n", msg->my_pid);
  pthread_cond_wait(&(res->res_q), &(res->mutex));
  check_int();
  res->c_res_q--;
 }
 if (res->c_res_p == 0){
  res->partner_finished = calloc(sizeof(int), 1);
  res->c_res_p++;
  res->pair_weight = msg->res_quantity;
  res->pair_pid = msg->my_pid;
  if (res->c_res_q != 0)
   pthread_cond_signal(&(res->res_q));
  if (debug)
   printf("Czekamy na drugiego w parze %li\n", msg->my_pid);
  pthread_cond_wait(&(res->res_p), &(res->mutex));
  check_int();
  msg->partner_pid = res->pair_pid;
 } else {
  res->c_res_p++;
  res->pair_weight += msg->res_quantity;
  msg->partner_pid = res->pair_pid;
  res->pair_pid = msg->my_pid;
  if (res->pair_weight > res->free){
   if (debug)
    printf("Czekamy na wolne zasoby %li\n", msg->my_pid);
   pthread_cond_wait(&(res->res_p), &(res->mutex));
   check_int();
  }
  res->free -= res->pair_weight;
  printf("Watek %ld przyznal %li+%li zasobow klientom %li %li, pozostalo %i zasobow\n",
   pthread_self(),
   msg->res_quantity,
   res->pair_weight - msg->res_quantity,
   msg->my_pid,
   msg->partner_pid,
   res->free);
 }
 if (res->c_res_p == 2){
  res->c_res_p--;
  pthread_cond_signal(&(res->res_p));
 } else {
  res->c_res_p--;
  pthread_cond_signal(&(res->res_q));
 }
 msg->mtype = msg->my_pid;
 pair_finished = res->partner_finished;
 if ((err = pthread_mutex_unlock(&(res->mutex))) != 0)
  syserr(err, "Thread mutex unlock fail\n");
 do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (0) __cancel_routine (__cancel_arg); } while (0);
 if (msgsnd(acqu_msg_qid, msg, sizeof(long) * 4, 0) == -1)
  syserr(0, "Thread msgsnd fail\n");
 if (debug)
  printf("Message sent to klient %li, starting work\n", msg->mtype);
 check_int();
 struct msg msgend;
 if (debug)
  printf("Waiting for klient %li end\n", msg->my_pid);
 msgrcv(free_msg_qid, &msgend, sizeof(long) * 4, msg->my_pid, 0);
 check_int();
 do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (client_cleanup); void *__cancel_arg = ((void *)&(res->mutex)); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {;
 if ((err = pthread_mutex_lock(&(res->mutex))) != 0)
  syserr(err, "Thread mutex lock fail\n");
 if ((*pair_finished) == 0){
  *pair_finished = msg->res_quantity;
 } else {
  *pair_finished += msg->res_quantity;
  res->free += *pair_finished;
  if (res->c_res_p == 2 && res->free >= res->pair_weight)
   pthread_cond_signal(&(res->res_p));
  if (debug)
   printf("Zwolniono %i dostepnych %i\n", *pair_finished, res->free);
 }
 if ((err = pthread_mutex_unlock(&(res->mutex))) != 0)
  syserr(err, "Thread mutex unlock fail\n");
 do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (0) __cancel_routine (__cancel_arg); } while (0);
 if (debug)
  printf("Koniec watku %li\n", msg->my_pid);
 free(msg);
 if ((err = pthread_mutex_lock(&(running_lock))) != 0)
  syserr(err, "Thread mutex lock fail\n");
 running_threads --;
 if ((err = pthread_mutex_unlock(&(running_lock))) != 0)
  syserr(err, "Thread mutex unlock fail\n");
 do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (0) __cancel_routine (__cancel_arg); } while (0);
 pthread_exit(0);
}

variable_types:
m
void *

variable_types: struct msg { long mtype; long my_pid; long partner_pid; long res_number; long res_quantity; } *

variable_types: state int

variable_types: struct __pthread_unwind_buf_t { struct { long __cancel_jmp_buf[8]; int __mask_was_saved; } __cancel_jmp_buf[1]; void *__pad[4]; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
unsigned int v4; // eax
int v5; // ebx
__int64 v6; // rbp
int v7; // ebx
unsigned int v8; // eax
void *v10; // rbx
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

if ( argc != 3 )
{
puts("Wrong arguments, terminating");
exit(0);
}
K = atoi(argv[1]);
N = atoi(argv[2]);
interrupt = 0;
running_threads = 0;
if ( signal(2, (__sighandler_t)exit_server) == (__sighandler_t)-1LL )
syserr(0LL, "Server: signal failed\n");
if ( signal(15, (__sighandler_t)exit_server) == (__sighandler_t)-1LL )
syserr(0LL, "Server: signal failed\n");
v3 = pthread_mutex_init(&running_lock, 0LL);
if ( v3 )
syserr(v3, "Mutex init fail\n");
v4 = pthread_cond_init(&no_threads, 0LL);
if ( v4 )
syserr(v4, "Cond init fail\n");
v5 = K;
resources = calloc(0xB0uLL, K);
if ( v5 > 0 )
{
v6 = 0LL;
v7 = 0;
do
{
res_init((__int64)resources + v6, N);
++v7;
v6 += 176LL;
}
while ( K > v7 );
}
query_msg_qid = msgget(1234, 1974);
if ( query_msg_qid == -1 )
syserr(0LL, "Server: msgget failed\n");
free_msg_qid = msgget(1236, 1974);
if ( free_msg_qid == -1 )
syserr(0LL, "Server: msgget failed\n");
acqu_msg_qid = msgget(1235, 1974);
if ( acqu_msg_qid == -1 )
syserr(0LL, "Server: msgget failed\n");
if ( pthread_attr_init(&client_thread_attr) == -1 )
syserr(0xFFFFFFFFLL, "Server pthread attr init failed\n");
v8 = pthread_attr_setdetachstate(&client_thread_attr, 1);
if ( v8 )
syserr(v8, "Server: setdetachstate failed\n");
while ( interrupt != 1 )
{
v10 = malloc(0x28uLL);
msgrcv(query_msg_qid, v10, 0x20uLL, 32769LL, 0);
if ( pthread_create(newthread, &client_thread_attr, (void *(*)(void *))client, v10) == -1 )
syserr(0xFFFFFFFFLL, "Server: pthread create failed\n");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
unsigned int v4; // eax
int v5; // ebx
__int64 v6; // rbp
int v7; // ebx
unsigned int v8; // eax
void *v10; // rbx
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

if ( argc != 3 )
{
puts("Wrong arguments, terminating");
exit(0);
}
K = atoi(argv[1]);
N = atoi(argv[2]);
interrupt = 0;
running_threads = 0;
if ( signal(2, (__sighandler_t)exit_server) == (__sighandler_t)-1LL )
syserr(0LL, "Server: signal failed\n");
if ( signal(15, (__sighandler_t)exit_server) == (__sighandler_t)-1LL )
syserr(0LL, "Server: signal failed\n");
v3 = pthread_mutex_init(&running_lock, 0LL);
if ( v3 )
syserr(v3, "Mutex init fail\n");
v4 = pthread_cond_init(&no_threads, 0LL);
if ( v4 )
syserr(v4, "Cond init fail\n");
v5 = K;
resources = calloc(0xB0uLL, K);
if ( v5 > 0 )
{
v6 = 0LL;
v7 = 0;
do
{
func2((__int64)resources + v6, N);
++v7;
v6 += 176LL;
}
while ( K > v7 );
}
query_msg_qid = msgget(1234, 1974);
if ( query_msg_qid == -1 )
syserr(0LL, "Server: msgget failed\n");
free_msg_qid = msgget(1236, 1974);
if ( free_msg_qid == -1 )
syserr(0LL, "Server: msgget failed\n");
acqu_msg_qid = msgget(1235, 1974);
if ( acqu_msg_qid == -1 )
syserr(0LL, "Server: msgget failed\n");
if ( pthread_attr_init(&client_thread_attr) == -1 )
syserr(0xFFFFFFFFLL, "Server pthread attr init failed\n");
v8 = pthread_attr_setdetachstate(&client_thread_attr, 1);
if ( v8 )
syserr(v8, "Server: setdetachstate failed\n");
while ( interrupt != 1 )
{
v10 = malloc(0x28uLL);
msgrcv(query_msg_qid, v10, 0x20uLL, 32769LL, 0);
if ( pthread_create(newthread, &client_thread_attr, (void *(*)(void *))client, v10) == -1 )
syserr(0xFFFFFFFFLL, "Server: pthread create failed\n");
}
return 0;
}

original_code:
int main(int argc, char ** argv){
 int err;
 if (argc != 3){
  printf("Wrong arguments, terminating\n");
  exit(0);
 }
 K = atoi(argv[1]);
 N = atoi(argv[2]);
 interrupt = 0;
 running_threads = 0;
 if (signal(2, exit_server) == ((__sighandler_t) -1))
  syserr(0, "Server: signal failed\n");
 if (signal(15, exit_server) == ((__sighandler_t) -1))
  syserr(0, "Server: signal failed\n");
 if (debug)
  printf("Server: run with K: %i N: %i\n", K, N);
 int i = 0;
 if ((err = pthread_mutex_init(&running_lock, 0)) != 0)
  syserr(err,"Mutex init fail\n");
 if ((err = pthread_cond_init(&no_threads, 0)) != -0)
  syserr(err,"Cond init fail\n");
 resources = calloc(sizeof(t_resource), K);
 for (i = 0; i < K; i++){
  res_init(&resources[i], N);
 }
 if (debug)
  printf("Server: resources initialized\n");
 if ((query_msg_qid = msgget(QUER_MSGQID, 0666 | 01000 | 02000)) == -1)
  syserr(0,"Server: msgget failed\n");
 if ((free_msg_qid = msgget(FREE_MSGQID, 0666 | 01000 | 02000)) == -1)
  syserr(0,"Server: msgget failed\n");
 if ((acqu_msg_qid = msgget(ACQD_MSGQID, 0666 | 01000 | 02000)) == -1)
  syserr(0,"Server: msgget failed\n");
 if (debug)
  printf("Server: msg queue created\n");
 if ((err = pthread_attr_init(&client_thread_attr)) == -1)
  syserr(err, "Server pthread attr init failed\n");
 if ((err = pthread_attr_setdetachstate(
    &client_thread_attr,
    PTHREAD_CREATE_DETACHED)) != 0)
  syserr(err, "Server: setdetachstate failed\n");
 if (debug)
  printf("Server: initialization successful\n");
 while(interrupt != 1){
  t_msg * msg = malloc(sizeof(t_msg));
  if (debug)
   printf("Waiting for msg\n");
  msgrcv(query_msg_qid, msg, sizeof(long) * 4, 32768 +1, 0);
  pthread_t client_thread;
  if ((err = pthread_create(
     &client_thread,
     &client_thread_attr,
     client, msg))
     == -1)
   syserr(err, "Server: pthread create failed\n");
  if (debug)
   printf("Msg rcv %li %li %li %li\n",
    msg->mtype,
    msg->res_number,
    msg->res_quantity,
    msg->partner_pid);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv){
 int err;
 if (argc != 3){
  printf("Wrong arguments, terminating\n");
  exit(0);
 }
 K = atoi(argv[1]);
 N = atoi(argv[2]);
 interrupt = 0;
 running_threads = 0;
 if (signal(2, exit_server) == ((__sighandler_t) -1))
  syserr(0, "Server: signal failed\n");
 if (signal(15, exit_server) == ((__sighandler_t) -1))
  syserr(0, "Server: signal failed\n");
 if (debug)
  printf("Server: run with K: %i N: %i\n", K, N);
 int i = 0;
 if ((err = pthread_mutex_init(&running_lock, 0)) != 0)
  syserr(err,"Mutex init fail\n");
 if ((err = pthread_cond_init(&no_threads, 0)) != -0)
  syserr(err,"Cond init fail\n");
 resources = calloc(sizeof(t_resource), K);
 for (i = 0; i < K; i++){
  res_init(&resources[i], N);
 }
 if (debug)
  printf("Server: resources initialized\n");
 if ((query_msg_qid = msgget(QUER_MSGQID, 0666 | 01000 | 02000)) == -1)
  syserr(0,"Server: msgget failed\n");
 if ((free_msg_qid = msgget(FREE_MSGQID, 0666 | 01000 | 02000)) == -1)
  syserr(0,"Server: msgget failed\n");
 if ((acqu_msg_qid = msgget(ACQD_MSGQID, 0666 | 01000 | 02000)) == -1)
  syserr(0,"Server: msgget failed\n");
 if (debug)
  printf("Server: msg queue created\n");
 if ((err = pthread_attr_init(&client_thread_attr)) == -1)
  syserr(err, "Server pthread attr init failed\n");
 if ((err = pthread_attr_setdetachstate(
    &client_thread_attr,
    PTHREAD_CREATE_DETACHED)) != 0)
  syserr(err, "Server: setdetachstate failed\n");
 if (debug)
  printf("Server: initialization successful\n");
 while(interrupt != 1){
  struct msg *msg = malloc(sizeof(t_msg));
  if (debug)
   printf("Waiting for msg\n");
  msgrcv(query_msg_qid, msg, sizeof(long) * 4, 32768 +1, 0);
  unsigned long client_thread;
  if ((err = pthread_create(
     &client_thread,
     &client_thread_attr,
     client, msg))
     == -1)
   syserr(err, "Server: pthread create failed\n");
  if (debug)
   printf("Msg rcv %li %li %li %li\n",
    msg->mtype,
    msg->res_number,
    msg->res_quantity,
    msg->partner_pid);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: err int

variable_types: i int

return_type: int

user_defined_types: struct msg { long mtype; long my_pid; long partner_pid; long res_number; long res_quantity; }


syserr

decompiled_code:
void __noreturn syserr(int errnum, char *format, ...)
{
char *v2; // rax
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

va_start(arg, format);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
v2 = strerror(errnum);
fprintf(stderr, " (%d; %s)\n", (unsigned int)errnum, v2);
exit(1);
}

canonical_decompiled_code:
void __noreturn func7(int errnum, char *format, ...)
{
char *v2; // rax
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

va_start(arg, format);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
v2 = strerror(errnum);
fprintf(stderr, " (%d; %s)\n", (unsigned int)errnum, v2);
exit(1);
}

original_code:
void syserr(int bl, const char *fmt, ...)
{
  va_list fmt_args;
  fprintf(stderr, "ERROR: ");
  __builtin_va_start(fmt_args,fmt);
  vfprintf(stderr, fmt, fmt_args);
  __builtin_va_end(fmt_args);
  fprintf(stderr," (%d; %s)\n", bl, strerror(bl));
  exit(1);
}

canonical_original_code:
void syserr(int bl, char *fmt, ...)
{
  __builtin_va_list fmt_args;
  fprintf(stderr, "ERROR: ");
  __builtin_va_start(fmt_args,fmt);
  vfprintf(stderr, fmt, fmt_args);
  __builtin_va_end(fmt_args);
  fprintf(stderr," (%d; %s)\n", bl, strerror(bl));
  exit(1);
}

variable_types: bl int

variable_types:
fmt
char *

return_type: void


fatal

decompiled_code:
void __noreturn fatal(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func8(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

original_code:
void fatal(const char *fmt, ...)
{
  va_list fmt_args;
  fprintf(stderr, "ERROR: ");
  __builtin_va_start(fmt_args,fmt);
  vfprintf(stderr, fmt, fmt_args);
  __builtin_va_end(fmt_args);
  fprintf(stderr,"\n");
  exit(1);
}

canonical_original_code:
void fatal(char *fmt, ...)
{
  __builtin_va_list fmt_args;
  fprintf(stderr, "ERROR: ");
  __builtin_va_start(fmt_args,fmt);
  vfprintf(stderr, fmt, fmt_args);
  __builtin_va_end(fmt_args);
  fprintf(stderr,"\n");
  exit(1);
}


decompiled_code:
double __fastcall slope2(double a1, double a2, double a3, double a4)
{
double v4; // xmm7_8
double v6; // [rsp+20h] [rbp-18h]
double v7; // [rsp+28h] [rbp-10h]

v6 = (double)(int)((__int64 (*)(void))function)();
v7 = (double)(int)function(0.5 * a4 + a1, v6 * a4 * 0.5 + a2);
v4 = (double)(int)function(0.5 * a4 + a1, a4 * v7 * 0.5 + a2);
return (v7 + v7 + v6 + v4 + v4 + (double)(int)function(a1 + a4, a4 * v4 + a2)) / 6.0;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2, double a3, double a4)
{
double v4; // xmm7_8
double v6; // [rsp+20h] [rbp-18h]
double v7; // [rsp+28h] [rbp-10h]

v6 = (double)(int)((__int64 (*)(void))function)();
v7 = (double)(int)function(0.5 * a4 + a1, v6 * a4 * 0.5 + a2);
v4 = (double)(int)function(0.5 * a4 + a1, a4 * v7 * 0.5 + a2);
return (v7 + v7 + v6 + v4 + v4 + (double)(int)function(a1 + a4, a4 * v4 + a2)) / 6.0;
}

original_code:
double slope2(double x, double y1, double y2, double h)
{
 double k1 = function(x,y1);
 double k2 = function(x + h/2, y1 + k1*h/2);
 double k3 = function(x + h/2, y1 + k2*h/2);
 double k4 = function(x + h, y1 + k3*h);
 return (k1+2*k2+2*k3+k4)/6;
}

variable_types: x double

variable_types: h double

return_type: double


decompiled_code:
double __fastcall slope1(double a1, double a2, double a3, double a4)
{
double v4; // xmm0_8

v4 = a3 * a4 * 0.5 + a3;
return (v4 + v4 + a3 + a4 * v4 * 0.5 + a3 + a4 * v4 * 0.5 + a3 + a4 * (a4 * v4 * 0.5 + a3) + a3) / 6.0;
}

original_code:
double slope1(double x, double y1, double y2, double h)
{
 double k1 = y2;
 double k2 = y2 + k1*h/2;
 double k3 = y2 + k2*h/2;
 double k4 = y2 + k3*h;
 return (k1+2*k2+2*k3+k4)/6;
}


function

decompiled_code:
double __fastcall function(double a1, double a2)
{
return sin(a2) * -4.0;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2)
{
return sin(a2) * -4.0;
}

original_code:
double function(double x, double y)
{
 return (-4*(sin(y)));
}

variable_types: y double


repo: andrew-bodine/dragon

decompiled_code:
_DWORD *make_integer_record()
{
_DWORD *v0; // rax
_DWORD *v1; // rbx
_DWORD *v2; // rax

v0 = malloc(0x10uLL);
if ( !v0 )
_assert_fail("ptr != NULL", "sym_table.c", 0x10u, "make_integer_record");
v1 = v0;
*v0 = 274;
v2 = malloc(8uLL);
*((_QWORD *)v1 + 1) = v2;
if ( !v2 )
_assert_fail("ptr->record.i_info != NULL", "sym_table.c", 0x14u, "make_integer_record");
*v2 = 0;
v2[1] = 0;
return v1;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *v0; // rax
_DWORD *v1; // rbx
_DWORD *v2; // rax

v0 = malloc(0x10uLL);
if ( !v0 )
_assert_fail("ptr != NULL", "sym_table.c", 0x10u, "make_integer_record");
v1 = v0;
*v0 = 274;
v2 = malloc(8uLL);
*((_QWORD *)v1 + 1) = v2;
if ( !v2 )
_assert_fail("ptr->record.i_info != NULL", "sym_table.c", 0x14u, "make_integer_record");
*v2 = 0;
v2[1] = 0;
return v1;
}

original_code:
r_ptr *make_integer_record( ) {
 r_ptr *ptr;
 ptr = ( r_ptr * )malloc( sizeof( r_ptr ) );
 ((void) sizeof ((ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr != ((void *)0)) ; else __assert_fail ("ptr != NULL", "sym_table.c", 16, __extension__ __PRETTY_FUNCTION__); }));
 ptr->e_rtype = 274;
 ptr->record.i_info = ( i_rinfo * )malloc( sizeof( i_rinfo ) );
 ((void) sizeof ((ptr->record.i_info != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr->record.i_info != ((void *)0)) ; else __assert_fail ("ptr->record.i_info != NULL", "sym_table.c", 20, __extension__ __PRETTY_FUNCTION__); }));
 ptr->record.i_info->e_init = 0;
 ptr->record.i_info->e_value = 0;
 return ptr;
}

canonical_original_code:
struct r_ptr *make_integer_record() {
 struct r_ptr *ptr;
 ptr = ( struct r_ptr * )malloc( sizeof( r_ptr ) );
 ((void) sizeof ((ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr != ((void *)0)) ; else __assert_fail ("ptr != NULL", "sym_table.c", 16, __extension__ __PRETTY_FUNCTION__); }));
 ptr->e_rtype = 274;
 ptr->record.i_info = ( struct i_rinfo * )malloc( sizeof( i_rinfo ) );
 ((void) sizeof ((ptr->record.i_info != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr->record.i_info != ((void *)0)) ; else __assert_fail ("ptr->record.i_info != NULL", "sym_table.c", 20, __extension__ __PRETTY_FUNCTION__); }));
 ptr->record.i_info->e_init = 0;
 ptr->record.i_info->e_value = 0;
 return ptr;
}

variable_types: struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n { struct t_entry { char *e_symbol; struct r_ptr *e_record; struct t_entry *n_entry; } *e_ptr; struct ident_n *n_ident; } *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *

user_defined_types: struct r_ptr { int e_rtype; union { struct i_rinfo *i_info; struct r_rinfo *r_info; struct a_rinfo *a_info; struct f_rinfo *f_info; struct p_rinfo *p_info; } record; }

user_defined_types: struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n *a_ptr; }

user_defined_types: struct ident_n { struct t_entry *e_ptr; struct ident_n *n_ident; }


decompiled_code:
_DWORD *make_real_record()
{
_DWORD *v0; // rax
_DWORD *v1; // rbx
_DWORD *v2; // rax

v0 = malloc(0x10uLL);
if ( !v0 )
_assert_fail("ptr != NULL", "sym_table.c", 0x1Eu, "make_real_record");
v1 = v0;
*v0 = 275;
v2 = malloc(8uLL);
*((_QWORD *)v1 + 1) = v2;
if ( !v2 )
_assert_fail("ptr->record.r_info != NULL", "sym_table.c", 0x22u, "make_real_record");
*v2 = 0;
v2[1] = 0;
return v1;
}

canonical_decompiled_code:
_DWORD *func1()
{
_DWORD *v0; // rax
_DWORD *v1; // rbx
_DWORD *v2; // rax

v0 = malloc(0x10uLL);
if ( !v0 )
_assert_fail("ptr != NULL", "sym_table.c", 0x1Eu, "make_real_record");
v1 = v0;
*v0 = 275;
v2 = malloc(8uLL);
*((_QWORD *)v1 + 1) = v2;
if ( !v2 )
_assert_fail("ptr->record.r_info != NULL", "sym_table.c", 0x22u, "make_real_record");
*v2 = 0;
v2[1] = 0;
return v1;
}

original_code:
r_ptr *make_real_record( ) {
 r_ptr *ptr;
 ptr = ( r_ptr * )malloc( sizeof( r_ptr ) );
 ((void) sizeof ((ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr != ((void *)0)) ; else __assert_fail ("ptr != NULL", "sym_table.c", 30, __extension__ __PRETTY_FUNCTION__); }));
 ptr->e_rtype = 275;
 ptr->record.r_info = ( r_rinfo * )malloc( sizeof( r_rinfo ) );
 ((void) sizeof ((ptr->record.r_info != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr->record.r_info != ((void *)0)) ; else __assert_fail ("ptr->record.r_info != NULL", "sym_table.c", 34, __extension__ __PRETTY_FUNCTION__); }));
 ptr->record.r_info->e_init = 0;
 ptr->record.r_info->e_value = ( float )0;
 return ptr;
}

canonical_original_code:
struct r_ptr *make_real_record() {
 struct r_ptr *ptr;
 ptr = ( struct r_ptr * )malloc( sizeof( r_ptr ) );
 ((void) sizeof ((ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr != ((void *)0)) ; else __assert_fail ("ptr != NULL", "sym_table.c", 30, __extension__ __PRETTY_FUNCTION__); }));
 ptr->e_rtype = 275;
 ptr->record.r_info = ( struct r_rinfo * )malloc( sizeof( r_rinfo ) );
 ((void) sizeof ((ptr->record.r_info != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr->record.r_info != ((void *)0)) ; else __assert_fail ("ptr->record.r_info != NULL", "sym_table.c", 34, __extension__ __PRETTY_FUNCTION__); }));
 ptr->record.r_info->e_init = 0;
 ptr->record.r_info->e_value = ( float )0;
 return ptr;
}

return_type: struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n { struct t_entry { char *e_symbol; struct r_ptr *e_record; struct t_entry *n_entry; } *e_ptr; struct ident_n *n_ident; } *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *


decompiled_code:
void __fastcall free_record(void *ptr)
{
int v1; // eax

if ( ptr )
{
v1 = *(_DWORD *)ptr;
if ( *(_DWORD *)ptr != 274 )
{
if ( v1 > 274 )
{
if ( v1 == 275 )
goto LABEL_8;
}
else
{
if ( v1 == 261 )
goto LABEL_8;
if ( v1 == 270 )
{
free(*(void **)(*((_QWORD *)ptr + 1) + 8LL));
goto LABEL_8;
}
}
LABEL_9:
free(ptr);
return;
}
LABEL_8:
free(*((void **)ptr + 1));
goto LABEL_9;
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
int v1; // eax

if ( ptr )
{
v1 = *(_DWORD *)ptr;
if ( *(_DWORD *)ptr != 274 )
{
if ( v1 > 274 )
{
if ( v1 == 275 )
goto LABEL_8;
}
else
{
if ( v1 == 261 )
goto LABEL_8;
if ( v1 == 270 )
{
free(*(void **)(*((_QWORD *)ptr + 1) + 8LL));
goto LABEL_8;
}
}
LABEL_9:
free(ptr);
return;
}
LABEL_8:
free(*((void **)ptr + 1));
goto LABEL_9;
}
}

original_code:
void free_record( r_ptr *ptr ) {
 if( ptr == ((void *)0) ) return;
 switch( ptr->e_rtype ) {
   case 274:
    free( ptr->record.i_info );
    break;
   case 275:
    free( ptr->record.r_info );
    break;
   case 270:
    if( ptr->record.a_info->a_type == 274 )
     free( ptr->record.a_info->e_value.i_ptr );
    else
     free( ptr->record.a_info->e_value.r_ptr );
    free( ptr->record.a_info );
    break;
   case 261:
    free( ptr->record.f_info );
    break;
   case 262:
    break;
   default:
    break;
  }
 free( ptr );
}

canonical_original_code:
void free_record(struct r_ptr *ptr) {
 if( ptr == ((void *)0) ) return;
 switch( ptr->e_rtype ) {
   case 274:
    free( ptr->record.i_info );
    break;
   case 275:
    free( ptr->record.r_info );
    break;
   case 270:
    if( ptr->record.a_info->a_type == 274 )
     free( ptr->record.a_info->e_value.i_ptr );
    else
     free( ptr->record.a_info->e_value.r_ptr );
    free( ptr->record.a_info );
    break;
   case 261:
    free( ptr->record.f_info );
    break;
   case 262:
    break;
   default:
    break;
  }
 free( ptr );
}

user_defined_types: struct i_rinfo { int e_init; int e_value; }

user_defined_types: struct r_rinfo { int e_init; float e_value; }

user_defined_types: struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; }

user_defined_types: struct p_rinfo { struct ident_n *a_ptr; }

user_defined_types: struct t_entry { char *e_symbol; struct r_ptr *e_record; struct t_entry *n_entry; }


decompiled_code:
void __fastcall install_entry_record(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void install_entry_record( t_entry *ptr, r_ptr *record ) {
 ptr->e_record = record;
}

canonical_original_code:
void install_entry_record(struct t_entry *ptr, struct r_ptr *record) {
 ptr->e_record = record;
}

variable_types: struct t_entry { char *e_symbol; struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n { struct t_entry *e_ptr; struct ident_n *n_ident; } *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *e_record; struct t_entry *n_entry; } *

variable_types:
record
struct r_ptr *


decompiled_code:
void __fastcall free_entry(void *ptr)
{
if ( ptr )
{
free_entry(*((void **)ptr + 2));
free(*(void **)ptr);
free_record(*((void **)ptr + 1));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
if ( ptr )
{
func4(*((void **)ptr + 2));
free(*(void **)ptr);
func2(*((void **)ptr + 1));
free(ptr);
}
}

original_code:
void free_entry( t_entry *ptr ) {
 if( ptr == ((void *)0) )
  return;
 else {
  free_entry( ptr->n_entry );
  free( ptr->e_symbol );
  free_record( ptr->e_record );
  free( ptr );
 }
}

canonical_original_code:
void free_entry(struct t_entry *ptr) {
 if( ptr == ((void *)0) )
  return;
 else {
  free_entry( ptr->n_entry );
  free( ptr->e_symbol );
  free_record( ptr->e_record );
  free( ptr );
 }
}


decompiled_code:
__int64 __fastcall pop_scope(void *ptr)
{
__int64 v1; // r13
void **v2; // rbx

if ( !ptr )
return 0LL;
v1 = *((_QWORD *)ptr + 211);
v2 = (void **)ptr;
do
{
if ( *v2 )
free_entry(*v2);
++v2;
}
while ( v2 != (void **)((char *)ptr + 1688) );
free(ptr);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func5(void *ptr)
{
__int64 v1; // r13
void **v2; // rbx

if ( !ptr )
return 0LL;
v1 = *((_QWORD *)ptr + 211);
v2 = (void **)ptr;
do
{
if ( *v2 )
func4(*v2);
++v2;
}
while ( v2 != (void **)((char *)ptr + 1688) );
free(ptr);
return v1;
}

original_code:
s_table *pop_scope( s_table *s_stack ) {
 s_table *ptr;
 int i;
 if( s_stack == ((void *)0) )
  return ((void *)0);
 else {
  ptr = s_stack->e_scope;
  for( i = 0; i < 211; i++ ) {
   if( s_stack->s_entries[ i ] != ((void *)0) )
    free_entry( s_stack->s_entries[ i ] );
  }
  free( s_stack );
  return ptr;
 }
}

canonical_original_code:
struct s_table *pop_scope(struct s_table *s_stack) {
 struct s_table *ptr;
 int i;
 if( s_stack == ((void *)0) )
  return ((void *)0);
 else {
  ptr = s_stack->e_scope;
  for( i = 0; i < 211; i++ ) {
   if( s_stack->s_entries[ i ] != ((void *)0) )
    free_entry( s_stack->s_entries[ i ] );
  }
  free( s_stack );
  return ptr;
 }
}

variable_types: struct s_table { struct t_entry { char *e_symbol; struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n { struct t_entry *e_ptr; struct ident_n *n_ident; } *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *e_record; struct t_entry *n_entry; } *s_entries[211]; struct s_table *e_scope; } *

user_defined_types: struct s_table { struct t_entry *s_entries[211]; struct s_table *e_scope; }


original_code:
int hash_pjw( const void *t_key, int t_size ) {
 const char *ptr = t_key;
 int val = 0;
 while( *ptr != '\0' ) {
  int tmp;
  val = ( ( val << 4 ) + ( *ptr ) );
  if( ( tmp = ( val & 0xf0000000 ) ) ) {
   val = val ^ ( tmp >> 24 );
   val = val ^ tmp;
  }
  ptr++;
 }
 return val % t_size;
}

canonical_original_code:
int hash_pjw(void *t_key, int t_size) {
 char *ptr = t_key;
 int val = 0;
 while( *ptr != '\0' ) {
  int tmp;
  val = ( ( val << 4 ) + ( *ptr ) );
  if( ( tmp = ( val & 0xf0000000 ) ) ) {
   val = val ^ ( tmp >> 24 );
   val = val ^ tmp;
  }
  ptr++;
 }
 return val % t_size;
}

variable_types:
ptr
char *

variable_types: val int

variable_types: tmp int


decompiled_code:
__int64 __fastcall find_entry(__int64 a1, char *a2)
{
__int64 v2; // r13
int v3; // eax
__int64 v4; // r14
__int64 v5; // rbx
size_t v6; // r12

v2 = a1;
v3 = hash_pjw(a2, 211);
if ( !a1 )
return 0LL;
v4 = v3;
while ( 1 )
{
v5 = *(_QWORD *)(v2 + 8 * v4);
if ( v5 )
break;
LABEL_3:
v2 = *(_QWORD *)(v2 + 1688);
if ( !v2 )
return 0LL;
}
v6 = strlen(a2);
while ( strncmp(a2, *(const char **)v5, v6) )
{
v5 = *(_QWORD *)(v5 + 16);
if ( !v5 )
goto LABEL_3;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, char *a2)
{
__int64 v2; // r13
int v3; // eax
__int64 v4; // r14
__int64 v5; // rbx
size_t v6; // r12

v2 = a1;
v3 = func6(a2, 211);
if ( !a1 )
return 0LL;
v4 = v3;
while ( 1 )
{
v5 = *(_QWORD *)(v2 + 8 * v4);
if ( v5 )
break;
LABEL_3:
v2 = *(_QWORD *)(v2 + 1688);
if ( !v2 )
return 0LL;
}
v6 = strlen(a2);
while ( strncmp(a2, *(const char **)v5, v6) )
{
v5 = *(_QWORD *)(v5 + 16);
if ( !v5 )
goto LABEL_3;
}
return v5;
}

original_code:
t_entry *find_entry( s_table *s_stack, char *e_symbol ) {
 t_entry *ptr;
 int index;
 index = hash_pjw( e_symbol, 211 );
 while( s_stack != ((void *)0) ) {
  if( s_stack->s_entries[ index ] != ((void *)0) ) {
   ptr = s_stack->s_entries[ index ];
   while( ptr != ((void *)0) ) {
    if( strncmp( e_symbol, ptr->e_symbol, strlen( e_symbol ) ) == 0 )
     return ptr;
    ptr = ptr->n_entry;
   }
  }
  s_stack = s_stack->e_scope;
 }
 return ((void *)0);
}

canonical_original_code:
struct t_entry *find_entry(struct s_table *s_stack, char *e_symbol) {
 struct t_entry *ptr;
 int index;
 index = hash_pjw( e_symbol, 211 );
 while( s_stack != ((void *)0) ) {
  if( s_stack->s_entries[ index ] != ((void *)0) ) {
   ptr = s_stack->s_entries[ index ];
   while( ptr != ((void *)0) ) {
    if( strncmp( e_symbol, ptr->e_symbol, strlen( e_symbol ) ) == 0 )
     return ptr;
    ptr = ptr->n_entry;
   }
  }
  s_stack = s_stack->e_scope;
 }
 return ((void *)0);
}

variable_types: struct s_table { struct t_entry *s_entries[211]; struct s_table *e_scope; } *

variable_types: index int

return_type: struct t_entry { char *e_symbol; struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n { struct t_entry *e_ptr; struct ident_n *n_ident; } *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *e_record; struct t_entry *n_entry; } *


decompiled_code:
const char *__fastcall type_to_str(__int64 a1)
{
_DWORD *v1; // rax
const char *result; // rax

v1 = *(_DWORD **)(a1 + 8);
if ( !v1 )
return "NULL";
switch ( *v1 )
{
case 0x102:
result = "PROG";
break;
case 0x105:
result = "FUNC";
break;
case 0x106:
result = "PROC";
break;
case 0x10E:
result = "ARRAY";
break;
case 0x112:
result = "INT";
break;
case 0x113:
result = "REAL";
break;
case 0x11A:
result = "UNKN";
break;
default:
result = (const char *)&unk_979;
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func8(__int64 a1)
{
_DWORD *v1; // rax
const char *result; // rax

v1 = *(_DWORD **)(a1 + 8);
if ( !v1 )
return "NULL";
switch ( *v1 )
{
case 0x102:
result = "PROG";
break;
case 0x105:
result = "FUNC";
break;
case 0x106:
result = "PROC";
break;
case 0x10E:
result = "ARRAY";
break;
case 0x112:
result = "INT";
break;
case 0x113:
result = "REAL";
break;
case 0x11A:
result = "UNKN";
break;
default:
result = (const char *)&unk_979;
break;
}
return result;
}

original_code:
char *type_to_str( t_entry *ptr ) {
 if( ptr->e_record == ((void *)0) ) return "NULL";
 switch( ptr->e_record->e_rtype ) {
  case 282:
   return "UNKN";
  case 258:
   return "PROG";
  case 274:
   return "INT";
  case 275:
   return "REAL";
  case 270:
   return "ARRAY";
  case 261:
   return "FUNC";
  case 262:
   return "PROC";
  default:
   return "";
 }
}

canonical_original_code:
char *type_to_str(struct t_entry *ptr) {
 if( ptr->e_record == ((void *)0) ) return "NULL";
 switch( ptr->e_record->e_rtype ) {
  case 282:
   return "UNKN";
  case 258:
   return "PROG";
  case 274:
   return "INT";
  case 275:
   return "REAL";
  case 270:
   return "ARRAY";
  case 261:
   return "FUNC";
  case 262:
   return "PROC";
  default:
   return "";
 }
}

return_type: char *


original_code:
void print_sstack( s_table *s_stack ) {
 t_entry *ptr;
 int i;
 fprintf( stderr, "SYMBOL TABLE(S)\n---------------------------------------\n" );
 if( s_stack == ((void *)0) ) return;
 else {
  while( s_stack != ((void *)0) ) {
   for( i = 0; i < 211; i++ ) {
    if( s_stack->s_entries[ i ] != ((void *)0) ) {
     ptr = s_stack->s_entries[ i ];
     while( ptr != ((void *)0) ) {
      fprintf( stderr, "[%s|%s", ptr->e_symbol, type_to_str( ptr ) );
      switch( ptr->e_record->e_rtype ) {
       case 274:
        fprintf( stderr, "|%d]->", ptr->e_record->record.i_info->e_init );
        break;
       case 275:
        fprintf( stderr, "|%d]->", ptr->e_record->record.r_info->e_init );
        break;
       case 270:
        if( ptr->e_record->record.a_info->a_type == 274 ) {
         fprintf( stderr, "|%d|%d|%d]->", ptr->e_record->record.a_info->a_size,
          ptr->e_record->record.a_info->e_value.i_ptr[ 0 ],
          ptr->e_record->record.a_info->e_value.i_ptr[ ptr->e_record->record.a_info->a_size - 1 ] );
        }
        else if( ptr->e_record->record.a_info->a_type == 275 ) {
         fprintf( stderr, "|%d|%d|%d]->", ptr->e_record->record.a_info->a_size,
          ptr->e_record->record.a_info->e_value.r_ptr[ 0 ],
          ptr->e_record->record.a_info->e_value.r_ptr[ ptr->e_record->record.a_info->a_size - 1 ] );
        }
        else {
         fprintf( stderr, "unrecognized array type in symbol table\n" );
        }
        break;
       case 261:
        break;
       default:
        fprintf( stderr, "]->" );
      }
      ptr = ptr->n_entry;
     }
     fprintf( stderr, "\n" );
    }
   }
   s_stack = s_stack->e_scope;
  }
  fprintf( stderr, "---------------------------------------\n" );
 }
}

canonical_original_code:
void print_sstack(struct s_table *s_stack) {
 struct t_entry *ptr;
 int i;
 fprintf( stderr, "SYMBOL TABLE(S)\n---------------------------------------\n" );
 if( s_stack == ((void *)0) ) return;
 else {
  while( s_stack != ((void *)0) ) {
   for( i = 0; i < 211; i++ ) {
    if( s_stack->s_entries[ i ] != ((void *)0) ) {
     ptr = s_stack->s_entries[ i ];
     while( ptr != ((void *)0) ) {
      fprintf( stderr, "[%s|%s", ptr->e_symbol, type_to_str( ptr ) );
      switch( ptr->e_record->e_rtype ) {
       case 274:
        fprintf( stderr, "|%d]->", ptr->e_record->record.i_info->e_init );
        break;
       case 275:
        fprintf( stderr, "|%d]->", ptr->e_record->record.r_info->e_init );
        break;
       case 270:
        if( ptr->e_record->record.a_info->a_type == 274 ) {
         fprintf( stderr, "|%d|%d|%d]->", ptr->e_record->record.a_info->a_size,
          ptr->e_record->record.a_info->e_value.i_ptr[ 0 ],
          ptr->e_record->record.a_info->e_value.i_ptr[ ptr->e_record->record.a_info->a_size - 1 ] );
        }
        else if( ptr->e_record->record.a_info->a_type == 275 ) {
         fprintf( stderr, "|%d|%d|%d]->", ptr->e_record->record.a_info->a_size,
          ptr->e_record->record.a_info->e_value.r_ptr[ 0 ],
          ptr->e_record->record.a_info->e_value.r_ptr[ ptr->e_record->record.a_info->a_size - 1 ] );
        }
        else {
         fprintf( stderr, "unrecognized array type in symbol table\n" );
        }
        break;
       case 261:
        break;
       default:
        fprintf( stderr, "]->" );
      }
      ptr = ptr->n_entry;
     }
     fprintf( stderr, "\n" );
    }
   }
   s_stack = s_stack->e_scope;
  }
  fprintf( stderr, "---------------------------------------\n" );
 }
}


decompiled_code:
void __fastcall free_comp(_QWORD *a1)
{
if ( a1[4] )
free_comp();
if ( a1[5] )
free_comp();
free(a1);
}

canonical_decompiled_code:
void __fastcall func0(_QWORD *a1)
{
if ( a1[4] )
func0();
if ( a1[5] )
func0();
free(a1);
}

original_code:
void free_comp( comp_n *ptr ) {
 if( ptr->left != ((void *)0) )
  free_comp( ptr->left );
 if( ptr->right != ((void *)0) )
  free_comp( ptr->right );
 free( ptr );
}

canonical_original_code:
void free_comp(struct comp_n *ptr) {
 if( ptr->left != ((void *)0) )
  free_comp( ptr->left );
 if( ptr->right != ((void *)0) )
  free_comp( ptr->right );
 free( ptr );
}

variable_types: struct comp_n { int type; int index; int l_not; int u_minus; int call; union { int ival; float rval; int oval; char *woval; struct ident_n { struct t_entry { char *e_symbol; struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *e_record; struct t_entry *n_entry; } *e_ptr; struct ident_n *n_ident; } *ident; struct statement_n { struct comp_n *root; struct statement_n *n_statement; } *statement; } attr; struct comp_n *left; } *

user_defined_types: struct comp_n { int type; int index; int l_not; int u_minus; int call; union { int ival; float rval; int oval; char *woval; struct ident_n *ident; struct statement_n *statement; } attr; struct comp_n *left; }


decompiled_code:
void __fastcall free_statement(_QWORD *a1)
{
if ( a1[1] )
free_statement();
free_comp((_QWORD *)*a1);
free(a1);
}

canonical_decompiled_code:
void __fastcall func1(_QWORD *a1)
{
if ( a1[1] )
func1();
func0((_QWORD *)*a1);
free(a1);
}

original_code:
void free_statement( statement_n *ptr ) {
 if( ptr->n_statement != ((void *)0) )
  free_statement( ptr->n_statement );
 if( ptr != ((void *)0) ) {
  free_comp( ptr->root );
  free( ptr );
 }
}

canonical_original_code:
void free_statement(struct statement_n *ptr) {
 if( ptr->n_statement != ((void *)0) )
  free_statement( ptr->n_statement );
 if( ptr != ((void *)0) ) {
  free_comp( ptr->root );
  free( ptr );
 }
}

variable_types: struct statement_n { struct comp_n { int type; int index; int l_not; int u_minus; int call; union { int ival; float rval; int oval; char *woval; struct ident_n { struct t_entry { char *e_symbol; struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *e_record; struct t_entry *n_entry; } *e_ptr; struct ident_n *n_ident; } *ident; struct statement_n *statement; } attr; struct comp_n *left; } *root; struct statement_n *n_statement; } *

user_defined_types: struct statement_n { struct comp_n *root; struct statement_n *n_statement; }


decompiled_code:
void __fastcall free_ident(_QWORD *a1)
{
if ( a1[1] )
free_ident();
free(a1);
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
if ( a1[1] )
func2();
free(a1);
}

original_code:
void free_ident( ident_n *ptr ) {
 if( ptr->n_ident != ((void *)0) )
  free_ident( ptr->n_ident );
 if( ptr != ((void *)0) )
  free( ptr );
}

canonical_original_code:
void free_ident(struct ident_n *ptr) {
 if( ptr->n_ident != ((void *)0) )
  free_ident( ptr->n_ident );
 if( ptr != ((void *)0) )
  free( ptr );
}

variable_types: struct ident_n { struct t_entry { char *e_symbol; struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *e_record; struct t_entry *n_entry; } *e_ptr; struct ident_n *n_ident; } *


decompiled_code:
void __fastcall free_program(void *ptr)
{
_QWORD *v2; // rdi

free_ident(*((_QWORD **)ptr + 1));
free_ident(*((_QWORD **)ptr + 2));
v2 = (_QWORD *)*((_QWORD *)ptr + 3);
if ( v2 )
free_ident(v2);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
_QWORD *v2; // rdi

func2(*((_QWORD **)ptr + 1));
func2(*((_QWORD **)ptr + 2));
v2 = (_QWORD *)*((_QWORD *)ptr + 3);
if ( v2 )
func2(v2);
free(ptr);
}

original_code:
void free_program( program_n *ptr ) {
 free_ident( ptr->p_name );
 free_ident( ptr->p_ilist );
 if( ptr->p_declarations != ((void *)0) )
  free_ident( ptr->p_declarations );
 free( ptr );
}

canonical_original_code:
void free_program(struct program_n *ptr) {
 free_ident( ptr->p_name );
 free_ident( ptr->p_ilist );
 if( ptr->p_declarations != ((void *)0) )
  free_ident( ptr->p_declarations );
 free( ptr );
}

variable_types: struct program_n { int type; struct ident_n { struct t_entry { char *e_symbol; struct r_ptr { int e_rtype; union { struct i_rinfo { int e_init; int e_value; } *i_info; struct r_rinfo { int e_init; float e_value; } *r_info; struct a_rinfo { int a_type; int a_size; union { int *i_ptr; float *r_ptr; } e_value; } *a_info; struct f_rinfo { int r_type; union { int ival; float fval; } rec; struct ident_n *a_ptr; } *f_info; struct p_rinfo { struct ident_n *a_ptr; } *p_info; } record; } *e_record; struct t_entry *n_entry; } *e_ptr; struct ident_n *n_ident; } *p_name; struct ident_n *p_ilist; struct ident_n *p_declarations; struct program_n *p_sprograms; struct statement_n { struct comp_n { int type; int index; int l_not; int u_minus; int call; union { int ival; float rval; int oval; char *woval; struct ident_n *ident; struct statement_n *statement; } attr; struct comp_n *left; } *root; struct statement_n *n_statement; } *p_statements; struct program_n *p_nprogram; } *

user_defined_types: struct program_n { int type; struct ident_n *p_name; struct ident_n *p_ilist; struct ident_n *p_declarations; struct program_n *p_sprograms; struct statement_n *p_statements; struct program_n *p_nprogram; }


decompiled_code:
__int64 __fastcall print_comp(__int64 a1, int a2)
{
int i; // ebx
__int64 result; // rax

if ( a1 )
{
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
fputc(32, stderr);
}
switch ( *(_DWORD *)a1 )
{
case 0x107:
fputc(10, stderr);
print_statement(*(_QWORD *)(a1 + 24), (unsigned int)(a2 + 16));
break;
case 0x108:
fwrite("[IF]", 1uLL, 4uLL, stderr);
break;
case 0x109:
fwrite("[THEN]", 1uLL, 6uLL, stderr);
break;
case 0x10A:
fwrite("[ELSE]", 1uLL, 6uLL, stderr);
break;
case 0x10B:
fwrite("[WHILE]", 1uLL, 7uLL, stderr);
break;
case 0x10C:
fwrite("[DO]", 1uLL, 4uLL, stderr);
break;
case 0x112:
fprintf(
stderr,
"[INUM:%d|%d|%d|%d]",
*(unsigned int *)(a1 + 24),
*(unsigned int *)(a1 + 4),
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
break;
case 0x113:
fprintf(
stderr,
"[RNUM:%f|%d|%d|%d]",
*(float *)(a1 + 24),
*(unsigned int *)(a1 + 4),
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
break;
case 0x114:
fprintf(stderr, "[RELOP:%s]", *(const char **)(a1 + 24));
break;
case 0x115:
fprintf(stderr, "[ADDOP:%c]", (unsigned int)*(char *)(a1 + 24));
break;
case 0x116:
fprintf(stderr, "[ADDOP:%s]", *(const char **)(a1 + 24));
break;
case 0x117:
fprintf(stderr, "[MULOP:%c]", (unsigned int)*(char *)(a1 + 24));
break;
case 0x118:
fprintf(stderr, "[MULOP:%s]", *(const char **)(a1 + 24));
break;
case 0x119:
fwrite("[ASSIGNOP]", 1uLL, 0xAuLL, stderr);
break;
case 0x11A:
fprintf(
stderr,
"[IDENT:%s|%d|%d|%d]",
***(const char ****)(a1 + 24),
*(unsigned int *)(a1 + 4),
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
break;
default:
fwrite("[UNKNOWN]", 1uLL, 9uLL, stderr);
break;
}
fputc(10, stderr);
print_comp(*(_QWORD *)(a1 + 32), (unsigned int)(a2 + 4));
result = print_comp(*(_QWORD *)(a1 + 40), (unsigned int)(a2 + 4));
}
return result;
}

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

if ( a1 )
{
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
fputc(32, stderr);
}
switch ( *(_DWORD *)a1 )
{
case 0x107:
fputc(10, stderr);
func5(*(_QWORD *)(a1 + 24), (unsigned int)(a2 + 16));
break;
case 0x108:
fwrite("[IF]", 1uLL, 4uLL, stderr);
break;
case 0x109:
fwrite("[THEN]", 1uLL, 6uLL, stderr);
break;
case 0x10A:
fwrite("[ELSE]", 1uLL, 6uLL, stderr);
break;
case 0x10B:
fwrite("[WHILE]", 1uLL, 7uLL, stderr);
break;
case 0x10C:
fwrite("[DO]", 1uLL, 4uLL, stderr);
break;
case 0x112:
fprintf(
stderr,
"[INUM:%d|%d|%d|%d]",
*(unsigned int *)(a1 + 24),
*(unsigned int *)(a1 + 4),
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
break;
case 0x113:
fprintf(
stderr,
"[RNUM:%f|%d|%d|%d]",
*(float *)(a1 + 24),
*(unsigned int *)(a1 + 4),
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
break;
case 0x114:
fprintf(stderr, "[RELOP:%s]", *(const char **)(a1 + 24));
break;
case 0x115:
fprintf(stderr, "[ADDOP:%c]", (unsigned int)*(char *)(a1 + 24));
break;
case 0x116:
fprintf(stderr, "[ADDOP:%s]", *(const char **)(a1 + 24));
break;
case 0x117:
fprintf(stderr, "[MULOP:%c]", (unsigned int)*(char *)(a1 + 24));
break;
case 0x118:
fprintf(stderr, "[MULOP:%s]", *(const char **)(a1 + 24));
break;
case 0x119:
fwrite("[ASSIGNOP]", 1uLL, 0xAuLL, stderr);
break;
case 0x11A:
fprintf(
stderr,
"[IDENT:%s|%d|%d|%d]",
***(const char ****)(a1 + 24),
*(unsigned int *)(a1 + 4),
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12));
break;
default:
fwrite("[UNKNOWN]", 1uLL, 9uLL, stderr);
break;
}
fputc(10, stderr);
func4(*(_QWORD *)(a1 + 32), (unsigned int)(a2 + 4));
result = func4(*(_QWORD *)(a1 + 40), (unsigned int)(a2 + 4));
}
return result;
}

original_code:
void print_comp( comp_n *ptr, int spaces ) {
 int i;
 if( ptr == ((void *)0) ) return;
 for( i = 0; i < spaces; i++ )
  fprintf( stderr, " " );
 switch( ptr->type ) {
  case 263:
   fprintf( stderr, "\n" );
   print_statement( ptr->attr.statement, spaces+16 );
   break;
  case 281:
   fprintf( stderr, "[ASSIGNOP]" );
   break;
  case 276:
   fprintf( stderr, "[RELOP:%s]", ptr->attr.woval );
   break;
  case 278:
   fprintf( stderr, "[ADDOP:%s]", ptr->attr.woval );
   break;
  case 277:
   fprintf( stderr, "[ADDOP:%c]", ( char )ptr->attr.ival );
   break;
  case 280:
   fprintf( stderr, "[MULOP:%s]", ptr->attr.woval );
   break;
  case 279:
   fprintf( stderr, "[MULOP:%c]", ( char )ptr->attr.ival );
   break;
  case 274:
   fprintf( stderr, "[INUM:%d|%d|%d|%d]", ptr->attr.ival, ptr->index, ptr->l_not, ptr->u_minus );
   break;
  case 275:
   fprintf( stderr, "[RNUM:%f|%d|%d|%d]", ptr->attr.rval, ptr->index, ptr->l_not, ptr->u_minus );
   break;
  case 282:
   fprintf( stderr, "[IDENT:%s|%d|%d|%d]", ptr->attr.ident->e_ptr->e_symbol, ptr->index, ptr->l_not, ptr->u_minus );
   break;
  case 264:
   fprintf( stderr, "[IF]" );
   break;
  case 265:
   fprintf( stderr, "[THEN]" );
   break;
  case 266:
   fprintf( stderr, "[ELSE]" );
   break;
  case 267:
   fprintf( stderr, "[WHILE]" );
   break;
  case 268:
   fprintf( stderr, "[DO]" );
   break;
  default:
   fprintf( stderr, "[UNKNOWN]" );
   break;
 }
 fprintf( stderr, "\n" );
 print_comp( ptr->left, spaces + 4 );
 print_comp( ptr->right, spaces + 4 );
}

canonical_original_code:
void print_comp(struct comp_n *ptr, int spaces) {
 int i;
 if( ptr == ((void *)0) ) return;
 for( i = 0; i < spaces; i++ )
  fprintf( stderr, " " );
 switch( ptr->type ) {
  case 263:
   fprintf( stderr, "\n" );
   print_statement( ptr->attr.statement, spaces+16 );
   break;
  case 281:
   fprintf( stderr, "[ASSIGNOP]" );
   break;
  case 276:
   fprintf( stderr, "[RELOP:%s]", ptr->attr.woval );
   break;
  case 278:
   fprintf( stderr, "[ADDOP:%s]", ptr->attr.woval );
   break;
  case 277:
   fprintf( stderr, "[ADDOP:%c]", ( char )ptr->attr.ival );
   break;
  case 280:
   fprintf( stderr, "[MULOP:%s]", ptr->attr.woval );
   break;
  case 279:
   fprintf( stderr, "[MULOP:%c]", ( char )ptr->attr.ival );
   break;
  case 274:
   fprintf( stderr, "[INUM:%d|%d|%d|%d]", ptr->attr.ival, ptr->index, ptr->l_not, ptr->u_minus );
   break;
  case 275:
   fprintf( stderr, "[RNUM:%f|%d|%d|%d]", ptr->attr.rval, ptr->index, ptr->l_not, ptr->u_minus );
   break;
  case 282:
   fprintf( stderr, "[IDENT:%s|%d|%d|%d]", ptr->attr.ident->e_ptr->e_symbol, ptr->index, ptr->l_not, ptr->u_minus );
   break;
  case 264:
   fprintf( stderr, "[IF]" );
   break;
  case 265:
   fprintf( stderr, "[THEN]" );
   break;
  case 266:
   fprintf( stderr, "[ELSE]" );
   break;
  case 267:
   fprintf( stderr, "[WHILE]" );
   break;
  case 268:
   fprintf( stderr, "[DO]" );
   break;
  default:
   fprintf( stderr, "[UNKNOWN]" );
   break;
 }
 fprintf( stderr, "\n" );
 print_comp( ptr->left, spaces + 4 );
 print_comp( ptr->right, spaces + 4 );
}

variable_types: spaces int

variable_types: i int


decompiled_code:
int __fastcall print_ident(__int64 a1)
{
__int64 i; // rbx

for ( i = a1; i; i = *(_QWORD *)(i + 8) )
fprintf(stderr, "[%s]->", **(const char ***)i);
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1)
{
__int64 i; // rbx

for ( i = a1; i; i = *(_QWORD *)(i + 8) )
fprintf(stderr, "[%s]->", **(const char ***)i);
return fputc(10, stderr);
}

original_code:
void print_ident( ident_n *ptr ) {
 while( ptr != ((void *)0) ) {
  fprintf( stderr, "[%s]->", ptr->e_ptr->e_symbol );
  ptr = ptr->n_ident;
 }
 fprintf( stderr, "\n" );
}

canonical_original_code:
void print_ident(struct ident_n *ptr) {
 while( ptr != ((void *)0) ) {
  fprintf( stderr, "[%s]->", ptr->e_ptr->e_symbol );
  ptr = ptr->n_ident;
 }
 fprintf( stderr, "\n" );
}


decompiled_code:
int __fastcall print_spaces(int a1)
{
int i; // ebx
int result; // eax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
result = fputc(32, stderr);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(int a1)
{
int i; // ebx
int result; // eax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
result = fputc(32, stderr);
}
return result;
}

original_code:
void print_spaces( int spaces ) {
 int i;
 for( i = 0; i < spaces; i++ )
  fprintf( stderr, " " );
}

canonical_original_code:
void print_spaces(int spaces) {
 int i;
 for( i = 0; i < spaces; i++ )
  fprintf( stderr, " " );
}


decompiled_code:
int __fastcall print_program(int *a1, int a2)
{
int v3; // eax
__int64 v4; // rdi
__int64 v5; // rdi

fputc(10, stderr);
print_spaces(a2);
v3 = *a1;
if ( *a1 == 258 )
{
fwrite("PROGRAM: \n", 1uLL, 0xAuLL, stderr);
}
else if ( v3 == 261 )
{
fwrite("FUNCTION: \n", 1uLL, 0xBuLL, stderr);
}
else if ( v3 == 262 )
{
fwrite("PROCEDURE:\n", 1uLL, 0xBuLL, stderr);
}
print_spaces(a2);
fwrite("\tNAME: ", 1uLL, 7uLL, stderr);
print_ident(*((_QWORD *)a1 + 1));
print_spaces(a2);
fwrite("\tARGS: ", 1uLL, 7uLL, stderr);
v4 = *((_QWORD *)a1 + 2);
if ( v4 )
print_ident(v4);
else
fwrite("NONE\n", 1uLL, 5uLL, stderr);
print_spaces(a2);
fwrite("\tDECS: ", 1uLL, 7uLL, stderr);
v5 = *((_QWORD *)a1 + 3);
if ( v5 )
print_ident(v5);
else
fwrite("NONE\n", 1uLL, 5uLL, stderr);
print_spaces(a2);
fwrite("\tSPGS: ", 1uLL, 7uLL, stderr);
if ( *((_QWORD *)a1 + 4) )
{
fputc(10, stderr);
print_program(*((_QWORD *)a1 + 4), (unsigned int)(a2 + 16));
}
else
{
fwrite("NONE\n", 1uLL, 5uLL, stderr);
}
print_spaces(a2);
fwrite("\tSTTS: ", 1uLL, 7uLL, stderr);
if ( *((_QWORD *)a1 + 5) )
{
fputc(10, stderr);
print_spaces(a2);
print_statement(*((__int64 **)a1 + 5), a2 + 16);
}
else
{
fwrite("NONE\n", 1uLL, 5uLL, stderr);
}
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func8(int *a1, int a2)
{
int v3; // eax
__int64 v4; // rdi
__int64 v5; // rdi

fputc(10, stderr);
func7(a2);
v3 = *a1;
if ( *a1 == 258 )
{
fwrite("PROGRAM: \n", 1uLL, 0xAuLL, stderr);
}
else if ( v3 == 261 )
{
fwrite("FUNCTION: \n", 1uLL, 0xBuLL, stderr);
}
else if ( v3 == 262 )
{
fwrite("PROCEDURE:\n", 1uLL, 0xBuLL, stderr);
}
func7(a2);
fwrite("\tNAME: ", 1uLL, 7uLL, stderr);
func6(*((_QWORD *)a1 + 1));
func7(a2);
fwrite("\tARGS: ", 1uLL, 7uLL, stderr);
v4 = *((_QWORD *)a1 + 2);
if ( v4 )
func6(v4);
else
fwrite("NONE\n", 1uLL, 5uLL, stderr);
func7(a2);
fwrite("\tDECS: ", 1uLL, 7uLL, stderr);
v5 = *((_QWORD *)a1 + 3);
if ( v5 )
func6(v5);
else
fwrite("NONE\n", 1uLL, 5uLL, stderr);
func7(a2);
fwrite("\tSPGS: ", 1uLL, 7uLL, stderr);
if ( *((_QWORD *)a1 + 4) )
{
fputc(10, stderr);
func8(*((_QWORD *)a1 + 4), (unsigned int)(a2 + 16));
}
else
{
fwrite("NONE\n", 1uLL, 5uLL, stderr);
}
func7(a2);
fwrite("\tSTTS: ", 1uLL, 7uLL, stderr);
if ( *((_QWORD *)a1 + 5) )
{
fputc(10, stderr);
func7(a2);
func5(*((__int64 **)a1 + 5), a2 + 16);
}
else
{
fwrite("NONE\n", 1uLL, 5uLL, stderr);
}
return fputc(10, stderr);
}

original_code:
void print_program( program_n *ptr, int spaces ) {
 fprintf( stderr, "\n" );
 print_spaces( spaces );
 if( ptr->type == 258 ) fprintf( stderr, "PROGRAM: \n" );
 else if( ptr->type == 261 ) fprintf( stderr, "FUNCTION: \n" );
 else if( ptr->type == 262 ) fprintf( stderr, "PROCEDURE:\n" );
 print_spaces( spaces );
 fprintf( stderr, "\tNAME: " );
 print_ident( ptr->p_name );
 print_spaces( spaces );
 fprintf( stderr, "\tARGS: " );
 if( ptr->p_ilist == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else
  print_ident( ptr->p_ilist );
 print_spaces( spaces );
 fprintf( stderr, "\tDECS: " );
 if( ptr->p_declarations == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else
  print_ident( ptr->p_declarations );
 print_spaces( spaces );
 fprintf( stderr, "\tSPGS: " );
 if( ptr->p_sprograms == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else {
  fprintf( stderr, "\n" );
  print_program( ptr->p_sprograms, spaces+16 );
 }
 print_spaces( spaces );
 fprintf( stderr, "\tSTTS: " );
 if( ptr->p_statements == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else {
  fprintf( stderr, "\n" );
  print_spaces( spaces );
  print_statement( ptr->p_statements, spaces+16 );
 }
 fprintf( stderr, "\n" );
}

canonical_original_code:
void print_program(struct program_n *ptr, int spaces) {
 fprintf( stderr, "\n" );
 print_spaces( spaces );
 if( ptr->type == 258 ) fprintf( stderr, "PROGRAM: \n" );
 else if( ptr->type == 261 ) fprintf( stderr, "FUNCTION: \n" );
 else if( ptr->type == 262 ) fprintf( stderr, "PROCEDURE:\n" );
 print_spaces( spaces );
 fprintf( stderr, "\tNAME: " );
 print_ident( ptr->p_name );
 print_spaces( spaces );
 fprintf( stderr, "\tARGS: " );
 if( ptr->p_ilist == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else
  print_ident( ptr->p_ilist );
 print_spaces( spaces );
 fprintf( stderr, "\tDECS: " );
 if( ptr->p_declarations == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else
  print_ident( ptr->p_declarations );
 print_spaces( spaces );
 fprintf( stderr, "\tSPGS: " );
 if( ptr->p_sprograms == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else {
  fprintf( stderr, "\n" );
  print_program( ptr->p_sprograms, spaces+16 );
 }
 print_spaces( spaces );
 fprintf( stderr, "\tSTTS: " );
 if( ptr->p_statements == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else {
  fprintf( stderr, "\n" );
  print_spaces( spaces );
  print_statement( ptr->p_statements, spaces+16 );
 }
 fprintf( stderr, "\n" );
}


yyparse

original_code:
int
yyparse (void)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    YYSTYPE yyvsa[200];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 6)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-10))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 260 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 35 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 2:
    { ; }
    break;
  case 3:
    { sptr = push_scope( sptr ); }
    break;
  case 4:
    {
     sptr = pop_scope( sptr );
    }
    break;
  case 5:
    { ; }
    break;
  case 6:
    {;}
    break;
  case 7:
    { (yyval.tval) = (yyvsp[-1].tval); }
    break;
  case 8:
    {;}
    break;
  case 9:
    {;}
    break;
  case 10:
    {
          eptr = find_entry( sptr, (yyvsp[-2].sval) );
     if( eptr == ((void *)0) )
           eptr = new_entry( sptr, (yyvsp[-2].sval) );
     tptr = new_node( id, ((void *)0), ((void *)0) );
     tptr->attr.id = eptr;
     tptr2 = new_node( op, tptr, (yyvsp[0].tval) );
     tptr2->attr.oval = '=';
     (yyval.tval) = tptr2;
     eval_stmt( (yyval.tval) );
     print_tree( (yyval.tval), 0 );
    }
    break;
  case 11:
    {
     tptr = new_node( op, (yyvsp[0].tval), ((void *)0) );
     tptr->attr.oval = 'p';
     (yyval.tval) = tptr;
     fprintf( stderr, "\tValue >> %d\n", eval_stmt( (yyval.tval) ) );
    }
    break;
  case 12:
    { sptr = push_scope( sptr ); }
    break;
  case 13:
    {
     sptr = pop_scope( sptr );
    }
    break;
  case 14:
    {
     print_tree( (yyvsp[0].tval), 0 );
    }
    break;
  case 15:
    {
          tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '+';
     (yyval.tval) = tptr;
    }
    break;
  case 16:
    {
     tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '-';
     (yyval.tval) = tptr;
    }
    break;
  case 17:
    {
     tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '*';
     (yyval.tval) = tptr;
    }
    break;
  case 18:
    { (yyval.tval) = (yyvsp[-1].tval); }
    break;
  case 19:
    {
     eptr = find_entry( sptr, (yyvsp[0].sval) );
     ((void) sizeof ((eptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (eptr != ((void *)0)) ; else __assert_fail ("eptr != NULL", "ldragon.y", 118, __extension__ __PRETTY_FUNCTION__); }));
     tptr = new_node( id, ((void *)0), ((void *)0) );
     tptr->attr.id = eptr;
     (yyval.tval) = tptr;
    }
    break;
  case 20:
    {
     tptr = new_node( num, ((void *)0), ((void *)0) );
     tptr->attr.ival = (yyvsp[0].ival);
     (yyval.tval) = tptr;
    }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 15;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 35 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 260 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-10))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 35 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 260 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

canonical_original_code:
int yyparse()
{
    int yystate;
    int yyerrstatus;
    short yyssa[200];
    short *yyss;
    short *yyssp;
    union YYSTYPE yyvsa[200];
    union YYSTYPE *yyvs;
    union YYSTYPE *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  union YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 6)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-10))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 260 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 35 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 2:
    { ; }
    break;
  case 3:
    { sptr = push_scope( sptr ); }
    break;
  case 4:
    {
     sptr = pop_scope( sptr );
    }
    break;
  case 5:
    { ; }
    break;
  case 6:
    {;}
    break;
  case 7:
    { (yyval.tval) = (yyvsp[-1].tval); }
    break;
  case 8:
    {;}
    break;
  case 9:
    {;}
    break;
  case 10:
    {
          eptr = find_entry( sptr, (yyvsp[-2].sval) );
     if( eptr == ((void *)0) )
           eptr = new_entry( sptr, (yyvsp[-2].sval) );
     tptr = new_node( id, ((void *)0), ((void *)0) );
     tptr->attr.id = eptr;
     tptr2 = new_node( op, tptr, (yyvsp[0].tval) );
     tptr2->attr.oval = '=';
     (yyval.tval) = tptr2;
     eval_stmt( (yyval.tval) );
     print_tree( (yyval.tval), 0 );
    }
    break;
  case 11:
    {
     tptr = new_node( op, (yyvsp[0].tval), ((void *)0) );
     tptr->attr.oval = 'p';
     (yyval.tval) = tptr;
     fprintf( stderr, "\tValue >> %d\n", eval_stmt( (yyval.tval) ) );
    }
    break;
  case 12:
    { sptr = push_scope( sptr ); }
    break;
  case 13:
    {
     sptr = pop_scope( sptr );
    }
    break;
  case 14:
    {
     print_tree( (yyvsp[0].tval), 0 );
    }
    break;
  case 15:
    {
          tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '+';
     (yyval.tval) = tptr;
    }
    break;
  case 16:
    {
     tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '-';
     (yyval.tval) = tptr;
    }
    break;
  case 17:
    {
     tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '*';
     (yyval.tval) = tptr;
    }
    break;
  case 18:
    { (yyval.tval) = (yyvsp[-1].tval); }
    break;
  case 19:
    {
     eptr = find_entry( sptr, (yyvsp[0].sval) );
     ((void) sizeof ((eptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (eptr != ((void *)0)) ; else __assert_fail ("eptr != NULL", "ldragon.y", 118, __extension__ __PRETTY_FUNCTION__); }));
     tptr = new_node( id, ((void *)0), ((void *)0) );
     tptr->attr.id = eptr;
     (yyval.tval) = tptr;
    }
    break;
  case 20:
    {
     tptr = new_node( num, ((void *)0), ((void *)0) );
     tptr->attr.ival = (yyvsp[0].ival);
     (yyval.tval) = tptr;
    }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 15;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 35 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 260 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-10))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 35 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 260 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyssp
short *

variable_types: union YYSTYPE { int ival; struct t_node { enum node_type { num=0, op=1, id=2 } type; union { int ival; int oval; struct entry { char *name; int value; struct entry *next; } *id; } attr; int gcl; struct t_node *left; } *tval; char *sval; } [200]

variable_types: union YYSTYPE { int ival; struct t_node { enum node_type { num=0, op=1, id=2 } type; union { int ival; int oval; struct entry { char *name; int value; struct entry *next; } *id; } attr; int gcl; struct t_node *left; } *tval; char *sval; } *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; union YYSTYPE { int ival; struct t_node { enum node_type { num=0, op=1, id=2 } type; union { int ival; int oval; struct entry { char *name; int value; struct entry *next; } *id; } attr; int gcl; struct t_node *left; } *tval; char *sval; } yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int

user_defined_types: union YYSTYPE { int ival; struct t_node *tval; char *sval; }

user_defined_types: union yyalloc { short yyss_alloc; union YYSTYPE yyvs_alloc; }

user_defined_types: struct t_node { enum node_type type; union { int ival; int oval; struct entry *id; } attr; int gcl; struct t_node *left; }


yyerror

decompiled_code:
int __fastcall yyerror(const char *a1)
{
return fprintf(stderr, "%s\n", a1);
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
return fprintf(stderr, "%s\n", a1);
}

original_code:
void yyerror( char *s ) {
 fprintf( stderr, "%s\n", s );
}

canonical_original_code:
void yyerror(char *s) {
 fprintf( stderr, "%s\n", s );
}

variable_types:
s
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
yyparse(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func1(argc, argv, envp);
return 0;
}

original_code:
int main( void ) {
 yyparse( );
 return 0;
}

canonical_original_code:
int main() {
 yyparse( );
 return 0;
}


decompiled_code:
void __fastcall destroy_rnode(void *a1)
{
if ( a1 )
free(a1);
}

canonical_decompiled_code:
void __fastcall func0(void *a1)
{
if ( a1 )
free(a1);
}

original_code:
void destroy_rnode( r_node *to_delete ) {
 if( to_delete == ((void *)0) )
  return;
 free( to_delete );
}

canonical_original_code:
void destroy_rnode(struct r_node *to_delete) {
 if( to_delete == ((void *)0) )
  return;
 free( to_delete );
}

variable_types: struct r_node { int number; struct r_node *next; } *


decompiled_code:
_QWORD *init_rstack()
{
return new_rnode(0);
}

canonical_decompiled_code:
_QWORD *func1()
{
return new_rnode(0);
}

original_code:
r_node *init_rstack( ) {
 r_node *ptr;
 ptr = new_rnode( 0 );
 return ptr;
}

canonical_original_code:
struct r_node *init_rstack() {
 struct r_node *ptr;
 ptr = new_rnode( 0 );
 return ptr;
}

return_type: struct r_node { int number; struct r_node *next; } *


decompiled_code:
void __fastcall destroy_rstack(_QWORD *a1)
{
if ( a1 )
{
destroy_rstack(a1[1]);
destroy_rnode(a1);
}
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
if ( a1 )
{
func2(a1[1]);
func0(a1);
}
}

original_code:
void destroy_rstack( r_node *rstack ) {
 if( rstack == ((void *)0) )
  return;
 destroy_rstack( rstack->next );
 destroy_rnode( rstack );
}

canonical_original_code:
void destroy_rstack(struct r_node *rstack) {
 if( rstack == ((void *)0) )
  return;
 destroy_rstack( rstack->next );
 destroy_rnode( rstack );
}

user_defined_types: struct r_node { int number; struct r_node *next; }


push

decompiled_code:
__int64 __fastcall push(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( !a1 || (result = a2) == 0 )
_assert_fail("rstack != NULL && new_top != NULL", "gencode.c", 0x2Au, "push");
*(_QWORD *)(a2 + 8) = a1;
return result;
}

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

if ( !a1 || (result = a2) == 0 )
_assert_fail("rstack != NULL && new_top != NULL", "gencode.c", 0x2Au, "push");
*(_QWORD *)(a2 + 8) = a1;
return result;
}

original_code:
r_node *push( r_node *rstack, r_node *new_top ) {
 ((void) sizeof ((rstack != ((void *)0) && new_top != ((void *)0)) ? 1 : 0), __extension__ ({ if (rstack != ((void *)0) && new_top != ((void *)0)) ; else __assert_fail ("rstack != NULL && new_top != NULL", "gencode.c", 42, __extension__ __PRETTY_FUNCTION__); }));
 new_top->next = rstack;
 return new_top;
}

canonical_original_code:
struct r_node *push(struct r_node *rstack, struct r_node *new_top) {
 ((void) sizeof ((rstack != ((void *)0) && new_top != ((void *)0)) ? 1 : 0), __extension__ ({ if (rstack != ((void *)0) && new_top != ((void *)0)) ; else __assert_fail ("rstack != NULL && new_top != NULL", "gencode.c", 42, __extension__ __PRETTY_FUNCTION__); }));
 new_top->next = rstack;
 return new_top;
}

variable_types:
rstack
struct r_node *


decompiled_code:
size_t __fastcall print_rstack(unsigned int *a1)
{
if ( !a1 )
return fwrite("---------------------\n", 1uLL, 0x16uLL, stderr);
fprintf(stderr, "[ R%d ]\n", *a1);
return print_rstack(*((_QWORD *)a1 + 1));
}

canonical_decompiled_code:
size_t __fastcall func4(unsigned int *a1)
{
if ( !a1 )
return fwrite("---------------------\n", 1uLL, 0x16uLL, stderr);
fprintf(stderr, "[ R%d ]\n", *a1);
return func4(*((_QWORD *)a1 + 1));
}

original_code:
void print_rstack( r_node *rstack ) {
 if( rstack == ((void *)0) )
  fprintf( stderr, "---------------------\n" );
 else {
  fprintf( stderr, "[ R%d ]\n", rstack->number );
  print_rstack( rstack->next );
 }
}

canonical_original_code:
void print_rstack(struct r_node *rstack) {
 if( rstack == ((void *)0) )
  fprintf( stderr, "---------------------\n" );
 else {
  fprintf( stderr, "[ R%d ]\n", rstack->number );
  print_rstack( rstack->next );
 }
}


moao

decompiled_code:
__int64 __fastcall moao(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // edx

result = *(unsigned int *)(a1 + 16);
v3 = *(_DWORD *)(a2 + 16);
if ( (_DWORD)result == v3 )
return (unsigned int)(result + 1);
if ( (int)result < v3 )
result = (unsigned int)v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // edx

result = *(unsigned int *)(a1 + 16);
v3 = *(_DWORD *)(a2 + 16);
if ( (_DWORD)result == v3 )
return (unsigned int)(result + 1);
if ( (int)result < v3 )
result = (unsigned int)v3;
return result;
}

original_code:
int moao( t_node *left, t_node *right ) {
 if( left->gcl == right->gcl )
  return left->gcl + 1;
 else if( left->gcl > right->gcl )
  return left->gcl;
 else
  return right->gcl;
}

canonical_original_code:
int moao(struct t_node *left, struct t_node *right) {
 if( left->gcl == right->gcl )
  return left->gcl + 1;
 else if( left->gcl > right->gcl )
  return left->gcl;
 else
  return right->gcl;
}

variable_types: struct t_node { enum node_type { num=0, op=1, id=2 } type; union { int ival; int oval; struct entry { char *name; int value; struct entry *next; } *id; } attr; int gcl; struct t_node *left; } *

variable_types:
right
struct t_node *


label

original_code:
void label( t_node *root, int type ) {
 if( type == 0 ) {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 0;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
 else if( type == 1 ) {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 1;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
 else {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 0;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
}

canonical_original_code:
void label(struct t_node *root, int type) {
 if( type == 0 ) {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 0;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
 else if( type == 1 ) {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 1;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
 else {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 0;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
}

variable_types: type int

user_defined_types: struct entry { char *name; int value; struct entry *next; }