original_code:
void *mythread_getspecific(mythread_key_t key)
{
 int id;
 id = key.keyID;
 mythread_keyval_t *currKeyVal;
 currKeyVal= (mythread_keyval_t *)malloc(sizeof(mythread_keyval_t));
 mythread_key_t *currKey;
 currKey = (mythread_key_t *)malloc(sizeof(mythread_key_t *));
 currKey = mythread_key_helper.headkey;
 while(currKey != mythread_key_helper.tailkey)
 {
  if(currKey->keyID == id)
  {
   break;
  }
  currKey = currKey->next;
 }
 currKeyVal = currKey->mythread_keyval_helper->headkeyval;
 while(currKeyVal->next != currKey->mythread_keyval_helper->tailkeyval)
 {
  if(currKeyVal->thread->pid == mythread_queue->currThread->pid)
  {
   break;
  }
  else
  currKeyVal= currKeyVal->next;
 }
 return(currKeyVal->value);
}

canonical_original_code:
void *mythread_getspecific(struct mythread_key_t key)
{
 int id;
 id = key.keyID;
 struct mythread_keyval *currKeyVal;
 currKeyVal= (struct mythread_keyval *)malloc(sizeof(mythread_keyval_t));
 struct mythread_key_t *currKey;
 currKey = (struct mythread_key_t *)malloc(sizeof(struct mythread_key_t *));
 currKey = mythread_key_helper.headkey;
 while(currKey != mythread_key_helper.tailkey)
 {
  if(currKey->keyID == id)
  {
   break;
  }
  currKey = currKey->next;
 }
 currKeyVal = currKey->mythread_keyval_helper->headkeyval;
 while(currKeyVal->next != currKey->mythread_keyval_helper->tailkeyval)
 {
  if(currKeyVal->thread->pid == mythread_queue->currThread->pid)
  {
   break;
  }
  else
  currKeyVal= currKeyVal->next;
 }
 return(currKeyVal->value);
}

variable_types: struct mythread_key_t { int keyID; struct mythread_keyval { void *value; struct mythread_keyval *next; struct mythread_keyval *prev; struct mythread_helper { int pid; char *threadStack; struct mythread_helper *prev; enum MTHREADSTATE { NEW=0, READY=1, RUNNING=2, WAITING=3, TERMINATED=4 } currState; struct futex { int count; } thread_futex; int joiner_thread; int hasChildren; } *thread; } *keyval; struct mythread_key_t *next; struct mythread_key_t *prev; struct mythread_keyval_helper { struct mythread_keyval *headkeyval; } *mythread_keyval_helper; }

variable_types: id int


writeLog

decompiled_code:
__int64 __fastcall writeLog(char *src, int a2, const char *a3)
{
struct tm *v5; // rax
size_t v6; // rax
time_t timer; // [rsp+0h] [rbp-260h] BYREF
char s[64]; // [rsp+8h] [rbp-258h] BYREF
char dest[536]; // [rsp+48h] [rbp-218h] BYREF

if ( !system_log_level )
return 0LL;
timer = time(0LL);
v5 = localtime(&timer);
strftime(s, 0x40uLL, "%Y%m%d %H:%M:%S|", v5);
strcpy(dest, s);
switch ( a2 )
{
case 4:
strcat(dest, "ERROR|");
break;
case 2:
strcat(dest, "WARNING|");
break;
case 8:
*(_QWORD *)&dest[strlen(dest)] = 0x7C455245564553LL;
break;
case 1:
strcat(dest, "INFO|");
break;
case 16:
strcat(dest, "DEBUG|");
break;
}
strcat(dest, src);
*(_WORD *)&dest[strlen(dest)] = 124;
strcat(dest, a3);
*(_WORD *)&dest[strlen(dest)] = 10;
if ( a2 == (system_log_level & a2) )
{
v6 = strlen(dest);
write(1, dest, v6);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src, int a2, const char *a3)
{
struct tm *v5; // rax
size_t v6; // rax
time_t timer; // [rsp+0h] [rbp-260h] BYREF
char s[64]; // [rsp+8h] [rbp-258h] BYREF
char dest[536]; // [rsp+48h] [rbp-218h] BYREF

if ( !system_log_level )
return 0LL;
timer = time(0LL);
v5 = localtime(&timer);
strftime(s, 0x40uLL, "%Y%m%d %H:%M:%S|", v5);
strcpy(dest, s);
switch ( a2 )
{
case 4:
strcat(dest, "ERROR|");
break;
case 2:
strcat(dest, "WARNING|");
break;
case 8:
*(_QWORD *)&dest[strlen(dest)] = 0x7C455245564553LL;
break;
case 1:
strcat(dest, "INFO|");
break;
case 16:
strcat(dest, "DEBUG|");
break;
}
strcat(dest, src);
*(_WORD *)&dest[strlen(dest)] = 124;
strcat(dest, a3);
*(_WORD *)&dest[strlen(dest)] = 10;
if ( a2 == (system_log_level & a2) )
{
v6 = strlen(dest);
write(1, dest, v6);
}
return 0LL;
}

original_code:
int writeLog(const char *sourceFunction,enum VLOGLEVEL loglevel,char *logStr)
{
 if (_system_log_level != NONE)
 {
  char text[512];
  struct tm *timeVal;
  time_t currTime;
  char timeBuff[64];
  currTime = time(((void *)0));
  timeVal = localtime(&currTime);
  strftime(timeBuff,64,"%Y%m%d %H:%M:%S|",timeVal);
  strcpy(text,timeBuff);
  if (loglevel == VERROR)
  {
   strcat(text,"ERROR|");
  }
  else if (loglevel == VWARNING)
  {
   strcat(text,"WARNING|");
  }
  else if (loglevel == VSEVERE)
  {
   strcat(text,"SEVERE|");
  }
  else if (loglevel == VINFO)
  {
   strcat(text,"INFO|");
  }
  else if (loglevel == VDEBUG)
  {
   strcat(text,"DEBUG|");
  }
  strcat(text,sourceFunction);
  strcat(text,"|");
  strcat(text,logStr);
  strcat(text,"\n");
  if ( (_system_log_level & (int) loglevel) == (int) loglevel)
  {
   write(1,text,strlen(text));
  }
 }
 return 0;
}

canonical_original_code:
int writeLog(char *sourceFunction, enum VLOGLEVEL loglevel, char *logStr)
{
 if (_system_log_level != NONE)
 {
  char text[512];
  struct tm *timeVal;
  long currTime;
  char timeBuff[64];
  currTime = time(((void *)0));
  timeVal = localtime(&currTime);
  strftime(timeBuff,64,"%Y%m%d %H:%M:%S|",timeVal);
  strcpy(text,timeBuff);
  if (loglevel == VERROR)
  {
   strcat(text,"ERROR|");
  }
  else if (loglevel == VWARNING)
  {
   strcat(text,"WARNING|");
  }
  else if (loglevel == VSEVERE)
  {
   strcat(text,"SEVERE|");
  }
  else if (loglevel == VINFO)
  {
   strcat(text,"INFO|");
  }
  else if (loglevel == VDEBUG)
  {
   strcat(text,"DEBUG|");
  }
  strcat(text,sourceFunction);
  strcat(text,"|");
  strcat(text,logStr);
  strcat(text,"\n");
  if ( (_system_log_level & (int) loglevel) == (int) loglevel)
  {
   write(1,text,strlen(text));
  }
 }
 return 0;
}

variable_types:
sourceFunction
char *

variable_types: enum VLOGLEVEL { NONE=0, VINFO=1, VWARNING=2, VERROR=4, VSEVERE=8, VDEBUG=16 }

variable_types:
logStr
char *

variable_types:
text
char [512]

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

variable_types: currTime long

variable_types:
timeBuff
char [64]

return_type: int


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

result = 1LL;
if ( a1 )
{
*(_DWORD *)(a1 + 32) = 0;
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
*(_DWORD *)a1 = -1;
*(_DWORD *)(a1 + 40) = 0;
futex_init(a1 + 36, 0LL);
result = 0LL;
}
return result;
}

original_code:
enum MERRORSTATE mythread_helper_init(mythread_helper_t *helper)
{
 if ( helper == ((void *)0))
 {
  return MERR_MALLOC;
 }
 else
 {
  helper->currState = NEW;
  helper->next = ((void *)0);
  helper->prev = ((void *)0);
  helper->pid = -1;
  helper->joiner_thread = 0;
  futex_init(&helper->thread_futex,0);
 }
 return MNOERR;
}

canonical_original_code:
enum MERRORSTATE mythread_helper_init(struct mythread_helper *helper)
{
 if ( helper == ((void *)0))
 {
  return MERR_MALLOC;
 }
 else
 {
  helper->currState = NEW;
  helper->next = ((void *)0);
  helper->prev = ((void *)0);
  helper->pid = -1;
  helper->joiner_thread = 0;
  futex_init(&helper->thread_futex,0);
 }
 return MNOERR;
}

variable_types: struct mythread_helper { int pid; char *threadStack; struct mythread_helper *prev; enum MTHREADSTATE { NEW=0, READY=1, RUNNING=2, WAITING=3, TERMINATED=4 } currState; struct futex { int count; } thread_futex; int joiner_thread; int hasChildren; } *

return_type: enum MERRORSTATE { MNOERR=0, MERR_MALLOC=1, MERR_LOG=2, MERR_CLONE=3, MERR_THREADINIT=4, MERR_QUEUECREATE=5, MERR_INVALIDTID=6, MERR_QUEUENOITEM=7, MERR_GENERIC=8 }

user_defined_types: struct mythread_helper { int pid; char *threadStack; struct mythread_helper *prev; enum MTHREADSTATE currState; struct futex thread_futex; int joiner_thread; int hasChildren; }


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

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

original_code:
void mythread_helper_destroy(mythread_helper_t *helper)
{
 helper->currState = TERMINATED;
 helper->next = ((void *)0);
 helper->prev = ((void *)0);
 helper->pid = -1;
 helper->threadStack = ((void *)0);
 free(helper);
}

canonical_original_code:
void mythread_helper_destroy(struct mythread_helper *helper)
{
 helper->currState = TERMINATED;
 helper->next = ((void *)0);
 helper->prev = ((void *)0);
 helper->pid = -1;
 helper->threadStack = ((void *)0);
 free(helper);
}

return_type: void

user_defined_types: enum MTHREADSTATE { NEW=0, READY=1, RUNNING=2, WAITING=3, TERMINATED=4 }


decompiled_code:
__int64 mythread_self()
{
return **(unsigned int **)(mythread_queue + 16);
}

canonical_decompiled_code:
__int64 func0()
{
return **(unsigned int **)(mythread_queue + 16);
}

original_code:
mythread_t mythread_self(void)
{
 mythread_helper_t *currNode = mythread_queue->currThread;
 return currNode->pid;
}

canonical_original_code:
int mythread_self()
{
 struct mythread_helper *currNode = mythread_queue->currThread;
 return currNode->pid;
}


decompiled_code:
void mythread_exit()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void mythread_exit(void *retval)
{
 return;
}

variable_types:
retval
void *


decompiled_code:
__int64 __fastcall mythread_setspecific(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7)
{
__int64 v8; // rax
__int64 v9; // rdx
__int64 *v10; // rdx
__int64 result; // rax
__int64 v12; // rdi
__int64 v13; // rdx

v8 = mythread_key_helper;
v9 = *(&mythread_key_helper + 1);
if ( mythread_key_helper != v9 )
{
while ( *(_DWORD *)v8 != a7 )
{
v8 = *(_QWORD *)(v8 + 16);
if ( v8 == v9 )
goto LABEL_6;
}
v9 = v8;
}
LABEL_6:
v10 = *(__int64 **)(v9 + 32);
result = *v10;
v12 = v10[1];
do
{
v13 = result;
result = *(_QWORD *)(result + 8);
}
while ( result != v12 && **(_DWORD **)(v13 + 24) != **(_DWORD **)(mythread_queue + 16) );
*(_QWORD *)v13 = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7)
{
__int64 v8; // rax
__int64 v9; // rdx
__int64 *v10; // rdx
__int64 result; // rax
__int64 v12; // rdi
__int64 v13; // rdx

v8 = mythread_key_helper;
v9 = *(&mythread_key_helper + 1);
if ( mythread_key_helper != v9 )
{
while ( *(_DWORD *)v8 != a7 )
{
v8 = *(_QWORD *)(v8 + 16);
if ( v8 == v9 )
goto LABEL_6;
}
v9 = v8;
}
LABEL_6:
v10 = *(__int64 **)(v9 + 32);
result = *v10;
v12 = v10[1];
do
{
v13 = result;
result = *(_QWORD *)(result + 8);
}
while ( result != v12 && **(_DWORD **)(v13 + 24) != **(_DWORD **)(mythread_queue + 16) );
*(_QWORD *)v13 = a1;
return result;
}

original_code:
int mythread_setspecific(mythread_key_t key, const void *val)
{
 int id;
 id = key.keyID;
 mythread_keyval_t *currKeyVal;
 currKeyVal = (mythread_keyval_t *) malloc(sizeof(mythread_keyval_t));
 mythread_key_t *currKey;
 currKey = (mythread_key_t *)malloc(sizeof(mythread_key_t *));
 currKey = mythread_key_helper.headkey;
 while(currKey != mythread_key_helper.tailkey)
 {
  if(currKey->keyID == id)
  {
   break;
  }
  currKey = currKey->next;
 }
 currKeyVal = currKey->mythread_keyval_helper->headkeyval;
 while(currKeyVal->next != currKey->mythread_keyval_helper->tailkeyval)
 {
  if(currKeyVal->thread->pid == mythread_queue->currThread->pid)
   {
   break;
  }
  else
  currKeyVal= currKeyVal->next;
 }
 currKeyVal->value = val;
 }

canonical_original_code:
int mythread_setspecific(struct mythread_key_t key, void *val)
{
 int id;
 id = key.keyID;
 struct mythread_keyval *currKeyVal;
 currKeyVal = (struct mythread_keyval *) malloc(sizeof(mythread_keyval_t));
 struct mythread_key_t *currKey;
 currKey = (struct mythread_key_t *)malloc(sizeof(struct mythread_key_t *));
 currKey = mythread_key_helper.headkey;
 while(currKey != mythread_key_helper.tailkey)
 {
  if(currKey->keyID == id)
  {
   break;
  }
  currKey = currKey->next;
 }
 currKeyVal = currKey->mythread_keyval_helper->headkeyval;
 while(currKeyVal->next != currKey->mythread_keyval_helper->tailkeyval)
 {
  if(currKeyVal->thread->pid == mythread_queue->currThread->pid)
   {
   break;
  }
  else
  currKeyVal= currKeyVal->next;
 }
 currKeyVal->value = val;
 }

variable_types:
val
void *

variable_types: struct mythread_key_t { int keyID; struct mythread_keyval { void *value; struct mythread_keyval *next; struct mythread_keyval *prev; struct mythread_helper { int pid; char *threadStack; struct mythread_helper *prev; enum MTHREADSTATE { NEW=0, READY=1, RUNNING=2, WAITING=3, TERMINATED=4 } currState; struct futex { int count; } thread_futex; int joiner_thread; int hasChildren; } *thread; } *keyval; struct mythread_key_t *next; struct mythread_key_t *prev; struct mythread_keyval_helper { struct mythread_keyval *headkeyval; } *mythread_keyval_helper; } *

user_defined_types: struct mythread_key_t { int keyID; struct mythread_keyval *keyval; struct mythread_key_t *next; struct mythread_key_t *prev; struct mythread_keyval_helper *mythread_keyval_helper; }

user_defined_types: struct mythread_keyval { void *value; struct mythread_keyval *next; struct mythread_keyval *prev; struct mythread_helper *thread; }


decompiled_code:
void *mythread_key_init()
{
void *result; // rax

result = malloc(8uLL);
key_helper = (__int64)result;
*(&key_helper + 1) = (__int64)result;
return result;
}

canonical_decompiled_code:
void *func0()
{
void *result; // rax

result = malloc(8uLL);
key_helper = (__int64)result;
*(&key_helper + 1) = (__int64)result;
return result;
}

original_code:
void mythread_key_init(mythread_key_t *key)
{
 key = (mythread_key_t *)malloc(sizeof(mythread_key_t *));
 key_helper.headkey = key;
 key_helper.tailkey = key;
}

canonical_original_code:
void mythread_key_init(struct mythread_key_t *key)
{
 key = (struct mythread_key_t *)malloc(sizeof(struct mythread_key_t *));
 key_helper.headkey = key;
 key_helper.tailkey = key;
}

user_defined_types: struct mythread_keyval_helper { struct mythread_keyval *headkeyval; }


decompiled_code:
__int64 mythread_yield()
{
*(_DWORD *)(*(_QWORD *)(mythread_queue + 16) + 32LL) = 1;
mythread_swapcontext();
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
*(_DWORD *)(*(_QWORD *)(mythread_queue + 16) + 32LL) = 1;
mythread_swapcontext();
return 0LL;
}

original_code:
int mythread_yield(void)
{
    mythread_helper_t *currNode = mythread_queue->currThread;
    currNode->currState = READY;
    mythread_swapcontext(currNode);
    return 0;
}

canonical_original_code:
int mythread_yield()
{
    struct mythread_helper *currNode = mythread_queue->currThread;
    currNode->currState = READY;
    mythread_swapcontext(currNode);
    return 0;
}


getConflict

decompiled_code:
__int64 *getConflict()
{
return &conflict;
}

canonical_decompiled_code:
__int64 *func0()
{
return &conflict;
}

original_code:
Item **getConflict() {
    return &conflict;
}

canonical_original_code:
struct palavra **getConflict() {
    return &conflict;
}

return_type: struct palavra { char *literal; struct palavra *lema; struct palavra *prox; struct sentence { struct _G_fpos_t { long __pos; struct __mbstate_t { int __count; union { unsigned int __wch; char __wchb[4]; } __value; } __state; } position; struct sentence *prox; struct sentence *ant; } *list; } **

user_defined_types: struct palavra { char *literal; struct palavra *lema; struct palavra *prox; struct sentence *list; }

user_defined_types: struct sentence { struct _G_fpos_t position; struct sentence *prox; struct sentence *ant; }

user_defined_types: struct _G_fpos_t { long __pos; struct __mbstate_t __state; }


initTree

decompiled_code:
__int64 initTree()
{
return z;
}

canonical_decompiled_code:
__int64 func1()
{
return z;
}

original_code:
link initTree() {
    link head = z;
    return head;
}

canonical_original_code:
struct STnode *initTree() {
    struct STnode *head = z;
    return head;
}

variable_types: struct STnode { struct palavra { char *literal; struct palavra *lema; struct palavra *prox; struct sentence { struct _G_fpos_t { long __pos; struct __mbstate_t { int __count; union { unsigned int __wch; char __wchb[4]; } __value; } __state; } position; struct sentence *prox; struct sentence *ant; } *list; } *item; struct STnode *l; int N; int red; } *

user_defined_types: struct STnode { struct palavra *item; struct STnode *l; int N; int red; }


STinit

decompiled_code:
_QWORD *STinit()
{
__int64 v0; // rax
_QWORD *result; // rax

v0 = getNULLitem();
result = NEW(v0, 0LL, 0LL, 0, 0);
z = (__int64)result;
conflict = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func2()
{
__int64 v0; // rax
_QWORD *result; // rax

v0 = getNULLitem();
result = NEW(v0, 0LL, 0LL, 0, 0);
z = (__int64)result;
conflict = 0LL;
return result;
}

original_code:
void STinit() {
    z = NEW(getNULLitem(), 0, 0, 0, 0);
    conflict = ((void *)0);
}


STcount

decompiled_code:
__int64 __fastcall STcount(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

original_code:
int STcount(link head) {
    return head->N;
}

canonical_original_code:
int STcount(struct STnode *head) {
    return head->N;
}

user_defined_types: struct __mbstate_t { int __count; union { unsigned int __wch; char __wchb[4]; } __value; }


searchR

decompiled_code:
__int64 __fastcall searchR(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // r12

v2 = key(*a1);
if ( (_QWORD *)z == a1 )
return getNULLitem();
v3 = v2;
if ( (unsigned int)eq(a2, v2) )
return *a1;
if ( (unsigned int)less(a2, v3) )
return searchR(a1[1], a2);
return searchR(a1[2], a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // r12

v2 = key(*a1);
if ( (_QWORD *)z == a1 )
return getNULLitem();
v3 = v2;
if ( (unsigned int)eq(a2, v2) )
return *a1;
if ( (unsigned int)less(a2, v3) )
return func4(a1[1], a2);
return func4(a1[2], a2);
}

original_code:
Item *searchR(link h, Key v) {
    Key t = key(h->item);
    if (h == z) return getNULLitem();
    if (eq(v, t)) return (h->item);
    if (less(v, t)) return searchR((h->l), v);
    else return searchR((h->r), v);
}

canonical_original_code:
struct palavra *searchR(struct STnode *h, char *v) {
    char *t = key(h->item);
    if (h == z) return getNULLitem();
    if (eq(v, t)) return (h->item);
    if (less(v, t)) return searchR((h->l), v);
    else return searchR((h->r), v);
}

variable_types: struct STnode { struct palavra *item; struct STnode *l; int N; int red; } *

variable_types:
v
char *

variable_types:
t
char *

return_type: struct palavra { char *literal; struct palavra *lema; struct palavra *prox; struct sentence { struct _G_fpos_t { long __pos; struct __mbstate_t { int __count; union { unsigned int __wch; char __wchb[4]; } __value; } __state; } position; struct sentence *prox; struct sentence *ant; } *list; } *


STsearch

decompiled_code:
__int64 __fastcall STsearch(__int64 a1, _QWORD *a2)
{
return searchR(a2, a1);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _QWORD *a2)
{
return func4(a2, a1);
}

original_code:
Item *STsearch(Key v, link head) {
    return searchR(head, v);
}

canonical_original_code:
struct palavra *STsearch(char *v, struct STnode *head) {
    return searchR(head, v);
}


fixNr

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

result = a1;
*(_DWORD *)(a1 + 24) = *(_DWORD *)(*(_QWORD *)(a1 + 8) + 24LL) + *(_DWORD *)(*(_QWORD *)(a1 + 16) + 24LL) + 1;
return result;
}

original_code:
link fixNr(link h) {
    h->N = (h->l)->N + (h->r)->N +1;
    return h;
}

canonical_original_code:
struct STnode *fixNr(struct STnode *h) {
    h->N = (h->l)->N + (h->r)->N +1;
    return h;
}

variable_types:
h
struct STnode *

return_type: struct STnode { struct palavra { char *literal; struct palavra *lema; struct palavra *prox; struct sentence { struct _G_fpos_t { long __pos; struct __mbstate_t { int __count; union { unsigned int __wch; char __wchb[4]; } __value; } __state; } position; struct sentence *prox; struct sentence *ant; } *list; } *item; struct STnode *l; int N; int red; } *


rotL

original_code:
link rotL(link h) {
    link x = (h->r); (h->r) = x->l; x->l = fixNr(h);
    x->red = x->l->red; x->l->red = 1;
    return fixNr(x);
}

canonical_original_code:
struct STnode *rotL(struct STnode *h) {
    struct STnode *x = (h->r); (h->r) = x->l; x->l = fixNr(h);
    x->red = x->l->red; x->l->red = 1;
    return fixNr(x);
}


rotR

original_code:
link rotR(link h) {
    link x = (h->l); (h->l) = x->r; x->r = fixNr(h);
    x->red = x->r->red; x->r->red = 1;
    return fixNr(x);
}

canonical_original_code:
struct STnode *rotR(struct STnode *h) {
    struct STnode *x = (h->l); (h->l) = x->r; x->r = fixNr(h);
    x->red = x->r->red; x->r->red = 1;
    return fixNr(x);
}


colorFlip

original_code:
void colorFlip(link h) {
    h->red = 1 - h->red;
    (h->l)->red = 1 - (h->l)->red;
    (h->r)->red = 1 - (h->r)->red;
}

canonical_original_code:
void colorFlip(struct STnode *h) {
    h->red = 1 - h->red;
    (h->l)->red = 1 - (h->l)->red;
    (h->r)->red = 1 - (h->r)->red;
}


mvRedL

original_code:
link mvRedL(link h) {
    colorFlip(h);
    if ((h->r->l)->red) { (h->r) = rotR((h->r)); h = rotL(h); }
    return h;
}

canonical_original_code:
struct STnode *mvRedL(struct STnode *h) {
    colorFlip(h);
    if ((h->r->l)->red) { (h->r) = rotR((h->r)); h = rotL(h); }
    return h;
}


mvRedR

decompiled_code:
__int64 __fastcall mvRedR(__int64 a1)
{
__int64 v1; // rbx

v1 = a1;
colorFlip(a1);
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL) + 28LL) )
v1 = rotR(a1);
return v1;
}

original_code:
link mvRedR(link h) {
    colorFlip(h);
    if ((h->l->l)->red) { h = rotR(h); }
    return h;
}

canonical_original_code:
struct STnode *mvRedR(struct STnode *h) {
    colorFlip(h);
    if ((h->l->l)->red) { h = rotR(h); }
    return h;
}


balance

original_code:
link balance(link h) {
    if ((h->r)->red) h = rotL(h);
    if ((h->l)->red && (h->l->l)->red) h = rotR(h);
    if ((h->l)->red && (h->r)->red) colorFlip(h);
    return fixNr(h);
}

canonical_original_code:
struct STnode *balance(struct STnode *h) {
    if ((h->r)->red) h = rotL(h);
    if ((h->l)->red && (h->l->l)->red) h = rotR(h);
    if ((h->l)->red && (h->r)->red) colorFlip(h);
    return fixNr(h);
}


sortR

decompiled_code:
__int64 __fastcall sortR(__int64 a1, void (__fastcall *a2)(__int64, _QWORD, __int64, __int64))
{
__int64 v3; // rdi
__int64 v4; // rdx
__int64 v5; // rcx
__int64 result; // rax

if ( z != a1 )
{
v3 = *(_QWORD *)(a1 + 8);
sortR(v3);
a2(v3, a2, v4, v5);
result = sortR(*(_QWORD *)(a1 + 16));
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, void (__fastcall *a2)(__int64, _QWORD, __int64, __int64))
{
__int64 v3; // rdi
__int64 v4; // rdx
__int64 v5; // rcx
__int64 result; // rax

if ( z != a1 )
{
v3 = *(_QWORD *)(a1 + 8);
func13(v3);
a2(v3, a2, v4, v5);
result = func13(*(_QWORD *)(a1 + 16));
}
return result;
}

original_code:
void sortR(link h, void(*visit)(Item)) {
    if (h!=z) {
        sortR((h->l), visit);
        visit(*(h->item));
        sortR((h->r), visit);
    }
}

canonical_original_code:
void sortR(struct STnode *h, void (*visit)(struct palavra)) {
    if (h!=z) {
        sortR((h->l), visit);
        visit(*(h->item));
        sortR((h->r), visit);
    }
}

variable_types:
visit
void (*)(struct palavra)


STsort

decompiled_code:
__int64 __fastcall STsort(__int64 a1, void (__fastcall *a2)(__int64, _QWORD, __int64, __int64))
{
return sortR(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, void (__fastcall *a2)(__int64, _QWORD, __int64, __int64))
{
return func13(a1, a2);
}

original_code:
void STsort(link head, void(*visit)(Item)) {
    sortR(head, visit);
}

canonical_original_code:
void STsort(struct STnode *head, void (*visit)(struct palavra)) {
    sortR(head, visit);
}


decompiled_code:
void __fastcall print_rangeR(_QWORD *a1, __int64 a2, __int64 a3)
{
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rdi
__int64 v10; // rsi
__int64 v11; // rdx
__int64 v12; // rcx
__int64 v13; // rax

if ( (_QWORD *)z != a1 )
{
v6 = key(*a1);
if ( (unsigned int)less(a2, v6) )
print_rangeR(a1[1], a2, a3);
v7 = key(*a1);
if ( (unsigned int)less(a2, v7) || (v8 = key(*a1), (unsigned int)eq(a2, v8)) )
{
v9 = key(*a1);
v10 = a3;
if ( (unsigned int)less(v9, a3) || (v9 = key(*a1), v10 = a3, (unsigned int)eq(v9, a3)) )
ITEMshow(v9, v10, v11, v12);
}
v13 = key(*a1);
if ( (unsigned int)less(v13, a3) )
print_rangeR(a1[2], a2, a3);
}
}

canonical_decompiled_code:
void __fastcall func15(_QWORD *a1, __int64 a2, __int64 a3)
{
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rdi
__int64 v10; // rsi
__int64 v11; // rdx
__int64 v12; // rcx
__int64 v13; // rax

if ( (_QWORD *)z != a1 )
{
v6 = key(*a1);
if ( (unsigned int)less(a2, v6) )
func15(a1[1], a2, a3);
v7 = key(*a1);
if ( (unsigned int)less(a2, v7) || (v8 = key(*a1), (unsigned int)eq(a2, v8)) )
{
v9 = key(*a1);
v10 = a3;
if ( (unsigned int)less(v9, a3) || (v9 = key(*a1), v10 = a3, (unsigned int)eq(v9, a3)) )
ITEMshow(v9, v10, v11, v12);
}
v13 = key(*a1);
if ( (unsigned int)less(v13, a3) )
func15(a1[2], a2, a3);
}
}

original_code:
void print_rangeR(link h, Key lo, Key hi) {
    if (h == z) return;
    if (less(lo, key(h->item)))
        print_rangeR((h->l), lo, hi);
    if ((less(lo, key(h->item)) || eq(lo, key(h->item)))
        && (less(key(h->item), hi) || eq(key(h->item), hi)))
        ITEMshow(*(h->item));
    if (less(key(h->item), hi))
        print_rangeR((h->r), lo, hi);
}

canonical_original_code:
void print_rangeR(struct STnode *h, char *lo, char *hi) {
    if (h == z) return;
    if (less(lo, key(h->item)))
        print_rangeR((h->l), lo, hi);
    if ((less(lo, key(h->item)) || eq(lo, key(h->item)))
        && (less(key(h->item), hi) || eq(key(h->item), hi)))
        ITEMshow(*(h->item));
    if (less(key(h->item), hi))
        print_rangeR((h->r), lo, hi);
}

variable_types:
lo
char *

variable_types:
hi
char *


decompiled_code:
void __fastcall STprint_range(_QWORD *a1, __int64 a2, __int64 a3)
{
print_rangeR(a1, a2, a3);
}

canonical_decompiled_code:
void __fastcall func16(_QWORD *a1, __int64 a2, __int64 a3)
{
func15(a1, a2, a3);
}

original_code:
void STprint_range(link head, Key lo, Key hi) {
    print_rangeR(head, lo, hi);
}

canonical_original_code:
void STprint_range(struct STnode *head, char *lo, char *hi) {
    print_rangeR(head, lo, hi);
}


getMin

decompiled_code:
__int64 __fastcall getMin(__int64 *a1)
{
__int64 result; // rax

if ( a1[1] == z )
result = *a1;
else
result = getMin(a1[1]);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 *a1)
{
__int64 result; // rax

if ( a1[1] == z )
result = *a1;
else
result = func17(a1[1]);
return result;
}

original_code:
Item *getMin(link h) {
    if ((h->l) == z) return h->item;
    else return getMin((h->l));
}

canonical_original_code:
struct palavra *getMin(struct STnode *h) {
    if ((h->l) == z) return h->item;
    else return getMin((h->l));
}


deleteMin

original_code:
link deleteMin(link h) {
    if ((h->l) == z) { free(h); return z; }
    if (!(h->l)->red && !(h->l->l)->red) h = mvRedL(h);
    (h->l) = deleteMin((h->l));
    return balance(h);
}

canonical_original_code:
struct STnode *deleteMin(struct STnode *h) {
    if ((h->l) == z) { free(h); return z; }
    if (!(h->l)->red && !(h->l->l)->red) h = mvRedL(h);
    (h->l) = deleteMin((h->l));
    return balance(h);
}


STdeleteMin

decompiled_code:
__int64 __fastcall STdeleteMin(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( !(unsigned int)STcount(a1) )
{
printf("Underflow");
exit(1);
}
if ( !*(_DWORD *)(*(_QWORD *)(a1 + 8) + 28LL) && !*(_DWORD *)(*(_QWORD *)(a1 + 16) + 28LL) )
*(_DWORD *)(a1 + 28) = 1;
v1 = deleteMin((_QWORD *)a1);
result = STcount(v1);
if ( (int)result > 0 )
*(_DWORD *)(v1 + 28) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( !(unsigned int)func3(a1) )
{
printf("Underflow");
exit(1);
}
if ( !*(_DWORD *)(*(_QWORD *)(a1 + 8) + 28LL) && !*(_DWORD *)(*(_QWORD *)(a1 + 16) + 28LL) )
*(_DWORD *)(a1 + 28) = 1;
v1 = func18((_QWORD *)a1);
result = func3(v1);
if ( (int)result > 0 )
*(_DWORD *)(v1 + 28) = 0;
return result;
}

original_code:
void STdeleteMin(link head) {
    if (STcount(head) == 0)
    { printf("Underflow"); exit(1); }
    if (!head->l->red && !head->r->red) head->red = 1;
    head = deleteMin(head);
    if (STcount(head) > 0) head->red = 0;
}

canonical_original_code:
void STdeleteMin(struct STnode *head) {
    if (STcount(head) == 0)
    { printf("Underflow"); exit(1); }
    if (!head->l->red && !head->r->red) head->red = 1;
    head = deleteMin(head);
    if (STcount(head) > 0) head->red = 0;
}


deleteMax

original_code:
link deleteMax(link h) {
    if ((h->l)->red) h = rotR(h);
    if ((h->r) == z) { free(h); return z; }
    if (!(h->r)->red && !(h->r->l)->red) h = mvRedR(h);
    (h->r) = deleteMax((h->r));
    return balance(h);
}

canonical_original_code:
struct STnode *deleteMax(struct STnode *h) {
    if ((h->l)->red) h = rotR(h);
    if ((h->r) == z) { free(h); return z; }
    if (!(h->r)->red && !(h->r->l)->red) h = mvRedR(h);
    (h->r) = deleteMax((h->r));
    return balance(h);
}


STdeleteMax

decompiled_code:
void __fastcall __noreturn STdeleteMax(__int64 a1)
{
if ( !(unsigned int)STcount(a1) )
printf("Underflow");
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func21(__int64 a1)
{
if ( !(unsigned int)func3(a1) )
printf("Underflow");
exit(1);
}

original_code:
void STdeleteMax(link head) {
    if (STcount(head) == 0)
        printf("Underflow"); exit(1);
    if (!head->l->red && !head->r->red) head->red = 1;
    head = deleteMax(head);
    if (STcount(head) > 0) head->red = 0;
}

canonical_original_code:
void STdeleteMax(struct STnode *head) {
    if (STcount(head) == 0)
        printf("Underflow"); exit(1);
    if (!head->l->red && !head->r->red) head->red = 1;
    head = deleteMax(head);
    if (STcount(head) > 0) head->red = 0;
}


deleteR

decompiled_code:
__int64 __fastcall deleteR(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rbx
__int64 v3; // rax
__int64 v4; // rax
__int64 result; // rax
__int64 v6; // rax

v2 = a1;
v3 = key(*a1);
if ( (unsigned int)less(a2, v3) )
{
v4 = a1[1];
if ( !*(_DWORD *)(v4 + 28) && !*(_DWORD *)(*(_QWORD *)(v4 + 8) + 28LL) )
v2 = (_QWORD *)mvRedL((__int64)a1);
v2[1] = deleteR(v2[1], a2);
result = balance((__int64)v2);
}
else
{
if ( *(_DWORD *)(a1[1] + 28LL) )
v2 = (_QWORD *)rotR((__int64)a1);
v6 = key(*v2);
if ( (unsigned int)eq(a2, v6) && v2[2] == z )
free(v2);
result = z;
}
return result;
}

original_code:
link deleteR(link h, Key v) {
    Key t = key(h->item);
    if (less(v,t)) {
        if (!(h->l)->red && !(h->l->l)->red) h = mvRedL(h);
        (h->l) = deleteR((h->l), v);
    }
    else {
        if ((h->l)->red) h = rotR(h);
        if (eq(v,key(h->item)) && (h->r) == z)
            free(h); return z;
        if (!(h->r)->red && !(h->r->l)->red) h = mvRedR(h);
        if (eq(v,key(h->item))) {
            h->item = getMin((h->r));
            (h->r) = deleteMin((h->r));
        }
        else (h->r) = deleteR((h->r), v);
    }
    return balance(h);
}

canonical_original_code:
struct STnode *deleteR(struct STnode *h, char *v) {
    char *t = key(h->item);
    if (less(v,t)) {
        if (!(h->l)->red && !(h->l->l)->red) h = mvRedL(h);
        (h->l) = deleteR((h->l), v);
    }
    else {
        if ((h->l)->red) h = rotR(h);
        if (eq(v,key(h->item)) && (h->r) == z)
            free(h); return z;
        if (!(h->r)->red && !(h->r->l)->red) h = mvRedR(h);
        if (eq(v,key(h->item))) {
            h->item = getMin((h->r));
            (h->r) = deleteMin((h->r));
        }
        else (h->r) = deleteR((h->r), v);
    }
    return balance(h);
}


STdelete

decompiled_code:
__int64 __fastcall STdelete(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

if ( !*(_DWORD *)(*(_QWORD *)(a1 + 8) + 28LL) && !*(_DWORD *)(*(_QWORD *)(a1 + 16) + 28LL) )
*(_DWORD *)(a1 + 28) = 1;
v2 = deleteR((_QWORD *)a1, a2);
result = STcount(v2);
if ( (int)result > 0 )
*(_DWORD *)(v2 + 28) = 0;
return result;
}

original_code:
void STdelete(link head, Key v) {
    if (!head->l->red && !head->r->red) head->red = 1;
    head = deleteR(head, v);
    if (STcount(head) > 0) head->red = 0;
}

canonical_original_code:
void STdelete(struct STnode *head, char *v) {
    if (!head->l->red && !head->r->red) head->red = 1;
    head = deleteR(head, v);
    if (STcount(head) > 0) head->red = 0;
}


decompiled_code:
__int64 __fastcall faz_desenho(__int64 a1, int a2)
{
int v2; // er12
int v3; // ebx
__int64 result; // rax

if ( *(_DWORD *)(a1 + 24) )
{
if ( a2 )
printf("\\pstree{%s}{\n", "\\Tc*{3pt}");
else
printf("\\pstree[levelsep=%s, treesep=%s]{%s}{\n", "5mm", "3mm", "\\Tc*{3pt}");
v2 = faz_desenho(*(_QWORD *)(a1 + 8), (unsigned int)(a2 + 1));
v3 = faz_desenho(*(_QWORD *)(a1 + 16), (unsigned int)(a2 + 1));
puts("}");
result = (unsigned int)(v2 + v3 + 1);
}
else
{
puts("\\Tn");
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1, int a2)
{
int v2; // er12
int v3; // ebx
__int64 result; // rax

if ( *(_DWORD *)(a1 + 24) )
{
if ( a2 )
printf("\\pstree{%s}{\n", "\\Tc*{3pt}");
else
printf("\\pstree[levelsep=%s, treesep=%s]{%s}{\n", "5mm", "3mm", "\\Tc*{3pt}");
v2 = func24(*(_QWORD *)(a1 + 8), (unsigned int)(a2 + 1));
v3 = func24(*(_QWORD *)(a1 + 16), (unsigned int)(a2 + 1));
puts("}");
result = (unsigned int)(v2 + v3 + 1);
}
else
{
puts("\\Tn");
result = 1LL;
}
return result;
}

original_code:
int faz_desenho(link h, int nivel) {
    int d1, d2;
    if (h->N == 0) {
        printf("%s\n", no_externo);
        return 1;
    }
    if (nivel == 0)
        printf("\\pstree[levelsep=%s, treesep=%s]{%s}{\n", level_sep,
               tree_sep, no_interno);
    else
        printf("\\pstree{%s}{\n", no_interno);
    d1 = faz_desenho(h->l, nivel+1);
    d2 = faz_desenho(h->r, nivel+1);
    printf("}\n");
    return d1 + d2 + 1;
}

canonical_original_code:
int faz_desenho(struct STnode *h, int nivel) {
    int d1; int d2;
    if (h->N == 0) {
        printf("%s\n", no_externo);
        return 1;
    }
    if (nivel == 0)
        printf("\\pstree[levelsep=%s, treesep=%s]{%s}{\n", level_sep,
               tree_sep, no_interno);
    else
        printf("\\pstree{%s}{\n", no_interno);
    d1 = faz_desenho(h->l, nivel+1);
    d2 = faz_desenho(h->r, nivel+1);
    printf("}\n");
    return d1 + d2 + 1;
}

variable_types: nivel int


STdraw

decompiled_code:
int __fastcall STdraw(__int64 a1)
{
printf("\\rput{90}{");
faz_desenho(a1, 0);
return puts("}");
}

canonical_decompiled_code:
int __fastcall func25(__int64 a1)
{
printf("\\rput{90}{");
func24(a1, 0);
return puts("}");
}

original_code:
void STdraw(link head) {
    printf("\\rput{90}{");
    faz_desenho(head, 0);
    printf("}\n");
}

canonical_original_code:
void STdraw(struct STnode *head) {
    printf("\\rput{90}{");
    faz_desenho(head, 0);
    printf("}\n");
}


printR

decompiled_code:
void __fastcall printR(__int64 a1, int a2)
{
int i; // ebx
unsigned int v3; // ebx
const char *v4; // rax

if ( z != a1 )
{
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
putchar(32);
}
v3 = *(_DWORD *)(a1 + 28) == 0 ? 32 : 42;
v4 = (const char *)key(*(_QWORD *)a1);
printf("%s%c\n", v4, v3);
printR(*(_QWORD *)(a1 + 8), (unsigned int)(a2 + 2));
printR(*(_QWORD *)(a1 + 16), (unsigned int)(a2 + 2));
}
}

canonical_decompiled_code:
void __fastcall func26(__int64 a1, int a2)
{
int i; // ebx
unsigned int v3; // ebx
const char *v4; // rax

if ( z != a1 )
{
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
putchar(32);
}
v3 = *(_DWORD *)(a1 + 28) == 0 ? 32 : 42;
v4 = (const char *)key(*(_QWORD *)a1);
printf("%s%c\n", v4, v3);
func26(*(_QWORD *)(a1 + 8), (unsigned int)(a2 + 2));
func26(*(_QWORD *)(a1 + 16), (unsigned int)(a2 + 2));
}
}

original_code:
void printR(link h, int ind) {
    int i;
    if (h != z) {
        for (i=0; i<ind; i++) putchar(' ');
        printf("%s%c\n", key(h->item), h->red?'*':' ');
        printR((h->l), ind+2);
        printR((h->r), ind+2);
    }
}

canonical_original_code:
void printR(struct STnode *h, int ind) {
    int i;
    if (h != z) {
        for (i=0; i<ind; i++) putchar(' ');
        printf("%s%c\n", key(h->item), h->red?'*':' ');
        printR((h->l), ind+2);
        printR((h->r), ind+2);
    }
}

variable_types: ind int

variable_types: i int


STprint

decompiled_code:
int __fastcall STprint(__int64 a1)
{
printf("\n**** %d keys ****\n", *(unsigned int *)(a1 + 24));
printR(a1, 0);
return puts("**** ****** ****");
}

original_code:
void STprint(link head) {
    printf("\n**** %d keys ****\n", head->N);
    printR(head, 0);
    printf("**** ****** ****\n");
}

canonical_original_code:
void STprint(struct STnode *head) {
    printf("\n**** %d keys ****\n", head->N);
    printR(head, 0);
    printf("**** ****** ****\n");
}


ITEMscan

decompiled_code:
_QWORD *ITEMscan()
{
void *v0; // rbp
_QWORD *v1; // rbx

v0 = malloc(0x32uLL);
v1 = malloc(0x20uLL);
_isoc99_scanf(&unk_F0, v0);
*v1 = v0;
v1[1] = 0LL;
v1[2] = 0LL;
v1[3] = 0LL;
return v1;
}

canonical_decompiled_code:
_QWORD *func0()
{
void *v0; // rbp
_QWORD *v1; // rbx

v0 = malloc(0x32uLL);
v1 = malloc(0x20uLL);
_isoc99_scanf(&unk_F0, v0);
*v1 = v0;
v1[1] = 0LL;
v1[2] = 0LL;
v1[3] = 0LL;
return v1;
}

original_code:
Item *ITEMscan(Item *x) {
    char *t = malloc(50*sizeof(char));
    Item *palavra = malloc(sizeof(Item));
    scanf("%s", t);
    palavra->literal = t;
    palavra->prox = palavra->lema = ((void *)0);
    palavra->list = ((void *)0);
    return palavra;
}

canonical_original_code:
struct palavra *ITEMscan(struct palavra *x) {
    char *t = malloc(50*sizeof(char));
    struct palavra *palavra = malloc(sizeof(Item));
    scanf("%s", t);
    palavra->literal = t;
    palavra->prox = palavra->lema = ((void *)0);
    palavra->list = ((void *)0);
    return palavra;
}

variable_types:
x
struct palavra *

variable_types: struct palavra { char *literal; struct palavra *lema; struct palavra *prox; struct sentence { struct _G_fpos_t { long __pos; struct __mbstate_t { int __count; union { unsigned int __wch; char __wchb[4]; } __value; } __state; } position; struct sentence *prox; struct sentence *ant; } *list; } *


ITEMshow

decompiled_code:
int __fastcall ITEMshow(int a1, int a2, int a3, int a4, int a5, int a6, char *s)
{
return puts(s);
}

canonical_decompiled_code:
int __fastcall func1(int a1, int a2, int a3, int a4, int a5, int a6, char *s)
{
return puts(s);
}

original_code:
void ITEMshow(Item x) {
    printf("%s\n", x.literal);
}

canonical_original_code:
void ITEMshow(struct palavra x) {
    printf("%s\n", x.literal);
}

variable_types: struct palavra { char *literal; struct palavra *lema; struct palavra *prox; struct sentence { struct _G_fpos_t { long __pos; struct __mbstate_t { int __count; union { unsigned int __wch; char __wchb[4]; } __value; } __state; } position; struct sentence *prox; struct sentence *ant; } *list; }


key

decompiled_code:
__int64 __fastcall key(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
Key key(Item *item) {
    return item->literal;
}

canonical_original_code:
char *key(struct palavra *item) {
    return item->literal;
}

return_type: char *


eq

decompiled_code:
_BOOL8 __fastcall eq(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

original_code:
int eq(Key key1, Key key2) {
    if (strcmp(key1, key2) == 0) return 1;
    return 0;
}

canonical_original_code:
int eq(char *key1, char *key2) {
    if (strcmp(key1, key2) == 0) return 1;
    return 0;
}


less

decompiled_code:
__int64 __fastcall less(const char *a1, const char *a2)
{
return (unsigned int)strcmp(a1, a2) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, const char *a2)
{
return (unsigned int)strcmp(a1, a2) >> 31;
}

original_code:
int less(Key key1, Key key2) {
    if (strcmp(key1, key2) < 0) return 1;
    return 0;
}

canonical_original_code:
int less(char *key1, char *key2) {
    if (strcmp(key1, key2) < 0) return 1;
    return 0;
}


initItem

decompiled_code:
_QWORD *initItem()
{
_QWORD *result; // rax

result = malloc(0x20uLL);
NULLitem = (__int64)result;
*result = 0LL;
result[2] = 0LL;
result[1] = 0LL;
result[3] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func5()
{
_QWORD *result; // rax

result = malloc(0x20uLL);
NULLitem = (__int64)result;
*result = 0LL;
result[2] = 0LL;
result[1] = 0LL;
result[3] = 0LL;
return result;
}

original_code:
void initItem () {
    NULLitem = malloc(sizeof(Item));
    NULLitem->literal = ((void *)0);
    NULLitem->lema = NULLitem->prox = ((void *)0);
    NULLitem->list = ((void *)0);
}

canonical_original_code:
void initItem() {
    NULLitem = malloc(sizeof(Item));
    NULLitem->literal = ((void *)0);
    NULLitem->lema = NULLitem->prox = ((void *)0);
    NULLitem->list = ((void *)0);
}


getNULLitem

decompiled_code:
__int64 getNULLitem()
{
return NULLitem;
}

canonical_decompiled_code:
__int64 func6()
{
return NULLitem;
}

original_code:
Item *getNULLitem () {
    return NULLitem;
}

canonical_original_code:
struct palavra *getNULLitem() {
    return NULLitem;
}


isNULLitem

decompiled_code:
_BOOL8 __fastcall isNULLitem(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7)
{
return a7 == 0;
}

original_code:
int isNULLitem (Item item) {
    if (item.literal == ((void *)0)) return 1;
    else return 0;
}

canonical_original_code:
int isNULLitem(struct palavra item) {
    if (item.literal == ((void *)0)) return 1;
    else return 0;
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rsi
int i; // edx

v3 = 0LL;
for ( i = 1; i != 1000; ++i )
{
if ( i == 3 * (i / 3) || i == 5 * (i / 5) )
v3 = (unsigned int)(i + v3);
}
printf("Sum = %d\n", v3);
return 0;
}

variable_types: sum int


decompiled_code:
char *__fastcall getenv2(const char *a1)
{
char *result; // rax

result = getenv(a1);
if ( !result )
{
printf("please define environment variable \"%s\"\n", a1);
exit(1);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func7(const char *a1)
{
char *result; // rax

result = getenv(a1);
if ( !result )
{
printf("please define environment variable \"%s\"\n", a1);
exit(1);
}
return result;
}

original_code:
char * getenv2(char * name)
{
 char * e = getenv(name);
 if (!e) {
  printf("please define environment variable \"%s\"\n",name);
  exit(1);
 }
 return e;
}

canonical_original_code:
char *getenv2(char *name)
{
 char *e = getenv(name);
 if (!e) {
  printf("please define environment variable \"%s\"\n",name);
  exit(1);
 }
 return e;
}

variable_types:
name
char *

variable_types:
e
char *


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // rax

if ( !getenv("dm3xx_boot_rec") && !getenv("dm3xx_boot_data") )
{
puts("please define env var 'dm3xx_boot_rec' or 'dm3xx_boot_data'");
exit(1);
}
if ( getenv("dm3xx_boot_rec") )
{
v3 = getenv2("dm3xx_boot_rec");
dm3xx_boot_rec_make(v3);
}
if ( getenv("dm3xx_boot_data") )
{
v4 = getenv2("dm3xx_boot_data");
sdcard_build_data(v4);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // rax

if ( !getenv("dm3xx_boot_rec") && !getenv("dm3xx_boot_data") )
{
puts("please define env var 'dm3xx_boot_rec' or 'dm3xx_boot_data'");
exit(1);
}
if ( getenv("dm3xx_boot_rec") )
{
v3 = func7("dm3xx_boot_rec");
func9(v3);
}
if ( getenv("dm3xx_boot_data") )
{
v4 = func7("dm3xx_boot_data");
func12(v4);
}
return 0;
}

original_code:
int main()
{
 if (! getenv("dm3xx_boot_rec") && ! getenv("dm3xx_boot_data") ) {
  printf("please define env var 'dm3xx_boot_rec' or 'dm3xx_boot_data'\n");
  exit(1);
 }
 if ( getenv("dm3xx_boot_rec") )
  dm3xx_boot_rec_make(getenv2("dm3xx_boot_rec"));
 if ( getenv("dm3xx_boot_data") )
  sdcard_build_data(getenv2("dm3xx_boot_data"));
 return 0;
}


repo: virtadpt/eBBS

decompiled_code:
__int64 yy_get_previous_state()
{
unsigned int v0; // edx
_BYTE *v1; // r8
int v2; // ebx
__int64 v3; // rbp
char v4; // r11
char v5; // r10
__int16 v6; // di
__int16 v7; // cx
unsigned __int8 v8; // si

v0 = yy_start;
v1 = yytext;
if ( (unsigned __int64)yytext < yy_c_buf_p )
{
v2 = yy_last_accepting_state;
v3 = yy_last_accepting_cpos;
v4 = 0;
v5 = 0;
do
{
v8 = 1;
if ( *v1 )
v8 = yy_ec[(unsigned __int8)*v1];
if ( yy_accept[v0] )
v3 = (__int64)v1;
if ( yy_accept[v0] )
{
v2 = v0;
if ( yy_accept[v0] )
{
v4 = 1;
if ( yy_accept[v0] )
v5 = 1;
}
}
v6 = yy_base[v0];
if ( yy_chk[v8 + v6] != v0 )
{
do
{
v7 = yy_def[v0];
v0 = v7;
if ( v7 > 80 )
v8 = yy_meta[4 * v8];
v6 = yy_base[v7];
}
while ( v7 != yy_chk[v8 + v6] );
}
v0 = yy_nxt[v6 + v8];
++v1;
}
while ( v1 != (_BYTE *)yy_c_buf_p );
if ( v5 )
yy_last_accepting_state = v2;
if ( v4 )
yy_last_accepting_cpos = v3;
}
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // edx
_BYTE *v1; // r8
int v2; // ebx
__int64 v3; // rbp
char v4; // r11
char v5; // r10
__int16 v6; // di
__int16 v7; // cx
unsigned __int8 v8; // si

v0 = yy_start;
v1 = yytext;
if ( (unsigned __int64)yytext < yy_c_buf_p )
{
v2 = yy_last_accepting_state;
v3 = yy_last_accepting_cpos;
v4 = 0;
v5 = 0;
do
{
v8 = 1;
if ( *v1 )
v8 = yy_ec[(unsigned __int8)*v1];
if ( yy_accept[v0] )
v3 = (__int64)v1;
if ( yy_accept[v0] )
{
v2 = v0;
if ( yy_accept[v0] )
{
v4 = 1;
if ( yy_accept[v0] )
v5 = 1;
}
}
v6 = yy_base[v0];
if ( yy_chk[v8 + v6] != v0 )
{
do
{
v7 = yy_def[v0];
v0 = v7;
if ( v7 > 80 )
v8 = yy_meta[4 * v8];
v6 = yy_base[v7];
}
while ( v7 != yy_chk[v8 + v6] );
}
v0 = yy_nxt[v6 + v8];
++v1;
}
while ( v1 != (_BYTE *)yy_c_buf_p );
if ( v5 )
yy_last_accepting_state = v2;
if ( v4 )
yy_last_accepting_cpos = v3;
}
return v0;
}

original_code:
static yy_state_type yy_get_previous_state()
 {
 register yy_state_type yy_current_state;
 register char *yy_cp;
 yy_current_state = yy_start;
 for ( yy_cp = yytext + 0; yy_cp < yy_c_buf_p; ++yy_cp )
  {
  register YY_CHAR yy_c = (*yy_cp ? yy_ec[((unsigned int) (unsigned char) *yy_cp)] : 1);
  if ( yy_accept[yy_current_state] )
   {
   yy_last_accepting_state = yy_current_state;
   yy_last_accepting_cpos = yy_cp;
   }
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
   {
   yy_current_state = (int) yy_def[yy_current_state];
   if ( yy_current_state >= 81 )
    yy_c = yy_meta[(unsigned int) yy_c];
   }
  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  }
 return yy_current_state;
 }

canonical_original_code:
static int yy_get_previous_state()
 {
 register int yy_current_state;
 register char *yy_cp;
 yy_current_state = yy_start;
 for ( yy_cp = yytext + 0; yy_cp < yy_c_buf_p; ++yy_cp )
  {
  register unsigned char yy_c = (*yy_cp ? yy_ec[((unsigned int) (unsigned char) *yy_cp)] : 1);
  if ( yy_accept[yy_current_state] )
   {
   yy_last_accepting_state = yy_current_state;
   yy_last_accepting_cpos = yy_cp;
   }
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
   {
   yy_current_state = (int) yy_def[yy_current_state];
   if ( yy_current_state >= 81 )
    yy_c = yy_meta[(unsigned int) yy_c];
   }
  yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  }
 return yy_current_state;
 }


decompiled_code:
__int64 __fastcall yy_try_NUL_trans(int a1)
{
__int16 v1; // cx
__int16 v2; // dx
__int64 result; // rax

if ( yy_accept[a1] )
{
yy_last_accepting_state = a1;
yy_last_accepting_cpos = yy_c_buf_p;
}
v1 = yy_base[a1];
if ( a1 != yy_chk[v1 + 1] )
{
do
{
v2 = yy_def[a1];
a1 = v2;
v1 = yy_base[v2];
}
while ( v2 != yy_chk[v1 + 1] );
}
result = (unsigned int)yy_nxt[v1 + 1];
if ( (_DWORD)result == 80 )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int16 v1; // cx
__int16 v2; // dx
__int64 result; // rax

if ( yy_accept[a1] )
{
yy_last_accepting_state = a1;
yy_last_accepting_cpos = yy_c_buf_p;
}
v1 = yy_base[a1];
if ( a1 != yy_chk[v1 + 1] )
{
do
{
v2 = yy_def[a1];
a1 = v2;
v1 = yy_base[v2];
}
while ( v2 != yy_chk[v1 + 1] );
}
result = (unsigned int)yy_nxt[v1 + 1];
if ( (_DWORD)result == 80 )
result = 0LL;
return result;
}

original_code:
static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
 {
 register int yy_is_jam;
 register char *yy_cp = yy_c_buf_p;
 register YY_CHAR yy_c = 1;
 if ( yy_accept[yy_current_state] )
  {
  yy_last_accepting_state = yy_current_state;
  yy_last_accepting_cpos = yy_cp;
  }
 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  {
  yy_current_state = (int) yy_def[yy_current_state];
  if ( yy_current_state >= 81 )
   yy_c = yy_meta[(unsigned int) yy_c];
  }
 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 yy_is_jam = (yy_current_state == 80);
 return yy_is_jam ? 0 : yy_current_state;
 }

canonical_original_code:
static int yy_try_NUL_trans(int yy_current_state)
 {
 register int yy_is_jam;
 register char *yy_cp = yy_c_buf_p;
 register unsigned char yy_c = 1;
 if ( yy_accept[yy_current_state] )
  {
  yy_last_accepting_state = yy_current_state;
  yy_last_accepting_cpos = yy_cp;
  }
 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  {
  yy_current_state = (int) yy_def[yy_current_state];
  if ( yy_current_state >= 81 )
   yy_c = yy_meta[(unsigned int) yy_c];
  }
 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 yy_is_jam = (yy_current_state == 80);
 return yy_is_jam ? 0 : yy_current_state;
 }


decompiled_code:
void *__fastcall yy_flex_realloc(void *a1, unsigned int a2)
{
return realloc(a1, a2);
}

canonical_decompiled_code:
void *__fastcall func2(void *a1, unsigned int a2)
{
return realloc(a1, a2);
}

original_code:
static void *yy_flex_realloc( void *ptr, unsigned int size )
 {
 return (void *) realloc( ptr, size );
 }

canonical_original_code:
static void *yy_flex_realloc(void *ptr, unsigned int size)
 {
 return (void *) realloc( ptr, size );
 }

variable_types:
ptr
void *

variable_types:
size
unsigned int

return_type: void *


decompiled_code:
void __fastcall __noreturn yy_fatal_error(const char *a1)
{
fprintf(stderr, "%s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(const char *a1)
{
fprintf(stderr, "%s\n", a1);
exit(1);
}

original_code:
static void yy_fatal_error( const char msg[] )
 {
 (void) fprintf( stderr, "%s\n", msg );
 exit( 1 );
 }

canonical_original_code:
static void yy_fatal_error(char msg[])
 {
 (void) fprintf( stderr, "%s\n", msg );
 exit( 1 );
 }

variable_types:
msg
char []


decompiled_code:
void *__fastcall yy_flex_alloc(size_t size)
{
return malloc((unsigned int)size);
}

canonical_decompiled_code:
void *__fastcall func4(size_t size)
{
return malloc((unsigned int)size);
}

original_code:
static void *yy_flex_alloc( unsigned int size )
 {
 return (void *) malloc( size );
 }

canonical_original_code:
static void *yy_flex_alloc(unsigned int size)
 {
 return (void *) malloc( size );
 }


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

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

original_code:
static void yy_flex_free( void *ptr )
 {
 free( ptr );
 }

canonical_original_code:
static void yy_flex_free(void *ptr)
 {
 free( ptr );
 }


decompiled_code:
void *get_yytext()
{
return yytext;
}

canonical_decompiled_code:
void *func6()
{
return yytext;
}

original_code: char *get_yytext() { return yytext ; }

canonical_original_code: char *get_yytext() { return yytext ; }


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

yy_n_chars = *(_DWORD *)(yy_current_buffer + 28);
yy_c_buf_p = *(_QWORD *)(yy_current_buffer + 16);
yytext = (void *)yy_c_buf_p;
yyin = *(FILE **)yy_current_buffer;
result = *(unsigned __int8 *)yy_c_buf_p;
yy_hold_char = *(_BYTE *)yy_c_buf_p;
return result;
}

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

yy_n_chars = *(_DWORD *)(yy_current_buffer + 28);
yy_c_buf_p = *(_QWORD *)(yy_current_buffer + 16);
yytext = (void *)yy_c_buf_p;
yyin = *(FILE **)yy_current_buffer;
result = *(unsigned __int8 *)yy_c_buf_p;
yy_hold_char = *(_BYTE *)yy_c_buf_p;
return result;
}

original_code:
void yy_load_buffer_state( void )
 {
 yy_n_chars = yy_current_buffer->yy_n_chars;
 yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
 yyin = yy_current_buffer->yy_input_file;
 yy_hold_char = *yy_c_buf_p;
 }

canonical_original_code:
void yy_load_buffer_state()
 {
 yy_n_chars = yy_current_buffer->yy_n_chars;
 yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
 yyin = yy_current_buffer->yy_input_file;
 yy_hold_char = *yy_c_buf_p;
 }


yylex

decompiled_code:
__int64 yylex()
{
char *v0; // rbp
unsigned int v1; // ebx
char *v2; // r13
int v3; // er10
__int64 v4; // r9
__int64 v5; // r8
__int64 v6; // rdi
__int16 v7; // si
__int16 v8; // dx
__int64 v9; // rcx
__int64 v10; // rsi
int v11; // eax
int v12; // eax
int v14; // ebx
__int64 v15; // rax
unsigned __int64 v16; // rdx
int v17; // eax
__int64 v18; // rdx
__int64 v19; // rcx
__int64 v20; // r8
__int64 v21; // r9
unsigned int v22; // eax
char *v23; // r14

if ( yy_init )
{
if ( !yy_start )
yy_start = 1;
if ( !yyin )
yyin = stdin;
if ( !yyout )
yyout = stdout;
if ( yy_current_buffer )
yy_init_buffer(yy_current_buffer, yyin);
else
yy_current_buffer = yy_create_buffer(yyin, 0x4000);
yy_load_buffer_state();
yy_init = 0;
}
while ( 1 )
{
LABEL_11:
v0 = (char *)yy_c_buf_p;
*(_BYTE *)yy_c_buf_p = yy_hold_char;
v1 = yy_start;
v2 = v0;
LABEL_12:
v3 = yy_last_accepting_state;
v4 = yy_last_accepting_cpos;
v5 = 0LL;
v6 = 0LL;
do
{
v11 = yy_ec[(unsigned __int8)*v0];
LOBYTE(v9) = v11;
if ( yy_accept[v1] )
v3 = v1;
if ( yy_accept[v1] )
{
v4 = (__int64)v0;
if ( yy_accept[v1] )
{
v5 = 1LL;
if ( yy_accept[v1] )
v6 = 1LL;
}
}
v7 = yy_base[v1];
if ( v1 != yy_chk[v7 + (unsigned __int8)v11] )
{
do
{
v8 = yy_def[v1];
v1 = v8;
if ( v8 > 80 )
LOBYTE(v9) = yy_meta[4 * (unsigned __int8)v9];
v7 = yy_base[v8];
}
while ( v8 != yy_chk[(unsigned __int8)v9 + v7] );
}
v10 = (unsigned int)v7;
v9 = (unsigned __int8)v9;
v1 = yy_nxt[(unsigned int)v10 + (unsigned __int8)v9];
++v0;
}
while ( yy_base[yy_nxt[(unsigned int)v10 + (unsigned __int8)v9]] != 120 );
if ( (_BYTE)v6 )
yy_last_accepting_cpos = v4;
if ( (_BYTE)v5 )
yy_last_accepting_state = v3;
while ( 2 )
{
v12 = yy_accept[v1];
yytext = v2;
yyleng = (_DWORD)v0 - (_DWORD)v2;
yy_hold_char = *v0;
*v0 = 0;
yy_c_buf_p = (__int64)v0;
LABEL_31:
switch ( v12 )
{
case 0:
*v0 = yy_hold_char;
v0 = (char *)yy_last_accepting_cpos;
v1 = yy_last_accepting_state;
continue;
case 1:
case 2:
return 258LL;
case 3:
case 4:
return 259LL;
case 5:
case 6:
return 260LL;
case 7:
return 265LL;
case 8:
return 263LL;
case 9:
return 264LL;
case 10:
return 266LL;
case 11:
return 267LL;
case 12:
return 261LL;
case 13:
return 270LL;
case 14:
return 270LL;
case 15:
return 262LL;
case 16:
return 271LL;
case 17:
return 268LL;
case 18:
return 269LL;
case 19:
case 21:
case 22:
goto LABEL_11;
case 20:
++line_num;
goto LABEL_11;
case 23:
return 272LL;
case 24:
fwrite(yytext, yyleng, 1uLL, yyout);
goto LABEL_11;
case 25:
v14 = (_DWORD)v0 - (_DWORD)yytext - 1;
*v0 = yy_hold_char;
v15 = yy_current_buffer;
if ( *(FILE **)yy_current_buffer != yyin )
{
*(_QWORD *)yy_current_buffer = yyin;
yy_n_chars = *(_DWORD *)(v15 + 28);
}
v16 = *(_QWORD *)(v15 + 8) + yy_n_chars;
if ( yy_c_buf_p <= v16 )
{
v23 = (char *)yytext + v14;
yy_c_buf_p = (__int64)v23;
v1 = yy_get_previous_state(v6, v10, v16, v9, v5, v4);
v6 = v1;
v22 = yy_try_NUL_trans(v1);
v2 = (char *)yytext;
if ( v22 )
{
v0 = v23 + 1;
LABEL_58:
v1 = v22;
goto LABEL_12;
}
continue;
}
v17 = yy_get_next_buffer(v6, v10, v16, v9, v5, v4);
if ( v17 != 1 )
{
if ( v17 != 2 )
{
if ( v17 )
goto LABEL_11;
v0 = (char *)yytext + v14;
yy_c_buf_p = (__int64)v0;
v22 = yy_get_previous_state(v6, v10, v18, v19, v20, v21);
v2 = (char *)yytext;
goto LABEL_58;
}
v0 = (char *)(*(_QWORD *)(yy_current_buffer + 8) + yy_n_chars);
yy_c_buf_p = (__int64)v0;
v1 = yy_get_previous_state(v6, v10, v18, v19, v20, v21);
v2 = (char *)yytext;
continue;
}
yy_did_buffer_switch_on_eof = 0;
if ( (unsigned int)yywrap() )
{
yy_c_buf_p = (__int64)yytext;
v12 = (yy_start - 1) / 2 + 26;
goto LABEL_31;
}
if ( !yy_did_buffer_switch_on_eof )
yyrestart(yyin);
break;
case 26:
return 0LL;
default:
yy_fatal_error("fatal flex scanner internal error--no action found");
}
break;
}
}
}

canonical_decompiled_code:
__int64 func14()
{
char *v0; // rbp
unsigned int v1; // ebx
char *v2; // r13
int v3; // er10
__int64 v4; // r9
__int64 v5; // r8
__int64 v6; // rdi
__int16 v7; // si
__int16 v8; // dx
__int64 v9; // rcx
__int64 v10; // rsi
int v11; // eax
int v12; // eax
int v14; // ebx
__int64 v15; // rax
unsigned __int64 v16; // rdx
int v17; // eax
__int64 v18; // rdx
__int64 v19; // rcx
__int64 v20; // r8
__int64 v21; // r9
unsigned int v22; // eax
char *v23; // r14

if ( yy_init )
{
if ( !yy_start )
yy_start = 1;
if ( !yyin )
yyin = stdin;
if ( !yyout )
yyout = stdout;
if ( yy_current_buffer )
func10(yy_current_buffer, yyin);
else
yy_current_buffer = func11(yyin, 0x4000);
func7();
yy_init = 0;
}
while ( 1 )
{
LABEL_11:
v0 = (char *)yy_c_buf_p;
*(_BYTE *)yy_c_buf_p = yy_hold_char;
v1 = yy_start;
v2 = v0;
LABEL_12:
v3 = yy_last_accepting_state;
v4 = yy_last_accepting_cpos;
v5 = 0LL;
v6 = 0LL;
do
{
v11 = yy_ec[(unsigned __int8)*v0];
LOBYTE(v9) = v11;
if ( yy_accept[v1] )
v3 = v1;
if ( yy_accept[v1] )
{
v4 = (__int64)v0;
if ( yy_accept[v1] )
{
v5 = 1LL;
if ( yy_accept[v1] )
v6 = 1LL;
}
}
v7 = yy_base[v1];
if ( v1 != yy_chk[v7 + (unsigned __int8)v11] )
{
do
{
v8 = yy_def[v1];
v1 = v8;
if ( v8 > 80 )
LOBYTE(v9) = yy_meta[4 * (unsigned __int8)v9];
v7 = yy_base[v8];
}
while ( v8 != yy_chk[(unsigned __int8)v9 + v7] );
}
v10 = (unsigned int)v7;
v9 = (unsigned __int8)v9;
v1 = yy_nxt[(unsigned int)v10 + (unsigned __int8)v9];
++v0;
}
while ( yy_base[yy_nxt[(unsigned int)v10 + (unsigned __int8)v9]] != 120 );
if ( (_BYTE)v6 )
yy_last_accepting_cpos = v4;
if ( (_BYTE)v5 )
yy_last_accepting_state = v3;
while ( 2 )
{
v12 = yy_accept[v1];
yytext = v2;
yyleng = (_DWORD)v0 - (_DWORD)v2;
yy_hold_char = *v0;
*v0 = 0;
yy_c_buf_p = (__int64)v0;
LABEL_31:
switch ( v12 )
{
case 0:
*v0 = yy_hold_char;
v0 = (char *)yy_last_accepting_cpos;
v1 = yy_last_accepting_state;
continue;
case 1:
case 2:
return 258LL;
case 3:
case 4:
return 259LL;
case 5:
case 6:
return 260LL;
case 7:
return 265LL;
case 8:
return 263LL;
case 9:
return 264LL;
case 10:
return 266LL;
case 11:
return 267LL;
case 12:
return 261LL;
case 13:
return 270LL;
case 14:
return 270LL;
case 15:
return 262LL;
case 16:
return 271LL;
case 17:
return 268LL;
case 18:
return 269LL;
case 19:
case 21:
case 22:
goto LABEL_11;
case 20:
++line_num;
goto LABEL_11;
case 23:
return 272LL;
case 24:
fwrite(yytext, yyleng, 1uLL, yyout);
goto LABEL_11;
case 25:
v14 = (_DWORD)v0 - (_DWORD)yytext - 1;
*v0 = yy_hold_char;
v15 = yy_current_buffer;
if ( *(FILE **)yy_current_buffer != yyin )
{
*(_QWORD *)yy_current_buffer = yyin;
yy_n_chars = *(_DWORD *)(v15 + 28);
}
v16 = *(_QWORD *)(v15 + 8) + yy_n_chars;
if ( yy_c_buf_p <= v16 )
{
v23 = (char *)yytext + v14;
yy_c_buf_p = (__int64)v23;
v1 = func0(v6, v10, v16, v9, v5, v4);
v6 = v1;
v22 = func1(v1);
v2 = (char *)yytext;
if ( v22 )
{
v0 = v23 + 1;
LABEL_58:
v1 = v22;
goto LABEL_12;
}
continue;
}
v17 = func13(v6, v10, v16, v9, v5, v4);
if ( v17 != 1 )
{
if ( v17 != 2 )
{
if ( v17 )
goto LABEL_11;
v0 = (char *)yytext + v14;
yy_c_buf_p = (__int64)v0;
v22 = func0(v6, v10, v18, v19, v20, v21);
v2 = (char *)yytext;
goto LABEL_58;
}
v0 = (char *)(*(_QWORD *)(yy_current_buffer + 8) + yy_n_chars);
yy_c_buf_p = (__int64)v0;
v1 = func0(v6, v10, v18, v19, v20, v21);
v2 = (char *)yytext;
continue;
}
yy_did_buffer_switch_on_eof = 0;
if ( (unsigned int)yywrap() )
{
yy_c_buf_p = (__int64)yytext;
v12 = (yy_start - 1) / 2 + 26;
goto LABEL_31;
}
if ( !yy_did_buffer_switch_on_eof )
func12(yyin);
break;
case 26:
return 0LL;
default:
func3("fatal flex scanner internal error--no action found");
}
break;
}
}
}

original_code:
int yylex ( void )
 {
 register yy_state_type yy_current_state;
 register char *yy_cp, *yy_bp;
 register int yy_act;
 if ( yy_init )
  {
  if ( ! yy_start )
   yy_start = 1;
  if ( ! yyin )
   yyin = stdin;
  if ( ! yyout )
   yyout = stdout;
  if ( yy_current_buffer )
   yy_init_buffer( yy_current_buffer, yyin );
  else
   yy_current_buffer =
    yy_create_buffer( yyin, 16384 );
  yy_load_buffer_state();
  yy_init = 0;
  }
 while ( 1 )
  {
  yy_cp = yy_c_buf_p;
  *yy_cp = yy_hold_char;
  yy_bp = yy_cp;
  yy_current_state = yy_start;
yy_match:
  do
   {
   register YY_CHAR yy_c = yy_ec[((unsigned int) (unsigned char) *yy_cp)];
   if ( yy_accept[yy_current_state] )
    {
    yy_last_accepting_state = yy_current_state;
    yy_last_accepting_cpos = yy_cp;
    }
   while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
    {
    yy_current_state = (int) yy_def[yy_current_state];
    if ( yy_current_state >= 81 )
     yy_c = yy_meta[(unsigned int) yy_c];
    }
   yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
   ++yy_cp;
   }
  while ( yy_base[yy_current_state] != 120 );
yy_find_action:
  yy_act = yy_accept[yy_current_state];
  yytext = yy_bp; yyleng = yy_cp - yy_bp; yy_hold_char = *yy_cp; *yy_cp = '\0'; yy_c_buf_p = yy_cp;;
do_action:
  switch ( yy_act )
 {
   case 0:
   *yy_cp = yy_hold_char;
   yy_cp = yy_last_accepting_cpos;
   yy_current_state = yy_last_accepting_state;
   goto yy_find_action;
case 1:

case 2:

{return 258;}
 break;
case 3:

case 4:

{return 259;}
 break;
case 5:

case 6:

{return 260;}
 break;
case 7:

{return 265;}
 break;
case 8:

{return 263;}
 break;
case 9:

{return 264;}
 break;
case 10:

{return 266;}
 break;
case 11:

{return 267;}
 break;
case 12:

{return 261;}
 break;
case 13:

{return 270;}
 break;
case 14:

{return 270;}
 break;
case 15:

{return 262;}
 break;
case 16:

{return 271;}
 break;
case 17:

{return 268;}
 break;
case 18:

{return 269;}
 break;
case 19:

;
 break;
case 20:

{line_num++; }
 break;
case 21:

;
 break;
case 22:

;
 break;
case 23:

{return 272 ; }
 break;
case 24:

(void) fwrite( yytext, yyleng, 1, yyout );
 break;
case (25 + 0 + 1):
 return 0;
 case 25:
  {
  int yy_amount_of_matched_text = yy_cp - yytext - 1;
  *yy_cp = yy_hold_char;
  if ( yy_current_buffer->yy_input_file != yyin )
   {
   yy_current_buffer->yy_input_file = yyin;
   yy_n_chars = yy_current_buffer->yy_n_chars;
   }
  if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
   {
   yy_state_type yy_next_state;
   yy_c_buf_p = yytext + yy_amount_of_matched_text;
   yy_current_state = yy_get_previous_state();
   yy_next_state = yy_try_NUL_trans( yy_current_state );
   yy_bp = yytext + 0;
   if ( yy_next_state )
    {
    yy_cp = ++yy_c_buf_p;
    yy_current_state = yy_next_state;
    goto yy_match;
    }
   else
    {
    goto yy_find_action;
    }
   }
  else switch ( yy_get_next_buffer() )
   {
   case 1:
    {
    yy_did_buffer_switch_on_eof = 0;
    if ( yywrap() )
     {
     yy_c_buf_p = yytext + 0;
     yy_act = (25 + ((yy_start - 1) / 2) + 1);
     goto do_action;
     }
    else
     {
     if ( ! yy_did_buffer_switch_on_eof )
      yyrestart( yyin );
     }
    break;
    }
   case 0:
    yy_c_buf_p =
     yytext + yy_amount_of_matched_text;
    yy_current_state = yy_get_previous_state();
    yy_cp = yy_c_buf_p;
    yy_bp = yytext + 0;
    goto yy_match;
   case 2:
    yy_c_buf_p =
    &yy_current_buffer->yy_ch_buf[yy_n_chars];
    yy_current_state = yy_get_previous_state();
    yy_cp = yy_c_buf_p;
    yy_bp = yytext + 0;
    goto yy_find_action;
   }
  break;
  }
 default:
  yy_fatal_error( "fatal flex scanner internal error--no action found" );
 }
  }
 }

canonical_original_code:
int yylex()
 {
 register int yy_current_state;
 register char *yy_cp; register char *yy_bp;
 register int yy_act;
 if ( yy_init )
  {
  if ( ! yy_start )
   yy_start = 1;
  if ( ! yyin )
   yyin = stdin;
  if ( ! yyout )
   yyout = stdout;
  if ( yy_current_buffer )
   yy_init_buffer( yy_current_buffer, yyin );
  else
   yy_current_buffer =
    yy_create_buffer( yyin, 16384 );
  yy_load_buffer_state();
  yy_init = 0;
  }
 while ( 1 )
  {
  yy_cp = yy_c_buf_p;
  *yy_cp = yy_hold_char;
  yy_bp = yy_cp;
  yy_current_state = yy_start;
yy_match:
  do
   {
   register unsigned char yy_c = yy_ec[((unsigned int) (unsigned char) *yy_cp)];
   if ( yy_accept[yy_current_state] )
    {
    yy_last_accepting_state = yy_current_state;
    yy_last_accepting_cpos = yy_cp;
    }
   while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
    {
    yy_current_state = (int) yy_def[yy_current_state];
    if ( yy_current_state >= 81 )
     yy_c = yy_meta[(unsigned int) yy_c];
    }
   yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
   ++yy_cp;
   }
  while ( yy_base[yy_current_state] != 120 );
yy_find_action:
  yy_act = yy_accept[yy_current_state];
  yytext = yy_bp; yyleng = yy_cp - yy_bp; yy_hold_char = *yy_cp; *yy_cp = '\0'; yy_c_buf_p = yy_cp;;
do_action:
  switch ( yy_act )
 {
   case 0:
   *yy_cp = yy_hold_char;
   yy_cp = yy_last_accepting_cpos;
   yy_current_state = yy_last_accepting_state;
   goto yy_find_action;
case 1:

case 2:

{return 258;}
 break;
case 3:

case 4:

{return 259;}
 break;
case 5:

case 6:

{return 260;}
 break;
case 7:

{return 265;}
 break;
case 8:

{return 263;}
 break;
case 9:

{return 264;}
 break;
case 10:

{return 266;}
 break;
case 11:

{return 267;}
 break;
case 12:

{return 261;}
 break;
case 13:

{return 270;}
 break;
case 14:

{return 270;}
 break;
case 15:

{return 262;}
 break;
case 16:

{return 271;}
 break;
case 17:

{return 268;}
 break;
case 18:

{return 269;}
 break;
case 19:

;
 break;
case 20:

{line_num++; }
 break;
case 21:

;
 break;
case 22:

;
 break;
case 23:

{return 272 ; }
 break;
case 24:

(void) fwrite( yytext, yyleng, 1, yyout );
 break;
case (25 + 0 + 1):
 return 0;
 case 25:
  {
  int yy_amount_of_matched_text = yy_cp - yytext - 1;
  *yy_cp = yy_hold_char;
  if ( yy_current_buffer->yy_input_file != yyin )
   {
   yy_current_buffer->yy_input_file = yyin;
   yy_n_chars = yy_current_buffer->yy_n_chars;
   }
  if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
   {
   int yy_next_state;
   yy_c_buf_p = yytext + yy_amount_of_matched_text;
   yy_current_state = yy_get_previous_state();
   yy_next_state = yy_try_NUL_trans( yy_current_state );
   yy_bp = yytext + 0;
   if ( yy_next_state )
    {
    yy_cp = ++yy_c_buf_p;
    yy_current_state = yy_next_state;
    goto yy_match;
    }
   else
    {
    goto yy_find_action;
    }
   }
  else switch ( yy_get_next_buffer() )
   {
   case 1:
    {
    yy_did_buffer_switch_on_eof = 0;
    if ( yywrap() )
     {
     yy_c_buf_p = yytext + 0;
     yy_act = (25 + ((yy_start - 1) / 2) + 1);
     goto do_action;
     }
    else
     {
     if ( ! yy_did_buffer_switch_on_eof )
      yyrestart( yyin );
     }
    break;
    }
   case 0:
    yy_c_buf_p =
     yytext + yy_amount_of_matched_text;
    yy_current_state = yy_get_previous_state();
    yy_cp = yy_c_buf_p;
    yy_bp = yytext + 0;
    goto yy_match;
   case 2:
    yy_c_buf_p =
    &yy_current_buffer->yy_ch_buf[yy_n_chars];
    yy_current_state = yy_get_previous_state();
    yy_cp = yy_c_buf_p;
    yy_bp = yytext + 0;
    goto yy_find_action;
   }
  break;
  }
 default:
  yy_fatal_error( "fatal flex scanner internal error--no action found" );
 }
  }
 }


MenuGetch

decompiled_code:
__int64 MenuGetch()
{
int i; // ebp
char v2; // al
char v3; // bl

for ( i = 0; ; i = 0 )
{
while ( 1 )
{
while ( 1 )
{
v2 = igetch();
v3 = v2;
if ( i != 1 )
break;
i = 2;
if ( v2 != 91 )
goto LABEL_8;
}
if ( i == 2 )
break;
if ( !i )
{
if ( ((*_ctype_b_loc())[v2] & 0x4000) != 0 )
return (unsigned int)v3;
if ( v3 == 13 )
return 10LL;
if ( (v3 & 0xFD) == 8 || v3 == 127 )
return 10LL;
if ( v3 == 12 )
redoscr();
else
i = v3 == 27;
}
}
if ( v2 == 65 )
return 16LL;
if ( v2 == 66 )
break;
LABEL_8:
bell();
}
return 14LL;
}

canonical_decompiled_code:
__int64 func12()
{
int i; // ebp
char v2; // al
char v3; // bl

for ( i = 0; ; i = 0 )
{
while ( 1 )
{
while ( 1 )
{
v2 = igetch();
v3 = v2;
if ( i != 1 )
break;
i = 2;
if ( v2 != 91 )
goto LABEL_8;
}
if ( i == 2 )
break;
if ( !i )
{
if ( ((*_ctype_b_loc())[v2] & 0x4000) != 0 )
return (unsigned int)v3;
if ( v3 == 13 )
return 10LL;
if ( (v3 & 0xFD) == 8 || v3 == 127 )
return 10LL;
if ( v3 == 12 )
redoscr();
else
i = v3 == 27;
}
}
if ( v2 == 65 )
return 16LL;
if ( v2 == 66 )
break;
LABEL_8:
bell();
}
return 14LL;
}

original_code:
int
MenuGetch()
{
  char c;
  int keymode = (0);
  while (1) {
    c = igetch();
    switch (keymode) {
    case (0):
      if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISprint)) return c;
      if (c == '\r' || c == '\n' || c == '\010' || c == '\177') {
 c = '\n';
 return c;
      }
      if (c == ('L'&037)) {
        redoscr() ;
      }
      if (c == 27) keymode = (1);
      break;
    case (1):
      if (c == '[') keymode = (2);
      else {
 bell();
 keymode = (0);
      }
      break;
    case (2):
      if (c == 'A') return (16);
      else if (c == 'B') return (14);
      else {
 bell();
 keymode = (0);
      }
    }
  }
}

canonical_original_code:
int MenuGetch()
{
  char c;
  int keymode = (0);
  while (1) {
    c = igetch();
    switch (keymode) {
    case (0):
      if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISprint)) return c;
      if (c == '\r' || c == '\n' || c == '\010' || c == '\177') {
 c = '\n';
 return c;
      }
      if (c == ('L'&037)) {
        redoscr() ;
      }
      if (c == 27) keymode = (1);
      break;
    case (1):
      if (c == '[') keymode = (2);
      else {
 bell();
 keymode = (0);
      }
      break;
    case (2):
      if (c == 'A') return (16);
      else if (c == 'B') return (14);
      else {
 bell();
 keymode = (0);
      }
    }
  }
}

variable_types: c char

variable_types: keymode int


decompiled_code:
void hit_alarm_clock()
{
int v0; // edi

if ( !input_active )
disconnect(-3);
input_active = 0;
signal(14, hit_alarm_clock);
v0 = *(_DWORD *)&myinfo[16];
if ( v0 )
alarm(60 * v0);
}

canonical_decompiled_code:
void func3()
{
int v0; // edi

if ( !input_active )
func1(-3);
input_active = 0;
signal(14, hit_alarm_clock);
v0 = *(_DWORD *)&myinfo[16];
if ( v0 )
alarm(60 * v0);
}

original_code:
void
hit_alarm_clock()
{
  if (!input_active) {
    disconnect(-3);
  }
  input_active = 0;
  signal(14, hit_alarm_clock);
  if (myinfo.idletimeout) alarm((int)myinfo.idletimeout*60);
}


InitializeTerminal

decompiled_code:
__int64 InitializeTerminal()
{
__int64 result; // rax
__int64 v1; // [rsp+0h] [rbp-188h] BYREF
char src[264]; // [rsp+6Ch] [rbp-11Ch] BYREF
char dest[20]; // [rsp+174h] [rbp-14h] BYREF

if ( (unsigned int)local_bbs_owninfo(&v1) )
{
prints("Can't determine your terminal type!\n");
prints("Defaulting to 'dumb'.\n");
result = term_init("dumb");
}
else
{
strncpy(dest, src, 0xBuLL);
result = term_init(dest);
if ( (_DWORD)result == -1 )
{
prints("I don't know about '%s' terminals!\n", dest);
prints("Defaulting terminal type to 'dumb'.\n");
result = term_init("dumb");
}
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
__int64 v1; // [rsp+0h] [rbp-188h] BYREF
char src[264]; // [rsp+6Ch] [rbp-11Ch] BYREF
char dest[20]; // [rsp+174h] [rbp-14h] BYREF

if ( (unsigned int)local_bbs_owninfo(&v1) )
{
prints("Can't determine your terminal type!\n");
prints("Defaulting to 'dumb'.\n");
result = term_init("dumb");
}
else
{
strncpy(dest, src, 0xBuLL);
result = term_init(dest);
if ( (_DWORD)result == -1 )
{
prints("I don't know about '%s' terminals!\n", dest);
prints("Defaulting terminal type to 'dumb'.\n");
result = term_init("dumb");
}
}
return result;
}

original_code:
void
InitializeTerminal()
{
  TERM t;
  ACCOUNT acct;
  if (local_bbs_owninfo(&acct) != 0) {
    prints("Can't determine your terminal type!\n");
    prints("Defaulting to 'dumb'.\n");
    term_init("dumb");
    return;
  }
  strncpy(t, acct.terminal, 11);
  if (term_init(t) == -1) {
    prints("I don't know about '%s' terminals!\n", t);
    prints("Defaulting terminal type to 'dumb'.\n");
    term_init("dumb");
  }
}

canonical_original_code:
void InitializeTerminal()
{
  char t[-1];
  struct _ACCOUNT acct;
  if (local_bbs_owninfo(&acct) != 0) {
    prints("Can't determine your terminal type!\n");
    prints("Defaulting to 'dumb'.\n");
    term_init("dumb");
    return;
  }
  strncpy(t, acct.terminal, 11);
  if (term_init(t) == -1) {
    prints("I don't know about '%s' terminals!\n", t);
    prints("Defaulting terminal type to 'dumb'.\n");
    term_init("dumb");
  }
}

variable_types:
t
char [-1]

variable_types: struct _ACCOUNT { char userid[-1]; char passwd[-1]; char username[-1]; unsigned int perms; unsigned short flags; unsigned int lastlogin; char fromhost[-1]; char terminal[-1]; char charset[-1]; char realname[-1]; char address[-1]; char email[-1]; char protocol[-1]; char editor[-1]; }


InitializeCharset

decompiled_code:
__int64 InitializeCharset()
{
__int64 result; // rax
__int64 v1; // [rsp+0h] [rbp-188h] BYREF
char src[252]; // [rsp+78h] [rbp-110h] BYREF
char dest[20]; // [rsp+174h] [rbp-14h] BYREF

if ( (unsigned int)local_bbs_owninfo(&v1) )
{
prints("Can't determine your character set!\n");
prints("Defaulting to 'ascii'.\n");
result = conv_init("ascii");
}
else
{
strncpy(dest, src, 0xBuLL);
result = conv_init(dest);
if ( (_DWORD)result == -1 )
{
prints("I don't know about '%s' charset!\n", dest);
prints("Defaulting character set to 'ascii'.\n");
result = conv_init("ascii");
}
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax
__int64 v1; // [rsp+0h] [rbp-188h] BYREF
char src[252]; // [rsp+78h] [rbp-110h] BYREF
char dest[20]; // [rsp+174h] [rbp-14h] BYREF

if ( (unsigned int)local_bbs_owninfo(&v1) )
{
prints("Can't determine your character set!\n");
prints("Defaulting to 'ascii'.\n");
result = conv_init("ascii");
}
else
{
strncpy(dest, src, 0xBuLL);
result = conv_init(dest);
if ( (_DWORD)result == -1 )
{
prints("I don't know about '%s' charset!\n", dest);
prints("Defaulting character set to 'ascii'.\n");
result = conv_init("ascii");
}
}
return result;
}

original_code:
void
InitializeCharset()
{
  CSET c;
  ACCOUNT acct;
  if (local_bbs_owninfo(&acct) != 0) {
    prints("Can't determine your character set!\n");
    prints("Defaulting to 'ascii'.\n");
    conv_init("ascii");
    return;
  }
  strncpy(c, acct.charset, 11);
  if (conv_init(c) == -1) {
    prints("I don't know about '%s' charset!\n", c);
    prints("Defaulting character set to 'ascii'.\n");
    conv_init("ascii");
  }
}

canonical_original_code:
void InitializeCharset()
{
  char c[-1];
  struct _ACCOUNT acct;
  if (local_bbs_owninfo(&acct) != 0) {
    prints("Can't determine your character set!\n");
    prints("Defaulting to 'ascii'.\n");
    conv_init("ascii");
    return;
  }
  strncpy(c, acct.charset, 11);
  if (conv_init(c) == -1) {
    prints("I don't know about '%s' charset!\n", c);
    prints("Defaulting character set to 'ascii'.\n");
    conv_init("ascii");
  }
}

variable_types:
c
char [-1]

user_defined_types: struct _ACCOUNT { char userid[-1]; char passwd[-1]; char username[-1]; unsigned int perms; unsigned short flags; unsigned int lastlogin; char fromhost[-1]; char terminal[-1]; char charset[-1]; char realname[-1]; char address[-1]; char email[-1]; char protocol[-1]; char editor[-1]; }


bbslog

decompiled_code:
int bbslog(int a1, const char *a2, ...)
{
int result; // eax
struct tm *v3; // rax
char v4[48]; // [rsp+0h] [rbp-108h] BYREF
time_t timer; // [rsp+30h] [rbp-D8h] BYREF
gcc_va_list arg; // [rsp+38h] [rbp-D0h] BYREF

va_start(arg, a2);
result = (int)arg[0].reg_save_area;
if ( bbs_loglevel >= a1 )
{
fseek(bbs_log, 0LL, 2);
if ( fprintf(bbs_log, "%-16s ", (const char *)&bbs_logsource) == -1 )
{
close_bbslog();
open_bbslog(bbs_logfile, bbs_loglevel);
fprintf(bbs_log, "%-16s ", (const char *)&bbs_logsource);
}
time(&timer);
v3 = localtime(&timer);
strftime(v4, 0x28uLL, "%x %X", v3);
fprintf(bbs_log, "%s ", v4);
vfprintf(bbs_log, a2, arg);
result = fflush(bbs_log);
}
return result;
}

canonical_decompiled_code:
int func3(int a1, const char *a2, ...)
{
int result; // eax
struct tm *v3; // rax
char v4[48]; // [rsp+0h] [rbp-108h] BYREF
time_t timer; // [rsp+30h] [rbp-D8h] BYREF
gcc_va_list arg; // [rsp+38h] [rbp-D0h] BYREF

va_start(arg, a2);
result = (int)arg[0].reg_save_area;
if ( bbs_loglevel >= a1 )
{
fseek(bbs_log, 0LL, 2);
if ( fprintf(bbs_log, "%-16s ", (const char *)&bbs_logsource) == -1 )
{
func1();
func0(bbs_logfile, bbs_loglevel);
fprintf(bbs_log, "%-16s ", (const char *)&bbs_logsource);
}
time(&timer);
v3 = localtime(&timer);
strftime(v4, 0x28uLL, "%x %X", v3);
fprintf(bbs_log, "%s ", v4);
vfprintf(bbs_log, a2, arg);
result = fflush(bbs_log);
}
return result;
}

original_code:
void
bbslog(int level, char *fmt, ...)
{
  va_list args;
  time_t now;
  char timestr[40];
  __builtin_va_start(args,fmt);
  if (level > bbs_loglevel) {
    __builtin_va_end(args);
    return;
  }
  fseek(bbs_log, 0, 2);
  if (fprintf(bbs_log, "%-16s ", bbs_logsource) == (-1)) {
    close_bbslog();
    open_bbslog(bbs_logfile, bbs_loglevel);
    fprintf(bbs_log, "%-16s ", bbs_logsource);
  }
  time(&now);
  strftime(timestr, sizeof timestr, "%x %X", localtime(&now));
  fprintf(bbs_log, "%s ", timestr);
  vfprintf(bbs_log, fmt, args);
  fflush(bbs_log);
  __builtin_va_end(args);
}

canonical_original_code:
void bbslog(int level, char *fmt, ...)
{
  __builtin_va_list args;
  long now;
  char timestr[40];
  __builtin_va_start(args,fmt);
  if (level > bbs_loglevel) {
    __builtin_va_end(args);
    return;
  }
  fseek(bbs_log, 0, 2);
  if (fprintf(bbs_log, "%-16s ", bbs_logsource) == (-1)) {
    close_bbslog();
    open_bbslog(bbs_logfile, bbs_loglevel);
    fprintf(bbs_log, "%-16s ", bbs_logsource);
  }
  time(&now);
  strftime(timestr, sizeof timestr, "%x %X", localtime(&now));
  fprintf(bbs_log, "%s ", timestr);
  vfprintf(bbs_log, fmt, args);
  fflush(bbs_log);
  __builtin_va_end(args);
}

variable_types: level int

variable_types:
fmt
char *

variable_types: now long

variable_types:
timestr
char [40]


igetch

decompiled_code:
__int64 __fastcall igetch(__int64 a1, char *a2)
{
int v2; // eax
int v3; // ebp
int v4; // eax
unsigned __int8 v6; // al
int v7; // eax
__int64 v8; // rdi
int v9; // eax
__int64 v10; // rdx
__int64 v11; // rdx
struct timeval v12; // [rsp+0h] [rbp-A8h] BYREF
fd_set readfds; // [rsp+10h] [rbp-98h] BYREF

while ( 1 )
{
if ( ibufsize == icurrchar )
{
v12.tv_sec = 0LL;
v12.tv_usec = 0LL;
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[0] |= 1uLL;
v7 = i_newfd;
v8 = 1LL;
if ( i_newfd )
{
readfds.fds_bits[i_newfd / 64] |= 1LL << (i_newfd % 64);
v8 = (unsigned int)(v7 + 1);
}
if ( select(v8, &readfds, 0LL, 0LL, &v12) <= 0 )
{
if ( flushf )
flushf(v8, &readfds, flushf);
if ( dumb_term )
oflush();
else
refresh();
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[0] |= 1uLL;
v2 = i_newfd;
v3 = 1;
if ( i_newfd )
{
readfds.fds_bits[i_newfd / 64] |= 1LL << (i_newfd % 64);
v3 = v2 + 1;
}
while ( 1 )
{
v4 = select(v3, &readfds, 0LL, 0LL, i_top);
if ( v4 >= 0 )
break;
if ( *_errno_location() != 4 )
{
perror("select");
fwrite("abnormal select conditions\n", 1uLL, 0x1BuLL, stderr);
return 0xFFFFFFFFLL;
}
}
if ( !v4 )
return 4294967294LL;
}
if ( i_newfd && (readfds.fds_bits[i_newfd / 64] & (1LL << (i_newfd % 64))) != 0 )
return 4294967293LL;
while ( 1 )
{
a2 = inbuf;
a1 = 0LL;
v9 = read(0, inbuf, 0x100uLL);
ibufsize = v9;
if ( v9 > 0 )
break;
if ( !v9 )
generic_abort(0LL, inbuf, v10);
if ( ibufsize < 0 && *_errno_location() != 4 )
generic_abort(0LL, inbuf, v11);
}
icurrchar = 0;
}
input_active = 1;
v6 = inbuf[icurrchar];
if ( v6 != 12 )
break;
redoscr(a1, a2, (unsigned int)icurrchar);
++icurrchar;
}
++icurrchar;
return *((unsigned int *)&conv_table + 2 * v6);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, char *a2)
{
int v2; // eax
int v3; // ebp
int v4; // eax
unsigned __int8 v6; // al
int v7; // eax
__int64 v8; // rdi
int v9; // eax
__int64 v10; // rdx
__int64 v11; // rdx
struct timeval v12; // [rsp+0h] [rbp-A8h] BYREF
fd_set readfds; // [rsp+10h] [rbp-98h] BYREF

while ( 1 )
{
if ( ibufsize == icurrchar )
{
v12.tv_sec = 0LL;
v12.tv_usec = 0LL;
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[0] |= 1uLL;
v7 = i_newfd;
v8 = 1LL;
if ( i_newfd )
{
readfds.fds_bits[i_newfd / 64] |= 1LL << (i_newfd % 64);
v8 = (unsigned int)(v7 + 1);
}
if ( select(v8, &readfds, 0LL, 0LL, &v12) <= 0 )
{
if ( flushf )
flushf(v8, &readfds, flushf);
if ( dumb_term )
func0();
else
refresh();
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[0] |= 1uLL;
v2 = i_newfd;
v3 = 1;
if ( i_newfd )
{
readfds.fds_bits[i_newfd / 64] |= 1LL << (i_newfd % 64);
v3 = v2 + 1;
}
while ( 1 )
{
v4 = select(v3, &readfds, 0LL, 0LL, i_top);
if ( v4 >= 0 )
break;
if ( *_errno_location() != 4 )
{
perror("select");
fwrite("abnormal select conditions\n", 1uLL, 0x1BuLL, stderr);
return 0xFFFFFFFFLL;
}
}
if ( !v4 )
return 4294967294LL;
}
if ( i_newfd && (readfds.fds_bits[i_newfd / 64] & (1LL << (i_newfd % 64))) != 0 )
return 4294967293LL;
while ( 1 )
{
a2 = inbuf;
a1 = 0LL;
v9 = read(0, inbuf, 0x100uLL);
ibufsize = v9;
if ( v9 > 0 )
break;
if ( !v9 )
generic_abort(0LL, inbuf, v10);
if ( ibufsize < 0 && *_errno_location() != 4 )
generic_abort(0LL, inbuf, v11);
}
icurrchar = 0;
}
input_active = 1;
v6 = inbuf[icurrchar];
if ( v6 != 12 )
break;
redoscr(a1, a2, (unsigned int)icurrchar);
++icurrchar;
}
++icurrchar;
return *((unsigned int *)&conv_table + 2 * v6);
}

original_code:
int
igetch()
{
igetagain:
    if(ibufsize == icurrchar) {
        fd_set readfds ;
        struct timeval to ;
        int nfds, sr ;
        to.tv_sec = 0 ;
        to.tv_usec = 0 ;
        do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0) ;
        nfds = 1;
     ((void) (((&readfds)->__fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((0) % (8 * (int) sizeof (__fd_mask))))))) ;
        if(i_newfd) {
            ((void) (((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask))))))) ;
     nfds = i_newfd+1;
        }
        if((sr = select(nfds, &readfds, ((void *)0), ((void *)0), &to)) <= 0) {
            if(flushf)
                (*flushf)() ;
            if(dumb_term)
                oflush() ;
            else
                refresh() ;
selectagain:
            do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0) ;
            nfds = 1;
           ((void) (((&readfds)->__fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((0) % (8 * (int) sizeof (__fd_mask))))))) ;
            if(i_newfd) {
                ((void) (((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask))))))) ;
           nfds = i_newfd+1;
     }
            while((sr = select(nfds, &readfds, ((void *)0), ((void *)0), i_top)) <0) {
                if((*__errno_location ()) == 4) {
        continue ;
  }
                else {
                    perror("select") ;
                    fprintf(stderr,"abnormal select conditions\n") ;
                    return -1 ;
                }
            }
            if(sr == 0)
                return (-2) ;
        }
        if(i_newfd && ((((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
            return (-3) ;
        }
        while((ibufsize = read(0,inbuf,(256))) <= 0) {
            if(ibufsize == 0)
                generic_abort() ;
            if(ibufsize < 0 && (*__errno_location ()) != 4)
                generic_abort() ;
        }
        icurrchar = 0 ;
    }
    input_active = 1;
    switch(inbuf[icurrchar]) {
      case ('L'&037):
        redoscr() ;
        icurrchar++ ;
        goto igetagain ;
      default:
        break ;
    }
    return conv_table[inbuf[icurrchar++]][0] ;
}

canonical_original_code:
int igetch()
{
igetagain:
    if(ibufsize == icurrchar) {
        struct fd_set readfds;
        struct timeval to;
        int nfds; int sr;
        to.tv_sec = 0 ;
        to.tv_usec = 0 ;
        do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0) ;
        nfds = 1;
     ((void) (((&readfds)->__fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((0) % (8 * (int) sizeof (__fd_mask))))))) ;
        if(i_newfd) {
            ((void) (((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask))))))) ;
     nfds = i_newfd+1;
        }
        if((sr = select(nfds, &readfds, ((void *)0), ((void *)0), &to)) <= 0) {
            if(flushf)
                (*flushf)() ;
            if(dumb_term)
                oflush() ;
            else
                refresh() ;
selectagain:
            do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readfds)->__fds_bits)[0]) : "memory"); } while (0) ;
            nfds = 1;
           ((void) (((&readfds)->__fds_bits)[((0) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((0) % (8 * (int) sizeof (__fd_mask))))))) ;
            if(i_newfd) {
                ((void) (((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask))))))) ;
           nfds = i_newfd+1;
     }
            while((sr = select(nfds, &readfds, ((void *)0), ((void *)0), i_top)) <0) {
                if((*__errno_location ()) == 4) {
        continue ;
  }
                else {
                    perror("select") ;
                    fprintf(stderr,"abnormal select conditions\n") ;
                    return -1 ;
                }
            }
            if(sr == 0)
                return (-2) ;
        }
        if(i_newfd && ((((&readfds)->__fds_bits)[((i_newfd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((i_newfd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
            return (-3) ;
        }
        while((ibufsize = read(0,inbuf,(256))) <= 0) {
            if(ibufsize == 0)
                generic_abort() ;
            if(ibufsize < 0 && (*__errno_location ()) != 4)
                generic_abort() ;
        }
        icurrchar = 0 ;
    }
    input_active = 1;
    switch(inbuf[icurrchar]) {
      case ('L'&037):
        redoscr() ;
        icurrchar++ ;
        goto igetagain ;
      default:
        break ;
    }
    return conv_table[inbuf[icurrchar++]][0] ;
}

variable_types:
readfds
struct fd_set { long __fds_bits[-1]; }

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: nfds int

variable_types: sr int


repo: virtualolson/who

decompiled_code:
__int64 __fastcall db_cluster_bind_api(_QWORD *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
*a1 = 0LL;
a1[20] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 168) >> 3));
a1[1] = &db_cluster_use_table;
a1[2] = &db_cluster_init;
a1[4] = &db_cluster_close;
a1[5] = &db_cluster_query;
a1[6] = &db_cluster_fetch_result;
a1[7] = &db_cluster_raw_query;
a1[8] = &db_cluster_free_result;
a1[9] = &db_cluster_insert;
a1[10] = &db_cluster_delete;
a1[11] = &db_cluster_update;
a1[12] = &db_cluster_replace;
a1[13] = &db_cluster_last_inserted_id;
a1[14] = &db_cluster_insert_update;
a1[15] = &db_cluster_insert_delayed;
a1[16] = &db_cluster_affected_rows;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
*a1 = 0LL;
a1[20] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 168) >> 3));
a1[1] = &db_cluster_use_table;
a1[2] = &db_cluster_init;
a1[4] = &db_cluster_close;
a1[5] = &db_cluster_query;
a1[6] = &db_cluster_fetch_result;
a1[7] = &db_cluster_raw_query;
a1[8] = &db_cluster_free_result;
a1[9] = &db_cluster_insert;
a1[10] = &db_cluster_delete;
a1[11] = &db_cluster_update;
a1[12] = &db_cluster_replace;
a1[13] = &db_cluster_last_inserted_id;
a1[14] = &db_cluster_insert_update;
a1[15] = &db_cluster_insert_delayed;
a1[16] = &db_cluster_affected_rows;
return 0LL;
}

original_code:
int db_cluster_bind_api(db_func_t *dbb)
{
 if(dbb==((void *)0))
  return -1;
 memset(dbb, 0, sizeof(db_func_t));
 dbb->use_table = db_cluster_use_table;
 dbb->init = db_cluster_init;
 dbb->close = db_cluster_close;
 dbb->query = db_cluster_query;
 dbb->fetch_result = db_cluster_fetch_result;
 dbb->raw_query = db_cluster_raw_query;
 dbb->free_result = db_cluster_free_result;
 dbb->insert = db_cluster_insert;
 dbb->delete = db_cluster_delete;
 dbb->update = db_cluster_update;
 dbb->replace = db_cluster_replace;
 dbb->last_inserted_id = db_cluster_last_inserted_id;
 dbb->insert_update = db_cluster_insert_update;
 dbb->insert_delayed = db_cluster_insert_delayed;
 dbb->affected_rows = db_cluster_affected_rows;
 return 0;
}

canonical_original_code:
int db_cluster_bind_api(struct db_func *dbb)
{
 if(dbb==((void *)0))
  return -1;
 memset(dbb, 0, sizeof(db_func_t));
 dbb->use_table = db_cluster_use_table;
 dbb->init = db_cluster_init;
 dbb->close = db_cluster_close;
 dbb->query = db_cluster_query;
 dbb->fetch_result = db_cluster_fetch_result;
 dbb->raw_query = db_cluster_raw_query;
 dbb->free_result = db_cluster_free_result;
 dbb->insert = db_cluster_insert;
 dbb->delete = db_cluster_delete;
 dbb->update = db_cluster_update;
 dbb->replace = db_cluster_replace;
 dbb->last_inserted_id = db_cluster_last_inserted_id;
 dbb->insert_update = db_cluster_insert_update;
 dbb->insert_delayed = db_cluster_insert_delayed;
 dbb->affected_rows = db_cluster_affected_rows;
 return 0;
}

variable_types: struct db_func { unsigned int cap; int (*use_table)(struct db1_con_t { struct _str { char *s; int len; } *table; unsigned long tail; } *_h, struct _str *_t); struct db1_con_t *(*init)(struct _str *_sqlurl); struct db1_con_t *(*init2)(struct _str *_sqlurl, enum db_pooling_t { DB_POOLING_PERMITTED=0, DB_POOLING_NONE=1 } _pooling); void (*close)(struct db1_con_t *_h); int (*query)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t { enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } type; int nul; int free; union { int int_val; long long ll_val; double double_val; long time_val; char *string_val; struct _str str_val; struct _str blob_val; unsigned int bitmap_val; } val; } *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res { struct { struct _str **names; enum db_type_t { DB1_INT=0, DB1_BIGINT=1, DB1_DOUBLE=2, DB1_STRING=3, DB1_STR=4, DB1_DATETIME=5, DB1_BLOB=6, DB1_BITMAP=7 } *types; int n; } col; struct db_row { struct db_val_t *values; int n; } *rows; int n; int res_rows; int last_row; void *ptr; } **_r); int (*fetch_result)(struct db1_con_t *_h, struct db1_res **_r, int _n); int (*raw_query)(struct db1_con_t *_h, struct _str *_s, struct db1_res **_r); int (*free_result)(struct db1_con_t *_h, struct db1_res *_r); int (*insert)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*delete)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, int _n); int (*update)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, struct _str **_uk, struct db_val_t *_uv, int _n, int _un); int (*replace)(struct db1_con_t *handle, struct _str **keys, struct db_val_t *vals, int n, int _un, int _m); int (*last_inserted_id)(struct db1_con_t *_h); int (*insert_update)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*insert_delayed)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*affected_rows)(struct db1_con_t *_h); int (*start_transaction)(struct db1_con_t *_h, enum db_locking_t { DB_LOCKING_NONE=0, DB_LOCKING_WRITE=1, DB_LOCKING_FULL=2 } _l); int (*end_transaction)(struct db1_con_t *_h); int (*abort_transaction)(struct db1_con_t *_h); int (*query_lock)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); } *

user_defined_types: struct db_func { unsigned int cap; int (*use_table)(struct db1_con_t *_h, struct _str *_t); struct db1_con_t *(*init)(struct _str *_sqlurl); struct db1_con_t *(*init2)(struct _str *_sqlurl, enum db_pooling_t _pooling); void (*close)(struct db1_con_t *_h); int (*query)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); int (*fetch_result)(struct db1_con_t *_h, struct db1_res **_r, int _n); int (*raw_query)(struct db1_con_t *_h, struct _str *_s, struct db1_res **_r); int (*free_result)(struct db1_con_t *_h, struct db1_res *_r); int (*insert)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*delete)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, int _n); int (*update)(struct db1_con_t *_h, struct _str **_k, char **_o, struct db_val_t *_v, struct _str **_uk, struct db_val_t *_uv, int _n, int _un); int (*replace)(struct db1_con_t *handle, struct _str **keys, struct db_val_t *vals, int n, int _un, int _m); int (*last_inserted_id)(struct db1_con_t *_h); int (*insert_update)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*insert_delayed)(struct db1_con_t *_h, struct _str **_k, struct db_val_t *_v, int _n); int (*affected_rows)(struct db1_con_t *_h); int (*start_transaction)(struct db1_con_t *_h, enum db_locking_t _l); int (*end_transaction)(struct db1_con_t *_h); int (*abort_transaction)(struct db1_con_t *_h); int (*query_lock)(struct db1_con_t *_h, struct _str **_k, char **_op, struct db_val_t *_v, struct _str **_c, int _n, int _nc, struct _str *_o, struct db1_res **_r); }

user_defined_types: struct db1_con_t { struct _str *table; unsigned long tail; }

user_defined_types: struct db_val_t { enum db_type_t type; int nul; int free; union { int int_val; long long ll_val; double double_val; long time_val; char *string_val; struct _str str_val; struct _str blob_val; unsigned int bitmap_val; } val; }

user_defined_types: struct db1_res { struct { struct _str **names; enum db_type_t *types; int n; } col; struct db_row *rows; int n; int res_rows; int last_row; void *ptr; }


decompiled_code:
__int64 __fastcall dbcl_con_param(__int64 a1, __int64 a2)
{
return dbcl_parse_con_param(a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return dbcl_parse_con_param(a2);
}

original_code:
int dbcl_con_param(modparam_t type, void *val)
{
 return dbcl_parse_con_param((char*)val);
}

canonical_original_code:
int dbcl_con_param(unsigned int type, void *val)
{
 return dbcl_parse_con_param((char *)val);
}

variable_types:
type
unsigned int

variable_types:
val
void *


decompiled_code:
__int64 __fastcall dbcl_cls_param(__int64 a1, __int64 a2)
{
return dbcl_parse_cls_param(a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
return dbcl_parse_cls_param(a2);
}

original_code:
int dbcl_cls_param(modparam_t type, void *val)
{
 return dbcl_parse_cls_param((char*)val);
}

canonical_original_code:
int dbcl_cls_param(unsigned int type, void *val)
{
 return dbcl_parse_cls_param((char *)val);
}