decompiled_code:
void *__fastcall memleak_alloc(size_t n, __int64 a2, __int64 a3)
{
void *v4; // rax
void *v5; // rbx

pthread_spin_lock(&lock);
v4 = malloc(n);
v5 = v4;
if ( v4 && start_sw )
memleak_add_to_index(v4, n, a2, a3, 0xFFu);
pthread_spin_unlock(&lock);
return v5;
}

canonical_decompiled_code:
void *__fastcall func5(size_t n, __int64 a2, __int64 a3)
{
void *v4; // rax
void *v5; // rbx

pthread_spin_lock(&lock);
v4 = malloc(n);
v5 = v4;
if ( v4 && start_sw )
func4(v4, n, a2, a3, 0xFFu);
pthread_spin_unlock(&lock);
return v5;
}

original_code:
void * memleak_alloc(size_t size, char *file, size_t line)
{
    pthread_spin_lock(&lock);
    void *addr = malloc(size);
    if (addr && start_sw) {
        _memleak_add_to_index(addr, size, file, line, (0xff));
    }
    pthread_spin_unlock(&lock);
    return addr;
}

canonical_original_code:
void *memleak_alloc(unsigned long size, char *file, unsigned long line)
{
    pthread_spin_lock(&lock);
    void *addr = malloc(size);
    if (addr && start_sw) {
        _memleak_add_to_index(addr, size, file, line, (0xff));
    }
    pthread_spin_unlock(&lock);
    return addr;
}

variable_types:
size
unsigned long

variable_types:
file
char *

variable_types:
line
unsigned long

variable_types:
addr
void *


decompiled_code:
void *__fastcall memleak_calloc(size_t nmemb, size_t n, __int64 a3, __int64 a4)
{
void *v6; // rax
void *v7; // rbx

pthread_spin_lock(&lock);
v6 = calloc(nmemb, n);
v7 = v6;
if ( v6 && start_sw )
memleak_add_to_index(v6, n, a3, a4, 0);
pthread_spin_unlock(&lock);
return v7;
}

canonical_decompiled_code:
void *__fastcall func6(size_t nmemb, size_t n, __int64 a3, __int64 a4)
{
void *v6; // rax
void *v7; // rbx

pthread_spin_lock(&lock);
v6 = calloc(nmemb, n);
v7 = v6;
if ( v6 && start_sw )
func4(v6, n, a3, a4, 0);
pthread_spin_unlock(&lock);
return v7;
}

original_code:
void * memleak_calloc(size_t nmemb, size_t size, char *file, size_t line)
{
    pthread_spin_lock(&lock);
    void *addr = calloc(nmemb, size);
    if (addr && start_sw) {
        _memleak_add_to_index(addr, size, file, line, 0x0);
    }
    pthread_spin_unlock(&lock);
    return addr;
}

canonical_original_code:
void *memleak_calloc(unsigned long nmemb, unsigned long size, char *file, unsigned long line)
{
    pthread_spin_lock(&lock);
    void *addr = calloc(nmemb, size);
    if (addr && start_sw) {
        _memleak_add_to_index(addr, size, file, line, 0x0);
    }
    pthread_spin_unlock(&lock);
    return addr;
}

variable_types:
nmemb
unsigned long

return_type: void *


decompiled_code:
__int64 __fastcall memleak_posix_memalign(void **memptr, size_t alignment, size_t n, __int64 a4, __int64 a5)
{
unsigned int v8; // ebx
void *v9; // rdi

pthread_spin_lock(&lock);
v8 = posix_memalign(memptr, alignment, n);
if ( !v8 )
{
v9 = *memptr;
if ( start_sw )
memleak_add_to_index(v9, n, a4, a5, 0xFFu);
}
pthread_spin_unlock(&lock);
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func7(void **memptr, size_t alignment, size_t n, __int64 a4, __int64 a5)
{
unsigned int v8; // ebx
void *v9; // rdi

pthread_spin_lock(&lock);
v8 = posix_memalign(memptr, alignment, n);
if ( !v8 )
{
v9 = *memptr;
if ( start_sw )
func4(v9, n, a4, a5, 0xFFu);
}
pthread_spin_unlock(&lock);
return v8;
}

original_code:
int memleak_posix_memalign(void **memptr, size_t alignment, size_t size, char *file, size_t line)
{
    pthread_spin_lock(&lock);
    int ret = posix_memalign(memptr, alignment, size);
    if (ret==0 && start_sw)
    {
        _memleak_add_to_index(*memptr, size, file, line, (0xff));
    }
    pthread_spin_unlock(&lock);
    return ret;
}

canonical_original_code:
int memleak_posix_memalign(void **memptr, unsigned long alignment, unsigned long size, char *file, unsigned long line)
{
    pthread_spin_lock(&lock);
    int ret = posix_memalign(memptr, alignment, size);
    if (ret==0 && start_sw)
    {
        _memleak_add_to_index(*memptr, size, file, line, (0xff));
    }
    pthread_spin_unlock(&lock);
    return ret;
}

variable_types:
memptr
void **

variable_types:
alignment
unsigned long

variable_types: ret int

return_type: int


repo: gregnavis/netbox

decompiled_code:
int __fastcall process_line(char *src)
{
size_t v1; // rax
ssize_t v2; // rax
char v4[256]; // [rsp+0h] [rbp-2118h] BYREF
char srca[16]; // [rsp+100h] [rbp-2018h] BYREF
char v6[4096]; // [rsp+110h] [rbp-2008h] BYREF
char dest[4104]; // [rsp+1110h] [rbp-1008h] BYREF

if ( strlen(src) > 0xFFF )
return fwrite("line too long\n", 1uLL, 0xEuLL, stderr);
strcpy(dest, src);
while ( 1 )
{
if ( read_protocol(dest, srca, 0x10uLL) == -1 )
return fwrite("cannot read protocol\n", 1uLL, 0x15uLL, stderr);
strcpy(v4, "nb");
strcpy(&v4[2], srca);
v1 = strlen(dest);
v2 = redirect(v4, dest, v1, v6, 0x1000uLL);
if ( v2 == -1 )
break;
v6[v2] = 0;
strcpy(dest, v6);
}
return fputs(dest, stdout);
}

canonical_decompiled_code:
int __fastcall func9(char *src)
{
size_t v1; // rax
ssize_t v2; // rax
char v4[256]; // [rsp+0h] [rbp-2118h] BYREF
char srca[16]; // [rsp+100h] [rbp-2018h] BYREF
char v6[4096]; // [rsp+110h] [rbp-2008h] BYREF
char dest[4104]; // [rsp+1110h] [rbp-1008h] BYREF

if ( strlen(src) > 0xFFF )
return fwrite("line too long\n", 1uLL, 0xEuLL, stderr);
strcpy(dest, src);
while ( 1 )
{
if ( func7(dest, srca, 0x10uLL) == -1 )
return fwrite("cannot read protocol\n", 1uLL, 0x15uLL, stderr);
strcpy(v4, "nb");
strcpy(&v4[2], srca);
v1 = strlen(dest);
v2 = func8(v4, dest, v1, v6, 0x1000uLL);
if ( v2 == -1 )
break;
v6[v2] = 0;
strcpy(dest, v6);
}
return fputs(dest, stdout);
}

original_code:
static void process_line(const char *line)
{
 char input[((2 * 2048) - 1) + 1], output[((2 * 2048) - 1) + 1], protocol[15 + 1], path[255 + 1];
 ssize_t size;
 if (strlen(line) > ((2 * 2048) - 1)) {
  fprintf(stderr, "line too long\n");
  goto out;
 }
 strcpy(input, line);
 while (1) {
  if (read_protocol(input, protocol, sizeof(protocol)) == -1) {
   fprintf(stderr, "cannot read protocol\n");
   goto out;
  }
  strcpy(path, "nb");
  strcpy(path + 2, protocol);
  size = redirect(path, input, strlen(input), output, sizeof(output));
  if (size == -1) {
   fputs(input, stdout);
   break;
  } else {
   output[size] = '\0';
   strcpy(input, output);
  }
 }
out:
 return;
}

canonical_original_code:
static void process_line(char *line)
{
 char input[-1]; char output[-1]; char protocol[-1]; char path[-1];
 long size;
 if (strlen(line) > ((2 * 2048) - 1)) {
  fprintf(stderr, "line too long\n");
  goto out;
 }
 strcpy(input, line);
 while (1) {
  if (read_protocol(input, protocol, sizeof(protocol)) == -1) {
   fprintf(stderr, "cannot read protocol\n");
   goto out;
  }
  strcpy(path, "nb");
  strcpy(path + 2, protocol);
  size = redirect(path, input, strlen(input), output, sizeof(output));
  if (size == -1) {
   fputs(input, stdout);
   break;
  } else {
   output[size] = '\0';
   strcpy(input, output);
  }
 }
out:
 return;
}

variable_types:
line
char *

variable_types:
input
char [-1]

variable_types:
output
char [-1]

variable_types:
protocol
char [-1]

variable_types:
path
char [-1]

variable_types: size long

return_type: void


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char v5[4104]; // [rsp+0h] [rbp-1008h] BYREF

while ( 1 )
{
v3 = fgets(v5, 4096, stdin);
if ( !v3 )
break;
process_line(v5);
}
return (int)v3;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char v5[4104]; // [rsp+0h] [rbp-1008h] BYREF

while ( 1 )
{
v3 = fgets(v5, 4096, stdin);
if ( !v3 )
break;
func9(v5);
}
return (int)v3;
}

original_code:
int main()
{
 char line[((2 * 2048) - 1) + 1];
 while (fgets(line, sizeof(line), stdin)) {
  process_line(line);
 }
 return 0;
}

canonical_original_code:
int main()
{
 char line[-1];
 while (fgets(line, sizeof(line), stdin)) {
  process_line(line);
 }
 return 0;
}

variable_types:
line
char [-1]


decompiled_code:
int __fastcall print_packet(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // rbx

v2 = a1;
printf("eth:");
if ( a2 )
{
do
printf("%02x", *v2++);
while ( &a1[a2] != v2 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func8(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // rbx

v2 = a1;
printf("eth:");
if ( a2 )
{
do
printf("%02x", *v2++);
while ( &a1[a2] != v2 );
}
return putchar(10);
}

original_code:
static void print_packet(const unsigned char *pkt, size_t pktlen)
{
 printf("eth:");
 while (pktlen--) {
  printf("%02x", *pkt++);
 }
 putchar('\n');
}

canonical_original_code:
static void print_packet(unsigned char *pkt, unsigned long pktlen)
{
 printf("eth:");
 while (pktlen--) {
  printf("%02x", *pkt++);
 }
 putchar('\n');
}

variable_types:
pkt
unsigned char *

variable_types:
pktlen
unsigned long


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int16 v3; // ax
int v4; // ebx
__int64 v6; // rax
unsigned __int8 v7[2056]; // [rsp+0h] [rbp-808h] BYREF

v3 = _bswap_16(3);
v4 = socket(17, 3, v3);
if ( v4 != -1 )
{
while ( 1 )
{
while ( 1 )
{
v6 = read(v4, v7, 0x800uLL);
if ( v6 >= 0 )
break;
perror("read");
}
if ( v6 > 0 )
print_packet(v7, v6);
}
}
perror("socket");
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int16 v3; // ax
int v4; // ebx
__int64 v6; // rax
unsigned __int8 v7[2056]; // [rsp+0h] [rbp-808h] BYREF

v3 = func7(3);
v4 = socket(17, 3, v3);
if ( v4 != -1 )
{
while ( 1 )
{
while ( 1 )
{
v6 = read(v4, v7, 0x800uLL);
if ( v6 >= 0 )
break;
perror("read");
}
if ( v6 > 0 )
func8(v7, v6);
}
}
perror("socket");
return 1;
}

original_code:
int main()
{
 unsigned char pktbuf[2048];
 int sockfd, res = 0;
 sockfd = socket(17, SOCK_RAW, htons(0x0003));
 if (-1 == sockfd) {
  perror("socket");
  goto error;
 }
 while (1) {
  ssize_t pktlen = read(sockfd, pktbuf, sizeof(pktbuf));
  if (pktlen < 0) {
   perror("read");
   continue;
  }
  if (pktlen > 0) {
   print_packet(pktbuf, pktlen);
  }
 }
 close(sockfd);
out:
 return res;
error:
 res = 1;
 goto out;
}

canonical_original_code:
int main()
{
 unsigned char pktbuf[2048];
 int sockfd; int res = 0;
 sockfd = socket(17, SOCK_RAW, htons(0x0003));
 if (-1 == sockfd) {
  perror("socket");
  goto error;
 }
 while (1) {
  long pktlen = read(sockfd, pktbuf, sizeof(pktbuf));
  if (pktlen < 0) {
   perror("read");
   continue;
  }
  if (pktlen > 0) {
   print_packet(pktbuf, pktlen);
  }
 }
 close(sockfd);
out:
 return res;
error:
 res = 1;
 goto out;
}

variable_types:
pktbuf
unsigned char [2048]

variable_types: sockfd int

variable_types: res int

variable_types: pktlen long


GetCCITT

repo: gregrahn/tpcds-kit

original_code:
unsigned short GetCCITT (unsigned short crc, unsigned short ch)
{
  static unsigned int i;
  ch <<= 8;
  for (i=8; i>0; i--) {
    if ((ch ^ crc) & 0X8000)
      crc = (crc << 1 ) ^ 0x1021;
    else
      crc <<= 1;
    ch <<= 1;
  }
  return (crc);
}

canonical_original_code:
unsigned short GetCCITT(unsigned short crc, unsigned short ch)
{
  static unsigned int i;
  ch <<= 8;
  for (i=8; i>0; i--) {
    if ((ch ^ crc) & 0X8000)
      crc = (crc << 1 ) ^ 0x1021;
    else
      crc <<= 1;
    ch <<= 1;
  }
  return (crc);
}

variable_types:
crc
unsigned short

variable_types:
ch
unsigned short

variable_types:
i
unsigned int

return_type: unsigned short


comp

repo: grevutiu-gabriel/lista

decompiled_code:
int __fastcall comp(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

canonical_decompiled_code:
int __fastcall func7(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code: int comp(const void *s1, const void *s2){return (strcmp(*(char **)s1, *(char **)s2));}

canonical_original_code: int comp(void *s1, void *s2){return (strcmp(*(char **)s1, *(char **)s2));}


cp

repo: gridnow/GridOS

decompiled_code:
__int64 cp()
{
TODO(&unk_1F);
return 38LL;
}

canonical_decompiled_code:
__int64 func0()
{
TODO(&unk_1F);
return 38LL;
}

original_code:
static int cp(int argc, char * argv[])
{
 TODO("");
 return 38;
}

canonical_original_code:
static int cp(int argc, char *argv[])
{
 TODO("");
 return 38;
}

variable_types: argc int

variable_types:
argv
char *[]


strcmp

decompiled_code:
__int64 __fastcall strcmp(__int64 a1, __int64 a2)
{
__int64 i; // rax
unsigned __int8 v3; // dl
unsigned __int8 v4; // cl

for ( i = 0LL; ; ++i )
{
v3 = *(_BYTE *)(a1 + i);
v4 = *(_BYTE *)(a2 + i);
if ( v3 != v4 )
break;
if ( !v3 )
return 0LL;
}
return v3 < v4 ? -1 : 1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 i; // rax
unsigned __int8 v3; // dl
unsigned __int8 v4; // cl

for ( i = 0LL; ; ++i )
{
v3 = *(_BYTE *)(a1 + i);
v4 = *(_BYTE *)(a2 + i);
if ( v3 != v4 )
break;
if ( !v3 )
return 0LL;
}
return v3 < v4 ? -1 : 1;
}

original_code:
int strcmp(const char *cs, const char *ct)
{
 unsigned char c1, c2;
 while (1) {
  c1 = *cs++;
  c2 = *ct++;
  if (c1 != c2)
   return c1 < c2 ? -1 : 1;
  if (!c1)
   break;
 }
 return 0;
}

canonical_original_code:
int strcmp(char *cs, char *ct)
{
 unsigned char c1; unsigned char c2;
 while (1) {
  c1 = *cs++;
  c2 = *ct++;
  if (c1 != c2)
   return c1 < c2 ? -1 : 1;
  if (!c1)
   break;
 }
 return 0;
}

variable_types:
cs
char *

variable_types:
ct
char *


strncmp

decompiled_code:
__int64 __fastcall strncmp(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rax
unsigned __int8 v6; // dl
unsigned __int8 v7; // cl

if ( !a3 )
return 0LL;
v5 = 0LL;
while ( 1 )
{
v6 = *(_BYTE *)(a1 + v5);
v7 = *(_BYTE *)(a2 + v5);
if ( v6 != v7 )
return v6 < v7 ? -1 : 1;
if ( !v6 )
break;
if ( ++v5 == a3 )
return 0LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rax
unsigned __int8 v6; // dl
unsigned __int8 v7; // cl

if ( !a3 )
return 0LL;
v5 = 0LL;
while ( 1 )
{
v6 = *(_BYTE *)(a1 + v5);
v7 = *(_BYTE *)(a2 + v5);
if ( v6 != v7 )
return v6 < v7 ? -1 : 1;
if ( !v6 )
break;
if ( ++v5 == a3 )
return 0LL;
}
return 0LL;
}

original_code:
int strncmp(const char *cs, const char *ct, size_t count)
{
 unsigned char c1, c2;
 while (count) {
  c1 = *cs++;
  c2 = *ct++;
  if (c1 != c2)
   return c1 < c2 ? -1 : 1;
  if (!c1)
   break;
  count--;
 }
 return 0;
}

canonical_original_code:
int strncmp(char *cs, char *ct, unsigned long count)
{
 unsigned char c1; unsigned char c2;
 while (count) {
  c1 = *cs++;
  c2 = *ct++;
  if (c1 != c2)
   return c1 < c2 ? -1 : 1;
  if (!c1)
   break;
  count--;
 }
 return 0;
}

variable_types:
count
unsigned long


cd

decompiled_code:
int __fastcall cd(int a1, __int64 a2)
{
int result; // eax

result = 22;
if ( a1 != 1 )
result = chdir(*(const char **)(a2 + 8));
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1, __int64 a2)
{
int result; // eax

result = 22;
if ( a1 != 1 )
result = chdir(*(const char **)(a2 + 8));
return result;
}

original_code:
static int cd(int argc, char * argv[])
{
 int r;
 if (argc == 1)
  return 22;
 r = chdir(argv[1]);
 return r;
}

canonical_original_code:
static int cd(int argc, char *argv[])
{
 int r;
 if (argc == 1)
  return 22;
 r = chdir(argv[1]);
 return r;
}

variable_types: r int


rm

decompiled_code:
__int64 rm()
{
TODO(&unk_1F);
return 38LL;
}

original_code:
static int rm(int argc, char * argv[])
{
 TODO("");
 return 38;
}

canonical_original_code:
static int rm(int argc, char *argv[])
{
 TODO("");
 return 38;
}


ls

decompiled_code:
__int64 ls()
{
show_normal();
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
func0();
return 0LL;
}

original_code:
static int ls(int argc, char * argv[])
{
 show_normal();
 return (0);
}

canonical_original_code:
static int ls(int argc, char *argv[])
{
 show_normal();
 return (0);
}


decompiled_code:
__int64 pthread_spin_init()
{
return TODO(&unk_4A);
}

canonical_decompiled_code:
__int64 func0()
{
return TODO(&unk_4A);
}

original_code:
void pthread_spin_init()
{
 TODO("");
}

canonical_original_code:
void pthread_spin_init()
{
 TODO("");
}


decompiled_code:
__int64 pthread_spin_lock()
{
return TODO(&unk_4A);
}

canonical_decompiled_code:
__int64 func1()
{
return TODO(&unk_4A);
}

original_code:
void pthread_spin_lock()
{
 TODO("");
}

canonical_original_code:
void pthread_spin_lock()
{
 TODO("");
}


decompiled_code:
__int64 pthread_spin_unlock()
{
return TODO(&unk_4A);
}

canonical_decompiled_code:
__int64 func2()
{
return TODO(&unk_4A);
}

original_code:
void pthread_spin_unlock()
{
 TODO("");
}


dlerror

decompiled_code:
__int64 dlerror()
{
TODO(&unk_1F);
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
TODO(&unk_1F);
return 0LL;
}

original_code:
char *dlerror(void)
{
 TODO("");
 return ((void *)0);
}

canonical_original_code:
char *dlerror()
{
 TODO("");
 return ((void *)0);
}

return_type: char *


CreateFromFile

repo: gromgull/subdue

decompiled_code:
__int64 __fastcall CreateFromFile(char *src, unsigned __int64 a2, unsigned __int64 a3)
{
char v5[32]; // [rsp+0h] [rbp-78h] BYREF
char dest[88]; // [rsp+20h] [rbp-58h] BYREF

sprintf(v5, "_%d", (unsigned int)incrementCount);
strcpy(dest, src);
strcat(dest, v5);
strcat(dest, ".g");
return ReadIncrement(dest, (__int64)src, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *src, unsigned __int64 a2, unsigned __int64 a3)
{
char v5[32]; // [rsp+0h] [rbp-78h] BYREF
char dest[88]; // [rsp+20h] [rbp-58h] BYREF

sprintf(v5, "_%d", (unsigned int)incrementCount);
strcpy(dest, src);
strcat(dest, v5);
strcat(dest, ".g");
return func3(dest, (__int64)src, a2, a3);
}

original_code:
BOOLEAN CreateFromFile(Parameters *parameters,
                       ULONG startPosVertexIndex, ULONG startNegVertexIndex)
{
   char fileName[50];
   char str[20];
   BOOLEAN newData = 0;
   sprintf(str, "_%d", incrementCount);
   strcpy(fileName, parameters->inputFileName);
   strcat(fileName, str);
   strcat(fileName, ".g");
   newData = ReadIncrement(fileName, parameters,
                           startPosVertexIndex, startNegVertexIndex);
   return newData;
}

canonical_original_code:
unsigned char CreateFromFile(struct Parameters *parameters, unsigned long startPosVertexIndex, unsigned long startNegVertexIndex)
{
   char fileName[50];
   char str[20];
   unsigned char newData = 0;
   sprintf(str, "_%d", incrementCount);
   strcpy(fileName, parameters->inputFileName);
   strcat(fileName, str);
   strcat(fileName, ".g");
   newData = ReadIncrement(fileName, parameters,
                           startPosVertexIndex, startNegVertexIndex);
   return newData;
}

variable_types: struct Parameters { char inputFileName[512]; char psInputFileName[512]; char outFileName[512]; struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; } *vertices; struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; } *edges; unsigned long vertexListSize; unsigned long edgeListSize; } *posGraph; struct Graph *negGraph; double posGraphDL; double negGraphDL; unsigned long numPosEgs; unsigned long numNegEgs; unsigned long *posEgsVertexIndices; unsigned long *negEgsVertexIndices; struct LabelList { unsigned long size; unsigned long numLabels; struct Label { unsigned char labelType; union { char *stringLabel; double numericLabel; } labelValue; unsigned char used; } *labels; } *labelList; struct Graph **preSubs; unsigned long numPreSubs; unsigned char predefinedSubs; unsigned char outputToFile; unsigned char directed; unsigned long beamWidth; unsigned long limit; unsigned long maxVertices; unsigned long minVertices; unsigned long numBestSubs; unsigned char valueBased; unsigned char prune; unsigned long outputLevel; unsigned char allowInstanceOverlap; unsigned long evalMethod; double threshold; unsigned long iterations; double *log2Factorial; unsigned long log2FactorialSize; unsigned long numPartitions; unsigned char recursion; unsigned char variables; unsigned char relations; unsigned char incremental; unsigned char compress; struct IncrementList { struct _increment_list_node { struct _increment { struct SubList { struct _sub_list_node { struct Substructure { struct Graph *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList { struct _instance_list_node { struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *instance; struct _instance_list_node *next; } *head; } *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; } *sub; struct _sub_list_node *next; } *head; } *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; } *increment; struct _increment_list_node *next; } *head; } *incrementList; struct InstanceVertexList { struct AvlTreeList { struct _avltablenode { struct avl_table { struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; } *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); } *avl_alloc; unsigned long avl_count; unsigned long avl_generation; } *vertexTree; struct Substructure *sub; struct _avltablenode *next; } *head; } *avlTreeList; } *vertexList; unsigned long posGraphSize; unsigned long negGraphSize; } *

variable_types:
startPosVertexIndex
unsigned long

variable_types:
startNegVertexIndex
unsigned long

variable_types:
fileName
char [50]

variable_types:
str
char [20]

variable_types:
newData
unsigned char

return_type: unsigned char

user_defined_types: struct Parameters { char inputFileName[512]; char psInputFileName[512]; char outFileName[512]; struct Graph *posGraph; struct Graph *negGraph; double posGraphDL; double negGraphDL; unsigned long numPosEgs; unsigned long numNegEgs; unsigned long *posEgsVertexIndices; unsigned long *negEgsVertexIndices; struct LabelList *labelList; struct Graph **preSubs; unsigned long numPreSubs; unsigned char predefinedSubs; unsigned char outputToFile; unsigned char directed; unsigned long beamWidth; unsigned long limit; unsigned long maxVertices; unsigned long minVertices; unsigned long numBestSubs; unsigned char valueBased; unsigned char prune; unsigned long outputLevel; unsigned char allowInstanceOverlap; unsigned long evalMethod; double threshold; unsigned long iterations; double *log2Factorial; unsigned long log2FactorialSize; unsigned long numPartitions; unsigned char recursion; unsigned char variables; unsigned char relations; unsigned char incremental; unsigned char compress; struct IncrementList *incrementList; struct InstanceVertexList *vertexList; unsigned long posGraphSize; unsigned long negGraphSize; }

user_defined_types: struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex *vertices; struct Edge *edges; unsigned long vertexListSize; unsigned long edgeListSize; }

user_defined_types: struct LabelList { unsigned long size; unsigned long numLabels; struct Label *labels; }

user_defined_types: struct IncrementList { struct _increment_list_node *head; }

user_defined_types: struct InstanceVertexList { struct AvlTreeList *avlTreeList; }

user_defined_types: struct _increment_list_node { struct _increment *increment; struct _increment_list_node *next; }

user_defined_types: struct AvlTreeList { struct _avltablenode *head; }

user_defined_types: struct _increment { struct SubList *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; }

user_defined_types: struct _avltablenode { struct avl_table *vertexTree; struct Substructure *sub; struct _avltablenode *next; }

user_defined_types: struct SubList { struct _sub_list_node *head; }

user_defined_types: struct avl_table { struct avl_node *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator *avl_alloc; unsigned long avl_count; unsigned long avl_generation; }

user_defined_types: struct _sub_list_node { struct Substructure *sub; struct _sub_list_node *next; }

user_defined_types: struct Substructure { struct Graph *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; }

user_defined_types: struct InstanceList { struct _instance_list_node *head; }

user_defined_types: struct _instance_list_node { struct _instance *instance; struct _instance_list_node *next; }

user_defined_types: struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; }


GetNextIncrement

decompiled_code:
__int64 __fastcall GetNextIncrement(char *src)
{
unsigned __int64 *v1; // rdx
unsigned __int64 v2; // r13
unsigned __int64 *v3; // rax
unsigned __int64 v4; // r12
unsigned __int64 v5; // r14
unsigned int v6; // eax
unsigned int v7; // ebp

if ( start )
{
InitializeGraph(src);
start = 0;
}
v1 = (unsigned __int64 *)*((_QWORD *)src + 192);
v2 = *v1;
v3 = (unsigned __int64 *)*((_QWORD *)src + 193);
if ( v3 )
{
v4 = *v3;
v5 = v3[1];
}
else
{
v5 = v1[1];
v4 = 0LL;
}
numIncrementPosVertices = 0LL;
numIncrementPosEdges = 0LL;
numIncrementNegVertices = 0LL;
numIncrementNegEdges = 0LL;
v6 = time(0LL);
srand(v6 >> 1);
v7 = CreateFromFile(src, v2, v4);
AddNewIncrement(
v2,
0LL,
v4,
v5,
numIncrementPosVertices,
numIncrementPosEdges,
numIncrementNegVertices,
numIncrementNegEdges,
src);
++incrementCount;
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *src)
{
unsigned __int64 *v1; // rdx
unsigned __int64 v2; // r13
unsigned __int64 *v3; // rax
unsigned __int64 v4; // r12
unsigned __int64 v5; // r14
unsigned int v6; // eax
unsigned int v7; // ebp

if ( start )
{
func0(src);
start = 0;
}
v1 = (unsigned __int64 *)*((_QWORD *)src + 192);
v2 = *v1;
v3 = (unsigned __int64 *)*((_QWORD *)src + 193);
if ( v3 )
{
v4 = *v3;
v5 = v3[1];
}
else
{
v5 = v1[1];
v4 = 0LL;
}
numIncrementPosVertices = 0LL;
numIncrementPosEdges = 0LL;
numIncrementNegVertices = 0LL;
numIncrementNegEdges = 0LL;
v6 = time(0LL);
srand(v6 >> 1);
v7 = func4(src, v2, v4);
AddNewIncrement(
v2,
0LL,
v4,
v5,
numIncrementPosVertices,
numIncrementPosEdges,
numIncrementNegVertices,
numIncrementNegEdges,
src);
++incrementCount;
return v7;
}

original_code:
BOOLEAN GetNextIncrement(Parameters *parameters)
{
   long ltime;
   int stime;
   BOOLEAN newData;
   ULONG startPosVertexIndex = 0;
   ULONG startPosEdgeIndex = 0;
   ULONG startNegVertexIndex = 0;
   ULONG startNegEdgeIndex = 0;
   if (start)
   {
      InitializeGraph(parameters);
      start = 0;
   }
   startPosVertexIndex = parameters->posGraph->numVertices;
   if (parameters->negGraph != ((void *)0))
      startNegVertexIndex = parameters->negGraph->numVertices;
   startNegEdgeIndex = parameters->posGraph->numEdges;
   if (parameters->negGraph != ((void *)0))
      startNegEdgeIndex = parameters->negGraph->numEdges;
   numIncrementPosVertices = 0;
   numIncrementPosEdges = 0;
   numIncrementNegVertices = 0;
   numIncrementNegEdges = 0;
   ltime = time(((void *)0));
   stime = (unsigned) ltime/2;
   srand(stime);
   newData = CreateFromFile(parameters,
                            startPosVertexIndex, startNegVertexIndex);
   AddNewIncrement(startPosVertexIndex, startPosEdgeIndex,
                   startNegVertexIndex, startNegEdgeIndex,
                   numIncrementPosVertices, numIncrementPosEdges,
                   numIncrementNegVertices, numIncrementNegEdges, parameters);
   incrementCount++;
   return newData;
}

canonical_original_code:
unsigned char GetNextIncrement(struct Parameters *parameters)
{
   long ltime;
   int stime;
   unsigned char newData;
   unsigned long startPosVertexIndex = 0;
   unsigned long startPosEdgeIndex = 0;
   unsigned long startNegVertexIndex = 0;
   unsigned long startNegEdgeIndex = 0;
   if (start)
   {
      InitializeGraph(parameters);
      start = 0;
   }
   startPosVertexIndex = parameters->posGraph->numVertices;
   if (parameters->negGraph != ((void *)0))
      startNegVertexIndex = parameters->negGraph->numVertices;
   startNegEdgeIndex = parameters->posGraph->numEdges;
   if (parameters->negGraph != ((void *)0))
      startNegEdgeIndex = parameters->negGraph->numEdges;
   numIncrementPosVertices = 0;
   numIncrementPosEdges = 0;
   numIncrementNegVertices = 0;
   numIncrementNegEdges = 0;
   ltime = time(((void *)0));
   stime = (unsigned int) ltime/2;
   srand(stime);
   newData = CreateFromFile(parameters,
                            startPosVertexIndex, startNegVertexIndex);
   AddNewIncrement(startPosVertexIndex, startPosEdgeIndex,
                   startNegVertexIndex, startNegEdgeIndex,
                   numIncrementPosVertices, numIncrementPosEdges,
                   numIncrementNegVertices, numIncrementNegEdges, parameters);
   incrementCount++;
   return newData;
}

variable_types: ltime long

variable_types: stime int

variable_types:
startPosEdgeIndex
unsigned long

variable_types:
startNegEdgeIndex
unsigned long

user_defined_types: struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; }

user_defined_types: struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; }

user_defined_types: struct Label { unsigned char labelType; union { char *stringLabel; double numericLabel; } labelValue; unsigned char used; }

user_defined_types: struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; }

user_defined_types: struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); }

user_defined_types: struct VertexMap { unsigned long v1; unsigned long v2; }


FindSingleVertexInstances

decompiled_code:
__int64 __fastcall FindSingleVertexInstances(unsigned __int64 *a1, _QWORD *a2)
{
__int64 v2; // r13
unsigned __int64 v3; // rbx
__int64 v4; // rax

v2 = AllocateInstanceList();
if ( *a1 )
{
v3 = 0LL;
do
{
if ( *(_QWORD *)(a1[2] + 40 * v3) == *a2 )
{
v4 = AllocateInstance(1LL, 0LL);
**(_QWORD **)(v4 + 16) = v3;
*(_QWORD *)(v4 + 32) = 0LL;
InstanceListInsert(v4, v2, 0LL);
}
++v3;
}
while ( *a1 > v3 );
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 *a1, _QWORD *a2)
{
__int64 v2; // r13
unsigned __int64 v3; // rbx
__int64 v4; // rax

v2 = AllocateInstanceList();
if ( *a1 )
{
v3 = 0LL;
do
{
if ( *(_QWORD *)(a1[2] + 40 * v3) == *a2 )
{
v4 = AllocateInstance(1LL, 0LL);
**(_QWORD **)(v4 + 16) = v3;
*(_QWORD *)(v4 + 32) = 0LL;
InstanceListInsert(v4, v2, 0LL);
}
++v3;
}
while ( *a1 > v3 );
}
return v2;
}

original_code:
InstanceList *FindSingleVertexInstances(Graph *graph, Vertex *vertex,
                                        Parameters *parameters)
{
   ULONG v;
   InstanceList *instanceList;
   Instance *instance;
   instanceList = AllocateInstanceList();
   for (v = 0; v < graph->numVertices; v++)
   {
      if (graph->vertices[v].label == vertex->label)
      {
         instance = AllocateInstance(1, 0);
         instance->vertices[0] = v;
         instance->minMatchCost = 0.0;
         InstanceListInsert(instance, instanceList, 0);
      }
   }
   return instanceList;
}

canonical_original_code:
struct InstanceList *FindSingleVertexInstances(struct Graph *graph, struct Vertex *vertex, struct Parameters *parameters)
{
   unsigned long v;
   struct InstanceList *instanceList;
   struct _instance *instance;
   instanceList = AllocateInstanceList();
   for (v = 0; v < graph->numVertices; v++)
   {
      if (graph->vertices[v].label == vertex->label)
      {
         instance = AllocateInstance(1, 0);
         instance->vertices[0] = v;
         instance->minMatchCost = 0.0;
         InstanceListInsert(instance, instanceList, 0);
      }
   }
   return instanceList;
}

variable_types: struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; } *vertices; struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; } *edges; unsigned long vertexListSize; unsigned long edgeListSize; } *

variable_types:
vertex
struct Vertex *

variable_types: struct Parameters { char inputFileName[512]; char psInputFileName[512]; char outFileName[512]; struct Graph *posGraph; struct Graph *negGraph; double posGraphDL; double negGraphDL; unsigned long numPosEgs; unsigned long numNegEgs; unsigned long *posEgsVertexIndices; unsigned long *negEgsVertexIndices; struct LabelList { unsigned long size; unsigned long numLabels; struct Label { unsigned char labelType; union { char *stringLabel; double numericLabel; } labelValue; unsigned char used; } *labels; } *labelList; struct Graph **preSubs; unsigned long numPreSubs; unsigned char predefinedSubs; unsigned char outputToFile; unsigned char directed; unsigned long beamWidth; unsigned long limit; unsigned long maxVertices; unsigned long minVertices; unsigned long numBestSubs; unsigned char valueBased; unsigned char prune; unsigned long outputLevel; unsigned char allowInstanceOverlap; unsigned long evalMethod; double threshold; unsigned long iterations; double *log2Factorial; unsigned long log2FactorialSize; unsigned long numPartitions; unsigned char recursion; unsigned char variables; unsigned char relations; unsigned char incremental; unsigned char compress; struct IncrementList { struct _increment_list_node { struct _increment { struct SubList { struct _sub_list_node { struct Substructure { struct Graph *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; } *sub; struct _sub_list_node *next; } *head; } *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; } *increment; struct _increment_list_node *next; } *head; } *incrementList; struct InstanceVertexList { struct AvlTreeList { struct _avltablenode { struct avl_table { struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; } *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); } *avl_alloc; unsigned long avl_count; unsigned long avl_generation; } *vertexTree; struct Substructure *sub; struct _avltablenode *next; } *head; } *avlTreeList; } *vertexList; unsigned long posGraphSize; unsigned long negGraphSize; } *

variable_types:
v
unsigned long

variable_types: struct InstanceList { struct _instance_list_node { struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *instance; struct _instance_list_node *next; } *head; } *

user_defined_types: struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex *vertices; struct Edge *edges; unsigned long vertexListSize; unsigned long edgeListSize; }

user_defined_types: struct Parameters { char inputFileName[512]; char psInputFileName[512]; char outFileName[512]; struct Graph *posGraph; struct Graph *negGraph; double posGraphDL; double negGraphDL; unsigned long numPosEgs; unsigned long numNegEgs; unsigned long *posEgsVertexIndices; unsigned long *negEgsVertexIndices; struct LabelList *labelList; struct Graph **preSubs; unsigned long numPreSubs; unsigned char predefinedSubs; unsigned char outputToFile; unsigned char directed; unsigned long beamWidth; unsigned long limit; unsigned long maxVertices; unsigned long minVertices; unsigned long numBestSubs; unsigned char valueBased; unsigned char prune; unsigned long outputLevel; unsigned char allowInstanceOverlap; unsigned long evalMethod; double threshold; unsigned long iterations; double *log2Factorial; unsigned long log2FactorialSize; unsigned long numPartitions; unsigned char recursion; unsigned char variables; unsigned char relations; unsigned char incremental; unsigned char compress; struct IncrementList *incrementList; struct InstanceVertexList *vertexList; unsigned long posGraphSize; unsigned long negGraphSize; }

user_defined_types: struct LabelList { unsigned long size; unsigned long numLabels; struct Label *labels; }

user_defined_types: struct IncrementList { struct _increment_list_node *head; }

user_defined_types: struct InstanceVertexList { struct AvlTreeList *avlTreeList; }

user_defined_types: struct _increment_list_node { struct _increment *increment; struct _increment_list_node *next; }


EdgesMatch

original_code:
BOOLEAN EdgesMatch(Graph *g1, Edge *edge1, Graph *g2, Edge *edge2,
                   Parameters *parameters)
{
   ULONG vertex11Label;
   ULONG vertex12Label;
   ULONG vertex21Label;
   ULONG vertex22Label;
   BOOLEAN match;
   match = 0;
   vertex11Label = g1->vertices[edge1->vertex1].label;
   vertex12Label = g1->vertices[edge1->vertex2].label;
   vertex21Label = g2->vertices[edge2->vertex1].label;
   vertex22Label = g2->vertices[edge2->vertex2].label;
   if ((edge1->label == edge2->label) &&
       (edge1->directed == edge2->directed))
   {
      if ((vertex11Label == vertex21Label) &&
          (vertex12Label == vertex22Label))
         match = 1;
      else if ((! edge1->directed) &&
               (vertex11Label == vertex22Label) &&
               (vertex12Label == vertex21Label))
         match = 1;
   }
   return match;
}

canonical_original_code:
unsigned char EdgesMatch(struct Graph *g1, struct Edge *edge1, struct Graph *g2, struct Edge *edge2, struct Parameters *parameters)
{
   unsigned long vertex11Label;
   unsigned long vertex12Label;
   unsigned long vertex21Label;
   unsigned long vertex22Label;
   unsigned char match;
   match = 0;
   vertex11Label = g1->vertices[edge1->vertex1].label;
   vertex12Label = g1->vertices[edge1->vertex2].label;
   vertex21Label = g2->vertices[edge2->vertex1].label;
   vertex22Label = g2->vertices[edge2->vertex2].label;
   if ((edge1->label == edge2->label) &&
       (edge1->directed == edge2->directed))
   {
      if ((vertex11Label == vertex21Label) &&
          (vertex12Label == vertex22Label))
         match = 1;
      else if ((! edge1->directed) &&
               (vertex11Label == vertex22Label) &&
               (vertex12Label == vertex21Label))
         match = 1;
   }
   return match;
}

variable_types: struct Parameters { char inputFileName[512]; char psInputFileName[512]; char outFileName[512]; struct Graph *posGraph; struct Graph *negGraph; double posGraphDL; double negGraphDL; unsigned long numPosEgs; unsigned long numNegEgs; unsigned long *posEgsVertexIndices; unsigned long *negEgsVertexIndices; struct LabelList { unsigned long size; unsigned long numLabels; struct Label { unsigned char labelType; union { char *stringLabel; double numericLabel; } labelValue; unsigned char used; } *labels; } *labelList; struct Graph **preSubs; unsigned long numPreSubs; unsigned char predefinedSubs; unsigned char outputToFile; unsigned char directed; unsigned long beamWidth; unsigned long limit; unsigned long maxVertices; unsigned long minVertices; unsigned long numBestSubs; unsigned char valueBased; unsigned char prune; unsigned long outputLevel; unsigned char allowInstanceOverlap; unsigned long evalMethod; double threshold; unsigned long iterations; double *log2Factorial; unsigned long log2FactorialSize; unsigned long numPartitions; unsigned char recursion; unsigned char variables; unsigned char relations; unsigned char incremental; unsigned char compress; struct IncrementList { struct _increment_list_node { struct _increment { struct SubList { struct _sub_list_node { struct Substructure { struct Graph *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList { struct _instance_list_node { struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *instance; struct _instance_list_node *next; } *head; } *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; } *sub; struct _sub_list_node *next; } *head; } *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; } *increment; struct _increment_list_node *next; } *head; } *incrementList; struct InstanceVertexList { struct AvlTreeList { struct _avltablenode { struct avl_table { struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; } *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); } *avl_alloc; unsigned long avl_count; unsigned long avl_generation; } *vertexTree; struct Substructure *sub; struct _avltablenode *next; } *head; } *avlTreeList; } *vertexList; unsigned long posGraphSize; unsigned long negGraphSize; } *

variable_types:
match
unsigned char

user_defined_types: struct AvlTreeList { struct _avltablenode *head; }

user_defined_types: struct _increment { struct SubList *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; }

user_defined_types: struct _avltablenode { struct avl_table *vertexTree; struct Substructure *sub; struct _avltablenode *next; }

user_defined_types: struct SubList { struct _sub_list_node *head; }

user_defined_types: struct avl_table { struct avl_node *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator *avl_alloc; unsigned long avl_count; unsigned long avl_generation; }

user_defined_types: struct _sub_list_node { struct Substructure *sub; struct _sub_list_node *next; }


ExtendInstancesByEdge

decompiled_code:
__int64 __fastcall ExtendInstancesByEdge(unsigned __int64 ***a1, __int64 a2, __int64 a3, __int64 a4)
{
unsigned __int64 v6; // rbx
__int64 v7; // r12
__int64 v8; // rcx
__int64 v9; // rax
unsigned __int64 v10; // r14
__int64 v11; // rbp
unsigned __int64 *v12; // r13
__int64 v14; // [rsp+28h] [rbp-50h]
unsigned __int64 **i; // [rsp+30h] [rbp-48h]

v14 = AllocateInstanceList();
for ( i = *a1; i; i = (unsigned __int64 **)i[1] )
{
v12 = *i;
MarkInstanceEdges(*i, a4, 1LL);
if ( *v12 )
{
v10 = 0LL;
do
{
v11 = *(_QWORD *)(a4 + 16) + 40LL * *(_QWORD *)(v12[2] + 8 * v10);
if ( *(_QWORD *)(v11 + 8) )
{
v6 = 0LL;
do
{
v7 = *(_QWORD *)(*(_QWORD *)(v11 + 16) + 8 * v6);
v8 = *(_QWORD *)(a4 + 24) + 32 * v7;
if ( !*(_BYTE *)(v8 + 25) && (unsigned __int8)EdgesMatch(a2, a3, a4, v8) )
{
v9 = CreateExtendedInstance(v12, *(_QWORD *)(v12[2] + 8 * v10), v7, a4);
InstanceListInsert(v9, v14, 1LL);
}
++v6;
}
while ( *(_QWORD *)(v11 + 8) > v6 );
}
++v10;
}
while ( *v12 > v10 );
}
MarkInstanceEdges(v12, a4, 0LL);
}
FreeInstanceList(a1);
return v14;
}

original_code:
InstanceList *ExtendInstancesByEdge(InstanceList *instanceList,
                                    Graph *g1, Edge *edge1, Graph *g2,
                                    Parameters *parameters)
{
   InstanceList *newInstanceList;
   InstanceListNode *instanceListNode;
   Instance *instance;
   Instance *newInstance;
   ULONG v2;
   ULONG e2;
   Edge *edge2;
   Vertex *vertex2;
   newInstanceList = AllocateInstanceList();
   instanceListNode = instanceList->head;
   while (instanceListNode != ((void *)0))
   {
      instance = instanceListNode->instance;
      MarkInstanceEdges(instance, g2, 1);
      for (v2 = 0; v2 < instance->numVertices; v2++)
      {
         vertex2 = & g2->vertices[instance->vertices[v2]];
         for (e2 = 0; e2 < vertex2->numEdges; e2++)
         {
            edge2 = & g2->edges[vertex2->edges[e2]];
            if ((! edge2->used) &&
                (EdgesMatch(g1, edge1, g2, edge2, parameters)))
            {
               newInstance =
                  CreateExtendedInstance(instance, instance->vertices[v2],
                                         vertex2->edges[e2], g2);
               InstanceListInsert(newInstance, newInstanceList, 1);
            }
         }
      }
      MarkInstanceEdges(instance, g2, 0);
      instanceListNode = instanceListNode->next;
   }
   FreeInstanceList(instanceList);
   return newInstanceList;
}

canonical_original_code:
struct InstanceList *ExtendInstancesByEdge(struct InstanceList *instanceList, struct Graph *g1, struct Edge *edge1, struct Graph *g2, struct Parameters *parameters)
{
   struct InstanceList *newInstanceList;
   struct _instance_list_node *instanceListNode;
   struct _instance *instance;
   struct _instance *newInstance;
   unsigned long v2;
   unsigned long e2;
   struct Edge *edge2;
   struct Vertex *vertex2;
   newInstanceList = AllocateInstanceList();
   instanceListNode = instanceList->head;
   while (instanceListNode != ((void *)0))
   {
      instance = instanceListNode->instance;
      MarkInstanceEdges(instance, g2, 1);
      for (v2 = 0; v2 < instance->numVertices; v2++)
      {
         vertex2 = & g2->vertices[instance->vertices[v2]];
         for (e2 = 0; e2 < vertex2->numEdges; e2++)
         {
            edge2 = & g2->edges[vertex2->edges[e2]];
            if ((! edge2->used) &&
                (EdgesMatch(g1, edge1, g2, edge2, parameters)))
            {
               newInstance =
                  CreateExtendedInstance(instance, instance->vertices[v2],
                                         vertex2->edges[e2], g2);
               InstanceListInsert(newInstance, newInstanceList, 1);
            }
         }
      }
      MarkInstanceEdges(instance, g2, 0);
      instanceListNode = instanceListNode->next;
   }
   FreeInstanceList(instanceList);
   return newInstanceList;
}

variable_types:
instanceList
struct InstanceList *

variable_types: struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; } *

variable_types: struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; } *

return_type: struct InstanceList { struct _instance_list_node { struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *instance; struct _instance_list_node *next; } *head; } *

user_defined_types: struct InstanceList { struct _instance_list_node *head; }

user_defined_types: struct _instance_list_node { struct _instance *instance; struct _instance_list_node *next; }

user_defined_types: struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; }

user_defined_types: struct Substructure { struct Graph *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; }


FilterInstances

decompiled_code:
__int64 __fastcall FilterInstances(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4)
{
__int64 v5; // r14
_QWORD *v6; // rbp
double v8; // xmm0_8
__int64 v9; // rbx
__int64 v10; // rax
__int64 v11; // r12
double v12; // [rsp+8h] [rbp-60h]
double v14[8]; // [rsp+28h] [rbp-40h] BYREF

v5 = AllocateInstanceList();
if ( a2 )
{
v6 = (_QWORD *)*a2;
if ( *a2 )
{
do
{
v9 = *v6;
if ( *v6 && (*(_BYTE *)(a4 + 1688) || !(unsigned __int8)InstanceListOverlap(*v6, v5)) )
{
v10 = *(_QWORD *)v9 + *(_QWORD *)(v9 + 8);
if ( v10 < 0 )
v8 = (double)(int)(v10 & 1 | ((unsigned __int64)v10 >> 1))
+ (double)(int)(v10 & 1 | ((unsigned __int64)v10 >> 1));
else
v8 = (double)(int)v10;
v12 = v8 * *(double *)(a4 + 1704);
v11 = InstanceToGraph(v9, a3);
if ( (unsigned __int8)GraphMatch(a1, v11, *(_QWORD *)(a4 + 1600), v14, 0LL, v12) )
{
if ( *(double *)(v9 + 32) > v14[0] )
*(double *)(v9 + 32) = v14[0];
InstanceListInsert(v9, v5, 0LL);
}
FreeGraph(v11);
}
v6 = (_QWORD *)v6[1];
}
while ( v6 );
}
}
FreeInstanceList(a2);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4)
{
__int64 v5; // r14
_QWORD *v6; // rbp
double v8; // xmm0_8
__int64 v9; // rbx
__int64 v10; // rax
__int64 v11; // r12
double v12; // [rsp+8h] [rbp-60h]
double v14[8]; // [rsp+28h] [rbp-40h] BYREF

v5 = AllocateInstanceList();
if ( a2 )
{
v6 = (_QWORD *)*a2;
if ( *a2 )
{
do
{
v9 = *v6;
if ( *v6 && (*(_BYTE *)(a4 + 1688) || !(unsigned __int8)InstanceListOverlap(*v6, v5)) )
{
v10 = *(_QWORD *)v9 + *(_QWORD *)(v9 + 8);
if ( v10 < 0 )
v8 = (double)(int)(v10 & 1 | ((unsigned __int64)v10 >> 1))
+ (double)(int)(v10 & 1 | ((unsigned __int64)v10 >> 1));
else
v8 = (double)(int)v10;
v12 = v8 * *(double *)(a4 + 1704);
v11 = InstanceToGraph(v9, a3);
if ( (unsigned __int8)GraphMatch(a1, v11, *(_QWORD *)(a4 + 1600), v14, 0LL, v12) )
{
if ( *(double *)(v9 + 32) > v14[0] )
*(double *)(v9 + 32) = v14[0];
InstanceListInsert(v9, v5, 0LL);
}
FreeGraph(v11);
}
v6 = (_QWORD *)v6[1];
}
while ( v6 );
}
}
FreeInstanceList(a2);
return v5;
}

original_code:
InstanceList *FilterInstances(Graph *subGraph, InstanceList *instanceList,
                              Graph *graph, Parameters *parameters)
{
   InstanceListNode *instanceListNode;
   Instance *instance;
   InstanceList *newInstanceList;
   Graph *instanceGraph;
   double thresholdLimit;
   double matchCost;
   newInstanceList = AllocateInstanceList();
   if (instanceList != ((void *)0))
   {
      instanceListNode = instanceList->head;
      while (instanceListNode != ((void *)0))
      {
         if (instanceListNode->instance != ((void *)0))
         {
            instance = instanceListNode->instance;
            if (parameters->allowInstanceOverlap ||
                (! InstanceListOverlap(instance, newInstanceList)))
            {
               thresholdLimit = parameters->threshold *
                                (instance->numVertices + instance->numEdges);
               instanceGraph = InstanceToGraph(instance, graph);
               if (GraphMatch(subGraph, instanceGraph, parameters->labelList,
                              thresholdLimit, & matchCost, ((void *)0)))
               {
                  if (matchCost < instance->minMatchCost)
                     instance->minMatchCost = matchCost;
                  InstanceListInsert(instance, newInstanceList, 0);
               }
               FreeGraph(instanceGraph);
            }
         }
         instanceListNode = instanceListNode->next;
      }
   }
   FreeInstanceList(instanceList);
   return newInstanceList;
}

canonical_original_code:
struct InstanceList *FilterInstances(struct Graph *subGraph, struct InstanceList *instanceList, struct Graph *graph, struct Parameters *parameters)
{
   struct _instance_list_node *instanceListNode;
   struct _instance *instance;
   struct InstanceList *newInstanceList;
   struct Graph *instanceGraph;
   double thresholdLimit;
   double matchCost;
   newInstanceList = AllocateInstanceList();
   if (instanceList != ((void *)0))
   {
      instanceListNode = instanceList->head;
      while (instanceListNode != ((void *)0))
      {
         if (instanceListNode->instance != ((void *)0))
         {
            instance = instanceListNode->instance;
            if (parameters->allowInstanceOverlap ||
                (! InstanceListOverlap(instance, newInstanceList)))
            {
               thresholdLimit = parameters->threshold *
                                (instance->numVertices + instance->numEdges);
               instanceGraph = InstanceToGraph(instance, graph);
               if (GraphMatch(subGraph, instanceGraph, parameters->labelList,
                              thresholdLimit, & matchCost, ((void *)0)))
               {
                  if (matchCost < instance->minMatchCost)
                     instance->minMatchCost = matchCost;
                  InstanceListInsert(instance, newInstanceList, 0);
               }
               FreeGraph(instanceGraph);
            }
         }
         instanceListNode = instanceListNode->next;
      }
   }
   FreeInstanceList(instanceList);
   return newInstanceList;
}

variable_types:
graph
struct Graph *

variable_types: struct _instance_list_node { struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *instance; struct _instance_list_node *next; } *

variable_types: thresholdLimit double

variable_types: matchCost double

user_defined_types: struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; }

user_defined_types: struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; }

user_defined_types: struct Label { unsigned char labelType; union { char *stringLabel; double numericLabel; } labelValue; unsigned char used; }

user_defined_types: struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; }

user_defined_types: struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); }


FindInstances

original_code:
InstanceList *FindInstances(Graph *g1, Graph *g2, Parameters *parameters)
{
   ULONG v;
   ULONG v1;
   ULONG e1;
   Vertex *vertex1;
   Edge *edge1;
   InstanceList *instanceList;
   BOOLEAN *reached;
   BOOLEAN noMatches;
   BOOLEAN found;
   reached = (BOOLEAN *) malloc(sizeof(BOOLEAN) * g1->numVertices);
   if (reached == ((void *)0))
      OutOfMemoryError("FindInstances:reached");
   for (v1 = 0; v1 < g1->numVertices; v1++)
      reached[v1] = 0;
   v1 = 0;
   reached[v1] = 1;
   vertex1 = & g1->vertices[v1];
   instanceList = FindSingleVertexInstances(g2, vertex1, parameters);
   noMatches = 0;
   if (instanceList->head == ((void *)0))
      noMatches = 1;
   while ((vertex1 != ((void *)0)) && (! noMatches))
   {
      vertex1->used = 1;
      for (e1 = 0; ((e1 < vertex1->numEdges) && (! noMatches)); e1++)
      {
         edge1 = & g1->edges[g1->vertices[v1].edges[e1]];
         if (! edge1->used)
         {
            reached[edge1->vertex1] = 1;
            reached[edge1->vertex2] = 1;
            instanceList =
               ExtendInstancesByEdge(instanceList, g1, edge1, g2, parameters);
            if (instanceList->head == ((void *)0))
               noMatches = 1;
            edge1->used = 1;
         }
      }
      vertex1 = ((void *)0);
      found = 0;
      for (v = 0; ((v < g1->numVertices) && (! found)); v++)
      {
         if ((! g1->vertices[v].used) && (reached[v]))
         {
            v1 = v;
            vertex1 = & g1->vertices[v1];
            found = 1;
         }
      }
   }
   free(reached);
   for (v1 = 0; v1 < g1->numVertices; v1++)
      g1->vertices[v1].used = 0;
   for (e1 = 0; e1 < g1->numEdges; e1++)
      g1->edges[e1].used = 0;
   instanceList = FilterInstances(g1, instanceList, g2, parameters);
   return instanceList;
}

canonical_original_code:
struct InstanceList *FindInstances(struct Graph *g1, struct Graph *g2, struct Parameters *parameters)
{
   unsigned long v;
   unsigned long v1;
   unsigned long e1;
   struct Vertex *vertex1;
   struct Edge *edge1;
   struct InstanceList *instanceList;
   unsigned char *reached;
   unsigned char noMatches;
   unsigned char found;
   reached = (unsigned char *) malloc(sizeof(BOOLEAN) * g1->numVertices);
   if (reached == ((void *)0))
      OutOfMemoryError("FindInstances:reached");
   for (v1 = 0; v1 < g1->numVertices; v1++)
      reached[v1] = 0;
   v1 = 0;
   reached[v1] = 1;
   vertex1 = & g1->vertices[v1];
   instanceList = FindSingleVertexInstances(g2, vertex1, parameters);
   noMatches = 0;
   if (instanceList->head == ((void *)0))
      noMatches = 1;
   while ((vertex1 != ((void *)0)) && (! noMatches))
   {
      vertex1->used = 1;
      for (e1 = 0; ((e1 < vertex1->numEdges) && (! noMatches)); e1++)
      {
         edge1 = & g1->edges[g1->vertices[v1].edges[e1]];
         if (! edge1->used)
         {
            reached[edge1->vertex1] = 1;
            reached[edge1->vertex2] = 1;
            instanceList =
               ExtendInstancesByEdge(instanceList, g1, edge1, g2, parameters);
            if (instanceList->head == ((void *)0))
               noMatches = 1;
            edge1->used = 1;
         }
      }
      vertex1 = ((void *)0);
      found = 0;
      for (v = 0; ((v < g1->numVertices) && (! found)); v++)
      {
         if ((! g1->vertices[v].used) && (reached[v]))
         {
            v1 = v;
            vertex1 = & g1->vertices[v1];
            found = 1;
         }
      }
   }
   free(reached);
   for (v1 = 0; v1 < g1->numVertices; v1++)
      g1->vertices[v1].used = 0;
   for (e1 = 0; e1 < g1->numEdges; e1++)
      g1->edges[e1].used = 0;
   instanceList = FilterInstances(g1, instanceList, g2, parameters);
   return instanceList;
}

variable_types:
reached
unsigned char *

variable_types:
noMatches
unsigned char

variable_types:
found
unsigned char

user_defined_types: struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex *vertices; struct Edge *edges; unsigned long vertexListSize; unsigned long edgeListSize; }

user_defined_types: struct Parameters { char inputFileName[512]; char psInputFileName[512]; char outFileName[512]; struct Graph *posGraph; struct Graph *negGraph; double posGraphDL; double negGraphDL; unsigned long numPosEgs; unsigned long numNegEgs; unsigned long *posEgsVertexIndices; unsigned long *negEgsVertexIndices; struct LabelList *labelList; struct Graph **preSubs; unsigned long numPreSubs; unsigned char predefinedSubs; unsigned char outputToFile; unsigned char directed; unsigned long beamWidth; unsigned long limit; unsigned long maxVertices; unsigned long minVertices; unsigned long numBestSubs; unsigned char valueBased; unsigned char prune; unsigned long outputLevel; unsigned char allowInstanceOverlap; unsigned long evalMethod; double threshold; unsigned long iterations; double *log2Factorial; unsigned long log2FactorialSize; unsigned long numPartitions; unsigned char recursion; unsigned char variables; unsigned char relations; unsigned char incremental; unsigned char compress; struct IncrementList *incrementList; struct InstanceVertexList *vertexList; unsigned long posGraphSize; unsigned long negGraphSize; }

user_defined_types: struct LabelList { unsigned long size; unsigned long numLabels; struct Label *labels; }

user_defined_types: struct IncrementList { struct _increment_list_node *head; }

user_defined_types: struct InstanceVertexList { struct AvlTreeList *avlTreeList; }

user_defined_types: struct VertexMap { unsigned long v1; unsigned long v2; }


RunSubdue

decompiled_code:
int __fastcall RunSubdue(int a1, __int64 a2, const char *a3, const char *a4)
{
const char **v6; // rbx
int result; // eax
char v8[296]; // [rsp+0h] [rbp-128h] BYREF

strcpy(v8, "subdue");
if ( a1 > 1 )
{
v6 = (const char **)(a2 + 8);
do
{
*(_WORD *)&v8[strlen(v8)] = 32;
strcat(v8, *v6++);
}
while ( v6 != (const char **)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) );
}
strcat(v8, " -out ");
strcat(v8, a4);
*(_WORD *)&v8[strlen(v8)] = 32;
strcat(v8, a3);
result = system(v8);
if ( result )
{
fprintf(stderr, "ERROR: unable to run command: %s\n", v8);
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, __int64 a2, const char *a3, const char *a4)
{
const char **v6; // rbx
int result; // eax
char v8[296]; // [rsp+0h] [rbp-128h] BYREF

strcpy(v8, "subdue");
if ( a1 > 1 )
{
v6 = (const char **)(a2 + 8);
do
{
*(_WORD *)&v8[strlen(v8)] = 32;
strcat(v8, *v6++);
}
while ( v6 != (const char **)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) );
}
strcat(v8, " -out ");
strcat(v8, a4);
*(_WORD *)&v8[strlen(v8)] = 32;
strcat(v8, a3);
result = system(v8);
if ( result )
{
fprintf(stderr, "ERROR: unable to run command: %s\n", v8);
exit(1);
}
return result;
}

original_code:
void RunSubdue(int argc, char **argv, char *trainFileName,
               char *subsFileName)
{
   char command[256];
   int i;
   int status;
   strcpy(command, "subdue");
   for (i = 1; i < argc; i++)
   {
      strcat(command, " ");
      strcat(command, argv[i]);
   }
   strcat(command, " -out ");
   strcat(command, subsFileName);
   strcat(command, " ");
   strcat(command, trainFileName);
   status = system(command);
   if (status != 0)
   {
      fprintf(stderr, "ERROR: unable to run command: %s\n",command);
      exit (1);
   }
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
trainFileName
char *

variable_types:
subsFileName
char *

variable_types:
command
char [256]

variable_types: i int

variable_types: status int


RemoveFile

decompiled_code:
int __fastcall RemoveFile(const char *a1)
{
char v2[264]; // [rsp+0h] [rbp-108h] BYREF

sprintf(v2, "%s %s", "/bin/rm -f", a1);
return system(v2);
}

canonical_decompiled_code:
int __fastcall func3(const char *a1)
{
char v2[264]; // [rsp+0h] [rbp-108h] BYREF

sprintf(v2, "%s %s", "/bin/rm -f", a1);
return system(v2);
}

original_code:
void RemoveFile(char *fileName)
{
   char command[256];
   sprintf(command, "%s %s", "/bin/rm -f", fileName);
   system(command);
}

variable_types:
fileName
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // r15
__int64 v4; // rax
__int64 v5; // r12
_QWORD *v6; // r13
__int64 i; // rbx
__int64 v8; // rbx
__int64 v9; // r14
__int64 v10; // r12
__int64 v11; // r13
double v12; // xmm0_8
double v13; // xmm1_8
float v14; // xmm0_4
unsigned __int64 v15; // rax
__int64 v16; // rax
float v17; // xmm1_4
__int64 v19; // [rsp+10h] [rbp-490h]
__int64 v20; // [rsp+18h] [rbp-488h]
__int64 v21; // [rsp+20h] [rbp-480h]
unsigned __int64 v22; // [rsp+30h] [rbp-470h]
int v23; // [rsp+38h] [rbp-468h]
float v24; // [rsp+3Ch] [rbp-464h]
__int64 v25; // [rsp+40h] [rbp-460h] BYREF
__int64 v26; // [rsp+48h] [rbp-458h] BYREF
__int64 v27; // [rsp+50h] [rbp-450h] BYREF
__int64 v28; // [rsp+58h] [rbp-448h] BYREF
__int64 v29; // [rsp+60h] [rbp-440h] BYREF
__int64 v30; // [rsp+68h] [rbp-438h] BYREF
char v31[256]; // [rsp+70h] [rbp-430h] BYREF
char v32[256]; // [rsp+170h] [rbp-330h] BYREF
char s[256]; // [rsp+270h] [rbp-230h] BYREF
char dest[304]; // [rsp+370h] [rbp-130h] BYREF

v3 = malloc(0x6F8uLL);
if ( !v3 )
OutOfMemoryError("GetParameters:parameters");
v3[1626] = 1;
*((_QWORD *)v3 + 200) = AllocateLabelList();
strcpy(dest, argv[argc - 1]);
v23 = argc - 1;
if ( argc - 1 <= 1 )
{
v22 = 1LL;
}
else
{
v4 = argc - 1;
if ( !strcmp("-nfolds", argv[v4 - 2]) )
{
v22 = atol(argv[v4 - 1]);
v23 = argc - 3;
if ( !v22 )
{
fwrite("-nfolds must be greater than one\n", 1uLL, 0x21uLL, stderr);
exit(1);
}
}
else
{
v22 = 1LL;
}
}
fwrite("Subdue Cross-Validation Testing\n", 1uLL, 0x20uLL, stdout);
fprintf(stdout, "Number of Folds = %lu\n\n", v22);
NumPosNegExamples(dest, &v30, &v29);
fprintf(stdout, "Read %lu positive and %lu negative examples.\n", v30, v29);
v5 = v30 + v29;
v6 = malloc(8 * (v30 + v29));
if ( !v6 )
OutOfMemoryError("cvtest main: fold array");
if ( v5 )
{
for ( i = 0LL; i != v5; ++i )
v6[i] = random() % v22 + 1;
}
v8 = 0LL;
v21 = 0LL;
v9 = 0LL;
v24 = 0.0;
v20 = v5;
v19 = (__int64)v6;
v10 = 0LL;
v11 = 0LL;
do
{
fprintf(stdout, "----------\nFold %lu\n----------\n", ++v8);
fflush(stdout);
sprintf(s, "%s.train.%lu", dest, v8);
sprintf(v32, "%s.test.%lu", dest, v8);
sprintf(v31, "%s.subs.%lu", dest, v8);
WriteTrainTestFiles(dest, s, v32, v8, v19, v20, v22);
RunSubdue(v23, (__int64)argv, s, v31);
Test(v31, v32, v3, &v28, &v27, &v26, &v25);
v15 = v25 + v26;
if ( v25 + v26 < 0 )
v12 = (double)(int)(v15 & 1 | (v15 >> 1)) + (double)(int)(v15 & 1 | (v15 >> 1));
else
v12 = (double)(int)v15;
v16 = v27 + v28 + v15;
if ( v16 < 0 )
v13 = (double)(int)(v16 & 1 | ((unsigned __int64)v16 >> 1))
+ (double)(int)(v16 & 1 | ((unsigned __int64)v16 >> 1));
else
v13 = (double)(int)v16;
v14 = v12 / v13;
v24 = v24 + v14;
v9 += v28;
v10 += v27;
v11 += v26;
v21 += v25;
fprintf(stdout, "Fold %lu error = %f\n", v8, v14);
fprintf(stdout, " TP = %lu\n", v28);
fprintf(stdout, " TN = %lu\n", v27);
fprintf(stdout, " FP = %lu\n", v26);
fprintf(stdout, " FN = %lu\n\n", v25);
RemoveFile(s);
RemoveFile(v32);
RemoveFile(v31);
}
while ( v8 != v22 );
if ( (v22 & 0x8000000000000000LL) != 0LL )
v17 = (float)(int)(v22 & 1 | (v22 >> 1)) + (float)(int)(v22 & 1 | (v22 >> 1));
else
v17 = (float)(int)v22;
fprintf(stdout, "%lu-fold cross validation error = %f\n", v22, (float)(v24 / v17));
fprintf(stdout, " total TP = %lu\n", v9);
fprintf(stdout, " total TN = %lu\n", v10);
fprintf(stdout, " total FP = %lu\n", v11);
fprintf(stdout, " total FN = %lu\n", v21);
fflush(stdout);
FreeLabelList(*((_QWORD *)v3 + 200));
free(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // r15
__int64 v4; // rax
__int64 v5; // r12
_QWORD *v6; // r13
__int64 i; // rbx
__int64 v8; // rbx
__int64 v9; // r14
__int64 v10; // r12
__int64 v11; // r13
double v12; // xmm0_8
double v13; // xmm1_8
float v14; // xmm0_4
unsigned __int64 v15; // rax
__int64 v16; // rax
float v17; // xmm1_4
__int64 v19; // [rsp+10h] [rbp-490h]
__int64 v20; // [rsp+18h] [rbp-488h]
__int64 v21; // [rsp+20h] [rbp-480h]
unsigned __int64 v22; // [rsp+30h] [rbp-470h]
int v23; // [rsp+38h] [rbp-468h]
float v24; // [rsp+3Ch] [rbp-464h]
__int64 v25; // [rsp+40h] [rbp-460h] BYREF
__int64 v26; // [rsp+48h] [rbp-458h] BYREF
__int64 v27; // [rsp+50h] [rbp-450h] BYREF
__int64 v28; // [rsp+58h] [rbp-448h] BYREF
__int64 v29; // [rsp+60h] [rbp-440h] BYREF
__int64 v30; // [rsp+68h] [rbp-438h] BYREF
char v31[256]; // [rsp+70h] [rbp-430h] BYREF
char v32[256]; // [rsp+170h] [rbp-330h] BYREF
char s[256]; // [rsp+270h] [rbp-230h] BYREF
char dest[304]; // [rsp+370h] [rbp-130h] BYREF

v3 = malloc(0x6F8uLL);
if ( !v3 )
OutOfMemoryError("GetParameters:parameters");
v3[1626] = 1;
*((_QWORD *)v3 + 200) = AllocateLabelList();
strcpy(dest, argv[argc - 1]);
v23 = argc - 1;
if ( argc - 1 <= 1 )
{
v22 = 1LL;
}
else
{
v4 = argc - 1;
if ( !strcmp("-nfolds", argv[v4 - 2]) )
{
v22 = atol(argv[v4 - 1]);
v23 = argc - 3;
if ( !v22 )
{
fwrite("-nfolds must be greater than one\n", 1uLL, 0x21uLL, stderr);
exit(1);
}
}
else
{
v22 = 1LL;
}
}
fwrite("Subdue Cross-Validation Testing\n", 1uLL, 0x20uLL, stdout);
fprintf(stdout, "Number of Folds = %lu\n\n", v22);
func0(dest, &v30, &v29);
fprintf(stdout, "Read %lu positive and %lu negative examples.\n", v30, v29);
v5 = v30 + v29;
v6 = malloc(8 * (v30 + v29));
if ( !v6 )
OutOfMemoryError("cvtest main: fold array");
if ( v5 )
{
for ( i = 0LL; i != v5; ++i )
v6[i] = random() % v22 + 1;
}
v8 = 0LL;
v21 = 0LL;
v9 = 0LL;
v24 = 0.0;
v20 = v5;
v19 = (__int64)v6;
v10 = 0LL;
v11 = 0LL;
do
{
fprintf(stdout, "----------\nFold %lu\n----------\n", ++v8);
fflush(stdout);
sprintf(s, "%s.train.%lu", dest, v8);
sprintf(v32, "%s.test.%lu", dest, v8);
sprintf(v31, "%s.subs.%lu", dest, v8);
func1(dest, s, v32, v8, v19, v20, v22);
func2(v23, (__int64)argv, s, v31);
Test(v31, v32, v3, &v28, &v27, &v26, &v25);
v15 = v25 + v26;
if ( v25 + v26 < 0 )
v12 = (double)(int)(v15 & 1 | (v15 >> 1)) + (double)(int)(v15 & 1 | (v15 >> 1));
else
v12 = (double)(int)v15;
v16 = v27 + v28 + v15;
if ( v16 < 0 )
v13 = (double)(int)(v16 & 1 | ((unsigned __int64)v16 >> 1))
+ (double)(int)(v16 & 1 | ((unsigned __int64)v16 >> 1));
else
v13 = (double)(int)v16;
v14 = v12 / v13;
v24 = v24 + v14;
v9 += v28;
v10 += v27;
v11 += v26;
v21 += v25;
fprintf(stdout, "Fold %lu error = %f\n", v8, v14);
fprintf(stdout, " TP = %lu\n", v28);
fprintf(stdout, " TN = %lu\n", v27);
fprintf(stdout, " FP = %lu\n", v26);
fprintf(stdout, " FN = %lu\n\n", v25);
func3(s);
func3(v32);
func3(v31);
}
while ( v8 != v22 );
if ( (v22 & 0x8000000000000000LL) != 0LL )
v17 = (float)(int)(v22 & 1 | (v22 >> 1)) + (float)(int)(v22 & 1 | (v22 >> 1));
else
v17 = (float)(int)v22;
fprintf(stdout, "%lu-fold cross validation error = %f\n", v22, (float)(v24 / v17));
fprintf(stdout, " total TP = %lu\n", v9);
fprintf(stdout, " total TN = %lu\n", v10);
fprintf(stdout, " total FP = %lu\n", v11);
fprintf(stdout, " total FN = %lu\n", v21);
fflush(stdout);
FreeLabelList(*((_QWORD *)v3 + 200));
free(v3);
return 0;
}

original_code:
int main(int argc, char **argv)
{
   Parameters *parameters;
   char inputFileName[256];
   char trainFileName[256];
   char testFileName[256];
   char subsFileName[256];
   ULONG numPosEgs;
   ULONG numNegEgs;
   ULONG numEgs;
   ULONG numFolds;
   ULONG *egFolds;
   float error;
   float meanError = 0.0;
   ULONG TP, TN, FP, FN;
   ULONG totalTP = 0, totalTN = 0, totalFP = 0, totalFN = 0;
   ULONG i;
   parameters = (Parameters *) malloc(sizeof(Parameters));
   if (parameters == ((void *)0))
      OutOfMemoryError("GetParameters:parameters");
   parameters->directed = 1;
   parameters->labelList = AllocateLabelList();
   numFolds = 1;
   strcpy(inputFileName, argv[argc - 1]);
   argc--;
   if ((argc > 1) && (strcmp ("-nfolds", argv[argc - 2]) == 0))
   {
      numFolds = atol(argv[argc - 1]);
      if (numFolds < 1)
      {
         fprintf(stderr, "-nfolds must be greater than one\n");
         exit (1);
      }
      argc -= 2;
   }
   fprintf(stdout, "Subdue Cross-Validation Testing\n");
   fprintf(stdout, "Number of Folds = %lu\n\n", numFolds);
   NumPosNegExamples(inputFileName, &numPosEgs, &numNegEgs);
   fprintf(stdout, "Read %lu positive and %lu negative examples.\n",
           numPosEgs, numNegEgs);
   numEgs = numPosEgs + numNegEgs;
   egFolds = (ULONG *) malloc(sizeof(ULONG) * numEgs);
   if (egFolds == ((void *)0))
      OutOfMemoryError("cvtest main: fold array");
   for (i = 0; i < numEgs; i++)
      egFolds[i] = (random() % numFolds) + 1;
   for (i = 0; i < numFolds; i++)
   {
      fprintf (stdout, "----------\nFold %lu\n----------\n", (i+1));
      fflush (stdout);
      sprintf (trainFileName, "%s.train.%lu", inputFileName, (i+1));
      sprintf (testFileName, "%s.test.%lu", inputFileName, (i+1));
      sprintf (subsFileName, "%s.subs.%lu", inputFileName, (i+1));
      WriteTrainTestFiles(inputFileName, trainFileName, testFileName,
                          (i+1), egFolds, numEgs, numFolds);
      RunSubdue(argc, argv, trainFileName, subsFileName);
      Test(subsFileName, testFileName, parameters,
           &TP, &TN, &FP, &FN);
      error = ((double) (FP+FN)) / ((double) (TP+TN+FP+FN));
      meanError += error;
      totalTP += TP;
      totalTN += TN;
      totalFP += FP;
      totalFN += FN;
      fprintf(stdout, "Fold %lu error = %f\n", (i+1), error);
      fprintf(stdout, "  TP = %lu\n", TP);
      fprintf(stdout, "  TN = %lu\n", TN);
      fprintf(stdout, "  FP = %lu\n", FP);
      fprintf(stdout, "  FN = %lu\n\n", FN);
      RemoveFile(trainFileName);
      RemoveFile(testFileName);
      RemoveFile(subsFileName);
   }
   meanError = meanError / numFolds;
   fprintf(stdout, "%lu-fold cross validation error = %f\n",
           numFolds, meanError);
   fprintf(stdout, "  total TP = %lu\n", totalTP);
   fprintf(stdout, "  total TN = %lu\n", totalTN);
   fprintf(stdout, "  total FP = %lu\n", totalFP);
   fprintf(stdout, "  total FN = %lu\n", totalFN);
   fflush(stdout);
   FreeLabelList(parameters->labelList);
   free(parameters);
   return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
   struct Parameters *parameters;
   char inputFileName[256];
   char trainFileName[256];
   char testFileName[256];
   char subsFileName[256];
   unsigned long numPosEgs;
   unsigned long numNegEgs;
   unsigned long numEgs;
   unsigned long numFolds;
   unsigned long *egFolds;
   float error;
   float meanError = 0.0;
   unsigned long TP; unsigned long TN; unsigned long FP; unsigned long FN;
   unsigned long totalTP = 0; unsigned long totalTN = 0; unsigned long totalFP = 0; unsigned long totalFN = 0;
   unsigned long i;
   parameters = (struct Parameters *) malloc(sizeof(Parameters));
   if (parameters == ((void *)0))
      OutOfMemoryError("GetParameters:parameters");
   parameters->directed = 1;
   parameters->labelList = AllocateLabelList();
   numFolds = 1;
   strcpy(inputFileName, argv[argc - 1]);
   argc--;
   if ((argc > 1) && (strcmp ("-nfolds", argv[argc - 2]) == 0))
   {
      numFolds = atol(argv[argc - 1]);
      if (numFolds < 1)
      {
         fprintf(stderr, "-nfolds must be greater than one\n");
         exit (1);
      }
      argc -= 2;
   }
   fprintf(stdout, "Subdue Cross-Validation Testing\n");
   fprintf(stdout, "Number of Folds = %lu\n\n", numFolds);
   NumPosNegExamples(inputFileName, &numPosEgs, &numNegEgs);
   fprintf(stdout, "Read %lu positive and %lu negative examples.\n",
           numPosEgs, numNegEgs);
   numEgs = numPosEgs + numNegEgs;
   egFolds = (unsigned long *) malloc(sizeof(ULONG) * numEgs);
   if (egFolds == ((void *)0))
      OutOfMemoryError("cvtest main: fold array");
   for (i = 0; i < numEgs; i++)
      egFolds[i] = (random() % numFolds) + 1;
   for (i = 0; i < numFolds; i++)
   {
      fprintf (stdout, "----------\nFold %lu\n----------\n", (i+1));
      fflush (stdout);
      sprintf (trainFileName, "%s.train.%lu", inputFileName, (i+1));
      sprintf (testFileName, "%s.test.%lu", inputFileName, (i+1));
      sprintf (subsFileName, "%s.subs.%lu", inputFileName, (i+1));
      WriteTrainTestFiles(inputFileName, trainFileName, testFileName,
                          (i+1), egFolds, numEgs, numFolds);
      RunSubdue(argc, argv, trainFileName, subsFileName);
      Test(subsFileName, testFileName, parameters,
           &TP, &TN, &FP, &FN);
      error = ((double) (FP+FN)) / ((double) (TP+TN+FP+FN));
      meanError += error;
      totalTP += TP;
      totalTN += TN;
      totalFP += FP;
      totalFN += FN;
      fprintf(stdout, "Fold %lu error = %f\n", (i+1), error);
      fprintf(stdout, "  TP = %lu\n", TP);
      fprintf(stdout, "  TN = %lu\n", TN);
      fprintf(stdout, "  FP = %lu\n", FP);
      fprintf(stdout, "  FN = %lu\n\n", FN);
      RemoveFile(trainFileName);
      RemoveFile(testFileName);
      RemoveFile(subsFileName);
   }
   meanError = meanError / numFolds;
   fprintf(stdout, "%lu-fold cross validation error = %f\n",
           numFolds, meanError);
   fprintf(stdout, "  total TP = %lu\n", totalTP);
   fprintf(stdout, "  total TN = %lu\n", totalTN);
   fprintf(stdout, "  total FP = %lu\n", totalFP);
   fprintf(stdout, "  total FN = %lu\n", totalFN);
   fflush(stdout);
   FreeLabelList(parameters->labelList);
   free(parameters);
   return 0;
}

variable_types: struct Parameters { char inputFileName[512]; char psInputFileName[512]; char outFileName[512]; struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; } *vertices; struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; } *edges; unsigned long vertexListSize; unsigned long edgeListSize; } *posGraph; struct Graph *negGraph; double posGraphDL; double negGraphDL; unsigned long numPosEgs; unsigned long numNegEgs; unsigned long *posEgsVertexIndices; unsigned long *negEgsVertexIndices; struct LabelList { unsigned long size; unsigned long numLabels; struct Label { unsigned char labelType; union { char *stringLabel; double numericLabel; } labelValue; unsigned char used; } *labels; } *labelList; struct Graph **preSubs; unsigned long numPreSubs; unsigned char predefinedSubs; unsigned char outputToFile; unsigned char directed; unsigned long beamWidth; unsigned long limit; unsigned long maxVertices; unsigned long minVertices; unsigned long numBestSubs; unsigned char valueBased; unsigned char prune; unsigned long outputLevel; unsigned char allowInstanceOverlap; unsigned long evalMethod; double threshold; unsigned long iterations; double *log2Factorial; unsigned long log2FactorialSize; unsigned long numPartitions; unsigned char recursion; unsigned char variables; unsigned char relations; unsigned char incremental; unsigned char compress; struct IncrementList { struct _increment_list_node { struct _increment { struct SubList { struct _sub_list_node { struct Substructure { struct Graph *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList { struct _instance_list_node { struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *instance; struct _instance_list_node *next; } *head; } *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; } *sub; struct _sub_list_node *next; } *head; } *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; } *increment; struct _increment_list_node *next; } *head; } *incrementList; struct InstanceVertexList { struct AvlTreeList { struct _avltablenode { struct avl_table { struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; } *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); } *avl_alloc; unsigned long avl_count; unsigned long avl_generation; } *vertexTree; struct Substructure *sub; struct _avltablenode *next; } *head; } *avlTreeList; } *vertexList; unsigned long posGraphSize; unsigned long negGraphSize; } *

variable_types:
inputFileName
char [256]

variable_types:
trainFileName
char [256]

variable_types:
testFileName
char [256]

variable_types:
subsFileName
char [256]

variable_types:
numPosEgs
unsigned long

variable_types:
numNegEgs
unsigned long

variable_types:
numEgs
unsigned long

variable_types:
numFolds
unsigned long

variable_types:
egFolds
unsigned long *

variable_types: error float

variable_types: meanError float

variable_types:
TP
unsigned long

variable_types:
TN
unsigned long

variable_types:
FP
unsigned long

variable_types:
FN
unsigned long

variable_types:
totalTP
unsigned long

variable_types:
totalTN
unsigned long

variable_types:
totalFP
unsigned long

variable_types:
totalFN
unsigned long

variable_types:
i
unsigned long

user_defined_types: struct _increment_list_node { struct _increment *increment; struct _increment_list_node *next; }

user_defined_types: struct AvlTreeList { struct _avltablenode *head; }

user_defined_types: struct _increment { struct SubList *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; }

user_defined_types: struct _avltablenode { struct avl_table *vertexTree; struct Substructure *sub; struct _avltablenode *next; }

user_defined_types: struct SubList { struct _sub_list_node *head; }

user_defined_types: struct avl_table { struct avl_node *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator *avl_alloc; unsigned long avl_count; unsigned long avl_generation; }


decompiled_code:
__int64 __fastcall compare_ints(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 > *a2;
return result;
}

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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 > *a2;
return result;
}

original_code:
int compare_ints(const void *pa, const void *pb)
{
   const int *a = pa;
   const int *b = pb;
   if (*a < *b)
      return -1;
   else if (*a > *b)
      return 1;
   else
      return 0;
}

canonical_original_code:
int compare_ints(void *pa, void *pb)
{
   int *a = pa;
   int *b = pb;
   if (*a < *b)
      return -1;
   else if (*a > *b)
      return 1;
   else
      return 0;
}

variable_types:
pa
void *

variable_types:
pb
void *

variable_types:
a
int *

variable_types:
b
int *


GetOutputFileName

decompiled_code:
char *__fastcall GetOutputFileName(char *src, unsigned int a2)
{
char *v2; // rbx
char v4[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = (char *)malloc(0x32uLL);
sprintf(v4, "_%d", a2);
strcpy(v2, src);
strcat(v2, v4);
strcat(v2, ".txt");
return v2;
}

canonical_decompiled_code:
char *__fastcall func2(char *src, unsigned int a2)
{
char *v2; // rbx
char v4[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = (char *)malloc(0x32uLL);
sprintf(v4, "_%d", a2);
strcpy(v2, src);
strcat(v2, v4);
strcat(v2, ".txt");
return v2;
}

original_code:
char *GetOutputFileName(char *suffix, ULONG index)
{
   char *fileName;
   char str[20];
   fileName = malloc(sizeof(char) * 50);
   sprintf(str, "_%d", (int) index);
   strcpy(fileName, suffix);
   strcat(fileName, str);
   strcat(fileName, ".txt");
   return fileName;
}

canonical_original_code:
char *GetOutputFileName(char *suffix, unsigned long index)
{
   char *fileName;
   char str[20];
   fileName = malloc(sizeof(char) * 50);
   sprintf(str, "_%d", (int) index);
   strcpy(fileName, suffix);
   strcat(fileName, str);
   strcat(fileName, ".txt");
   return fileName;
}

variable_types:
suffix
char *

variable_types:
index
unsigned long

variable_types:
fileName
char *

variable_types:
str
char [20]


AddInstanceToTree

decompiled_code:
void __fastcall AddInstanceToTree(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 v2; // r13
unsigned __int64 v3; // rbx

v2 = a2[2];
if ( *a2 )
{
v3 = 0LL;
do
{
*(_QWORD *)malloc(8uLL) = *(_QWORD *)(v2 + 8 * v3);
avl_insert(a1);
++v3;
}
while ( *a2 > v3 );
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 v2; // r13
unsigned __int64 v3; // rbx

v2 = a2[2];
if ( *a2 )
{
v3 = 0LL;
do
{
*(_QWORD *)malloc(8uLL) = *(_QWORD *)(v2 + 8 * v3);
avl_insert(a1);
++v3;
}
while ( *a2 > v3 );
}
}

original_code:
void AddInstanceToTree(struct avl_table *avlTable, Instance *instance)
{
   ULONG *vertices;
   ULONG *j;
   ULONG i;
   vertices = instance->vertices;
   for (i=0;i<instance->numVertices;i++)
   {
      j = (ULONG*) malloc(sizeof(ULONG));
      *j = vertices[i];
      avl_insert(avlTable, j);
   }
}

canonical_original_code:
void AddInstanceToTree(struct avl_table *avlTable, struct _instance *instance)
{
   unsigned long *vertices;
   unsigned long *j;
   unsigned long i;
   vertices = instance->vertices;
   for (i=0;i<instance->numVertices;i++)
   {
      j = (unsigned long *) malloc(sizeof(ULONG));
      *j = vertices[i];
      avl_insert(avlTable, j);
   }
}

variable_types: struct avl_table { struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; } *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); } *avl_alloc; unsigned long avl_count; unsigned long avl_generation; } *

variable_types: struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *

variable_types:
vertices
unsigned long *

variable_types:
j
unsigned long *

user_defined_types: struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; }


GetCurrentIncrementNum

decompiled_code:
__int64 __fastcall GetCurrentIncrementNum(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = **(_QWORD **)(a1 + 1752);
if ( !v1 )
return 0LL;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
return *(_QWORD *)(*(_QWORD *)v2 + 8LL);
}

original_code:
ULONG GetCurrentIncrementNum(Parameters *parameters)
{
   IncrementListNode *incNodePtr = parameters->incrementList->head;
   if (incNodePtr == ((void *)0))
      return 0;
   while (incNodePtr->next != ((void *)0))
      incNodePtr = incNodePtr->next;
   return incNodePtr->increment->incrementNum;
}

canonical_original_code:
unsigned long GetCurrentIncrementNum(struct Parameters *parameters)
{
   struct _increment_list_node *incNodePtr = parameters->incrementList->head;
   if (incNodePtr == ((void *)0))
      return 0;
   while (incNodePtr->next != ((void *)0))
      incNodePtr = incNodePtr->next;
   return incNodePtr->increment->incrementNum;
}

variable_types: struct Parameters { char inputFileName[512]; char psInputFileName[512]; char outFileName[512]; struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; } *vertices; struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; } *edges; unsigned long vertexListSize; unsigned long edgeListSize; } *posGraph; struct Graph *negGraph; double posGraphDL; double negGraphDL; unsigned long numPosEgs; unsigned long numNegEgs; unsigned long *posEgsVertexIndices; unsigned long *negEgsVertexIndices; struct LabelList { unsigned long size; unsigned long numLabels; struct Label { unsigned char labelType; union { char *stringLabel; double numericLabel; } labelValue; unsigned char used; } *labels; } *labelList; struct Graph **preSubs; unsigned long numPreSubs; unsigned char predefinedSubs; unsigned char outputToFile; unsigned char directed; unsigned long beamWidth; unsigned long limit; unsigned long maxVertices; unsigned long minVertices; unsigned long numBestSubs; unsigned char valueBased; unsigned char prune; unsigned long outputLevel; unsigned char allowInstanceOverlap; unsigned long evalMethod; double threshold; unsigned long iterations; double *log2Factorial; unsigned long log2FactorialSize; unsigned long numPartitions; unsigned char recursion; unsigned char variables; unsigned char relations; unsigned char incremental; unsigned char compress; struct IncrementList { struct _increment_list_node { struct _increment { struct SubList { struct _sub_list_node { struct Substructure { struct Graph *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList { struct _instance_list_node { struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *instance; struct _instance_list_node *next; } *head; } *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; } *sub; struct _sub_list_node *next; } *head; } *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; } *increment; struct _increment_list_node *next; } *head; } *incrementList; struct InstanceVertexList { struct AvlTreeList { struct _avltablenode { struct avl_table { struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; } *avl_root; int (*avl_compare)(void *avl_a, void *avl_b, void *avl_param); void *avl_param; struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); } *avl_alloc; unsigned long avl_count; unsigned long avl_generation; } *vertexTree; struct Substructure *sub; struct _avltablenode *next; } *head; } *avlTreeList; } *vertexList; unsigned long posGraphSize; unsigned long negGraphSize; } *

variable_types: struct _increment_list_node { struct _increment { struct SubList { struct _sub_list_node { struct Substructure { struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; } *vertices; struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; } *edges; unsigned long vertexListSize; unsigned long edgeListSize; } *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList { struct _instance_list_node { struct _instance { unsigned long numVertices; unsigned long numEdges; unsigned long *vertices; unsigned long *edges; double minMatchCost; unsigned long newVertex; unsigned long newEdge; unsigned long refCount; struct VertexMap { unsigned long v1; unsigned long v2; } *mapping; unsigned long mappingIndex1; unsigned long mappingIndex2; unsigned char used; struct _instance *parentInstance; } *instance; struct _instance_list_node *next; } *head; } *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; } *sub; struct _sub_list_node *next; } *head; } *subList; unsigned long incrementNum; unsigned long numPosVertices; unsigned long numPosEdges; unsigned long numNegVertices; unsigned long numNegEdges; unsigned long startPosVertexIndex; unsigned long startPosEdgeIndex; unsigned long startNegVertexIndex; unsigned long startNegEdgeIndex; double numPosEgs; double numNegEgs; } *increment; struct _increment_list_node *next; } *

return_type: unsigned long

user_defined_types: struct _sub_list_node { struct Substructure *sub; struct _sub_list_node *next; }

user_defined_types: struct Substructure { struct Graph *definition; unsigned long numInstances; unsigned long numExamples; struct InstanceList *instances; unsigned long numNegInstances; unsigned long numNegExamples; struct InstanceList *negInstances; double value; unsigned char recursive; unsigned long recursiveEdgeLabel; double posIncrementValue; double negIncrementValue; }

user_defined_types: struct InstanceList { struct _instance_list_node *head; }

user_defined_types: struct _instance_list_node { struct _instance *instance; struct _instance_list_node *next; }


GetStartVertexIndex

decompiled_code:
__int64 __fastcall GetStartVertexIndex(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rdx
__int64 result; // rax

v4 = **(_QWORD **)(a2 + 1752);
if ( !v4 )
{
puts("Error GetStartVertexIndex: increment list empty");
exit(1);
}
do
{
v5 = v4;
v4 = *(_QWORD *)(v4 + 8);
}
while ( v4 );
if ( a3 == 1 )
result = *(_QWORD *)(*(_QWORD *)v5 + 48LL);
else
result = *(_QWORD *)(*(_QWORD *)v5 + 64LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rdx
__int64 result; // rax

v4 = **(_QWORD **)(a2 + 1752);
if ( !v4 )
{
puts("Error GetStartVertexIndex: increment list empty");
exit(1);
}
do
{
v5 = v4;
v4 = *(_QWORD *)(v4 + 8);
}
while ( v4 );
if ( a3 == 1 )
result = *(_QWORD *)(*(_QWORD *)v5 + 48LL);
else
result = *(_QWORD *)(*(_QWORD *)v5 + 64LL);
return result;
}

original_code:
ULONG GetStartVertexIndex(ULONG incrementNum, Parameters *parameters,
                          ULONG graphType)
{
   IncrementListNode *incNodePtr = parameters->incrementList->head;
   if (incNodePtr == ((void *)0))
   {
      printf("Error GetStartVertexIndex: increment list empty\n");
      exit(1);
   }
   while (incNodePtr->next != ((void *)0))
      incNodePtr = incNodePtr->next;
   if (graphType == 1)
      return incNodePtr->increment->startPosVertexIndex;
   else
      return incNodePtr->increment->startNegVertexIndex;
}

canonical_original_code:
unsigned long GetStartVertexIndex(unsigned long incrementNum, struct Parameters *parameters, unsigned long graphType)
{
   struct _increment_list_node *incNodePtr = parameters->incrementList->head;
   if (incNodePtr == ((void *)0))
   {
      printf("Error GetStartVertexIndex: increment list empty\n");
      exit(1);
   }
   while (incNodePtr->next != ((void *)0))
      incNodePtr = incNodePtr->next;
   if (graphType == 1)
      return incNodePtr->increment->startPosVertexIndex;
   else
      return incNodePtr->increment->startNegVertexIndex;
}

variable_types:
incrementNum
unsigned long

variable_types:
graphType
unsigned long

user_defined_types: struct Graph { unsigned long numVertices; unsigned long numEdges; struct Vertex *vertices; struct Edge *edges; unsigned long vertexListSize; unsigned long edgeListSize; }

user_defined_types: struct Vertex { unsigned long label; unsigned long numEdges; unsigned long *edges; unsigned long map; unsigned char used; }

user_defined_types: struct Edge { unsigned long vertex1; unsigned long vertex2; unsigned long label; unsigned char directed; unsigned char used; unsigned char spansIncrement; unsigned char validPath; }

user_defined_types: struct Label { unsigned char labelType; union { char *stringLabel; double numericLabel; } labelValue; unsigned char used; }

user_defined_types: struct avl_node { struct avl_node *avl_link[2]; void *avl_data; char avl_balance; }

user_defined_types: struct libavl_allocator { void *(*libavl_malloc)(struct libavl_allocator *, unsigned long libavl_size); void (*libavl_free)(struct libavl_allocator *, void *libavl_block); }