usage

decompiled_code:
int usage()
{
puts("Usage: \n");
puts("cte <samples_file> <depth> <max_c> <epsilon> <size_resample1> <size_resample2> <number_of_resamples>\n");
puts("<samples_file> is the file with the samples ie. ./samples.txt");
puts("<depth> is the depth of tree, or the size of the words to consider ie. 6");
puts("<max_c> is a c that is used as the maximum cost, a Tau with this cost should be the root tree. ie. 3.5");
puts("<epsilon> the minimum difference between two costs, to calculate the champion set. ie. 0.01");
puts("<size_resample1> the size of the small resamples, in percentage ie. 10");
puts("<size_resample2> the size of the big resamples, in percentage ie. 50");
return printf("<number_of_resamples> the number of resamples to create\n\n ");
}

canonical_decompiled_code:
int func0()
{
puts("Usage: \n");
puts("cte <samples_file> <depth> <max_c> <epsilon> <size_resample1> <size_resample2> <number_of_resamples>\n");
puts("<samples_file> is the file with the samples ie. ./samples.txt");
puts("<depth> is the depth of tree, or the size of the words to consider ie. 6");
puts("<max_c> is a c that is used as the maximum cost, a Tau with this cost should be the root tree. ie. 3.5");
puts("<epsilon> the minimum difference between two costs, to calculate the champion set. ie. 0.01");
puts("<size_resample1> the size of the small resamples, in percentage ie. 10");
puts("<size_resample2> the size of the big resamples, in percentage ie. 50");
return printf("<number_of_resamples> the number of resamples to create\n\n ");
}

original_code:
void usage() {
  printf("Usage: \n\n");
  printf("cte <samples_file> <depth> <max_c> <epsilon> <size_resample1> <size_resample2> <number_of_resamples>\n\n");
  printf("<samples_file> is the file with the samples ie. ./samples.txt\n");
  printf("<depth> is the depth of tree, or the size of the words to consider ie. 6\n");
  printf("<max_c> is a c that is used as the maximum cost, a Tau with this cost should be the root tree. ie. 3.5\n");
  printf("<epsilon> the minimum difference between two costs, to calculate the champion set. ie. 0.01\n");
  printf("<size_resample1> the size of the small resamples, in percentage ie. 10\n");
  printf("<size_resample2> the size of the big resamples, in percentage ie. 50\n");
  printf("<number_of_resamples> the number of resamples to create\n\n ");
}


repo: meiao/cte

decompiled_code:
void __fastcall __noreturn fatal_error(int status)
{
switch ( status )
{
case 2:
fwrite("Wrong number of arguments given.\n", 1uLL, 0x21uLL, stderr);
usage();
break;
case 3:
fwrite(
"There was no object in the omega set.\n"
"Most likely the most frequent word appeared only once on the/each sample.\n",
1uLL,
0x70uLL,
stderr);
break;
case 1:
fwrite("The file containing the alphabet could not be found.\n", 1uLL, 0x35uLL, stderr);
break;
}
exit(status);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(int status)
{
switch ( status )
{
case 2:
fwrite("Wrong number of arguments given.\n", 1uLL, 0x21uLL, stderr);
func0();
break;
case 3:
fwrite(
"There was no object in the omega set.\n"
"Most likely the most frequent word appeared only once on the/each sample.\n",
1uLL,
0x70uLL,
stderr);
break;
case 1:
fwrite("The file containing the alphabet could not be found.\n", 1uLL, 0x35uLL, stderr);
break;
}
exit(status);
}

original_code:
void fatal_error(enum Error_code code) {
  switch (code) {
  case FILE_NOT_FOUND:
    fprintf(stderr, "The file containing the alphabet could not be found.\n");
    break;
  case WRONG_ARGUMENTS:
    fprintf(stderr, "Wrong number of arguments given.\n");
    usage();
    break;
  case UNABLE_TO_RESAMPLE:
    fprintf(stderr, "There was no object in the omega set.\nMost likely the most frequent word appeared only once on the/each sample.\n");
    break;
  }
  exit(code);
}

variable_types: enum Error_code { FILE_NOT_FOUND=1, WRONG_ARGUMENTS=2, UNABLE_TO_RESAMPLE=3 }

return_type: void


decompiled_code:
void __fastcall free_lines(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (char *)ptr + 8;
do
{
free(v2);
v3 += 8;
v2 = (void *)*((_QWORD *)v3 - 1);
}
while ( v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (char *)ptr + 8;
do
{
free(v2);
v3 += 8;
v2 = (void *)*((_QWORD *)v3 - 1);
}
while ( v2 );
}
free(ptr);
}

original_code:
void free_lines(char** lines) {
  for (int i = 0; lines[i] != ((void *)0); i++) {
    free(lines[i]);
  }
  free(lines);
  lines = ((void *)0);
}

canonical_original_code:
void free_lines(char **lines) {
  for (int i = 0; lines[i] != ((void *)0); i++) {
    free(lines[i]);
  }
  free(lines);
  lines = ((void *)0);
}

variable_types:
lines
char **

variable_types: i int


decompiled_code:
void __fastcall assert_equals(__int64 a1, __int64 a2, const char *a3)
{
if ( a2 != a1 )
{
fprintf(stderr, a3);
exit(1);
}
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1, __int64 a2, const char *a3)
{
if ( a2 != a1 )
{
fprintf(stderr, a3);
exit(1);
}
}

original_code:
void assert_equals(void* arg1, void* arg2, char* error_message) {
  if (arg1 == arg2) {
    return;
  }
  fprintf(stderr, error_message);
  exit(1);
}

canonical_original_code:
void assert_equals(void *arg1, void *arg2, char *error_message) {
  if (arg1 == arg2) {
    return;
  }
  fprintf(stderr, error_message);
  exit(1);
}


decompiled_code:
void __fastcall assert_equals_int(unsigned int a1, unsigned int a2, const char *a3)
{
if ( a1 != a2 )
{
fprintf(stderr, a3);
fprintf(stderr, "expected: %d\nactual: %d\n", a1, a2);
exit(1);
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned int a1, unsigned int a2, const char *a3)
{
if ( a1 != a2 )
{
fprintf(stderr, a3);
fprintf(stderr, "expected: %d\nactual: %d\n", a1, a2);
exit(1);
}
}

original_code:
void assert_equals_int(int expected, int actual, char* error_message) {
  if (expected == actual) {
    return;
  }
  fprintf(stderr, error_message);
  fprintf(stderr, "expected: %d\nactual: %d\n", expected, actual);
  exit(1);
}

canonical_original_code:
void assert_equals_int(int expected, int actual, char *error_message) {
  if (expected == actual) {
    return;
  }
  fprintf(stderr, error_message);
  fprintf(stderr, "expected: %d\nactual: %d\n", expected, actual);
  exit(1);
}

variable_types: expected int

variable_types: actual int


decompiled_code:
void __fastcall assert_near_float(char *format, double a2, double a3)
{
double v3; // xmm2_8
float v4; // [rsp+8h] [rbp-10h]

v3 = a2;
v4 = *(float *)&a2;
*(float *)&a2 = *(float *)&a2 - 0.000099999997;
if ( *(float *)&a3 <= *(float *)&a2
|| (*(float *)&v3 = *(float *)&v3 + 0.000099999997, *(float *)&v3 <= *(float *)&a3) )
{
fprintf(stderr, format, a2, a3, v3);
fprintf(stderr, "expected: %f\nactual: %f\n", v4, *(float *)&a3);
exit(1);
}
}

canonical_decompiled_code:
void __fastcall func2(char *format, double a2, double a3)
{
double v3; // xmm2_8
float v4; // [rsp+8h] [rbp-10h]

v3 = a2;
v4 = *(float *)&a2;
*(float *)&a2 = *(float *)&a2 - 0.000099999997;
if ( *(float *)&a3 <= *(float *)&a2
|| (*(float *)&v3 = *(float *)&v3 + 0.000099999997, *(float *)&v3 <= *(float *)&a3) )
{
fprintf(stderr, format, a2, a3, v3);
fprintf(stderr, "expected: %f\nactual: %f\n", v4, *(float *)&a3);
exit(1);
}
}

original_code:
void assert_near_float(float expected, float actual, char* error_message) {
  if ((expected - 0.0001f < actual) && (actual < expected + 0.0001f)) {
    return;
  }
  fprintf(stderr, error_message);
  fprintf(stderr, "expected: %f\nactual: %f\n", expected, actual);
  exit(1);
}

canonical_original_code:
void assert_near_float(float expected, float actual, char *error_message) {
  if ((expected - 0.0001f < actual) && (actual < expected + 0.0001f)) {
    return;
  }
  fprintf(stderr, error_message);
  fprintf(stderr, "expected: %f\nactual: %f\n", expected, actual);
  exit(1);
}

variable_types: expected float

variable_types: actual float


original_code:
int accept_tree(char** resample, Tau* current_tree, Tau* next_tree, int depth, int number_resamples) {
  double db[number_resamples];
  char* sample[2];
  sample[1] = ((void *)0);
  for (int i = 0; i < number_resamples; i++) {
    db[i] = 0.0;
    sample[0] = resample[i];
    db[i] += delta_tau(sample, current_tree, next_tree, depth);
    sample[0] = resample[number_resamples + i];
    db[i] -= delta_tau(sample, current_tree, next_tree, depth);
  }
  double d_avg = 0.0;
  double d_squared = 0.0;
  for (int i = 0; i< number_resamples; i++) {
    d_avg += db[i];
    d_squared += db[i] * db[i];
  }
  d_avg = d_avg / number_resamples;
  double Sd = sqrt((d_squared - d_avg * number_resamples)/(number_resamples - 1));
  double t_b1 = d_avg / (Sd / sqrt(number_resamples));
  printf("t_b1=%g tree=", t_b1);
  print_Tau(current_tree);
  printf("\n");
  return 0;
}

canonical_original_code:
int accept_tree(char **resample, struct tau *current_tree, struct tau *next_tree, int depth, int number_resamples) {
  double db[-1];
  char *sample[2];
  sample[1] = ((void *)0);
  for (int i = 0; i < number_resamples; i++) {
    db[i] = 0.0;
    sample[0] = resample[i];
    db[i] += delta_tau(sample, current_tree, next_tree, depth);
    sample[0] = resample[number_resamples + i];
    db[i] -= delta_tau(sample, current_tree, next_tree, depth);
  }
  double d_avg = 0.0;
  double d_squared = 0.0;
  for (int i = 0; i< number_resamples; i++) {
    d_avg += db[i];
    d_squared += db[i] * db[i];
  }
  d_avg = d_avg / number_resamples;
  double Sd = sqrt((d_squared - d_avg * number_resamples)/(number_resamples - 1));
  double t_b1 = d_avg / (Sd / sqrt(number_resamples));
  printf("t_b1=%g tree=", t_b1);
  print_Tau(current_tree);
  printf("\n");
  return 0;
}

variable_types:
resample
char **

variable_types: struct tau { struct tau_item { char *string; double probability; struct tau_item *next; } *item; double c; } *

variable_types: depth int

variable_types:
db
double [-1]

variable_types:
sample
char *[2]

variable_types: Sd double

return_type: int

user_defined_types: struct tau { struct tau_item *item; double c; }


bootstrap

original_code:
Tau* bootstrap(char** resample, Champion_item* champion_set, int depth, int number_resamples) {
  int number_of_trees = 0;
  Tau** champion_trees;
  {
    Champion_item* item = champion_set;
    while (item != ((void *)0)) {
      number_of_trees++;
      item = item->next;
    }
    champion_trees = (Tau**) malloc(number_of_trees * sizeof(Tau*));
    item = champion_set;
    for (int i = number_of_trees - 1; i >= 0; i--) {
      champion_trees[i] = item->tau;
      item = item->next;
    }
  }
  for (int i = 0; i < number_of_trees - 1; i++) {
    if(accept_tree(resample, champion_trees[i], champion_trees[i+1], depth, number_resamples)) {
      free(champion_trees);
      return champion_trees[i];
    }
  }
  free(champion_trees);
  return champion_set->tau;
}

canonical_original_code:
struct tau *bootstrap(char **resample, struct champion_item *champion_set, int depth, int number_resamples) {
  int number_of_trees = 0;
  struct tau **champion_trees;
  {
    struct champion_item *item = champion_set;
    while (item != ((void *)0)) {
      number_of_trees++;
      item = item->next;
    }
    champion_trees = (struct tau **) malloc(number_of_trees * sizeof(struct tau *));
    item = champion_set;
    for (int i = number_of_trees - 1; i >= 0; i--) {
      champion_trees[i] = item->tau;
      item = item->next;
    }
  }
  for (int i = 0; i < number_of_trees - 1; i++) {
    if(accept_tree(resample, champion_trees[i], champion_trees[i+1], depth, number_resamples)) {
      free(champion_trees);
      return champion_trees[i];
    }
  }
  free(champion_trees);
  return champion_set->tau;
}

variable_types: struct champion_item { struct tau *tau; struct champion_item *next; } *

variable_types: struct tau { struct tau_item { char *string; double probability; struct tau_item *next; } *item; double c; } **

variable_types: struct champion_item { struct tau { struct tau_item { char *string; double probability; struct tau_item *next; } *item; double c; } *tau; struct champion_item *next; } *


decompiled_code:
__int64 __fastcall free_omega(__int64 a1)
{
__int64 v1; // rbp
__int64 result; // rax

if ( a1 )
{
v1 = *(_QWORD *)(a1 + 8);
free(*(void **)a1);
free((void *)a1);
result = free_omega(v1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rbp
__int64 result; // rax

if ( a1 )
{
v1 = *(_QWORD *)(a1 + 8);
free(*(void **)a1);
free((void *)a1);
result = func0(v1);
}
return result;
}

original_code:
void free_omega(Omega* omega) {
  if (omega == ((void *)0)) return;
  Omega* next = omega->next;
  free(omega->word);
  free(omega);
  free_omega(next);
}

canonical_original_code:
void free_omega(struct omega *omega) {
  if (omega == ((void *)0)) return;
  struct omega *next = omega->next;
  free(omega->word);
  free(omega);
  free_omega(next);
}

variable_types: struct omega { char *word; struct omega *next; } *


repo: meibenjin/CloudIndex

decompiled_code:
int __fastcall gen_range(int a1, int a2, float a3)
{
float v3; // xmm1_4
__int64 i; // rbx
int v5; // edx
int v7[3]; // [rsp+8h] [rbp-40h]
int v8[13]; // [rsp+14h] [rbp-34h]

v3 = a3 * (float)a2;
printf("%d %d ", 2LL, 1LL);
for ( i = 0LL; i != 3; ++i )
{
v5 = a1 + rand() % ((int)(float)((float)a2 - v3) - a1);
v8[i] = v5;
v7[i] = (int)v3 + v5 - 1;
}
printf("%d ", (unsigned int)v8[0]);
printf("%d ", (unsigned int)v8[1]);
printf("%d ", (unsigned int)v8[2]);
printf("%d ", (unsigned int)v7[0]);
printf("%d ", (unsigned int)v7[1]);
printf("%d ", (unsigned int)v7[2]);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func0(int a1, int a2, float a3)
{
float v3; // xmm1_4
__int64 i; // rbx
int v5; // edx
int v7[3]; // [rsp+8h] [rbp-40h]
int v8[13]; // [rsp+14h] [rbp-34h]

v3 = a3 * (float)a2;
printf("%d %d ", 2LL, 1LL);
for ( i = 0LL; i != 3; ++i )
{
v5 = a1 + rand() % ((int)(float)((float)a2 - v3) - a1);
v8[i] = v5;
v7[i] = (int)v3 + v5 - 1;
}
printf("%d ", (unsigned int)v8[0]);
printf("%d ", (unsigned int)v8[1]);
printf("%d ", (unsigned int)v8[2]);
printf("%d ", (unsigned int)v7[0]);
printf("%d ", (unsigned int)v7[1]);
printf("%d ", (unsigned int)v7[2]);
return putchar(10);
}

original_code:
void gen_range(int min, int max, float p) {
 int low, high, step, i, randint;
    step = max * p;
    max = max - max * p;
    printf("%d %d ", 2, 1);
    int rlow[3], rhigh[3];
 for (i = 0; i < 3; i++) {
  randint = rand();
  low = (randint % (max - min)) + min;
  high = low + step - 1 ;
        rlow[i] = low;
        rhigh[i] = high;
 }
 for (i = 0; i < 3; i++)
        printf("%d ", rlow[i]);
 for (i = 0; i < 3; i++)
        printf("%d ", rhigh[i]);
 printf("\n");
}

canonical_original_code:
void gen_range(int min, int max, float p) {
 int low; int high; int step; int i; int randint;
    step = max * p;
    max = max - max * p;
    printf("%d %d ", 2, 1);
    int rlow[3]; int rhigh[3];
 for (i = 0; i < 3; i++) {
  randint = rand();
  low = (randint % (max - min)) + min;
  high = low + step - 1 ;
        rlow[i] = low;
        rhigh[i] = high;
 }
 for (i = 0; i < 3; i++)
        printf("%d ", rlow[i]);
 for (i = 0; i < 3; i++)
        printf("%d ", rhigh[i]);
 printf("\n");
}

variable_types: min int

variable_types: max int

variable_types: p float

variable_types: low int

variable_types: high int

variable_types: step int

variable_types: randint int

variable_types:
rlow
int [3]

variable_types:
rhigh
int [3]


original_code:
long get_elasped_time(struct timespec start, struct timespec end) {
 return 1000000000L * (end.tv_sec - start.tv_sec)
   + (end.tv_nsec - start.tv_nsec);
}

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types:
end
struct timespec

return_type: long


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
performance_test(argv[1]);
return 0;
}

original_code:
int main(int argc, char **argv) {
    performance_test(argv[1]);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


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

if ( !a1 )
return puts("set_node_capacity: node_ptr is null pointer.");
*(_DWORD *)(a1 + 84) = a2;
return result;
}

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

if ( !a1 )
return puts("set_node_capacity: node_ptr is null pointer.");
*(_DWORD *)(a1 + 84) = a2;
return result;
}

original_code:
void set_node_capacity(node_info *info_ptr, int c) {
 if (!info_ptr) {
  printf("set_node_capacity: node_ptr is null pointer.\n");
  return;
 }
    info_ptr->capacity = c;
}

canonical_original_code:
void set_node_capacity(struct node_info *info_ptr, int c) {
 if (!info_ptr) {
  printf("set_node_capacity: node_ptr is null pointer.\n");
  return;
 }
    info_ptr->capacity = c;
}

variable_types: struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } *

variable_types: c int

user_defined_types: struct node_info { char ip[20]; int cluster_id; struct interval region[3]; struct coordinate node_id; unsigned int capacity; }


decompiled_code:
__int64 __fastcall get_node_capacity(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, __int64 a17)
{
return HIDWORD(a17);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, __int64 a17)
{
return HIDWORD(a17);
}

original_code:
int get_node_capacity(node_info info) {
    return info.capacity;
}

canonical_original_code:
int get_node_capacity(struct node_info info) {
    return info.capacity;
}

variable_types: struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; }


decompiled_code:
int __fastcall set_node_ip(char *a1, const char *a2)
{
int result; // eax

if ( a1 )
result = (unsigned int)strncpy(a1, a2, 0x14uLL);
else
result = puts("set_node_ip: node_ptr is null pointer.");
return result;
}

canonical_decompiled_code:
int __fastcall func3(char *a1, const char *a2)
{
int result; // eax

if ( a1 )
result = (unsigned int)strncpy(a1, a2, 0x14uLL);
else
result = puts("set_node_ip: node_ptr is null pointer.");
return result;
}

original_code:
void set_node_ip(node_info *info_ptr, const char *ip) {
 if (!info_ptr) {
  printf("set_node_ip: node_ptr is null pointer.\n");
  return;
 }
 strncpy(info_ptr->ip, ip, 20);
}

canonical_original_code:
void set_node_ip(struct node_info *info_ptr, char *ip) {
 if (!info_ptr) {
  printf("set_node_ip: node_ptr is null pointer.\n");
  return;
 }
 strncpy(info_ptr->ip, ip, 20);
}

variable_types:
ip
char *

user_defined_types: struct coordinate { int x; int y; int z; }

user_defined_types: struct interval { double low; double high; }


decompiled_code:
int __fastcall get_node_ip(char *a1, int a2, int a3, int a4, int a5, int a6, char src)
{
int result; // eax

if ( a1 )
result = (unsigned int)strncpy(a1, &src, 0x14uLL);
else
result = puts("get_node_ip: ip is null pointer.");
return result;
}

canonical_decompiled_code:
int __fastcall func4(char *a1, int a2, int a3, int a4, int a5, int a6, char src)
{
int result; // eax

if ( a1 )
result = (unsigned int)strncpy(a1, &src, 0x14uLL);
else
result = puts("get_node_ip: ip is null pointer.");
return result;
}

original_code:
void get_node_ip(node_info info, char *ip) {
 if (ip == ((void *)0)) {
  printf("get_node_ip: ip is null pointer.\n");
  return;
 }
 strncpy(ip, info.ip, 20);
}

canonical_original_code:
void get_node_ip(struct node_info info, char *ip) {
 if (ip == ((void *)0)) {
  printf("get_node_ip: ip is null pointer.\n");
  return;
 }
 strncpy(ip, info.ip, 20);
}


decompiled_code:
int __fastcall set_node_id(_DWORD *a1, int a2, int a3, int a4)
{
int result; // eax

if ( !a1 )
return puts("set_coordinate: node_ptr is null pointer.");
a1[18] = a2;
a1[19] = a3;
a1[20] = a4;
return result;
}

canonical_decompiled_code:
int __fastcall func5(_DWORD *a1, int a2, int a3, int a4)
{
int result; // eax

if ( !a1 )
return puts("set_coordinate: node_ptr is null pointer.");
a1[18] = a2;
a1[19] = a3;
a1[20] = a4;
return result;
}

original_code:
void set_node_id(node_info *info_ptr, int x, int y, int z) {
 if (!info_ptr) {
  printf("set_coordinate: node_ptr is null pointer.\n");
  return;
 }
 info_ptr->node_id.x = x;
 info_ptr->node_id.y = y;
 info_ptr->node_id.z = z;
}

canonical_original_code:
void set_node_id(struct node_info *info_ptr, int x, int y, int z) {
 if (!info_ptr) {
  printf("set_coordinate: node_ptr is null pointer.\n");
  return;
 }
 info_ptr->node_id.x = x;
 info_ptr->node_id.y = y;
 info_ptr->node_id.z = z;
}

variable_types: x int

variable_types: y int

variable_types: z int


decompiled_code:
__int64 __fastcall get_node_id(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, __int64 a16)
{
return a16;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, __int64 a16)
{
return a16;
}

original_code:
struct coordinate get_node_id(node_info info) {
 return info.node_id;
}

canonical_original_code:
struct coordinate get_node_id(struct node_info info) {
 return info.node_id;
}

variable_types: struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate node_id; unsigned int capacity; }

return_type: struct coordinate { int x; int y; int z; }


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

if ( !a1 )
return puts("set_cluster_id: node_ptr is null pointer.");
*(_DWORD *)(a1 + 20) = a2;
return result;
}

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

if ( !a1 )
return puts("set_cluster_id: node_ptr is null pointer.");
*(_DWORD *)(a1 + 20) = a2;
return result;
}

original_code:
void set_cluster_id(node_info *info_ptr, int cluster_id) {
 if (!info_ptr) {
  printf("set_cluster_id: node_ptr is null pointer.\n");
  return;
 }
 info_ptr->cluster_id = cluster_id;
}

canonical_original_code:
void set_cluster_id(struct node_info *info_ptr, int cluster_id) {
 if (!info_ptr) {
  printf("set_cluster_id: node_ptr is null pointer.\n");
  return;
 }
 info_ptr->cluster_id = cluster_id;
}


decompiled_code:
int __fastcall init_node_info(__int64 a1)
{
int result; // eax

if ( !a1 )
return puts("init_node_info: node_ptr is null pointer.");
set_node_ip((char *)a1, "0.0.0.0");
set_node_id((_DWORD *)a1, -1, -1, -1);
set_cluster_id(a1, -1);
result = set_node_capacity(a1, 0);
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)(a1 + 40) = 0LL;
*(_QWORD *)(a1 + 48) = 0LL;
*(_QWORD *)(a1 + 56) = 0LL;
*(_QWORD *)(a1 + 64) = 0LL;
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
int result; // eax

if ( !a1 )
return puts("init_node_info: node_ptr is null pointer.");
func3((char *)a1, "0.0.0.0");
func5((_DWORD *)a1, -1, -1, -1);
func7(a1, -1);
result = func1(a1, 0);
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)(a1 + 40) = 0LL;
*(_QWORD *)(a1 + 48) = 0LL;
*(_QWORD *)(a1 + 56) = 0LL;
*(_QWORD *)(a1 + 64) = 0LL;
return result;
}

original_code:
void init_node_info(node_info *info_ptr) {
 if (!info_ptr) {
  printf("init_node_info: node_ptr is null pointer.\n");
  return;
 }
 set_node_ip(info_ptr, "0.0.0.0");
 set_node_id(info_ptr, -1, -1, -1);
 set_cluster_id(info_ptr, -1);
    set_node_capacity(info_ptr, 0);
 int i;
 for(i = 0; i < 3; ++i){
  info_ptr->region[i].low = 0;
  info_ptr->region[i].high = 0;
 }
}

canonical_original_code:
void init_node_info(struct node_info *info_ptr) {
 if (!info_ptr) {
  printf("init_node_info: node_ptr is null pointer.\n");
  return;
 }
 set_node_ip(info_ptr, "0.0.0.0");
 set_node_id(info_ptr, -1, -1, -1);
 set_cluster_id(info_ptr, -1);
    set_node_capacity(info_ptr, 0);
 int i;
 for(i = 0; i < 3; ++i){
  info_ptr->region[i].low = 0;
  info_ptr->region[i].high = 0;
 }
}

variable_types: i int


decompiled_code:
int __fastcall init_torus_node(__int64 a1)
{
int result; // eax

if ( !a1 )
return puts("init_torus_node: node_ptr is null pointer.");
result = init_node_info(a1);
*(_DWORD *)(a1 + 92) = 0;
*(_DWORD *)(a1 + 88) = 0;
*(_QWORD *)(a1 + 96) = 0LL;
*(_QWORD *)(a1 + 104) = 0LL;
*(_QWORD *)(a1 + 112) = 0LL;
*(_QWORD *)(a1 + 120) = 0LL;
*(_QWORD *)(a1 + 128) = 0LL;
*(_QWORD *)(a1 + 136) = 0LL;
return result;
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1)
{
int result; // eax

if ( !a1 )
return puts("init_torus_node: node_ptr is null pointer.");
result = func8(a1);
*(_DWORD *)(a1 + 92) = 0;
*(_DWORD *)(a1 + 88) = 0;
*(_QWORD *)(a1 + 96) = 0LL;
*(_QWORD *)(a1 + 104) = 0LL;
*(_QWORD *)(a1 + 112) = 0LL;
*(_QWORD *)(a1 + 120) = 0LL;
*(_QWORD *)(a1 + 128) = 0LL;
*(_QWORD *)(a1 + 136) = 0LL;
return result;
}

original_code:
void init_torus_node(torus_node *node_ptr) {
 if (!node_ptr) {
  printf("init_torus_node: node_ptr is null pointer.\n");
  return;
 }
    init_node_info(&node_ptr->info);
    node_ptr->neighbors_num = 0;
    node_ptr->is_leader = 0;
    int i;
    for(i = 0; i < 6; i++) {
        node_ptr->neighbors[i] = ((void *)0);
    }
}

canonical_original_code:
void init_torus_node(struct torus_node *node_ptr) {
 if (!node_ptr) {
  printf("init_torus_node: node_ptr is null pointer.\n");
  return;
 }
    init_node_info(&node_ptr->info);
    node_ptr->neighbors_num = 0;
    node_ptr->is_leader = 0;
    int i;
    for(i = 0; i < 6; i++) {
        node_ptr->neighbors[i] = ((void *)0);
    }
}

variable_types: struct torus_node { struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } info; int is_leader; int neighbors_num; struct neighbor_node { struct node_info *info; struct neighbor_node *next; } *neighbors[6]; } *

user_defined_types: struct torus_node { struct node_info info; int is_leader; int neighbors_num; struct neighbor_node *neighbors[6]; }


decompiled_code:
__int64 __fastcall get_cluster_id(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, __int64 a9)
{
return HIDWORD(a9);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, __int64 a9)
{
return HIDWORD(a9);
}

original_code:
int get_cluster_id(node_info info) {
 return info.cluster_id;
}

canonical_original_code:
int get_cluster_id(struct node_info info) {
 return info.cluster_id;
}


decompiled_code:
__int64 __fastcall add_neighbor_info(__int64 a1, int a2, __int64 a3)
{
_QWORD *v4; // rax
_QWORD *v5; // rbx
__int64 v6; // rax
__int64 result; // rax
_QWORD *v8; // rax

v4 = malloc(0x10uLL);
if ( v4 )
{
v5 = v4;
*v4 = a3;
v4[1] = 0LL;
if ( *(_QWORD *)(a1 + 8LL * a2 + 96) )
{
LABEL_3:
v6 = *(_QWORD *)(a1 + 8LL * a2 + 96);
v5[1] = *(_QWORD *)(v6 + 8);
*(_QWORD *)(v6 + 8) = v5;
return 0LL;
}
v8 = malloc(0x10uLL);
*(_QWORD *)(a1 + 8LL * a2 + 96) = v8;
if ( v8 )
{
*v8 = 0LL;
v8[1] = 0LL;
goto LABEL_3;
}
puts("add_neighbor_info: malloc for neighbor node info failed.");
result = 0xFFFFFFFFLL;
}
else
{
puts("add_neighbor_info: malloc neighbor_node failed");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2, __int64 a3)
{
_QWORD *v4; // rax
_QWORD *v5; // rbx
__int64 v6; // rax
__int64 result; // rax
_QWORD *v8; // rax

v4 = malloc(0x10uLL);
if ( v4 )
{
v5 = v4;
*v4 = a3;
v4[1] = 0LL;
if ( *(_QWORD *)(a1 + 8LL * a2 + 96) )
{
LABEL_3:
v6 = *(_QWORD *)(a1 + 8LL * a2 + 96);
v5[1] = *(_QWORD *)(v6 + 8);
*(_QWORD *)(v6 + 8) = v5;
return 0LL;
}
v8 = malloc(0x10uLL);
*(_QWORD *)(a1 + 8LL * a2 + 96) = v8;
if ( v8 )
{
*v8 = 0LL;
v8[1] = 0LL;
goto LABEL_3;
}
puts("add_neighbor_info: malloc for neighbor node info failed.");
result = 0xFFFFFFFFLL;
}
else
{
puts("add_neighbor_info: malloc neighbor_node failed");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int add_neighbor_info(torus_node *node_ptr, int d, node_info *neighbor_ptr) {
    struct neighbor_node *nn_ptr;
    nn_ptr = (struct neighbor_node *) malloc(sizeof(struct neighbor_node));
    if(nn_ptr == ((void *)0)) {
        printf("add_neighbor_info: malloc neighbor_node failed\n");
        return FALSE;
    }
    nn_ptr->info = neighbor_ptr;
    nn_ptr->next = ((void *)0);
    if(node_ptr->neighbors[d] == ((void *)0)) {
        node_ptr->neighbors[d] = (struct neighbor_node*) malloc(sizeof(struct neighbor_node));
        if(node_ptr->neighbors[d] == ((void *)0)) {
            printf("add_neighbor_info: malloc for neighbor node info failed.\n");
            return FALSE;
        }
        node_ptr->neighbors[d]->info = ((void *)0);
        node_ptr->neighbors[d]->next = ((void *)0);
    }
    nn_ptr->next = node_ptr->neighbors[d]->next;
    node_ptr->neighbors[d]->next = nn_ptr;
    return TRUE;
}

canonical_original_code:
int add_neighbor_info(struct torus_node *node_ptr, int d, struct node_info *neighbor_ptr) {
    struct neighbor_node *nn_ptr;
    nn_ptr = (struct neighbor_node *) malloc(sizeof(struct neighbor_node));
    if(nn_ptr == ((void *)0)) {
        printf("add_neighbor_info: malloc neighbor_node failed\n");
        return FALSE;
    }
    nn_ptr->info = neighbor_ptr;
    nn_ptr->next = ((void *)0);
    if(node_ptr->neighbors[d] == ((void *)0)) {
        node_ptr->neighbors[d] = (struct neighbor_node *) malloc(sizeof(struct neighbor_node));
        if(node_ptr->neighbors[d] == ((void *)0)) {
            printf("add_neighbor_info: malloc for neighbor node info failed.\n");
            return FALSE;
        }
        node_ptr->neighbors[d]->info = ((void *)0);
        node_ptr->neighbors[d]->next = ((void *)0);
    }
    nn_ptr->next = node_ptr->neighbors[d]->next;
    node_ptr->neighbors[d]->next = nn_ptr;
    return TRUE;
}

variable_types: d int

variable_types: struct neighbor_node { struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } *info; struct neighbor_node *next; } *

user_defined_types: struct neighbor_node { struct node_info *info; struct neighbor_node *next; }


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

if ( !a1 )
return puts("set_neighbors_num: node_ptr is null pointer.");
*(_DWORD *)(a1 + 92) = a2;
return result;
}

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

if ( !a1 )
return puts("set_neighbors_num: node_ptr is null pointer.");
*(_DWORD *)(a1 + 92) = a2;
return result;
}

original_code:
void set_neighbors_num(torus_node *node_ptr, int neighbors_num) {
 if (!node_ptr) {
  printf("set_neighbors_num: node_ptr is null pointer.\n");
  return;
 }
 node_ptr->neighbors_num = neighbors_num;
}

canonical_original_code:
void set_neighbors_num(struct torus_node *node_ptr, int neighbors_num) {
 if (!node_ptr) {
  printf("set_neighbors_num: node_ptr is null pointer.\n");
  return;
 }
 node_ptr->neighbors_num = neighbors_num;
}


decompiled_code:
__int64 __fastcall get_neighbors_num_d(__int64 a1, int a2)
{
__int64 v2; // rax
unsigned int v3; // edx
__int64 v4; // rax

v2 = *(_QWORD *)(a1 + 8LL * a2 + 96);
v3 = 0;
if ( v2 )
{
v4 = *(_QWORD *)(v2 + 8);
if ( v4 )
{
do
{
++v3;
v4 = *(_QWORD *)(v4 + 8);
}
while ( v4 );
}
else
{
v3 = 0;
}
}
return v3;
}

original_code:
int get_neighbors_num_d(torus_node *node_ptr, int d) {
    int count = 0;
    if(node_ptr->neighbors[d] != ((void *)0)) {
        struct neighbor_node *nn_ptr;
        nn_ptr = node_ptr->neighbors[d]->next;
        while(nn_ptr != ((void *)0)) {
            count++;
            nn_ptr = nn_ptr->next;
        }
    }
    return count;
}

canonical_original_code:
int get_neighbors_num_d(struct torus_node *node_ptr, int d) {
    int count = 0;
    if(node_ptr->neighbors[d] != ((void *)0)) {
        struct neighbor_node *nn_ptr;
        nn_ptr = node_ptr->neighbors[d]->next;
        while(nn_ptr != ((void *)0)) {
            count++;
            nn_ptr = nn_ptr->next;
        }
    }
    return count;
}

variable_types: count int


decompiled_code:
__int64 __fastcall get_neighbors_num(__int64 a1)
{
return *(unsigned int *)(a1 + 92);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
return *(unsigned int *)(a1 + 92);
}

original_code:
int get_neighbors_num(torus_node *node_ptr) {
 return node_ptr->neighbors_num;
}

canonical_original_code:
int get_neighbors_num(struct torus_node *node_ptr) {
 return node_ptr->neighbors_num;
}


decompiled_code:
__int64 __fastcall get_neighbor_by_id(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v4; // r8
_QWORD *v5; // rax
__int64 v6; // rdx

v4 = a1 + 96;
while ( 1 )
{
if ( *(_QWORD *)v4 )
{
v5 = *(_QWORD **)(*(_QWORD *)v4 + 8LL);
if ( v5 )
break;
}
LABEL_6:
v4 += 8LL;
if ( v4 == a1 + 144 )
return 0LL;
}
while ( 1 )
{
v6 = *v5;
if ( (_DWORD)a2 == *(_DWORD *)(*v5 + 72LL) && __PAIR64__(a3, HIDWORD(a2)) == *(_QWORD *)(*v5 + 76LL) )
return v6;
v5 = (_QWORD *)v5[1];
if ( !v5 )
goto LABEL_6;
}
}

original_code:
node_info *get_neighbor_by_id(torus_node *node_ptr, struct coordinate node_id){
 int d, x, y, z;
 for (d = 0; d < 6; ++d) {
        if(node_ptr->neighbors[d] != ((void *)0)) {
            struct neighbor_node *nn_ptr;
            nn_ptr = node_ptr->neighbors[d]->next;
            while(nn_ptr != ((void *)0)) {
                x = nn_ptr->info->node_id.x;
                y = nn_ptr->info->node_id.y;
                z = nn_ptr->info->node_id.z;
                if ((node_id.x == x) && (node_id.y == y) && (node_id.z == z)) {
                    return nn_ptr->info;
                }
                nn_ptr = nn_ptr->next;
            }
        }
 }
    return ((void *)0);
}

canonical_original_code:
struct node_info *get_neighbor_by_id(struct torus_node *node_ptr, struct coordinate node_id){
 int d; int x; int y; int z;
 for (d = 0; d < 6; ++d) {
        if(node_ptr->neighbors[d] != ((void *)0)) {
            struct neighbor_node *nn_ptr;
            nn_ptr = node_ptr->neighbors[d]->next;
            while(nn_ptr != ((void *)0)) {
                x = nn_ptr->info->node_id.x;
                y = nn_ptr->info->node_id.y;
                z = nn_ptr->info->node_id.z;
                if ((node_id.x == x) && (node_id.y == y) && (node_id.z == z)) {
                    return nn_ptr->info;
                }
                nn_ptr = nn_ptr->next;
            }
        }
 }
    return ((void *)0);
}

variable_types: struct torus_node { struct node_info info; int is_leader; int neighbors_num; struct neighbor_node { struct node_info *info; struct neighbor_node *next; } *neighbors[6]; } *

return_type: struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } *


decompiled_code:
void *new_torus_node()
{
void *v0; // rax
void *v1; // rbx

v0 = malloc(0x90uLL);
v1 = v0;
if ( v0 )
init_torus_node((__int64)v0);
else
puts("new_torus_node: malloc for torus node failed.");
return v1;
}

canonical_decompiled_code:
void *func16()
{
void *v0; // rax
void *v1; // rbx

v0 = malloc(0x90uLL);
v1 = v0;
if ( v0 )
func9((__int64)v0);
else
puts("new_torus_node: malloc for torus node failed.");
return v1;
}

original_code:
torus_node *new_torus_node() {
 torus_node *new_torus;
 new_torus = (torus_node *) malloc(sizeof(torus_node));
 if (new_torus == ((void *)0)) {
  printf("new_torus_node: malloc for torus node failed.\n");
  return ((void *)0);
 }
    init_torus_node(new_torus);
 return new_torus;
}

canonical_original_code:
struct torus_node *new_torus_node() {
 struct torus_node *new_torus;
 new_torus = (struct torus_node *) malloc(sizeof(torus_node));
 if (new_torus == ((void *)0)) {
  printf("new_torus_node: malloc for torus node failed.\n");
  return ((void *)0);
 }
    init_torus_node(new_torus);
 return new_torus;
}

return_type: struct torus_node { struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } info; int is_leader; int neighbors_num; struct neighbor_node { struct node_info *info; struct neighbor_node *next; } *neighbors[6]; } *


decompiled_code:
__int64 __fastcall print_node_info(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7, int a8, __int64 a9, int a10, int a11, int a12, char a13, int a14, int a15, __int64 a16, unsigned int a17)
{
unsigned int v17; // er13
unsigned int v18; // er14
unsigned int v19; // er15
char *v20; // rbx
char *v21; // rbp
int v22; // eax
int v23; // ebp
unsigned int v25; // [rsp+Ch] [rbp-43Ch]
char s[1080]; // [rsp+10h] [rbp-438h] BYREF

v25 = HIDWORD(a9);
v17 = a16;
v18 = HIDWORD(a16);
v19 = a17;
printf("[%d_%d%d%d]", HIDWORD(a9), (unsigned int)a16, HIDWORD(a16), a17);
printf("%s:", &a7);
v20 = &a7;
v21 = &a7;
do
{
printf("[%lf, %lf] ", *((double *)v21 + 3), *((double *)v21 + 4));
v21 += 16;
}
while ( v21 != &a13 );
putchar(10);
memset(s, 0, 0x400uLL);
v22 = sprintf(s, "[%d_%d%d%d]", v25, v17, v18, v19);
v23 = v22 + sprintf(&s[v22], "%s:", &a7);
do
{
v23 += sprintf(&s[v23], "[%lf, %lf] ", *((double *)v20 + 3), *((double *)v20 + 4));
v20 += 16;
}
while ( v20 != &a13 );
*(_WORD *)&s[v23] = 10;
return write_log("../logs/torus_node.log", s);
}

original_code:
void print_node_info(node_info node) {
 int i;
    int cid = node.cluster_id;
    coordinate nid = node.node_id;
    printf("[%d_%d%d%d]", cid, nid.x, nid.y, nid.z);
 printf("%s:", node.ip);
 for(i = 0; i < 3; ++i){
            printf("[%lf, %lf] ", node.region[i].low, node.region[i].high);
 }
 printf("\n");
        char buf[1024];
        memset(buf, 0, 1024);
        int len = 0;
        len = sprintf(buf, "[%d_%d%d%d]", cid, nid.x, nid.y, nid.z);
        len += sprintf(buf + len, "%s:", node.ip);
        for(i = 0; i < 3; ++i){
                len += sprintf(buf + len, "[%lf, %lf] ", node.region[i].low, node.region[i].high);
        }
        sprintf(buf+len, "\n");
        write_log("../logs/torus_node.log", buf);
}

canonical_original_code:
void print_node_info(struct node_info node) {
 int i;
    int cid = node.cluster_id;
    struct coordinate nid = node.node_id;
    printf("[%d_%d%d%d]", cid, nid.x, nid.y, nid.z);
 printf("%s:", node.ip);
 for(i = 0; i < 3; ++i){
            printf("[%lf, %lf] ", node.region[i].low, node.region[i].high);
 }
 printf("\n");
        char buf[1024];
        memset(buf, 0, 1024);
        int len = 0;
        len = sprintf(buf, "[%d_%d%d%d]", cid, nid.x, nid.y, nid.z);
        len += sprintf(buf + len, "%s:", node.ip);
        for(i = 0; i < 3; ++i){
                len += sprintf(buf + len, "[%lf, %lf] ", node.region[i].low, node.region[i].high);
        }
        sprintf(buf+len, "\n");
        write_log("../logs/torus_node.log", buf);
}

variable_types: cid int

variable_types: struct coordinate { int x; int y; int z; }

variable_types:
buf
char [1024]

variable_types: len int


decompiled_code:
__int64 __fastcall print_neighbors(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17, int a18, char a19, int a20, int a21, int a22, int a23, int a24, char a25)
{
char *v25; // rbp
__int64 result; // rax
_QWORD *i; // rbx
__int64 v28; // rdx
__int64 v29; // rcx
__int64 v30; // r8
__int64 v31; // r9

puts("neighbors:");
write_log("../logs/torus_node.log", "neighbor:\n");
v25 = &a19;
do
{
result = *(_QWORD *)v25;
if ( *(_QWORD *)v25 )
{
for ( i = *(_QWORD **)(result + 8); i; i = (_QWORD *)i[1] )
{
putchar(9);
result = print_node_info(
9LL,
(__int64)"neighbor:\n",
v28,
v29,
v30,
v31,
*(_QWORD *)*i,
*(_QWORD *)(*i + 8LL),
*(_QWORD *)(*i + 16LL),
*(_QWORD *)(*i + 24LL),
*(_QWORD *)(*i + 32LL),
*(_QWORD *)(*i + 40LL),
*(_QWORD *)(*i + 48LL),
*(_QWORD *)(*i + 56LL),
*(_QWORD *)(*i + 64LL),
*(_QWORD *)(*i + 72LL),
*(_QWORD *)(*i + 80LL));
}
}
v25 += 8;
}
while ( v25 != &a25 );
return result;
}

original_code:
void print_neighbors(torus_node node) {
    printf("neighbors:\n");
        write_log("../logs/torus_node.log", "neighbor:\n");
 int d;
 for (d = 0; d < 6; ++d) {
        if(node.neighbors[d] != ((void *)0)) {
            struct neighbor_node *nn_ptr;
            nn_ptr = node.neighbors[d]->next;
            while(nn_ptr != ((void *)0)) {
                printf("\t");
                print_node_info(*nn_ptr->info);
                nn_ptr = nn_ptr->next;
            }
        }
 }
}

canonical_original_code:
void print_neighbors(struct torus_node node) {
    printf("neighbors:\n");
        write_log("../logs/torus_node.log", "neighbor:\n");
 int d;
 for (d = 0; d < 6; ++d) {
        if(node.neighbors[d] != ((void *)0)) {
            struct neighbor_node *nn_ptr;
            nn_ptr = node.neighbors[d]->next;
            while(nn_ptr != ((void *)0)) {
                printf("\t");
                print_node_info(*nn_ptr->info);
                nn_ptr = nn_ptr->next;
            }
        }
 }
}

variable_types: struct torus_node { struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } info; int is_leader; int neighbors_num; struct neighbor_node { struct node_info *info; struct neighbor_node *next; } *neighbors[6]; }


original_code:
void print_torus_node(torus_node torus) {
 print_node_info(torus.info);
 print_neighbors(torus);
 printf("\n");
}

canonical_original_code:
void print_torus_node(struct torus_node torus) {
 print_node_info(torus.info);
 print_neighbors(torus);
 printf("\n");
}


decompiled_code:
__int64 __fastcall print_torus_leaders(const char *a1)
{
const char *v1; // rbp
int v2; // ebx
char v4[1048]; // [rsp+0h] [rbp-418h] BYREF

memset(v4, 0, 0x400uLL);
strcpy(v4, "torus leaders:[");
v1 = a1;
v2 = 15;
do
{
v2 += sprintf(&v4[v2], "%s ", v1);
v1 += 88;
}
while ( v1 != a1 + 264 );
strcpy(&v4[v2], "]\n");
return write_log("../logs/torus_node.log", v4);
}

canonical_decompiled_code:
__int64 __fastcall func20(const char *a1)
{
const char *v1; // rbp
int v2; // ebx
char v4[1048]; // [rsp+0h] [rbp-418h] BYREF

memset(v4, 0, 0x400uLL);
strcpy(v4, "torus leaders:[");
v1 = a1;
v2 = 15;
do
{
v2 += sprintf(&v4[v2], "%s ", v1);
v1 += 88;
}
while ( v1 != a1 + 264 );
strcpy(&v4[v2], "]\n");
return write_log("../logs/torus_node.log", v4);
}

original_code:
void print_torus_leaders(node_info leaders[]) {
        char buf[1024];
        memset(buf, 0, 1024);
        int len = 0, i;
        len = sprintf(buf, "torus leaders:[");
        for(i = 0; i < 3; i++) {
            len += sprintf(buf + len, "%s ", leaders[i].ip);
        }
        len += sprintf(buf + len, "]\n");
        write_log("../logs/torus_node.log", buf);
}

canonical_original_code:
void print_torus_leaders(struct node_info leaders[]) {
        char buf[1024];
        memset(buf, 0, 1024);
        int len = 0; int i;
        len = sprintf(buf, "torus leaders:[");
        for(i = 0; i < 3; i++) {
            len += sprintf(buf + len, "%s ", leaders[i].ip);
        }
        len += sprintf(buf + len, "]\n");
        write_log("../logs/torus_node.log", buf);
}

variable_types: struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } []


decompiled_code:
__int16 __fastcall init_socket_addr(__int64 a1, __int16 a2)
{
__int16 result; // ax

*(_QWORD *)(a1 + 8) = 0LL;
*(_WORD *)a1 = 2;
*(_DWORD *)(a1 + 4) = (unsigned __int16)_bswap_16(0);
result = _bswap_16(a2);
*(_WORD *)(a1 + 2) = result;
return result;
}

canonical_decompiled_code:
__int16 __fastcall func1(__int64 a1, __int16 a2)
{
__int16 result; // ax

*(_QWORD *)(a1 + 8) = 0LL;
*(_WORD *)a1 = 2;
*(_DWORD *)(a1 + 4) = (unsigned __int16)func0(0);
result = func0(a2);
*(_WORD *)(a1 + 2) = result;
return result;
}

original_code:
void init_socket_addr(struct sockaddr_in *sock_addr, int port) {
 bzero(sock_addr, sizeof(struct sockaddr_in));
 sock_addr->sin_family = 2;
 sock_addr->sin_addr.s_addr = htons(((in_addr_t) 0x00000000));
 sock_addr->sin_port = htons(port);
}

canonical_original_code:
void init_socket_addr(struct sockaddr_in *sock_addr, int port) {
 bzero(sock_addr, sizeof(struct sockaddr_in));
 sock_addr->sin_family = 2;
 sock_addr->sin_addr.s_addr = htons(((unsigned int) 0x00000000));
 sock_addr->sin_port = htons(port);
}

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

variable_types: port int

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


decompiled_code:
__int64 __fastcall set_server_ip(struct in_addr *a1, const char *a2)
{
__int64 result; // rax

if ( a2 )
{
if ( inet_aton(a2, a1 + 1) )
{
result = 0LL;
}
else
{
printf("%s: resolve destination ip failed.\n", a2);
result = 0xFFFFFFFFLL;
}
}
else
{
puts("set_server_ip: ip is null pointer.");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(struct in_addr *a1, const char *a2)
{
__int64 result; // rax

if ( a2 )
{
if ( inet_aton(a2, a1 + 1) )
{
result = 0LL;
}
else
{
printf("%s: resolve destination ip failed.\n", a2);
result = 0xFFFFFFFFLL;
}
}
else
{
puts("set_server_ip: ip is null pointer.");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int set_server_ip(struct sockaddr_in *sock_addr, const char *ip) {
 if (ip == ((void *)0)) {
  printf("set_server_ip: ip is null pointer.\n");
  return FALSE;
 }
 if (inet_aton(ip, &sock_addr->sin_addr) == 0) {
  printf("%s: resolve destination ip failed.\n", ip);
  return FALSE;
 }
 return TRUE;
}

canonical_original_code:
int set_server_ip(struct sockaddr_in *sock_addr, char *ip) {
 if (ip == ((void *)0)) {
  printf("set_server_ip: ip is null pointer.\n");
  return FALSE;
 }
 if (inet_aton(ip, &sock_addr->sin_addr) == 0) {
  printf("%s: resolve destination ip failed.\n", ip);
  return FALSE;
 }
 return TRUE;
}

variable_types:
ip
char *


decompiled_code:
__int64 __fastcall new_client_socket(const char *a1, __int16 a2)
{
unsigned int v2; // ebx
int v3; // eax
int *v5; // rax
char *v6; // rax
int optval; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF

init_socket_addr((__int64)&addr, a2);
v2 = set_server_ip((struct in_addr *)&addr, a1);
if ( v2 != -1 )
{
v3 = socket(2, 1, 0);
v2 = v3;
if ( v3 < 0 )
{
v5 = _errno_location();
v6 = strerror(*v5);
fprintf(stderr, "%s: socket()\n", v6);
v2 = -1;
}
else
{
optval = 0x8000;
setsockopt(v3, 1, 7, &optval, 4u);
if ( connect(v2, &addr, 0x10u) < 0 )
{
printf("%s: connect failed.\n", a1);
v2 = -1;
}
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1, __int16 a2)
{
unsigned int v2; // ebx
int v3; // eax
int *v5; // rax
char *v6; // rax
int optval; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF

func1((__int64)&addr, a2);
v2 = func2((struct in_addr *)&addr, a1);
if ( v2 != -1 )
{
v3 = socket(2, 1, 0);
v2 = v3;
if ( v3 < 0 )
{
v5 = _errno_location();
v6 = strerror(*v5);
fprintf(stderr, "%s: socket()\n", v6);
v2 = -1;
}
else
{
optval = 0x8000;
setsockopt(v3, 1, 7, &optval, 4u);
if ( connect(v2, &addr, 0x10u) < 0 )
{
printf("%s: connect failed.\n", a1);
v2 = -1;
}
}
}
return v2;
}

original_code:
int new_client_socket(const char *ip, int port) {
 struct sockaddr_in client_addr;
 init_socket_addr(&client_addr, port);
 if (FALSE == set_server_ip(&client_addr, ip)) {
  return FALSE;
 }
 int client_socket = socket(2, SOCK_STREAM, 0);
 if (client_socket < 0) {
  fprintf(stderr, "%s: socket()\n", strerror((*__errno_location ())));
  return FALSE;
 }
    int snd_buf = 32 * 1024;
    setsockopt(client_socket, 1, 7, (const char*)&snd_buf, sizeof(int));
 if (connect(client_socket, (struct sockaddr *) &client_addr,
   sizeof(struct sockaddr)) < 0) {
  printf("%s: connect failed.\n", ip);
  return FALSE;
 }
 return client_socket;
}

canonical_original_code:
int new_client_socket(char *ip, int port) {
 struct sockaddr_in client_addr;
 init_socket_addr(&client_addr, port);
 if (FALSE == set_server_ip(&client_addr, ip)) {
  return FALSE;
 }
 int client_socket = socket(2, SOCK_STREAM, 0);
 if (client_socket < 0) {
  fprintf(stderr, "%s: socket()\n", strerror((*__errno_location ())));
  return FALSE;
 }
    int snd_buf = 32 * 1024;
    setsockopt(client_socket, 1, 7, (char *)&snd_buf, sizeof(int));
 if (connect(client_socket, (struct sockaddr *) &client_addr,
   sizeof(struct sockaddr)) < 0) {
  printf("%s: connect failed.\n", ip);
  return FALSE;
 }
 return client_socket;
}

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

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


decompiled_code:
__int64 __fastcall new_server_socket(__int16 a1)
{
int v1; // eax
unsigned int v2; // ebx
int *v4; // rax
char *v5; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax
int optval; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

init_socket_addr((__int64)&addr, a1);
v1 = socket(2, 1, 0);
if ( v1 < 0 )
{
v4 = _errno_location();
v5 = strerror(*v4);
fprintf(stderr, "%s: socket()\n", v5);
v2 = -1;
}
else
{
v2 = v1;
if ( bind(v1, &addr, 0x10u) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
fprintf(stderr, "%s: bind()\n", v7);
v2 = -1;
}
else
{
optval = 0x8000;
setsockopt(v2, 1, 8, &optval, 4u);
if ( listen(v2, 20) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
fprintf(stderr, "%s: listen()\n", v9);
v2 = -1;
}
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int16 a1)
{
int v1; // eax
unsigned int v2; // ebx
int *v4; // rax
char *v5; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax
int optval; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

func1((__int64)&addr, a1);
v1 = socket(2, 1, 0);
if ( v1 < 0 )
{
v4 = _errno_location();
v5 = strerror(*v4);
fprintf(stderr, "%s: socket()\n", v5);
v2 = -1;
}
else
{
v2 = v1;
if ( bind(v1, &addr, 0x10u) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
fprintf(stderr, "%s: bind()\n", v7);
v2 = -1;
}
else
{
optval = 0x8000;
setsockopt(v2, 1, 8, &optval, 4u);
if ( listen(v2, 20) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
fprintf(stderr, "%s: listen()\n", v9);
v2 = -1;
}
}
}
return v2;
}

original_code:
int new_server_socket(int port) {
 struct sockaddr_in server_addr;
 init_socket_addr(&server_addr, port);
 int server_socket = socket(2, SOCK_STREAM, 0);
 if (server_socket < 0) {
  fprintf(stderr, "%s: socket()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 int ret = bind(server_socket, (struct sockaddr*) &server_addr,
   sizeof(struct sockaddr));
 if (ret < 0) {
  fprintf(stderr, "%s: bind()\n", strerror((*__errno_location ())));
  return FALSE;
 }
    int rcv_buf = 32 * 1024;
    setsockopt(server_socket, 1, 8, (const char*)&rcv_buf, sizeof(int));
 if (listen(server_socket, 20) < 0) {
  fprintf(stderr, "%s: listen()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 return server_socket;
}

canonical_original_code:
int new_server_socket(int port) {
 struct sockaddr_in server_addr;
 init_socket_addr(&server_addr, port);
 int server_socket = socket(2, SOCK_STREAM, 0);
 if (server_socket < 0) {
  fprintf(stderr, "%s: socket()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 int ret = bind(server_socket, (struct sockaddr*) &server_addr,
   sizeof(struct sockaddr));
 if (ret < 0) {
  fprintf(stderr, "%s: bind()\n", strerror((*__errno_location ())));
  return FALSE;
 }
    int rcv_buf = 32 * 1024;
    setsockopt(server_socket, 1, 8, (char *)&rcv_buf, sizeof(int));
 if (listen(server_socket, 20) < 0) {
  fprintf(stderr, "%s: listen()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 return server_socket;
}

variable_types: ret int


decompiled_code:
__int64 __fastcall set_nonblocking(int fd)
{
int v1; // eax
__int64 result; // rax

v1 = fcntl(fd, 3);
if ( v1 < 0 )
{
fwrite("fcntl(socket, GETFL)\n", 1uLL, 0x15uLL, stderr);
result = 0xFFFFFFFFLL;
}
else
{
BYTE1(v1) |= 8u;
if ( fcntl(fd, 4, (unsigned int)v1) < 0 )
{
fwrite("fcntl(socket, SETFL, opts)\n", 1uLL, 0x1BuLL, stderr);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int fd)
{
int v1; // eax
__int64 result; // rax

v1 = fcntl(fd, 3);
if ( v1 < 0 )
{
fwrite("fcntl(socket, GETFL)\n", 1uLL, 0x15uLL, stderr);
result = 0xFFFFFFFFLL;
}
else
{
BYTE1(v1) |= 8u;
if ( fcntl(fd, 4, (unsigned int)v1) < 0 )
{
fwrite("fcntl(socket, SETFL, opts)\n", 1uLL, 0x1BuLL, stderr);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int set_nonblocking(int socketfd) {
    int opts;
    opts = fcntl(socketfd, 3);
    if(opts < 0) {
        fprintf(stderr, "fcntl(socket, GETFL)\n");
        return FALSE;
    }
    opts = opts | 04000;
    if(fcntl(socketfd, 4, opts) < 0) {
        fprintf(stderr, "fcntl(socket, SETFL, opts)\n");
        return FALSE;
    }
    return TRUE;
}

variable_types: socketfd int

variable_types: opts int


decompiled_code:
__int64 __fastcall set_blocking(int fd)
{
int v1; // eax
__int64 result; // rax

v1 = fcntl(fd, 3);
if ( v1 < 0 )
{
fwrite("fcntl(socket, GETFL)\n", 1uLL, 0x15uLL, stderr);
result = 0xFFFFFFFFLL;
}
else
{
BYTE1(v1) &= 0xF7u;
if ( fcntl(fd, 4, (unsigned int)v1) < 0 )
{
fwrite("fcntl(socket, SETFL, opts)\n", 1uLL, 0x1BuLL, stderr);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int fd)
{
int v1; // eax
__int64 result; // rax

v1 = fcntl(fd, 3);
if ( v1 < 0 )
{
fwrite("fcntl(socket, GETFL)\n", 1uLL, 0x15uLL, stderr);
result = 0xFFFFFFFFLL;
}
else
{
BYTE1(v1) &= 0xF7u;
if ( fcntl(fd, 4, (unsigned int)v1) < 0 )
{
fwrite("fcntl(socket, SETFL, opts)\n", 1uLL, 0x1BuLL, stderr);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int set_blocking(int socketfd) {
    int opts;
    opts = fcntl(socketfd, 3);
    if(opts < 0) {
        fprintf(stderr, "fcntl(socket, GETFL)\n");
        return FALSE;
    }
    opts = opts & ~04000;
    if(fcntl(socketfd, 4, opts) < 0) {
        fprintf(stderr, "fcntl(socket, SETFL, opts)\n");
        return FALSE;
    }
    return TRUE;
}


decompiled_code:
int __fastcall accept_connection(int a1)
{
int result; // eax
socklen_t addr_len; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

addr_len = 16;
result = accept(a1, &addr, &addr_len);
if ( result < 0 )
result = -1;
return result;
}

canonical_decompiled_code:
int __fastcall func7(int a1)
{
int result; // eax
socklen_t addr_len; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

addr_len = 16;
result = accept(a1, &addr, &addr_len);
if ( result < 0 )
result = -1;
return result;
}

original_code:
int accept_connection(int socketfd) {
 struct sockaddr_in client_addr;
 socklen_t length = sizeof(client_addr);
 int conn_socket;
 conn_socket = accept(socketfd, (struct sockaddr*) &client_addr, &length);
 if (conn_socket < 0) {
  return FALSE;
 }
 return conn_socket;
}

canonical_original_code:
int accept_connection(int socketfd) {
 struct sockaddr_in client_addr;
 unsigned int length = sizeof(client_addr);
 int conn_socket;
 conn_socket = accept(socketfd, (struct sockaddr *) &client_addr, &length);
 if (conn_socket < 0) {
  return FALSE;
 }
 return conn_socket;
}

variable_types:
length
unsigned int


decompiled_code:
__int64 __fastcall send_reply(int a1, int a2, int a3, int a4, int a5, int a6, char buf)
{
if ( send(a1, &buf, 0x30uLL, 0) != -1 )
return 0LL;
puts("send_reply: send reply failed.");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2, int a3, int a4, int a5, int a6, char buf)
{
if ( send(a1, &buf, 0x30uLL, 0) != -1 )
return 0LL;
puts("send_reply: send reply failed.");
return 0xFFFFFFFFLL;
}

original_code:
int send_reply(int socketfd, struct reply_message reply_msg) {
 if (-1
   == send(socketfd, (void *)&reply_msg, sizeof(struct reply_message),
     0)) {
  printf("send_reply: send reply failed.\n");
  return FALSE;
 }
 return TRUE;
}

variable_types: struct reply_message { enum OP { CREATE_TORUS=80, UPDATE_PARTITION=81, TRAVERSE_TORUS=82, QUERY_TORUS_NODE=83, QUERY_TORUS_CLUSTER=84, NEW_SKIP_LIST=85, UPDATE_SKIP_LIST=86, UPDATE_SKIP_LIST_NODE=87, TRAVERSE_SKIP_LIST=88, SEEK_IDLE_NODE=89, HEARTBEAT=90, RECEIVE_RESULT=91, RECEIVE_QUERY=92, RECEIVE_DATA=93, PERFORMANCE_TEST=94, RELOAD_RTREE=95 } op; char stamp[40]; enum REPLY_CODE { SUCCESS=1, FAILED=2, VISITED=3, WRONG_OP=4 } reply_code; }

user_defined_types: struct reply_message { enum OP op; char stamp[40]; enum REPLY_CODE reply_code; }


decompiled_code:
__int64 __fastcall receive_reply(int a1, void *a2)
{
__int64 result; // rax
int *v3; // rax
char *v4; // rax

if ( a2 )
{
if ( recv(a1, a2, 0x30uLL, 0) <= 0 )
{
v3 = _errno_location();
v4 = strerror(*v3);
fprintf(stderr, "%s: recv()\n", v4);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
else
{
puts("receive_reply: reply_msg is null pointer.");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, void *a2)
{
__int64 result; // rax
int *v3; // rax
char *v4; // rax

if ( a2 )
{
if ( recv(a1, a2, 0x30uLL, 0) <= 0 )
{
v3 = _errno_location();
v4 = strerror(*v3);
fprintf(stderr, "%s: recv()\n", v4);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
else
{
puts("receive_reply: reply_msg is null pointer.");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int receive_reply(int socketfd, struct reply_message *reply_msg) {
 if (reply_msg == ((void *)0)) {
  printf("receive_reply: reply_msg is null pointer.\n");
  return FALSE;
 }
 ssize_t recv_len = -1;
 recv_len = recv(socketfd, reply_msg, sizeof(struct reply_message), 0);
 if (recv_len <= 0) {
  fprintf(stderr, "%s: recv()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 return TRUE;
}

canonical_original_code:
int receive_reply(int socketfd, struct reply_message *reply_msg) {
 if (reply_msg == ((void *)0)) {
  printf("receive_reply: reply_msg is null pointer.\n");
  return FALSE;
 }
 long recv_len = -1;
 recv_len = recv(socketfd, reply_msg, sizeof(struct reply_message), 0);
 if (recv_len <= 0) {
  fprintf(stderr, "%s: recv()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 return TRUE;
}

variable_types: struct reply_message { enum OP { CREATE_TORUS=80, UPDATE_PARTITION=81, TRAVERSE_TORUS=82, QUERY_TORUS_NODE=83, QUERY_TORUS_CLUSTER=84, NEW_SKIP_LIST=85, UPDATE_SKIP_LIST=86, UPDATE_SKIP_LIST_NODE=87, TRAVERSE_SKIP_LIST=88, SEEK_IDLE_NODE=89, HEARTBEAT=90, RECEIVE_RESULT=91, RECEIVE_QUERY=92, RECEIVE_DATA=93, PERFORMANCE_TEST=94, RELOAD_RTREE=95 } op; char stamp[40]; enum REPLY_CODE { SUCCESS=1, FAILED=2, VISITED=3, WRONG_OP=4 } reply_code; } *


decompiled_code:
__int64 __fastcall fill_message(int a1, const char *a2, const char *a3, const char *a4, _QWORD *a5, __int64 a6)
{
__int64 result; // rax

*(_DWORD *)a6 = a1;
strncpy((char *)(a6 + 4), a2, 0x14uLL);
strncpy((char *)(a6 + 24), a3, 0x14uLL);
strncpy((char *)(a6 + 44), a4, 0x28uLL);
*(_QWORD *)(a6 + 84) = *a5;
result = a5[124];
*(_QWORD *)(a6 + 1076) = result;
qmemcpy(
(void *)((a6 + 92) & 0xFFFFFFFFFFFFFFF8LL),
(char *)a5 - (a6 + 84 - ((a6 + 92) & 0xFFFFFFFFFFFFFFF8LL)),
8LL * (((_DWORD)a6 + 84 - (((_DWORD)a6 + 92) & 0xFFFFFFF8) + 1000) >> 3));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, const char *a2, const char *a3, const char *a4, _QWORD *a5, __int64 a6)
{
__int64 result; // rax

*(_DWORD *)a6 = a1;
strncpy((char *)(a6 + 4), a2, 0x14uLL);
strncpy((char *)(a6 + 24), a3, 0x14uLL);
strncpy((char *)(a6 + 44), a4, 0x28uLL);
*(_QWORD *)(a6 + 84) = *a5;
result = a5[124];
*(_QWORD *)(a6 + 1076) = result;
qmemcpy(
(void *)((a6 + 92) & 0xFFFFFFFFFFFFFFF8LL),
(char *)a5 - (a6 + 84 - ((a6 + 92) & 0xFFFFFFFFFFFFFFF8LL)),
8LL * (((_DWORD)a6 + 84 - (((_DWORD)a6 + 92) & 0xFFFFFFF8) + 1000) >> 3));
return result;
}

original_code:
void fill_message(OP op, const char *src_ip, const char *dst_ip, const char *stamp, const char *data, struct message *msg){
 msg->op = op;
 strncpy(msg->src_ip, src_ip, 20);
 strncpy(msg->dst_ip, dst_ip, 20);
 strncpy(msg->stamp, stamp, 40);
 memcpy(msg->data, data, 1000);
}

canonical_original_code:
void fill_message(enum OP op, char *src_ip, char *dst_ip, char *stamp, char *data, struct message *msg){
 msg->op = op;
 strncpy(msg->src_ip, src_ip, 20);
 strncpy(msg->dst_ip, dst_ip, 20);
 strncpy(msg->stamp, stamp, 40);
 memcpy(msg->data, data, 1000);
}

variable_types:
stamp
char *

variable_types:
data
char *

variable_types: struct message { enum OP { CREATE_TORUS=80, UPDATE_PARTITION=81, TRAVERSE_TORUS=82, QUERY_TORUS_NODE=83, QUERY_TORUS_CLUSTER=84, NEW_SKIP_LIST=85, UPDATE_SKIP_LIST=86, UPDATE_SKIP_LIST_NODE=87, TRAVERSE_SKIP_LIST=88, SEEK_IDLE_NODE=89, HEARTBEAT=90, RECEIVE_RESULT=91, RECEIVE_QUERY=92, RECEIVE_DATA=93, PERFORMANCE_TEST=94, RELOAD_RTREE=95 } op; char src_ip[20]; char dst_ip[20]; char stamp[40]; char data[1000]; } *

user_defined_types: struct message { enum OP op; char src_ip[20]; char dst_ip[20]; char stamp[40]; char data[1000]; }


decompiled_code:
__int64 __fastcall send_message(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int buf)
{
if ( send(a1, &buf, 0x43CuLL, 0) != -1 )
return 0LL;
printf("send_message: %s send message failed.\n", (const char *)&buf + 4);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int buf)
{
if ( send(a1, &buf, 0x43CuLL, 0) != -1 )
return 0LL;
printf("send_message: %s send message failed.\n", (const char *)&buf + 4);
return 0xFFFFFFFFLL;
}

original_code:
int send_message(int socketfd, struct message msg) {
 if (-1
   == send(socketfd, (void *) &msg, sizeof(struct message), 0)) {
  printf("send_message: %s send message failed.\n", msg.src_ip);
  return FALSE;
 }
 return TRUE;
}

variable_types: struct message { enum OP { CREATE_TORUS=80, UPDATE_PARTITION=81, TRAVERSE_TORUS=82, QUERY_TORUS_NODE=83, QUERY_TORUS_CLUSTER=84, NEW_SKIP_LIST=85, UPDATE_SKIP_LIST=86, UPDATE_SKIP_LIST_NODE=87, TRAVERSE_SKIP_LIST=88, SEEK_IDLE_NODE=89, HEARTBEAT=90, RECEIVE_RESULT=91, RECEIVE_QUERY=92, RECEIVE_DATA=93, PERFORMANCE_TEST=94, RELOAD_RTREE=95 } op; char src_ip[20]; char dst_ip[20]; char stamp[40]; char data[1000]; }


decompiled_code:
__int64 __fastcall forward_message(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, __int64 a8, __int64 a9, char a10)
{
int v10; // er12
__int64 v11; // rdx
int v12; // ebx
__int64 v13; // r8
__int64 v14; // r9
unsigned int v15; // ebp
int v17[271]; // [rsp-440h] [rbp-888h] BYREF
_DWORD v18[12]; // [rsp+0h] [rbp-448h] BYREF
char s[1048]; // [rsp+30h] [rbp-418h] BYREF

v10 = a1;
v12 = new_client_socket(&a10, 10086);
if ( v12 == -1 )
return (unsigned int)-1;
qmemcpy(v17, &a7, sizeof(v17));
v15 = -1;
if ( !(unsigned int)send_message(v12, (__int64)&STACK[0x888], v11, 0LL, v13, v14, v17[0]) )
{
memset(s, 0, 0x400uLL);
sprintf(s, "\tforward message: %s -> %s\n", (const char *)&a7 + 4, &a10);
if ( a1 )
{
v10 = -1;
if ( !(unsigned int)receive_reply(v12, v18) )
v10 = -(v18[11] != 1);
}
v15 = v10;
}
close(v12);
return v15;
}

original_code:
int forward_message(struct message msg, int need_reply) {
 int socketfd;
 socketfd = new_client_socket(msg.dst_ip, 10086);
 if (FALSE == socketfd) {
  return FALSE;
 }
 int ret = FALSE;
 if (TRUE == send_message(socketfd, msg)) {
            char buf[1024];
            memset(buf, 0, 1024);
            sprintf(buf, "\tforward message: %s -> %s\n", msg.src_ip, msg.dst_ip);
  if (need_reply) {
   struct reply_message reply_msg;
   if (TRUE == receive_reply(socketfd, &reply_msg)) {
    if (SUCCESS == reply_msg.reply_code) {
     ret = TRUE;
    } else {
     ret = FALSE;
    }
   } else {
    ret = FALSE;
   }
  } else {
            ret = TRUE;
        }
 }
 close(socketfd);
 return ret;
}

variable_types:
buf
char [1024]

user_defined_types: enum OP { CREATE_TORUS=80, UPDATE_PARTITION=81, TRAVERSE_TORUS=82, QUERY_TORUS_NODE=83, QUERY_TORUS_CLUSTER=84, NEW_SKIP_LIST=85, UPDATE_SKIP_LIST=86, UPDATE_SKIP_LIST_NODE=87, TRAVERSE_SKIP_LIST=88, SEEK_IDLE_NODE=89, HEARTBEAT=90, RECEIVE_RESULT=91, RECEIVE_QUERY=92, RECEIVE_DATA=93, PERFORMANCE_TEST=94, RELOAD_RTREE=95 }

user_defined_types: enum REPLY_CODE { SUCCESS=1, FAILED=2, VISITED=3, WRONG_OP=4 }


decompiled_code:
__int64 __fastcall receive_message(int a1, void *a2)
{
__int64 result; // rax
int *v3; // rax
char *v4; // rax

if ( a2 )
{
if ( recv(a1, a2, 0x43CuLL, 0) < 0 )
{
v3 = _errno_location();
v4 = strerror(*v3);
fprintf(stderr, "%s: recv()\n", v4);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
else
{
puts("receive_message: msg is null pointer.");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, void *a2)
{
__int64 result; // rax
int *v3; // rax
char *v4; // rax

if ( a2 )
{
if ( recv(a1, a2, 0x43CuLL, 0) < 0 )
{
v3 = _errno_location();
v4 = strerror(*v3);
fprintf(stderr, "%s: recv()\n", v4);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
else
{
puts("receive_message: msg is null pointer.");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int receive_message(int socketfd, struct message *msg) {
 if (msg == ((void *)0)) {
  printf("receive_message: msg is null pointer.\n");
  return FALSE;
 }
 ssize_t recv_len = -1;
 recv_len = recv(socketfd, (void *) msg, sizeof(struct message), 0);
 if (recv_len < 0) {
  fprintf(stderr, "%s: recv()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 return TRUE;
}

canonical_original_code:
int receive_message(int socketfd, struct message *msg) {
 if (msg == ((void *)0)) {
  printf("receive_message: msg is null pointer.\n");
  return FALSE;
 }
 long recv_len = -1;
 recv_len = recv(socketfd, (void *) msg, sizeof(struct message), 0);
 if (recv_len < 0) {
  fprintf(stderr, "%s: recv()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 return TRUE;
}


decompiled_code:
__int64 __fastcall get_local_ip(char *dest)
{
int v1; // eax
int v2; // ebx
char *v3; // rax
unsigned int v4; // ebp
int *v6; // rax
char *v7; // rax
__int64 v8[2]; // [rsp+0h] [rbp-48h] BYREF
struct in_addr in; // [rsp+14h] [rbp-34h]

if ( dest )
{
v1 = socket(2, 2, 0);
v2 = v1;
if ( v1 < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
fprintf(stderr, "%s: socket()\n", v7);
v4 = -1;
}
else
{
v8[0] = 812151909LL;
v8[1] = 0LL;
if ( ioctl(v1, 0x8915uLL, v8) < 0 )
{
puts("get_local_ip: get local ip failed.");
v4 = -1;
}
else
{
v3 = inet_ntoa(in);
strncpy(dest, v3, 0x14uLL);
v4 = 0;
}
close(v2);
}
}
else
{
puts("get_local_ip: ip is null pointer.");
v4 = -1;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func14(char *dest)
{
int v1; // eax
int v2; // ebx
char *v3; // rax
unsigned int v4; // ebp
int *v6; // rax
char *v7; // rax
__int64 v8[2]; // [rsp+0h] [rbp-48h] BYREF
struct in_addr in; // [rsp+14h] [rbp-34h]

if ( dest )
{
v1 = socket(2, 2, 0);
v2 = v1;
if ( v1 < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
fprintf(stderr, "%s: socket()\n", v7);
v4 = -1;
}
else
{
v8[0] = 812151909LL;
v8[1] = 0LL;
if ( ioctl(v1, 0x8915uLL, v8) < 0 )
{
puts("get_local_ip: get local ip failed.");
v4 = -1;
}
else
{
v3 = inet_ntoa(in);
strncpy(dest, v3, 0x14uLL);
v4 = 0;
}
close(v2);
}
}
else
{
puts("get_local_ip: ip is null pointer.");
v4 = -1;
}
return v4;
}

original_code:
int get_local_ip(char *ip) {
 if (ip == ((void *)0)) {
  printf("get_local_ip: ip is null pointer.\n");
  return FALSE;
 }
 int socketfd;
 struct ifreq ifr;
 socketfd = socket(2, SOCK_DGRAM, 0);
 if (socketfd < 0) {
  fprintf(stderr, "%s: socket()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 int ret = FALSE;
 strncpy(ifr.ifr_ifrn.ifrn_name, "eth0", 16);
 if (ioctl(socketfd, 0x8915, &ifr) >= 0) {
  strncpy(ip,
    inet_ntoa(((struct sockaddr_in*) &(ifr.ifr_ifru.ifru_addr))->sin_addr),
    20);
  ret = TRUE;
 } else {
  printf("get_local_ip: get local ip failed.\n");
  ret = FALSE;
 }
 close(socketfd);
 return ret;
}

canonical_original_code:
int get_local_ip(char *ip) {
 if (ip == ((void *)0)) {
  printf("get_local_ip: ip is null pointer.\n");
  return FALSE;
 }
 int socketfd;
 struct ifreq ifr;
 socketfd = socket(2, SOCK_DGRAM, 0);
 if (socketfd < 0) {
  fprintf(stderr, "%s: socket()\n", strerror((*__errno_location ())));
  return FALSE;
 }
 int ret = FALSE;
 strncpy(ifr.ifr_ifrn.ifrn_name, "eth0", 16);
 if (ioctl(socketfd, 0x8915, &ifr) >= 0) {
  strncpy(ip,
    inet_ntoa(((struct sockaddr_in *) &(ifr.ifr_ifru.ifru_addr))->sin_addr),
    20);
  ret = TRUE;
 } else {
  printf("get_local_ip: get local ip failed.\n");
  ret = FALSE;
 }
 close(socketfd);
 return ret;
}

variable_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; } ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }

user_defined_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }


decompiled_code:
__int64 __fastcall recv_safe(int fd, __int64 a2, unsigned __int64 a3, int a4)
{
unsigned __int64 v6; // rbx
int v7; // eax

if ( a3 )
{
v6 = 0LL;
while ( 1 )
{
v7 = recv(fd, (void *)(a2 + v6), a3 - v6, a4);
if ( v7 >= 0 )
{
if ( !v7 )
{
LODWORD(v6) = 0;
return (unsigned int)v6;
}
v6 += v7;
}
if ( v6 >= a3 )
return (unsigned int)v6;
}
}
LODWORD(v6) = 0;
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func15(int fd, __int64 a2, unsigned __int64 a3, int a4)
{
unsigned __int64 v6; // rbx
int v7; // eax

if ( a3 )
{
v6 = 0LL;
while ( 1 )
{
v7 = recv(fd, (void *)(a2 + v6), a3 - v6, a4);
if ( v7 >= 0 )
{
if ( !v7 )
{
LODWORD(v6) = 0;
return (unsigned int)v6;
}
v6 += v7;
}
if ( v6 >= a3 )
return (unsigned int)v6;
}
}
LODWORD(v6) = 0;
return (unsigned int)v6;
}

original_code:
int recv_safe(int socketfd, void *data, size_t len, int flags) {
    size_t nrecv = 0;
    int irecv = -1;
    while (nrecv < len){
        irecv = recv(socketfd, data + nrecv, len - nrecv, flags);
        if(irecv < 0){
            continue;
        }else if(irecv == 0) {
            nrecv = 0;
            break;
        }else {
          nrecv += irecv;
        }
    }
    return nrecv;
}

canonical_original_code:
int recv_safe(int socketfd, void *data, unsigned long len, int flags) {
    unsigned long nrecv = 0;
    int irecv = -1;
    while (nrecv < len){
        irecv = recv(socketfd, data + nrecv, len - nrecv, flags);
        if(irecv < 0){
            continue;
        }else if(irecv == 0) {
            nrecv = 0;
            break;
        }else {
          nrecv += irecv;
        }
    }
    return nrecv;
}

variable_types:
data
void *

variable_types:
len
unsigned long

variable_types: flags int

variable_types:
nrecv
unsigned long

variable_types: irecv int


decompiled_code:
__int64 __fastcall send_safe(int fd, __int64 a2, unsigned __int64 a3, int a4)
{
unsigned __int64 v6; // rbx
int v7; // eax

if ( a3 )
{
v6 = 0LL;
while ( 1 )
{
v7 = send(fd, (const void *)(a2 + v6), a3 - v6, a4);
if ( v7 >= 0 )
{
if ( !v7 )
{
LODWORD(v6) = 0;
return (unsigned int)v6;
}
v6 += v7;
}
if ( v6 >= a3 )
return (unsigned int)v6;
}
}
LODWORD(v6) = 0;
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func16(int fd, __int64 a2, unsigned __int64 a3, int a4)
{
unsigned __int64 v6; // rbx
int v7; // eax

if ( a3 )
{
v6 = 0LL;
while ( 1 )
{
v7 = send(fd, (const void *)(a2 + v6), a3 - v6, a4);
if ( v7 >= 0 )
{
if ( !v7 )
{
LODWORD(v6) = 0;
return (unsigned int)v6;
}
v6 += v7;
}
if ( v6 >= a3 )
return (unsigned int)v6;
}
}
LODWORD(v6) = 0;
return (unsigned int)v6;
}

original_code:
int send_safe(int socketfd, void *data, size_t len, int flags) {
    size_t nsend = 0;
    int isend = -1;
    while (nsend < len){
        isend = send(socketfd, data + nsend, len - nsend, flags);
        if(isend < 0){
            continue;
        }else if(isend == 0) {
            nsend = 0;
            break;
        }else {
          nsend += isend;
        }
    }
    return nsend;
}

canonical_original_code:
int send_safe(int socketfd, void *data, unsigned long len, int flags) {
    unsigned long nsend = 0;
    int isend = -1;
    while (nsend < len){
        isend = send(socketfd, data + nsend, len - nsend, flags);
        if(isend < 0){
            continue;
        }else if(isend == 0) {
            nsend = 0;
            break;
        }else {
          nsend += isend;
        }
    }
    return nsend;
}

variable_types:
nsend
unsigned long

variable_types: isend int


original_code:
int send_data(OP op, const char *dst_ip, const char *data, size_t length) {
 int socketfd;
 socketfd = new_client_socket(dst_ip, 10086);
 if (FALSE == socketfd) {
  return FALSE;
 }
 char local_ip[20];
 memset(local_ip, 0, 20);
 if (FALSE == get_local_ip(local_ip)) {
  return FALSE;
 }
 struct message msg;
 msg.op = op;
 strncpy(msg.src_ip, local_ip, 20);
 strncpy(msg.dst_ip, dst_ip, 20);
 strncpy(msg.stamp, "", 40);
 memcpy(msg.data, (void *) data, length);
 int ret;
 if (TRUE == send_message(socketfd, msg)) {
        printf("%s:\tsend data...... finish.\n", dst_ip);
        ret = TRUE;
 } else {
  printf("%s:\tsend data...... failed.\n", dst_ip);
  ret = FALSE;
 }
 close(socketfd);
 return ret;
}

canonical_original_code:
int send_data(enum OP op, char *dst_ip, char *data, unsigned long length) {
 int socketfd;
 socketfd = new_client_socket(dst_ip, 10086);
 if (FALSE == socketfd) {
  return FALSE;
 }
 char local_ip[20];
 memset(local_ip, 0, 20);
 if (FALSE == get_local_ip(local_ip)) {
  return FALSE;
 }
 struct message msg;
 msg.op = op;
 strncpy(msg.src_ip, local_ip, 20);
 strncpy(msg.dst_ip, dst_ip, 20);
 strncpy(msg.stamp, "", 40);
 memcpy(msg.data, (void *) data, length);
 int ret;
 if (TRUE == send_message(socketfd, msg)) {
        printf("%s:\tsend data...... finish.\n", dst_ip);
        ret = TRUE;
 } else {
  printf("%s:\tsend data...... failed.\n", dst_ip);
  ret = FALSE;
 }
 close(socketfd);
 return ret;
}

variable_types: enum OP { CREATE_TORUS=80, UPDATE_PARTITION=81, TRAVERSE_TORUS=82, QUERY_TORUS_NODE=83, QUERY_TORUS_CLUSTER=84, NEW_SKIP_LIST=85, UPDATE_SKIP_LIST=86, UPDATE_SKIP_LIST_NODE=87, TRAVERSE_SKIP_LIST=88, SEEK_IDLE_NODE=89, HEARTBEAT=90, RECEIVE_RESULT=91, RECEIVE_QUERY=92, RECEIVE_DATA=93, PERFORMANCE_TEST=94, RELOAD_RTREE=95 }

variable_types:
length
unsigned long

variable_types: socketfd int

variable_types: ret int


decompiled_code:
__int64 __fastcall performance_test(char *src)
{
int v1; // ebp
int v2; // ebx
int v4; // [rsp+0h] [rbp-478h] BYREF
char dest[20]; // [rsp+4h] [rbp-474h] BYREF
char v6[20]; // [rsp+18h] [rbp-460h] BYREF
__int64 v7; // [rsp+2Ch] [rbp-44Ch]
__int64 v8; // [rsp+34h] [rbp-444h]
__int64 v9; // [rsp+3Ch] [rbp-43Ch]
__int64 v10; // [rsp+44h] [rbp-434h]
__int64 v11; // [rsp+4Ch] [rbp-42Ch]
char v12[1004]; // [rsp+54h] [rbp-424h] BYREF
char srca[8]; // [rsp+440h] [rbp-38h] BYREF
__int64 v14; // [rsp+448h] [rbp-30h]
int v15; // [rsp+450h] [rbp-28h]

*(_QWORD *)srca = 0LL;
v14 = 0LL;
v15 = 0;
get_local_ip(srca);
v4 = 94;
strncpy(dest, srca, 0x14uLL);
strncpy(v6, src, 0x14uLL);
v7 = 0LL;
v8 = 0LL;
v9 = 0LL;
v10 = 0LL;
v11 = 0LL;
strncpy(v12, "hello server!", 0x3E8uLL);
puts("start send data to server");
v1 = new_client_socket(src, 10086);
send_safe(v1, (__int64)&v4, 0x43CuLL, 0);
v2 = 1;
while ( 1 )
{
close(v1);
if ( v2 == 500000 )
break;
v1 = new_client_socket(src, 10086);
send_safe(v1, (__int64)&v4, 0x43CuLL, 0);
++v2;
if ( v2 == 1000 * (v2 / 1000) )
printf("%d\n", (unsigned int)v2);
}
puts("finish send data to server");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func18(char *src)
{
int v1; // ebp
int v2; // ebx
int v4; // [rsp+0h] [rbp-478h] BYREF
char dest[20]; // [rsp+4h] [rbp-474h] BYREF
char v6[20]; // [rsp+18h] [rbp-460h] BYREF
__int64 v7; // [rsp+2Ch] [rbp-44Ch]
__int64 v8; // [rsp+34h] [rbp-444h]
__int64 v9; // [rsp+3Ch] [rbp-43Ch]
__int64 v10; // [rsp+44h] [rbp-434h]
__int64 v11; // [rsp+4Ch] [rbp-42Ch]
char v12[1004]; // [rsp+54h] [rbp-424h] BYREF
char srca[8]; // [rsp+440h] [rbp-38h] BYREF
__int64 v14; // [rsp+448h] [rbp-30h]
int v15; // [rsp+450h] [rbp-28h]

*(_QWORD *)srca = 0LL;
v14 = 0LL;
v15 = 0;
func14(srca);
v4 = 94;
strncpy(dest, srca, 0x14uLL);
strncpy(v6, src, 0x14uLL);
v7 = 0LL;
v8 = 0LL;
v9 = 0LL;
v10 = 0LL;
v11 = 0LL;
strncpy(v12, "hello server!", 0x3E8uLL);
puts("start send data to server");
v1 = func3(src, 10086);
func16(v1, (__int64)&v4, 0x43CuLL, 0);
v2 = 1;
while ( 1 )
{
close(v1);
if ( v2 == 500000 )
break;
v1 = func3(src, 10086);
func16(v1, (__int64)&v4, 0x43CuLL, 0);
++v2;
if ( v2 == 1000 * (v2 / 1000) )
printf("%d\n", (unsigned int)v2);
}
puts("finish send data to server");
return 0xFFFFFFFFLL;
}

original_code:
int performance_test(char *entry_ip) {
    int i, ret = FALSE;
    int socketfd;
 char local_ip[20];
 memset(local_ip, 0, 20);
 if (FALSE == get_local_ip(local_ip)) {
  ret = FALSE;
 }
    struct message msg;
    msg.op = PERFORMANCE_TEST;
 strncpy(msg.src_ip, local_ip, 20);
 strncpy(msg.dst_ip, entry_ip, 20);
 strncpy(msg.stamp, "", 40);
    strncpy(msg.data, "hello server!", 1000);
    printf("start send data to server\n");
    int count = 0;
    for(i = 0; i < 500000; i++) {
        socketfd = new_client_socket(entry_ip, 10086);
        if (FALSE == socketfd) {
            ret = FALSE;
        }
        send_safe(socketfd, (void *) &msg, sizeof(struct message), 0);
        count++;
        if(count % 1000 == 0) {
            printf("%d\n", count);
        }
        close(socketfd);
    }
    printf("finish send data to server\n");
    return ret;
}

canonical_original_code:
int performance_test(char *entry_ip) {
    int i; int ret = FALSE;
    int socketfd;
 char local_ip[20];
 memset(local_ip, 0, 20);
 if (FALSE == get_local_ip(local_ip)) {
  ret = FALSE;
 }
    struct message msg;
    msg.op = PERFORMANCE_TEST;
 strncpy(msg.src_ip, local_ip, 20);
 strncpy(msg.dst_ip, entry_ip, 20);
 strncpy(msg.stamp, "", 40);
    strncpy(msg.data, "hello server!", 1000);
    printf("start send data to server\n");
    int count = 0;
    for(i = 0; i < 500000; i++) {
        socketfd = new_client_socket(entry_ip, 10086);
        if (FALSE == socketfd) {
            ret = FALSE;
        }
        send_safe(socketfd, (void *) &msg, sizeof(struct message), 0);
        count++;
        if(count % 1000 == 0) {
            printf("%d\n", count);
        }
        close(socketfd);
    }
    printf("finish send data to server\n");
    return ret;
}

variable_types: i int

variable_types: count int


decompiled_code:
int __fastcall print_message(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, char a10)
{
printf("op:%d\n", (unsigned int)a7);
printf("src:%s\n", (const char *)&a7 + 4);
return printf("dst:%s\n", &a10);
}

canonical_decompiled_code:
int __fastcall func19(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, char a10)
{
printf("op:%d\n", (unsigned int)a7);
printf("src:%s\n", (const char *)&a7 + 4);
return printf("dst:%s\n", &a10);
}

original_code:
void print_message(struct message msg) {
 printf("op:%d\n", msg.op);
 printf("src:%s\n", msg.src_ip);
 printf("dst:%s\n", msg.dst_ip);
}


overlaps

decompiled_code:
__int64 __fastcall overlaps(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = 0LL;
while ( *(double *)(a2 + v2) <= *(double *)(a1 + v2 + 8) )
{
if ( *(double *)(a1 + v2) > *(double *)(a2 + v2 + 8) )
return 0LL;
v2 += 16LL;
if ( v2 == 48 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = 0LL;
while ( *(double *)(a2 + v2) <= *(double *)(a1 + v2 + 8) )
{
if ( *(double *)(a1 + v2) > *(double *)(a2 + v2 + 8) )
return 0LL;
v2 += 16LL;
if ( v2 == 48 )
return 1LL;
}
return 0LL;
}

original_code:
int overlaps(interval c[], interval o[]) {
 int i, ovlp = 1;
 i = 0;
 while (ovlp && i < 3) {
  ovlp = !(c[i].high < o[i].low || c[i].low > o[i].high);
  i++;
 }
 return ovlp;
}

canonical_original_code:
int overlaps(struct interval c[], struct interval o[]) {
 int i; int ovlp = 1;
 i = 0;
 while (ovlp && i < 3) {
  ovlp = !(c[i].high < o[i].low || c[i].low > o[i].high);
  i++;
 }
 return ovlp;
}

variable_types: struct interval { double low; double high; } []

variable_types:
o
struct interval []

variable_types: ovlp int


decompiled_code:
__m128d __fastcall get_distance(__m128d result, double a2, double a3, double a4)
{
result.m128d_f64[0] = (result.m128d_f64[0] + a2) * 0.5 - (a3 + a4) * 0.5;
if ( result.m128d_f64[0] <= 0.0 )
result = _mm_xor_pd(result, (__m128d)LC2);
return result;
}

canonical_decompiled_code:
__m128d __fastcall func1(__m128d result, double a2, double a3, double a4)
{
result.m128d_f64[0] = (result.m128d_f64[0] + a2) * 0.5 - (a3 + a4) * 0.5;
if ( result.m128d_f64[0] <= 0.0 )
result = _mm_xor_pd(result, (__m128d)LC2);
return result;
}

original_code:
data_type get_distance(interval c, interval o){
 data_type c_center = (c.low + c.high) / 2;
 data_type o_center = (o.low + o.high) / 2;
 data_type dis = c_center - o_center;
 return (dis > 0) ? dis : (-1 * dis);
}

canonical_original_code:
double get_distance(struct interval c, struct interval o){
 double c_center = (c.low + c.high) / 2;
 double o_center = (o.low + o.high) / 2;
 double dis = c_center - o_center;
 return (dis > 0) ? dis : (-1 * dis);
}

variable_types: struct interval { double low; double high; }

variable_types:
o
struct interval

variable_types: dis double

return_type: double


compare

decompiled_code:
__int64 __fastcall compare(double a1, double a2, double a3)
{
return a3 < a1 ? 1 : -1;
}

canonical_decompiled_code:
__int64 __fastcall func2(double a1, double a2, double a3)
{
return a3 < a1 ? 1 : -1;
}

original_code:
int compare(interval cinterval, interval ointerval) {
 if (cinterval.low <= ointerval.low) {
  return -1;
 } else {
  return 1;
 }
}

canonical_original_code:
int compare(struct interval cinterval, struct interval ointerval) {
 if (cinterval.low <= ointerval.low) {
  return -1;
 } else {
  return 1;
 }
}

variable_types:
ointerval
struct interval


decompiled_code:
__int64 random_level()
{
int v0; // eax
int v1; // edx
int v2; // ecx
__int64 result; // rax

v0 = rand();
if ( (v0 & 1) != 0 )
{
v2 = 0;
}
else
{
v1 = v0;
v2 = 0;
do
{
++v2;
v1 /= 2;
}
while ( (v1 & 1) == 0 );
}
result = 31LL;
if ( v2 <= 31 )
result = (unsigned int)v2;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // eax
int v1; // edx
int v2; // ecx
__int64 result; // rax

v0 = rand();
if ( (v0 & 1) != 0 )
{
v2 = 0;
}
else
{
v1 = v0;
v2 = 0;
do
{
++v2;
v1 /= 2;
}
while ( (v1 & 1) == 0 );
}
result = 31LL;
if ( v2 <= 31 )
result = (unsigned int)v2;
return result;
}

original_code:
int random_level() {
 int level = 0, randint;
 randint = rand();
 for (; (randint % 2) == 0; randint /= 2) {
  level++;
 }
 if (level > 31) {
  level = 31;
 }
 return (level < 31) ? level : 31;
}

canonical_original_code:
int random_level() {
 int level = 0; int randint;
 randint = rand();
 for (; (randint % 2) == 0; randint /= 2) {
  level++;
 }
 if (level > 31) {
  level = 31;
 }
 return (level < 31) ? level : 31;
}

variable_types: level int

variable_types: randint int


decompiled_code:
__int64 insert_skip_list()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
return 0LL;
}

original_code:
int insert_skip_list(skip_list *slist, node_info *node_ptr) {
 return TRUE;
}

canonical_original_code:
int insert_skip_list(struct skip_list *slist, struct node_info *node_ptr) {
 return TRUE;
}

variable_types: struct skip_list { struct skip_list_node { int height; struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } leader[3]; struct skip_list_level { struct skip_list_node *forward; struct skip_list_node *backward; } level[]; } *header; int level; } *

user_defined_types: struct skip_list { struct skip_list_node *header; int level; }

user_defined_types: struct skip_list_node { int height; struct node_info leader[3]; struct skip_list_level level[]; }


decompiled_code:
__int64 remove_skip_list()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 0LL;
}

original_code:
int remove_skip_list(skip_list *slist, node_info *node_ptr) {
 return TRUE;
}

canonical_original_code:
int remove_skip_list(struct skip_list *slist, struct node_info *node_ptr) {
 return TRUE;
}

user_defined_types: struct skip_list_level { struct skip_list_node *forward; struct skip_list_node *backward; }


decompiled_code:
__int64 __fastcall interval_overlap(double a1, double a2, double a3, double a4)
{
__int64 result; // rax

result = 0xFFFFFFFFLL;
if ( a3 <= a2 )
result = a1 > a4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(double a1, double a2, double a3, double a4)
{
__int64 result; // rax

result = 0xFFFFFFFFLL;
if ( a3 <= a2 )
result = a1 > a4;
return result;
}

original_code:
int interval_overlap(interval cinterval, interval ointerval) {
 if(cinterval.high < ointerval.low){
  return -1;
 }
 if (cinterval.low > ointerval.high) {
  return 1;
 }
 return 0;
}

canonical_original_code:
int interval_overlap(struct interval cinterval, struct interval ointerval) {
 if(cinterval.high < ointerval.low){
  return -1;
 }
 if (cinterval.low > ointerval.high) {
  return 1;
 }
 return 0;
}


decompiled_code:
__int64 search_skip_list()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
return 0LL;
}

original_code:
node_info *search_skip_list(skip_list *slist, interval time_interval) {
 return ((void *)0);
}

canonical_original_code:
struct node_info *search_skip_list(struct skip_list *slist, struct interval time_interval) {
 return ((void *)0);
}

variable_types: struct skip_list { struct skip_list_node { int height; struct node_info leader[3]; struct skip_list_level { struct skip_list_node *forward; struct skip_list_node *backward; } level[]; } *header; int level; } *


original_code:
void print_skip_list(skip_list *slist) {
 int i, j, k;
 skip_list_node *sln_ptr;
 for (i = 0; i <= slist->level; ++i) {
  sln_ptr = slist->header;
  printf("level:%d\n", i);
  while (sln_ptr->level[i].forward != ((void *)0)) {
            for(j = 0; j < 3; j++) {
                printf("%s ", sln_ptr->level[i].forward->leader[j].ip);
            }
            printf("height:%d\n", sln_ptr->level[i].forward->height);
            if (sln_ptr->level[i].forward->level[i].backward) {
                printf("\tback:");
                for(k = 0; k < 3; k++) {
                    printf("%s ", sln_ptr->level[i].forward->level[i].backward->leader[k].ip);
                }
                printf("\n");
            } else {
                printf("\tback:NULL\n");
            }
            sln_ptr = sln_ptr->level[i].forward;
  }
  printf("\n");
 }
}

canonical_original_code:
void print_skip_list(struct skip_list *slist) {
 int i; int j; int k;
 struct skip_list_node *sln_ptr;
 for (i = 0; i <= slist->level; ++i) {
  sln_ptr = slist->header;
  printf("level:%d\n", i);
  while (sln_ptr->level[i].forward != ((void *)0)) {
            for(j = 0; j < 3; j++) {
                printf("%s ", sln_ptr->level[i].forward->leader[j].ip);
            }
            printf("height:%d\n", sln_ptr->level[i].forward->height);
            if (sln_ptr->level[i].forward->level[i].backward) {
                printf("\tback:");
                for(k = 0; k < 3; k++) {
                    printf("%s ", sln_ptr->level[i].forward->level[i].backward->leader[k].ip);
                }
                printf("\n");
            } else {
                printf("\tback:NULL\n");
            }
            sln_ptr = sln_ptr->level[i].forward;
  }
  printf("\n");
 }
}

variable_types: j int

variable_types: k int

variable_types: struct skip_list_node { int height; struct node_info { char ip[20]; int cluster_id; struct interval { double low; double high; } region[3]; struct coordinate { int x; int y; int z; } node_id; unsigned int capacity; } leader[3]; struct skip_list_level { struct skip_list_node *forward; struct skip_list_node *backward; } level[]; } *


decompiled_code:
int __fastcall get_local_time(char *s)
{
struct tm *v1; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

time(&timer);
v1 = localtime(&timer);
return sprintf(
s,
"[%04d-%02d-%02d %02d:%02d:%02d]\t",
(unsigned int)(v1->tm_year + 1900),
(unsigned int)v1->tm_mon,
(unsigned int)v1->tm_mday,
(unsigned int)v1->tm_hour,
(unsigned int)v1->tm_min,
(unsigned int)v1->tm_sec);
}

canonical_decompiled_code:
int __fastcall func0(char *s)
{
struct tm *v1; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

time(&timer);
v1 = localtime(&timer);
return sprintf(
s,
"[%04d-%02d-%02d %02d:%02d:%02d]\t",
(unsigned int)(v1->tm_year + 1900),
(unsigned int)v1->tm_mon,
(unsigned int)v1->tm_mday,
(unsigned int)v1->tm_hour,
(unsigned int)v1->tm_min,
(unsigned int)v1->tm_sec);
}

original_code:
void get_local_time(char* buffer) {
 time_t rawtime;
 struct tm* timeinfo;
 time(&rawtime);
 timeinfo = localtime(&rawtime);
 sprintf(buffer, "[%04d-%02d-%02d %02d:%02d:%02d]\t", (timeinfo->tm_year + 1900),
   timeinfo->tm_mon, timeinfo->tm_mday, timeinfo->tm_hour,
   timeinfo->tm_min, timeinfo->tm_sec);
}

canonical_original_code:
void get_local_time(char *buffer) {
 long rawtime;
 struct tm *timeinfo;
 time(&rawtime);
 timeinfo = localtime(&rawtime);
 sprintf(buffer, "[%04d-%02d-%02d %02d:%02d:%02d]\t", (timeinfo->tm_year + 1900),
   timeinfo->tm_mon, timeinfo->tm_mday, timeinfo->tm_hour,
   timeinfo->tm_min, timeinfo->tm_sec);
}

variable_types:
buffer
char *

variable_types: rawtime long

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


repo: meissnol/smtp-duplicator

decompiled_code:
void __fastcall sigchld_handler(int a1)
{
SIG_received = 1;
switch ( a1 )
{
case 15:
syslog(6, "onSIGTERM\n");
keep_going = 0;
break;
case 17:
syslog(6, "onSIGCHLD\n");
while ( waitpid(-1, 0LL, 1) > 0 )
;
break;
case 10:
dump_configfile(smtpConfigFile);
break;
}
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
SIG_received = 1;
switch ( a1 )
{
case 15:
syslog(6, "onSIGTERM\n");
keep_going = 0;
break;
case 17:
syslog(6, "onSIGCHLD\n");
while ( waitpid(-1, 0LL, 1) > 0 )
;
break;
case 10:
dump_configfile(smtpConfigFile);
break;
}
}

original_code:
void sigchld_handler(int s) {
   SIG_received = 1;
   switch(s) {
    case 17:
         syslog(6, "onSIGCHLD\n");
         while(waitpid(-1, ((void *)0), 1) > 0);
         break;
    case 15:
         syslog(6, "onSIGTERM\n");
         keep_going = 0;
         break;
    case 10:
         dump_configfile(smtpConfigFile);
         break;
   }
}

variable_types: s int


usage

decompiled_code:
void __noreturn usage()
{
fprintf(stderr, "Usage is %s [options]\n", (const char *)option_programName);
fwrite("Options\n", 1uLL, 8uLL, stderr);
fwrite(" -d don't fork to background.\n", 1uLL, 0x26uLL, stderr);
fwrite(" -f<file> read config from <file>.\n", 1uLL, 0x25uLL, stderr);
fwrite(" -h show this help and exit.\n", 1uLL, 0x25uLL, stderr);
exit(8);
}

canonical_decompiled_code:
void __noreturn func1()
{
fprintf(stderr, "Usage is %s [options]\n", (const char *)option_programName);
fwrite("Options\n", 1uLL, 8uLL, stderr);
fwrite(" -d don't fork to background.\n", 1uLL, 0x26uLL, stderr);
fwrite(" -f<file> read config from <file>.\n", 1uLL, 0x25uLL, stderr);
fwrite(" -h show this help and exit.\n", 1uLL, 0x25uLL, stderr);
exit(8);
}

original_code:
void usage() {
    fprintf(stderr, "Usage is %s [options]\n", option_programName);
    fprintf(stderr, "Options\n");
    fprintf(stderr, " -d         don\'t fork to background.\n");
    fprintf(stderr, " -f<file>   read config from <file>.\n");
    fprintf(stderr, " -h         show this help and exit.\n");
    exit(8);
}


decompiled_code:
__int64 __fastcall parse_cmdLine(int a1, __int64 a2)
{
__int64 v2; // rcx
__int64 v4; // rdx
char v5; // al

option_programName = *(void **)a2;
if ( a1 > 1 )
{
v2 = a2 + 8LL * (unsigned int)(a1 - 1);
do
{
v4 = *(_QWORD *)(a2 + 8);
if ( *(_BYTE *)v4 != 45 )
break;
v5 = *(_BYTE *)(v4 + 1);
if ( v5 != 102 )
{
LABEL_12:
if ( v5 == 104 )
usage();
if ( v5 != 100 )
{
fprintf(stderr, "Bad option %s\n", (const char *)v4);
usage();
}
option_DontFork = 1;
while ( 1 )
{
a2 += 8LL;
if ( a2 == v2 )
return 0LL;
v4 = *(_QWORD *)(a2 + 8);
if ( *(_BYTE *)v4 != 45 )
return 0LL;
v5 = *(_BYTE *)(v4 + 1);
if ( v5 != 102 )
goto LABEL_12;
if ( *(_BYTE *)(v4 + 2) )
option_ConfigFile = (char *)(v4 + 2);
else
option_ConfigFile = *(char **)(a2 + 16);
}
}
if ( *(_BYTE *)(v4 + 2) )
option_ConfigFile = (char *)(v4 + 2);
else
option_ConfigFile = *(char **)(a2 + 16);
a2 += 8LL;
}
while ( a2 != v2 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, __int64 a2)
{
__int64 v2; // rcx
__int64 v4; // rdx
char v5; // al

option_programName = *(void **)a2;
if ( a1 > 1 )
{
v2 = a2 + 8LL * (unsigned int)(a1 - 1);
do
{
v4 = *(_QWORD *)(a2 + 8);
if ( *(_BYTE *)v4 != 45 )
break;
v5 = *(_BYTE *)(v4 + 1);
if ( v5 != 102 )
{
LABEL_12:
if ( v5 == 104 )
func1();
if ( v5 != 100 )
{
fprintf(stderr, "Bad option %s\n", (const char *)v4);
func1();
}
option_DontFork = 1;
while ( 1 )
{
a2 += 8LL;
if ( a2 == v2 )
return 0LL;
v4 = *(_QWORD *)(a2 + 8);
if ( *(_BYTE *)v4 != 45 )
return 0LL;
v5 = *(_BYTE *)(v4 + 1);
if ( v5 != 102 )
goto LABEL_12;
if ( *(_BYTE *)(v4 + 2) )
option_ConfigFile = (char *)(v4 + 2);
else
option_ConfigFile = *(char **)(a2 + 16);
}
}
if ( *(_BYTE *)(v4 + 2) )
option_ConfigFile = (char *)(v4 + 2);
else
option_ConfigFile = *(char **)(a2 + 16);
a2 += 8LL;
}
while ( a2 != v2 );
}
return 0LL;
}

original_code:
int parse_cmdLine(int argc, char *argv[]) {
  option_programName = argv[0];
  while ((argc > 1) && (argv[1][0] == '-')) {
    switch (argv[1][1]) {
        case 'd':
            option_DontFork = 1;
            break;
        case 'f':
            if (argv[1][2]) {
               option_ConfigFile = &argv[1][2];
            } else {
               option_ConfigFile = &argv[2][0];
            }
            break;
        case 'h':
            usage();
        default:
            fprintf(stderr, "Bad option %s\n", argv[1]);
            usage();
    }
    ++argv;
    --argc;
  }
  return(0);
}

variable_types: argc int

variable_types:
argv
char *[]


daemonize

decompiled_code:
__int64 daemonize()
{
__pid_t v0; // eax

syslog(6, "forking to background.");
v0 = fork();
if ( v0 == -1 )
{
perror("fork()");
exit(3);
}
if ( v0 )
{
syslog(6, "parent: exiting.");
exit(0);
}
syslog(6, "child: initializing.");
close(0);
close(1);
close(2);
if ( setsid() == -1 )
exit(4);
syslog(6, "fork() finished.");
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__pid_t v0; // eax

syslog(6, "forking to background.");
v0 = fork();
if ( v0 == -1 )
{
perror("fork()");
exit(3);
}
if ( v0 )
{
syslog(6, "parent: exiting.");
exit(0);
}
syslog(6, "child: initializing.");
close(0);
close(1);
close(2);
if ( setsid() == -1 )
exit(4);
syslog(6, "fork() finished.");
return 0LL;
}

original_code:
int daemonize() {
   syslog(6, "forking to background.");
   switch (fork ())
     {
     case -1:
       perror ("fork()");
       exit (3);
     case 0:
       syslog(6, "child: initializing.");
       close (0);
       close (1);
       close (2);
       if (setsid () == -1)
         {
           exit (4);
         }
       break;
     default:
       syslog(6, "parent: exiting.");
       exit(0);
     }
  syslog(6, "fork() finished.");
  return(0);
}


decompiled_code:
__int64 handle_NewClient()
{
return smtprelay_ClientConnect();
}

canonical_decompiled_code:
__int64 func4()
{
return smtprelay_ClientConnect();
}

original_code:
int handle_NewClient(int cliSock, struct sockaddr_storage *client_addr) {
    int res = smtprelay_ClientConnect(cliSock, client_addr);
    return(res);
}

variable_types: cliSock int

variable_types: struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; } *

variable_types: res int


decompiled_code:
void prepare_syslog()
{
openlog("smtp-duplictor", 3, 16);
}

canonical_decompiled_code:
void func5()
{
openlog("smtp-duplictor", 3, 16);
}

original_code:
void prepare_syslog(void) {
  openlog("smtp-duplictor", 0x02 | 0x01, (2<<3));
}

canonical_original_code:
void prepare_syslog() {
  openlog("smtp-duplictor", 0x02 | 0x01, (2<<3));
}


itoa

decompiled_code:
char *__fastcall itoa(int a1, int a2)
{
__int64 v2; // rcx
int v3; // er8
bool v4; // al

if ( a1 )
{
v2 = 29LL;
do
{
byte_BC1[v2] = byte_CBB[a1 % a2];
v3 = v2;
a1 /= a2;
v4 = (_DWORD)v2-- != 0;
}
while ( v4 && a1 != 0 );
}
else
{
v3 = 30;
}
return (char *)&buf_0 + v3 + 1;
}

canonical_decompiled_code:
char *__fastcall func6(int a1, int a2)
{
__int64 v2; // rcx
int v3; // er8
bool v4; // al

if ( a1 )
{
v2 = 29LL;
do
{
byte_BC1[v2] = byte_CBB[a1 % a2];
v3 = v2;
a1 /= a2;
v4 = (_DWORD)v2-- != 0;
}
while ( v4 && a1 != 0 );
}
else
{
v3 = 30;
}
return (char *)&buf_0 + v3 + 1;
}

original_code:
char* itoa(int val, int base){
    static char buf[32] = {0};
    int i = 30;
    for(; val && i ; --i, val /= base)
        buf[i] = "0123456789abcdef"[val % base];
    return &buf[i+1];
}

canonical_original_code:
char *itoa(int val, int base){
    static char buf[32] = {0};
    int i = 30;
    for(; val && i ; --i, val /= base)
        buf[i] = "0123456789abcdef"[val % base];
    return &buf[i+1];
}

variable_types: val int

variable_types: base int

variable_types:
buf
char [32]

variable_types: i int

return_type: char *