main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
socklen_t v3; // edx
int optval; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr v5; // [rsp+10h] [rbp-18h] BYREF

dListen = socket(2, 1, 0);
optval = 1;
if ( setsockopt(dListen, 1, 2, &optval, 4u) != -1 )
{
*(_QWORD *)&v5.sa_data[6] = 0LL;
v5.sa_family = 2;
*(_QWORD *)&v5.sa_data[2] = (unsigned __int16)_bswap_16(0);
*(_WORD *)v5.sa_data = _bswap_16(9997);
bind(dListen, &v5, v3);
listen(dListen, 100);
while ( 1 )
{
dConnection = accept(dListen, 0LL, 0LL);
pthread_create(&tidPreServerThread, 0LL, preServerThread, 0LL);
}
}
perror("setsockopt()");
exit(1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
socklen_t v3; // edx
int optval; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr v5; // [rsp+10h] [rbp-18h] BYREF

dListen = socket(2, 1, 0);
optval = 1;
if ( setsockopt(dListen, 1, 2, &optval, 4u) != -1 )
{
*(_QWORD *)&v5.sa_data[6] = 0LL;
v5.sa_family = 2;
*(_QWORD *)&v5.sa_data[2] = (unsigned __int16)func0(0);
*(_WORD *)v5.sa_data = func0(9997);
bind(dListen, &v5, v3);
listen(dListen, 100);
while ( 1 )
{
dConnection = accept(dListen, 0LL, 0LL);
pthread_create(&tidPreServerThread, 0LL, preServerThread, 0LL);
}
}
perror("setsockopt()");
exit(1);
}

original_code:
int main(int argc, char *argv[])
{
 struct sockaddr_in uServer;
 dListen = socket(2, SOCK_STREAM, 0);
 int yes=1;
 if (setsockopt(dListen, 1, 2, &yes, sizeof(int)) == -1) {
  perror("setsockopt()");
  exit(1);
 }
 bzero(&uServer, sizeof(uServer));
 uServer.sin_family = 2;
 uServer.sin_addr.s_addr = htons(((in_addr_t) 0x00000000));
 uServer.sin_port = htons(9997);
 bind(dListen, (struct sockaddr *) &uServer, sizeof(uServer));
 listen(dListen, 100);
 for ( ; ; ) {
  dConnection = accept(dListen, ((void *)0), ((void *)0));
  pthread_create(&tidPreServerThread, ((void *)0), preServerThread, ((void *)0));
 }
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct sockaddr_in uServer;
 dListen = socket(2, SOCK_STREAM, 0);
 int yes = 1;
 if (setsockopt(dListen, 1, 2, &yes, sizeof(int)) == -1) {
  perror("setsockopt()");
  exit(1);
 }
 bzero(&uServer, sizeof(uServer));
 uServer.sin_family = 2;
 uServer.sin_addr.s_addr = htons(((unsigned int) 0x00000000));
 uServer.sin_port = htons(9997);
 bind(dListen, (struct sockaddr *) &uServer, sizeof(uServer));
 listen(dListen, 100);
 for ( ; ; ) {
  dConnection = accept(dListen, ((void *)0), ((void *)0));
  pthread_create(&tidPreServerThread, ((void *)0), preServerThread, ((void *)0));
 }
}

variable_types:
argv
char *[]

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

variable_types: yes int

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

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


writeToServer

repo: SunnyBingoMe/chat

decompiled_code:
void *__fastcall writeToServer(void *a1)
{
size_t v1; // rax
void *result; // rax
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

while ( fgets(v3, 256, dFile) )
{
v1 = strlen(v3);
write(dConnection, v3, v1);
}
shutdown(dConnection, 1);
result = 0LL;
writeToServerIsDone = 1;
return result;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
size_t v1; // rax
void *result; // rax
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

while ( fgets(v3, 256, dFile) )
{
v1 = strlen(v3);
write(dConnection, v3, v1);
}
shutdown(dConnection, 1);
result = 0LL;
writeToServerIsDone = 1;
return result;
}

original_code:
void * writeToServer(void *arg)
{
 char aMsg[255 + 1];
 while (fgets(aMsg, 255 + 1, dFile) != ((void *)0)){
  write(dConnection, aMsg, strlen(aMsg));
 }
 shutdown(dConnection, SHUT_WR);
 writeToServerIsDone = 1;
 return(((void *)0));
}

canonical_original_code:
void *writeToServer(void *arg)
{
 char aMsg[-1];
 while (fgets(aMsg, 255 + 1, dFile) != ((void *)0)){
  write(dConnection, aMsg, strlen(aMsg));
 }
 shutdown(dConnection, SHUT_WR);
 writeToServerIsDone = 1;
 return(((void *)0));
}

variable_types:
arg
void *

variable_types:
aMsg
char [-1]

return_type: void *


main

canonical_name: main

repo: Superkazuya/neuralnetwork-with-pso

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
char *v5; // r12
__int64 i; // rbp
char *v7; // r12
__int64 j; // rbp
char *v9; // r13
__int64 k; // rbp
int v11; // er13
int v12; // ebp
double *v13; // r15
__int64 v14; // r14
double v15; // xmm0_8
double v16; // xmm1_8
__int64 l; // rax
double v18; // xmm0_8
double v19; // [rsp+0h] [rbp-2E8h]
char *endptr; // [rsp+18h] [rbp-2D0h] BYREF
double v21; // [rsp+20h] [rbp-2C8h]
double v22; // [rsp+28h] [rbp-2C0h]
__int64 v23[5]; // [rsp+48h] [rbp-2A0h]
double v24; // [rsp+70h] [rbp-278h]
__int64 v25[15]; // [rsp+A0h] [rbp-248h] BYREF
char v26; // [rsp+118h] [rbp-1D0h] BYREF
char v27[200]; // [rsp+120h] [rbp-1C8h] BYREF
char v28[200]; // [rsp+1E8h] [rbp-100h] BYREF
char v29; // [rsp+2B0h] [rbp-38h] BYREF

xmlKeepBlanksDefault();
*(_DWORD *)__xmlIndentTreeOutput() = 1;
if ( xmlReadFile() )
{
if ( !xmlDocGetRootElement() || (unsigned int)xmlStrcmp() )
goto LABEL_4;
v5 = v27;
endptr = (char *)xmlNodeListGetString();
do
{
for ( i = 0LL; i != 5; ++i )
*(double *)&v5[8 * i] = strtod(endptr, &endptr);
v5 += 40;
}
while ( v5 != v28 );
v7 = v28;
do
{
for ( j = 0LL; j != 5; ++j )
*(double *)&v7[8 * j] = strtod(endptr, &endptr);
v7 += 40;
}
while ( v7 != &v29 );
v3 = xmlStrcmp();
if ( v3 )
{
LABEL_4:
v3 = 1;
puts("XML empty or corrupted.");
xmlCleanupParser();
xmlMemoryDump();
}
else
{
v9 = (char *)v25;
endptr = (char *)xmlNodeListGetString();
do
{
for ( k = 0LL; k != 5; ++k )
*(double *)&v9[8 * k] = strtod(endptr, &endptr);
v9 += 40;
}
while ( v9 != &v26 );
v11 = 0;
puts("XML file loaded successfully.");
while ( 1 )
{
v12 = 0;
v19 = (double)v11;
while ( 1 )
{
v13 = (double *)v27;
v14 = 5LL;
printf("%lf, %lf:", v19, (double)v12);
v21 = 1.0 / (exp(-(v19 - *(double *)v25)) + 1.0);
v22 = 1.0 / (exp(-((double)v12 - *(double *)&v25[1])) + 1.0);
do
{
v15 = *v13 * v21;
v13 += 5;
*(double *)((char *)&v21 + v14 * 8) = 1.0 / (exp(-(v22 * *(v13 - 4) + *(double *)&v25[v14] + v15)) + 1.0);
++v14;
}
while ( v14 != 10 );
v16 = *(double *)&v25[10];
for ( l = 0LL; l != 5; ++l )
{
v18 = *(double *)&v28[l * 8] * *(double *)&v23[l];
v16 = v16 + v18;
}
v24 = 1.0 / (exp(-v16) + 1.0);
printf("%lf\n", v24);
if ( v12 == 1 )
break;
v12 = 1;
}
if ( v11 == 1 )
break;
v11 = 1;
}
}
}
else
{
v3 = 1;
puts("Error opening XML file.");
}
return v3;
}

original_code:
int
main()
{
  unsigned int i, counter = 0;
  int array[3];
  void* status;
  pthread_t pthread_id[3];
  pthread_attr_t pthread_attr;
  pthread_mutex_init(&mutex_g, ((void *)0));
  pthread_attr_init(&pthread_attr);
  pthread_attr_setdetachstate(&pthread_attr, PTHREAD_CREATE_JOINABLE);
  for(i = 0; i < 3; i++)
  {
    array[i] = i;
    pthread_create(pthread_id+i, &pthread_attr, thread_agent, (void *)(array+i));
  }
  pthread_attr_destroy(&pthread_attr);
  for(i = 0; i < 3; i++)
  {
    pthread_join(pthread_id[i], &status);
    printf("Thread return: %d.\n", *(int*)status);
    if(*(int*)status == 0)
      goto STORE;
  }
  printf("BAD ENDING.\n");
  exit(1);
STORE:
  printf("GOOD ENDING.\n");
  store();
  exit(0);
}

canonical_original_code:
int main()
{
  unsigned int i; unsigned int counter = 0;
  int array[3];
  void *status;
  unsigned long pthread_id[3];
  union pthread_attr_t pthread_attr;
  pthread_mutex_init(&mutex_g, ((void *)0));
  pthread_attr_init(&pthread_attr);
  pthread_attr_setdetachstate(&pthread_attr, PTHREAD_CREATE_JOINABLE);
  for(i = 0; i < 3; i++)
  {
    array[i] = i;
    pthread_create(pthread_id+i, &pthread_attr, thread_agent, (void *)(array+i));
  }
  pthread_attr_destroy(&pthread_attr);
  for(i = 0; i < 3; i++)
  {
    pthread_join(pthread_id[i], &status);
    printf("Thread return: %d.\n", *(int *)status);
    if(*(int *)status == 0)
      goto STORE;
  }
  printf("BAD ENDING.\n");
  exit(1);
STORE:
  printf("GOOD ENDING.\n");
  store();
  exit(0);
}

variable_types:
i
unsigned int

variable_types:
counter
unsigned int

variable_types:
array
int [3]

variable_types:
status
void *

variable_types: union pthread_attr_t { char __size[56]; long __align; }

return_type: int


decompiled_code:
__int64 __fastcall game_of_life(unsigned int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
{
int v9; // esi
__int64 result; // rax

v9 = a3 + a4 + a5 + a6 + a7 + a8 + a9 + a2;
result = 0LL;
if ( (unsigned int)(v9 - 2) <= 1 )
{
result = 1LL;
if ( v9 != 3 )
result = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
{
int v9; // esi
__int64 result; // rax

v9 = a3 + a4 + a5 + a6 + a7 + a8 + a9 + a2;
result = 0LL;
if ( (unsigned int)(v9 - 2) <= 1 )
{
result = 1LL;
if ( v9 != 3 )
result = a1;
}
return result;
}

original_code:
Vivant game_of_life (Vivant mm,Vivant bm, Vivant bg, Vivant bd, Vivant mg, Vivant md, Vivant hg, Vivant hm, Vivant hd){
    int nombreEnVie;
    nombreEnVie=bm+bg+bd+mg+md+hg+hd+hm;
    if(nombreEnVie==3 || nombreEnVie==2){
        if(nombreEnVie==3){
            return Vie;
        }
        else{
            return mm;
        }
    }
    return Mort;
}

canonical_original_code:
enum Vivant game_of_life(enum Vivant mm, enum Vivant bm, enum Vivant bg, enum Vivant bd, enum Vivant mg, enum Vivant md, enum Vivant hg, enum Vivant hm, enum Vivant hd){
    int nombreEnVie;
    nombreEnVie=bm+bg+bd+mg+md+hg+hd+hm;
    if(nombreEnVie==3 || nombreEnVie==2){
        if(nombreEnVie==3){
            return Vie;
        }
        else{
            return mm;
        }
    }
    return Mort;
}

variable_types:
mm
enum Vivant { Mort=0, Vie=1 }

variable_types:
bm
enum Vivant { Mort=0, Vie=1 }

variable_types:
bg
enum Vivant { Mort=0, Vie=1 }

variable_types:
bd
enum Vivant { Mort=0, Vie=1 }

variable_types:
mg
enum Vivant { Mort=0, Vie=1 }

variable_types:
md
enum Vivant { Mort=0, Vie=1 }

variable_types:
hg
enum Vivant { Mort=0, Vie=1 }

variable_types:
hm
enum Vivant { Mort=0, Vie=1 }

variable_types:
hd
enum Vivant { Mort=0, Vie=1 }

variable_types: nombreEnVie int

return_type: enum Vivant { Mort=0, Vie=1 }


copie

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

result = a2 + 10LL * a1;
t[result] = temp[8 * a1 - 9 + a2];
return result;
}

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

result = a2 + 10LL * a1;
t[result] = temp[8 * a1 - 9 + a2];
return result;
}

original_code:
void copie(int i, int j){
    t[i][j]=temp[i-1][j-1];
}

variable_types: i int

variable_types: j int

return_type: void


max

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

result = a1;
if ( (int)a2 >= (int)a1 )
result = a2;
return result;
}

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

result = a1;
if ( (int)a2 >= (int)a1 )
result = a2;
return result;
}

original_code:
int max(int i, int j){
   return i>j ? i : j;
}


decompiled_code:
__int64 game_of_life_multifor()
{
int v0; // er12
int i; // ebp
int j; // ebx
__int64 result; // rax
int v4; // er8
int k; // ecx

v0 = -2;
for ( i = 1; i != 9; ++i )
{
for ( j = 1; j != 9; ++j )
{
compute(i, j);
if ( i > 3 )
copie(v0, j);
}
++v0;
}
result = max(4u, 9u);
v4 = result - 3;
if ( (int)result <= 11 )
{
do
{
for ( k = 1; k != 9; result = copie(v4, k) )
;
++v4;
}
while ( v4 != 9 );
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
int v0; // er12
int i; // ebp
int j; // ebx
__int64 result; // rax
int v4; // er8
int k; // ecx

v0 = -2;
for ( i = 1; i != 9; ++i )
{
for ( j = 1; j != 9; ++j )
{
func8(i, j);
if ( i > 3 )
func9(v0, j);
}
++v0;
}
result = func10(4u, 9u);
v4 = result - 3;
if ( (int)result <= 11 )
{
do
{
for ( k = 1; k != 9; result = func9(v4, k) )
;
++v4;
}
while ( v4 != 9 );
}
return result;
}


decompiled_code:
__int64 game_of_life_normal()
{
int i; // ebp
int j; // ebx
int v2; // esi
int k; // er8
int l; // ecx
__int64 result; // rax

for ( i = 1; i != 9; ++i )
{
for ( j = 1; j != 9; ++j )
{
v2 = j;
compute(i, v2);
}
}
for ( k = 1; k != 9; ++k )
{
for ( l = 1; l != 9; result = copie(k, l) )
;
}
return result;
}

canonical_decompiled_code:
__int64 func12()
{
int i; // ebp
int j; // ebx
int v2; // esi
int k; // er8
int l; // ecx
__int64 result; // rax

for ( i = 1; i != 9; ++i )
{
for ( j = 1; j != 9; ++j )
{
v2 = j;
func8(i, v2);
}
}
for ( k = 1; k != 9; ++k )
{
for ( l = 1; l != 9; result = func9(k, l) )
;
}
return result;
}

original_code:
void game_of_life_normal(){
    for(int i=1; i<10 -1; i++){
        for(int j=1; j<10 -1; j++){
            compute(i,j);
        }
    }
    for(int i=1; i<10 -1; i++){
        for(int j=1; j<10 -1; j++){
            copie(i,j);
        }
    }
    return;
}

canonical_original_code:
void game_of_life_normal(){
    for(int i = 1; i<10 -1; i++){
        for(int j = 1; j<10 -1; j++){
            compute(i,j);
        }
    }
    for(int i = 1; i<10 -1; i++){
        for(int j = 1; j<10 -1; j++){
            copie(i,j);
        }
    }
    return;
}


decompiled_code:
__int64 initialise_alea()
{
char *v0; // rbp
char *v1; // rbx
__int64 result; // rax

v0 = (char *)&unk_4041A8;
do
{
v1 = v0 - 40;
do
{
v1 += 4;
result = rand() & 1;
*((_DWORD *)v1 - 1) = result;
}
while ( v1 != v0 );
v0 = v1 + 40;
}
while ( v1 != (char *)&end );
return result;
}

canonical_decompiled_code:
__int64 func13()
{
char *v0; // rbp
char *v1; // rbx
__int64 result; // rax

v0 = (char *)&unk_4041A8;
do
{
v1 = v0 - 40;
do
{
v1 += 4;
result = rand() & 1;
*((_DWORD *)v1 - 1) = result;
}
while ( v1 != v0 );
v0 = v1 + 40;
}
while ( v1 != (char *)&end );
return result;
}

original_code:
void initialise_alea(){
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            t[i][j]=(Vivant) rand()%2;
        }
    }
}

canonical_original_code:
void initialise_alea(){
    for(int i = 0; i<10; i++){
        for(int j = 0; j<10; j++){
            t[i][j]=(enum Vivant) rand()%2;
        }
    }
}


repo: SystemGarden/habitat

decompiled_code:
__int64 __fastcall job_runqexpired(int a1)
{
__int64 v1; // rdx
__int64 result; // rax
_QWORD *v4; // rdi
__int64 v5; // rax
_QWORD *v6; // rbp

v1 = *job_tab;
result = *(_QWORD *)*job_tab;
*(_QWORD *)(job_tab + 8LL) = result;
if ( v1 != result )
{
while ( 1 )
{
v5 = itree_get();
v6 = (_QWORD *)v5;
if ( *(_DWORD *)(v5 + 16) == a1 )
break;
v4 = (_QWORD *)job_tab;
result = **(_QWORD **)(job_tab + 8LL);
*(_QWORD *)(job_tab + 8LL) = result;
if ( result == *v4 )
return result;
}
elog_fprintf(1LL, "iiab/job.c", 242LL, "job_runqexpired", "job %s finshed", **(const char ***)(v5 + 8));
itree_rm(job_tab);
nm_nfree(*v6, "iiab/job.c", 246LL, "job_runqexpired");
result = nm_nfree(v6, "iiab/job.c", 247LL, "job_runqexpired");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 v1; // rdx
__int64 result; // rax
_QWORD *v4; // rdi
__int64 v5; // rax
_QWORD *v6; // rbp

v1 = *job_tab;
result = *(_QWORD *)*job_tab;
*(_QWORD *)(job_tab + 8LL) = result;
if ( v1 != result )
{
while ( 1 )
{
v5 = itree_get();
v6 = (_QWORD *)v5;
if ( *(_DWORD *)(v5 + 16) == a1 )
break;
v4 = (_QWORD *)job_tab;
result = **(_QWORD **)(job_tab + 8LL);
*(_QWORD *)(job_tab + 8LL) = result;
if ( result == *v4 )
return result;
}
elog_fprintf(1LL, "iiab/job.c", 242LL, "job_runqexpired", "job %s finshed", **(const char ***)(v5 + 8));
itree_rm(job_tab);
nm_nfree(*v6, "iiab/job.c", 246LL, "job_runqexpired");
result = nm_nfree(v6, "iiab/job.c", 247LL, "job_runqexpired");
}
return result;
}

original_code:
void job_runqexpired(void *ikey)
{
     struct job_work *w;
     for((job_tab)->node = ((job_tab)->root->c.list.flink); (job_tab)->node != ((job_tab)->root); (job_tab)->node = ((job_tab)->node->c.list.flink)) {
   w = itree_get(job_tab);
   if (w->runq == (int) (long) ikey) {
        elog_fprintf(DEBUG,"iiab/job.c",242,__PRETTY_FUNCTION__,"job %s finshed", w->runarg->key);
        itree_rm(job_tab);
        nm_nfree(w->origin,"iiab/job.c",246,__PRETTY_FUNCTION__);
        nm_nfree(w,"iiab/job.c",247,__PRETTY_FUNCTION__);
        return;
   }
     }
}

variable_types:
ikey
void *

variable_types: struct job_work { char *origin; struct meth_invoke { char *key; struct meth_info { char *(*name)(); char *(*info)(); enum exectype { METH_NONE=0, METH_FORK=1, METH_THREAD=2, METH_SOURCE=3 } (*type)(); int (*prerun)(); int (*preaction)(); int (*action)(); int (*postrun)(); char *fname; } *run; char *command; char *res_purl; char *err_purl; long keep; } *runarg; int runq; } *

user_defined_types: struct job_work { char *origin; struct meth_invoke *runarg; int runq; }

user_defined_types: struct meth_invoke { char *key; struct meth_info *run; char *command; char *res_purl; char *err_purl; long keep; }

user_defined_types: struct meth_info { char *(*name)(); char *(*info)(); enum exectype (*type)(); int (*prerun)(); int (*preaction)(); int (*action)(); int (*postrun)(); char *fname; }


decompiled_code:
time_t job_init()
{
time_t result; // rax

job_tab = itree_really_create("iiab/job.c", 35LL, "job_init");
callback_regcb("runq_expired", job_runqexpired);
result = time(0LL);
job_start_t = result;
return result;
}

canonical_decompiled_code:
time_t func1()
{
time_t result; // rax

job_tab = itree_really_create("iiab/job.c", 35LL, "job_init");
callback_regcb("runq_expired", job_runqexpired);
result = time(0LL);
job_start_t = result;
return result;
}

original_code:
void job_init()
{
     job_tab = itree_really_create("iiab/job.c",35,__PRETTY_FUNCTION__);
     callback_regcb("runq_expired", (void *) job_runqexpired);
     job_start_t = time(((void *)0));
}


decompiled_code:
__int64 job_dump()
{
__int64 v0; // rdx
__int64 v1; // rax
__int64 v2; // rbx
_QWORD *v3; // rdi
__int64 v4; // rax

elog_fstartsend(1LL, "iiab/job.c", 53LL, "job_dump", "Job table ------\n");
v0 = *job_tab;
v1 = *(_QWORD *)*job_tab;
*(_QWORD *)(job_tab + 8LL) = v1;
if ( v0 != v1 )
{
do
{
v2 = itree_get();
itree_getkey(job_tab);
elog_fcontprintf(
1LL,
" %8s %8s %14s %14s %d\n",
**(const char ***)(v2 + 8),
*(const char **)v2,
*(const char **)(*(_QWORD *)(v2 + 8) + 24LL),
*(const char **)(*(_QWORD *)(v2 + 8) + 32LL),
*(_QWORD *)(*(_QWORD *)(v2 + 8) + 40LL));
v3 = (_QWORD *)job_tab;
v4 = **(_QWORD **)(job_tab + 8LL);
*(_QWORD *)(job_tab + 8LL) = v4;
}
while ( v4 != *v3 );
}
return elog_fendsend(1LL, "----------------");
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rdx
__int64 v1; // rax
__int64 v2; // rbx
_QWORD *v3; // rdi
__int64 v4; // rax

elog_fstartsend(1LL, "iiab/job.c", 53LL, "job_dump", "Job table ------\n");
v0 = *job_tab;
v1 = *(_QWORD *)*job_tab;
*(_QWORD *)(job_tab + 8LL) = v1;
if ( v0 != v1 )
{
do
{
v2 = itree_get();
itree_getkey(job_tab);
elog_fcontprintf(
1LL,
" %8s %8s %14s %14s %d\n",
**(const char ***)(v2 + 8),
*(const char **)v2,
*(const char **)(*(_QWORD *)(v2 + 8) + 24LL),
*(const char **)(*(_QWORD *)(v2 + 8) + 32LL),
*(_QWORD *)(*(_QWORD *)(v2 + 8) + 40LL));
v3 = (_QWORD *)job_tab;
v4 = **(_QWORD **)(job_tab + 8LL);
*(_QWORD *)(job_tab + 8LL) = v4;
}
while ( v4 != *v3 );
}
return elog_fendsend(1LL, "----------------");
}

original_code:
void job_dump()
{
     struct job_work *w;
     time_t t;
     elog_fstartsend(DEBUG,"iiab/job.c",53,__PRETTY_FUNCTION__,"Job table ------\n");
     for((job_tab)->node = ((job_tab)->root->c.list.flink); (job_tab)->node != ((job_tab)->root); (job_tab)->node = ((job_tab)->node->c.list.flink)) {
   w = itree_get(job_tab);
   t = itree_getkey(job_tab);
   elog_fcontprintf(DEBUG,"    %8s %8s %14s %14s %d\n", w->runarg->key, w->origin, w->runarg->res_purl, w->runarg->err_purl, w->runarg->keep);
     }
     elog_fendsend(DEBUG,"----------------");
}

canonical_original_code:
void job_dump()
{
     struct job_work *w;
     long t;
     elog_fstartsend(DEBUG,"iiab/job.c",53,__PRETTY_FUNCTION__,"Job table ------\n");
     for((job_tab)->node = ((job_tab)->root->c.list.flink); (job_tab)->node != ((job_tab)->root); (job_tab)->node = ((job_tab)->node->c.list.flink)) {
   w = itree_get(job_tab);
   t = itree_getkey(job_tab);
   elog_fcontprintf(DEBUG,"    %8s %8s %14s %14s %d\n", w->runarg->key, w->origin, w->runarg->res_purl, w->runarg->err_purl, w->runarg->keep);
     }
     elog_fendsend(DEBUG,"----------------");
}

variable_types: t long

user_defined_types: enum exectype { METH_NONE=0, METH_FORK=1, METH_THREAD=2, METH_SOURCE=3 }


decompiled_code:
__int64 __fastcall job_add(__int64 a1, __int64 a2, __int64 a3, __int64 a4, const char *a5, const char *a6, char *src, char *a8, int a9, const char *a10, char *s)
{
__int64 v12; // rax
int v13; // er12
int v14; // er15
int v15; // eax
__int64 v16; // r11
__int64 v17; // r15
char *v18; // rax
char *v19; // rax
char *v20; // rax
unsigned int v21; // eax
unsigned int v22; // er12
__int64 v24; // rbp
__int64 v25; // rax
int v29; // [rsp+30h] [rbp-58h]
__int64 v30; // [rsp+30h] [rbp-58h]
__int64 v31; // [rsp+38h] [rbp-50h]
__int64 v32; // [rsp+40h] [rbp-48h]

if ( !a10 || !*a10 )
{
v22 = -1;
elog_fprintf(5LL, "iiab/job.c", 110LL, "job_add", "no method in job %s", a5);
return v22;
}
v12 = tree_find(meth_methods, a10);
if ( !v12 )
{
v22 = -1;
elog_fprintf(5LL, "iiab/job.c", 115LL, "job_add", "unknown method %s in job %s", a10, a5);
return v22;
}
v32 = v12;
v13 = strlen(a5);
v29 = strlen(s);
v14 = strlen(src);
v15 = strlen(a8);
v16 = v29;
v30 = v14;
v31 = v16;
v17 = nm_xnmalloc(v15 + v14 + v13 + v16 + 52, "iiab/job.c", 124LL, "job_add");
v18 = strcpy((char *)(v17 + 48), a5);
*(_QWORD *)v17 = v18;
*(_QWORD *)(v17 + 8) = v32;
v19 = strcpy(&v18[v13 + 1], s);
*(_QWORD *)(v17 + 16) = v19;
v20 = strcpy(&v19[v31 + 1], src);
*(_QWORD *)(v17 + 24) = v20;
*(_QWORD *)(v17 + 32) = strcpy(&v20[v30 + 1], a8);
*(_QWORD *)(v17 + 40) = a9;
elog_fprintf(
1LL,
"iiab/job.c",
138LL,
"job_add",
"job added: %d %d %d %d %s %s %s %s %d %8s %s",
a1,
a2,
a3,
a4,
a5,
a6,
src,
a8,
a9,
a10,
s);
v21 = runq_add(
a1 + job_start_t,
a2,
a3,
a4,
a5,
&meth_startrun_s,
&meth_execute_s,
&meth_isrunning_s,
&meth_endrun_s,
v17,
48LL);
v22 = v21;
if ( v21 >= 0xFFFFFFFE )
{
if ( v21 != -1 )
return (unsigned int)-2;
elog_fprintf(5LL, "iiab/job.c", 148LL, "job_add", "bad parameter in job %s", a5);
return v22;
}
v24 = nm_xnmalloc(24LL, "iiab/job.c", 155LL, "job_add");
v25 = nm_xnstrdup(a6, "iiab/job.c", 156LL, "job_add");
*(_QWORD *)(v24 + 8) = v17;
*(_QWORD *)v24 = v25;
*(_DWORD *)(v24 + 16) = v22;
return itree_append(job_tab, v24);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4, const char *a5, const char *a6, char *src, char *a8, int a9, const char *a10, char *s)
{
__int64 v12; // rax
int v13; // er12
int v14; // er15
int v15; // eax
__int64 v16; // r11
__int64 v17; // r15
char *v18; // rax
char *v19; // rax
char *v20; // rax
unsigned int v21; // eax
unsigned int v22; // er12
__int64 v24; // rbp
__int64 v25; // rax
int v29; // [rsp+30h] [rbp-58h]
__int64 v30; // [rsp+30h] [rbp-58h]
__int64 v31; // [rsp+38h] [rbp-50h]
__int64 v32; // [rsp+40h] [rbp-48h]

if ( !a10 || !*a10 )
{
v22 = -1;
elog_fprintf(5LL, "iiab/job.c", 110LL, "job_add", "no method in job %s", a5);
return v22;
}
v12 = tree_find(meth_methods, a10);
if ( !v12 )
{
v22 = -1;
elog_fprintf(5LL, "iiab/job.c", 115LL, "job_add", "unknown method %s in job %s", a10, a5);
return v22;
}
v32 = v12;
v13 = strlen(a5);
v29 = strlen(s);
v14 = strlen(src);
v15 = strlen(a8);
v16 = v29;
v30 = v14;
v31 = v16;
v17 = nm_xnmalloc(v15 + v14 + v13 + v16 + 52, "iiab/job.c", 124LL, "job_add");
v18 = strcpy((char *)(v17 + 48), a5);
*(_QWORD *)v17 = v18;
*(_QWORD *)(v17 + 8) = v32;
v19 = strcpy(&v18[v13 + 1], s);
*(_QWORD *)(v17 + 16) = v19;
v20 = strcpy(&v19[v31 + 1], src);
*(_QWORD *)(v17 + 24) = v20;
*(_QWORD *)(v17 + 32) = strcpy(&v20[v30 + 1], a8);
*(_QWORD *)(v17 + 40) = a9;
elog_fprintf(
1LL,
"iiab/job.c",
138LL,
"job_add",
"job added: %d %d %d %d %s %s %s %s %d %8s %s",
a1,
a2,
a3,
a4,
a5,
a6,
src,
a8,
a9,
a10,
s);
v21 = runq_add(
a1 + job_start_t,
a2,
a3,
a4,
a5,
&meth_startrun_s,
&meth_execute_s,
&meth_isrunning_s,
&meth_endrun_s,
v17,
48LL);
v22 = v21;
if ( v21 >= 0xFFFFFFFE )
{
if ( v21 != -1 )
return (unsigned int)-2;
elog_fprintf(5LL, "iiab/job.c", 148LL, "job_add", "bad parameter in job %s", a5);
return v22;
}
v24 = nm_xnmalloc(24LL, "iiab/job.c", 155LL, "job_add");
v25 = nm_xnstrdup(a6, "iiab/job.c", 156LL, "job_add");
*(_QWORD *)(v24 + 8) = v17;
*(_QWORD *)v24 = v25;
*(_DWORD *)(v24 + 16) = v22;
return itree_append(job_tab, v24);
}

original_code:
int job_add(long start,
     long interval,
     long phase,
     long count,
     char *key,
     char *origin,
     char *result,
     char *error,
     int keep,
     char *method,
     char *command )
{
     struct job_work *work;
     int r, klen, clen, rlen, elen;
     METHID meth;
     struct meth_invoke *runarg;
     char *mem;
     if (method == ((void *)0) || *method == '\0') {
          elog_fprintf(ERROR,"iiab/job.c",110,__PRETTY_FUNCTION__,"no method in job %s", key);
          return -1;
     }
     meth = tree_find(meth_methods, (method));
     if (meth == ((void *)0)) {
          elog_fprintf(ERROR,"iiab/job.c",115,__PRETTY_FUNCTION__,"unknown method %s in job %s", method, key);
          return -1;
     }
     klen = strlen(key);
     clen = strlen(command);
     rlen = strlen(result);
     elen = strlen(error);
     runarg = nm_xnmalloc(sizeof(struct meth_invoke) + klen + clen + rlen + elen +4,"iiab/job.c",124,__PRETTY_FUNCTION__);
     mem = ((char *) runarg) + sizeof(struct meth_invoke);
     runarg->key = strcpy(mem, key);
     runarg->run = meth;
     mem += klen + 1;
     runarg->command = strcpy(mem, command);
     mem += clen + 1;
     runarg->res_purl = strcpy(mem, result);
     mem += rlen + 1;
     runarg->err_purl = strcpy(mem, error);
     runarg->keep = keep;
     elog_fprintf(DEBUG,"iiab/job.c",138,__PRETTY_FUNCTION__,"job added: %d %d %d %d %s %s %s %s %d %8s %s", start, interval, phase, count, key, origin, result, error, keep, method, command);
     r = runq_add(job_start_t+start, interval, phase, count, key,
    meth_startrun_s, meth_execute_s, meth_isrunning_s,
    meth_endrun_s, runarg, sizeof(struct meth_invoke));
     if (r == -1 || r == -2) {
   if (r == -1) {
        elog_fprintf(ERROR,"iiab/job.c",148,__PRETTY_FUNCTION__,"bad parameter in job %s", key);
        return -1;
   } else
        return -2;
     }
     work = nm_xnmalloc(sizeof(struct job_work),"iiab/job.c",155,__PRETTY_FUNCTION__);
     work->origin = nm_xnstrdup(origin,"iiab/job.c",156,__PRETTY_FUNCTION__);
     work->runarg = runarg;
     work->runq = r;
     r = itree_append(job_tab, work);
     return r;
}

canonical_original_code:
int job_add(long start, long interval, long phase, long count, char *key, char *origin, char *result, char *error, int keep, char *method, char *command)
{
     struct job_work *work;
     int r; int klen; int clen; int rlen; int elen;
     struct meth_info *meth;
     struct meth_invoke *runarg;
     char *mem;
     if (method == ((void *)0) || *method == '\0') {
          elog_fprintf(ERROR,"iiab/job.c",110,__PRETTY_FUNCTION__,"no method in job %s", key);
          return -1;
     }
     meth = tree_find(meth_methods, (method));
     if (meth == ((void *)0)) {
          elog_fprintf(ERROR,"iiab/job.c",115,__PRETTY_FUNCTION__,"unknown method %s in job %s", method, key);
          return -1;
     }
     klen = strlen(key);
     clen = strlen(command);
     rlen = strlen(result);
     elen = strlen(error);
     runarg = nm_xnmalloc(sizeof(struct meth_invoke) + klen + clen + rlen + elen +4,"iiab/job.c",124,__PRETTY_FUNCTION__);
     mem = ((char *) runarg) + sizeof(struct meth_invoke);
     runarg->key = strcpy(mem, key);
     runarg->run = meth;
     mem += klen + 1;
     runarg->command = strcpy(mem, command);
     mem += clen + 1;
     runarg->res_purl = strcpy(mem, result);
     mem += rlen + 1;
     runarg->err_purl = strcpy(mem, error);
     runarg->keep = keep;
     elog_fprintf(DEBUG,"iiab/job.c",138,__PRETTY_FUNCTION__,"job added: %d %d %d %d %s %s %s %s %d %8s %s", start, interval, phase, count, key, origin, result, error, keep, method, command);
     r = runq_add(job_start_t+start, interval, phase, count, key,
    meth_startrun_s, meth_execute_s, meth_isrunning_s,
    meth_endrun_s, runarg, sizeof(struct meth_invoke));
     if (r == -1 || r == -2) {
   if (r == -1) {
        elog_fprintf(ERROR,"iiab/job.c",148,__PRETTY_FUNCTION__,"bad parameter in job %s", key);
        return -1;
   } else
        return -2;
     }
     work = nm_xnmalloc(sizeof(struct job_work),"iiab/job.c",155,__PRETTY_FUNCTION__);
     work->origin = nm_xnstrdup(origin,"iiab/job.c",156,__PRETTY_FUNCTION__);
     work->runarg = runarg;
     work->runq = r;
     r = itree_append(job_tab, work);
     return r;
}

variable_types: start long

variable_types: interval long

variable_types: phase long

variable_types: count long

variable_types:
key
char *

variable_types:
origin
char *

variable_types:
result
char *

variable_types:
error
char *

variable_types: keep int

variable_types:
method
char *

variable_types:
command
char *

variable_types: r int

variable_types: klen int

variable_types: clen int

variable_types: rlen int

variable_types: elen int

variable_types: struct meth_invoke { char *key; struct meth_info { char *(*name)(); char *(*info)(); enum exectype { METH_NONE=0, METH_FORK=1, METH_THREAD=2, METH_SOURCE=3 } (*type)(); int (*prerun)(); int (*preaction)(); int (*action)(); int (*postrun)(); char *fname; } *run; char *command; char *res_purl; char *err_purl; long keep; } *

variable_types:
mem
char *


decompiled_code:
__int64 __fastcall job_rm(unsigned int a1)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 result; // rax

v1 = itree_find(job_tab, a1);
if ( v1 == -1 )
{
elog_fprintf(5LL, "iiab/job.c", 178LL, "job_rm", "job not found (id %d)", a1);
result = 0LL;
}
else
{
v2 = v1;
elog_fprintf(1LL, "iiab/job.c", 183LL, "job_rm", "remove job %s", **(const char ***)(v1 + 8));
if ( (unsigned int)runq_rm(*(unsigned int *)(v2 + 16)) )
{
itree_rm(job_tab);
nm_nfree(*(_QWORD *)v2, "iiab/job.c", 195LL, "job_rm");
nm_nfree(v2, "iiab/job.c", 196LL, "job_rm");
result = 1LL;
}
else
{
elog_fprintf(
1LL,
"iiab/job.c",
187LL,
"job_rm",
"job %s can't remove runq (id %d)",
**(const char ***)(v2 + 8),
*(unsigned int *)(v2 + 16));
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 result; // rax

v1 = itree_find(job_tab, a1);
if ( v1 == -1 )
{
elog_fprintf(5LL, "iiab/job.c", 178LL, "job_rm", "job not found (id %d)", a1);
result = 0LL;
}
else
{
v2 = v1;
elog_fprintf(1LL, "iiab/job.c", 183LL, "job_rm", "remove job %s", **(const char ***)(v1 + 8));
if ( (unsigned int)runq_rm(*(unsigned int *)(v2 + 16)) )
{
itree_rm(job_tab);
nm_nfree(*(_QWORD *)v2, "iiab/job.c", 195LL, "job_rm");
nm_nfree(v2, "iiab/job.c", 196LL, "job_rm");
result = 1LL;
}
else
{
elog_fprintf(
1LL,
"iiab/job.c",
187LL,
"job_rm",
"job %s can't remove runq (id %d)",
**(const char ***)(v2 + 8),
*(unsigned int *)(v2 + 16));
result = 0LL;
}
}
return result;
}

original_code:
int job_rm(int ikey ) {
     struct job_work *w;
     if ((w = itree_find(job_tab, ikey)) == (void *) -1) {
          elog_fprintf(ERROR,"iiab/job.c",178,__PRETTY_FUNCTION__,"job not found (id %d)", ikey);
   return 0;
     }
     elog_fprintf(DEBUG,"iiab/job.c",183,__PRETTY_FUNCTION__,"remove job %s", w->runarg->key);
     if (!runq_rm(w->runq)) {
          elog_fprintf(DEBUG,"iiab/job.c",187,__PRETTY_FUNCTION__,"job %s can't remove runq (id %d)", w->runarg->key, w->runq);
   return 0;
     }
     itree_rm(job_tab);
     nm_nfree(w->origin,"iiab/job.c",195,__PRETTY_FUNCTION__);
     nm_nfree(w,"iiab/job.c",196,__PRETTY_FUNCTION__);
     return(1);
}

canonical_original_code:
int job_rm(int ikey) {
     struct job_work *w;
     if ((w = itree_find(job_tab, ikey)) == (void *) -1) {
          elog_fprintf(ERROR,"iiab/job.c",178,__PRETTY_FUNCTION__,"job not found (id %d)", ikey);
   return 0;
     }
     elog_fprintf(DEBUG,"iiab/job.c",183,__PRETTY_FUNCTION__,"remove job %s", w->runarg->key);
     if (!runq_rm(w->runq)) {
          elog_fprintf(DEBUG,"iiab/job.c",187,__PRETTY_FUNCTION__,"job %s can't remove runq (id %d)", w->runarg->key, w->runq);
   return 0;
     }
     itree_rm(job_tab);
     nm_nfree(w->origin,"iiab/job.c",195,__PRETTY_FUNCTION__);
     nm_nfree(w,"iiab/job.c",196,__PRETTY_FUNCTION__);
     return(1);
}

variable_types: ikey int

variable_types: struct job_work { char *origin; struct meth_invoke { char *key; struct meth_info { char *(*name)(); char *(*info)(); enum exectype { METH_NONE=0, METH_FORK=1, METH_THREAD=2, METH_SOURCE=3 } (*type)(); int (*prerun)(); int (*preaction)(); int (*action)(); int (*postrun)(); char *fname; } *run; char *command; char *res_purl; char *err_purl; long keep; } *runarg; int runq; } *


decompiled_code:
void job_clear()
{
__int64 v0; // rax
_QWORD *v1; // rdi
__int64 v2; // rbp
__int64 v3; // rdx
__int64 v4; // rax
unsigned int v5; // eax
__int64 v6; // rax
unsigned int v7; // eax
_QWORD *v8; // rdx
_QWORD *v9; // rax
unsigned int v10; // eax
__int64 v11; // rax

if ( job_tab )
{
v0 = itree_really_create("iiab/job.c", 212LL, "job_clear");
v1 = (_QWORD *)job_tab;
v2 = v0;
v3 = *job_tab;
v4 = *(_QWORD *)*job_tab;
*(_QWORD *)(job_tab + 8LL) = v4;
if ( v3 != v4 )
{
do
{
v5 = itree_getkey(v1);
itree_add(v2, v5, 0LL);
v1 = (_QWORD *)job_tab;
v6 = **(_QWORD **)(job_tab + 8LL);
*(_QWORD *)(job_tab + 8LL) = v6;
}
while ( v6 != *v1 );
}
v7 = itree_n();
elog_fprintf(1LL, "iiab/job.c", 218LL, "job_clear", "removing %d jobs", v7);
v8 = *(_QWORD **)v2;
v9 = **(_QWORD ***)v2;
*(_QWORD *)(v2 + 8) = v9;
if ( v8 != v9 )
{
do
{
v10 = itree_getkey(v2);
job_rm(v10);
v11 = **(_QWORD **)(v2 + 8);
*(_QWORD *)(v2 + 8) = v11;
}
while ( v11 != *(_QWORD *)v2 );
}
itree_really_destroy(v2, "iiab/job.c", 223LL, "job_clear");
}
}

canonical_decompiled_code:
void func5()
{
__int64 v0; // rax
_QWORD *v1; // rdi
__int64 v2; // rbp
__int64 v3; // rdx
__int64 v4; // rax
unsigned int v5; // eax
__int64 v6; // rax
unsigned int v7; // eax
_QWORD *v8; // rdx
_QWORD *v9; // rax
unsigned int v10; // eax
__int64 v11; // rax

if ( job_tab )
{
v0 = itree_really_create("iiab/job.c", 212LL, "job_clear");
v1 = (_QWORD *)job_tab;
v2 = v0;
v3 = *job_tab;
v4 = *(_QWORD *)*job_tab;
*(_QWORD *)(job_tab + 8LL) = v4;
if ( v3 != v4 )
{
do
{
v5 = itree_getkey(v1);
itree_add(v2, v5, 0LL);
v1 = (_QWORD *)job_tab;
v6 = **(_QWORD **)(job_tab + 8LL);
*(_QWORD *)(job_tab + 8LL) = v6;
}
while ( v6 != *v1 );
}
v7 = itree_n();
elog_fprintf(1LL, "iiab/job.c", 218LL, "job_clear", "removing %d jobs", v7);
v8 = *(_QWORD **)v2;
v9 = **(_QWORD ***)v2;
*(_QWORD *)(v2 + 8) = v9;
if ( v8 != v9 )
{
do
{
v10 = itree_getkey(v2);
func4(v10);
v11 = **(_QWORD **)(v2 + 8);
*(_QWORD *)(v2 + 8) = v11;
}
while ( v11 != *(_QWORD *)v2 );
}
itree_really_destroy(v2, "iiab/job.c", 223LL, "job_clear");
}
}

original_code:
void job_clear()
{
     ITREE *keys;
     if (!job_tab)
          return;
     keys = itree_really_create("iiab/job.c",212,__PRETTY_FUNCTION__);
     for((job_tab)->node = ((job_tab)->root->c.list.flink); (job_tab)->node != ((job_tab)->root); (job_tab)->node = ((job_tab)->node->c.list.flink))
   itree_add(keys, itree_getkey(job_tab), ((void *)0));
     elog_fprintf(DEBUG,"iiab/job.c",218,__PRETTY_FUNCTION__,"removing %d jobs", itree_n(job_tab));
    for((keys)->node = ((keys)->root->c.list.flink); (keys)->node != ((keys)->root); (keys)->node = ((keys)->node->c.list.flink)) {
         job_rm( itree_getkey(keys) );
    }
     itree_really_destroy(keys,"iiab/job.c",223,__PRETTY_FUNCTION__);
}

canonical_original_code:
void job_clear()
{
     struct itree_head *keys;
     if (!job_tab)
          return;
     keys = itree_really_create("iiab/job.c",212,__PRETTY_FUNCTION__);
     for((job_tab)->node = ((job_tab)->root->c.list.flink); (job_tab)->node != ((job_tab)->root); (job_tab)->node = ((job_tab)->node->c.list.flink))
   itree_add(keys, itree_getkey(job_tab), ((void *)0));
     elog_fprintf(DEBUG,"iiab/job.c",218,__PRETTY_FUNCTION__,"removing %d jobs", itree_n(job_tab));
    for((keys)->node = ((keys)->root->c.list.flink); (keys)->node != ((keys)->root); (keys)->node = ((keys)->node->c.list.flink)) {
         job_rm( itree_getkey(keys) );
    }
     itree_really_destroy(keys,"iiab/job.c",223,__PRETTY_FUNCTION__);
}

variable_types: struct itree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *

user_defined_types: struct itree_head { struct rb_node *root; struct rb_node *node; }

user_defined_types: struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; }


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

job_clear();
result = job_tab;
if ( job_tab[0] )
result = (_QWORD *)itree_really_destroy(job_tab[0], "iiab/job.c", 44LL, "job_fini");
return result;
}

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

func5();
result = job_tab;
if ( job_tab[0] )
result = (_QWORD *)itree_really_destroy(job_tab[0], "iiab/job.c", 44LL, "job_fini");
return result;
}

original_code:
void job_fini()
{
     job_clear();
     if (job_tab)
          itree_really_destroy(job_tab,"iiab/job.c",44,__PRETTY_FUNCTION__);
}


decompiled_code:
__int64 __fastcall job_loadroute(const char *a1)
{
_QWORD *v2; // rdx
_QWORD *v3; // rax
__int64 v4; // r14
const char *v5; // rax
__int64 v6; // rbp
char *v7; // rax
const char *v8; // rax
char *v9; // rax
const char *v10; // rax
char *v11; // rax
const char *v12; // rax
char *v13; // rax
const char *v14; // rbx
char *v15; // rdi
char *v16; // rdi
const char *v17; // rax
char *v18; // rax
int v19; // eax
char *v20; // r10
__int64 v21; // rax
__int64 v22; // rax
_QWORD *v23; // rdi
__int64 v24; // rax
__int64 v26; // rbx
int v27; // eax
_QWORD *v28; // rdx
_QWORD *v29; // rax
const char *v30; // rax
__int64 v31; // rax
__int64 v32; // rax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
__int64 v37; // rax
__int64 v38; // [rsp+0h] [rbp-6E8h]
unsigned int v39; // [rsp+Ch] [rbp-6DCh]
__int64 v40; // [rsp+10h] [rbp-6D8h]
__int64 v41; // [rsp+20h] [rbp-6C8h]
char *v42; // [rsp+20h] [rbp-6C8h]
__int64 v43; // [rsp+28h] [rbp-6C0h]
__int64 v44; // [rsp+30h] [rbp-6B8h]
__int64 v45; // [rsp+38h] [rbp-6B0h]
const char *v46; // [rsp+40h] [rbp-6A8h]
const char *v47; // [rsp+48h] [rbp-6A0h]
char *v48; // [rsp+50h] [rbp-698h]
__int64 v49; // [rsp+58h] [rbp-690h]
char *endptr; // [rsp+60h] [rbp-688h] BYREF
__int64 v51; // [rsp+68h] [rbp-680h] BYREF
char v52[64]; // [rsp+70h] [rbp-678h] BYREF
char v53[256]; // [rsp+B0h] [rbp-638h] BYREF
char v54[256]; // [rsp+1B0h] [rbp-538h] BYREF
char v55[1080]; // [rsp+2B0h] [rbp-438h] BYREF

if ( (int)util_parseroute(a1, " \t", "job 1", &v51) <= 0 )
return (unsigned int)-1;
util_parsedump(v51);
v39 = 0;
v2 = *(_QWORD **)v51;
v3 = **(_QWORD ***)v51;
*(_QWORD *)(v51 + 8) = v3;
if ( v2 != v3 )
{
do
{
v4 = ((__int64 (*)(void))itree_get)();
if ( (unsigned int)itree_n(v4) == 11 )
{
itree_find(v4, 0LL);
v5 = (const char *)itree_get(v4);
v6 = strtol(v5, &endptr, 10);
if ( (unsigned __int64)(v6 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v7 = (char *)itree_get(v4), endptr == v7) )
{
itree_get(v4);
v22 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
320LL,
"job_loadroute",
"%s row %d start time (column 1) is incorrect: '%s'; skipping",
a1,
v22);
}
else
{
itree_find(v4, 1LL);
v8 = (const char *)itree_get(v4);
v38 = strtol(v8, &endptr, 10);
if ( (unsigned __int64)(v38 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v9 = (char *)itree_get(v4), endptr == v9) )
{
itree_get(v4);
v32 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
331LL,
"job_loadroute",
"%s row %d interval (column 2) is incorrect: '%s'; skipping",
a1,
v32);
}
else
{
itree_find(v4, 2LL);
v10 = (const char *)itree_get(v4);
v40 = strtol(v10, &endptr, 10);
if ( (unsigned __int64)(v40 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v11 = (char *)itree_get(v4), endptr == v11) )
{
itree_get(v4);
v33 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
342LL,
"job_loadroute",
"%s row %d phase (column 3) is incorrect: '%s'; skipping",
a1,
v33);
}
else
{
itree_find(v4, 3LL);
v12 = (const char *)itree_get(v4);
v44 = strtol(v12, &endptr, 10);
if ( (unsigned __int64)(v44 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v13 = (char *)itree_get(v4), endptr == v13) )
{
itree_get(v4);
v34 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
353LL,
"job_loadroute",
"%s row %d count (column 4) is incorrect: '%s'; skipping",
a1,
v34);
}
else
{
itree_find(v4, 4LL);
v14 = (const char *)itree_get(v4);
if ( (unsigned int)route_expand(v52, v14, v14, (unsigned int)v38) != -1 )
v14 = v52;
itree_find(v4, 5LL);
v46 = (const char *)itree_get(v4);
itree_find(v4, 6LL);
v41 = itree_get(v4);
v15 = v53;
if ( (unsigned int)route_expand(v53, v41, v14, (unsigned int)v38) == -1 )
v15 = (char *)v41;
v42 = v15;
itree_find(v4, 7LL);
v43 = itree_get(v4);
v16 = v54;
if ( (unsigned int)route_expand(v54, v43, v14, (unsigned int)v38) == -1 )
v16 = (char *)v43;
itree_find(v4, 8LL);
v17 = (const char *)itree_get(v4);
v45 = strtol(v17, &endptr, 10);
if ( (unsigned __int64)(v45 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v18 = (char *)itree_get(v4), endptr == v18) )
{
itree_get(v4);
v35 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
386LL,
"job_loadroute",
"%s row %d keep (column 9) is incorrect: '%s'; skipping",
a1,
v35);
}
else
{
itree_find(v4, 9LL);
v47 = (const char *)itree_get(v4);
itree_find(v4, 10LL);
v49 = itree_get(v4);
v19 = route_expand(v55, v49, v14, (unsigned int)v38);
v20 = (char *)v49;
if ( v19 != -1 )
v20 = v55;
v48 = v20;
v21 = itree_getkey(v51);
elog_fprintf(
1LL,
"iiab/job.c",
402LL,
"job_loadroute",
"%s row %d read: start=%ld interval=%ld phase=%ld count=%ld key=%s origin=%s result=%s error=%s keep="
"%ld method=%s command=%s",
a1,
v21,
v6,
v38,
v40,
v44,
v14,
v46,
v42,
v16,
v45,
v47,
v48);
if ( (unsigned int)meth_check(v47) )
{
v36 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
409LL,
"job_loadroute",
"%s row %d method %s not loaded; skipping",
a1,
v36);
}
else if ( (unsigned int)job_add(v6, v38, v40, v44, v14, v46, v42, v16, v45, v47, v48) == -1 )
{
v37 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
418LL,
"job_loadroute",
"%s row %d unable to add job; skipping",
a1,
v37);
}
else
{
++v39;
}
}
}
}
}
}
}
else
{
v26 = (unsigned int)itree_n(v4);
v27 = itree_getkey(v51);
elog_fstartprintf(
5LL,
"iiab/job.c",
302LL,
"job_loadroute",
"%s row %d has %d fields, want 11 (",
a1,
(unsigned int)(v27 + 1),
v26);
v28 = *(_QWORD **)v4;
v29 = **(_QWORD ***)v4;
*(_QWORD *)(v4 + 8) = v29;
if ( v28 != v29 )
{
do
{
v30 = (const char *)itree_get(v4);
elog_fcontprintf(5LL, "%s ", v30);
v31 = **(_QWORD **)(v4 + 8);
*(_QWORD *)(v4 + 8) = v31;
}
while ( v31 != *(_QWORD *)v4 );
}
elog_fendprintf(5LL, ")");
}
v23 = (_QWORD *)v51;
v24 = **(_QWORD **)(v51 + 8);
*(_QWORD *)(v51 + 8) = v24;
}
while ( v24 != *v23 );
}
util_freeparse();
return v39;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
_QWORD *v2; // rdx
_QWORD *v3; // rax
__int64 v4; // r14
const char *v5; // rax
__int64 v6; // rbp
char *v7; // rax
const char *v8; // rax
char *v9; // rax
const char *v10; // rax
char *v11; // rax
const char *v12; // rax
char *v13; // rax
const char *v14; // rbx
char *v15; // rdi
char *v16; // rdi
const char *v17; // rax
char *v18; // rax
int v19; // eax
char *v20; // r10
__int64 v21; // rax
__int64 v22; // rax
_QWORD *v23; // rdi
__int64 v24; // rax
__int64 v26; // rbx
int v27; // eax
_QWORD *v28; // rdx
_QWORD *v29; // rax
const char *v30; // rax
__int64 v31; // rax
__int64 v32; // rax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
__int64 v37; // rax
__int64 v38; // [rsp+0h] [rbp-6E8h]
unsigned int v39; // [rsp+Ch] [rbp-6DCh]
__int64 v40; // [rsp+10h] [rbp-6D8h]
__int64 v41; // [rsp+20h] [rbp-6C8h]
char *v42; // [rsp+20h] [rbp-6C8h]
__int64 v43; // [rsp+28h] [rbp-6C0h]
__int64 v44; // [rsp+30h] [rbp-6B8h]
__int64 v45; // [rsp+38h] [rbp-6B0h]
const char *v46; // [rsp+40h] [rbp-6A8h]
const char *v47; // [rsp+48h] [rbp-6A0h]
char *v48; // [rsp+50h] [rbp-698h]
__int64 v49; // [rsp+58h] [rbp-690h]
char *endptr; // [rsp+60h] [rbp-688h] BYREF
__int64 v51; // [rsp+68h] [rbp-680h] BYREF
char v52[64]; // [rsp+70h] [rbp-678h] BYREF
char v53[256]; // [rsp+B0h] [rbp-638h] BYREF
char v54[256]; // [rsp+1B0h] [rbp-538h] BYREF
char v55[1080]; // [rsp+2B0h] [rbp-438h] BYREF

if ( (int)util_parseroute(a1, " \t", "job 1", &v51) <= 0 )
return (unsigned int)-1;
util_parsedump(v51);
v39 = 0;
v2 = *(_QWORD **)v51;
v3 = **(_QWORD ***)v51;
*(_QWORD *)(v51 + 8) = v3;
if ( v2 != v3 )
{
do
{
v4 = ((__int64 (*)(void))itree_get)();
if ( (unsigned int)itree_n(v4) == 11 )
{
itree_find(v4, 0LL);
v5 = (const char *)itree_get(v4);
v6 = strtol(v5, &endptr, 10);
if ( (unsigned __int64)(v6 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v7 = (char *)itree_get(v4), endptr == v7) )
{
itree_get(v4);
v22 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
320LL,
"job_loadroute",
"%s row %d start time (column 1) is incorrect: '%s'; skipping",
a1,
v22);
}
else
{
itree_find(v4, 1LL);
v8 = (const char *)itree_get(v4);
v38 = strtol(v8, &endptr, 10);
if ( (unsigned __int64)(v38 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v9 = (char *)itree_get(v4), endptr == v9) )
{
itree_get(v4);
v32 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
331LL,
"job_loadroute",
"%s row %d interval (column 2) is incorrect: '%s'; skipping",
a1,
v32);
}
else
{
itree_find(v4, 2LL);
v10 = (const char *)itree_get(v4);
v40 = strtol(v10, &endptr, 10);
if ( (unsigned __int64)(v40 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v11 = (char *)itree_get(v4), endptr == v11) )
{
itree_get(v4);
v33 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
342LL,
"job_loadroute",
"%s row %d phase (column 3) is incorrect: '%s'; skipping",
a1,
v33);
}
else
{
itree_find(v4, 3LL);
v12 = (const char *)itree_get(v4);
v44 = strtol(v12, &endptr, 10);
if ( (unsigned __int64)(v44 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v13 = (char *)itree_get(v4), endptr == v13) )
{
itree_get(v4);
v34 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
353LL,
"job_loadroute",
"%s row %d count (column 4) is incorrect: '%s'; skipping",
a1,
v34);
}
else
{
itree_find(v4, 4LL);
v14 = (const char *)itree_get(v4);
if ( (unsigned int)route_expand(v52, v14, v14, (unsigned int)v38) != -1 )
v14 = v52;
itree_find(v4, 5LL);
v46 = (const char *)itree_get(v4);
itree_find(v4, 6LL);
v41 = itree_get(v4);
v15 = v53;
if ( (unsigned int)route_expand(v53, v41, v14, (unsigned int)v38) == -1 )
v15 = (char *)v41;
v42 = v15;
itree_find(v4, 7LL);
v43 = itree_get(v4);
v16 = v54;
if ( (unsigned int)route_expand(v54, v43, v14, (unsigned int)v38) == -1 )
v16 = (char *)v43;
itree_find(v4, 8LL);
v17 = (const char *)itree_get(v4);
v45 = strtol(v17, &endptr, 10);
if ( (unsigned __int64)(v45 + 0x7FFFFFFFFFFFFFFFLL) > 0xFFFFFFFFFFFFFFFDLL
|| (v18 = (char *)itree_get(v4), endptr == v18) )
{
itree_get(v4);
v35 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
386LL,
"job_loadroute",
"%s row %d keep (column 9) is incorrect: '%s'; skipping",
a1,
v35);
}
else
{
itree_find(v4, 9LL);
v47 = (const char *)itree_get(v4);
itree_find(v4, 10LL);
v49 = itree_get(v4);
v19 = route_expand(v55, v49, v14, (unsigned int)v38);
v20 = (char *)v49;
if ( v19 != -1 )
v20 = v55;
v48 = v20;
v21 = itree_getkey(v51);
elog_fprintf(
1LL,
"iiab/job.c",
402LL,
"job_loadroute",
"%s row %d read: start=%ld interval=%ld phase=%ld count=%ld key=%s origin=%s result=%s error=%s keep="
"%ld method=%s command=%s",
a1,
v21,
v6,
v38,
v40,
v44,
v14,
v46,
v42,
v16,
v45,
v47,
v48);
if ( (unsigned int)meth_check(v47) )
{
v36 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
409LL,
"job_loadroute",
"%s row %d method %s not loaded; skipping",
a1,
v36);
}
else if ( (unsigned int)func3(v6, v38, v40, v44, v14, v46, v42, v16, v45, v47, v48) == -1 )
{
v37 = itree_getkey(v51);
elog_fprintf(
5LL,
"iiab/job.c",
418LL,
"job_loadroute",
"%s row %d unable to add job; skipping",
a1,
v37);
}
else
{
++v39;
}
}
}
}
}
}
}
else
{
v26 = (unsigned int)itree_n(v4);
v27 = itree_getkey(v51);
elog_fstartprintf(
5LL,
"iiab/job.c",
302LL,
"job_loadroute",
"%s row %d has %d fields, want 11 (",
a1,
(unsigned int)(v27 + 1),
v26);
v28 = *(_QWORD **)v4;
v29 = **(_QWORD ***)v4;
*(_QWORD *)(v4 + 8) = v29;
if ( v28 != v29 )
{
do
{
v30 = (const char *)itree_get(v4);
elog_fcontprintf(5LL, "%s ", v30);
v31 = **(_QWORD **)(v4 + 8);
*(_QWORD *)(v4 + 8) = v31;
}
while ( v31 != *(_QWORD *)v4 );
}
elog_fendprintf(5LL, ")");
}
v23 = (_QWORD *)v51;
v24 = **(_QWORD **)(v51 + 8);
*(_QWORD *)(v51 + 8) = v24;
}
while ( v24 != *v23 );
}
util_freeparse();
return v39;
}

original_code:
int job_loadroute(char *purl )
{
     long start, interval, phase, count, keep;
     char *key, *origin, *result, *error, *method, *command;
     char *endint;
     ITREE *jobdefs, *job;
     int r, njobdefs, jobsadded = 0;
     char key_t[60], result_t[256], error_t[256], command_t[1024];
     njobdefs = util_parseroute(purl, " \t", "job 1", &jobdefs);
     if (njobdefs < 1)
   return -1;
     util_parsedump(jobdefs);
     for((jobdefs)->node = ((jobdefs)->root->c.list.flink); (jobdefs)->node != ((jobdefs)->root); (jobdefs)->node = ((jobdefs)->node->c.list.flink)) {
          job = itree_get(jobdefs);
   if (itree_n(job) != 11) {
        elog_fstartprintf(ERROR,"iiab/job.c",302,__PRETTY_FUNCTION__,"%s row %d has %d fields, want 11 (", purl, itree_getkey(jobdefs)+1, itree_n(job));
        for((job)->node = ((job)->root->c.list.flink); (job)->node != ((job)->root); (job)->node = ((job)->node->c.list.flink))
      elog_fcontprintf(ERROR,"%s ", (char *) itree_get(job));
        elog_fendprintf(ERROR,")");
        continue;
   }
   itree_find(job, 0);
   start = strtol( itree_get(job), &endint, 10 );
   if (start == (-0x7fffffffffffffffL - 1L) || start == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",320,__PRETTY_FUNCTION__,"%s row %d start time (column 1) is " "incorrect: '%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 1);
   interval = strtol( itree_get(job), &endint, 10 );
   if (interval == (-0x7fffffffffffffffL - 1L) || interval == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",331,__PRETTY_FUNCTION__,"%s row %d interval (column 2) is " "incorrect: '%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 2);
   phase = strtol( itree_get(job), &endint, 10 );
   if (phase == (-0x7fffffffffffffffL - 1L) || phase == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",342,__PRETTY_FUNCTION__,"%s row %d phase (column 3) is incorrect: " "'%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 3);
   count = strtol( itree_get(job), &endint, 10 );
   if (count == (-0x7fffffffffffffffL - 1L) || count == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",353,__PRETTY_FUNCTION__,"%s row %d count (column 4) is incorrect: " "'%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 4);
   key = itree_get(job);
   if (route_expand(key_t, key, key, interval) != -1)
        key = key_t;
   itree_find(job, 5);
   origin = itree_get(job);
   itree_find(job, 6);
   result = itree_get(job);
   if (route_expand(result_t, result, key, interval) != -1)
        result = result_t;
   itree_find(job, 7);
   error = itree_get(job);
   if (route_expand(error_t, error, key, interval) != -1)
        error = error_t;
   itree_find(job, 8);
   keep = strtol( itree_get(job), &endint, 10 );
   if (keep == (-0x7fffffffffffffffL - 1L) || keep == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",386,__PRETTY_FUNCTION__,"%s row %d keep (column 9) is incorrect: " "'%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 9);
   method = itree_get(job);
   itree_find(job, 10);
   command = itree_get(job);
   if (route_expand(command_t, command, key, interval) != -1)
        command = command_t;
   elog_fprintf(DEBUG,"iiab/job.c",402,__PRETTY_FUNCTION__,"%s row %d read: start=%ld interval=%ld phase=%ld " "count=%ld key=%s origin=%s result=%s error=%s keep=%ld " "method=%s command=%s", purl, itree_getkey(jobdefs), start, interval, phase, count, key, origin, result, error, keep, method, command);
   if (meth_check(method)) {
        elog_fprintf(ERROR,"iiab/job.c",409,__PRETTY_FUNCTION__,"%s row %d method %s not loaded; skipping", purl, itree_getkey(jobdefs), method);
        continue;
   }
   r = job_add(start, interval, phase, count, key, origin, result,
        error, keep, method, command);
   if (r == -1)
        elog_fprintf(ERROR,"iiab/job.c",418,__PRETTY_FUNCTION__,"%s row %d unable to add job; skipping", purl, itree_getkey(jobdefs));
   else
        jobsadded++;
     }
     util_freeparse(jobdefs);
     return jobsadded;
}

canonical_original_code:
int job_loadroute(char *purl)
{
     long start; long interval; long phase; long count; long keep;
     char *key; char *origin; char *result; char *error; char *method; char *command;
     char *endint;
     struct itree_head *jobdefs; struct itree_head *job;
     int r; int njobdefs; int jobsadded = 0;
     char key_t[60]; char result_t[256]; char error_t[256]; char command_t[1024];
     njobdefs = util_parseroute(purl, " \t", "job 1", &jobdefs);
     if (njobdefs < 1)
   return -1;
     util_parsedump(jobdefs);
     for((jobdefs)->node = ((jobdefs)->root->c.list.flink); (jobdefs)->node != ((jobdefs)->root); (jobdefs)->node = ((jobdefs)->node->c.list.flink)) {
          job = itree_get(jobdefs);
   if (itree_n(job) != 11) {
        elog_fstartprintf(ERROR,"iiab/job.c",302,__PRETTY_FUNCTION__,"%s row %d has %d fields, want 11 (", purl, itree_getkey(jobdefs)+1, itree_n(job));
        for((job)->node = ((job)->root->c.list.flink); (job)->node != ((job)->root); (job)->node = ((job)->node->c.list.flink))
      elog_fcontprintf(ERROR,"%s ", (char *) itree_get(job));
        elog_fendprintf(ERROR,")");
        continue;
   }
   itree_find(job, 0);
   start = strtol( itree_get(job), &endint, 10 );
   if (start == (-0x7fffffffffffffffL - 1L) || start == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",320,__PRETTY_FUNCTION__,"%s row %d start time (column 1) is " "incorrect: '%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 1);
   interval = strtol( itree_get(job), &endint, 10 );
   if (interval == (-0x7fffffffffffffffL - 1L) || interval == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",331,__PRETTY_FUNCTION__,"%s row %d interval (column 2) is " "incorrect: '%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 2);
   phase = strtol( itree_get(job), &endint, 10 );
   if (phase == (-0x7fffffffffffffffL - 1L) || phase == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",342,__PRETTY_FUNCTION__,"%s row %d phase (column 3) is incorrect: " "'%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 3);
   count = strtol( itree_get(job), &endint, 10 );
   if (count == (-0x7fffffffffffffffL - 1L) || count == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",353,__PRETTY_FUNCTION__,"%s row %d count (column 4) is incorrect: " "'%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 4);
   key = itree_get(job);
   if (route_expand(key_t, key, key, interval) != -1)
        key = key_t;
   itree_find(job, 5);
   origin = itree_get(job);
   itree_find(job, 6);
   result = itree_get(job);
   if (route_expand(result_t, result, key, interval) != -1)
        result = result_t;
   itree_find(job, 7);
   error = itree_get(job);
   if (route_expand(error_t, error, key, interval) != -1)
        error = error_t;
   itree_find(job, 8);
   keep = strtol( itree_get(job), &endint, 10 );
   if (keep == (-0x7fffffffffffffffL - 1L) || keep == 0x7fffffffffffffffL ||
       itree_get(job) == endint) {
        elog_fprintf(ERROR,"iiab/job.c",386,__PRETTY_FUNCTION__,"%s row %d keep (column 9) is incorrect: " "'%s'; skipping", purl, itree_getkey(jobdefs), itree_get(job));
        continue;
   }
   itree_find(job, 9);
   method = itree_get(job);
   itree_find(job, 10);
   command = itree_get(job);
   if (route_expand(command_t, command, key, interval) != -1)
        command = command_t;
   elog_fprintf(DEBUG,"iiab/job.c",402,__PRETTY_FUNCTION__,"%s row %d read: start=%ld interval=%ld phase=%ld " "count=%ld key=%s origin=%s result=%s error=%s keep=%ld " "method=%s command=%s", purl, itree_getkey(jobdefs), start, interval, phase, count, key, origin, result, error, keep, method, command);
   if (meth_check(method)) {
        elog_fprintf(ERROR,"iiab/job.c",409,__PRETTY_FUNCTION__,"%s row %d method %s not loaded; skipping", purl, itree_getkey(jobdefs), method);
        continue;
   }
   r = job_add(start, interval, phase, count, key, origin, result,
        error, keep, method, command);
   if (r == -1)
        elog_fprintf(ERROR,"iiab/job.c",418,__PRETTY_FUNCTION__,"%s row %d unable to add job; skipping", purl, itree_getkey(jobdefs));
   else
        jobsadded++;
     }
     util_freeparse(jobdefs);
     return jobsadded;
}

variable_types:
purl
char *

variable_types: start long

variable_types: interval long

variable_types: phase long

variable_types: count long

variable_types: keep long

variable_types:
key
char *

variable_types:
endint
char *

variable_types: njobdefs int

variable_types: jobsadded int

user_defined_types: struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; }


decompiled_code:
__int64 __fastcall job_scanintotable(char *a1)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 result; // rax

v2 = table_create_a(job_cols);
v3 = v2;
if ( memcmp(a1, "job 1\n", 6uLL) || (unsigned int)table_scan(v2, a1 + 6, " \t", 2LL, 0LL, 0LL) == -1 )
{
elog_fprintf(5LL, "iiab/job.c", 449LL, "job_scanintotable", "unable to scan clockwork table");
table_destroy(v3);
result = 0LL;
}
else
{
table_freeondestroy(v3, a1);
result = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 result; // rax

v2 = table_create_a(job_cols);
v3 = v2;
if ( memcmp(a1, "job 1\n", 6uLL) || (unsigned int)table_scan(v2, a1 + 6, " \t", 2LL, 0LL, 0LL) == -1 )
{
elog_fprintf(5LL, "iiab/job.c", 449LL, "job_scanintotable", "unable to scan clockwork table");
table_destroy(v3);
result = 0LL;
}
else
{
table_freeondestroy(v3, a1);
result = v3;
}
return result;
}

original_code:
TABLE job_scanintotable(char *jobtext)
{
     TABLE tab;
     int r;
     tab = table_create_a(job_cols);
     r = strncmp(jobtext, "job 1\n", 6);
     if (r != 0 ||
  table_scan(tab, jobtext+6, " \t", 2, 0,
      0)== -1) {
   elog_fprintf(ERROR,"iiab/job.c",449,__PRETTY_FUNCTION__,"unable to scan clockwork table");
   table_destroy(tab);
   return ((void *)0);
     }
     table_freeondestroy(tab, jobtext);
     return tab;
}

canonical_original_code:
struct table_info *job_scanintotable(char *jobtext)
{
     struct table_info *tab;
     int r;
     tab = table_create_a(job_cols);
     r = strncmp(jobtext, "job 1\n", 6);
     if (r != 0 ||
  table_scan(tab, jobtext+6, " \t", 2, 0,
      0)== -1) {
   elog_fprintf(ERROR,"iiab/job.c",449,__PRETTY_FUNCTION__,"unable to scan clockwork table");
   table_destroy(tab);
   return ((void *)0);
     }
     table_freeondestroy(tab, jobtext);
     return tab;
}

variable_types:
jobtext
char *

variable_types: struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *data; struct itree_head { struct rb_node *root; struct rb_node *node; } *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; } *

variable_types: r int

user_defined_types: struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head *data; struct itree_head *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; }

user_defined_types: struct tree_head { struct rb_node *root; struct rb_node *node; }


decompiled_code:
void nm_rpt(void)
{
__int64 v0; // rbx
__int64 v1; // rdx
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rdx
const char *v6; // rcx
_QWORD *v7; // rdi
__int64 v8; // rax

if ( nm_active )
{
if ( nm_used )
{
v0 = (unsigned int)ptree_n();
fprintf(stderr, "nm_rpt() %d leaks detected\n", v0);
if ( (_DWORD)v0 )
{
fwrite("TIME METHOD ALLOTED SIZE FILE LINE FUNCTION\n", 1uLL, 0x3DuLL, stderr);
v1 = *nm_used;
v2 = *(_QWORD *)*nm_used;
*(_QWORD *)(nm_used + 8LL) = v2;
if ( v1 != v2 )
{
do
{
v3 = ptree_get();
fprintf(
stderr,
"%ld %9s %10p %5d %8s:%5d:%s\n",
*(_QWORD *)v3,
nm_names[*(unsigned int *)(v3 + 8)],
*(const void **)(v3 + 16),
*(_QWORD *)(v3 + 24),
*(const char **)(v3 + 32),
*(unsigned int *)(v3 + 40),
*(const char **)(v3 + 48));
if ( *(int *)(v3 + 64) > 0 )
{
v4 = 0LL;
do
{
v5 = (unsigned int)v4;
v6 = *(const char **)(*(_QWORD *)(v3 + 56) + 8 * v4++);
fprintf(stderr, " -->%2.2d %s\n", v5, v6);
}
while ( *(_DWORD *)(v3 + 64) > (int)v4 );
}
v7 = (_QWORD *)nm_used;
v8 = **(_QWORD **)(nm_used + 8LL);
*(_QWORD *)(nm_used + 8LL) = v8;
}
while ( v8 != *v7 );
}
}
}
else
{
fwrite("nm_rpt() no request for memory ever made\n", 1uLL, 0x29uLL, stderr);
}
}
}

canonical_decompiled_code:
void func0(void)
{
__int64 v0; // rbx
__int64 v1; // rdx
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rdx
const char *v6; // rcx
_QWORD *v7; // rdi
__int64 v8; // rax

if ( nm_active )
{
if ( nm_used )
{
v0 = (unsigned int)ptree_n();
fprintf(stderr, "nm_rpt() %d leaks detected\n", v0);
if ( (_DWORD)v0 )
{
fwrite("TIME METHOD ALLOTED SIZE FILE LINE FUNCTION\n", 1uLL, 0x3DuLL, stderr);
v1 = *nm_used;
v2 = *(_QWORD *)*nm_used;
*(_QWORD *)(nm_used + 8LL) = v2;
if ( v1 != v2 )
{
do
{
v3 = ptree_get();
fprintf(
stderr,
"%ld %9s %10p %5d %8s:%5d:%s\n",
*(_QWORD *)v3,
nm_names[*(unsigned int *)(v3 + 8)],
*(const void **)(v3 + 16),
*(_QWORD *)(v3 + 24),
*(const char **)(v3 + 32),
*(unsigned int *)(v3 + 40),
*(const char **)(v3 + 48));
if ( *(int *)(v3 + 64) > 0 )
{
v4 = 0LL;
do
{
v5 = (unsigned int)v4;
v6 = *(const char **)(*(_QWORD *)(v3 + 56) + 8 * v4++);
fprintf(stderr, " -->%2.2d %s\n", v5, v6);
}
while ( *(_DWORD *)(v3 + 64) > (int)v4 );
}
v7 = (_QWORD *)nm_used;
v8 = **(_QWORD **)(nm_used + 8LL);
*(_QWORD *)(nm_used + 8LL) = v8;
}
while ( v8 != *v7 );
}
}
}
else
{
fwrite("nm_rpt() no request for memory ever made\n", 1uLL, 0x29uLL, stderr);
}
}
}

original_code:
void nm_rpt() {
     struct nm_userec *log;
     int nleak, i;
     if ( ! nm_active )
   return;
     if ( ! nm_used ) {
          fprintf(stderr, "nm_rpt() no request for memory ever made\n");
   return;
     }
     nleak = ptree_n(nm_used);
     fprintf(stderr, "nm_rpt() %d leaks detected\n", nleak);
     if ( ! nleak )
          return;
     fprintf(stderr, "TIME         METHOD    ALLOTED  SIZE     "
       "FILE  LINE FUNCTION\n");
     for((nm_used)->node = ((nm_used)->root->c.list.flink); (nm_used)->node != ((nm_used)->root); (nm_used)->node = ((nm_used)->node->c.list.flink)) {
          log = ptree_get(nm_used);
          fprintf(stderr, "%ld %9s %10p %5d %8s:%5d:%s\n", (long) log->when,
    nm_names[log->method], log->addr, (int) log->length,
    log->reqfile, log->reqline, log->reqfunc);
   for (i = 0; i < log->n_backtrace; i++)
        fprintf(stderr, "  -->%2.2d %s\n", i, log->backtrace[i]);
     }
}

canonical_original_code:
void nm_rpt() {
     struct nm_userec *log;
     int nleak; int i;
     if ( ! nm_active )
   return;
     if ( ! nm_used ) {
          fprintf(stderr, "nm_rpt() no request for memory ever made\n");
   return;
     }
     nleak = ptree_n(nm_used);
     fprintf(stderr, "nm_rpt() %d leaks detected\n", nleak);
     if ( ! nleak )
          return;
     fprintf(stderr, "TIME         METHOD    ALLOTED  SIZE     "
       "FILE  LINE FUNCTION\n");
     for((nm_used)->node = ((nm_used)->root->c.list.flink); (nm_used)->node != ((nm_used)->root); (nm_used)->node = ((nm_used)->node->c.list.flink)) {
          log = ptree_get(nm_used);
          fprintf(stderr, "%ld %9s %10p %5d %8s:%5d:%s\n", (long) log->when,
    nm_names[log->method], log->addr, (int) log->length,
    log->reqfile, log->reqline, log->reqfunc);
   for (i = 0; i < log->n_backtrace; i++)
        fprintf(stderr, "  -->%2.2d %s\n", i, log->backtrace[i]);
     }
}

variable_types: struct nm_userec { long when; enum nm_origin { NM_NMALLOC=0, NM_XNMALLOC=1, NM_NREALLOC=2, NM_XNREALLOC=3, NM_NFREE=4, NM_XNFREE=5, NM_NSTRDUP=6, NM_XNSTRDUP=7, NM_NMEMDUP=8, NM_XNMEMDUP=9, NM_FORGET=10, NM_ADOPT=11, NM_ITREE=12, NM_TREE=13, NM_PTREE=14, NM_ANON=15 } method; void *addr; unsigned long length; char *reqfile; int reqline; char *reqfunc; char **backtrace; int n_backtrace; } *

variable_types: nleak int

variable_types: i int

user_defined_types: struct nm_userec { long when; enum nm_origin method; void *addr; unsigned long length; char *reqfile; int reqline; char *reqfunc; char **backtrace; int n_backtrace; }


decompiled_code:
_QWORD *ptree_createnocheck()
{
_QWORD *v0; // r12
__int64 v1; // rax

v0 = malloc(0x10uLL);
v1 = make_rb();
*v0 = v1;
v0[1] = v1;
if ( !v1 )
v0 = 0LL;
return v0;
}

original_code:
PTREE *ptree_createnocheck() {
 PTREE *t;
 t = malloc(sizeof(PTREE));
 t->node = t->root = make_rb();
 if (t->node)
  return t;
 else
  return ((void *)0);
}

canonical_original_code:
struct ptree_head *ptree_createnocheck() {
 struct ptree_head *t;
 t = malloc(sizeof(PTREE));
 t->node = t->root = make_rb();
 if (t->node)
  return t;
 else
  return ((void *)0);
}

variable_types: struct ptree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *

user_defined_types: struct ptree_head { struct rb_node *root; struct rb_node *node; }


decompiled_code:
_DWORD *nm_deactivate()
{
_DWORD *result; // rax
_DWORD *v1; // rdx
void **v2; // rbp
void **v3; // rdi

result = &nm_active;
nm_active = 0;
if ( nm_used )
{
v1 = (_DWORD *)*nm_used;
result = *(_DWORD **)*nm_used;
*(_QWORD *)(nm_used + 8LL) = result;
if ( v1 != result )
{
do
{
v2 = (void **)ptree_get();
ptree_rm(nm_used);
free(v2[4]);
free(v2[6]);
free(v2);
v3 = (void **)nm_used;
result = **(_DWORD ***)(nm_used + 8LL);
*(_QWORD *)(nm_used + 8LL) = result;
}
while ( result != *v3 );
}
}
return result;
}

canonical_decompiled_code:
_DWORD *func2()
{
_DWORD *result; // rax
_DWORD *v1; // rdx
void **v2; // rbp
void **v3; // rdi

result = &nm_active;
nm_active = 0;
if ( nm_used )
{
v1 = (_DWORD *)*nm_used;
result = *(_DWORD **)*nm_used;
*(_QWORD *)(nm_used + 8LL) = result;
if ( v1 != result )
{
do
{
v2 = (void **)ptree_get();
ptree_rm(nm_used);
free(v2[4]);
free(v2[6]);
free(v2);
v3 = (void **)nm_used;
result = **(_DWORD ***)(nm_used + 8LL);
*(_QWORD *)(nm_used + 8LL) = result;
}
while ( result != *v3 );
}
}
return result;
}

original_code:
void nm_deactivate()
{
     struct nm_userec *log;
     nm_active = 0;
     if (nm_used) {
   for((nm_used)->node = ((nm_used)->root->c.list.flink); (nm_used)->node != ((nm_used)->root); (nm_used)->node = ((nm_used)->node->c.list.flink)) {
        log = ptree_get(nm_used);
        ptree_rm(nm_used);
        free(log->reqfile);
        free(log->reqfunc);
        free(log);
   }
     }
}

user_defined_types: enum nm_origin { NM_NMALLOC=0, NM_XNMALLOC=1, NM_NREALLOC=2, NM_XNREALLOC=3, NM_NFREE=4, NM_XNFREE=5, NM_NSTRDUP=6, NM_XNSTRDUP=7, NM_NMEMDUP=8, NM_XNMEMDUP=9, NM_FORGET=10, NM_ADOPT=11, NM_ITREE=12, NM_TREE=13, NM_PTREE=14, NM_ANON=15 }


decompiled_code:
__int64 __fastcall nm_add(int a1, const void *a2, __int64 a3, const char *a4, unsigned int a5, const char *a6)
{
__int64 v9; // rbx
__int64 v10; // rax
_QWORD *v11; // r15
time_t v12; // rax
char *v13; // rax
char *v14; // rax
int v15; // eax

v9 = a5;
if ( nm_used )
{
v10 = ptree_find();
if ( v10 )
fprintf(
stderr,
"nm_add() allocation already in table\n asked - %s %p %lu %s:%d:%s\n exists - %s %p %lu %s:%d:%s (%ld)\n",
nm_names[a1],
a2,
a3,
a4,
v9,
a6,
nm_names[*(unsigned int *)(v10 + 8)],
*(const void **)(v10 + 16),
*(_QWORD *)(v10 + 24),
*(const char **)(v10 + 32),
*(unsigned int *)(v10 + 40),
*(const char **)(v10 + 48),
*(_QWORD *)v10);
}
else
{
nm_used = ptree_createnocheck();
atexit(nm_rpt);
}
v11 = malloc(0x48uLL);
v12 = time(0LL);
v11[2] = a2;
*v11 = v12;
v11[3] = a3;
*((_DWORD *)v11 + 2) = a1;
v13 = strdup(a4);
*((_DWORD *)v11 + 10) = v9;
v11[4] = v13;
v14 = strdup(a6);
v11[7] = 0LL;
v11[6] = v14;
*((_DWORD *)v11 + 16) = 0;
v15 = backtrace(&nm_backtrace, 100);
*((_DWORD *)v11 + 16) = v15;
v11[7] = backtrace_symbols(&nm_backtrace, v15);
return ptree_add(nm_used, a2, v11);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, const void *a2, __int64 a3, const char *a4, unsigned int a5, const char *a6)
{
__int64 v9; // rbx
__int64 v10; // rax
_QWORD *v11; // r15
time_t v12; // rax
char *v13; // rax
char *v14; // rax
int v15; // eax

v9 = a5;
if ( nm_used )
{
v10 = ptree_find();
if ( v10 )
fprintf(
stderr,
"nm_add() allocation already in table\n asked - %s %p %lu %s:%d:%s\n exists - %s %p %lu %s:%d:%s (%ld)\n",
nm_names[a1],
a2,
a3,
a4,
v9,
a6,
nm_names[*(unsigned int *)(v10 + 8)],
*(const void **)(v10 + 16),
*(_QWORD *)(v10 + 24),
*(const char **)(v10 + 32),
*(unsigned int *)(v10 + 40),
*(const char **)(v10 + 48),
*(_QWORD *)v10);
}
else
{
nm_used = func1();
atexit(nm_rpt);
}
v11 = malloc(0x48uLL);
v12 = time(0LL);
v11[2] = a2;
*v11 = v12;
v11[3] = a3;
*((_DWORD *)v11 + 2) = a1;
v13 = strdup(a4);
*((_DWORD *)v11 + 10) = v9;
v11[4] = v13;
v14 = strdup(a6);
v11[7] = 0LL;
v11[6] = v14;
*((_DWORD *)v11 + 16) = 0;
v15 = backtrace(&nm_backtrace, 100);
*((_DWORD *)v11 + 16) = v15;
v11[7] = backtrace_symbols(&nm_backtrace, v15);
return ptree_add(nm_used, a2, v11);
}

original_code:
void nm_add(enum nm_origin meth, void *aloc, size_t sz, char *rfile,
     int rline, const char *rfunc) {
     struct nm_userec *log;
     if ( nm_used ) {
          if ( (log = ptree_find(nm_used, aloc)) != (void *) ((void *)0))
        fprintf(stderr, "nm_add() allocation already in table\n"
         "   asked - %s %p %lu %s:%d:%s\n"
         "  exists - %s %p %lu %s:%d:%s (%ld)\n",
         nm_names[meth], aloc, (unsigned long) sz,
           rfile, rline, rfunc,
         nm_names[log->method], log->addr,
           (unsigned long) log->length, log->reqfile,
           log->reqline, log->reqfunc, (long) log->when);
     } else {
          nm_used = ptree_createnocheck();
   atexit(nm_rpt);
     }
     log = malloc(sizeof(struct nm_userec));
     log->when = time(((void *)0));
     log->method = meth;
     log->addr = aloc;
     log->length = sz;
     log->reqfile = strdup(rfile);
     log->reqline = rline;
     log->reqfunc = strdup(rfunc);
     log->backtrace = ((void *)0);
     log->n_backtrace = 0;
     log->n_backtrace = backtrace(nm_backtrace, 100);
     log->backtrace = backtrace_symbols(nm_backtrace, log->n_backtrace);
     ptree_add(nm_used, aloc, log);
}

canonical_original_code:
void nm_add(enum nm_origin meth, void *aloc, unsigned long sz, char *rfile, int rline, char *rfunc) {
     struct nm_userec *log;
     if ( nm_used ) {
          if ( (log = ptree_find(nm_used, aloc)) != (void *) ((void *)0))
        fprintf(stderr, "nm_add() allocation already in table\n"
         "   asked - %s %p %lu %s:%d:%s\n"
         "  exists - %s %p %lu %s:%d:%s (%ld)\n",
         nm_names[meth], aloc, (unsigned long) sz,
           rfile, rline, rfunc,
         nm_names[log->method], log->addr,
           (unsigned long) log->length, log->reqfile,
           log->reqline, log->reqfunc, (long) log->when);
     } else {
          nm_used = ptree_createnocheck();
   atexit(nm_rpt);
     }
     log = malloc(sizeof(struct nm_userec));
     log->when = time(((void *)0));
     log->method = meth;
     log->addr = aloc;
     log->length = sz;
     log->reqfile = strdup(rfile);
     log->reqline = rline;
     log->reqfunc = strdup(rfunc);
     log->backtrace = ((void *)0);
     log->n_backtrace = 0;
     log->n_backtrace = backtrace(nm_backtrace, 100);
     log->backtrace = backtrace_symbols(nm_backtrace, log->n_backtrace);
     ptree_add(nm_used, aloc, log);
}

variable_types: enum nm_origin { NM_NMALLOC=0, NM_XNMALLOC=1, NM_NREALLOC=2, NM_XNREALLOC=3, NM_NFREE=4, NM_XNFREE=5, NM_NSTRDUP=6, NM_XNSTRDUP=7, NM_NMEMDUP=8, NM_XNMEMDUP=9, NM_FORGET=10, NM_ADOPT=11, NM_ITREE=12, NM_TREE=13, NM_PTREE=14, NM_ANON=15 }

variable_types:
aloc
void *

variable_types:
sz
unsigned long

variable_types:
rfile
char *

variable_types: rline int

variable_types:
rfunc
char *


decompiled_code:
void __fastcall nm_rm(int a1, __int64 a2, __int64 a3, unsigned int a4, __int64 a5)
{
__int64 v8; // rbp
void *v9; // rdi

if ( !nm_used )
{
fprintf(stderr, "nm_rm() table does not exist - %s %p %s:%d:%s\n", nm_names[a1], a2, a3, a4, a5);
goto LABEL_7;
}
v8 = ptree_find();
if ( !v8 )
{
fprintf(stderr, "nm_rm() allocation not in table - %s %p %s:%d:%s\n", nm_names[a1], a2, a3, a4, a5);
LABEL_7:
abort();
}
ptree_rm(nm_used);
free(*(void **)(v8 + 32));
free(*(void **)(v8 + 48));
v9 = *(void **)(v8 + 56);
if ( v9 )
free(v9);
free((void *)v8);
}

canonical_decompiled_code:
void __fastcall func4(int a1, __int64 a2, __int64 a3, unsigned int a4, __int64 a5)
{
__int64 v8; // rbp
void *v9; // rdi

if ( !nm_used )
{
fprintf(stderr, "nm_rm() table does not exist - %s %p %s:%d:%s\n", nm_names[a1], a2, a3, a4, a5);
goto LABEL_7;
}
v8 = ptree_find();
if ( !v8 )
{
fprintf(stderr, "nm_rm() allocation not in table - %s %p %s:%d:%s\n", nm_names[a1], a2, a3, a4, a5);
LABEL_7:
abort();
}
ptree_rm(nm_used);
free(*(void **)(v8 + 32));
free(*(void **)(v8 + 48));
v9 = *(void **)(v8 + 56);
if ( v9 )
free(v9);
free((void *)v8);
}

original_code:
void nm_rm(enum nm_origin meth, void *aloc, char *rfile, int rline,
    const char *rfunc) {
     struct nm_userec *log;
     if ( ! nm_used ) {
          fprintf(stderr, "nm_rm() table does not exist - %s %p %s:%d:%s\n",
    nm_names[meth], aloc, rfile, rline, rfunc);
   abort();
     }
     if ( (log = ptree_find(nm_used, aloc)) == (void *) ((void *)0) ) {
          fprintf(stderr, "nm_rm() allocation not in table - %s %p %s:%d:%s\n",
    nm_names[meth], aloc, rfile, rline, rfunc);
   abort();
     }
     ptree_rm(nm_used);
     free(log->reqfile);
     free(log->reqfunc);
     if (log->backtrace)
          free(log->backtrace);
     free(log);
}

canonical_original_code:
void nm_rm(enum nm_origin meth, void *aloc, char *rfile, int rline, char *rfunc) {
     struct nm_userec *log;
     if ( ! nm_used ) {
          fprintf(stderr, "nm_rm() table does not exist - %s %p %s:%d:%s\n",
    nm_names[meth], aloc, rfile, rline, rfunc);
   abort();
     }
     if ( (log = ptree_find(nm_used, aloc)) == (void *) ((void *)0) ) {
          fprintf(stderr, "nm_rm() allocation not in table - %s %p %s:%d:%s\n",
    nm_names[meth], aloc, rfile, rline, rfunc);
   abort();
     }
     ptree_rm(nm_used);
     free(log->reqfile);
     free(log->reqfunc);
     if (log->backtrace)
          free(log->backtrace);
     free(log);
}


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

result = (unsigned int)nm_active;
if ( nm_active )
{
if ( nm_used )
{
result = ptree_find(nm_used, a1) != 0;
}
else
{
fwrite("nm_isalloc() no request for memory ever made\n", 1uLL, 0x2DuLL, stderr);
result = 0LL;
}
}
return result;
}

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

result = (unsigned int)nm_active;
if ( nm_active )
{
if ( nm_used )
{
result = ptree_find(nm_used, a1) != 0;
}
else
{
fwrite("nm_isalloc() no request for memory ever made\n", 1uLL, 0x2DuLL, stderr);
result = 0LL;
}
}
return result;
}

original_code:
int nm_isalloc(void *aloc)
{
     if ( ! nm_active )
   return 0;
     if ( ! nm_used ) {
          fprintf(stderr, "nm_isalloc() no request for memory ever made\n");
   return 0;
     }
     if (ptree_find(nm_used, aloc) == (void *) ((void *)0))
   return 0;
     else
   return 1;
}


decompiled_code:
void *__fastcall nm_nmalloc(size_t size, const char *a2, __int64 a3, const char *a4)
{
unsigned int v5; // ebx
void *result; // rax
void *v7; // [rsp+8h] [rbp-30h]

v5 = a3;
if ( !size )
elog_fdie(6LL, "iiab/nmalloc.c", 207LL, "nm_nmalloc", "n <= 0 at %s:%d:%s", a2, a3, a4);
result = malloc(size);
if ( nm_active )
{
v7 = result;
nm_add(0, result, size, a2, v5, a4);
result = v7;
}
return result;
}

canonical_decompiled_code:
void *__fastcall func6(size_t size, const char *a2, __int64 a3, const char *a4)
{
unsigned int v5; // ebx
void *result; // rax
void *v7; // [rsp+8h] [rbp-30h]

v5 = a3;
if ( !size )
elog_fdie(6LL, "iiab/nmalloc.c", 207LL, "nm_nmalloc", "n <= 0 at %s:%d:%s", a2, a3, a4);
result = malloc(size);
if ( nm_active )
{
v7 = result;
func3(0, result, size, a2, v5, a4);
result = v7;
}
return result;
}

original_code:
void *nm_nmalloc(size_t n, char *rfile, int rline, const char *rfunc) {
 char *q;
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",207,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 q = malloc(n);
 if (nm_active)
      nm_add(NM_NMALLOC, q, n, rfile, rline, rfunc);
 return q;
}

canonical_original_code:
void *nm_nmalloc(unsigned long n, char *rfile, int rline, char *rfunc) {
 char *q;
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",207,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 q = malloc(n);
 if (nm_active)
      nm_add(NM_NMALLOC, q, n, rfile, rline, rfunc);
 return q;
}

variable_types:
n
unsigned long

variable_types:
q
char *


decompiled_code:
void *__fastcall nm_xnmalloc(size_t size, const char *a2, __int64 a3, const char *a4)
{
__int64 v5; // rbx
void *v6; // r13

v5 = (unsigned int)a3;
if ( !size )
elog_fdie(6LL, "iiab/nmalloc.c", 225LL, "nm_xnmalloc", "n <= 0 at %s:%d:%s", a2, a3, a4);
v6 = malloc(size);
if ( !v6 )
elog_fdie(6LL, "iiab/nmalloc.c", 230LL, "nm_xnmalloc", "malloc failed (%d) at %s:%d:%s", size, a2, v5, a4);
if ( nm_active )
nm_add(1, v6, size, a2, v5, a4);
return v6;
}

canonical_decompiled_code:
void *__fastcall func7(size_t size, const char *a2, __int64 a3, const char *a4)
{
__int64 v5; // rbx
void *v6; // r13

v5 = (unsigned int)a3;
if ( !size )
elog_fdie(6LL, "iiab/nmalloc.c", 225LL, "nm_xnmalloc", "n <= 0 at %s:%d:%s", a2, a3, a4);
v6 = malloc(size);
if ( !v6 )
elog_fdie(6LL, "iiab/nmalloc.c", 230LL, "nm_xnmalloc", "malloc failed (%d) at %s:%d:%s", size, a2, v5, a4);
if ( nm_active )
func3(1, v6, size, a2, v5, a4);
return v6;
}

original_code:
void *nm_xnmalloc(size_t n, char *rfile, int rline, const char *rfunc) {
 char *q;
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",225,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 q = malloc(n);
 if (q == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",230,__PRETTY_FUNCTION__,"malloc failed (%d) at %s:%d:%s", n, rfile, rline, rfunc);;
 if (nm_active)
      nm_add(NM_XNMALLOC, q, n, rfile, rline, rfunc);
 return q;
}

canonical_original_code:
void *nm_xnmalloc(unsigned long n, char *rfile, int rline, char *rfunc) {
 char *q;
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",225,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 q = malloc(n);
 if (q == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",230,__PRETTY_FUNCTION__,"malloc failed (%d) at %s:%d:%s", n, rfile, rline, rfunc);;
 if (nm_active)
      nm_add(NM_XNMALLOC, q, n, rfile, rline, rfunc);
 return q;
}


decompiled_code:
void *__fastcall nm_nrealloc(void *ptr, size_t size, const char *a3, __int64 a4, const char *a5)
{
unsigned int v7; // ebx
int v8; // eax
void *result; // rax
void *v10; // [rsp+8h] [rbp-40h]

v7 = a4;
if ( size )
{
v8 = nm_active;
if ( ptr )
goto LABEL_3;
LABEL_8:
result = malloc(size);
if ( !nm_active )
return result;
LABEL_9:
v10 = result;
nm_add(2, result, size, a3, v7, a5);
return v10;
}
elog_fdie(6LL, "iiab/nmalloc.c", 247LL, "nm_nrealloc", "n <= 0 at %s:%d:%s", a3, a4, a5);
v8 = nm_active;
if ( !ptr )
goto LABEL_8;
LABEL_3:
if ( v8 )
nm_rm(2, (__int64)ptr, (__int64)a3, v7, (__int64)a5);
result = realloc(ptr, size);
if ( nm_active )
goto LABEL_9;
return result;
}

canonical_decompiled_code:
void *__fastcall func8(void *ptr, size_t size, const char *a3, __int64 a4, const char *a5)
{
unsigned int v7; // ebx
int v8; // eax
void *result; // rax
void *v10; // [rsp+8h] [rbp-40h]

v7 = a4;
if ( size )
{
v8 = nm_active;
if ( ptr )
goto LABEL_3;
LABEL_8:
result = malloc(size);
if ( !nm_active )
return result;
LABEL_9:
v10 = result;
func3(2, result, size, a3, v7, a5);
return v10;
}
elog_fdie(6LL, "iiab/nmalloc.c", 247LL, "nm_nrealloc", "n <= 0 at %s:%d:%s", a3, a4, a5);
v8 = nm_active;
if ( !ptr )
goto LABEL_8;
LABEL_3:
if ( v8 )
func4(2, (__int64)ptr, (__int64)a3, v7, (__int64)a5);
result = realloc(ptr, size);
if ( nm_active )
goto LABEL_9;
return result;
}

original_code:
void *nm_nrealloc(void *p, size_t n, char *rfile, int rline,
    const char *rfunc) {
 char *q;
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",247,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 if (p == ((void *)0)) {
  q = malloc(n);
 } else {
      if (nm_active)
    nm_rm(NM_NREALLOC, p, rfile, rline, rfunc);
      q = realloc(p, n);
 }
 if (nm_active)
      nm_add(NM_NREALLOC, q, n, rfile, rline, rfunc);
 return q;
}

canonical_original_code:
void *nm_nrealloc(void *p, unsigned long n, char *rfile, int rline, char *rfunc) {
 char *q;
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",247,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 if (p == ((void *)0)) {
  q = malloc(n);
 } else {
      if (nm_active)
    nm_rm(NM_NREALLOC, p, rfile, rline, rfunc);
      q = realloc(p, n);
 }
 if (nm_active)
      nm_add(NM_NREALLOC, q, n, rfile, rline, rfunc);
 return q;
}

variable_types:
p
void *


decompiled_code:
void *__fastcall nm_xnrealloc(void *ptr, size_t size, const char *a3, __int64 a4, const char *a5)
{
__int64 v7; // rbx
void *v8; // r13

v7 = (unsigned int)a4;
if ( !size )
{
elog_fdie(6LL, "iiab/nmalloc.c", 274LL, "nm_xnrealloc", "n <= 0 at %s:%d:%s", a3, a4, a5);
if ( ptr )
goto LABEL_3;
LABEL_12:
v8 = malloc(size);
goto LABEL_6;
}
if ( !ptr )
goto LABEL_12;
LABEL_3:
if ( nm_active )
nm_rm(2, (__int64)ptr, (__int64)a3, v7, (__int64)a5);
v8 = realloc(ptr, size);
LABEL_6:
if ( !v8 )
elog_fdie(
6LL,
"iiab/nmalloc.c",
287LL,
"nm_xnrealloc",
"realloc failed (%d -> %d) at %s:%d:%s",
ptr,
size,
a3,
v7,
a5);
if ( nm_active )
nm_add(3, v8, size, a3, v7, a5);
return v8;
}

canonical_decompiled_code:
void *__fastcall func9(void *ptr, size_t size, const char *a3, __int64 a4, const char *a5)
{
__int64 v7; // rbx
void *v8; // r13

v7 = (unsigned int)a4;
if ( !size )
{
elog_fdie(6LL, "iiab/nmalloc.c", 274LL, "nm_xnrealloc", "n <= 0 at %s:%d:%s", a3, a4, a5);
if ( ptr )
goto LABEL_3;
LABEL_12:
v8 = malloc(size);
goto LABEL_6;
}
if ( !ptr )
goto LABEL_12;
LABEL_3:
if ( nm_active )
func4(2, (__int64)ptr, (__int64)a3, v7, (__int64)a5);
v8 = realloc(ptr, size);
LABEL_6:
if ( !v8 )
elog_fdie(
6LL,
"iiab/nmalloc.c",
287LL,
"nm_xnrealloc",
"realloc failed (%d -> %d) at %s:%d:%s",
ptr,
size,
a3,
v7,
a5);
if ( nm_active )
func3(3, v8, size, a3, v7, a5);
return v8;
}

original_code:
void *nm_xnrealloc(void *p, size_t n, char *rfile, int rline,
     const char *rfunc) {
 char *q;
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",274,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 if (p == ((void *)0)) {
  q = malloc(n);
 } else {
      if (nm_active)
    nm_rm(NM_NREALLOC, p, rfile, rline, rfunc);
      q = realloc(p, n);
 }
 if (q == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",287,__PRETTY_FUNCTION__,"realloc failed (%d -> %d) at %s:%d:%s", p, n, rfile, rline, rfunc);
 if (nm_active)
      nm_add(NM_XNREALLOC, q, n, rfile, rline, rfunc);
 return q;
}

canonical_original_code:
void *nm_xnrealloc(void *p, unsigned long n, char *rfile, int rline, char *rfunc) {
 char *q;
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",274,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 if (p == ((void *)0)) {
  q = malloc(n);
 } else {
      if (nm_active)
    nm_rm(NM_NREALLOC, p, rfile, rline, rfunc);
      q = realloc(p, n);
 }
 if (q == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",287,__PRETTY_FUNCTION__,"realloc failed (%d -> %d) at %s:%d:%s", p, n, rfile, rline, rfunc);
 if (nm_active)
      nm_add(NM_XNREALLOC, q, n, rfile, rline, rfunc);
 return q;
}


decompiled_code:
void __fastcall nm_nfree(void *ptr, __int64 a2, unsigned int a3, __int64 a4)
{
if ( ptr )
{
if ( nm_active )
nm_rm(4, (__int64)ptr, a2, a3, a4);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func10(void *ptr, __int64 a2, unsigned int a3, __int64 a4)
{
if ( ptr )
{
if ( nm_active )
func4(4, (__int64)ptr, a2, a3, a4);
free(ptr);
}
}

original_code:
void nm_nfree(void *p, char *rfile, int rline, const char *rfunc) {
 if (p == ((void *)0))
      return;
 if (nm_active)
      nm_rm(NM_NFREE, p, rfile, rline, rfunc);
 free(p);
}

canonical_original_code:
void nm_nfree(void *p, char *rfile, int rline, char *rfunc) {
 if (p == ((void *)0))
      return;
 if (nm_active)
      nm_rm(NM_NFREE, p, rfile, rline, rfunc);
 free(p);
}


decompiled_code:
void __fastcall nm_xnfree(void *ptr, __int64 a2, unsigned int a3, __int64 a4)
{
if ( ptr )
{
if ( nm_active )
nm_rm(5, (__int64)ptr, a2, a3, a4);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func11(void *ptr, __int64 a2, unsigned int a3, __int64 a4)
{
if ( ptr )
{
if ( nm_active )
func4(5, (__int64)ptr, a2, a3, a4);
free(ptr);
}
}

original_code:
void nm_xnfree(void *p, char *rfile, int rline, const char *rfunc) {
     if (p == ((void *)0))
          return;
     if (nm_active)
   nm_rm(NM_XNFREE, p, rfile, rline, rfunc);
     free(p);
}

canonical_original_code:
void nm_xnfree(void *p, char *rfile, int rline, char *rfunc) {
     if (p == ((void *)0))
          return;
     if (nm_active)
   nm_rm(NM_XNFREE, p, rfile, rline, rfunc);
     free(p);
}


decompiled_code:
char *__fastcall nm_nstrdup(char *s, const char *a2, __int64 a3, const char *a4)
{
unsigned int v5; // ebx
char *v6; // r12
size_t v8; // rax

v5 = a3;
if ( !s )
elog_fdie(6LL, "iiab/nmalloc.c", 330LL, "nm_nstrdup", "s == NULL at %s:%d:%s", a2, a3, a4);
v6 = strdup(s);
if ( nm_active )
{
v8 = strlen(s);
nm_add(6, v6, v8 + 1, a2, v5, a4);
}
return v6;
}

canonical_decompiled_code:
char *__fastcall func12(char *s, const char *a2, __int64 a3, const char *a4)
{
unsigned int v5; // ebx
char *v6; // r12
size_t v8; // rax

v5 = a3;
if ( !s )
elog_fdie(6LL, "iiab/nmalloc.c", 330LL, "nm_nstrdup", "s == NULL at %s:%d:%s", a2, a3, a4);
v6 = strdup(s);
if ( nm_active )
{
v8 = strlen(s);
func3(6, v6, v8 + 1, a2, v5, a4);
}
return v6;
}

original_code:
char *nm_nstrdup(const char *s, char *rfile, int rline, const char *rfunc) {
 char *p;
 if (s == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",330,__PRETTY_FUNCTION__,"s == NULL at %s:%d:%s", rfile, rline, rfunc);
 p = strdup(s);
 if (nm_active)
      nm_add(NM_NSTRDUP, p, strlen(s)+1, rfile, rline, rfunc);
 return p;
}

canonical_original_code:
char *nm_nstrdup(char *s, char *rfile, int rline, char *rfunc) {
 char *p;
 if (s == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",330,__PRETTY_FUNCTION__,"s == NULL at %s:%d:%s", rfile, rline, rfunc);
 p = strdup(s);
 if (nm_active)
      nm_add(NM_NSTRDUP, p, strlen(s)+1, rfile, rline, rfunc);
 return p;
}

variable_types:
s
char *

variable_types:
p
char *

return_type: char *


decompiled_code:
char *__fastcall nm_nstrndup(char *src, size_t size, const char *a3, __int64 a4, const char *a5)
{
char *v5; // rax

if ( !src )
elog_fdie(6LL, "iiab/nmalloc.c", 348LL, "nm_nstrndup", "s == NULL at %s:%d:%s", a3, a4, a5);
v5 = (char *)nm_nmalloc(size, "iiab/nmalloc.c", 351LL, "nm_nstrndup");
return strncpy(v5, src, size);
}

canonical_decompiled_code:
char *__fastcall func13(char *src, size_t size, const char *a3, __int64 a4, const char *a5)
{
char *v5; // rax

if ( !src )
elog_fdie(6LL, "iiab/nmalloc.c", 348LL, "nm_nstrndup", "s == NULL at %s:%d:%s", a3, a4, a5);
v5 = (char *)func6(size, "iiab/nmalloc.c", 351LL, "nm_nstrndup");
return strncpy(v5, src, size);
}

original_code:
char *nm_nstrndup(const char *s, size_t max, char *rfile, int rline,
    const char *rfunc) {
 char *p;
 if (s == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",348,__PRETTY_FUNCTION__,"s == NULL at %s:%d:%s", rfile, rline, rfunc);
 p = nm_nmalloc(max,"iiab/nmalloc.c",351,__PRETTY_FUNCTION__);
 strncpy(p, s, max);
 return p;
}

canonical_original_code:
char *nm_nstrndup(char *s, unsigned long max, char *rfile, int rline, char *rfunc) {
 char *p;
 if (s == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",348,__PRETTY_FUNCTION__,"s == NULL at %s:%d:%s", rfile, rline, rfunc);
 p = nm_nmalloc(max,"iiab/nmalloc.c",351,__PRETTY_FUNCTION__);
 strncpy(p, s, max);
 return p;
}

variable_types:
max
unsigned long


decompiled_code:
char *__fastcall nm_xnstrndup(char *src, size_t size, const char *a3, __int64 a4, const char *a5)
{
char *v5; // rax

if ( !src )
elog_fdie(6LL, "iiab/nmalloc.c", 363LL, "nm_xnstrndup", "s == NULL at %s:%d:%s", a3, a4, a5);
v5 = (char *)nm_xnmalloc(size, "iiab/nmalloc.c", 366LL, "nm_xnstrndup");
return strncpy(v5, src, size);
}

canonical_decompiled_code:
char *__fastcall func14(char *src, size_t size, const char *a3, __int64 a4, const char *a5)
{
char *v5; // rax

if ( !src )
elog_fdie(6LL, "iiab/nmalloc.c", 363LL, "nm_xnstrndup", "s == NULL at %s:%d:%s", a3, a4, a5);
v5 = (char *)func7(size, "iiab/nmalloc.c", 366LL, "nm_xnstrndup");
return strncpy(v5, src, size);
}

original_code:
char *nm_xnstrndup(const char *s, size_t max, char *rfile, int rline,
     const char *rfunc) {
 char *p;
 if (s == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",363,__PRETTY_FUNCTION__,"s == NULL at %s:%d:%s", rfile, rline, rfunc);
 p = nm_xnmalloc(max,"iiab/nmalloc.c",366,__PRETTY_FUNCTION__);
 strncpy(p, s, max);
 return p;
}

canonical_original_code:
char *nm_xnstrndup(char *s, unsigned long max, char *rfile, int rline, char *rfunc) {
 char *p;
 if (s == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",363,__PRETTY_FUNCTION__,"s == NULL at %s:%d:%s", rfile, rline, rfunc);
 p = nm_xnmalloc(max,"iiab/nmalloc.c",366,__PRETTY_FUNCTION__);
 strncpy(p, s, max);
 return p;
}


decompiled_code:
char *__fastcall nm_xnstrdup(char *s, const char *a2, __int64 a3, const char *a4)
{
__int64 v5; // rbx
char *v6; // r12
size_t v8; // rax

v5 = (unsigned int)a3;
if ( !s )
elog_fdie(6LL, "iiab/nmalloc.c", 377LL, "nm_xnstrdup", "s == NULL at %s:%d:%s", a2, a3, a4);
v6 = strdup(s);
if ( !v6 )
elog_fdie(6LL, "iiab/nmalloc.c", 382LL, "nm_xnstrdup", "strdup failed at %s:%d:%s", a2, v5, a4);
if ( nm_active )
{
v8 = strlen(s);
nm_add(7, v6, v8 + 1, a2, v5, a4);
}
return v6;
}

canonical_decompiled_code:
char *__fastcall func15(char *s, const char *a2, __int64 a3, const char *a4)
{
__int64 v5; // rbx
char *v6; // r12
size_t v8; // rax

v5 = (unsigned int)a3;
if ( !s )
elog_fdie(6LL, "iiab/nmalloc.c", 377LL, "nm_xnstrdup", "s == NULL at %s:%d:%s", a2, a3, a4);
v6 = strdup(s);
if ( !v6 )
elog_fdie(6LL, "iiab/nmalloc.c", 382LL, "nm_xnstrdup", "strdup failed at %s:%d:%s", a2, v5, a4);
if ( nm_active )
{
v8 = strlen(s);
func3(7, v6, v8 + 1, a2, v5, a4);
}
return v6;
}

original_code:
char *nm_xnstrdup(const char *s, char *rfile, int rline, const char *rfunc) {
 char *p;
 if (s == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",377,__PRETTY_FUNCTION__,"s == NULL at %s:%d:%s", rfile, rline, rfunc);
 p = strdup(s);
 if (p == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",382,__PRETTY_FUNCTION__,"strdup failed at %s:%d:%s", rfile, rline, rfunc);
 if (nm_active)
      nm_add(NM_XNSTRDUP, p, strlen(s)+1, rfile, rline, rfunc);
 return p;
}

canonical_original_code:
char *nm_xnstrdup(char *s, char *rfile, int rline, char *rfunc) {
 char *p;
 if (s == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",377,__PRETTY_FUNCTION__,"s == NULL at %s:%d:%s", rfile, rline, rfunc);
 p = strdup(s);
 if (p == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",382,__PRETTY_FUNCTION__,"strdup failed at %s:%d:%s", rfile, rline, rfunc);
 if (nm_active)
      nm_add(NM_XNSTRDUP, p, strlen(s)+1, rfile, rline, rfunc);
 return p;
}


decompiled_code:
const void *__fastcall nm_nmemdup(void *src, size_t n, const char *a3, __int64 a4, const char *a5)
{
__int64 v7; // rbx
void *v8; // rax
const void *v9; // r12

v7 = (unsigned int)a4;
if ( !src )
elog_fdie(6LL, "iiab/nmalloc.c", 398LL, "nm_nmemdup", "p == NULL at %s:%d:%s", a3, a4, a5);
if ( !n )
elog_fdie(6LL, "iiab/nmalloc.c", 402LL, "nm_nmemdup", "n <= 0 at %s:%d:%s", a3, v7, a5);
v8 = malloc(n);
v9 = v8;
if ( v8 )
memcpy(v8, src, n);
if ( nm_active )
nm_add(8, v9, n, a3, v7, a5);
return v9;
}

canonical_decompiled_code:
const void *__fastcall func16(void *src, size_t n, const char *a3, __int64 a4, const char *a5)
{
__int64 v7; // rbx
void *v8; // rax
const void *v9; // r12

v7 = (unsigned int)a4;
if ( !src )
elog_fdie(6LL, "iiab/nmalloc.c", 398LL, "nm_nmemdup", "p == NULL at %s:%d:%s", a3, a4, a5);
if ( !n )
elog_fdie(6LL, "iiab/nmalloc.c", 402LL, "nm_nmemdup", "n <= 0 at %s:%d:%s", a3, v7, a5);
v8 = malloc(n);
v9 = v8;
if ( v8 )
memcpy(v8, src, n);
if ( nm_active )
func3(8, v9, n, a3, v7, a5);
return v9;
}

original_code:
void *nm_nmemdup(const void *p, size_t n, char *rfile, int rline,
   const char *rfunc) {
 void *q;
 if (p == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",398,__PRETTY_FUNCTION__,"p == NULL at %s:%d:%s", rfile, rline, rfunc);
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",402,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 q = malloc(n);
 if (q != ((void *)0))
  memcpy(q, p, n);
 if (nm_active)
      nm_add(NM_NMEMDUP, q, n, rfile, rline, rfunc);
 return q;
}

canonical_original_code:
void *nm_nmemdup(void *p, unsigned long n, char *rfile, int rline, char *rfunc) {
 void *q;
 if (p == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",398,__PRETTY_FUNCTION__,"p == NULL at %s:%d:%s", rfile, rline, rfunc);
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",402,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 q = malloc(n);
 if (q != ((void *)0))
  memcpy(q, p, n);
 if (nm_active)
      nm_add(NM_NMEMDUP, q, n, rfile, rline, rfunc);
 return q;
}

variable_types:
q
void *


decompiled_code:
const void *__fastcall nm_xnmemdup(void *src, size_t n, const char *a3, __int64 a4, const char *a5)
{
__int64 v7; // rbx
void *v8; // rax
const void *v9; // r12

v7 = (unsigned int)a4;
if ( !src )
elog_fdie(6LL, "iiab/nmalloc.c", 421LL, "nm_xnmemdup", "p == NULL at %s:%d:%s", a3, a4, a5);
if ( !n )
elog_fdie(6LL, "iiab/nmalloc.c", 424LL, "nm_xnmemdup", "n <= 0 at %s:%d:%s", a3, v7, a5);
v8 = malloc(n);
v9 = v8;
if ( v8 )
memcpy(v8, src, n);
else
elog_fdie(6LL, "iiab/nmalloc.c", 429LL, "nm_xnmemdup", "malloc failed");
if ( nm_active )
nm_add(9, v9, n, a3, v7, a5);
return v9;
}

canonical_decompiled_code:
const void *__fastcall func17(void *src, size_t n, const char *a3, __int64 a4, const char *a5)
{
__int64 v7; // rbx
void *v8; // rax
const void *v9; // r12

v7 = (unsigned int)a4;
if ( !src )
elog_fdie(6LL, "iiab/nmalloc.c", 421LL, "nm_xnmemdup", "p == NULL at %s:%d:%s", a3, a4, a5);
if ( !n )
elog_fdie(6LL, "iiab/nmalloc.c", 424LL, "nm_xnmemdup", "n <= 0 at %s:%d:%s", a3, v7, a5);
v8 = malloc(n);
v9 = v8;
if ( v8 )
memcpy(v8, src, n);
else
elog_fdie(6LL, "iiab/nmalloc.c", 429LL, "nm_xnmemdup", "malloc failed");
if ( nm_active )
func3(9, v9, n, a3, v7, a5);
return v9;
}

original_code:
void *nm_xnmemdup(const void *p, size_t n, char *rfile, int rline,
    const char *rfunc) {
 char *q;
 if (p == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",421,__PRETTY_FUNCTION__,"p == NULL at %s:%d:%s", rfile, rline, rfunc);
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",424,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 q = malloc(n);
 if (q == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",429,__PRETTY_FUNCTION__,"malloc failed");
 else
  memcpy(q, p, n);
 if (nm_active)
      nm_add(NM_XNMEMDUP, q, n, rfile, rline, rfunc);
 return q;
}

canonical_original_code:
void *nm_xnmemdup(void *p, unsigned long n, char *rfile, int rline, char *rfunc) {
 char *q;
 if (p == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",421,__PRETTY_FUNCTION__,"p == NULL at %s:%d:%s", rfile, rline, rfunc);
 if (n <= 0)
      elog_fdie(FATAL,"iiab/nmalloc.c",424,__PRETTY_FUNCTION__,"n <= 0 at %s:%d:%s", rfile, rline, rfunc);
 q = malloc(n);
 if (q == ((void *)0))
      elog_fdie(FATAL,"iiab/nmalloc.c",429,__PRETTY_FUNCTION__,"malloc failed");
 else
  memcpy(q, p, n);
 if (nm_active)
      nm_add(NM_XNMEMDUP, q, n, rfile, rline, rfunc);
 return q;
}