decompiled_code:
__int64 __fastcall get_menu_input(_BYTE *a1)
{
unsigned __int8 i; // al
char v2; // bp

puts("Enter your choice");
for ( i = get_ushort_from_input(); ; i = get_ushort_from_input() )
{
v2 = i;
if ( (unsigned __int8)is_input_correct(i, (__int64)a1) )
{
if ( !skip_sign )
break;
}
skip_sign = 0;
}
return choice2item(v2, a1);
}

canonical_decompiled_code:
__int64 __fastcall func10(_BYTE *a1)
{
unsigned __int8 i; // al
char v2; // bp

puts("Enter your choice");
for ( i = func3(); ; i = func3() )
{
v2 = i;
if ( (unsigned __int8)func0(i, (__int64)a1) )
{
if ( !skip_sign )
break;
}
skip_sign = 0;
}
return func1(v2, a1);
}

original_code:
uint8_t get_menu_input(menu_list_t const *cur_menu) {
   uint8_t choice;
   uint8_t item;
   printf("%s", "Enter your choice\n");
   choice = get_ushort_from_input();
   while (!is_input_correct(choice, cur_menu) || skip_sign) {
      skip_sign = 0;
      choice = get_ushort_from_input();
   }
   item = choice2item(choice, cur_menu);
   return item;
}

canonical_original_code:
unsigned char get_menu_input(struct menu_list_t *cur_menu) {
   unsigned char choice;
   unsigned char item;
   printf("%s", "Enter your choice\n");
   choice = get_ushort_from_input();
   while (!is_input_correct(choice, cur_menu) || skip_sign) {
      skip_sign = 0;
      choice = get_ushort_from_input();
   }
   item = choice2item(choice, cur_menu);
   return item;
}

variable_types:
choice
unsigned char

variable_types:
item
unsigned char


decompiled_code:
char *__fastcall get_string_input(unsigned __int8 *a1, char *a2)
{
char *result; // rax

if ( (unsigned int)*a1 - 7 <= 1 )
printf("Enter %s's new name\n", output_code_table[*a1]);
else
printf("Error in menu, item is unknown\n");
fgets(a2, 256, stdin);
result = &a2[strlen(a2) - 1];
if ( *result == 10 )
*result = 0;
return result;
}

canonical_decompiled_code:
char *__fastcall func11(unsigned __int8 *a1, char *a2)
{
char *result; // rax

if ( (unsigned int)*a1 - 7 <= 1 )
printf("Enter %s's new name\n", output_code_table[*a1]);
else
printf("Error in menu, item is unknown\n");
fgets(a2, 256, stdin);
result = &a2[strlen(a2) - 1];
if ( *result == 10 )
*result = 0;
return result;
}

original_code:
void get_string_input(menu_item_t const *menu, char *message) {
   switch (menu->id) {
      case DEFAULT_PLAYER_NAME1:
      case DEFAULT_PLAYER_NAME2:
         printf("Enter %s's new name\n", output_code_table[menu->id]);
         break;
      default:
         printf("Error in menu, item is unknown\n", output_code_table[menu->id]);
   }
   fgets(message, 256, stdin);
   if (message[strlen(message) - 1] == '\n')
      message[strlen(message) - 1] = '\0';
}

canonical_original_code:
void get_string_input(struct menu_item *menu, char *message) {
   switch (menu->id) {
      case DEFAULT_PLAYER_NAME1:
      case DEFAULT_PLAYER_NAME2:
         printf("Enter %s's new name\n", output_code_table[menu->id]);
         break;
      default:
         printf("Error in menu, item is unknown\n", output_code_table[menu->id]);
   }
   fgets(message, 256, stdin);
   if (message[strlen(message) - 1] == '\n')
      message[strlen(message) - 1] = '\0';
}

variable_types: struct menu_item { unsigned char id; char *(*get_title)(); enum menu_item_type_t { MENU_ITEM_CLICKABLE=0, MENU_ITEM_EDITABLE=1, MENU_ITEM_TEXT=2 } type; unsigned char (*action)(struct menu_item *); void *data; } *

variable_types:
message
char *

return_type: void

user_defined_types: struct menu_item { unsigned char id; char *(*get_title)(); enum menu_item_type_t type; unsigned char (*action)(struct menu_item *); void *data; }


decompiled_code:
int __fastcall show_error(const char *a1)
{
printf("\nERROR: %s\nPress any key to exit\n", a1);
return getchar();
}

canonical_decompiled_code:
int __fastcall func13(const char *a1)
{
printf("\nERROR: %s\nPress any key to exit\n", a1);
return getchar();
}

original_code:
void show_error(char *msg) {
   printf("\nERROR: %s\nPress any key to exit\n", msg);
   getchar();
}

variable_types:
msg
char *


decompiled_code:
__int64 __fastcall check_and_apply_last_move(__int64 a1, __int64 a2, _BYTE *a3, char a4)
{
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // rax
_BYTE *v9; // r8
__int64 result; // rax
unsigned __int8 v11; // [rsp+Eh] [rbp-2Ah] BYREF
unsigned __int8 v12; // [rsp+Fh] [rbp-29h]

rule_func(&v11);
if ( !v12 )
return 0LL;
v6 = 0LL;
while ( !v11 )
{
LABEL_8:
if ( v12 <= (int)++v6 )
return 0LL;
}
v7 = *(_QWORD *)(a1 + 8 * v6);
v8 = 0LL;
while ( 1 )
{
v9 = (_BYTE *)(v7 + v8);
if ( *(_BYTE *)(*(_QWORD *)(a2 + 8 * v6) + v8) != *(_BYTE *)(v7 + v8) )
break;
if ( v11 <= (int)++v8 )
goto LABEL_8;
}
*a3 = v8;
result = 1LL;
a3[1] = v6;
*v9 = a4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, _BYTE *a3, char a4)
{
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // rax
_BYTE *v9; // r8
__int64 result; // rax
unsigned __int8 v11; // [rsp+Eh] [rbp-2Ah] BYREF
unsigned __int8 v12; // [rsp+Fh] [rbp-29h]

rule_func(&v11);
if ( !v12 )
return 0LL;
v6 = 0LL;
while ( !v11 )
{
LABEL_8:
if ( v12 <= (int)++v6 )
return 0LL;
}
v7 = *(_QWORD *)(a1 + 8 * v6);
v8 = 0LL;
while ( 1 )
{
v9 = (_BYTE *)(v7 + v8);
if ( *(_BYTE *)(*(_QWORD *)(a2 + 8 * v6) + v8) != *(_BYTE *)(v7 + v8) )
break;
if ( v11 <= (int)++v8 )
goto LABEL_8;
}
*a3 = v8;
result = 1LL;
a3[1] = v6;
*v9 = a4;
return result;
}

original_code:
static uint8_t check_and_apply_last_move(uint8_t **old_field,
      uint8_t const **new_field, point_t *move, uint8_t item) {
   point_t size;
   rule_func.get_field_size(&size);
   for (int i = 0; i < size.y; i++) {
      for (int j = 0; j < size.x; j++) {
         if (new_field[i][j] == old_field[i][j])
            continue;
         move->x = j; move->y = i;;
         old_field[i][j] = item;
         return 1;
      }
   }
   return 0;
}

canonical_original_code:
static unsigned char check_and_apply_last_move(unsigned char **old_field, unsigned char **new_field, struct point_t *move, unsigned char item) {
   struct point_t size;
   rule_func.get_field_size(&size);
   for (int i = 0; i < size.y; i++) {
      for (int j = 0; j < size.x; j++) {
         if (new_field[i][j] == old_field[i][j])
            continue;
         move->x = j; move->y = i;;
         old_field[i][j] = item;
         return 1;
      }
   }
   return 0;
}

variable_types: struct point_t { unsigned char x; unsigned char y; } *

variable_types: i int

variable_types: j int

return_type: unsigned char


decompiled_code:
__int64 __fastcall is_point_on_line(unsigned __int8 *a1, unsigned __int8 *a2, __int64 a3, __int64 a4, unsigned int a5)
{
int v5; // ecx
int v6; // edx
int v7; // esi
int v8; // eax

v5 = *a2;
v6 = a1[1];
v7 = a2[1];
v8 = *a1;
LOBYTE(a5) = (_BYTE)v7 != (unsigned __int8)v6;
if ( (_BYTE)v8 == (_BYTE)v5 )
return a5;
a5 = 1;
if ( (_BYTE)v7 == (_BYTE)v6 || (_BYTE)v8 == (_BYTE)v6 && (_BYTE)v5 == (_BYTE)v7 )
return a5;
a5 = 0;
if ( v6 + v8 != 2 )
return a5;
LOBYTE(a5) = v7 + v5 == 2;
return a5;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1, unsigned __int8 *a2, __int64 a3, __int64 a4, unsigned int a5)
{
int v5; // ecx
int v6; // edx
int v7; // esi
int v8; // eax

v5 = *a2;
v6 = a1[1];
v7 = a2[1];
v8 = *a1;
LOBYTE(a5) = (_BYTE)v7 != (unsigned __int8)v6;
if ( (_BYTE)v8 == (_BYTE)v5 )
return a5;
a5 = 1;
if ( (_BYTE)v7 == (_BYTE)v6 || (_BYTE)v8 == (_BYTE)v6 && (_BYTE)v5 == (_BYTE)v7 )
return a5;
a5 = 0;
if ( v6 + v8 != 2 )
return a5;
LOBYTE(a5) = v7 + v5 == 2;
return a5;
}

original_code:
static uint8_t is_point_on_line(point_t const *first, point_t const *second) {
   if (first->x == second->x && first->y == second->y)
      return 0;
   else if (first->x == second->x || first->y == second->y)
      return 1;
   else if (first->x - first->y == 0 && second->x - second->y == 0)
      return 1;
   else if (first->x + first->y == 2 && second->x + second->y == 2)
      return 1;
   return 0;
}

canonical_original_code:
static unsigned char is_point_on_line(struct point_t *first, struct point_t *second) {
   if (first->x == second->x && first->y == second->y)
      return 0;
   else if (first->x == second->x || first->y == second->y)
      return 1;
   else if (first->x - first->y == 0 && second->x - second->y == 0)
      return 1;
   else if (first->x + first->y == 2 && second->x + second->y == 2)
      return 1;
   return 0;
}

variable_types:
second
struct point_t *

user_defined_types: struct point_t { unsigned char x; unsigned char y; }


decompiled_code:
bool __fastcall init_data(__int64 a1)
{
bool result; // al
char v2; // bl
_QWORD *v3; // rax
size_t v4; // rbp
char v5; // al
_QWORD *v6; // r14
char v7; // r13
char v8; // al
__int64 v9; // r15
char v10; // r12
unsigned __int8 v11; // bp
_BYTE *v12; // rax
_BYTE *v13; // rbx
__int64 v14; // rax
char *v15; // rbx
size_t nmemb; // [rsp+0h] [rbp-68h]
_QWORD *v17; // [rsp+8h] [rbp-60h]
_QWORD *v18; // [rsp+10h] [rbp-58h]
_QWORD *v19; // [rsp+18h] [rbp-50h]
unsigned __int8 v20; // [rsp+2Eh] [rbp-3Ah] BYREF
unsigned __int8 v21; // [rsp+2Fh] [rbp-39h]

result = g_player != a1;
if ( !is_data_init )
{
v2 = result + 1;
v3 = *(_QWORD **)(a1 + 264);
is_data_init = 1;
v19 = v3;
rule_func(&v20);
v4 = v21;
v18 = calloc(v21, 8uLL);
v17 = calloc(v4, 8uLL);
if ( (_BYTE)v4 )
{
v5 = 25;
v6 = v18;
if ( v2 == 1 )
v5 = 12;
v7 = v5;
v8 = 50;
if ( v2 == 1 )
v8 = 1;
v9 = 0LL;
v10 = v8;
while ( 1 )
{
nmemb = v20;
v11 = v20;
v12 = calloc(v20, 1uLL);
*v6 = v12;
v13 = v12;
v17[v9] = calloc(nmemb, 1uLL);
if ( v11 )
break;
LABEL_18:
++v9;
++v6;
if ( v21 <= (int)v9 )
goto LABEL_19;
}
v14 = 0LL;
while ( (_DWORD)v14 != 1 || (_DWORD)v9 != 1 )
{
v15 = &v13[v14];
if ( (_DWORD)v14 == 1 || (_DWORD)v9 == 1 )
{
*v15 = 1;
LABEL_11:
if ( v20 <= (int)++v14 )
goto LABEL_18;
goto LABEL_12;
}
*v15 = v7;
if ( v20 <= (int)++v14 )
goto LABEL_18;
LABEL_12:
v13 = (_BYTE *)*v6;
}
v13[1] = v10;
goto LABEL_11;
}
LABEL_19:
result = (char)v19;
*v19 = v18;
v19[1] = v17;
}
return result;
}

original_code:
void init_data(player_ent_t *ctx) {
   point_t size;
   uint8_t **mark_field;
   uint8_t **own_field;
   ai_data_t *ai_ctx = (ai_data_t *) ctx->player_ctx;
   uint8_t item = (ctx == g_player[0] ? CROSS : NOUGHT);
   if (is_data_init)
      return;
   is_data_init = 1;
   rule_func.get_field_size(&size);
   mark_field = (uint8_t **) calloc(size.y, sizeof(uint8_t *));
   own_field = (uint8_t **) calloc(size.y, sizeof(uint8_t *));
   for (int i = 0; i < size.y; i++) {
      mark_field[i] = (uint8_t *) calloc(size.x, sizeof(uint8_t));
      own_field[i] = (uint8_t *) calloc(size.x, sizeof(uint8_t));
      for (int j = 0; j < size.x; j++) {
         if (i == 1 && j == 1)
            mark_field[i][j] = (item == CROSS ? 1 : 50);
         else if (i == 1 || j == 1)
            mark_field[i][j] = (item == CROSS ? 1 : 1);
         else
            mark_field[i][j] = (item == CROSS ? 12 : 25);
      }
   }
   ai_ctx->marked_fld = mark_field;
   ai_ctx->own_fld = own_field;
}

canonical_original_code:
void init_data(struct player_ent_t *ctx) {
   struct point_t size;
   unsigned char **mark_field;
   unsigned char **own_field;
   struct ai_data_t *ai_ctx = (ai_data_t *) ctx->player_ctx;
   unsigned char item = (ctx == g_player[0] ? CROSS : NOUGHT);
   if (is_data_init)
      return;
   is_data_init = 1;
   rule_func.get_field_size(&size);
   mark_field = (unsigned char **) calloc(size.y, sizeof(unsigned char *));
   own_field = (unsigned char **) calloc(size.y, sizeof(unsigned char *));
   for (int i = 0; i < size.y; i++) {
      mark_field[i] = (unsigned char *) calloc(size.x, sizeof(unsigned char));
      own_field[i] = (unsigned char *) calloc(size.x, sizeof(unsigned char));
      for (int j = 0; j < size.x; j++) {
         if (i == 1 && j == 1)
            mark_field[i][j] = (item == CROSS ? 1 : 50);
         else if (i == 1 || j == 1)
            mark_field[i][j] = (item == CROSS ? 1 : 1);
         else
            mark_field[i][j] = (item == CROSS ? 12 : 25);
      }
   }
   ai_ctx->marked_fld = mark_field;
   ai_ctx->own_fld = own_field;
}

variable_types: struct player_ent_t { struct player_func_list { void (*init_player)(struct player_ent_t *); int (*get_player_input)(struct point_t { unsigned char x; unsigned char y; } *, struct player_ent_t *); void (*clear_data)(struct player_ent_t *); } *func_list; char name[256]; void *player_ctx; } *

variable_types: struct ai_data_t { unsigned char **marked_fld; unsigned char **own_fld; } *

user_defined_types: struct player_ent_t { struct player_func_list *func_list; char name[256]; void *player_ctx; }

user_defined_types: struct player_func_list { void (*init_player)(struct player_ent_t *); int (*get_player_input)(struct point_t *, struct player_ent_t *); void (*clear_data)(struct player_ent_t *); }


original_code:
int make_move(point_t *move, player_ent_t const *ctx) {
   point_t size, op_prev_move;
   uint8_t found_move = 0;
   ai_data_t *ai_ctx = (ai_data_t *) ctx->player_ctx;
   rule_func.get_field_size(&size);
   if (check_and_apply_last_move(ai_ctx->own_fld,
      (uint8_t const **)rule_func.get_field(), &op_prev_move,
      (ctx == g_player[0] ? NOUGHT : CROSS))) {
      recalculate_values((uint8_t const **) ai_ctx->own_fld, ai_ctx->marked_fld,
         &op_prev_move, 0);
   }
   for (int i = 0; i < size.y; i++) {
      for (int j = 0; j < size.x; j++) {
         if (!found_move && ai_ctx->own_fld[i][j] == EMPTY) {
            move->x = j; move->y = i;;
            found_move = 1;
         }
         else if (found_move && ai_ctx->marked_fld[move->y][move->x] <
            ai_ctx->marked_fld[i][j]) {
            move->x = j; move->y = i;;
         }
      }
   }
   if (found_move) {
      ai_ctx->own_fld[move->y][move->x] = (ctx == g_player[0] ? CROSS : NOUGHT);
      recalculate_values((uint8_t const **) ai_ctx->own_fld, ai_ctx->marked_fld,
         move, 1);
   }
   if (!found_move)
      set_error("ai error, no move found", strlen("ai error, no move found"));
   return 1;
}

canonical_original_code:
int make_move(struct point_t *move, struct player_ent_t *ctx) {
   struct point_t size; struct point_t op_prev_move;
   unsigned char found_move = 0;
   struct ai_data_t *ai_ctx = (ai_data_t *) ctx->player_ctx;
   rule_func.get_field_size(&size);
   if (check_and_apply_last_move(ai_ctx->own_fld,
      (unsigned char **)rule_func.get_field(), &op_prev_move,
      (ctx == g_player[0] ? NOUGHT : CROSS))) {
      recalculate_values((unsigned char **) ai_ctx->own_fld, ai_ctx->marked_fld,
         &op_prev_move, 0);
   }
   for (int i = 0; i < size.y; i++) {
      for (int j = 0; j < size.x; j++) {
         if (!found_move && ai_ctx->own_fld[i][j] == EMPTY) {
            move->x = j; move->y = i;;
            found_move = 1;
         }
         else if (found_move && ai_ctx->marked_fld[move->y][move->x] <
            ai_ctx->marked_fld[i][j]) {
            move->x = j; move->y = i;;
         }
      }
   }
   if (found_move) {
      ai_ctx->own_fld[move->y][move->x] = (ctx == g_player[0] ? CROSS : NOUGHT);
      recalculate_values((unsigned char **) ai_ctx->own_fld, ai_ctx->marked_fld,
         move, 1);
   }
   if (!found_move)
      set_error("ai error, no move found", strlen("ai error, no move found"));
   return 1;
}

variable_types: struct player_ent_t { struct player_func_list { void (*init_player)(struct player_ent_t *); int (*get_player_input)(struct point_t *, struct player_ent_t *); void (*clear_data)(struct player_ent_t *); } *func_list; char name[256]; void *player_ctx; } *

variable_types: struct point_t { unsigned char x; unsigned char y; }

return_type: int

user_defined_types: struct ai_data_t { unsigned char **marked_fld; unsigned char **own_fld; }


decompiled_code:
void __fastcall clear_data(__int64 a1)
{
void **v1; // rbp
__int64 v2; // rbx
void *v3; // rdi
char v4; // [rsp+0h] [rbp-1Ah] BYREF
unsigned __int8 v5; // [rsp+1h] [rbp-19h]

if ( is_data_init )
{
is_data_init = 0;
v1 = *(void ***)(a1 + 264);
((__int64 (__fastcall **)(char *))rule_func)[0](&v4);
if ( v5 )
{
v2 = 0LL;
do
{
free(*((void **)*v1 + v2));
v3 = (void *)*((_QWORD *)v1[1] + v2++);
free(v3);
}
while ( v5 > (int)v2 );
}
free(*v1);
free(v1[1]);
}
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
void **v1; // rbp
__int64 v2; // rbx
void *v3; // rdi
char v4; // [rsp+0h] [rbp-1Ah] BYREF
unsigned __int8 v5; // [rsp+1h] [rbp-19h]

if ( is_data_init )
{
is_data_init = 0;
v1 = *(void ***)(a1 + 264);
((__int64 (__fastcall **)(char *))rule_func)[0](&v4);
if ( v5 )
{
v2 = 0LL;
do
{
free(*((void **)*v1 + v2));
v3 = (void *)*((_QWORD *)v1[1] + v2++);
free(v3);
}
while ( v5 > (int)v2 );
}
free(*v1);
free(v1[1]);
}
}

original_code:
void clear_data(player_ent_t *ctx) {
   point_t size;
   ai_data_t *ai_ctx = (ai_data_t *) ctx->player_ctx;
   if (!is_data_init)
      return;
   is_data_init = 0;
   rule_func.get_field_size(&size);
   for (int i = 0; i < size.y; i++) {
      free(ai_ctx->marked_fld[i]);
      free(ai_ctx->own_fld[i]);
   }
   free(ai_ctx->marked_fld);
   free(ai_ctx->own_fld);
}

canonical_original_code:
void clear_data(struct player_ent_t *ctx) {
   struct point_t size;
   struct ai_data_t *ai_ctx = (ai_data_t *) ctx->player_ctx;
   if (!is_data_init)
      return;
   is_data_init = 0;
   rule_func.get_field_size(&size);
   for (int i = 0; i < size.y; i++) {
      free(ai_ctx->marked_fld[i]);
      free(ai_ctx->own_fld[i]);
   }
   free(ai_ctx->marked_fld);
   free(ai_ctx->own_fld);
}


decompiled_code:
void set_players()
{
g_player = (__int64)&player_ent1;
*(&g_player + 1) = (__int64)&player_ent2;
}

canonical_decompiled_code:
void func0()
{
g_player = (__int64)&player_ent1;
*(&g_player + 1) = (__int64)&player_ent2;
}

original_code:
void set_players() {
   g_player[0] = &player_ent1;
   g_player[1] = &player_ent2;
}


decompiled_code:
void *switch_players()
{
void *result; // rax
void *v1; // rcx

result = &player_ent1;
v1 = &player_ent1;
if ( (_UNKNOWN *)g_player == &player_ent1 )
v1 = &player_ent2;
if ( (_UNKNOWN *)*(&g_player + 1) != &player_ent2 )
result = &player_ent2;
g_player = (__int64)v1;
*(&g_player + 1) = (__int64)result;
return result;
}

canonical_decompiled_code:
void *func1()
{
void *result; // rax
void *v1; // rcx

result = &player_ent1;
v1 = &player_ent1;
if ( (_UNKNOWN *)g_player == &player_ent1 )
v1 = &player_ent2;
if ( (_UNKNOWN *)*(&g_player + 1) != &player_ent2 )
result = &player_ent2;
g_player = (__int64)v1;
*(&g_player + 1) = (__int64)result;
return result;
}

original_code:
void switch_players() {
   g_player[0] = g_player[0] == &player_ent1 ? &player_ent2 : &player_ent1;
   g_player[1] = g_player[1] == &player_ent2 ? &player_ent1 : &player_ent2;
}


decompiled_code:
int __fastcall set_player_name(unsigned __int8 a1, const char *a2)
{
return snprintf((char *)(g_player[a1] + 8), 0x100uLL, "%s", a2);
}

canonical_decompiled_code:
int __fastcall func2(unsigned __int8 a1, const char *a2)
{
return snprintf((char *)(g_player[a1] + 8), 0x100uLL, "%s", a2);
}

original_code:
void set_player_name(uint8_t player_id, char const *value) {
   snprintf(g_player[player_id]->name, 256, "%s", value);
}

canonical_original_code:
void set_player_name(unsigned char player_id, char *value) {
   snprintf(g_player[player_id]->name, 256, "%s", value);
}

variable_types:
value
char *


decompiled_code:
__int64 __fastcall set_player_ctx(unsigned __int8 a1, __int64 a2)
{
__int64 result; // rax

result = g_player[a1];
*(_QWORD *)(result + 264) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 a1, __int64 a2)
{
__int64 result; // rax

result = g_player[a1];
*(_QWORD *)(result + 264) = a2;
return result;
}

original_code:
void set_player_ctx(uint8_t player_id, void *ctx) {
   g_player[player_id]->player_ctx = ctx;
}

canonical_original_code:
void set_player_ctx(unsigned char player_id, void *ctx) {
   g_player[player_id]->player_ctx = ctx;
}

variable_types:
ctx
void *


decompiled_code:
__int64 __fastcall get_player_name(unsigned __int8 a1)
{
return g_player[a1] + 8;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int8 a1)
{
return g_player[a1] + 8;
}

original_code:
char const *get_player_name(uint8_t player_id) {
   return g_player[player_id]->name;
}

canonical_original_code:
char *get_player_name(unsigned char player_id) {
   return g_player[player_id]->name;
}

return_type: char *


decompiled_code:
__int64 __fastcall get_player_func_list(unsigned __int8 a1)
{
return *(_QWORD *)g_player[a1];
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int8 a1)
{
return *(_QWORD *)g_player[a1];
}

original_code:
player_func_list_t const *get_player_func_list(uint8_t player_id) {
   return g_player[player_id]->func_list;
}

canonical_original_code:
struct player_func_list *get_player_func_list(unsigned char player_id) {
   return g_player[player_id]->func_list;
}

return_type: struct player_func_list { void (*init_player)(struct player_ent_t { struct player_func_list *func_list; char name[256]; void *player_ctx; } *); int (*get_player_input)(struct point_t { unsigned char x; unsigned char y; } *, struct player_ent_t *); void (*clear_data)(struct player_ent_t *); } *


decompiled_code:
__int64 __fastcall get_player_ctx(unsigned __int8 a1)
{
return *(_QWORD *)(g_player[a1] + 264);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int8 a1)
{
return *(_QWORD *)(g_player[a1] + 264);
}

original_code:
void *get_player_ctx(uint8_t player_id) {
   return g_player[player_id]->player_ctx;
}

canonical_original_code:
void *get_player_ctx(unsigned char player_id) {
   return g_player[player_id]->player_ctx;
}

return_type: void *


decompiled_code:
int __fastcall set_error(__int64 a1, char a2)
{
size_t v2; // rsi

v2 = (unsigned __int8)(a2 + 1);
if ( !(_BYTE)v2 )
v2 = 256LL;
error = 1;
return snprintf(err_msg, v2, "%s", a1);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, char a2)
{
size_t v2; // rsi

v2 = (unsigned __int8)(a2 + 1);
if ( !(_BYTE)v2 )
v2 = 256LL;
error = 1;
return snprintf(err_msg, v2, "%s", a1);
}

original_code:
void set_error(const char *msg, uint8_t len) {
   error = 1;
   snprintf(err_msg, len + 1 < 256 ? len + 1 :
      256, "%s", msg);
}

canonical_original_code:
void set_error(char *msg, unsigned char len) {
   error = 1;
   snprintf(err_msg, len + 1 < 256 ? len + 1 :
      256, "%s", msg);
}

variable_types:
len
unsigned char


decompiled_code:
void clear_error()
{
error = 0;
}

canonical_decompiled_code:
void func1()
{
error = 0;
}

original_code:
void clear_error() {
   error = 0;
}

canonical_original_code:
void clear_error() {
   error = 0;
}


decompiled_code:
__int64 is_error()
{
return (unsigned __int8)error;
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned __int8)error;
}

original_code:
uint8_t is_error() {
   return error;
}

canonical_original_code:
unsigned char is_error() {
   return error;
}


decompiled_code:
char *get_error()
{
return err_msg;
}

canonical_decompiled_code:
char *func3()
{
return err_msg;
}

original_code:
char *get_error() {
   return err_msg;
}

canonical_original_code:
char *get_error() {
   return err_msg;
}


decompiled_code:
__int64 test_mult_m_calloc()
{
__int64 v0; // rax
_QWORD *v1; // rbx
_QWORD *v2; // rbp
_BYTE *v3; // rax
_BYTE *v4; // rdx
__int64 result; // rax

tcase_fn_start("test_mult_m_calloc", "check_memory_handling.c", 56LL);
v0 = m_calloc(10LL, 8LL);
if ( v0 )
{
v1 = (_QWORD *)v0;
mark_point("check_memory_handling.c", 66LL);
v2 = v1 + 10;
while ( 2 )
{
v3 = (_BYTE *)m_calloc(1LL, 1000LL);
*v1 = v3;
v4 = v3 + 1000;
do
{
if ( *v3 )
{
ck_assert_failed("check_memory_handling.c", 73LL, "Failed", "Memory was not clear!", 0LL);
goto LABEL_9;
}
++v3;
}
while ( v3 != v4 );
if ( ++v1 != v2 )
continue;
break;
}
result = m_freeall();
}
else
{
LABEL_9:
ck_assert_failed("check_memory_handling.c", 66LL, "Assertion 'memarray!=NULL' failed", "Got no memory!", 0LL);
result = test_small_m_calloc();
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
_QWORD *v1; // rbx
_QWORD *v2; // rbp
_BYTE *v3; // rax
_BYTE *v4; // rdx
__int64 result; // rax

tcase_fn_start("test_mult_m_calloc", "check_memory_handling.c", 56LL);
v0 = m_calloc(10LL, 8LL);
if ( v0 )
{
v1 = (_QWORD *)v0;
mark_point("check_memory_handling.c", 66LL);
v2 = v1 + 10;
while ( 2 )
{
v3 = (_BYTE *)m_calloc(1LL, 1000LL);
*v1 = v3;
v4 = v3 + 1000;
do
{
if ( *v3 )
{
ck_assert_failed("check_memory_handling.c", 73LL, "Failed", "Memory was not clear!", 0LL);
goto LABEL_9;
}
++v3;
}
while ( v3 != v4 );
if ( ++v1 != v2 )
continue;
break;
}
result = m_freeall();
}
else
{
LABEL_9:
ck_assert_failed("check_memory_handling.c", 66LL, "Assertion 'memarray!=NULL' failed", "Got no memory!", 0LL);
result = func1();
}
return result;
}

original_code:
static void test_mult_m_calloc (int _i __attribute__ ((unused))){ tcase_fn_start ("""test_mult_m_calloc", "check_memory_handling.c", 56);
{
 void **memarray=((void *)0);
 int i=0;
 int j=0;
 memarray=m_calloc((10),sizeof(void *));
 (memarray!=((void *)0)) ? _mark_point("check_memory_handling.c", 66) : _ck_assert_failed("check_memory_handling.c", 66, "Assertion '""memarray!=NULL""' failed" ,"Got no memory!", ((void *)0));
 for(i=0; i<(10);i++) {
  memarray[i]=m_calloc(1, (1000));
  for(j=0; j<(1000);j++) {
   if (((char*) memarray[i])[j] != 0)
    _ck_assert_failed("check_memory_handling.c", 73, "Failed" ,"Memory was not clear!", ((void *)0));
  }
 }
 m_freeall();
}
}

canonical_original_code:
static void test_mult_m_calloc(int _i){ tcase_fn_start ("""test_mult_m_calloc", "check_memory_handling.c", 56);
{
 void **memarray = ((void *)0);
 int i = 0;
 int j = 0;
 memarray=m_calloc((10),sizeof(void *));
 (memarray!=((void *)0)) ? _mark_point("check_memory_handling.c", 66) : _ck_assert_failed("check_memory_handling.c", 66, "Assertion '""memarray!=NULL""' failed" ,"Got no memory!", ((void *)0));
 for(i=0; i<(10);i++) {
  memarray[i]=m_calloc(1, (1000));
  for(j=0; j<(1000);j++) {
   if (((char *) memarray[i])[j] != 0)
    _ck_assert_failed("check_memory_handling.c", 73, "Failed" ,"Memory was not clear!", ((void *)0));
  }
 }
 m_freeall();
}
}

variable_types:
memarray
void **


decompiled_code:
__int64 test_small_m_calloc()
{
__int64 v0; // rax
_BYTE *v1; // rbx
_BYTE *v2; // rax

tcase_fn_start("test_small_m_calloc", "check_memory_handling.c", 37LL);
v0 = m_calloc(100LL, 100LL);
if ( v0 )
{
v1 = (_BYTE *)v0;
mark_point("check_memory_handling.c", 44LL);
v2 = v1;
while ( !*v2 )
{
if ( ++v2 == v1 + 10000 )
return m_freeall();
}
ck_assert_failed("check_memory_handling.c", 48LL, "Failed", "Memory was not clear!", 0LL);
}
ck_assert_failed("check_memory_handling.c", 44LL, "Assertion 'mem!=NULL' failed", "Got no memory!", 0LL);
return test_small_calloc();
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rax
_BYTE *v1; // rbx
_BYTE *v2; // rax

tcase_fn_start("test_small_m_calloc", "check_memory_handling.c", 37LL);
v0 = m_calloc(100LL, 100LL);
if ( v0 )
{
v1 = (_BYTE *)v0;
mark_point("check_memory_handling.c", 44LL);
v2 = v1;
while ( !*v2 )
{
if ( ++v2 == v1 + 10000 )
return m_freeall();
}
ck_assert_failed("check_memory_handling.c", 48LL, "Failed", "Memory was not clear!", 0LL);
}
ck_assert_failed("check_memory_handling.c", 44LL, "Assertion 'mem!=NULL' failed", "Got no memory!", 0LL);
return func2();
}

original_code:
static void test_small_m_calloc (int _i __attribute__ ((unused))){ tcase_fn_start ("""test_small_m_calloc", "check_memory_handling.c", 37);
{
 void * mem=((void *)0);
 int i=0;
 mem=m_calloc(100,100);
 (mem!=((void *)0)) ? _mark_point("check_memory_handling.c", 44) : _ck_assert_failed("check_memory_handling.c", 44, "Assertion '""mem!=NULL""' failed" ,"Got no memory!", ((void *)0));
 for(i=0; i<100*100;i++) {
  if (((char*) mem)[i] != 0)
   _ck_assert_failed("check_memory_handling.c", 48, "Failed" ,"Memory was not clear!", ((void *)0));
 }
 m_freeall();
}
}

canonical_original_code:
static void test_small_m_calloc(int _i){ tcase_fn_start ("""test_small_m_calloc", "check_memory_handling.c", 37);
{
 void *mem = ((void *)0);
 int i = 0;
 mem=m_calloc(100,100);
 (mem!=((void *)0)) ? _mark_point("check_memory_handling.c", 44) : _ck_assert_failed("check_memory_handling.c", 44, "Assertion '""mem!=NULL""' failed" ,"Got no memory!", ((void *)0));
 for(i=0; i<100*100;i++) {
  if (((char *) mem)[i] != 0)
   _ck_assert_failed("check_memory_handling.c", 48, "Failed" ,"Memory was not clear!", ((void *)0));
 }
 m_freeall();
}
}

variable_types:
mem
void *


decompiled_code:
__int64 test_small_calloc()
{
__int64 v0; // rax
_BYTE *v1; // rbp
_BYTE *v2; // rax

tcase_fn_start("test_small_calloc", "check_memory_handling.c", 19LL);
v0 = mycalloc(100LL, 100LL);
if ( v0 )
{
v1 = (_BYTE *)v0;
mark_point("check_memory_handling.c", 26LL);
v2 = v1;
while ( !*v2 )
{
if ( ++v2 == v1 + 10000 )
return myfree(v1);
}
ck_assert_failed("check_memory_handling.c", 30LL, "Failed", "Memory was not clear!", 0LL);
}
ck_assert_failed("check_memory_handling.c", 26LL, "Assertion 'mem!=NULL' failed", "Got no memory!", 0LL);
return test_small_malloc();
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rax
_BYTE *v1; // rbp
_BYTE *v2; // rax

tcase_fn_start("test_small_calloc", "check_memory_handling.c", 19LL);
v0 = mycalloc(100LL, 100LL);
if ( v0 )
{
v1 = (_BYTE *)v0;
mark_point("check_memory_handling.c", 26LL);
v2 = v1;
while ( !*v2 )
{
if ( ++v2 == v1 + 10000 )
return myfree(v1);
}
ck_assert_failed("check_memory_handling.c", 30LL, "Failed", "Memory was not clear!", 0LL);
}
ck_assert_failed("check_memory_handling.c", 26LL, "Assertion 'mem!=NULL' failed", "Got no memory!", 0LL);
return func3();
}

original_code:
static void test_small_calloc (int _i __attribute__ ((unused))){ tcase_fn_start ("""test_small_calloc", "check_memory_handling.c", 19);
{
 void * mem=((void *)0);
 int i=0;
 mem=mycalloc(100,100);
 (mem!=((void *)0)) ? _mark_point("check_memory_handling.c", 26) : _ck_assert_failed("check_memory_handling.c", 26, "Assertion '""mem!=NULL""' failed" ,"Got no memory!", ((void *)0));
 for(i=0; i<100*100;i++) {
  if (((char*) mem)[i] != 0)
   _ck_assert_failed("check_memory_handling.c", 30, "Failed" ,"Memory was not clear!", ((void *)0));
 }
 myfree(mem);
}
}

canonical_original_code:
static void test_small_calloc(int _i){ tcase_fn_start ("""test_small_calloc", "check_memory_handling.c", 19);
{
 void *mem = ((void *)0);
 int i = 0;
 mem=mycalloc(100,100);
 (mem!=((void *)0)) ? _mark_point("check_memory_handling.c", 26) : _ck_assert_failed("check_memory_handling.c", 26, "Assertion '""mem!=NULL""' failed" ,"Got no memory!", ((void *)0));
 for(i=0; i<100*100;i++) {
  if (((char *) mem)[i] != 0)
   _ck_assert_failed("check_memory_handling.c", 30, "Failed" ,"Memory was not clear!", ((void *)0));
 }
 myfree(mem);
}
}


decompiled_code:
__int64 test_small_malloc()
{
__int64 v0; // rax
__int64 v1; // rbp
__int64 result; // rax

tcase_fn_start("test_small_malloc", "check_memory_handling.c", 7LL);
v0 = mymalloc(1000LL);
if ( v0 )
{
v1 = v0;
mark_point("check_memory_handling.c", 12LL);
result = myfree(v1);
}
else
{
ck_assert_failed("check_memory_handling.c", 12LL, "Assertion 'mem!=NULL' failed", "Got no memory!", 0LL);
result = memory_suite();
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
__int64 v1; // rbp
__int64 result; // rax

tcase_fn_start("test_small_malloc", "check_memory_handling.c", 7LL);
v0 = mymalloc(1000LL);
if ( v0 )
{
v1 = v0;
mark_point("check_memory_handling.c", 12LL);
result = myfree(v1);
}
else
{
ck_assert_failed("check_memory_handling.c", 12LL, "Assertion 'mem!=NULL' failed", "Got no memory!", 0LL);
result = func4();
}
return result;
}

original_code:
static void test_small_malloc (int _i __attribute__ ((unused))){ tcase_fn_start ("""test_small_malloc", "check_memory_handling.c", 7);
{
 void * mem=((void *)0);
 mem=mymalloc(1000);
 (mem!=((void *)0)) ? _mark_point("check_memory_handling.c", 12) : _ck_assert_failed("check_memory_handling.c", 12, "Assertion '""mem!=NULL""' failed" ,"Got no memory!", ((void *)0));
 myfree(mem);
}
}

canonical_original_code:
static void test_small_malloc(int _i){ tcase_fn_start ("""test_small_malloc", "check_memory_handling.c", 7);
{
 void *mem = ((void *)0);
 mem=mymalloc(1000);
 (mem!=((void *)0)) ? _mark_point("check_memory_handling.c", 12) : _ck_assert_failed("check_memory_handling.c", 12, "Assertion '""mem!=NULL""' failed" ,"Got no memory!", ((void *)0));
 myfree(mem);
}
}


main

canonical_name: main

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

v3 = memory_suite();
v4 = srunner_create(v3, argv);
srunner_run_all(v4, 2LL);
v5 = srunner_ntests_failed(v4);
srunner_free(v4);
return v5 != 0;
}

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

v3 = func4();
v4 = srunner_create(v3, argv);
srunner_run_all(v4, 2LL);
v5 = srunner_ntests_failed(v4);
srunner_free(v4);
return v5 != 0;
}

original_code:
int main(int argc, char *argv[]) {
   int i, labelsfile = 0;
   BOOLEAN source_set=0;
   BOOLEAN has_strc;
   int options[24], nopt=0;
   NODATA = (char*)mymalloc(2 * sizeof(char));
   strcpy(NODATA, "M");
   OPTREC optrec[24] = {
      {"-h", &help}, {"-help", &help}, {"--help", &help}, {"-?", &help},
      {"-silent", &silent}, {"--silent", &silent},
      {"-noplot", &noplot}, {"--noplot", &noplot},
      {"-log", &log_set}, {"--log", &log_set},
      {"-nofile", &nofile}, {"--nofile", &nofile},
      {"-nobell", &nobell}, {"--nobell", &nobell},
      {"-thist", &thist}, {"--thist", &thist},
      {"--bernhard",&bernhard},
      {"--header", &has_header},
      {"--noheader", &noheader},
      {"--xsample", &xsample},
      {"--xcols", &xcols},
      {"--color", &color},
      {"--quiet",&silent},
      {"--version", &version} };
   prefs_filename = (char*)mymalloc(15 * sizeof(char));
   strcpy(prefs_filename, "/etc/statistrc");
   has_strc = read_options();
   myfree(prefs_filename);
   prefs_filename = ((void *)0);
   set_prefs_filename();
   signal(13, handle_pipe_interrupt);
   signal(8, handle_fpe_interrupt);
   signal(2, handle_term_interrupt);
   signal(15, handle_term_interrupt);
   setlocale (6, "");
   bindtextdomain ("statist", "/progetti/statist-1.4.2/os2/share/locale");
   textdomain ("statist");
   is_utf8 = get_utf8_status();
   if(has_strc)
     read_options();
   else
     has_strc = read_options();
   set_default_colors();
   for (i=1; i<argc; i++) {
     if (argv[i][0]=='-') {
       options[nopt] = i;
       nopt ++;
       if (nopt > 24) {
  out_err(2, "", 0, gettext ("Too many options") );
       }
     }
   }
   if (!get_options(argv, options, nopt, optrec)) {
     exit(1);
   }
   out_d(gettext (("\nSTATIST --- Version %s\n " "(C) Dirk Melcher 1997-1999\n (C) Bernhard Reiter 1998-2009\n (C) Jakson Aquino 2005-2009\n STATIST comes with ABSOLUTELY NO WARRANTY; it is Free Software under GNU GPL.\n Read the file COPYING for details.\n\n")), "1.4.2");
  if(version){
    exit(0);
  }
  if(silent)
    verbose = 0;
  if(noheader)
    detect_header = 0;
  if(verbose){
    out_d(gettext (" Hint: You can often answer \"%s\" for the number of columns.\n"),
 gettext (("all")) );
    if(has_strc == 0)
      out_d(gettext ("\n You can create an ~/.statistrc file to increase statist " "functionality.\n There is an example of statistrc at %s.\n"),
   "/progetti/statist-1.4.2/os2/share/doc/statist");
  }
   out_d("\n");
   if (help) {
     help_msg();
     exit(0);
   }
   if(xsample){
     extract_sample(argc, argv);
     finish();
     exit(0);
   }
   for (i=1; i<argc; i++) {
     if (!(argv[i][0]=='-')){
       if(strcmp(argv[i-1], "--labels") == 0){
  labelsfile = i;
       } else
  if(strcmp(argv[i-1], "--na-string") == 0){
    NODATA = (char*)mymalloc((strlen(argv[i]) + 1) * sizeof(char));
    strcpy(NODATA, argv[i]);
  } else
    if(strcmp(argv[i-1], "--sep") == 0){
      if(strcmp(argv[i], "\\t") == 0)
        sep = '\t';
      else
        sep = argv[i][0];
    } else
      if(strcmp(argv[i-1], "--dec") == 0){
        dec = argv[i][0];
      } else
        if(!xcols){
   if (!source_set) {
     sourcename = (char*) mycalloc(strlen(argv[i]) + 1, sizeof(char));
     strcpy(sourcename, argv[i]);
     source_set = 1;
   }
   else {
     if(silent)
       out_err(2, "", 0,
    gettext (" More than one data file given!"));
     else{
       out_err(1, "", 0,
    gettext (" More than one data file given!\n" "   Only the first one will be read."));
       if(verbose)
         out_d(gettext ("   If you really want to load more than one file, please\n" "   choose the menu option:\n" "   'Data management | Read another file'\n"));
       mywait();
     }
   }
        }
     }
   }
   if(xcols){
     extract_cols(argc, argv);
     finish();
     exit(0);
   }
   if ( (!source_set) && (!nofile) ) {
     ls();
     out_i(gettext ("Name of data file: ") );
     fgets((line), (255 -1), (stdin)); if (strlen(line) <=1) { empty = 1; } else { line[strlen(line)-1]='\0'; empty = 0; }
       if (empty) {
  out_d(gettext ("No data file given. "));
  nofile = 1;
       } else {
  sourcename = (char*) mycalloc(strlen(line) + 1, sizeof(char));
  sscanf(line, "%s", sourcename);
  if(!(myexist(sourcename))){
    nofile = 1;
    out_err(1, "", 0,
        gettext ("File \"%s\" not found!"), sourcename);
    myfree(sourcename);
    sourcename = ((void *)0);
  }
       }
   }
   if (log_set) {
     if ((logfile = fopen(("statist.log"), ("wt")))==((void *)0)) { out_err(2, "", 0, gettext (" System reports error while opening file %s:\n   %s"), "statist.log", strerror((*__errno_location ()))); };
     if(!nofile)
       out_r(gettext ("Source file = %s\n\n"), sourcename);
   }
   if(dec != '.' && dec != ','){
     if(silent){
       out_err(0, "", 0,
    gettext ("Invalid decimal delimiter: '%c'. Please, choose either ',' or '.'"), dec);
     } else{
       out_err(1, "", 0,
    gettext ("Invalid decimal delimiter: '%c'. Please, choose either ',' or '.'"), dec);
       if(!nofile)
  show_file_head(sourcename);
       set_fileformat();
     }
   }
   if(sep && !(sep == ' ' || sep == ',' || sep == ';' || sep == '\t')){
       if(silent){
  out_err(0, "", 0, gettext ("Invalid field separator: '%c'"), sep);
       } else{
  out_err(1, "", 0, gettext ("Invalid field separator: '%c'"), sep);
  if(!nofile)
    show_file_head(sourcename);
  set_fileformat();
       }
     }
   if(nofile){
     out_d(gettext ("Load file using menu option\n" "Data management | Read another file\n"));
   } else{
     readsourcefile(sourcename);
     mywait();
   }
   out_d("\n");
   if(labelsfile){
     if(myexist(argv[labelsfile]))
       read_labels(argv[labelsfile]);
     else{
       out_err(1, "", 0,
    gettext ("File \"%s\" not found!"),
    argv[labelsfile]);
     }
   }
   main_menue();
   finish();
   return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
   int i; int labelsfile = 0;
   short source_set = 0;
   short has_strc;
   int options[24]; int nopt = 0;
   NODATA = (char *)mymalloc(2 * sizeof(char));
   strcpy(NODATA, "M");
   struct OPTREC optrec[24] = {
      {"-h", &help}, {"-help", &help}, {"--help", &help}, {"-?", &help},
      {"-silent", &silent}, {"--silent", &silent},
      {"-noplot", &noplot}, {"--noplot", &noplot},
      {"-log", &log_set}, {"--log", &log_set},
      {"-nofile", &nofile}, {"--nofile", &nofile},
      {"-nobell", &nobell}, {"--nobell", &nobell},
      {"-thist", &thist}, {"--thist", &thist},
      {"--bernhard",&bernhard},
      {"--header", &has_header},
      {"--noheader", &noheader},
      {"--xsample", &xsample},
      {"--xcols", &xcols},
      {"--color", &color},
      {"--quiet",&silent},
      {"--version", &version} };
   prefs_filename = (char *)mymalloc(15 * sizeof(char));
   strcpy(prefs_filename, "/etc/statistrc");
   has_strc = read_options();
   myfree(prefs_filename);
   prefs_filename = ((void *)0);
   set_prefs_filename();
   signal(13, handle_pipe_interrupt);
   signal(8, handle_fpe_interrupt);
   signal(2, handle_term_interrupt);
   signal(15, handle_term_interrupt);
   setlocale (6, "");
   bindtextdomain ("statist", "/progetti/statist-1.4.2/os2/share/locale");
   textdomain ("statist");
   is_utf8 = get_utf8_status();
   if(has_strc)
     read_options();
   else
     has_strc = read_options();
   set_default_colors();
   for (i=1; i<argc; i++) {
     if (argv[i][0]=='-') {
       options[nopt] = i;
       nopt ++;
       if (nopt > 24) {
  out_err(2, "", 0, gettext ("Too many options") );
       }
     }
   }
   if (!get_options(argv, options, nopt, optrec)) {
     exit(1);
   }
   out_d(gettext (("\nSTATIST --- Version %s\n " "(C) Dirk Melcher 1997-1999\n (C) Bernhard Reiter 1998-2009\n (C) Jakson Aquino 2005-2009\n STATIST comes with ABSOLUTELY NO WARRANTY; it is Free Software under GNU GPL.\n Read the file COPYING for details.\n\n")), "1.4.2");
  if(version){
    exit(0);
  }
  if(silent)
    verbose = 0;
  if(noheader)
    detect_header = 0;
  if(verbose){
    out_d(gettext (" Hint: You can often answer \"%s\" for the number of columns.\n"),
 gettext (("all")) );
    if(has_strc == 0)
      out_d(gettext ("\n You can create an ~/.statistrc file to increase statist " "functionality.\n There is an example of statistrc at %s.\n"),
   "/progetti/statist-1.4.2/os2/share/doc/statist");
  }
   out_d("\n");
   if (help) {
     help_msg();
     exit(0);
   }
   if(xsample){
     extract_sample(argc, argv);
     finish();
     exit(0);
   }
   for (i=1; i<argc; i++) {
     if (!(argv[i][0]=='-')){
       if(strcmp(argv[i-1], "--labels") == 0){
  labelsfile = i;
       } else
  if(strcmp(argv[i-1], "--na-string") == 0){
    NODATA = (char *)mymalloc((strlen(argv[i]) + 1) * sizeof(char));
    strcpy(NODATA, argv[i]);
  } else
    if(strcmp(argv[i-1], "--sep") == 0){
      if(strcmp(argv[i], "\\t") == 0)
        sep = '\t';
      else
        sep = argv[i][0];
    } else
      if(strcmp(argv[i-1], "--dec") == 0){
        dec = argv[i][0];
      } else
        if(!xcols){
   if (!source_set) {
     sourcename = (char *) mycalloc(strlen(argv[i]) + 1, sizeof(char));
     strcpy(sourcename, argv[i]);
     source_set = 1;
   }
   else {
     if(silent)
       out_err(2, "", 0,
    gettext (" More than one data file given!"));
     else{
       out_err(1, "", 0,
    gettext (" More than one data file given!\n" "   Only the first one will be read."));
       if(verbose)
         out_d(gettext ("   If you really want to load more than one file, please\n" "   choose the menu option:\n" "   'Data management | Read another file'\n"));
       mywait();
     }
   }
        }
     }
   }
   if(xcols){
     extract_cols(argc, argv);
     finish();
     exit(0);
   }
   if ( (!source_set) && (!nofile) ) {
     ls();
     out_i(gettext ("Name of data file: ") );
     fgets((line), (255 -1), (stdin)); if (strlen(line) <=1) { empty = 1; } else { line[strlen(line)-1]='\0'; empty = 0; }
       if (empty) {
  out_d(gettext ("No data file given. "));
  nofile = 1;
       } else {
  sourcename = (char *) mycalloc(strlen(line) + 1, sizeof(char));
  sscanf(line, "%s", sourcename);
  if(!(myexist(sourcename))){
    nofile = 1;
    out_err(1, "", 0,
        gettext ("File \"%s\" not found!"), sourcename);
    myfree(sourcename);
    sourcename = ((void *)0);
  }
       }
   }
   if (log_set) {
     if ((logfile = fopen(("statist.log"), ("wt")))==((void *)0)) { out_err(2, "", 0, gettext (" System reports error while opening file %s:\n   %s"), "statist.log", strerror((*__errno_location ()))); };
     if(!nofile)
       out_r(gettext ("Source file = %s\n\n"), sourcename);
   }
   if(dec != '.' && dec != ','){
     if(silent){
       out_err(0, "", 0,
    gettext ("Invalid decimal delimiter: '%c'. Please, choose either ',' or '.'"), dec);
     } else{
       out_err(1, "", 0,
    gettext ("Invalid decimal delimiter: '%c'. Please, choose either ',' or '.'"), dec);
       if(!nofile)
  show_file_head(sourcename);
       set_fileformat();
     }
   }
   if(sep && !(sep == ' ' || sep == ',' || sep == ';' || sep == '\t')){
       if(silent){
  out_err(0, "", 0, gettext ("Invalid field separator: '%c'"), sep);
       } else{
  out_err(1, "", 0, gettext ("Invalid field separator: '%c'"), sep);
  if(!nofile)
    show_file_head(sourcename);
  set_fileformat();
       }
     }
   if(nofile){
     out_d(gettext ("Load file using menu option\n" "Data management | Read another file\n"));
   } else{
     readsourcefile(sourcename);
     mywait();
   }
   out_d("\n");
   if(labelsfile){
     if(myexist(argv[labelsfile]))
       read_labels(argv[labelsfile]);
     else{
       out_err(1, "", 0,
    gettext ("File \"%s\" not found!"),
    argv[labelsfile]);
     }
   }
   main_menue();
   finish();
   return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: labelsfile int

variable_types:
options
int [24]

variable_types: nopt int

variable_types: struct OPTREC { char *optstr; short *optvar; } [24]


myrealloc

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

result = realloc(a1, a2);
if ( !result )
{
v3 = dcgettext(0LL, "Not enough memory. Terminating!", 5);
out_err(2LL, &unk_1C0, 0LL, v3);
finish();
exit(1);
}
return result;
}

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

result = realloc(a1, a2);
if ( !result )
{
v3 = dcgettext(0LL, "Not enough memory. Terminating!", 5);
out_err(2LL, &unk_1C0, 0LL, v3);
finish();
exit(1);
}
return result;
}

original_code:
void *myrealloc(void * pointer, int newsize) {
  pointer = realloc(pointer, newsize);
  if (pointer == ((void *)0)) {
     out_err(2, "", 0,
  gettext ("Not enough memory. Terminating!") );
     finish();
     exit(1);
  }
  return pointer;
}

canonical_original_code:
void *myrealloc(void *pointer, int newsize) {
  pointer = realloc(pointer, newsize);
  if (pointer == ((void *)0)) {
     out_err(2, "", 0,
  gettext ("Not enough memory. Terminating!") );
     finish();
     exit(1);
  }
  return pointer;
}

variable_types:
pointer
void *

variable_types: newsize int


mycalloc

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

result = calloc(a1, a2);
if ( !result )
{
v3 = dcgettext(0LL, "Not enough memory. Terminating!", 5);
out_err(2LL, &unk_1C0, 0LL, v3);
finish();
exit(1);
}
return result;
}

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

result = calloc(a1, a2);
if ( !result )
{
v3 = dcgettext(0LL, "Not enough memory. Terminating!", 5);
out_err(2LL, &unk_1C0, 0LL, v3);
finish();
exit(1);
}
return result;
}

original_code:
void *mycalloc(int nitems, int size) {
  void *pointer;
  pointer = calloc(nitems, size);
  if (pointer == ((void *)0)) {
     out_err(2, "", 0,
  gettext ("Not enough memory. Terminating!") );
     finish();
     exit(1);
  }
  return pointer;
}

variable_types: nitems int

variable_types: size int


mymalloc

decompiled_code:
void *__fastcall mymalloc(int a1)
{
void *result; // rax
char *v2; // rax

result = malloc(a1);
if ( !result )
{
v2 = dcgettext(0LL, "Not enough memory. Terminating!", 5);
out_err(2LL, &unk_1C0, 0LL, v2);
finish();
exit(1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(int a1)
{
void *result; // rax
char *v2; // rax

result = malloc(a1);
if ( !result )
{
v2 = dcgettext(0LL, "Not enough memory. Terminating!", 5);
out_err(2LL, &unk_1C0, 0LL, v2);
finish();
exit(1);
}
return result;
}

original_code:
void *mymalloc(int size) {
  void *pointer;
  pointer = malloc(size);
  if (pointer == ((void *)0)) {
     out_err(2, "", 0,
  gettext ("Not enough memory. Terminating!") );
     finish();
     exit(1);
  }
  return pointer;
}


myfree

decompiled_code:
// attributes: thunk
void myfree(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func3(void *ptr)
{
free(ptr);
}

original_code:
void myfree(void *ptr) {
  free(ptr);
}

canonical_original_code:
void myfree(void *ptr) {
  free(ptr);
}

variable_types:
ptr
void *


decompiled_code:
void *__fastcall m_calloc(int a1, int a2)
{
_QWORD *v2; // rbp
void *result; // rax
void *v4; // rdx

v2 = mycalloc(1, 24);
result = mycalloc(a1, a2);
v4 = ptr_memory_chunks;
ptr_memory_chunks = v2;
v2[2] = result;
*v2 = a2 * a1;
v2[1] = v4;
return result;
}

canonical_decompiled_code:
void *__fastcall func4(int a1, int a2)
{
_QWORD *v2; // rbp
void *result; // rax
void *v4; // rdx

v2 = func1(1, 24);
result = func1(a1, a2);
v4 = ptr_memory_chunks;
ptr_memory_chunks = v2;
v2[2] = result;
*v2 = a2 * a1;
v2[1] = v4;
return result;
}

original_code:
void *m_calloc(int nitems, int size) {
  memory_chunk *chunk;
  chunk = mycalloc(1,sizeof(memory_chunk));
  chunk->memory = mycalloc(nitems, size);
  chunk->size = nitems * size;
  chunk->previous_chunk=ptr_memory_chunks;
  ptr_memory_chunks=chunk;
  return chunk->memory;
}

canonical_original_code:
void *m_calloc(int nitems, int size) {
  struct memory_chunk *chunk;
  chunk = mycalloc(1,sizeof(memory_chunk));
  chunk->memory = mycalloc(nitems, size);
  chunk->size = nitems * size;
  chunk->previous_chunk=ptr_memory_chunks;
  ptr_memory_chunks=chunk;
  return chunk->memory;
}

variable_types: struct memory_chunk { unsigned long size; void *previous_chunk; void *memory; } *


decompiled_code:
__int64 m_freeall()
{
void **v0; // rbx
void **v1; // rdi

v0 = (void **)ptr_memory_chunks;
if ( ptr_memory_chunks )
{
do
{
myfree(v0[2]);
v1 = v0;
v0 = (void **)v0[1];
ptr_memory_chunks = v0;
myfree(v1);
}
while ( v0 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
void **v0; // rbx
void **v1; // rdi

v0 = (void **)ptr_memory_chunks;
if ( ptr_memory_chunks )
{
do
{
func3(v0[2]);
v1 = v0;
v0 = (void **)v0[1];
ptr_memory_chunks = v0;
func3(v1);
}
while ( v0 );
}
return 0LL;
}

original_code:
int m_freeall(void) {
  memory_chunk *chunk=((void *)0);
  while(ptr_memory_chunks!=((void *)0)) {
    chunk=ptr_memory_chunks;
    myfree(chunk->memory);
    ptr_memory_chunks=chunk->previous_chunk;
    myfree(chunk);
  }
  return 0;
}

canonical_original_code:
int m_freeall() {
  struct memory_chunk *chunk = ((void *)0);
  while(ptr_memory_chunks!=((void *)0)) {
    chunk=ptr_memory_chunks;
    myfree(chunk->memory);
    ptr_memory_chunks=chunk->previous_chunk;
    myfree(chunk);
  }
  return 0;
}

user_defined_types: struct memory_chunk { unsigned long size; void *previous_chunk; void *memory; }


newtrans

decompiled_code:
_WORD *newtrans()
{
_WORD *result; // rax

result = malloc(0x20uLL);
*(_DWORD *)result = 0;
result[2] = 0;
*((_BYTE *)result + 6) = 0;
*((_DWORD *)result + 2) = 0;
*((_QWORD *)result + 3) = 0LL;
return result;
}

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

result = malloc(0x20uLL);
*(_DWORD *)result = 0;
result[2] = 0;
*((_BYTE *)result + 6) = 0;
*((_DWORD *)result + 2) = 0;
*((_QWORD *)result + 3) = 0LL;
return result;
}

original_code:
trans
newtrans() {
    trans new;
    int i;
    new = (trans) malloc(sizeof (struct transx));
    for (i=0; i<((50 +6)/8); i++) new->states[i] = 0;
    new->anyst = 0;
    new->nxt = ((void *)0);
    return(new);
}

canonical_original_code:
struct transx *newtrans() {
    struct transx *new;
    int i;
    new = (struct transx *) malloc(sizeof (struct transx));
    for (i=0; i<((50 +6)/8); i++) new->states[i] = 0;
    new->anyst = 0;
    new->nxt = ((void *)0);
    return(new);
}

variable_types: struct transx { unsigned char states[-1]; int anyst; unsigned char inchr; int actno; struct transx *nxt; } *

variable_types: i int


emptytbl

decompiled_code:
unsigned __int64 emptytbl()
{
unsigned __int64 result; // rax

result = (unsigned int)nstates;
if ( 96 * nstates > 0 )
result = (unsigned __int64)memset(&tbl, 255, 384LL * nstates);
return result;
}

canonical_decompiled_code:
unsigned __int64 func8()
{
unsigned __int64 result; // rax

result = (unsigned int)nstates;
if ( 96 * nstates > 0 )
result = (unsigned __int64)memset(&tbl, 255, 384LL * nstates);
return result;
}

original_code:
void
emptytbl() {
    int i;
    for (i=0; i<nstates*96; i++) tbl[i] = -1;
}


clrhash

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

result = 0LL;
memset(&htab, 0, 0x328uLL);
return result;
}

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

result = 0LL;
memset(&htab, 0, 0x328uLL);
return result;
}

original_code:
void
clrhash() {
    int i;
    for (i=0; i<101; i++) htab[i] = ((void *)0);
}


usage

decompiled_code:
int usage()
{
const char *v0; // rdx
const char *v1; // rcx
int result; // eax

v0 = (const char *)versio;
if ( versio && *versio )
{
v1 = (const char *)build;
if ( build )
goto LABEL_4;
}
else
{
v1 = (const char *)build;
v0 = "gkermit UNKNOWN VERSION";
versio = "gkermit UNKNOWN VERSION";
if ( build )
{
LABEL_4:
if ( url )
goto LABEL_5;
LABEL_11:
url = &unk_1016;
if ( email )
goto LABEL_6;
LABEL_12:
email = &unk_1016;
goto LABEL_6;
}
}
v1 = "UNKNOWN BUILD";
build = "UNKNOWN BUILD";
if ( !url )
goto LABEL_11;
LABEL_5:
if ( !email )
goto LABEL_12;
LABEL_6:
fprintf(stderr, "%s: %s.\n", v0, v1);
fwrite("Usage: gkermit [ options ]\n", 1uLL, 0x1CuLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite(" -r Receive files\n", 1uLL, 0x17uLL, stderr);
fwrite(" -s fn Send files\n", 1uLL, 0x14uLL, stderr);
fwrite(" -g fn Get files from server\n", 1uLL, 0x1FuLL, stderr);
fwrite(" -a fn As-name for single file\n", 1uLL, 0x21uLL, stderr);
fwrite(" -i Image (binary) mode transfer\n", 1uLL, 0x26uLL, stderr);
fwrite(" -T Text mode transfer\n", 1uLL, 0x1CuLL, stderr);
fwrite(" -P Path/filename conversion disabled\n", 1uLL, 0x2BuLL, stderr);
fwrite(" -w Write over existing files with same name\n", 1uLL, 0x32uLL, stderr);
fwrite(" -K Keep incompletely received files\n", 1uLL, 0x2AuLL, stderr);
fwrite(" -p x Parity: x = o[dd],e[ven],m[ark],s[pace],n[one]\n", 1uLL, 0x38uLL, stderr);
fprintf(stderr, " -e n Receive packet-length (40-%d)\n", 9000LL);
fwrite(" -b n Timeout (sec, 0 = none)\n", 1uLL, 0x21uLL, stderr);
fwrite(" -x Force Xon/Xoff (--x = Don't force Xon/Xoff)\n", 1uLL, 0x35uLL, stderr);
fwrite(" -S Disable streaming\n", 1uLL, 0x1BuLL, stderr);
fwrite(" -X External protocol\n", 1uLL, 0x1BuLL, stderr);
fwrite(" -q Quiet (suppress messages)\n", 1uLL, 0x23uLL, stderr);
fwrite(" -d [fn] Debug to ./debug.log [or specified file]\n", 1uLL, 0x32uLL, stderr);
result = fwrite(" -h Help (this message)\n", 1uLL, 0x1DuLL, stderr);
if ( *url || *email )
result = fprintf(stderr, "More info: %s <%s>", url, email);
return result;
}

canonical_decompiled_code:
int func1()
{
const char *v0; // rdx
const char *v1; // rcx
int result; // eax

v0 = (const char *)versio;
if ( versio && *versio )
{
v1 = (const char *)build;
if ( build )
goto LABEL_4;
}
else
{
v1 = (const char *)build;
v0 = "gkermit UNKNOWN VERSION";
versio = "gkermit UNKNOWN VERSION";
if ( build )
{
LABEL_4:
if ( url )
goto LABEL_5;
LABEL_11:
url = &unk_1016;
if ( email )
goto LABEL_6;
LABEL_12:
email = &unk_1016;
goto LABEL_6;
}
}
v1 = "UNKNOWN BUILD";
build = "UNKNOWN BUILD";
if ( !url )
goto LABEL_11;
LABEL_5:
if ( !email )
goto LABEL_12;
LABEL_6:
fprintf(stderr, "%s: %s.\n", v0, v1);
fwrite("Usage: gkermit [ options ]\n", 1uLL, 0x1CuLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite(" -r Receive files\n", 1uLL, 0x17uLL, stderr);
fwrite(" -s fn Send files\n", 1uLL, 0x14uLL, stderr);
fwrite(" -g fn Get files from server\n", 1uLL, 0x1FuLL, stderr);
fwrite(" -a fn As-name for single file\n", 1uLL, 0x21uLL, stderr);
fwrite(" -i Image (binary) mode transfer\n", 1uLL, 0x26uLL, stderr);
fwrite(" -T Text mode transfer\n", 1uLL, 0x1CuLL, stderr);
fwrite(" -P Path/filename conversion disabled\n", 1uLL, 0x2BuLL, stderr);
fwrite(" -w Write over existing files with same name\n", 1uLL, 0x32uLL, stderr);
fwrite(" -K Keep incompletely received files\n", 1uLL, 0x2AuLL, stderr);
fwrite(" -p x Parity: x = o[dd],e[ven],m[ark],s[pace],n[one]\n", 1uLL, 0x38uLL, stderr);
fprintf(stderr, " -e n Receive packet-length (40-%d)\n", 9000LL);
fwrite(" -b n Timeout (sec, 0 = none)\n", 1uLL, 0x21uLL, stderr);
fwrite(" -x Force Xon/Xoff (--x = Don't force Xon/Xoff)\n", 1uLL, 0x35uLL, stderr);
fwrite(" -S Disable streaming\n", 1uLL, 0x1BuLL, stderr);
fwrite(" -X External protocol\n", 1uLL, 0x1BuLL, stderr);
fwrite(" -q Quiet (suppress messages)\n", 1uLL, 0x23uLL, stderr);
fwrite(" -d [fn] Debug to ./debug.log [or specified file]\n", 1uLL, 0x32uLL, stderr);
result = fwrite(" -h Help (this message)\n", 1uLL, 0x1DuLL, stderr);
if ( *url || *email )
result = fprintf(stderr, "More info: %s <%s>", url, email);
return result;
}

original_code:
void
usage() {
    extern char * versio, * build, * url, * email;
    if (!versio) versio = "";
    if (!*versio) versio = "gkermit UNKNOWN VERSION";
    if (!build) build = "UNKNOWN BUILD";
    if (!url) url = "";
    if (!email) email = "";
    fprintf(stderr,"%s: %s.\n",versio,build);
    fprintf(stderr,"Usage:  gkermit [ options ]\n");
    fprintf(stderr,"Options:\n");
    fprintf(stderr," -r      Receive files\n");
    fprintf(stderr," -s fn   Send files\n");
    fprintf(stderr," -g fn   Get files from server\n");
    fprintf(stderr," -a fn   As-name for single file\n");
    fprintf(stderr," -i      Image (binary) mode transfer\n");
    fprintf(stderr," -T      Text mode transfer\n");
    fprintf(stderr," -P      Path/filename conversion disabled\n");
    fprintf(stderr," -w      Write over existing files with same name\n");
    fprintf(stderr," -K      Keep incompletely received files\n");
    fprintf(stderr," -p x    Parity: x = o[dd],e[ven],m[ark],s[pace],n[one]\n")
      ;
    fprintf(stderr," -e n    Receive packet-length (40-%d)\n",9000);
    fprintf(stderr," -b n    Timeout (sec, 0 = none)\n");
    fprintf(stderr," -x      Force Xon/Xoff (--x = Don't force Xon/Xoff)\n");
    fprintf(stderr," -S      Disable streaming\n");
    fprintf(stderr," -X      External protocol\n");
    fprintf(stderr," -q      Quiet (suppress messages)\n");
    fprintf(stderr," -d [fn] Debug to ./debug.log [or specified file]\n");
    fprintf(stderr," -h      Help (this message)\n");
    if (*url || *email)
      fprintf(stderr,"More info: %s <%s>",url,email);
}

canonical_original_code:
void usage() {
    extern char *versio; extern char *build; extern char *url; extern char *email;
    if (!versio) versio = "";
    if (!*versio) versio = "gkermit UNKNOWN VERSION";
    if (!build) build = "UNKNOWN BUILD";
    if (!url) url = "";
    if (!email) email = "";
    fprintf(stderr,"%s: %s.\n",versio,build);
    fprintf(stderr,"Usage:  gkermit [ options ]\n");
    fprintf(stderr,"Options:\n");
    fprintf(stderr," -r      Receive files\n");
    fprintf(stderr," -s fn   Send files\n");
    fprintf(stderr," -g fn   Get files from server\n");
    fprintf(stderr," -a fn   As-name for single file\n");
    fprintf(stderr," -i      Image (binary) mode transfer\n");
    fprintf(stderr," -T      Text mode transfer\n");
    fprintf(stderr," -P      Path/filename conversion disabled\n");
    fprintf(stderr," -w      Write over existing files with same name\n");
    fprintf(stderr," -K      Keep incompletely received files\n");
    fprintf(stderr," -p x    Parity: x = o[dd],e[ven],m[ark],s[pace],n[one]\n")
      ;
    fprintf(stderr," -e n    Receive packet-length (40-%d)\n",9000);
    fprintf(stderr," -b n    Timeout (sec, 0 = none)\n");
    fprintf(stderr," -x      Force Xon/Xoff (--x = Don't force Xon/Xoff)\n");
    fprintf(stderr," -S      Disable streaming\n");
    fprintf(stderr," -X      External protocol\n");
    fprintf(stderr," -q      Quiet (suppress messages)\n");
    fprintf(stderr," -d [fn] Debug to ./debug.log [or specified file]\n");
    fprintf(stderr," -h      Help (this message)\n");
    if (*url || *email)
      fprintf(stderr,"More info: %s <%s>",url,email);
}

variable_types:
versio
char *

variable_types:
build
char *

variable_types:
url
char *

variable_types:
email
char *


doarg

decompiled_code:
__int64 __fastcall doarg(char a1)
{
char v1; // al
__int64 v2; // rbp
__int64 v3; // rbx
__int64 v5; // rdi
int v6; // esi
__int64 v7; // rax
int v8; // edx
_BYTE *v9; // rcx
__int64 v10; // rdx
_BYTE *v11; // rax
int v12; // edx
char v13; // al
bool v14; // zf
__int64 v15; // rdx
_BYTE *v16; // rax
__int64 v17; // rdx
const char *v18; // rdi
int v19; // eax
const char *v20; // rdi
FILE *v21; // rdi
const char *v22; // rcx
const char *v23; // rdx
__int64 v24; // rdx
const char *v25; // rdi
int v26; // eax
__int64 v27; // rdx
const char *v28; // rdx
__int64 v29; // rdi

v1 = a1;
v2 = *xargv + 1LL;
if ( a1 )
{
while ( 2 )
{
switch ( v1 )
{
case '-':
if ( *(_BYTE *)(v2 + 1) == 120 )
{
xonxoff = 0;
noxonxoff = 1;
}
else
{
fatal("invalid argument, type 'gkermit -h' for help");
}
v3 = v2 + 1;
goto LABEL_5;
case '?':
case 'h':
usage();
doexit(0LL);
goto LABEL_4;
case 'K':
keep = 1;
v3 = v2;
goto LABEL_5;
case 'P':
literal = 1;
v3 = v2;
goto LABEL_5;
case 'S':
streamok = -1;
v3 = v2;
goto LABEL_5;
case 'T':
manual = 1;
v3 = v2;
text = 1;
goto LABEL_5;
case 'X':
quiet = 1;
v3 = v2;
nomodes = 1;
goto LABEL_5;
case 'a':
if ( *(_BYTE *)(v2 + 1) )
fatal("invalid argument bundling after -a");
v14 = xargc-- == 1;
v27 = xargv;
xargv += 8LL;
if ( v14 || (v28 = *(const char **)(v27 + 8), *v28 == 45) )
{
fatal("missing name for -a");
v28 = (const char *)*xargv;
}
cmarg2 = v28;
v3 = v2;
if ( debug )
fprintf(db, "as-name: %s\n", v28);
goto LABEL_5;
case 'b':
if ( *(_BYTE *)(v2 + 1) )
fatal("invalid argument bundling after -b");
v24 = xargv;
xargv += 8LL;
--xargc;
if ( xargc <= 0 || (v25 = *(const char **)(v24 + 8), *v25 == 45) )
{
fatal("missing value");
v25 = (const char *)*xargv;
}
v3 = v2;
v26 = atoi(v25);
if ( v26 > 90 )
v26 = 90;
if ( v26 < 0 )
v26 = 0;
timint = v26;
goto LABEL_5;
case 'd':
if ( xargc <= 1 || (v20 = *(const char **)(xargv + 8LL), *v20 == 45) )
{
db = fopen("debug.log", "w");
v21 = db;
}
else
{
xargv += 8LL;
--xargc;
db = fopen(v20, "w");
v21 = db;
}
v3 = v2;
if ( v21 )
{
if ( !versio )
versio = &unk_1016;
if ( !build )
build = &unk_1016;
debug = 1;
v3 = v2;
setbuf(v21, 0LL);
v22 = (const char *)build;
v23 = (const char *)versio;
if ( !*build )
v22 = "BUILD UNKNOWN";
if ( !*versio )
v23 = "GKERMIT VERSION UNKNOWN";
fprintf(db, "%s: %s\n", v23, v22);
fprintf(db, "MAXPATHLEN = %d\n", 1024LL);
if ( gptr )
fprintf(db, "GKERMIT=\"%s\"\n", (const char *)gptr);
}
goto LABEL_5;
case 'e':
if ( *(_BYTE *)(v2 + 1) )
fatal("invalid argument bundling after -e");
v17 = xargv;
xargv += 8LL;
--xargc;
if ( xargc <= 0 || (v18 = *(const char **)(v17 + 8), *v18 == 45) )
{
fatal("missing length");
v18 = (const char *)*xargv;
}
v19 = atoi(v18);
if ( (unsigned int)(v19 - 40) > 0x2300 )
{
v3 = v2;
fatal("Unsupported packet length");
}
else
{
urpsiz = v19;
if ( v19 <= 94 )
rpsiz = v19;
else
rpsiz = 94;
v3 = v2;
}
goto LABEL_5;
case 'g':
if ( action )
fatal("conflicting actions");
if ( *(_BYTE *)(v2 + 1) )
fatal("invalid argument bundling after -g");
v14 = xargc-- == 1;
v15 = xargv;
xargv += 8LL;
if ( v14 || (v16 = *(_BYTE **)(v15 + 8), *v16 == 45) )
{
fatal("missing filename for -g");
v16 = (_BYTE *)*xargv;
}
cmarg = v16;
v3 = v2;
action = 114;
goto LABEL_5;
case 'i':
LABEL_4:
manual = 1;
v3 = v2;
text = 0;
goto LABEL_5;
case 'p':
if ( *(_BYTE *)(v2 + 1) )
fatal("invalid argument bundling");
v10 = xargv;
xargv += 8LL;
--xargc;
if ( xargc <= 0 || (v11 = *(_BYTE **)(v10 + 8), v12 = (char)*v11, *v11 == 45) )
{
fatal("missing parity");
v12 = *(char *)*xargv;
v13 = v12 - 101;
if ( (unsigned __int8)(*(_BYTE *)*xargv - 101) > 0xEu )
{
LABEL_91:
v3 = v2;
fatal("invalid parity");
goto LABEL_5;
}
}
else
{
v13 = v12 - 101;
}
switch ( v13 )
{
case 0:
case 8:
case 10:
case 14:
parity = v12;
v3 = v2;
break;
case 9:
parity = 0;
v3 = v2;
break;
default:
goto LABEL_91;
}
LABEL_5:
v1 = *(_BYTE *)(v3 + 1);
v2 = v3 + 1;
if ( !v1 )
break;
continue;
case 'q':
quiet = 1;
v3 = v2;
goto LABEL_5;
case 'r':
if ( action )
fatal("conflicting actions");
action = 118;
v3 = v2;
goto LABEL_5;
case 's':
if ( action )
fatal("conflicting actions");
if ( *(_BYTE *)(v2 + 1) )
fatal("invalid argument bundling after -s");
nfils = 0;
v5 = *(_QWORD *)(xargv + 8LL);
cmlist = xargv + 8LL;
if ( zchki(v5) < 0 )
fatal("file not found or not accessible");
v6 = xargc;
v7 = xargv;
v8 = nfils;
--xargc;
if ( xargc > 0 )
{
do
{
v29 = v7;
v9 = *(_BYTE **)(v7 + 8);
v7 += 8LL;
xargv = v7;
if ( *v9 == 45 )
break;
v6 = xargc;
nfils = ++v8;
--xargc;
}
while ( xargc > 0 );
}
else
{
v29 = xargv - 8LL;
}
xargc = v6;
xargv = v29;
if ( v8 <= 0 )
fatal("missing filename for -s");
action = 115;
v3 = v2;
goto LABEL_5;
case 'w':
backup = 0;
v3 = v2;
goto LABEL_5;
case 'x':
xonxoff = 1;
v3 = v2;
noxonxoff = 0;
goto LABEL_5;
default:
v3 = v2;
fatal("invalid argument, type 'gkermit -h' for help");
goto LABEL_5;
}
}
}
if ( !debug )
return (unsigned int)action;
if ( action )
{
fprintf(db, "cmdlin action = %c\n", (unsigned int)action);
return (unsigned int)action;
}
fwrite("cmdlin action = (none)\n", 1uLL, 0x17uLL, db);
return (unsigned int)action;
}

canonical_decompiled_code:
__int64 __fastcall func2(char a1)
{
char v1; // al
__int64 v2; // rbp
__int64 v3; // rbx
__int64 v5; // rdi
int v6; // esi
__int64 v7; // rax
int v8; // edx
_BYTE *v9; // rcx
__int64 v10; // rdx
_BYTE *v11; // rax
int v12; // edx
char v13; // al
bool v14; // zf
__int64 v15; // rdx
_BYTE *v16; // rax
__int64 v17; // rdx
const char *v18; // rdi
int v19; // eax
const char *v20; // rdi
FILE *v21; // rdi
const char *v22; // rcx
const char *v23; // rdx
__int64 v24; // rdx
const char *v25; // rdi
int v26; // eax
__int64 v27; // rdx
const char *v28; // rdx
__int64 v29; // rdi

v1 = a1;
v2 = *xargv + 1LL;
if ( a1 )
{
while ( 2 )
{
switch ( v1 )
{
case '-':
if ( *(_BYTE *)(v2 + 1) == 120 )
{
xonxoff = 0;
noxonxoff = 1;
}
else
{
func0("invalid argument, type 'gkermit -h' for help");
}
v3 = v2 + 1;
goto LABEL_5;
case '?':
case 'h':
func1();
doexit(0LL);
goto LABEL_4;
case 'K':
keep = 1;
v3 = v2;
goto LABEL_5;
case 'P':
literal = 1;
v3 = v2;
goto LABEL_5;
case 'S':
streamok = -1;
v3 = v2;
goto LABEL_5;
case 'T':
manual = 1;
v3 = v2;
text = 1;
goto LABEL_5;
case 'X':
quiet = 1;
v3 = v2;
nomodes = 1;
goto LABEL_5;
case 'a':
if ( *(_BYTE *)(v2 + 1) )
func0("invalid argument bundling after -a");
v14 = xargc-- == 1;
v27 = xargv;
xargv += 8LL;
if ( v14 || (v28 = *(const char **)(v27 + 8), *v28 == 45) )
{
func0("missing name for -a");
v28 = (const char *)*xargv;
}
cmarg2 = v28;
v3 = v2;
if ( debug )
fprintf(db, "as-name: %s\n", v28);
goto LABEL_5;
case 'b':
if ( *(_BYTE *)(v2 + 1) )
func0("invalid argument bundling after -b");
v24 = xargv;
xargv += 8LL;
--xargc;
if ( xargc <= 0 || (v25 = *(const char **)(v24 + 8), *v25 == 45) )
{
func0("missing value");
v25 = (const char *)*xargv;
}
v3 = v2;
v26 = atoi(v25);
if ( v26 > 90 )
v26 = 90;
if ( v26 < 0 )
v26 = 0;
timint = v26;
goto LABEL_5;
case 'd':
if ( xargc <= 1 || (v20 = *(const char **)(xargv + 8LL), *v20 == 45) )
{
db = fopen("debug.log", "w");
v21 = db;
}
else
{
xargv += 8LL;
--xargc;
db = fopen(v20, "w");
v21 = db;
}
v3 = v2;
if ( v21 )
{
if ( !versio )
versio = &unk_1016;
if ( !build )
build = &unk_1016;
debug = 1;
v3 = v2;
setbuf(v21, 0LL);
v22 = (const char *)build;
v23 = (const char *)versio;
if ( !*build )
v22 = "BUILD UNKNOWN";
if ( !*versio )
v23 = "GKERMIT VERSION UNKNOWN";
fprintf(db, "%s: %s\n", v23, v22);
fprintf(db, "MAXPATHLEN = %d\n", 1024LL);
if ( gptr )
fprintf(db, "GKERMIT=\"%s\"\n", (const char *)gptr);
}
goto LABEL_5;
case 'e':
if ( *(_BYTE *)(v2 + 1) )
func0("invalid argument bundling after -e");
v17 = xargv;
xargv += 8LL;
--xargc;
if ( xargc <= 0 || (v18 = *(const char **)(v17 + 8), *v18 == 45) )
{
func0("missing length");
v18 = (const char *)*xargv;
}
v19 = atoi(v18);
if ( (unsigned int)(v19 - 40) > 0x2300 )
{
v3 = v2;
func0("Unsupported packet length");
}
else
{
urpsiz = v19;
if ( v19 <= 94 )
rpsiz = v19;
else
rpsiz = 94;
v3 = v2;
}
goto LABEL_5;
case 'g':
if ( action )
func0("conflicting actions");
if ( *(_BYTE *)(v2 + 1) )
func0("invalid argument bundling after -g");
v14 = xargc-- == 1;
v15 = xargv;
xargv += 8LL;
if ( v14 || (v16 = *(_BYTE **)(v15 + 8), *v16 == 45) )
{
func0("missing filename for -g");
v16 = (_BYTE *)*xargv;
}
cmarg = v16;
v3 = v2;
action = 114;
goto LABEL_5;
case 'i':
LABEL_4:
manual = 1;
v3 = v2;
text = 0;
goto LABEL_5;
case 'p':
if ( *(_BYTE *)(v2 + 1) )
func0("invalid argument bundling");
v10 = xargv;
xargv += 8LL;
--xargc;
if ( xargc <= 0 || (v11 = *(_BYTE **)(v10 + 8), v12 = (char)*v11, *v11 == 45) )
{
func0("missing parity");
v12 = *(char *)*xargv;
v13 = v12 - 101;
if ( (unsigned __int8)(*(_BYTE *)*xargv - 101) > 0xEu )
{
LABEL_91:
v3 = v2;
func0("invalid parity");
goto LABEL_5;
}
}
else
{
v13 = v12 - 101;
}
switch ( v13 )
{
case 0:
case 8:
case 10:
case 14:
parity = v12;
v3 = v2;
break;
case 9:
parity = 0;
v3 = v2;
break;
default:
goto LABEL_91;
}
LABEL_5:
v1 = *(_BYTE *)(v3 + 1);
v2 = v3 + 1;
if ( !v1 )
break;
continue;
case 'q':
quiet = 1;
v3 = v2;
goto LABEL_5;
case 'r':
if ( action )
func0("conflicting actions");
action = 118;
v3 = v2;
goto LABEL_5;
case 's':
if ( action )
func0("conflicting actions");
if ( *(_BYTE *)(v2 + 1) )
func0("invalid argument bundling after -s");
nfils = 0;
v5 = *(_QWORD *)(xargv + 8LL);
cmlist = xargv + 8LL;
if ( zchki(v5) < 0 )
func0("file not found or not accessible");
v6 = xargc;
v7 = xargv;
v8 = nfils;
--xargc;
if ( xargc > 0 )
{
do
{
v29 = v7;
v9 = *(_BYTE **)(v7 + 8);
v7 += 8LL;
xargv = v7;
if ( *v9 == 45 )
break;
v6 = xargc;
nfils = ++v8;
--xargc;
}
while ( xargc > 0 );
}
else
{
v29 = xargv - 8LL;
}
xargc = v6;
xargv = v29;
if ( v8 <= 0 )
func0("missing filename for -s");
action = 115;
v3 = v2;
goto LABEL_5;
case 'w':
backup = 0;
v3 = v2;
goto LABEL_5;
case 'x':
xonxoff = 1;
v3 = v2;
noxonxoff = 0;
goto LABEL_5;
default:
v3 = v2;
func0("invalid argument, type 'gkermit -h' for help");
goto LABEL_5;
}
}
}
if ( !debug )
return (unsigned int)action;
if ( action )
{
fprintf(db, "cmdlin action = %c\n", (unsigned int)action);
return (unsigned int)action;
}
fwrite("cmdlin action = (none)\n", 1uLL, 0x17uLL, db);
return (unsigned int)action;
}

original_code:
static int
doarg(char x)
{
    int z; char *xp, **p;
    xp = *xargv+1;
    while (x) {
 switch (x) {
   case 'r':
     if (action) fatal("conflicting actions");
     action = 'v';
     break;
   case 's':
     if (action) fatal("conflicting actions");
     if (*(xp+1)) fatal("invalid argument bundling after -s");
     nfils = 0;
     cmlist = xargv+1;
     if (zchki(*cmlist) < 0)
       fatal("file not found or not accessible");
     while (--xargc > 0) {
  *xargv++;
  if (**xargv == '-')
    break;
  nfils++;
     }
     xargc++, *xargv--;
     if (nfils < 1) fatal("missing filename for -s");
     action = 's';
     break;
   case 'g':
     if (action) fatal("conflicting actions");
     if (*(xp+1)) fatal("invalid argument bundling after -g");
     *xargv++, xargc--;
     if ((xargc == 0) || (**xargv == '-'))
       fatal("missing filename for -g");
     cmarg = *xargv;
     action = 'r';
     break;
   case 'h':
   case '?':
     usage();
     doexit(0);
   case 'i':
     manual = 1;
     text = 0;
     break;
   case 'T':
     manual = 1;
     text = 1;
     break;
   case 'p':
     if (*(xp+1)) fatal("invalid argument bundling");
     *xargv++, xargc--;
     if ((xargc < 1) || (**xargv == '-'))
       fatal("missing parity");
     switch(x = **xargv) {
       case 'e':
       case 'o':
       case 'm':
       case 's': parity = x; break;
       case 'n': parity = 0; break;
       default: fatal("invalid parity");
     }
     break;
   case 'w':
     backup = 0;
     break;
   case 'd':
     p = xargv;
     *p++;
     if ((xargc < 2) || (**p == '-')) {
  db = fopen("debug.log","w");
     } else {
  *xargv++, xargc--;
  db = fopen(*xargv,"w");
     }
     if (db) {
  extern char * versio, * build;
  if (!versio) versio = "";
  if (!build) build = "";
  debug = 1;
  setbuf(db,((void *)0));
  fprintf(db,"%s: %s\n",
   (*versio ? versio : "GKERMIT VERSION UNKNOWN"),
   (*build ? build : "BUILD UNKNOWN")
   );
  fprintf(db,"MAXPATHLEN = %d\n",1024);
  if (gptr) fprintf(db,"GKERMIT=\"%s\"\n",gptr);
     }
     break;
   case 'a':
     if (*(xp+1)) fatal("invalid argument bundling after -a");
     *xargv++, xargc--;
     if ((xargc == 0) || (**xargv == '-'))
       fatal("missing name for -a");
     cmarg2 = *xargv;
     if (debug) fprintf(db,"as-name: %s\n",cmarg2);
     break;
   case 'e':
     if (*(xp+1)) fatal("invalid argument bundling after -e");
     xargv++, xargc--;
     if ((xargc < 1) || (**xargv == '-'))
       fatal("missing length");
     z = atoi(*xargv);
     if (z >= 40 && z <= 9000) {
  rpsiz = urpsiz = z;
  if (z > 94) rpsiz = 94;
     } else {
  fatal("Unsupported packet length");
     }
     break;
   case 'b':
     if (*(xp+1)) fatal("invalid argument bundling after -b");
     xargv++, xargc--;
     if ((xargc < 1) || (**xargv == '-'))
       fatal("missing value");
     z = atoi(*xargv);
     if (z < 0) z = 0;
     if (z > 90) z = 90;
     timint = z;
     break;
   case 'P':
     literal = 1;
     break;
   case 'q':
     quiet = 1;
     break;
   case 'K':
     keep = 1;
     break;
   case 'S':
     streamok = -1;
     break;
   case 'X':
     quiet = 1;
            nomodes = 1;
     break;
   case 'x':
     xonxoff = 1;
     noxonxoff = 0;
     break;
   case '-':
     if (*(xp+1) == 'x') {
  xonxoff = 0;
  noxonxoff = 1;
     } else {
  fatal("invalid argument, type 'gkermit -h' for help");
     }
     xp++;
     break;
   default:
     fatal("invalid argument, type 'gkermit -h' for help");
        }
 x = *++xp;
    }
    if (debug) {
 if (action)
   fprintf(db,"cmdlin action = %c\n",action);
 else
   fprintf(db,"cmdlin action = (none)\n");
    }
    return(action);
}

canonical_original_code:
static int doarg(char x)
{
    int z; char *xp; char **p;
    xp = *xargv+1;
    while (x) {
 switch (x) {
   case 'r':
     if (action) fatal("conflicting actions");
     action = 'v';
     break;
   case 's':
     if (action) fatal("conflicting actions");
     if (*(xp+1)) fatal("invalid argument bundling after -s");
     nfils = 0;
     cmlist = xargv+1;
     if (zchki(*cmlist) < 0)
       fatal("file not found or not accessible");
     while (--xargc > 0) {
  *xargv++;
  if (**xargv == '-')
    break;
  nfils++;
     }
     xargc++, *xargv--;
     if (nfils < 1) fatal("missing filename for -s");
     action = 's';
     break;
   case 'g':
     if (action) fatal("conflicting actions");
     if (*(xp+1)) fatal("invalid argument bundling after -g");
     *xargv++, xargc--;
     if ((xargc == 0) || (**xargv == '-'))
       fatal("missing filename for -g");
     cmarg = *xargv;
     action = 'r';
     break;
   case 'h':
   case '?':
     usage();
     doexit(0);
   case 'i':
     manual = 1;
     text = 0;
     break;
   case 'T':
     manual = 1;
     text = 1;
     break;
   case 'p':
     if (*(xp+1)) fatal("invalid argument bundling");
     *xargv++, xargc--;
     if ((xargc < 1) || (**xargv == '-'))
       fatal("missing parity");
     switch(x = **xargv) {
       case 'e':
       case 'o':
       case 'm':
       case 's': parity = x; break;
       case 'n': parity = 0; break;
       default: fatal("invalid parity");
     }
     break;
   case 'w':
     backup = 0;
     break;
   case 'd':
     p = xargv;
     *p++;
     if ((xargc < 2) || (**p == '-')) {
  db = fopen("debug.log","w");
     } else {
  *xargv++, xargc--;
  db = fopen(*xargv,"w");
     }
     if (db) {
  extern char *versio; extern char *build;
  if (!versio) versio = "";
  if (!build) build = "";
  debug = 1;
  setbuf(db,((void *)0));
  fprintf(db,"%s: %s\n",
   (*versio ? versio : "GKERMIT VERSION UNKNOWN"),
   (*build ? build : "BUILD UNKNOWN")
   );
  fprintf(db,"MAXPATHLEN = %d\n",1024);
  if (gptr) fprintf(db,"GKERMIT=\"%s\"\n",gptr);
     }
     break;
   case 'a':
     if (*(xp+1)) fatal("invalid argument bundling after -a");
     *xargv++, xargc--;
     if ((xargc == 0) || (**xargv == '-'))
       fatal("missing name for -a");
     cmarg2 = *xargv;
     if (debug) fprintf(db,"as-name: %s\n",cmarg2);
     break;
   case 'e':
     if (*(xp+1)) fatal("invalid argument bundling after -e");
     xargv++, xargc--;
     if ((xargc < 1) || (**xargv == '-'))
       fatal("missing length");
     z = atoi(*xargv);
     if (z >= 40 && z <= 9000) {
  rpsiz = urpsiz = z;
  if (z > 94) rpsiz = 94;
     } else {
  fatal("Unsupported packet length");
     }
     break;
   case 'b':
     if (*(xp+1)) fatal("invalid argument bundling after -b");
     xargv++, xargc--;
     if ((xargc < 1) || (**xargv == '-'))
       fatal("missing value");
     z = atoi(*xargv);
     if (z < 0) z = 0;
     if (z > 90) z = 90;
     timint = z;
     break;
   case 'P':
     literal = 1;
     break;
   case 'q':
     quiet = 1;
     break;
   case 'K':
     keep = 1;
     break;
   case 'S':
     streamok = -1;
     break;
   case 'X':
     quiet = 1;
            nomodes = 1;
     break;
   case 'x':
     xonxoff = 1;
     noxonxoff = 0;
     break;
   case '-':
     if (*(xp+1) == 'x') {
  xonxoff = 0;
  noxonxoff = 1;
     } else {
  fatal("invalid argument, type 'gkermit -h' for help");
     }
     xp++;
     break;
   default:
     fatal("invalid argument, type 'gkermit -h' for help");
        }
 x = *++xp;
    }
    if (debug) {
 if (action)
   fprintf(db,"cmdlin action = %c\n",action);
 else
   fprintf(db,"cmdlin action = (none)\n");
    }
    return(action);
}

variable_types: x char

variable_types: z int

variable_types:
xp
char *

variable_types:
p
char **


cmdlin

decompiled_code:
__int64 cmdlin()
{
char *v0; // rax
int v1; // ebx
__int64 v2; // rbx
char v3; // dl
int v4; // er8
char *v5; // rax
int v6; // ecx
char v7; // di
int v8; // esi
__int64 v9; // rdx
__int64 v10; // rbp
__int64 *v11; // rax
int v12; // edx
_BYTE *v13; // rdx
__int64 v14; // rdx

cmarg = &unk_1016;
cmlist = 0LL;
action = 0;
v0 = getenv("GKERMIT");
v1 = xargc;
if ( !v0 )
goto LABEL_21;
v2 = (__int64)v0;
strncpy(&gbuf, v0, 0xFFuLL);
v3 = gbuf;
byte_FDF = 0;
gptr = v2;
v4 = gargc;
if ( !gbuf )
{
LABEL_13:
v10 = xargv;
v1 = xargc;
xargv = gargs;
xargc = v4 - 1;
if ( v4 > 0 )
goto LABEL_14;
goto LABEL_20;
}
v5 = &gbuf;
v6 = gargc;
v7 = 0;
v8 = 0;
while ( v6 <= 31 )
{
if ( !v8 )
{
if ( v3 > 32 )
{
v9 = v6;
v7 = 1;
++v6;
v8 = 1;
gargs[v9] = (__int64)v5;
}
goto LABEL_6;
}
if ( v3 > 32 )
{
LABEL_6:
v3 = *++v5;
if ( !v3 )
goto LABEL_11;
}
else
{
*v5 = 0;
v3 = *++v5;
v8 = 0;
if ( !v3 )
{
LABEL_11:
if ( v7 )
{
gargc = v6;
v4 = v6;
}
goto LABEL_13;
}
}
}
if ( !v7 )
goto LABEL_13;
gargc = v6;
v10 = xargv;
v1 = xargc;
xargv = gargs;
xargc = v6 - 1;
LABEL_14:
v11 = gargs;
do
{
v13 = (_BYTE *)*v11;
if ( *(_BYTE *)*v11 == 45 )
{
if ( (int)doarg(v13[1]) < 0 )
doexit(1LL);
}
else
{
fprintf(stderr, "?GKERMIT variable option error: \"%s\"\n", v13);
usage();
doexit(0LL);
}
v12 = xargc;
v11 = (__int64 *)(xargv + 8LL);
xargv += 8LL;
--xargc;
}
while ( v12 > 0 );
LABEL_20:
xargv = v10;
LABEL_21:
xargc = v1 - 1;
if ( v1 - 1 > 0 )
{
do
{
xargv += 8LL;
v14 = *xargv;
if ( *(_BYTE *)*xargv == 45 )
{
if ( (int)doarg(*(_BYTE *)(v14 + 1)) >= 0 )
goto LABEL_25;
}
else
{
fprintf(stderr, "?Command-line option error: \"%s\"\n", (const char *)v14);
usage();
}
doexit(1LL);
LABEL_25:
--xargc;
}
while ( xargc > 0 );
}
return (unsigned int)action;
}

canonical_decompiled_code:
__int64 func3()
{
char *v0; // rax
int v1; // ebx
__int64 v2; // rbx
char v3; // dl
int v4; // er8
char *v5; // rax
int v6; // ecx
char v7; // di
int v8; // esi
__int64 v9; // rdx
__int64 v10; // rbp
__int64 *v11; // rax
int v12; // edx
_BYTE *v13; // rdx
__int64 v14; // rdx

cmarg = &unk_1016;
cmlist = 0LL;
action = 0;
v0 = getenv("GKERMIT");
v1 = xargc;
if ( !v0 )
goto LABEL_21;
v2 = (__int64)v0;
strncpy(&gbuf, v0, 0xFFuLL);
v3 = gbuf;
byte_FDF = 0;
gptr = v2;
v4 = gargc;
if ( !gbuf )
{
LABEL_13:
v10 = xargv;
v1 = xargc;
xargv = gargs;
xargc = v4 - 1;
if ( v4 > 0 )
goto LABEL_14;
goto LABEL_20;
}
v5 = &gbuf;
v6 = gargc;
v7 = 0;
v8 = 0;
while ( v6 <= 31 )
{
if ( !v8 )
{
if ( v3 > 32 )
{
v9 = v6;
v7 = 1;
++v6;
v8 = 1;
gargs[v9] = (__int64)v5;
}
goto LABEL_6;
}
if ( v3 > 32 )
{
LABEL_6:
v3 = *++v5;
if ( !v3 )
goto LABEL_11;
}
else
{
*v5 = 0;
v3 = *++v5;
v8 = 0;
if ( !v3 )
{
LABEL_11:
if ( v7 )
{
gargc = v6;
v4 = v6;
}
goto LABEL_13;
}
}
}
if ( !v7 )
goto LABEL_13;
gargc = v6;
v10 = xargv;
v1 = xargc;
xargv = gargs;
xargc = v6 - 1;
LABEL_14:
v11 = gargs;
do
{
v13 = (_BYTE *)*v11;
if ( *(_BYTE *)*v11 == 45 )
{
if ( (int)func2(v13[1]) < 0 )
doexit(1LL);
}
else
{
fprintf(stderr, "?GKERMIT variable option error: \"%s\"\n", v13);
func1();
doexit(0LL);
}
v12 = xargc;
v11 = (__int64 *)(xargv + 8LL);
xargv += 8LL;
--xargc;
}
while ( v12 > 0 );
LABEL_20:
xargv = v10;
LABEL_21:
xargc = v1 - 1;
if ( v1 - 1 > 0 )
{
do
{
xargv += 8LL;
v14 = *xargv;
if ( *(_BYTE *)*xargv == 45 )
{
if ( (int)func2(*(_BYTE *)(v14 + 1)) >= 0 )
goto LABEL_25;
}
else
{
fprintf(stderr, "?Command-line option error: \"%s\"\n", (const char *)v14);
func1();
}
doexit(1LL);
LABEL_25:
--xargc;
}
while ( xargc > 0 );
}
return (unsigned int)action;
}

original_code:
int
cmdlin() {
    char c;
    int x;
    char * p = ((void *)0);
    cmarg = "";
    cmlist = ((void *)0);
    action = 0;
    if ((p = getenv("GKERMIT"))) {
 int i, xc, flag = 0;
 char **xv = ((void *)0);
 strncpy(gbuf,p,256 -1);
 gbuf[256 -1] = '\000';
 gptr = p;
 p = gbuf;
 for (i = 0; gbuf[i] && i < 256 && gargc < 32; i++) {
     if (!flag) {
  if (gbuf[i] <= '\040')
    continue;
  flag = 1;
  gargs[gargc++] = &gbuf[i];
     } else if (flag && gbuf[i] <= '\040') {
  gbuf[i] = '\000';
  flag = 0;
  continue;
     }
 }
 xv = xargv;
 xc = xargc;
 xargv = gargs;
 xargc = gargc;
 while (xargc-- > 0) {
     if (**xargv == '-') {
  c = *(*xargv+1);
  x = doarg(c);
  if (x < 0) doexit(1);
     } else {
  fprintf(stderr,
   "?GKERMIT variable option error: \"%s\"\n",
   *xargv
   );
  usage();
  doexit(0);
     }
     xargv++;
 }
 xargv = xv;
 xargc = xc;
    }
    while (--xargc > 0) {
 xargv++;
     if (**xargv == '-') {
     c = *(*xargv+1);
     x = doarg(c);
     if (x < 0) doexit(1);
     } else {
     fprintf(stderr,"?Command-line option error: \"%s\"\n", *xargv);
     usage();
     doexit(1);
 }
    }
    return(action);
}

canonical_original_code:
int cmdlin() {
    char c;
    int x;
    char *p = ((void *)0);
    cmarg = "";
    cmlist = ((void *)0);
    action = 0;
    if ((p = getenv("GKERMIT"))) {
 int i; int xc; int flag = 0;
 char **xv = ((void *)0);
 strncpy(gbuf,p,256 -1);
 gbuf[256 -1] = '\000';
 gptr = p;
 p = gbuf;
 for (i = 0; gbuf[i] && i < 256 && gargc < 32; i++) {
     if (!flag) {
  if (gbuf[i] <= '\040')
    continue;
  flag = 1;
  gargs[gargc++] = &gbuf[i];
     } else if (flag && gbuf[i] <= '\040') {
  gbuf[i] = '\000';
  flag = 0;
  continue;
     }
 }
 xv = xargv;
 xc = xargc;
 xargv = gargs;
 xargc = gargc;
 while (xargc-- > 0) {
     if (**xargv == '-') {
  c = *(*xargv+1);
  x = doarg(c);
  if (x < 0) doexit(1);
     } else {
  fprintf(stderr,
   "?GKERMIT variable option error: \"%s\"\n",
   *xargv
   );
  usage();
  doexit(0);
     }
     xargv++;
 }
 xargv = xv;
 xargc = xc;
    }
    while (--xargc > 0) {
 xargv++;
     if (**xargv == '-') {
     c = *(*xargv+1);
     x = doarg(c);
     if (x < 0) doexit(1);
     } else {
     fprintf(stderr,"?Command-line option error: \"%s\"\n", *xargv);
     usage();
     doexit(1);
 }
    }
    return(action);
}

variable_types: c char

variable_types: x int

variable_types:
p
char *

variable_types: xc int

variable_types: flag int

variable_types:
xv
char **


streamon

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

result = streamok;
if ( streamok > 0 )
{
streaming = 1;
timint = 0;
}
return result;
}

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

result = streamok;
if ( streamok > 0 )
{
streaming = 1;
timint = 0;
}
return result;
}

original_code:
static void
streamon() {
    x = 0;
    if (streamok > 0) {
 streaming = 1;
 timint = 0;
    }
}


gwart

decompiled_code:
__int64 gwart()
{
unsigned int v0; // edx
__int16 v1; // ax
__int64 v3; // rax
int v4; // eax
bool v5; // sf
void *v6; // rdi
int v7; // eax
int v8; // eax

while ( 1 )
{
do
{
LABEL_1:
v0 = input() - 32;
if ( v0 >= 0x60 )
v0 = 0;
v1 = tbl[v0 + 96 * state];
}
while ( v1 == -1 );
switch ( v1 )
{
case 1:
tinit();
if ( (int)sinit(83LL) < 0 )
errpkt("sinit");
else
state = 1;
goto LABEL_1;
case 2:
spar(rdatap);
bctu = bctr;
if ( (int)gnfile() <= 0 )
{
if ( (int)seot() >= 0 )
goto LABEL_55;
errpkt("seot");
}
else
{
if ( (int)sfile() < 0 )
goto LABEL_58;
streamon();
state = 2;
}
goto LABEL_1;
case 3:
if ( !attributes )
goto LABEL_37;
if ( (int)sattr() < 0 )
errpkt("sattr");
else
state = 4;
goto LABEL_1;
case 4:
if ( *rdatap == 78 )
{
seof(&unk_E24);
goto LABEL_35;
}
LABEL_37:
v7 = sdata();
if ( v7 )
{
if ( v7 < 0 )
goto LABEL_53;
state = 3;
goto LABEL_1;
}
if ( (int)seof(&unk_E26) >= 0 )
goto LABEL_35;
goto LABEL_60;
case 5:
if ( *rdatap == 88 )
{
dword_1070 = 1;
v8 = sdata();
v5 = v8 < 0;
if ( v8 )
goto LABEL_52;
}
else
{
if ( *rdatap == 90 )
cz = 1;
v4 = sdata();
v5 = v4 < 0;
if ( v4 )
{
LABEL_52:
if ( v5 )
LABEL_53:
errpkt("sdata");
goto LABEL_1;
}
}
v6 = &unk_E24;
if ( !(cz | dword_1070) )
v6 = &unk_E26;
if ( (int)seof(v6) < 0 )
LABEL_60:
errpkt("seof");
else
LABEL_35:
state = 6;
break;
case 6:
if ( (int)gnfile() <= 0 )
{
seot();
LABEL_55:
state = 5;
}
else if ( (int)sfile() <= 0 )
{
LABEL_58:
errpkt("sfile");
}
else
{
state = 2;
}
goto LABEL_1;
case 7:
return failure;
case 8:
tinit();
rinit();
state = 8;
goto LABEL_1;
case 9:
spar(rdatap);
v3 = rpar();
ack1(v3);
bctu = bctr;
streamon();
state = 9;
goto LABEL_1;
case 10:
ack();
return failure;
case 11:
if ( (int)rcvfil() < 0 )
{
errpkt("rcvfil");
}
else
{
encstr(&filnam);
ack1(xdata);
streamon();
state = 11;
}
goto LABEL_1;
case 12:
if ( !(unsigned int)gattr(rdatap) )
goto LABEL_16;
ack1("\"");
goto LABEL_1;
case 13:
if ( (int)decode(datalen) < 0 )
goto LABEL_51;
ack();
state = 10;
goto LABEL_1;
case 14:
case 16:
if ( *rdatap == 68 )
{
dword_1070 = 1;
if ( (int)closof() >= 0 )
{
LABEL_7:
ack();
state = 9;
goto LABEL_1;
}
}
else if ( (int)closof() >= 0 )
{
goto LABEL_7;
}
errpkt("closof");
goto LABEL_1;
case 15:
if ( (int)decode(datalen) < 0 )
LABEL_51:
errpkt("Packet decoding error");
else
LABEL_16:
ack();
goto LABEL_1;
case 17:
tinit();
ginit();
sinit(73LL);
state = 7;
goto LABEL_1;
case 18:
spar(rdatap);
if ( (int)scmd(82LL, cmarg) < 0 )
errpkt("scmd");
else
state = 8;
goto LABEL_1;
case 19:
failure = 1;
return 1LL;
case 20:
errpkt("Unknown packet type");
goto LABEL_1;
default:
goto LABEL_1;
}
}
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // edx
__int16 v1; // ax
__int64 v3; // rax
int v4; // eax
bool v5; // sf
void *v6; // rdi
int v7; // eax
int v8; // eax

while ( 1 )
{
do
{
LABEL_1:
v0 = input() - 32;
if ( v0 >= 0x60 )
v0 = 0;
v1 = tbl[v0 + 96 * state];
}
while ( v1 == -1 );
switch ( v1 )
{
case 1:
tinit();
if ( (int)sinit(83LL) < 0 )
errpkt("sinit");
else
state = 1;
goto LABEL_1;
case 2:
spar(rdatap);
bctu = bctr;
if ( (int)gnfile() <= 0 )
{
if ( (int)seot() >= 0 )
goto LABEL_55;
errpkt("seot");
}
else
{
if ( (int)sfile() < 0 )
goto LABEL_58;
func0();
state = 2;
}
goto LABEL_1;
case 3:
if ( !attributes )
goto LABEL_37;
if ( (int)sattr() < 0 )
errpkt("sattr");
else
state = 4;
goto LABEL_1;
case 4:
if ( *rdatap == 78 )
{
seof(&unk_E24);
goto LABEL_35;
}
LABEL_37:
v7 = sdata();
if ( v7 )
{
if ( v7 < 0 )
goto LABEL_53;
state = 3;
goto LABEL_1;
}
if ( (int)seof(&unk_E26) >= 0 )
goto LABEL_35;
goto LABEL_60;
case 5:
if ( *rdatap == 88 )
{
dword_1070 = 1;
v8 = sdata();
v5 = v8 < 0;
if ( v8 )
goto LABEL_52;
}
else
{
if ( *rdatap == 90 )
cz = 1;
v4 = sdata();
v5 = v4 < 0;
if ( v4 )
{
LABEL_52:
if ( v5 )
LABEL_53:
errpkt("sdata");
goto LABEL_1;
}
}
v6 = &unk_E24;
if ( !(cz | dword_1070) )
v6 = &unk_E26;
if ( (int)seof(v6) < 0 )
LABEL_60:
errpkt("seof");
else
LABEL_35:
state = 6;
break;
case 6:
if ( (int)gnfile() <= 0 )
{
seot();
LABEL_55:
state = 5;
}
else if ( (int)sfile() <= 0 )
{
LABEL_58:
errpkt("sfile");
}
else
{
state = 2;
}
goto LABEL_1;
case 7:
return failure;
case 8:
tinit();
rinit();
state = 8;
goto LABEL_1;
case 9:
spar(rdatap);
v3 = rpar();
ack1(v3);
bctu = bctr;
func0();
state = 9;
goto LABEL_1;
case 10:
ack();
return failure;
case 11:
if ( (int)rcvfil() < 0 )
{
errpkt("rcvfil");
}
else
{
encstr(&filnam);
ack1(xdata);
func0();
state = 11;
}
goto LABEL_1;
case 12:
if ( !(unsigned int)gattr(rdatap) )
goto LABEL_16;
ack1("\"");
goto LABEL_1;
case 13:
if ( (int)decode(datalen) < 0 )
goto LABEL_51;
ack();
state = 10;
goto LABEL_1;
case 14:
case 16:
if ( *rdatap == 68 )
{
dword_1070 = 1;
if ( (int)closof() >= 0 )
{
LABEL_7:
ack();
state = 9;
goto LABEL_1;
}
}
else if ( (int)closof() >= 0 )
{
goto LABEL_7;
}
errpkt("closof");
goto LABEL_1;
case 15:
if ( (int)decode(datalen) < 0 )
LABEL_51:
errpkt("Packet decoding error");
else
LABEL_16:
ack();
goto LABEL_1;
case 17:
tinit();
ginit();
sinit(73LL);
state = 7;
goto LABEL_1;
case 18:
spar(rdatap);
if ( (int)scmd(82LL, cmarg) < 0 )
errpkt("scmd");
else
state = 8;
goto LABEL_1;
case 19:
failure = 1;
return 1LL;
case 20:
errpkt("Unknown packet type");
goto LABEL_1;
default:
goto LABEL_1;
}
}
}

original_code:
int
gwart()
{
    int c,actno;
    extern short tbl[];
    while (1) {
 c = input() - 32;
 if (c < 0 || c > 95) c = 0;
 if ((actno = tbl[c + state*96]) != -1)
     switch(actno) {
case 1:
    {
    tinit();
    if (sinit('S') < 0) { errpkt("sinit"); }
    else state = 1;
}
    break;
case 2:
    {
    spar(rdatap);
    bctu = bctr;
    if (gnfile() > 0) {
        if (sfile() < 0) {
     errpkt("sfile");
 } else {
     streamon();
     state = 2;
 }
    } else {
        if (seot() < 0) { errpkt("seot"); }
        else state = 5;
    }
}
    break;
case 3:
    {
    if (attributes) {
 if (sattr() < 0) {
     errpkt("sattr");
 } else
   state = 4;
    } else if ((x = sdata()) == 0) {
 if (seof("") < 0) {
     errpkt("seof");
 } else {
     state = 6;
 }
    } else if (x < 0) {
 errpkt("sdata");
    } else {
 state = 3;
    }
}
    break;
case 4:
    {
    if (*rdatap == 'N') {
 seof("D");
 state = 6;
    } else if ((x = sdata()) == 0) {
 if (seof("") < 0) {
     errpkt("seof");
 } else {
     state = 6;
 }
    } else if (x < 0) {
 errpkt("sdata");
    } else {
 state = 3;
    }
}
    break;
case 5:
    {
    if (*rdatap == 'X')
      cx = 1;
    else if (*rdatap == 'Z')
      cz = 1;
    if ((x = sdata()) == 0) {
 if (seof((cx | cz) ? "D" : "") < 0) {
     errpkt("seof");
 } else {
     state = 6;
 }
    } else if (x < 0)
      errpkt("sdata");
}
    break;
case 6:
    {
    if (gnfile() > 0) {
 if (sfile() > 0)
   state = 2;
 else { errpkt("sfile"); }
    } else {
 seot();
 state = 5;
    }
}
    break;
case 7:
    { return(failure); }
    break;
case 8:
    { tinit(); rinit(); state = 8; }
    break;
case 9:
    {
    spar(rdatap);
    ack1(rpar());
    bctu = bctr;
    streamon();
    state = 9;
}
    break;
case 10:
    { ack(); return(failure); }
    break;
case 11:
    {
    if (rcvfil() < 0) {
 errpkt("rcvfil");
    } else {
 encstr(filnam);
 ack1(xdata);
 streamon();
 state = 11;
    }
}
    break;
case 12:
    {
    if (gattr(rdatap) == 0) {
 ack();
    } else {
 ack1("\"");
    }
}
    break;
case 13:
    {
    if (decode(datalen) < 0) {
 errpkt("Packet decoding error");
    } else {
 ack();
 state = 10;
    }
}
    break;
case 14:
    {
    if (*rdatap == 'D')
      cx = 1;
    if (closof() < 0) {
 errpkt("closof");
    } else {
 ack();
 state = 9;
    }
}
    break;
case 15:
    {
    if (decode(datalen) < 0)
      errpkt("Packet decoding error");
    else
      ack();
}
    break;
case 16:
    {
    if (*rdatap == 'D')
      cx = 1;
    if (closof() < 0) {
 errpkt("closof");
    } else {
 ack();
 state = 9;
    }
}
    break;
case 17:
    {
    tinit();
    ginit();
    sinit('I');
    state = 7;
}
    break;
case 18:
    {
    spar(rdatap);
    if (scmd('R',cmarg) < 0)
      errpkt("scmd");
    else
      state = 8;
}
    break;
case 19:
    { return(failure = 1); }
    break;
case 20:
    { errpkt("Unknown packet type"); }
    break;
     }
    }
}

canonical_original_code:
int gwart()
{
    int c; int actno;
    extern short tbl[];
    while (1) {
 c = input() - 32;
 if (c < 0 || c > 95) c = 0;
 if ((actno = tbl[c + state*96]) != -1)
     switch(actno) {
case 1:
    {
    tinit();
    if (sinit('S') < 0) { errpkt("sinit"); }
    else state = 1;
}
    break;
case 2:
    {
    spar(rdatap);
    bctu = bctr;
    if (gnfile() > 0) {
        if (sfile() < 0) {
     errpkt("sfile");
 } else {
     streamon();
     state = 2;
 }
    } else {
        if (seot() < 0) { errpkt("seot"); }
        else state = 5;
    }
}
    break;
case 3:
    {
    if (attributes) {
 if (sattr() < 0) {
     errpkt("sattr");
 } else
   state = 4;
    } else if ((x = sdata()) == 0) {
 if (seof("") < 0) {
     errpkt("seof");
 } else {
     state = 6;
 }
    } else if (x < 0) {
 errpkt("sdata");
    } else {
 state = 3;
    }
}
    break;
case 4:
    {
    if (*rdatap == 'N') {
 seof("D");
 state = 6;
    } else if ((x = sdata()) == 0) {
 if (seof("") < 0) {
     errpkt("seof");
 } else {
     state = 6;
 }
    } else if (x < 0) {
 errpkt("sdata");
    } else {
 state = 3;
    }
}
    break;
case 5:
    {
    if (*rdatap == 'X')
      cx = 1;
    else if (*rdatap == 'Z')
      cz = 1;
    if ((x = sdata()) == 0) {
 if (seof((cx | cz) ? "D" : "") < 0) {
     errpkt("seof");
 } else {
     state = 6;
 }
    } else if (x < 0)
      errpkt("sdata");
}
    break;
case 6:
    {
    if (gnfile() > 0) {
 if (sfile() > 0)
   state = 2;
 else { errpkt("sfile"); }
    } else {
 seot();
 state = 5;
    }
}
    break;
case 7:
    { return(failure); }
    break;
case 8:
    { tinit(); rinit(); state = 8; }
    break;
case 9:
    {
    spar(rdatap);
    ack1(rpar());
    bctu = bctr;
    streamon();
    state = 9;
}
    break;
case 10:
    { ack(); return(failure); }
    break;
case 11:
    {
    if (rcvfil() < 0) {
 errpkt("rcvfil");
    } else {
 encstr(filnam);
 ack1(xdata);
 streamon();
 state = 11;
    }
}
    break;
case 12:
    {
    if (gattr(rdatap) == 0) {
 ack();
    } else {
 ack1("\"");
    }
}
    break;
case 13:
    {
    if (decode(datalen) < 0) {
 errpkt("Packet decoding error");
    } else {
 ack();
 state = 10;
    }
}
    break;
case 14:
    {
    if (*rdatap == 'D')
      cx = 1;
    if (closof() < 0) {
 errpkt("closof");
    } else {
 ack();
 state = 9;
    }
}
    break;
case 15:
    {
    if (decode(datalen) < 0)
      errpkt("Packet decoding error");
    else
      ack();
}
    break;
case 16:
    {
    if (*rdatap == 'D')
      cx = 1;
    if (closof() < 0) {
 errpkt("closof");
    } else {
 ack();
 state = 9;
    }
}
    break;
case 17:
    {
    tinit();
    ginit();
    sinit('I');
    state = 7;
}
    break;
case 18:
    {
    spar(rdatap);
    if (scmd('R',cmarg) < 0)
      errpkt("scmd");
    else
      state = 8;
}
    break;
case 19:
    { return(failure = 1); }
    break;
case 20:
    { errpkt("Unknown packet type"); }
    break;
     }
    }
}

variable_types: c int

variable_types: actno int

variable_types:
tbl
short []


getmyname

decompiled_code:
__int128 *getmyname()
{
__int128 *result; // rax

if ( initialized_1 )
return &hostname_0;
initialized_1 = 1;
word_430 = 69;
result = &hostname_0;
hostname_0 = (__int128)_mm_load_si128((const __m128i *)&LC3);
return result;
}

canonical_decompiled_code:
__int128 *func4()
{
__int128 *result; // rax

if ( initialized_1 )
return &hostname_0;
initialized_1 = 1;
word_430 = 69;
result = &hostname_0;
hostname_0 = (__int128)_mm_load_si128((const __m128i *)&LC3);
return result;
}

original_code:
char *getmyname() {
    static int initialized = 0;
    static char hostname[60];
    if (!initialized) {
    strcpy(hostname, "UNKNOWN.SITE.NAME");
        initialized = 1;
    }
    return(hostname);
}

variable_types: initialized int

variable_types:
hostname
char [60]


decompiled_code:
void __fastcall user_kernel_data_segment(int a1)
{
in_kernel = a1;
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
in_kernel = a1;
}

original_code:
void
user_kernel_data_segment (int to_kernel)
{
    in_kernel = to_kernel;
}

canonical_original_code:
void user_kernel_data_segment(int to_kernel)
{
    in_kernel = to_kernel;
}


decompiled_code:
void end_of_assembly_file()
{
in_kernel = 0;
auto_alignment = 1;
}

canonical_decompiled_code:
void func1()
{
in_kernel = 0;
auto_alignment = 1;
}

original_code:
void
end_of_assembly_file (void)
{
  in_kernel = 0;
  auto_alignment = 1;
}


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

result = bare_machine;
if ( !bare_machine )
{
result = (unsigned int)(a1 + 0x8000);
next_gp_item_addr = a1;
a1 += 0x10000;
gp_midpoint = result;
R[28] = result;
}
next_data_pc = a1;
return result;
}

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

result = bare_machine;
if ( !bare_machine )
{
result = (unsigned int)(a1 + 0x8000);
next_gp_item_addr = a1;
a1 += 0x10000;
gp_midpoint = result;
R[28] = result;
}
next_data_pc = a1;
return result;
}

original_code:
void
data_begins_at_point (mem_addr addr)
{
  if (bare_machine)
    next_data_pc = addr;
  else
    {
      next_gp_item_addr = addr;
      gp_midpoint = addr + 32*1024;
      R[28] = gp_midpoint;
      next_data_pc = addr + 64 * 1024;
    }
}

canonical_original_code:
void data_begins_at_point(unsigned int addr)
{
  if (bare_machine)
    next_data_pc = addr;
  else
    {
      next_gp_item_addr = addr;
      gp_midpoint = addr + 32*1024;
      R[28] = gp_midpoint;
      next_data_pc = addr + 64 * 1024;
    }
}

variable_types:
addr
unsigned int


decompiled_code:
void __fastcall k_data_begins_at_point(int a1)
{
next_k_data_pc = a1;
}

canonical_decompiled_code:
void __fastcall func3(int a1)
{
next_k_data_pc = a1;
}

original_code:
void
k_data_begins_at_point (mem_addr addr)
{
    next_k_data_pc = addr;
}

canonical_original_code:
void k_data_begins_at_point(unsigned int addr)
{
    next_k_data_pc = addr;
}


decompiled_code:
void __fastcall align_data(int a1)
{
int v1; // eax
int v2; // edi

if ( a1 )
{
v1 = 1 << a1;
v2 = -1 << a1;
if ( in_kernel )
next_k_data_pc = (v1 + next_k_data_pc - 1) & v2;
else
next_data_pc = (v1 + next_data_pc - 1) & v2;
fix_current_label_address();
}
else
{
auto_alignment = 0;
}
}

canonical_decompiled_code:
void __fastcall func4(int a1)
{
int v1; // eax
int v2; // edi

if ( a1 )
{
v1 = 1 << a1;
v2 = -1 << a1;
if ( in_kernel )
next_k_data_pc = (v1 + next_k_data_pc - 1) & v2;
else
next_data_pc = (v1 + next_data_pc - 1) & v2;
fix_current_label_address();
}
else
{
auto_alignment = 0;
}
}

original_code:
void
align_data (int alignment)
{
  if (alignment == 0)
    auto_alignment = 0;
  else if (in_kernel)
    {
      next_k_data_pc =
 (next_k_data_pc + (1 << alignment) - 1) & (-1 << alignment);
      fix_current_label_address (next_k_data_pc);
    }
  else
    {
      next_data_pc = (next_data_pc + (1 << alignment) - 1) & (-1 << alignment);
      fix_current_label_address (next_data_pc);
    }
}

canonical_original_code:
void align_data(int alignment)
{
  if (alignment == 0)
    auto_alignment = 0;
  else if (in_kernel)
    {
      next_k_data_pc =
 (next_k_data_pc + (1 << alignment) - 1) & (-1 << alignment);
      fix_current_label_address (next_k_data_pc);
    }
  else
    {
      next_data_pc = (next_data_pc + (1 << alignment) - 1) & (-1 << alignment);
      fix_current_label_address (next_data_pc);
    }
}

variable_types: alignment int