decompiled_code:
__int64 __fastcall st_shti_bp_mccreight_insert_suffix(int *a1, int *a2, _DWORD *a3, __int64 a4, __int64 a5, unsigned __int64 a6, _QWORD *a7)
{
unsigned __int64 v10; // rax
int v11; // eax
unsigned int v12; // er12
int v14; // er14
__int64 v15; // rdx
int v16; // eax
__int64 v17; // rdx
__int64 v19; // [rsp+18h] [rbp-50h] BYREF
unsigned int v20; // [rsp+24h] [rbp-44h] BYREF
int v21; // [rsp+28h] [rbp-40h] BYREF
int v22[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v22[0] = 0;
v21 = 0;
v20 = 0;
v19 = a4 + *(unsigned int *)(a7[9] + 16LL * *a1 + 4);
v10 = a7[14];
if ( a7[13] == v10 && v10 < a6 && (int)st_shti_bp_reallocate(v10 + 1, 0LL, a5, a6, a7) > 0 )
{
fwrite("Error: Could not reallocate memory!\n", 1uLL, 0x24uLL, stderr);
v12 = 1;
}
else
{
while ( 1 )
{
v11 = st_shti_bp_branch_once((unsigned int)*a1, v22, v19, a5, a7);
if ( v11 )
{
if ( v11 == 1 )
{
fprintf(stderr, "Error: Insertion of the suffix number %zu failed!\n", a4);
v12 = 6;
}
else
{
v12 = st_shti_bp_create_leaf(
(unsigned int)*a1,
(unsigned int)*(char *)(a5 + a4 + *(unsigned int *)(a7[9] + 16LL * *a1 + 4)),
(unsigned int)-(int)a4,
a5,
a7);
if ( v12 )
{
fwrite("Error: Could not create a new leaf of the parent!\n", 1uLL, 0x32uLL, stderr);
v12 = 7;
}
else if ( *a1 > 1 )
{
*a1 = *(_DWORD *)(a7[9] + 16LL * *a1 + 12);
}
}
return v12;
}
if ( (unsigned int)st_shti_bp_edge_slowscan((unsigned int)*a1, (unsigned int)v22[0], v19, &v20, a5, a6 + 1, a7) )
break;
st_shti_bp_edge_descend(a1, v22, &v21, &v19, a6 + 1, a7);
if ( *a1 < 0 )
{
fwrite(
"Error: The newly inserted suffix already has the corresponding leaf node\npresent in the suffix tree!\n",
1uLL,
0x65uLL,
stderr);
return 2;
}
}
v14 = v22[0];
if ( (unsigned int)st_shti_bp_split_edge(
a1,
(unsigned int)*(char *)(a5 + v19),
v22,
&v19,
v20,
(unsigned int)a4,
a5,
a7) )
{
fwrite("Error: Could not split the parent->child edge!\n", 1uLL, 0x2FuLL, stderr);
return 3;
}
v12 = st_shti_bp_create_leaf((unsigned int)*a1, (unsigned int)*(char *)(a5 + v19), (unsigned int)-(int)a4, a5, a7);
if ( v12 )
{
fwrite("Error: Could not create a new leaf of the parent!\n", 1uLL, 0x32uLL, stderr);
return 4;
}
v15 = (unsigned int)*a2;
if ( (_DWORD)v15 )
{
if ( (unsigned int)*a3 + a4 != v19 )
{
fprintf(
stderr,
"Error! The last opportunity to set the target of a suffix link missed! (suffix link source = %d)\n",
v15);
return 5;
}
*(_DWORD *)(a7[9] + 16LL * (int)v15 + 12) = *a1;
}
v16 = *a1;
*a2 = *a1;
v17 = (unsigned int)(*(_DWORD *)(a7[9] + 16LL * v16 + 4) - 1);
*a3 = v17;
if ( !(unsigned int)st_shti_bp_simulate_suffix_link_bottom_up(a1, v14, v17, (__int64)a7) )
{
*a2 = 0;
*a3 = 0;
v12 = 0;
}
}
return v12;
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1, int *a2, _DWORD *a3, __int64 a4, __int64 a5, unsigned __int64 a6, _QWORD *a7)
{
unsigned __int64 v10; // rax
int v11; // eax
unsigned int v12; // er12
int v14; // er14
__int64 v15; // rdx
int v16; // eax
__int64 v17; // rdx
__int64 v19; // [rsp+18h] [rbp-50h] BYREF
unsigned int v20; // [rsp+24h] [rbp-44h] BYREF
int v21; // [rsp+28h] [rbp-40h] BYREF
int v22[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v22[0] = 0;
v21 = 0;
v20 = 0;
v19 = a4 + *(unsigned int *)(a7[9] + 16LL * *a1 + 4);
v10 = a7[14];
if ( a7[13] == v10 && v10 < a6 && (int)st_shti_bp_reallocate(v10 + 1, 0LL, a5, a6, a7) > 0 )
{
fwrite("Error: Could not reallocate memory!\n", 1uLL, 0x24uLL, stderr);
v12 = 1;
}
else
{
while ( 1 )
{
v11 = st_shti_bp_branch_once((unsigned int)*a1, v22, v19, a5, a7);
if ( v11 )
{
if ( v11 == 1 )
{
fprintf(stderr, "Error: Insertion of the suffix number %zu failed!\n", a4);
v12 = 6;
}
else
{
v12 = st_shti_bp_create_leaf(
(unsigned int)*a1,
(unsigned int)*(char *)(a5 + a4 + *(unsigned int *)(a7[9] + 16LL * *a1 + 4)),
(unsigned int)-(int)a4,
a5,
a7);
if ( v12 )
{
fwrite("Error: Could not create a new leaf of the parent!\n", 1uLL, 0x32uLL, stderr);
v12 = 7;
}
else if ( *a1 > 1 )
{
*a1 = *(_DWORD *)(a7[9] + 16LL * *a1 + 12);
}
}
return v12;
}
if ( (unsigned int)st_shti_bp_edge_slowscan((unsigned int)*a1, (unsigned int)v22[0], v19, &v20, a5, a6 + 1, a7) )
break;
st_shti_bp_edge_descend(a1, v22, &v21, &v19, a6 + 1, a7);
if ( *a1 < 0 )
{
fwrite(
"Error: The newly inserted suffix already has the corresponding leaf node\npresent in the suffix tree!\n",
1uLL,
0x65uLL,
stderr);
return 2;
}
}
v14 = v22[0];
if ( (unsigned int)st_shti_bp_split_edge(
a1,
(unsigned int)*(char *)(a5 + v19),
v22,
&v19,
v20,
(unsigned int)a4,
a5,
a7) )
{
fwrite("Error: Could not split the parent->child edge!\n", 1uLL, 0x2FuLL, stderr);
return 3;
}
v12 = st_shti_bp_create_leaf((unsigned int)*a1, (unsigned int)*(char *)(a5 + v19), (unsigned int)-(int)a4, a5, a7);
if ( v12 )
{
fwrite("Error: Could not create a new leaf of the parent!\n", 1uLL, 0x32uLL, stderr);
return 4;
}
v15 = (unsigned int)*a2;
if ( (_DWORD)v15 )
{
if ( (unsigned int)*a3 + a4 != v19 )
{
fprintf(
stderr,
"Error! The last opportunity to set the target of a suffix link missed! (suffix link source = %d)\n",
v15);
return 5;
}
*(_DWORD *)(a7[9] + 16LL * (int)v15 + 12) = *a1;
}
v16 = *a1;
*a2 = *a1;
v17 = (unsigned int)(*(_DWORD *)(a7[9] + 16LL * v16 + 4) - 1);
*a3 = v17;
if ( !(unsigned int)func0(a1, v14, v17, (__int64)a7) )
{
*a2 = 0;
*a3 = 0;
v12 = 0;
}
}
return v12;
}

original_code:
int st_shti_bp_mccreight_insert_suffix (signed_integral_type *parent,
  signed_integral_type *sl_source,
  unsigned_integral_type *sl_targets_depth,
  size_t starting_position,
  const character_type *text,
  size_t length,
  suffix_tree_shti_bp *stree) {
 character_type letter = 0;
 signed_integral_type latest_child = 0;
 signed_integral_type child = 0;
 signed_integral_type prev_child = 0;
 signed_integral_type last_match_position = 0;
 size_t position = starting_position +
  stree->tbranch[(*parent)].depth;
 size_t tbranch_size = stree->tbranch_size;
 int tmp = 0;
 if ((tbranch_size == stree->branching_nodes) &&
   (tbranch_size < length)) {
  if (st_shti_bp_reallocate(tbranch_size + 1, (size_t)(0),
     text, length, stree) > 0) {
   fprintf(stderr, "Error: Could not "
     "reallocate memory!\n");
   return (1);
  }
 }
 while ((tmp = st_shti_bp_branch_once((*parent), &child,
     position, text, stree)) == 0) {
  if (st_shti_bp_edge_slowscan((*parent), child, position,
   &last_match_position, text, length + 1, stree) == 0) {
   st_shti_bp_edge_descend(parent, &child, &prev_child,
     &position, length + 1, stree);
   if ((*parent) < 0) {
    fprintf(stderr, "Error: The newly inserted "
      "suffix already has the "
      "corresponding leaf node\n"
      "present in the "
      "suffix tree!\n");
    return (2);
   }
  } else {
   latest_child = child;
   letter = text[position];
   if (st_shti_bp_split_edge(parent, letter, &child,
     &position, last_match_position,
    (unsigned_integral_type)(starting_position),
     text, stree) != 0) {
    fprintf(stderr, "Error: Could not split "
      "the parent->child edge!\n");
    return (3);
   }
   letter = text[position];
   if (st_shti_bp_create_leaf((*parent), letter,
    (-(signed_integral_type)(starting_position)),
    text, stree)) {
    fprintf(stderr, "Error: Could not create "
      "a new leaf of the parent!\n");
    return (4);
   }
   if ((*sl_source) != 0) {
    if (position == starting_position +
      (*sl_targets_depth)) {
     stree->tbranch[(*sl_source)].
      suffix_link = (*parent);
    } else {
     fprintf(stderr, "Error! The last "
       "opportunity to "
       "set the target "
       "of a suffix link "
       "missed! (suffix "
       "link source = %d)\n",
       (*sl_source));
     return (5);
    }
   }
   (*sl_source) = (*parent);
   (*sl_targets_depth) =
    stree->tbranch[(*parent)].depth - 1;
   if (st_shti_bp_simulate_suffix_link_bottom_up(parent,
     latest_child, (*sl_targets_depth),
     stree) == 0) {
    (*sl_source) = 0;
    (*sl_targets_depth) = 0;
   }
   return (0);
  }
 }
 if (tmp == 1) {
  fprintf(stderr, "Error: Insertion of the suffix number "
    "%zu failed!\n", starting_position);
  return (6);
 } else {
  letter = text[starting_position +
   stree->tbranch[(*parent)].depth];
  if (st_shti_bp_create_leaf((*parent), letter,
   (-(signed_integral_type)(starting_position)),
   text, stree)) {
   fprintf(stderr, "Error: Could not create "
     "a new leaf of the parent!\n");
   return (7);
  }
 }
 if ((*parent) > 1) {
  (*parent) = stree->tbranch[(*parent)].suffix_link;
 }
 return (0);
}

canonical_original_code:
int st_shti_bp_mccreight_insert_suffix(int *parent, int *sl_source, unsigned int *sl_targets_depth, unsigned long starting_position, char *text, unsigned long length, struct suffix_tree_shti_bp_struct *stree) {
 char letter = 0;
 int latest_child = 0;
 int child = 0;
 int prev_child = 0;
 int last_match_position = 0;
 unsigned long position = starting_position +
  stree->tbranch[(*parent)].depth;
 unsigned long tbranch_size = stree->tbranch_size;
 int tmp = 0;
 if ((tbranch_size == stree->branching_nodes) &&
   (tbranch_size < length)) {
  if (st_shti_bp_reallocate(tbranch_size + 1, (unsigned long)(0),
     text, length, stree) > 0) {
   fprintf(stderr, "Error: Could not "
     "reallocate memory!\n");
   return (1);
  }
 }
 while ((tmp = st_shti_bp_branch_once((*parent), &child,
     position, text, stree)) == 0) {
  if (st_shti_bp_edge_slowscan((*parent), child, position,
   &last_match_position, text, length + 1, stree) == 0) {
   st_shti_bp_edge_descend(parent, &child, &prev_child,
     &position, length + 1, stree);
   if ((*parent) < 0) {
    fprintf(stderr, "Error: The newly inserted "
      "suffix already has the "
      "corresponding leaf node\n"
      "present in the "
      "suffix tree!\n");
    return (2);
   }
  } else {
   latest_child = child;
   letter = text[position];
   if (st_shti_bp_split_edge(parent, letter, &child,
     &position, last_match_position,
    (unsigned_integral_type)(starting_position),
     text, stree) != 0) {
    fprintf(stderr, "Error: Could not split "
      "the parent->child edge!\n");
    return (3);
   }
   letter = text[position];
   if (st_shti_bp_create_leaf((*parent), letter,
    (-(signed_integral_type)(starting_position)),
    text, stree)) {
    fprintf(stderr, "Error: Could not create "
      "a new leaf of the parent!\n");
    return (4);
   }
   if ((*sl_source) != 0) {
    if (position == starting_position +
      (*sl_targets_depth)) {
     stree->tbranch[(*sl_source)].
      suffix_link = (*parent);
    } else {
     fprintf(stderr, "Error! The last "
       "opportunity to "
       "set the target "
       "of a suffix link "
       "missed! (suffix "
       "link source = %d)\n",
       (*sl_source));
     return (5);
    }
   }
   (*sl_source) = (*parent);
   (*sl_targets_depth) =
    stree->tbranch[(*parent)].depth - 1;
   if (st_shti_bp_simulate_suffix_link_bottom_up(parent,
     latest_child, (*sl_targets_depth),
     stree) == 0) {
    (*sl_source) = 0;
    (*sl_targets_depth) = 0;
   }
   return (0);
  }
 }
 if (tmp == 1) {
  fprintf(stderr, "Error: Insertion of the suffix number "
    "%zu failed!\n", starting_position);
  return (6);
 } else {
  letter = text[starting_position +
   stree->tbranch[(*parent)].depth];
  if (st_shti_bp_create_leaf((*parent), letter,
   (-(signed_integral_type)(starting_position)),
   text, stree)) {
   fprintf(stderr, "Error: Could not create "
     "a new leaf of the parent!\n");
   return (7);
  }
 }
 if ((*parent) > 1) {
  (*parent) = stree->tbranch[(*parent)].suffix_link;
 }
 return (0);
}

variable_types: letter char

user_defined_types: struct hash_settings_struct { int crt_type; unsigned int phf_max; unsigned int shf_max; unsigned long chf_number; unsigned int npu_size; unsigned int *chf_as; unsigned int *chf_bs; unsigned long *cp_offsets; unsigned long *cp_sizes; unsigned long allocated_size; }

user_defined_types: struct leaf_record_shti_bp_struct { int parent; }

user_defined_types: struct edge_record_struct { int source_node; int target_node; }

user_defined_types: struct branch_record_shti_bp_struct { int parent; unsigned int depth; unsigned int head_position; int suffix_link; }


repo: pbasista/stc

decompiled_code:
__int64 __fastcall st_shti_bp_ukkonen_prolong_suffix(__int64 a1, __int64 a2, __int64 *a3, int *a4, int *a5, _DWORD *a6, __int64 a7, __int64 a8)
{
int v9; // eax
int v10; // eax
int v11; // er15
unsigned int v12; // er12
int v14; // er13
__int64 v15; // rdx
int v16; // eax
__int64 v17; // rdx
__int64 v21; // [rsp+28h] [rbp-50h] BYREF
unsigned int v22; // [rsp+34h] [rbp-44h] BYREF
int v23; // [rsp+38h] [rbp-40h] BYREF
int v24[15]; // [rsp+3Ch] [rbp-3Ch] BYREF

v24[0] = 0;
v23 = 0;
v22 = 0;
v21 = *a3;
if ( a1 == a2 )
return (unsigned int)-1;
while ( 1 )
{
v9 = st_shti_bp_branch_once((unsigned int)*a4, v24, v21, a7, a8);
if ( v9 )
{
if ( v9 == 1 )
{
fprintf(stderr, "Error: Prolonging of the suffix number %zu to the length of %zu failed!\n", a1, a2 - a1);
v12 = 4;
}
else
{
v12 = st_shti_bp_create_leaf(
(unsigned int)*a4,
(unsigned int)*(char *)(a7 + a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4)),
(unsigned int)-(int)a1,
a7,
a8);
if ( v12 )
{
fwrite("Error: Could not create a new leaf of the parent!\n", 1uLL, 0x32uLL, stderr);
v12 = 5;
}
else
{
if ( *a4 > 1 )
*a4 = *(_DWORD *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 12);
*a3 = a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4) + 1;
}
}
return v12;
}
v10 = st_shti_bp_edge_slowscan((unsigned int)*a4, (unsigned int)v24[0], v21, &v22, a7, a2 - 1, a8);
if ( v10 )
break;
v11 = *a4;
st_shti_bp_edge_descend(a4, v24, &v23, &v21, a2 - 1, a8);
if ( *a4 < 0 )
{
*a4 = v11;
if ( v11 != 1 )
*a4 = *(_DWORD *)(*(_QWORD *)(a8 + 72) + 16LL * v11 + 12);
*a3 = a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4) + 1;
return (unsigned int)-2;
}
if ( a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4) == a2 )
{
*a3 = a2;
return (unsigned int)-3;
}
}
if ( v10 == 2 )
{
*a3 = a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4);
return (unsigned int)-4;
}
v14 = v24[0];
if ( (unsigned int)st_shti_bp_split_edge(
a4,
(unsigned int)*(char *)(a7 + v21),
v24,
&v21,
v22,
(unsigned int)a1,
a7,
a8) )
{
fwrite("Error: Could not split the parent->child edge!\n", 1uLL, 0x2FuLL, stderr);
return 1;
}
v12 = st_shti_bp_create_leaf((unsigned int)*a4, (unsigned int)*(char *)(a7 + v21), (unsigned int)-(int)a1, a7, a8);
if ( v12 )
{
fwrite("Error: Could not create a new leaf of the parent!\n", 1uLL, 0x32uLL, stderr);
return 2;
}
v15 = (unsigned int)*a5;
if ( (_DWORD)v15 )
{
if ( a1 + (unsigned int)*a6 != v21 )
{
fprintf(
stderr,
"Error! The last opportunity to set the target of a suffix link missed! (suffix link source = %d)\n",
v15);
return 3;
}
*(_DWORD *)(*(_QWORD *)(a8 + 72) + 16LL * (int)v15 + 12) = *a4;
}
v16 = *a4;
*a5 = *a4;
v17 = (unsigned int)(*(_DWORD *)(*(_QWORD *)(a8 + 72) + 16LL * v16 + 4) - 1);
*a6 = v17;
if ( !(unsigned int)st_shti_bp_simulate_suffix_link_bottom_up(a4, v14, v17, a8) )
{
*a5 = 0;
*a6 = 0;
}
*a3 = a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4) + 1;
return v12;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 *a3, int *a4, int *a5, _DWORD *a6, __int64 a7, __int64 a8)
{
int v9; // eax
int v10; // eax
int v11; // er15
unsigned int v12; // er12
int v14; // er13
__int64 v15; // rdx
int v16; // eax
__int64 v17; // rdx
__int64 v21; // [rsp+28h] [rbp-50h] BYREF
unsigned int v22; // [rsp+34h] [rbp-44h] BYREF
int v23; // [rsp+38h] [rbp-40h] BYREF
int v24[15]; // [rsp+3Ch] [rbp-3Ch] BYREF

v24[0] = 0;
v23 = 0;
v22 = 0;
v21 = *a3;
if ( a1 == a2 )
return (unsigned int)-1;
while ( 1 )
{
v9 = st_shti_bp_branch_once((unsigned int)*a4, v24, v21, a7, a8);
if ( v9 )
{
if ( v9 == 1 )
{
fprintf(stderr, "Error: Prolonging of the suffix number %zu to the length of %zu failed!\n", a1, a2 - a1);
v12 = 4;
}
else
{
v12 = st_shti_bp_create_leaf(
(unsigned int)*a4,
(unsigned int)*(char *)(a7 + a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4)),
(unsigned int)-(int)a1,
a7,
a8);
if ( v12 )
{
fwrite("Error: Could not create a new leaf of the parent!\n", 1uLL, 0x32uLL, stderr);
v12 = 5;
}
else
{
if ( *a4 > 1 )
*a4 = *(_DWORD *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 12);
*a3 = a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4) + 1;
}
}
return v12;
}
v10 = st_shti_bp_edge_slowscan((unsigned int)*a4, (unsigned int)v24[0], v21, &v22, a7, a2 - 1, a8);
if ( v10 )
break;
v11 = *a4;
st_shti_bp_edge_descend(a4, v24, &v23, &v21, a2 - 1, a8);
if ( *a4 < 0 )
{
*a4 = v11;
if ( v11 != 1 )
*a4 = *(_DWORD *)(*(_QWORD *)(a8 + 72) + 16LL * v11 + 12);
*a3 = a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4) + 1;
return (unsigned int)-2;
}
if ( a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4) == a2 )
{
*a3 = a2;
return (unsigned int)-3;
}
}
if ( v10 == 2 )
{
*a3 = a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4);
return (unsigned int)-4;
}
v14 = v24[0];
if ( (unsigned int)st_shti_bp_split_edge(
a4,
(unsigned int)*(char *)(a7 + v21),
v24,
&v21,
v22,
(unsigned int)a1,
a7,
a8) )
{
fwrite("Error: Could not split the parent->child edge!\n", 1uLL, 0x2FuLL, stderr);
return 1;
}
v12 = st_shti_bp_create_leaf((unsigned int)*a4, (unsigned int)*(char *)(a7 + v21), (unsigned int)-(int)a1, a7, a8);
if ( v12 )
{
fwrite("Error: Could not create a new leaf of the parent!\n", 1uLL, 0x32uLL, stderr);
return 2;
}
v15 = (unsigned int)*a5;
if ( (_DWORD)v15 )
{
if ( a1 + (unsigned int)*a6 != v21 )
{
fprintf(
stderr,
"Error! The last opportunity to set the target of a suffix link missed! (suffix link source = %d)\n",
v15);
return 3;
}
*(_DWORD *)(*(_QWORD *)(a8 + 72) + 16LL * (int)v15 + 12) = *a4;
}
v16 = *a4;
*a5 = *a4;
v17 = (unsigned int)(*(_DWORD *)(*(_QWORD *)(a8 + 72) + 16LL * v16 + 4) - 1);
*a6 = v17;
if ( !(unsigned int)func0(a4, v14, v17, a8) )
{
*a5 = 0;
*a6 = 0;
}
*a3 = a1 + *(unsigned int *)(*(_QWORD *)(a8 + 72) + 16LL * *a4 + 4) + 1;
return v12;
}

original_code:
int st_shti_bp_ukkonen_prolong_suffix (size_t starting_position,
  size_t ending_position,
  size_t *active_index,
  signed_integral_type *parent,
  signed_integral_type *sl_source,
  unsigned_integral_type *sl_targets_depth,
  const character_type *text,
  suffix_tree_shti_bp *stree) {
 character_type letter = 0;
 signed_integral_type latest_child = 0;
 signed_integral_type grandpa = 0;
 signed_integral_type child = 0;
 signed_integral_type prev_child = 0;
 signed_integral_type last_match_position = 0;
 size_t position = (*active_index);
 int tmp = 0;
 int slowscan_return = 0;
 if (starting_position == ending_position) {
  return (-1);
 }
 while ((tmp = st_shti_bp_branch_once((*parent), &child,
     position, text, stree)) == 0) {
  if ((slowscan_return = st_shti_bp_edge_slowscan((*parent),
    child, position, &last_match_position, text,
    ending_position - 1, stree)) == 0) {
   grandpa = (*parent);
   st_shti_bp_edge_descend(parent, &child, &prev_child,
     &position, ending_position - 1, stree);
   if ((*parent) < 0) {
    (*parent) = grandpa;
    if ((*parent) != 1) {
     (*parent) = stree->tbranch[(*parent)].
      suffix_link;
    }
    (*active_index) = starting_position + 1 +
     stree->tbranch[(*parent)].depth;
    return (-2);
   } else if (starting_position +
     stree->tbranch[(*parent)].depth ==
     ending_position) {
    (*active_index) = starting_position +
     stree->tbranch[(*parent)].depth;
    return (-3);
   }
  } else if (slowscan_return == 2) {
   (*active_index) = starting_position +
    stree->tbranch[(*parent)].depth;
   return (-4);
  } else {
   latest_child = child;
   letter = text[position];
   if (st_shti_bp_split_edge(parent, letter, &child,
     &position, last_match_position,
    (unsigned_integral_type)(starting_position),
     text, stree) != 0) {
    fprintf(stderr, "Error: Could not split "
      "the parent->child edge!\n");
    return (1);
   }
   letter = text[position];
   if (st_shti_bp_create_leaf((*parent), letter,
    (-(signed_integral_type)(starting_position)),
    text, stree)) {
    fprintf(stderr, "Error: Could not create "
      "a new leaf of the parent!\n");
    return (2);
   }
   if ((*sl_source) != 0) {
    if (position == starting_position +
      (*sl_targets_depth)) {
     stree->tbranch[(*sl_source)].
      suffix_link = (*parent);
    } else {
     fprintf(stderr, "Error! The last "
       "opportunity to "
       "set the target "
       "of a suffix link "
       "missed! (suffix "
       "link source = %d)\n",
       (*sl_source));
     return (3);
    }
   }
   (*sl_source) = (*parent);
   (*sl_targets_depth) =
    stree->tbranch[(*parent)].depth - 1;
   if (st_shti_bp_simulate_suffix_link_bottom_up(parent,
     latest_child, (*sl_targets_depth),
     stree) == 0) {
    (*sl_source) = 0;
    (*sl_targets_depth) = 0;
   }
   (*active_index) = starting_position + 1 +
    stree->tbranch[(*parent)].depth;
   return (0);
  }
 }
 if (tmp == 1) {
  fprintf(stderr, "Error: Prolonging of the suffix number "
    "%zu to the length of %zu failed!\n",
    starting_position,
    ending_position - starting_position);
  return (4);
 } else {
  letter = text[starting_position +
   stree->tbranch[(*parent)].depth];
  if (st_shti_bp_create_leaf((*parent), letter,
   (-(signed_integral_type)(starting_position)),
   text, stree)) {
   fprintf(stderr, "Error: Could not create "
     "a new leaf of the parent!\n");
   return (5);
  }
 }
 if ((*parent) > 1) {
  (*parent) = stree->tbranch[(*parent)].suffix_link;
 }
 (*active_index) = starting_position + 1 +
  stree->tbranch[(*parent)].depth;
 return (0);
}

canonical_original_code:
int st_shti_bp_ukkonen_prolong_suffix(unsigned long starting_position, unsigned long ending_position, unsigned long *active_index, int *parent, int *sl_source, unsigned int *sl_targets_depth, char *text, struct suffix_tree_shti_bp_struct *stree) {
 char letter = 0;
 int latest_child = 0;
 int grandpa = 0;
 int child = 0;
 int prev_child = 0;
 int last_match_position = 0;
 unsigned long position = (*active_index);
 int tmp = 0;
 int slowscan_return = 0;
 if (starting_position == ending_position) {
  return (-1);
 }
 while ((tmp = st_shti_bp_branch_once((*parent), &child,
     position, text, stree)) == 0) {
  if ((slowscan_return = st_shti_bp_edge_slowscan((*parent),
    child, position, &last_match_position, text,
    ending_position - 1, stree)) == 0) {
   grandpa = (*parent);
   st_shti_bp_edge_descend(parent, &child, &prev_child,
     &position, ending_position - 1, stree);
   if ((*parent) < 0) {
    (*parent) = grandpa;
    if ((*parent) != 1) {
     (*parent) = stree->tbranch[(*parent)].
      suffix_link;
    }
    (*active_index) = starting_position + 1 +
     stree->tbranch[(*parent)].depth;
    return (-2);
   } else if (starting_position +
     stree->tbranch[(*parent)].depth ==
     ending_position) {
    (*active_index) = starting_position +
     stree->tbranch[(*parent)].depth;
    return (-3);
   }
  } else if (slowscan_return == 2) {
   (*active_index) = starting_position +
    stree->tbranch[(*parent)].depth;
   return (-4);
  } else {
   latest_child = child;
   letter = text[position];
   if (st_shti_bp_split_edge(parent, letter, &child,
     &position, last_match_position,
    (unsigned_integral_type)(starting_position),
     text, stree) != 0) {
    fprintf(stderr, "Error: Could not split "
      "the parent->child edge!\n");
    return (1);
   }
   letter = text[position];
   if (st_shti_bp_create_leaf((*parent), letter,
    (-(signed_integral_type)(starting_position)),
    text, stree)) {
    fprintf(stderr, "Error: Could not create "
      "a new leaf of the parent!\n");
    return (2);
   }
   if ((*sl_source) != 0) {
    if (position == starting_position +
      (*sl_targets_depth)) {
     stree->tbranch[(*sl_source)].
      suffix_link = (*parent);
    } else {
     fprintf(stderr, "Error! The last "
       "opportunity to "
       "set the target "
       "of a suffix link "
       "missed! (suffix "
       "link source = %d)\n",
       (*sl_source));
     return (3);
    }
   }
   (*sl_source) = (*parent);
   (*sl_targets_depth) =
    stree->tbranch[(*parent)].depth - 1;
   if (st_shti_bp_simulate_suffix_link_bottom_up(parent,
     latest_child, (*sl_targets_depth),
     stree) == 0) {
    (*sl_source) = 0;
    (*sl_targets_depth) = 0;
   }
   (*active_index) = starting_position + 1 +
    stree->tbranch[(*parent)].depth;
   return (0);
  }
 }
 if (tmp == 1) {
  fprintf(stderr, "Error: Prolonging of the suffix number "
    "%zu to the length of %zu failed!\n",
    starting_position,
    ending_position - starting_position);
  return (4);
 } else {
  letter = text[starting_position +
   stree->tbranch[(*parent)].depth];
  if (st_shti_bp_create_leaf((*parent), letter,
   (-(signed_integral_type)(starting_position)),
   text, stree)) {
   fprintf(stderr, "Error: Could not create "
     "a new leaf of the parent!\n");
   return (5);
  }
 }
 if ((*parent) > 1) {
  (*parent) = stree->tbranch[(*parent)].suffix_link;
 }
 (*active_index) = starting_position + 1 +
  stree->tbranch[(*parent)].depth;
 return (0);
}

variable_types:
parent
int *

variable_types:
text
char *

variable_types: struct suffix_tree_shti_bp_struct { unsigned long hs_size; unsigned long lr_size; unsigned long er_size; unsigned long br_size; int crt_type; unsigned long chf_number; struct hash_settings_struct { int crt_type; unsigned int phf_max; unsigned int shf_max; unsigned long chf_number; unsigned int npu_size; unsigned int *chf_as; unsigned int *chf_bs; unsigned long *cp_offsets; unsigned long *cp_sizes; unsigned long allocated_size; } *hs; struct leaf_record_shti_bp_struct { int parent; } *tleaf; struct edge_record_struct { int source_node; int target_node; } *tedge; struct branch_record_shti_bp_struct { int parent; unsigned int depth; unsigned int head_position; int suffix_link; } *tbranch; unsigned long edges; unsigned long tedge_size; unsigned long tesize_increase; unsigned long branching_nodes; unsigned long tbranch_size; unsigned long tbsize_increase; } *

variable_types: grandpa int

variable_types: child int

variable_types:
position
unsigned long

variable_types: tmp int

return_type: int

user_defined_types: struct suffix_tree_shti_bp_struct { unsigned long hs_size; unsigned long lr_size; unsigned long er_size; unsigned long br_size; int crt_type; unsigned long chf_number; struct hash_settings_struct *hs; struct leaf_record_shti_bp_struct *tleaf; struct edge_record_struct *tedge; struct branch_record_shti_bp_struct *tbranch; unsigned long edges; unsigned long tedge_size; unsigned long tesize_increase; unsigned long branching_nodes; unsigned long tbranch_size; unsigned long tbsize_increase; }


decompiled_code:
__int64 __fastcall st_shti_bp_ukkonen_prolong_suffixes(__int64 *a1, __int64 a2, __int64 *a3, int *a4, __int64 a5, unsigned __int64 a6, __int64 a7)
{
unsigned __int64 v11; // rdi
unsigned __int64 v12; // rax
unsigned int v13; // edx
int v14; // eax
__int64 v15; // rdi
int v17; // [rsp+8h] [rbp-40h] BYREF
int v18[15]; // [rsp+Ch] [rbp-3Ch] BYREF

v18[0] = 0;
v17 = 0;
v11 = *(_QWORD *)(a7 + 104) + a2 - 1 - *a1;
v12 = a6;
if ( v11 <= a6 )
v12 = v11;
if ( v12 <= *(_QWORD *)(a7 + 112) || (int)st_shti_bp_reallocate(v11, 0LL, a5, a6, a7) <= 0 )
{
while ( 1 )
{
v14 = st_shti_bp_ukkonen_prolong_suffix(*a1, a2, a3, a4, v18, &v17, a5, a7);
if ( v14 != -1 )
break;
++*a1;
}
for ( ; !v14; v14 = st_shti_bp_ukkonen_prolong_suffix(v15, a2, a3, a4, v18, &v17, a5, a7) )
{
v15 = *a1 + 1;
*a1 = v15;
}
v13 = 0;
if ( v14 > 0 )
{
fprintf(stderr, "Error: Could not prolong suffixes to the ending position %zu!\n", a2);
v13 = 2;
}
}
else
{
fwrite("Error: Could not reallocate memory!\n", 1uLL, 0x24uLL, stderr);
v13 = 1;
}
return v13;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1, __int64 a2, __int64 *a3, int *a4, __int64 a5, unsigned __int64 a6, __int64 a7)
{
unsigned __int64 v11; // rdi
unsigned __int64 v12; // rax
unsigned int v13; // edx
int v14; // eax
__int64 v15; // rdi
int v17; // [rsp+8h] [rbp-40h] BYREF
int v18[15]; // [rsp+Ch] [rbp-3Ch] BYREF

v18[0] = 0;
v17 = 0;
v11 = *(_QWORD *)(a7 + 104) + a2 - 1 - *a1;
v12 = a6;
if ( v11 <= a6 )
v12 = v11;
if ( v12 <= *(_QWORD *)(a7 + 112) || (int)st_shti_bp_reallocate(v11, 0LL, a5, a6, a7) <= 0 )
{
while ( 1 )
{
v14 = func2(*a1, a2, a3, a4, v18, &v17, a5, a7);
if ( v14 != -1 )
break;
++*a1;
}
for ( ; !v14; v14 = func2(v15, a2, a3, a4, v18, &v17, a5, a7) )
{
v15 = *a1 + 1;
*a1 = v15;
}
v13 = 0;
if ( v14 > 0 )
{
fprintf(stderr, "Error: Could not prolong suffixes to the ending position %zu!\n", a2);
v13 = 2;
}
}
else
{
fwrite("Error: Could not reallocate memory!\n", 1uLL, 0x24uLL, stderr);
v13 = 1;
}
return v13;
}

original_code:
int st_shti_bp_ukkonen_prolong_suffixes (size_t *starting_position,
  size_t ending_position,
  size_t *active_index,
  signed_integral_type *active_node,
  const character_type *text,
  size_t length,
  suffix_tree_shti_bp *stree) {
 signed_integral_type sl_source = 0;
 unsigned_integral_type sl_targets_depth = 0;
 size_t maximum_possible_size = stree->branching_nodes +
  ending_position - (*starting_position) - 1;
 int tmp = 0;
 size_t tbranch_size = (size_t)(stree->tbranch_size);
 if ((tbranch_size < maximum_possible_size) &&
   (tbranch_size < length)) {
  if (st_shti_bp_reallocate(maximum_possible_size, (size_t)(0),
     text, length, stree) > 0) {
   fprintf(stderr, "Error: Could not "
     "reallocate memory!\n");
   return (1);
  }
 }
 while ((tmp = st_shti_bp_ukkonen_prolong_suffix((*starting_position),
     ending_position, active_index,
     active_node, &sl_source,
     &sl_targets_depth, text,
     stree)) == (-1)) {
  ++(*starting_position);
 }
 while (tmp == 0) {
  ++(*starting_position);
  tmp = st_shti_bp_ukkonen_prolong_suffix((*starting_position),
   ending_position, active_index, active_node, &sl_source,
   &sl_targets_depth, text, stree);
 }
 if (tmp > 0) {
  fprintf(stderr, "Error: Could not prolong suffixes "
    "to the ending position %zu!\n",
    ending_position);
  return (2);
 }
 return (0);
}

canonical_original_code:
int st_shti_bp_ukkonen_prolong_suffixes(unsigned long *starting_position, unsigned long ending_position, unsigned long *active_index, int *active_node, char *text, unsigned long length, struct suffix_tree_shti_bp_struct *stree) {
 int sl_source = 0;
 unsigned int sl_targets_depth = 0;
 unsigned long maximum_possible_size = stree->branching_nodes +
  ending_position - (*starting_position) - 1;
 int tmp = 0;
 unsigned long tbranch_size = (size_t)(stree->tbranch_size);
 if ((tbranch_size < maximum_possible_size) &&
   (tbranch_size < length)) {
  if (st_shti_bp_reallocate(maximum_possible_size, (unsigned long)(0),
     text, length, stree) > 0) {
   fprintf(stderr, "Error: Could not "
     "reallocate memory!\n");
   return (1);
  }
 }
 while ((tmp = st_shti_bp_ukkonen_prolong_suffix((*starting_position),
     ending_position, active_index,
     active_node, &sl_source,
     &sl_targets_depth, text,
     stree)) == (-1)) {
  ++(*starting_position);
 }
 while (tmp == 0) {
  ++(*starting_position);
  tmp = st_shti_bp_ukkonen_prolong_suffix((*starting_position),
   ending_position, active_index, active_node, &sl_source,
   &sl_targets_depth, text, stree);
 }
 if (tmp > 0) {
  fprintf(stderr, "Error: Could not prolong suffixes "
    "to the ending position %zu!\n",
    ending_position);
  return (2);
 }
 return (0);
}

variable_types:
length
unsigned long


decompiled_code:
__int64 __fastcall st_shti_bp_create_mccreight(__int64 a1, unsigned __int64 a2, _QWORD *a3)
{
__int64 v4; // rbx
__int64 result; // rax
int v6; // [rsp+4h] [rbp-34h] BYREF
int v7; // [rsp+8h] [rbp-30h] BYREF
int v8[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v8[0] = 1;
v7 = 0;
v6 = 0;
puts("Creating suffix tree using McCright's algorithm\n");
if ( (int)st_shti_bp_allocate(a2, a3) > 0 )
{
fwrite("Allocation error. Exiting.\n", 1uLL, 0x1BuLL, stderr);
result = 1LL;
}
else
{
v4 = 1LL;
if ( a2 >= 0xFFFFFFFFFFFFFFFELL )
{
LABEL_5:
puts("\nThe suffix tree has been successfully created.");
st_print_stats(
a2,
a3[10],
a3[13],
0LL,
a3[11],
a3[14],
0LL,
a3[1],
a3[2],
a3[3],
0LL,
*(_QWORD *)(a3[6] + 64LL),
*(_QWORD *)(a3[6] + 64LL));
result = 0LL;
}
else
{
while ( (int)st_shti_bp_mccreight_insert_suffix(v8, &v7, &v6, v4, a1, a2, a3) <= 0 )
{
if ( ++v4 == a2 + 2 )
goto LABEL_5;
}
fprintf(stderr, "Could not insert suffix number %zu. Exiting.\n", v4);
result = 2LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned __int64 a2, _QWORD *a3)
{
__int64 v4; // rbx
__int64 result; // rax
int v6; // [rsp+4h] [rbp-34h] BYREF
int v7; // [rsp+8h] [rbp-30h] BYREF
int v8[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v8[0] = 1;
v7 = 0;
v6 = 0;
puts("Creating suffix tree using McCright's algorithm\n");
if ( (int)st_shti_bp_allocate(a2, a3) > 0 )
{
fwrite("Allocation error. Exiting.\n", 1uLL, 0x1BuLL, stderr);
result = 1LL;
}
else
{
v4 = 1LL;
if ( a2 >= 0xFFFFFFFFFFFFFFFELL )
{
LABEL_5:
puts("\nThe suffix tree has been successfully created.");
st_print_stats(
a2,
a3[10],
a3[13],
0LL,
a3[11],
a3[14],
0LL,
a3[1],
a3[2],
a3[3],
0LL,
*(_QWORD *)(a3[6] + 64LL),
*(_QWORD *)(a3[6] + 64LL));
result = 0LL;
}
else
{
while ( (int)func1(v8, &v7, &v6, v4, a1, a2, a3) <= 0 )
{
if ( ++v4 == a2 + 2 )
goto LABEL_5;
}
fprintf(stderr, "Could not insert suffix number %zu. Exiting.\n", v4);
result = 2LL;
}
}
return result;
}

original_code:
int st_shti_bp_create_mccreight (const character_type *text,
  size_t length,
  suffix_tree_shti_bp *stree) {
 signed_integral_type starting_node = 1;
 signed_integral_type sl_source = 0;
 unsigned_integral_type sl_targets_depth = 0;
 size_t i = 1;
 printf("Creating suffix tree using McCright's algorithm\n\n");
 if (st_shti_bp_allocate(length, stree) > 0) {
  fprintf(stderr, "Allocation error. Exiting.\n");
  return (1);
 }
 for (i = 1; i < length + 2; ++i) {
  if (st_shti_bp_mccreight_insert_suffix(&starting_node,
     &sl_source, &sl_targets_depth, i,
     text, length, stree) > 0) {
   fprintf(stderr, "Could not insert suffix number "
     "%zu. Exiting.\n", i);
   return (2);
  }
 }
 printf("\nThe suffix tree has been successfully created.\n");
 st_print_stats(length, stree->edges, stree->branching_nodes,
   (size_t)(0), stree->tedge_size, stree->tbranch_size,
   (size_t)(0), stree->lr_size, stree->er_size,
   stree->br_size, (size_t)(0),
   stree->hs->allocated_size, stree->hs->allocated_size);
 return (0);
}

canonical_original_code:
int st_shti_bp_create_mccreight(char *text, unsigned long length, struct suffix_tree_shti_bp_struct *stree) {
 int starting_node = 1;
 int sl_source = 0;
 unsigned int sl_targets_depth = 0;
 unsigned long i = 1;
 printf("Creating suffix tree using McCright's algorithm\n\n");
 if (st_shti_bp_allocate(length, stree) > 0) {
  fprintf(stderr, "Allocation error. Exiting.\n");
  return (1);
 }
 for (i = 1; i < length + 2; ++i) {
  if (st_shti_bp_mccreight_insert_suffix(&starting_node,
     &sl_source, &sl_targets_depth, i,
     text, length, stree) > 0) {
   fprintf(stderr, "Could not insert suffix number "
     "%zu. Exiting.\n", i);
   return (2);
  }
 }
 printf("\nThe suffix tree has been successfully created.\n");
 st_print_stats(length, stree->edges, stree->branching_nodes,
   (unsigned long)(0), stree->tedge_size, stree->tbranch_size,
   (unsigned long)(0), stree->lr_size, stree->er_size,
   stree->br_size, (unsigned long)(0),
   stree->hs->allocated_size, stree->hs->allocated_size);
 return (0);
}

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall st_shti_bp_create_ukkonen(__int64 a1, unsigned __int64 a2, _QWORD *a3)
{
__int64 v4; // rbx
__int64 result; // rax
__int64 v6; // [rsp+8h] [rbp-40h] BYREF
__int64 v7; // [rsp+10h] [rbp-38h] BYREF
int v8[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v8[0] = 1;
v7 = 1LL;
v6 = 1LL;
puts("Creating suffix tree using Ukkonen's algorithm\n");
if ( (int)st_shti_bp_allocate(a2, a3) > 0 )
{
fwrite("Allocation error. Exiting.\n", 1uLL, 0x1BuLL, stderr);
result = 1LL;
}
else
{
v4 = 2LL;
if ( a2 >= 0xFFFFFFFFFFFFFFFELL )
{
LABEL_5:
puts("\nThe suffix tree has been successfully created.");
st_print_stats(
a2,
a3[10],
a3[13],
0LL,
a3[11],
a3[14],
0LL,
a3[1],
a3[2],
a3[3],
0LL,
*(_QWORD *)(a3[6] + 64LL),
*(_QWORD *)(a3[6] + 64LL));
result = 0LL;
}
else
{
while ( (int)st_shti_bp_ukkonen_prolong_suffixes(&v6, v4, &v7, v8, a1, a2, (__int64)a3) <= 0 )
{
if ( ++v4 > a2 + 2 )
goto LABEL_5;
}
fprintf(stderr, "Could not create the intermediate tree number %zu. Exiting.\n", v4 - 1);
result = 2LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned __int64 a2, _QWORD *a3)
{
__int64 v4; // rbx
__int64 result; // rax
__int64 v6; // [rsp+8h] [rbp-40h] BYREF
__int64 v7; // [rsp+10h] [rbp-38h] BYREF
int v8[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v8[0] = 1;
v7 = 1LL;
v6 = 1LL;
puts("Creating suffix tree using Ukkonen's algorithm\n");
if ( (int)st_shti_bp_allocate(a2, a3) > 0 )
{
fwrite("Allocation error. Exiting.\n", 1uLL, 0x1BuLL, stderr);
result = 1LL;
}
else
{
v4 = 2LL;
if ( a2 >= 0xFFFFFFFFFFFFFFFELL )
{
LABEL_5:
puts("\nThe suffix tree has been successfully created.");
st_print_stats(
a2,
a3[10],
a3[13],
0LL,
a3[11],
a3[14],
0LL,
a3[1],
a3[2],
a3[3],
0LL,
*(_QWORD *)(a3[6] + 64LL),
*(_QWORD *)(a3[6] + 64LL));
result = 0LL;
}
else
{
while ( (int)func3(&v6, v4, &v7, v8, a1, a2, (__int64)a3) <= 0 )
{
if ( ++v4 > a2 + 2 )
goto LABEL_5;
}
fprintf(stderr, "Could not create the intermediate tree number %zu. Exiting.\n", v4 - 1);
result = 2LL;
}
}
return result;
}

original_code:
int st_shti_bp_create_ukkonen (const character_type *text,
  size_t length,
  suffix_tree_shti_bp *stree) {
 signed_integral_type active_node = 1;
 size_t active_index = 1;
 size_t starting_position = 1;
 size_t i = 1;
 printf("Creating suffix tree using Ukkonen's algorithm\n\n");
 if (st_shti_bp_allocate(length, stree) > 0) {
  fprintf(stderr, "Allocation error. Exiting.\n");
  return (1);
 }
 for (i = 2; i <= length + 2; ++i) {
  if (st_shti_bp_ukkonen_prolong_suffixes(&starting_position, i,
     &active_index, &active_node, text,
     length, stree) > 0) {
   fprintf(stderr, "Could not create the intermediate "
     "tree number %zu. Exiting.\n", i - 1);
   return (2);
  }
 }
 printf("\nThe suffix tree has been successfully created.\n");
 st_print_stats(length, stree->edges, stree->branching_nodes,
   (size_t)(0), stree->tedge_size, stree->tbranch_size,
   (size_t)(0), stree->lr_size, stree->er_size,
   stree->br_size, (size_t)(0),
   stree->hs->allocated_size, stree->hs->allocated_size);
 return (0);
}

canonical_original_code:
int st_shti_bp_create_ukkonen(char *text, unsigned long length, struct suffix_tree_shti_bp_struct *stree) {
 int active_node = 1;
 unsigned long active_index = 1;
 unsigned long starting_position = 1;
 unsigned long i = 1;
 printf("Creating suffix tree using Ukkonen's algorithm\n\n");
 if (st_shti_bp_allocate(length, stree) > 0) {
  fprintf(stderr, "Allocation error. Exiting.\n");
  return (1);
 }
 for (i = 2; i <= length + 2; ++i) {
  if (st_shti_bp_ukkonen_prolong_suffixes(&starting_position, i,
     &active_index, &active_node, text,
     length, stree) > 0) {
   fprintf(stderr, "Could not create the intermediate "
     "tree number %zu. Exiting.\n", i - 1);
   return (2);
  }
 }
 printf("\nThe suffix tree has been successfully created.\n");
 st_print_stats(length, stree->edges, stree->branching_nodes,
   (unsigned long)(0), stree->tedge_size, stree->tbranch_size,
   (unsigned long)(0), stree->lr_size, stree->er_size,
   stree->br_size, (unsigned long)(0),
   stree->hs->allocated_size, stree->hs->allocated_size);
 return (0);
}


decompiled_code:
__int64 __fastcall hs_update(int a1, __int64 *a2, __int64 a3)
{
unsigned __int64 v5; // rdx
void *v6; // rax
int *v7; // rbp
void *v8; // rax
void *v9; // rax
void *v10; // rax
_QWORD *v11; // rbp
__int64 v12; // rdx
unsigned __int64 v13; // rax
unsigned int v14; // er12
__int64 v15; // rbp
__int64 result; // rax
__int64 v17; // rax
__int64 v18; // rsi

if ( !a3 )
{
fwrite("Error: The provided hash settings pointer is NULL!\n", 1uLL, 0x33uLL, stderr);
return 1LL;
}
if ( *(_DWORD *)a3 )
{
if ( *(_DWORD *)a3 != 1 )
{
if ( a1 > 1 )
{
puts("The selected collision resolution technique: double hashing");
if ( *a2 )
{
v18 = (unsigned int)next_prime(*a2);
}
else
{
fprintf(
stderr,
"\nWarning: The requested size of the hash table (%zu) is too small.\nIt will now be adjusted.\n\n",
0LL);
*a2 = 1LL;
v18 = (unsigned int)next_prime(1LL);
}
*a2 = v18;
printf("The new hash table size: %zu\n", v18);
}
else if ( *a2 )
{
*a2 = (unsigned int)next_prime(*a2);
}
else
{
fprintf(
stderr,
"\nWarning: The requested size of the hash table (%zu) is too small.\nIt will now be adjusted.\n\n",
0LL);
*a2 = 1LL;
*a2 = (unsigned int)next_prime(1LL);
}
*(_DWORD *)(a3 + 4) = *a2;
*(_DWORD *)(a3 + 8) = *a2 - 2;
return 0LL;
}
}
else
{
*(_DWORD *)a3 = 1;
}
if ( a1 > 1 )
puts("The selected collision resolution technique: Cuckoo hashing");
v5 = *(_QWORD *)(a3 + 16);
if ( v5 )
{
if ( v5 <= 1 )
{
fprintf(
stderr,
"Warning: The number of the Cuckoo hash functions\n"
"needs to be at least 2. The provided value (%zu)\n"
"will be adjusted to the default value of %zu.\n",
v5,
8uLL);
*(_QWORD *)(a3 + 16) = 8LL;
}
}
else
{
*(_QWORD *)(a3 + 16) = 8LL;
}
free(*(void **)(a3 + 32));
v6 = calloc(*(_QWORD *)(a3 + 16), 4uLL);
*(_QWORD *)(a3 + 32) = v6;
if ( v6 )
{
v7 = _errno_location();
*v7 = 0;
free(*(void **)(a3 + 40));
v8 = calloc(*(_QWORD *)(a3 + 16), 4uLL);
*(_QWORD *)(a3 + 40) = v8;
if ( v8 )
{
*v7 = 0;
free(*(void **)(a3 + 48));
v9 = calloc(*(_QWORD *)(a3 + 16), 8uLL);
*(_QWORD *)(a3 + 48) = v9;
if ( v9 )
{
*v7 = 0;
free(*(void **)(a3 + 56));
v10 = calloc(*(_QWORD *)(a3 + 16), 8uLL);
*(_QWORD *)(a3 + 56) = v10;
if ( v10 )
{
*v7 = 0;
*(_DWORD *)(a3 + 24) = -5;
**(_QWORD **)(a3 + 48) = 0LL;
**(_QWORD **)(a3 + 56) = (unsigned __int64)*a2 / *(_QWORD *)(a3 + 16);
if ( !**(_QWORD **)(a3 + 56) )
{
fprintf(
stderr,
"\nWarning: The requested size of the hash table (%zu) is too small.\nIt will now be adjusted.\n\n",
*a2);
**(_QWORD **)(a3 + 56) = 1LL;
}
v11 = *(_QWORD **)(a3 + 56);
*v11 = next_prime(*v11);
*a2 = **(_QWORD **)(a3 + 56);
**(_DWORD **)(a3 + 32) = (unsigned int)random() % (*(_DWORD *)(a3 + 24) - 1) + 1;
**(_DWORD **)(a3 + 40) = (unsigned int)random() % *(_DWORD *)(a3 + 24);
if ( a1 > 1 )
{
puts("The Cuckoo hash function parameters:");
printf(
"0: {a = %u, b = %u, offset = %zu, size = %zu}\n",
**(unsigned int **)(a3 + 32),
**(unsigned int **)(a3 + 40),
**(_QWORD **)(a3 + 48),
**(_QWORD **)(a3 + 56));
}
v13 = *(_QWORD *)(a3 + 16);
if ( v13 > 1 )
{
v14 = 1;
v15 = 1LL;
do
{
v17 = v14 - 1;
*(_QWORD *)(*(_QWORD *)(a3 + 48) + 8 * v15) = *(_QWORD *)(*(_QWORD *)(a3 + 56) + 8 * v17)
+ *(_QWORD *)(*(_QWORD *)(a3 + 48) + 8 * v17);
*(_QWORD *)(v12 + 8 * v15) = next_prime(*(_QWORD *)(*(_QWORD *)(a3 + 56) + 8 * v17));
*a2 += *(_QWORD *)(*(_QWORD *)(a3 + 56) + 8 * v15);
*(_DWORD *)(*(_QWORD *)(a3 + 32) + 4 * v15) = (unsigned int)random() % (*(_DWORD *)(a3 + 24) - 1) + 1;
*(_DWORD *)(*(_QWORD *)(a3 + 40) + 4 * v15) = (unsigned int)random() % *(_DWORD *)(a3 + 24);
if ( a1 > 1 )
printf(
"%u: {a = %u, b = %u, offset = %zu, size = %zu}\n",
v14,
*(unsigned int *)(*(_QWORD *)(a3 + 32) + 4 * v15),
*(unsigned int *)(*(_QWORD *)(a3 + 40) + 4 * v15),
*(_QWORD *)(*(_QWORD *)(a3 + 48) + 8 * v15),
*(_QWORD *)(*(_QWORD *)(a3 + 56) + 8 * v15));
v15 = ++v14;
v13 = *(_QWORD *)(a3 + 16);
}
while ( v14 < v13 );
}
*(_QWORD *)(a3 + 64) = 23 * v13 + 72;
result = 0LL;
if ( a1 > 1 )
{
printf("The new hash table size: %zu\n", *a2);
result = 0LL;
}
}
else
{
perror("calloc(hs->cp_sizes)");
*v7 = 0;
result = 5LL;
}
}
else
{
perror("calloc(hs->cp_offsets)");
*v7 = 0;
result = 4LL;
}
}
else
{
perror("calloc(hs->chf_bs)");
*v7 = 0;
result = 3LL;
}
}
else
{
perror("calloc(hs->chf_as)");
*_errno_location() = 0;
result = 2LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 *a2, __int64 a3)
{
unsigned __int64 v5; // rdx
void *v6; // rax
int *v7; // rbp
void *v8; // rax
void *v9; // rax
void *v10; // rax
_QWORD *v11; // rbp
__int64 v12; // rdx
unsigned __int64 v13; // rax
unsigned int v14; // er12
__int64 v15; // rbp
__int64 result; // rax
__int64 v17; // rax
__int64 v18; // rsi

if ( !a3 )
{
fwrite("Error: The provided hash settings pointer is NULL!\n", 1uLL, 0x33uLL, stderr);
return 1LL;
}
if ( *(_DWORD *)a3 )
{
if ( *(_DWORD *)a3 != 1 )
{
if ( a1 > 1 )
{
puts("The selected collision resolution technique: double hashing");
if ( *a2 )
{
v18 = (unsigned int)next_prime(*a2);
}
else
{
fprintf(
stderr,
"\nWarning: The requested size of the hash table (%zu) is too small.\nIt will now be adjusted.\n\n",
0LL);
*a2 = 1LL;
v18 = (unsigned int)next_prime(1LL);
}
*a2 = v18;
printf("The new hash table size: %zu\n", v18);
}
else if ( *a2 )
{
*a2 = (unsigned int)next_prime(*a2);
}
else
{
fprintf(
stderr,
"\nWarning: The requested size of the hash table (%zu) is too small.\nIt will now be adjusted.\n\n",
0LL);
*a2 = 1LL;
*a2 = (unsigned int)next_prime(1LL);
}
*(_DWORD *)(a3 + 4) = *a2;
*(_DWORD *)(a3 + 8) = *a2 - 2;
return 0LL;
}
}
else
{
*(_DWORD *)a3 = 1;
}
if ( a1 > 1 )
puts("The selected collision resolution technique: Cuckoo hashing");
v5 = *(_QWORD *)(a3 + 16);
if ( v5 )
{
if ( v5 <= 1 )
{
fprintf(
stderr,
"Warning: The number of the Cuckoo hash functions\n"
"needs to be at least 2. The provided value (%zu)\n"
"will be adjusted to the default value of %zu.\n",
v5,
8uLL);
*(_QWORD *)(a3 + 16) = 8LL;
}
}
else
{
*(_QWORD *)(a3 + 16) = 8LL;
}
free(*(void **)(a3 + 32));
v6 = calloc(*(_QWORD *)(a3 + 16), 4uLL);
*(_QWORD *)(a3 + 32) = v6;
if ( v6 )
{
v7 = _errno_location();
*v7 = 0;
free(*(void **)(a3 + 40));
v8 = calloc(*(_QWORD *)(a3 + 16), 4uLL);
*(_QWORD *)(a3 + 40) = v8;
if ( v8 )
{
*v7 = 0;
free(*(void **)(a3 + 48));
v9 = calloc(*(_QWORD *)(a3 + 16), 8uLL);
*(_QWORD *)(a3 + 48) = v9;
if ( v9 )
{
*v7 = 0;
free(*(void **)(a3 + 56));
v10 = calloc(*(_QWORD *)(a3 + 16), 8uLL);
*(_QWORD *)(a3 + 56) = v10;
if ( v10 )
{
*v7 = 0;
*(_DWORD *)(a3 + 24) = -5;
**(_QWORD **)(a3 + 48) = 0LL;
**(_QWORD **)(a3 + 56) = (unsigned __int64)*a2 / *(_QWORD *)(a3 + 16);
if ( !**(_QWORD **)(a3 + 56) )
{
fprintf(
stderr,
"\nWarning: The requested size of the hash table (%zu) is too small.\nIt will now be adjusted.\n\n",
*a2);
**(_QWORD **)(a3 + 56) = 1LL;
}
v11 = *(_QWORD **)(a3 + 56);
*v11 = next_prime(*v11);
*a2 = **(_QWORD **)(a3 + 56);
**(_DWORD **)(a3 + 32) = (unsigned int)random() % (*(_DWORD *)(a3 + 24) - 1) + 1;
**(_DWORD **)(a3 + 40) = (unsigned int)random() % *(_DWORD *)(a3 + 24);
if ( a1 > 1 )
{
puts("The Cuckoo hash function parameters:");
printf(
"0: {a = %u, b = %u, offset = %zu, size = %zu}\n",
**(unsigned int **)(a3 + 32),
**(unsigned int **)(a3 + 40),
**(_QWORD **)(a3 + 48),
**(_QWORD **)(a3 + 56));
}
v13 = *(_QWORD *)(a3 + 16);
if ( v13 > 1 )
{
v14 = 1;
v15 = 1LL;
do
{
v17 = v14 - 1;
*(_QWORD *)(*(_QWORD *)(a3 + 48) + 8 * v15) = *(_QWORD *)(*(_QWORD *)(a3 + 56) + 8 * v17)
+ *(_QWORD *)(*(_QWORD *)(a3 + 48) + 8 * v17);
*(_QWORD *)(v12 + 8 * v15) = next_prime(*(_QWORD *)(*(_QWORD *)(a3 + 56) + 8 * v17));
*a2 += *(_QWORD *)(*(_QWORD *)(a3 + 56) + 8 * v15);
*(_DWORD *)(*(_QWORD *)(a3 + 32) + 4 * v15) = (unsigned int)random() % (*(_DWORD *)(a3 + 24) - 1) + 1;
*(_DWORD *)(*(_QWORD *)(a3 + 40) + 4 * v15) = (unsigned int)random() % *(_DWORD *)(a3 + 24);
if ( a1 > 1 )
printf(
"%u: {a = %u, b = %u, offset = %zu, size = %zu}\n",
v14,
*(unsigned int *)(*(_QWORD *)(a3 + 32) + 4 * v15),
*(unsigned int *)(*(_QWORD *)(a3 + 40) + 4 * v15),
*(_QWORD *)(*(_QWORD *)(a3 + 48) + 8 * v15),
*(_QWORD *)(*(_QWORD *)(a3 + 56) + 8 * v15));
v15 = ++v14;
v13 = *(_QWORD *)(a3 + 16);
}
while ( v14 < v13 );
}
*(_QWORD *)(a3 + 64) = 23 * v13 + 72;
result = 0LL;
if ( a1 > 1 )
{
printf("The new hash table size: %zu\n", *a2);
result = 0LL;
}
}
else
{
perror("calloc(hs->cp_sizes)");
*v7 = 0;
result = 5LL;
}
}
else
{
perror("calloc(hs->cp_offsets)");
*v7 = 0;
result = 4LL;
}
}
else
{
perror("calloc(hs->chf_bs)");
*v7 = 0;
result = 3LL;
}
}
else
{
perror("calloc(hs->chf_as)");
*_errno_location() = 0;
result = 2LL;
}
return result;
}

original_code:
int hs_update (const int verbosity_level,
  size_t *new_size,
  hash_settings *hs) {
 static const size_t chf_count_default = 8;
 unsigned_integral_type i = 0;
 if (hs == ((void *)0)) {
  fprintf(stderr, "Error: The provided hash settings "
    "pointer is NULL!\n");
  return (1);
 }
 if (hs->crt_type == 0) {
  hs->crt_type = 1;
 }
 if (hs->crt_type == 1) {
  if (verbosity_level > 1) {
   printf("The selected collision resolution technique: "
     "Cuckoo hashing\n");
  }
  if (hs->chf_number == 0) {
   hs->chf_number = chf_count_default;
  }
  if (hs->chf_number < 2) {
   fprintf(stderr, "Warning: The number of the "
     "Cuckoo hash functions\n"
     "needs to be at least 2. "
     "The provided value (%zu)\n"
     "will be adjusted to the "
     "default value of %zu.\n",
     hs->chf_number, chf_count_default);
   hs->chf_number = chf_count_default;
  }
  free(hs->chf_as);
  hs->chf_as = calloc(hs->chf_number,
    sizeof (unsigned_integral_type));
  if (hs->chf_as == ((void *)0)) {
   perror("calloc(hs->chf_as)");
   (*__errno_location ()) = 0;
   return (2);
  } else {
   (*__errno_location ()) = 0;
  }
  free(hs->chf_bs);
  hs->chf_bs = calloc(hs->chf_number,
    sizeof (unsigned_integral_type));
  if (hs->chf_bs == ((void *)0)) {
   perror("calloc(hs->chf_bs)");
   (*__errno_location ()) = 0;
   return (3);
  } else {
   (*__errno_location ()) = 0;
  }
  free(hs->cp_offsets);
  hs->cp_offsets = calloc(hs->chf_number,
    sizeof (size_t));
  if (hs->cp_offsets == ((void *)0)) {
   perror("calloc(hs->cp_offsets)");
   (*__errno_location ()) = 0;
   return (4);
  } else {
   (*__errno_location ()) = 0;
  }
  free(hs->cp_sizes);
  hs->cp_sizes = calloc(hs->chf_number,
    sizeof (size_t));
  if (hs->cp_sizes == ((void *)0)) {
   perror("calloc(hs->cp_sizes)");
   (*__errno_location ()) = 0;
   return (5);
  } else {
   (*__errno_location ()) = 0;
  }
  hs->npu_size = 4294967291;
  hs->cp_offsets[0] = 0;
  hs->cp_sizes[0] = (*new_size) / hs->chf_number;
  if (hs->cp_sizes[0] == 0) {
   fprintf(stderr, "\nWarning: The requested size of "
     "the hash table (%zu) is too small."
     "\nIt will now be adjusted.\n\n",
     (*new_size));
   hs->cp_sizes[0] = 1;
  }
  hs->cp_sizes[0] = (size_t)
   (next_prime((ull)(hs->cp_sizes[0])));
  (*new_size) = hs->cp_sizes[0];
  hs->chf_as[0] = (unsigned_integral_type)(random()) %
   (hs->npu_size - 1) + 1;
  hs->chf_bs[0] = (unsigned_integral_type)(random()) %
   hs->npu_size;
  if (verbosity_level > 1) {
   printf("The Cuckoo hash function parameters:\n");
   printf("0: {a = %u, b = %u, offset = %zu, "
     "size = %zu}\n", hs->chf_as[0],
     hs->chf_bs[0], hs->cp_offsets[0],
     hs->cp_sizes[0]);
  }
  for (i = 1; i < hs->chf_number; ++i) {
   hs->cp_offsets[i] = hs->cp_offsets[i - 1]
    + hs->cp_sizes[i - 1];
   hs->cp_sizes[i] = (size_t)(
     next_prime((ull)(hs->
       cp_sizes[i - 1])));
   (*new_size) += hs->cp_sizes[i];
   hs->chf_as[i] = (unsigned_integral_type)(random()) %
    (hs->npu_size - 1) + 1;
   hs->chf_bs[i] = (unsigned_integral_type)(random()) %
    hs->npu_size;
   if (verbosity_level > 1) {
    printf("%u: {a = %u, b = %u, offset = %zu, "
      "size = %zu}\n", i,
      hs->chf_as[i], hs->chf_bs[i],
      hs->cp_offsets[i],
      hs->cp_sizes[i]);
   }
  }
  hs->allocated_size = sizeof (hash_settings) +
   (sizeof (unsigned_integral_type) * 2 +
   sizeof (size_t) * 2 - 1) * hs->chf_number;
  if (verbosity_level > 1) {
   printf("The new hash table size: %zu\n", (*new_size));
  }
  return (0);
 } else {
  if (verbosity_level > 1) {
   printf("The selected collision resolution technique: "
     "double hashing\n");
  }
  if ((*new_size) == 0) {
   fprintf(stderr, "\nWarning: The requested size of "
     "the hash table (%zu) is too small."
     "\nIt will now be adjusted.\n\n",
     (*new_size));
   (*new_size) = 1;
  }
  (*new_size) = (unsigned_integral_type)(next_prime((ull)
     (*new_size)));
  if (verbosity_level > 1) {
   printf("The new hash table size: %zu\n", (*new_size));
  }
  hs->phf_max = (unsigned_integral_type)(*new_size);
  hs->shf_max = (unsigned_integral_type)((*new_size) - 2);
  return (0);
 }
}

canonical_original_code:
int hs_update(int verbosity_level, unsigned long *new_size, struct hash_settings_struct *hs) {
 static unsigned long chf_count_default = 8;
 unsigned int i = 0;
 if (hs == ((void *)0)) {
  fprintf(stderr, "Error: The provided hash settings "
    "pointer is NULL!\n");
  return (1);
 }
 if (hs->crt_type == 0) {
  hs->crt_type = 1;
 }
 if (hs->crt_type == 1) {
  if (verbosity_level > 1) {
   printf("The selected collision resolution technique: "
     "Cuckoo hashing\n");
  }
  if (hs->chf_number == 0) {
   hs->chf_number = chf_count_default;
  }
  if (hs->chf_number < 2) {
   fprintf(stderr, "Warning: The number of the "
     "Cuckoo hash functions\n"
     "needs to be at least 2. "
     "The provided value (%zu)\n"
     "will be adjusted to the "
     "default value of %zu.\n",
     hs->chf_number, chf_count_default);
   hs->chf_number = chf_count_default;
  }
  free(hs->chf_as);
  hs->chf_as = calloc(hs->chf_number,
    sizeof (unsigned_integral_type));
  if (hs->chf_as == ((void *)0)) {
   perror("calloc(hs->chf_as)");
   (*__errno_location ()) = 0;
   return (2);
  } else {
   (*__errno_location ()) = 0;
  }
  free(hs->chf_bs);
  hs->chf_bs = calloc(hs->chf_number,
    sizeof (unsigned_integral_type));
  if (hs->chf_bs == ((void *)0)) {
   perror("calloc(hs->chf_bs)");
   (*__errno_location ()) = 0;
   return (3);
  } else {
   (*__errno_location ()) = 0;
  }
  free(hs->cp_offsets);
  hs->cp_offsets = calloc(hs->chf_number,
    sizeof (unsigned long));
  if (hs->cp_offsets == ((void *)0)) {
   perror("calloc(hs->cp_offsets)");
   (*__errno_location ()) = 0;
   return (4);
  } else {
   (*__errno_location ()) = 0;
  }
  free(hs->cp_sizes);
  hs->cp_sizes = calloc(hs->chf_number,
    sizeof (unsigned long));
  if (hs->cp_sizes == ((void *)0)) {
   perror("calloc(hs->cp_sizes)");
   (*__errno_location ()) = 0;
   return (5);
  } else {
   (*__errno_location ()) = 0;
  }
  hs->npu_size = 4294967291;
  hs->cp_offsets[0] = 0;
  hs->cp_sizes[0] = (*new_size) / hs->chf_number;
  if (hs->cp_sizes[0] == 0) {
   fprintf(stderr, "\nWarning: The requested size of "
     "the hash table (%zu) is too small."
     "\nIt will now be adjusted.\n\n",
     (*new_size));
   hs->cp_sizes[0] = 1;
  }
  hs->cp_sizes[0] = (unsigned long)
   (next_prime((ull)(hs->cp_sizes[0])));
  (*new_size) = hs->cp_sizes[0];
  hs->chf_as[0] = (unsigned_integral_type)(random()) %
   (hs->npu_size - 1) + 1;
  hs->chf_bs[0] = (unsigned_integral_type)(random()) %
   hs->npu_size;
  if (verbosity_level > 1) {
   printf("The Cuckoo hash function parameters:\n");
   printf("0: {a = %u, b = %u, offset = %zu, "
     "size = %zu}\n", hs->chf_as[0],
     hs->chf_bs[0], hs->cp_offsets[0],
     hs->cp_sizes[0]);
  }
  for (i = 1; i < hs->chf_number; ++i) {
   hs->cp_offsets[i] = hs->cp_offsets[i - 1]
    + hs->cp_sizes[i - 1];
   hs->cp_sizes[i] = (unsigned long)(
     next_prime((ull)(hs->
       cp_sizes[i - 1])));
   (*new_size) += hs->cp_sizes[i];
   hs->chf_as[i] = (unsigned_integral_type)(random()) %
    (hs->npu_size - 1) + 1;
   hs->chf_bs[i] = (unsigned_integral_type)(random()) %
    hs->npu_size;
   if (verbosity_level > 1) {
    printf("%u: {a = %u, b = %u, offset = %zu, "
      "size = %zu}\n", i,
      hs->chf_as[i], hs->chf_bs[i],
      hs->cp_offsets[i],
      hs->cp_sizes[i]);
   }
  }
  hs->allocated_size = sizeof (hash_settings) +
   (sizeof (unsigned_integral_type) * 2 +
   sizeof (unsigned long) * 2 - 1) * hs->chf_number;
  if (verbosity_level > 1) {
   printf("The new hash table size: %zu\n", (*new_size));
  }
  return (0);
 } else {
  if (verbosity_level > 1) {
   printf("The selected collision resolution technique: "
     "double hashing\n");
  }
  if ((*new_size) == 0) {
   fprintf(stderr, "\nWarning: The requested size of "
     "the hash table (%zu) is too small."
     "\nIt will now be adjusted.\n\n",
     (*new_size));
   (*new_size) = 1;
  }
  (*new_size) = (unsigned_integral_type)(next_prime((ull)
     (*new_size)));
  if (verbosity_level > 1) {
   printf("The new hash table size: %zu\n", (*new_size));
  }
  hs->phf_max = (unsigned_integral_type)(*new_size);
  hs->shf_max = (unsigned_integral_type)((*new_size) - 2);
  return (0);
 }
}

variable_types: struct hash_settings_struct { int crt_type; unsigned int phf_max; unsigned int shf_max; unsigned long chf_number; unsigned int npu_size; unsigned int *chf_as; unsigned int *chf_bs; unsigned long *cp_offsets; unsigned long *cp_sizes; unsigned long allocated_size; } *

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall hs_deallocate(void *ptr)
{
if ( !ptr )
return 0xFFFFFFFFLL;
free(*((void **)ptr + 4));
free(*((void **)ptr + 5));
free(*((void **)ptr + 6));
free(*((void **)ptr + 7));
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *ptr)
{
if ( !ptr )
return 0xFFFFFFFFLL;
free(*((void **)ptr + 4));
free(*((void **)ptr + 5));
free(*((void **)ptr + 6));
free(*((void **)ptr + 7));
free(ptr);
return 0LL;
}

original_code:
int hs_deallocate (hash_settings *hs) {
 if (hs == ((void *)0)) {
  return (-1);
 } else {
  free(hs->chf_as);
  hs->chf_as = ((void *)0);
  free(hs->chf_bs);
  hs->chf_bs = ((void *)0);
  free(hs->cp_offsets);
  hs->cp_offsets = ((void *)0);
  free(hs->cp_sizes);
  hs->cp_sizes = ((void *)0);
  free(hs);
  hs = ((void *)0);
  return (0);
 }
}

canonical_original_code:
int hs_deallocate(struct hash_settings_struct *hs) {
 if (hs == ((void *)0)) {
  return (-1);
 } else {
  free(hs->chf_as);
  hs->chf_as = ((void *)0);
  free(hs->chf_bs);
  hs->chf_bs = ((void *)0);
  free(hs->cp_offsets);
  hs->cp_offsets = ((void *)0);
  free(hs->cp_sizes);
  hs->cp_sizes = ((void *)0);
  free(hs);
  hs = ((void *)0);
  return (0);
 }
}


decompiled_code:
_BOOL8 __fastcall er_empty(__int64 a1)
{
return a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
return a1 == 0;
}

original_code:
int er_empty (const edge_record er) {
 if ((er.source_node == 0) && (er.target_node == 0)) {
  return (1);
 } else {
  return (0);
 }
}

canonical_original_code:
int er_empty(struct edge_record_struct er) {
 if ((er.source_node == 0) && (er.target_node == 0)) {
  return (1);
 } else {
  return (0);
 }
}

variable_types: struct edge_record_struct { int source_node; int target_node; }


decompiled_code:
_BOOL8 __fastcall er_vacant(int a1)
{
return a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(int a1)
{
return a1 == 0;
}

original_code:
int er_vacant (const edge_record er) {
 if (er.source_node == 0) {
  return (1);
 } else {
  return (0);
 }
}

canonical_original_code:
int er_vacant(struct edge_record_struct er) {
 if (er.source_node == 0) {
  return (1);
 } else {
  return (0);
 }
}


decompiled_code:
unsigned __int64 __fastcall primary_hf(int a1, char a2, __int64 a3)
{
return (a1 ^ (unsigned __int64)((__int64)a2 << 32)) % *(unsigned int *)(a3 + 4);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(int a1, char a2, __int64 a3)
{
return (a1 ^ (unsigned __int64)((__int64)a2 << 32)) % *(unsigned int *)(a3 + 4);
}

original_code:
size_t primary_hf (signed_integral_type source_node,
  character_type letter,
  const hash_settings *hs) {
 unsigned long long key =
  (unsigned long long)(source_node) ^
  ((unsigned long long)(letter) << 32);
 return ((size_t)(key % hs->phf_max));
}

canonical_original_code:
unsigned long primary_hf(int source_node, char letter, struct hash_settings_struct *hs) {
 unsigned long long key = (unsigned long long)(source_node) ^
  ((unsigned long long)(letter) << 32);
 return ((unsigned long)(key % hs->phf_max));
}

variable_types:
key
unsigned long long

return_type: unsigned long


decompiled_code:
unsigned __int64 __fastcall secondary_hf(int a1, char a2, __int64 a3)
{
return (a1 ^ (unsigned __int64)((__int64)a2 << 32)) % *(unsigned int *)(a3 + 8) + 1;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(int a1, char a2, __int64 a3)
{
return (a1 ^ (unsigned __int64)((__int64)a2 << 32)) % *(unsigned int *)(a3 + 8) + 1;
}

original_code:
size_t secondary_hf (signed_integral_type source_node,
  character_type letter,
  const hash_settings *hs) {
 unsigned long long key =
  (unsigned long long)(source_node) ^
  ((unsigned long long)(letter) << 32);
 return ((size_t)(key % hs->shf_max + 1));
}

canonical_original_code:
unsigned long secondary_hf(int source_node, char letter, struct hash_settings_struct *hs) {
 unsigned long long key = (unsigned long long)(source_node) ^
  ((unsigned long long)(letter) << 32);
 return ((unsigned long)(key % hs->shf_max + 1));
}


original_code:
size_t cuckoo_hf (size_t index,
  signed_integral_type source_node,
  character_type letter,
  const hash_settings *hs) {
 unsigned long long key =
  (unsigned long long)(source_node) ^
  ((unsigned long long)(letter) << 32);
 return (size_t)(((
    (unsigned long long)(hs->chf_as[index]) *
    key +
    (unsigned long long)(hs->chf_bs[index])) %
    (unsigned long long)(hs->npu_size)) %
   (unsigned long long)(hs->cp_sizes[index]) +
   (unsigned long long)(hs->cp_offsets[index]));
}

canonical_original_code:
unsigned long cuckoo_hf(unsigned long index, int source_node, char letter, struct hash_settings_struct *hs) {
 unsigned long long key = (unsigned long long)(source_node) ^
  ((unsigned long long)(letter) << 32);
 return (unsigned long)(((
    (unsigned long long)(hs->chf_as[index]) *
    key +
    (unsigned long long)(hs->chf_bs[index])) %
    (unsigned long long)(hs->npu_size)) %
   (unsigned long long)(hs->cp_sizes[index]) +
   (unsigned long long)(hs->cp_offsets[index]));
}

variable_types:
index
unsigned long


decompiled_code:
__int64 __fastcall st_slai_create_pwotd(__int64 a1, __int64 a2, __int64 a3, _QWORD *a4)
{
unsigned __int64 v6; // r15
__int64 v7; // rbx
unsigned __int64 v8; // rax
__int64 i; // rax
__int64 v10; // rax
__int64 v11; // rbx
__int64 v12; // r13
__int64 result; // rax

v6 = a3 + 1;
puts("Creating the suffix tree using the PWOTD algorithm\n");
v7 = 0LL;
if ( v6 > 0x100000 )
{
v8 = v6 >> 25;
if ( v6 >> 25 )
{
v7 = 1LL;
do
{
++v7;
v8 >>= 5;
}
while ( v8 );
}
else
{
v7 = 1LL;
}
}
if ( a1 >= 0 )
{
printf("Abandoning the automatically determined prefix length: %zu\n", v7);
v7 = a1;
}
printf("The selected prefix length: %zu\n\n", v7);
if ( (int)st_slai_allocate(a3, a4) > 0 )
{
fwrite("Suffix tree allocation error. Exiting.\n", 1uLL, 0x27uLL, stderr);
return 1LL;
}
if ( (int)pwotd_cdata_allocate(a3, a4 + 5) > 0 )
{
fwrite("Auxiliary data structures allocation error. Exiting.\n", 1uLL, 0x35uLL, stderr);
return 2LL;
}
pwotd_initialize_suffixes(a4 + 5);
if ( v7 )
{
if ( (int)pwotd_partition_suffixes(v7, a2, a3, a4 + 5) > 0 )
{
fwrite("Error: Could not perform the partitioning phase! Exiting.\n", 1uLL, 0x3AuLL, stderr);
return 3LL;
}
}
else
{
if ( (int)pwotd_cdata_tsuffixes_tmp_reallocate(v6, a3, a4 + 5) > 0 )
{
fwrite(
"Error: Could not allocate the memory for the temporary table of suffixes! Exiting.\n",
1uLL,
0x53uLL,
stderr);
return 4LL;
}
if ( (int)pwotd_cdata_partitions_reallocate(1LL, a3, a4 + 5) > 0 )
{
fwrite("Error: Could not allocate the memory for the table of partitions! Exiting.\n", 1uLL, 0x4BuLL, stderr);
return 5LL;
}
a4[32] = 0LL;
puts("Creating a single partition!");
pwotd_insert_partition(1LL, a3 + 2, 0LL, a3, a4 + 5);
puts("The partition has been created!");
}
if ( (int)pwotd_cdata_partitions_tbp_reallocate(a4[20], a3, a4 + 5) > 0 )
{
fwrite(
"Error: st_slai_create_pwotd:\nCould not reallocate the memory\nfor the table of partitions to be processed.\n",
1uLL,
0x6AuLL,
stderr);
result = 6LL;
}
else if ( (int)pwotd_cdata_partitions_stack_reallocate(a4[32] << 8, a3, a4 + 5) > 0 )
{
fwrite("Error: Could not reallocate the memory for the partitions stack. Exiting.\n", 1uLL, 0x4AuLL, stderr);
result = 7LL;
}
else
{
st_slai_process_partitions_range(0LL, a4[20], 0LL, 0LL, a2, a3, a4);
if ( (int)st_slai_empty_partitions_stack(a2, a3, a4) > 0 )
{
fwrite("Error: Could not successfully empty the partitions stack Exiting.\n", 1uLL, 0x42uLL, stderr);
result = 8LL;
}
else
{
for ( i = a4[23]; i; i = a4[23] )
{
v10 = i - 1;
a4[23] = v10;
st_slai_process_partition(
*(_QWORD *)(a4[13] + 24 * v10),
*(_QWORD *)(a4[13] + 24 * v10 + 8),
*(_QWORD *)(a4[13] + 24 * v10 + 16),
a2,
a3,
a4);
}
pwotd_print_memory_usage_stats(stdout, a3, a4 + 5);
v11 = a4[34];
v12 = a4[33];
if ( (int)pwotd_cdata_deallocate(a4 + 5) > 0 )
{
fwrite("Deallocation error. Exiting.\n", 1uLL, 0x1DuLL, stderr);
result = 9LL;
}
else
{
puts("\nThe suffix tree has been successfully created.");
st_print_stats(a3, 0LL, a4[1], a4[2] - 1LL, 0LL, 0LL, a4[3], 0LL, 0LL, 0LL, 4LL, v11, v12);
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, _QWORD *a4)
{
unsigned __int64 v6; // r15
__int64 v7; // rbx
unsigned __int64 v8; // rax
__int64 i; // rax
__int64 v10; // rax
__int64 v11; // rbx
__int64 v12; // r13
__int64 result; // rax

v6 = a3 + 1;
puts("Creating the suffix tree using the PWOTD algorithm\n");
v7 = 0LL;
if ( v6 > 0x100000 )
{
v8 = v6 >> 25;
if ( v6 >> 25 )
{
v7 = 1LL;
do
{
++v7;
v8 >>= 5;
}
while ( v8 );
}
else
{
v7 = 1LL;
}
}
if ( a1 >= 0 )
{
printf("Abandoning the automatically determined prefix length: %zu\n", v7);
v7 = a1;
}
printf("The selected prefix length: %zu\n\n", v7);
if ( (int)st_slai_allocate(a3, a4) > 0 )
{
fwrite("Suffix tree allocation error. Exiting.\n", 1uLL, 0x27uLL, stderr);
return 1LL;
}
if ( (int)pwotd_cdata_allocate(a3, a4 + 5) > 0 )
{
fwrite("Auxiliary data structures allocation error. Exiting.\n", 1uLL, 0x35uLL, stderr);
return 2LL;
}
pwotd_initialize_suffixes(a4 + 5);
if ( v7 )
{
if ( (int)pwotd_partition_suffixes(v7, a2, a3, a4 + 5) > 0 )
{
fwrite("Error: Could not perform the partitioning phase! Exiting.\n", 1uLL, 0x3AuLL, stderr);
return 3LL;
}
}
else
{
if ( (int)pwotd_cdata_tsuffixes_tmp_reallocate(v6, a3, a4 + 5) > 0 )
{
fwrite(
"Error: Could not allocate the memory for the temporary table of suffixes! Exiting.\n",
1uLL,
0x53uLL,
stderr);
return 4LL;
}
if ( (int)pwotd_cdata_partitions_reallocate(1LL, a3, a4 + 5) > 0 )
{
fwrite("Error: Could not allocate the memory for the table of partitions! Exiting.\n", 1uLL, 0x4BuLL, stderr);
return 5LL;
}
a4[32] = 0LL;
puts("Creating a single partition!");
pwotd_insert_partition(1LL, a3 + 2, 0LL, a3, a4 + 5);
puts("The partition has been created!");
}
if ( (int)pwotd_cdata_partitions_tbp_reallocate(a4[20], a3, a4 + 5) > 0 )
{
fwrite(
"Error: st_slai_create_pwotd:\nCould not reallocate the memory\nfor the table of partitions to be processed.\n",
1uLL,
0x6AuLL,
stderr);
result = 6LL;
}
else if ( (int)pwotd_cdata_partitions_stack_reallocate(a4[32] << 8, a3, a4 + 5) > 0 )
{
fwrite("Error: Could not reallocate the memory for the partitions stack. Exiting.\n", 1uLL, 0x4AuLL, stderr);
result = 7LL;
}
else
{
st_slai_process_partitions_range(0LL, a4[20], 0LL, 0LL, a2, a3, a4);
if ( (int)st_slai_empty_partitions_stack(a2, a3, a4) > 0 )
{
fwrite("Error: Could not successfully empty the partitions stack Exiting.\n", 1uLL, 0x42uLL, stderr);
result = 8LL;
}
else
{
for ( i = a4[23]; i; i = a4[23] )
{
v10 = i - 1;
a4[23] = v10;
st_slai_process_partition(
*(_QWORD *)(a4[13] + 24 * v10),
*(_QWORD *)(a4[13] + 24 * v10 + 8),
*(_QWORD *)(a4[13] + 24 * v10 + 16),
a2,
a3,
a4);
}
pwotd_print_memory_usage_stats(stdout, a3, a4 + 5);
v11 = a4[34];
v12 = a4[33];
if ( (int)pwotd_cdata_deallocate(a4 + 5) > 0 )
{
fwrite("Deallocation error. Exiting.\n", 1uLL, 0x1DuLL, stderr);
result = 9LL;
}
else
{
puts("\nThe suffix tree has been successfully created.");
st_print_stats(a3, 0LL, a4[1], a4[2] - 1LL, 0LL, 0LL, a4[3], 0LL, 0LL, 0LL, 4LL, v11, v12);
result = 0LL;
}
}
}
return result;
}

original_code:
int st_slai_create_pwotd (long int desired_prefix_length,
  const character_type *text,
  size_t length,
  suffix_tree_slai *stree) {
 size_t prefix_length = 0;
 size_t text_length = length + 1;
 size_t tmp_text_length = text_length;
 size_t extra_allocated_memory_size = 0;
 size_t extra_used_memory_size = 0;
 partition_process_record_pwotd *ppr = ((void *)0);
 printf("Creating the suffix tree using the PWOTD algorithm\n\n");
 if (tmp_text_length > 1048576) {
  prefix_length = 1;
  tmp_text_length = tmp_text_length >> 25;
  while (tmp_text_length > 0) {
   ++prefix_length;
   tmp_text_length = tmp_text_length >> 5;
  }
 }
 if (desired_prefix_length >= 0) {
  printf("Abandoning the automatically determined "
    "prefix length: %zu\n", prefix_length);
  prefix_length = (size_t)(desired_prefix_length);
 }
 printf("The selected prefix length: %zu\n\n",
   prefix_length);
 if (st_slai_allocate(length, stree) > 0) {
  fprintf(stderr, "Suffix tree allocation error. Exiting.\n");
  return (1);
 }
 if (pwotd_cdata_allocate(length, &stree->cdata) > 0) {
  fprintf(stderr, "Auxiliary data structures "
    "allocation error. Exiting.\n");
  return (2);
 }
 pwotd_initialize_suffixes(&stree->cdata);
 if (prefix_length > 0) {
  if (pwotd_partition_suffixes(prefix_length, text,
     length, &stree->cdata) > 0) {
   fprintf(stderr, "Error: Could not perform "
     "the partitioning phase! Exiting.\n");
   return (3);
  }
 } else {
  if (pwotd_cdata_tsuffixes_tmp_reallocate(text_length,
     length, &stree->cdata) > 0) {
   fprintf(stderr, "Error: Could not allocate "
     "the memory for the temporary "
     "table of suffixes! Exiting.\n");
   return (4);
  }
  if (pwotd_cdata_partitions_reallocate((size_t)(1),
     length, &stree->cdata) > 0) {
   fprintf(stderr, "Error: Could not allocate "
     "the memory for the table "
     "of partitions! Exiting.\n");
   return (5);
  }
  stree->cdata.prefix_length = 0;
  printf("Creating a single partition!\n");
  pwotd_insert_partition((size_t)(1), text_length + 1,
    (size_t)(0), length, &stree->cdata);
  printf("The partition has been created!\n");
 }
 if (pwotd_cdata_partitions_tbp_reallocate(
    stree->cdata.partitions_number,
    length, &stree->cdata) > 0) {
  fprintf(stderr, "Error: st_slai_create_pwotd:\n"
    "Could not reallocate the memory\n"
    "for the table of partitions "
    "to be processed.\n");
  return (6);
 }
 if (pwotd_cdata_partitions_stack_reallocate(
    256 * stree->cdata.prefix_length,
    length, &stree->cdata) > 0) {
  fprintf(stderr, "Error: Could not reallocate "
    "the memory for the partitions "
    "stack. Exiting.\n");
  return (7);
 }
 st_slai_process_partitions_range((size_t)(0),
   stree->cdata.partitions_number,
   (size_t)(0), (size_t)(0),
   text, length, stree);
 if (st_slai_empty_partitions_stack(text, length, stree) > 0) {
  fprintf(stderr, "Error: Could not successfully "
    "empty the partitions stack "
    "Exiting.\n");
  return (8);
 }
 while (stree->cdata.partitions_tbp_number > 0) {
  --stree->cdata.partitions_tbp_number;
  ppr = stree->cdata.partitions_tbp +
   stree->cdata.partitions_tbp_number;
  st_slai_process_partition(ppr->index, ppr->tnode_offset,
    ppr->parents_depth, text, length, stree);
 }
 pwotd_print_memory_usage_stats(stdout, length, &stree->cdata);
 extra_allocated_memory_size = stree->cdata.maximum_memory_allocated;
 extra_used_memory_size = stree->cdata.total_memory_allocated;
 if (pwotd_cdata_deallocate(&stree->cdata) > 0) {
  fprintf(stderr, "Deallocation error. Exiting.\n");
  return (9);
 }
 printf("\nThe suffix tree has been successfully created.\n");
 st_print_stats(length, (size_t)(0), stree->branching_nodes,
   stree->tnode_top - 1, (size_t)(0), (size_t)(0),
   stree->tnode_size, (size_t)(0), (size_t)(0),
   (size_t)(0), sizeof (unsigned_integral_type),
   extra_allocated_memory_size,
   extra_used_memory_size);
 return (0);
}

canonical_original_code:
int st_slai_create_pwotd(long desired_prefix_length, char *text, unsigned long length, struct suffix_tree_slai_struct *stree) {
 unsigned long prefix_length = 0;
 unsigned long text_length = length + 1;
 unsigned long tmp_text_length = text_length;
 unsigned long extra_allocated_memory_size = 0;
 unsigned long extra_used_memory_size = 0;
 struct partition_process_record_pwotd_struct *ppr = ((void *)0);
 printf("Creating the suffix tree using the PWOTD algorithm\n\n");
 if (tmp_text_length > 1048576) {
  prefix_length = 1;
  tmp_text_length = tmp_text_length >> 25;
  while (tmp_text_length > 0) {
   ++prefix_length;
   tmp_text_length = tmp_text_length >> 5;
  }
 }
 if (desired_prefix_length >= 0) {
  printf("Abandoning the automatically determined "
    "prefix length: %zu\n", prefix_length);
  prefix_length = (unsigned long)(desired_prefix_length);
 }
 printf("The selected prefix length: %zu\n\n",
   prefix_length);
 if (st_slai_allocate(length, stree) > 0) {
  fprintf(stderr, "Suffix tree allocation error. Exiting.\n");
  return (1);
 }
 if (pwotd_cdata_allocate(length, &stree->cdata) > 0) {
  fprintf(stderr, "Auxiliary data structures "
    "allocation error. Exiting.\n");
  return (2);
 }
 pwotd_initialize_suffixes(&stree->cdata);
 if (prefix_length > 0) {
  if (pwotd_partition_suffixes(prefix_length, text,
     length, &stree->cdata) > 0) {
   fprintf(stderr, "Error: Could not perform "
     "the partitioning phase! Exiting.\n");
   return (3);
  }
 } else {
  if (pwotd_cdata_tsuffixes_tmp_reallocate(text_length,
     length, &stree->cdata) > 0) {
   fprintf(stderr, "Error: Could not allocate "
     "the memory for the temporary "
     "table of suffixes! Exiting.\n");
   return (4);
  }
  if (pwotd_cdata_partitions_reallocate((unsigned long)(1),
     length, &stree->cdata) > 0) {
   fprintf(stderr, "Error: Could not allocate "
     "the memory for the table "
     "of partitions! Exiting.\n");
   return (5);
  }
  stree->cdata.prefix_length = 0;
  printf("Creating a single partition!\n");
  pwotd_insert_partition((unsigned long)(1), text_length + 1,
    (unsigned long)(0), length, &stree->cdata);
  printf("The partition has been created!\n");
 }
 if (pwotd_cdata_partitions_tbp_reallocate(
    stree->cdata.partitions_number,
    length, &stree->cdata) > 0) {
  fprintf(stderr, "Error: st_slai_create_pwotd:\n"
    "Could not reallocate the memory\n"
    "for the table of partitions "
    "to be processed.\n");
  return (6);
 }
 if (pwotd_cdata_partitions_stack_reallocate(
    256 * stree->cdata.prefix_length,
    length, &stree->cdata) > 0) {
  fprintf(stderr, "Error: Could not reallocate "
    "the memory for the partitions "
    "stack. Exiting.\n");
  return (7);
 }
 st_slai_process_partitions_range((unsigned long)(0),
   stree->cdata.partitions_number,
   (unsigned long)(0), (unsigned long)(0),
   text, length, stree);
 if (st_slai_empty_partitions_stack(text, length, stree) > 0) {
  fprintf(stderr, "Error: Could not successfully "
    "empty the partitions stack "
    "Exiting.\n");
  return (8);
 }
 while (stree->cdata.partitions_tbp_number > 0) {
  --stree->cdata.partitions_tbp_number;
  ppr = stree->cdata.partitions_tbp +
   stree->cdata.partitions_tbp_number;
  st_slai_process_partition(ppr->index, ppr->tnode_offset,
    ppr->parents_depth, text, length, stree);
 }
 pwotd_print_memory_usage_stats(stdout, length, &stree->cdata);
 extra_allocated_memory_size = stree->cdata.maximum_memory_allocated;
 extra_used_memory_size = stree->cdata.total_memory_allocated;
 if (pwotd_cdata_deallocate(&stree->cdata) > 0) {
  fprintf(stderr, "Deallocation error. Exiting.\n");
  return (9);
 }
 printf("\nThe suffix tree has been successfully created.\n");
 st_print_stats(length, (unsigned long)(0), stree->branching_nodes,
   stree->tnode_top - 1, (unsigned long)(0), (unsigned long)(0),
   stree->tnode_size, (unsigned long)(0), (unsigned long)(0),
   (unsigned long)(0), sizeof (unsigned_integral_type),
   extra_allocated_memory_size,
   extra_used_memory_size);
 return (0);
}

variable_types: struct suffix_tree_slai_struct { unsigned int *tnode; unsigned long branching_nodes; unsigned long tnode_top; unsigned long tnode_size; unsigned long tnode_size_increase; struct pwotd_construction_data_struct { unsigned long s_size; unsigned long pr_size; unsigned long ppr_size; unsigned long psr_size; unsigned long sr_size; unsigned int *tsuffixes; unsigned int *tsuffixes_tmp; struct partition_record_pwotd_struct { unsigned long begin_offset; unsigned long end_offset; unsigned long lcp_size; unsigned long text_offset; } *partitions; struct partition_process_record_pwotd_struct { unsigned long index; unsigned long tnode_offset; unsigned long parents_depth; } *partitions_tbp; unsigned int *current_partition; struct partitions_stack_record_pwotd_struct { unsigned long range_begin; unsigned long range_end; unsigned long lcp_size; unsigned long tnode_offset; } *partitions_stack; struct stack_record_pwotd_struct { unsigned long range_begin; unsigned long range_end; unsigned long lcp_size; unsigned long tnode_offset; } *stack; unsigned long tsuffixes_size; unsigned long tsuffixes_tmp_size; unsigned long cp_index; unsigned long partitions_number; unsigned long partitions_size; unsigned long partitions_size_increase; unsigned long partitions_tbp_number; unsigned long partitions_tbp_size; unsigned long partitions_tbp_size_increase; unsigned long partitions_stack_top; unsigned long partitions_stack_size; unsigned long partitions_stack_size_increase; unsigned long stack_top; unsigned long stack_size; unsigned long stack_size_increase; unsigned long prefix_length; unsigned long total_memory_allocated; unsigned long maximum_memory_allocated; } cdata; } *

user_defined_types: struct suffix_tree_slai_struct { unsigned int *tnode; unsigned long branching_nodes; unsigned long tnode_top; unsigned long tnode_size; unsigned long tnode_size_increase; struct pwotd_construction_data_struct cdata; }

user_defined_types: struct pwotd_construction_data_struct { unsigned long s_size; unsigned long pr_size; unsigned long ppr_size; unsigned long psr_size; unsigned long sr_size; unsigned int *tsuffixes; unsigned int *tsuffixes_tmp; struct partition_record_pwotd_struct *partitions; struct partition_process_record_pwotd_struct *partitions_tbp; unsigned int *current_partition; struct partitions_stack_record_pwotd_struct *partitions_stack; struct stack_record_pwotd_struct *stack; unsigned long tsuffixes_size; unsigned long tsuffixes_tmp_size; unsigned long cp_index; unsigned long partitions_number; unsigned long partitions_size; unsigned long partitions_size_increase; unsigned long partitions_tbp_number; unsigned long partitions_tbp_size; unsigned long partitions_tbp_size_increase; unsigned long partitions_stack_top; unsigned long partitions_stack_size; unsigned long partitions_stack_size_increase; unsigned long stack_top; unsigned long stack_size; unsigned long stack_size_increase; unsigned long prefix_length; unsigned long total_memory_allocated; unsigned long maximum_memory_allocated; }


ullrandom

decompiled_code:
unsigned __int64 __fastcall ullrandom(unsigned __int64 a1)
{
__int64 v1; // rbp

v1 = random();
return (v1 | (unsigned __int64)(random() << 32)) % a1;
}

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

v1 = random();
return (v1 | (unsigned __int64)(random() << 32)) % a1;
}

original_code:
ull ullrandom (ull upper_bound) {
 ull result = 0;
 long int low_bits = random();
 long int high_bits = random();
 result = (((ull)(high_bits) << 32) | (ull)(low_bits)) % upper_bound;
 return (result);
}

canonical_original_code:
unsigned long long ullrandom(unsigned long long upper_bound) {
 unsigned long long result = 0;
 long low_bits = random();
 long high_bits = random();
 result = (((ull)(high_bits) << 32) | (ull)(low_bits)) % upper_bound;
 return (result);
}

variable_types:
result
unsigned long long

return_type: unsigned long long


decompiled_code:
unsigned __int64 __fastcall mul_modular(unsigned __int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // r8
unsigned __int64 v4; // rdi

v3 = a1 % a3;
if ( !a2 )
return 0LL;
v4 = 0LL;
while ( 1 )
{
if ( (a2 & 1) != 0 )
v4 = (v4 + v3) % a3;
v3 = 2 * v3 % a3;
if ( a2 <= 1 )
break;
a2 >>= 1;
}
return v4;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(unsigned __int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // r8
unsigned __int64 v4; // rdi

v3 = a1 % a3;
if ( !a2 )
return 0LL;
v4 = 0LL;
while ( 1 )
{
if ( (a2 & 1) != 0 )
v4 = (v4 + v3) % a3;
v3 = 2 * v3 % a3;
if ( a2 <= 1 )
break;
a2 >>= 1;
}
return v4;
}

original_code:
ull mul_modular (ull a, ull b, ull c) {
 ull result = 0;
 ull add = a % c;
 while (b > 0) {
  if (b % 2 == 1) {
   result = (result + add) % c;
  }
  add = add * 2 % c;
  b /= 2;
 }
 return (result);
}

canonical_original_code:
unsigned long long mul_modular(unsigned long long a, unsigned long long b, unsigned long long c) {
 unsigned long long result = 0;
 unsigned long long add = a % c;
 while (b > 0) {
  if (b % 2 == 1) {
   result = (result + add) % c;
  }
  add = add * 2 % c;
  b /= 2;
 }
 return (result);
}

variable_types:
a
unsigned long long

variable_types:
b
unsigned long long

variable_types:
c
unsigned long long

variable_types:
add
unsigned long long


decompiled_code:
__int64 __fastcall pow_modular(unsigned __int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rbp
__int64 v6; // r13

if ( !a2 )
return 1LL;
v4 = a2;
v6 = 1LL;
while ( 1 )
{
if ( (v4 & 1) != 0 )
v6 = mul_modular(v6, a1, a3);
a1 = mul_modular(a1, a1, a3);
if ( v4 <= 1 )
break;
v4 >>= 1;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rbp
__int64 v6; // r13

if ( !a2 )
return 1LL;
v4 = a2;
v6 = 1LL;
while ( 1 )
{
if ( (v4 & 1) != 0 )
v6 = func1(v6, a1, a3);
a1 = func1(a1, a1, a3);
if ( v4 <= 1 )
break;
v4 >>= 1;
}
return v6;
}

original_code:
ull pow_modular (ull a, ull b, ull c) {
 ull result = 1;
 ull mul = a;
 while (b > 0) {
  if (b % 2 == 1) {
   result = mul_modular(result, mul, c);
  }
  mul = mul_modular(mul, mul, c);
  b /= 2;
 }
 return (result);
}

canonical_original_code:
unsigned long long pow_modular(unsigned long long a, unsigned long long b, unsigned long long c) {
 unsigned long long result = 1;
 unsigned long long mul = a;
 while (b > 0) {
  if (b % 2 == 1) {
   result = mul_modular(result, mul, c);
  }
  mul = mul_modular(mul, mul, c);
  b /= 2;
 }
 return (result);
}

variable_types:
mul
unsigned long long


decompiled_code:
unsigned __int64 __fastcall fermat_test(unsigned __int64 a1, __int64 a2)
{
unsigned __int64 v2; // r12
__int64 v3; // rbp
unsigned __int64 v4; // rbx

if ( !a2 )
return 0LL;
v2 = a1 - 1;
v3 = 0LL;
while ( 1 )
{
v4 = ullrandom(v2) + 1;
if ( pow_modular(v4, v2, a1) != 1 )
break;
if ( a2 == ++v3 )
return 0LL;
}
return v4;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(unsigned __int64 a1, __int64 a2)
{
unsigned __int64 v2; // r12
__int64 v3; // rbp
unsigned __int64 v4; // rbx

if ( !a2 )
return 0LL;
v2 = a1 - 1;
v3 = 0LL;
while ( 1 )
{
v4 = func0(v2) + 1;
if ( func2(v4, v2, a1) != 1 )
break;
if ( a2 == ++v3 )
return 0LL;
}
return v4;
}

original_code:
ull fermat_test (ull number, ull repeats) {
 ull i = 0;
 ull nd1 = number - 1;
 ull witness = 0;
 for (i = 0; i < repeats; ++i) {
  witness = ullrandom(nd1) + 1;
  if (pow_modular(witness, nd1, number) != 1) {
   return (witness);
  }
 }
 return (0);
}

canonical_original_code:
unsigned long long fermat_test(unsigned long long number, unsigned long long repeats) {
 unsigned long long i = 0;
 unsigned long long nd1 = number - 1;
 unsigned long long witness = 0;
 for (i = 0; i < repeats; ++i) {
  witness = ullrandom(nd1) + 1;
  if (pow_modular(witness, nd1, number) != 1) {
   return (witness);
  }
 }
 return (0);
}

variable_types:
number
unsigned long long

variable_types:
repeats
unsigned long long

variable_types:
i
unsigned long long

variable_types:
witness
unsigned long long


decompiled_code:
unsigned __int64 __fastcall mr_test(unsigned __int64 a1, __int64 a2)
{
unsigned __int64 v2; // r12
__int64 v3; // r14
unsigned __int64 v4; // rbp
unsigned __int64 v5; // rbx
__int64 v6; // rax

if ( !a2 )
return 0LL;
v2 = a1 - 1;
v3 = 0LL;
while ( 1 )
{
v4 = ullrandom(v2) + 1;
if ( pow_modular(v4, v2, a1) != 1 )
break;
v5 = a1 - 1;
while ( (v5 & 1) == 0 )
{
v5 >>= 1;
v6 = pow_modular(v4, v5, a1);
if ( v2 == v6 )
break;
if ( v6 != 1 )
return v4;
}
if ( a2 == ++v3 )
return 0LL;
}
return v4;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(unsigned __int64 a1, __int64 a2)
{
unsigned __int64 v2; // r12
__int64 v3; // r14
unsigned __int64 v4; // rbp
unsigned __int64 v5; // rbx
__int64 v6; // rax

if ( !a2 )
return 0LL;
v2 = a1 - 1;
v3 = 0LL;
while ( 1 )
{
v4 = func0(v2) + 1;
if ( func2(v4, v2, a1) != 1 )
break;
v5 = a1 - 1;
while ( (v5 & 1) == 0 )
{
v5 >>= 1;
v6 = func2(v4, v5, a1);
if ( v2 == v6 )
break;
if ( v6 != 1 )
return v4;
}
if ( a2 == ++v3 )
return 0LL;
}
return v4;
}

original_code:
ull mr_test (ull number, ull repeats) {
 ull i = 0;
 ull witness = 0;
 ull nd1 = number - 1;
 ull rex = 0;
 ull mod = 0;
 for (i = 0; i < repeats; ++i) {
  witness = ullrandom(nd1) + 1;
  if (pow_modular(witness, nd1, number) == 1) {
   rex = nd1;
   while (rex % 2 == 0) {
    rex /= 2;
    mod = pow_modular(witness, rex, number);
    if (mod == nd1) {
     break;
    } else if (mod != 1) {
     return (witness);
    }
   }
  } else {
   return (witness);
  }
 }
 return (0);
}

canonical_original_code:
unsigned long long mr_test(unsigned long long number, unsigned long long repeats) {
 unsigned long long i = 0;
 unsigned long long witness = 0;
 unsigned long long nd1 = number - 1;
 unsigned long long rex = 0;
 unsigned long long mod = 0;
 for (i = 0; i < repeats; ++i) {
  witness = ullrandom(nd1) + 1;
  if (pow_modular(witness, nd1, number) == 1) {
   rex = nd1;
   while (rex % 2 == 0) {
    rex /= 2;
    mod = pow_modular(witness, rex, number);
    if (mod == nd1) {
     break;
    } else if (mod != 1) {
     return (witness);
    }
   }
  } else {
   return (witness);
  }
 }
 return (0);
}

variable_types:
rex
unsigned long long

variable_types:
mod
unsigned long long


decompiled_code:
unsigned __int64 __fastcall next_prime(unsigned __int64 a1)
{
do
++a1;
while ( mr_test(a1, 100LL) );
return a1;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(unsigned __int64 a1)
{
do
++a1;
while ( func4(a1, 100LL) );
return a1;
}

original_code:
ull next_prime (ull number) {
 while (mr_test(++number, (ull)(100)) != 0) {
 }
 return (number);
}

canonical_original_code:
unsigned long long next_prime(unsigned long long number) {
 while (mr_test(++number, (ull)(100)) != 0) {
 }
 return (number);
}


decompiled_code:
__int64 __fastcall set_up_timeout(_QWORD *a1, int a2)
{
__int64 result; // rax

result = 0LL;
if ( a2 > 0 )
{
a1[1] = 0LL;
*a1 = a2;
result = (unsigned int)a2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1, int a2)
{
__int64 result; // rax

result = 0LL;
if ( a2 > 0 )
{
a1[1] = 0LL;
*a1 = a2;
result = (unsigned int)a2;
}
return result;
}

original_code:
int set_up_timeout(struct timeval *timeout, int seconds) {
 if (seconds <= 0) {
  return 0;
 }
 timeout->tv_usec = 0;
 timeout->tv_sec = seconds;
 return seconds;
}

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

variable_types: seconds int


decompiled_code:
int __fastcall raise_socket_flags(int fd, __int64 a2)
{
int v2; // ecx
int result; // eax

v2 = fcntl(fd, 3, 0LL);
result = -1;
if ( v2 != -1 )
result = fcntl(fd, 4, a2 | v2);
return result;
}

canonical_decompiled_code:
int __fastcall func8(int fd, __int64 a2)
{
int v2; // ecx
int result; // eax

v2 = fcntl(fd, 3, 0LL);
result = -1;
if ( v2 != -1 )
result = fcntl(fd, 4, a2 | v2);
return result;
}

original_code:
int raise_socket_flags(int handle_socket, long new_socket_flags) {
 long socket_flags;
 if ((socket_flags = fcntl(handle_socket, 3, ((void *)0))) == -1) {
  return socket_flags;
 }
 socket_flags |= new_socket_flags;
 return fcntl(handle_socket, 4, socket_flags);
}


decompiled_code:
__int64 __fastcall connect_by_addrinfo(__int64 a1)
{
int v1; // eax
unsigned int v2; // ebx

v1 = socket(2, 1, 6);
v2 = v1;
if ( v1 != -1 )
{
if ( raise_socket_flags(v1, 2048LL) == -1 )
{
v2 = -1;
}
else if ( connect(v2, *(const struct sockaddr **)(a1 + 24), *(_DWORD *)(a1 + 16)) == -1 )
{
if ( *__errno_location() != 115 )
v2 = -1;
}
else
{
v2 = -1;
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
int v1; // eax
unsigned int v2; // ebx

v1 = socket(2, 1, 6);
v2 = v1;
if ( v1 != -1 )
{
if ( func8(v1, 2048LL) == -1 )
{
v2 = -1;
}
else if ( connect(v2, *(const struct sockaddr **)(a1 + 24), *(_DWORD *)(a1 + 16)) == -1 )
{
if ( *__errno_location() != 115 )
v2 = -1;
}
else
{
v2 = -1;
}
}
return v2;
}

original_code:
int connect_by_addrinfo(struct addrinfo *address_info) {
 int handle_socket;
 if ((handle_socket = socket(2, SOCK_STREAM, IPPROTO_TCP)) == -1) {
  return handle_socket;
 }
 if (raise_socket_flags(handle_socket, 04000) == -1) {
  return -1;
 }
 if (connect(handle_socket, address_info->ai_addr, address_info->ai_addrlen) != -1) {
  return -1;
 }
 if ((*__errno_location ()) != 115) {
  return -1;
 }
 return handle_socket;
}

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *

user_defined_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }


decompiled_code:
__int64 __fastcall connect_to(const char *a1, const char *a2)
{
unsigned int v2; // ebx
struct addrinfo *pai; // [rsp+8h] [rbp-10h] BYREF

if ( getaddrinfo(a1, a2, 0LL, &pai) )
return (unsigned int)-1;
v2 = connect_by_addrinfo((__int64)pai);
freeaddrinfo(pai);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func10(const char *a1, const char *a2)
{
unsigned int v2; // ebx
struct addrinfo *pai; // [rsp+8h] [rbp-10h] BYREF

if ( getaddrinfo(a1, a2, 0LL, &pai) )
return (unsigned int)-1;
v2 = func9((__int64)pai);
freeaddrinfo(pai);
return v2;
}

original_code:
int connect_to(const char *remote_addr, const char *remote_port) {
 struct addrinfo *address_info;
 int handle_socket;
 if (getaddrinfo(remote_addr, remote_port, ((void *)0), &address_info) != 0) {
  return -1;
 }
 handle_socket = connect_by_addrinfo(address_info);
 freeaddrinfo(address_info);
 return handle_socket;
}

canonical_original_code:
int connect_to(char *remote_addr, char *remote_port) {
 struct addrinfo *address_info;
 int handle_socket;
 if (getaddrinfo(remote_addr, remote_port, ((void *)0), &address_info) != 0) {
  return -1;
 }
 handle_socket = connect_by_addrinfo(address_info);
 freeaddrinfo(address_info);
 return handle_socket;
}

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


decompiled_code:
int __fastcall wait_for_socket(int a1, struct timeval *a2)
{
fd_set v3; // [rsp+0h] [rbp-88h] BYREF

memset(&v3, 0, sizeof(v3));
v3.fds_bits[a1 / 64] |= 1LL << (a1 % 64);
return select(a1 + 1, 0LL, &v3, 0LL, a2);
}

canonical_decompiled_code:
int __fastcall func11(int a1, struct timeval *a2)
{
fd_set v3; // [rsp+0h] [rbp-88h] BYREF

memset(&v3, 0, sizeof(v3));
v3.fds_bits[a1 / 64] |= 1LL << (a1 % 64);
return select(a1 + 1, 0LL, &v3, 0LL, a2);
}

original_code:
int wait_for_socket(int handle_socket, struct timeval *timeout) {
 fd_set handles_monitored;
 do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&handles_monitored)->__fds_bits)[0]) : "memory"); } while (0);
 ((void) (((&handles_monitored)->__fds_bits)[((handle_socket) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((handle_socket) % (8 * (int) sizeof (__fd_mask)))))));
 return select(handle_socket + 1, ((void *)0), &handles_monitored, ((void *)0), timeout);
}

canonical_original_code:
int wait_for_socket(int handle_socket, struct timeval *timeout) {
 struct fd_set handles_monitored;
 do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&handles_monitored)->__fds_bits)[0]) : "memory"); } while (0);
 ((void) (((&handles_monitored)->__fds_bits)[((handle_socket) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((handle_socket) % (8 * (int) sizeof (__fd_mask)))))));
 return select(handle_socket + 1, ((void *)0), &handles_monitored, ((void *)0), timeout);
}

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


decompiled_code:
__int64 __fastcall get_socket_error(int a1)
{
__int64 result; // rax
socklen_t optlen; // [rsp+8h] [rbp-10h] BYREF
unsigned int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optlen = 4;
if ( getsockopt(a1, 1, 4, optval, &optlen) )
result = 0xFFFFFFFFLL;
else
result = optval[0];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1)
{
__int64 result; // rax
socklen_t optlen; // [rsp+8h] [rbp-10h] BYREF
unsigned int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optlen = 4;
if ( getsockopt(a1, 1, 4, optval, &optlen) )
result = 0xFFFFFFFFLL;
else
result = optval[0];
return result;
}

original_code:
int get_socket_error(int handle_socket) {
 int socket_option;
 socklen_t socket_option_length = sizeof(socket_option);
 if (getsockopt(handle_socket, 1, 4, (void *)&socket_option, &socket_option_length) != 0) {
  return -1;
 }
 return socket_option;
}

canonical_original_code:
int get_socket_error(int handle_socket) {
 int socket_option;
 unsigned int socket_option_length = sizeof(socket_option);
 if (getsockopt(handle_socket, 1, 4, (void *)&socket_option, &socket_option_length) != 0) {
  return -1;
 }
 return socket_option;
}


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // eax
int v5; // ebx
struct timeval v6; // [rsp+0h] [rbp-18h] BYREF

if ( argc != 4 )
{
fprintf(
stderr,
"Exactly three arguments expected: hostname, numeric port, timeout in seconds. %d received instead.\n",
(unsigned int)(argc - 1));
exit(1);
}
v3 = atoi(argv[3]);
if ( !(unsigned int)set_up_timeout(&v6, v3) )
{
fprintf(stderr, "Invalid timeout \"%s\" specified. Must be a positive integer.\n", argv[3]);
exit(1);
}
v4 = connect_to(argv[1], argv[2]);
v5 = v4;
if ( v4 != -1 )
{
if ( wait_for_socket(v4, &v6) > 0 )
{
if ( (unsigned int)get_socket_error(v5) )
{
fwrite("Connection closed.\n", 1uLL, 0x13uLL, stderr);
exit(1);
}
exit(0);
}
fwrite("Connection timed out.\n", 1uLL, 0x16uLL, stderr);
exit(1);
}
fwrite("Failed to open a socket. Invalid hostname or port number?\n", 1uLL, 0x3AuLL, stderr);
exit(1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // eax
int v5; // ebx
struct timeval v6; // [rsp+0h] [rbp-18h] BYREF

if ( argc != 4 )
{
fprintf(
stderr,
"Exactly three arguments expected: hostname, numeric port, timeout in seconds. %d received instead.\n",
(unsigned int)(argc - 1));
exit(1);
}
v3 = atoi(argv[3]);
if ( !(unsigned int)func7(&v6, v3) )
{
fprintf(stderr, "Invalid timeout \"%s\" specified. Must be a positive integer.\n", argv[3]);
exit(1);
}
v4 = func10(argv[1], argv[2]);
v5 = v4;
if ( v4 != -1 )
{
if ( func11(v4, &v6) > 0 )
{
if ( (unsigned int)func12(v5) )
{
fwrite("Connection closed.\n", 1uLL, 0x13uLL, stderr);
exit(1);
}
exit(0);
}
fwrite("Connection timed out.\n", 1uLL, 0x16uLL, stderr);
exit(1);
}
fwrite("Failed to open a socket. Invalid hostname or port number?\n", 1uLL, 0x3AuLL, stderr);
exit(1);
}

original_code:
int main(int argc, char **argv) {
 int handle_socket;
 struct timeval timeout;
 if (argc != (3 + 1)) {
  fprintf(stderr,
    "Exactly three arguments expected: hostname, numeric port, timeout in seconds. %d received instead.\n",
    argc - 1);
  exit(1);
 }
 if (! set_up_timeout(&timeout, atoi(argv[3]))) {
  fprintf(stderr,
    "Invalid timeout \"%s\" specified. Must be a positive integer.\n",
    argv[3]);
  exit(1);
 }
 if ((handle_socket = connect_to(argv[1], argv[2])) == -1) {
  fprintf(stderr,
    "Failed to open a socket. Invalid hostname or port number?\n");
  exit(1);
 }
 if (wait_for_socket(handle_socket, &timeout) <= 0) {
  fprintf(stderr, "Connection timed out.\n");
  exit(1);
 }
 if (get_socket_error(handle_socket) != 0) {
  fprintf(stderr, "Connection closed.\n");
  exit(1);
 }
 exit(0);
}

variable_types: argc int

variable_types:
argv
char **

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