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

result = 20LL;
if ( a1 <= 7 )
result = (unsigned int)CSWTCH_52[a1];
return result;
}

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

result = 20LL;
if ( a1 <= 7 )
result = (unsigned int)CSWTCH_52[a1];
return result;
}

original_code:
int game_slowdown (int speed) {
  int slowdown = 20;
  switch (speed) {
    case sp_pause: slowdown = 1; break;
    case sp_slowest: slowdown = 160; break;
    case sp_slower: slowdown = 80; break;
    case sp_slow: slowdown = 40; break;
    case sp_normal: slowdown = 20; break;
    case sp_fast: slowdown = 10; break;
    case sp_faster: slowdown = 5; break;
    case sp_fastest: slowdown = 2; break;
  }
  return slowdown;
}

canonical_original_code:
int game_slowdown(int speed) {
  int slowdown = 20;
  switch (speed) {
    case sp_pause: slowdown = 1; break;
    case sp_slowest: slowdown = 160; break;
    case sp_slower: slowdown = 80; break;
    case sp_slow: slowdown = 40; break;
    case sp_normal: slowdown = 20; break;
    case sp_fast: slowdown = 10; break;
    case sp_faster: slowdown = 5; break;
    case sp_fastest: slowdown = 2; break;
  }
  return slowdown;
}

variable_types: speed int

variable_types: slowdown int


repo: a-nikolaev/curseofwar

decompiled_code:
__int64 __fastcall get_options(int argc, char **argv, __int64 a3, __int64 a4)
{
int v4; // er14
int v7; // eax
char *v8; // rax
int v9; // eax
__int64 result; // rax
unsigned int v11; // eax
char *v12; // rdx
int v13; // eax
int v14; // edx
__int64 v15; // r8
int v16; // eax
int v17; // eax
int v18; // edx
char *v19; // rax
__int64 v20; // r8
int v21; // eax
int v22; // eax
int v23; // edx
bool v24; // zf
bool v25; // sf
bool v26; // of
bool v27; // cl
int v28; // edx
int v29; // edx
int v30; // ecx
int v31; // edx
int v32; // edx
const char *s1; // [rsp+8h] [rbp-50h]
char *endptr[8]; // [rsp+18h] [rbp-40h] BYREF

v4 = 0;
*(_QWORD *)a3 = 0x200000000LL;
*(_QWORD *)(a3 + 8) = 0x1500000004LL;
*(_QWORD *)(a3 + 16) = 21LL;
v7 = rand();
*(_QWORD *)(a3 + 28) = 0LL;
*(_DWORD *)(a3 + 24) = v7;
*(_QWORD *)(a3 + 36) = 0x1FFFFFFFFLL;
*(_DWORD *)(a4 + 32) = 1;
*(_QWORD *)a4 = 0x100000000LL;
*(_QWORD *)(a4 + 8) = strdup("19150");
*(_QWORD *)(a4 + 16) = strdup("127.0.0.1");
v8 = strdup("19140");
opterr = 0;
*(_QWORD *)(a4 + 24) = v8;
while ( 1 )
{
v9 = getopt(argc, argv, "hvrTW:H:i:l:q:d:s:R:S:E:e:C:c:");
if ( v9 == -1 )
break;
switch ( v9 )
{
case '?':
case 'h':
goto LABEL_8;
case 'C':
*(_QWORD *)a4 = 1LL;
free(*(void **)(a4 + 16));
*(_QWORD *)(a4 + 16) = strdup(optarg);
continue;
case 'E':
endptr[0] = 0LL;
*(_DWORD *)(a4 + 32) = strtol(optarg, endptr, 10);
if ( *endptr[0] )
goto LABEL_8;
*(_QWORD *)a4 = 0x100000001LL;
continue;
case 'H':
endptr[0] = 0LL;
v20 = strtol(optarg, endptr, 10);
v21 = 14;
if ( v20 > 14 )
v21 = strtol(optarg, endptr, 10);
*(_DWORD *)(a3 + 16) = v21;
if ( *endptr[0] )
goto LABEL_8;
continue;
case 'R':
endptr[0] = 0LL;
v17 = strtol(optarg, endptr, 10);
v18 = v17 >> 31;
*(_DWORD *)(a3 + 24) = v18 ^ v17;
v19 = endptr[0];
*(_DWORD *)(a3 + 24) -= v18;
if ( *v19 || !*optarg )
goto LABEL_8;
continue;
case 'S':
if ( !strcmp(optarg, "rhombus") )
{
*(_DWORD *)(a3 + 40) = 0;
}
else if ( !strcmp(optarg, "rect") )
{
*(_DWORD *)(a3 + 40) = 1;
}
else
{
if ( strcmp(optarg, "hex") )
goto LABEL_8;
*(_DWORD *)(a3 + 40) = 2;
}
continue;
case 'T':
*(_DWORD *)(a3 + 32) = 1;
continue;
case 'W':
endptr[0] = 0LL;
v15 = strtol(optarg, endptr, 10);
v16 = 14;
if ( v15 > 14 )
v16 = strtol(optarg, endptr, 10);
*(_DWORD *)(a3 + 12) = v16;
if ( *endptr[0] )
goto LABEL_8;
continue;
case 'c':
free(*(void **)(a4 + 8));
*(_QWORD *)(a4 + 8) = strdup(optarg);
continue;
case 'd':
v14 = (unsigned __int8)*optarg;
if ( v14 != 110 || optarg[1] )
{
if ( v14 == 101 && !optarg[1] )
{
LABEL_23:
*(_DWORD *)(a3 + 4) = 1;
continue;
}
v30 = (unsigned __int8)*optarg;
if ( v30 != 101 )
goto LABEL_121;
if ( optarg[1] == 49 && !optarg[2] )
goto LABEL_23;
if ( optarg[1] == 101 && !optarg[2] || optarg[1] == 50 && !optarg[2] )
{
*(_DWORD *)(a3 + 4) = 0;
}
else
{
LABEL_121:
if ( v14 == 104 && !optarg[1] )
goto LABEL_64;
if ( v30 != 104 )
goto LABEL_8;
if ( optarg[1] == 49 && !optarg[2] )
{
LABEL_64:
*(_DWORD *)(a3 + 4) = 3;
}
else
{
if ( (optarg[1] != 104 || optarg[2]) && (optarg[1] != 50 || optarg[2]) )
goto LABEL_8;
*(_DWORD *)(a3 + 4) = 4;
}
}
}
else
{
*(_DWORD *)(a3 + 4) = 2;
}
break;
case 'e':
free(*(void **)(a4 + 24));
*(_QWORD *)(a4 + 24) = strdup(optarg);
continue;
case 'i':
endptr[0] = 0LL;
v11 = strtol(optarg, endptr, 10);
v12 = endptr[0];
*(_DWORD *)(a3 + 36) = v11;
if ( *v12 || v11 > 4 )
goto LABEL_8;
continue;
case 'l':
endptr[0] = 0LL;
*(_DWORD *)(a3 + 20) = strtol(optarg, endptr, 10);
if ( *endptr[0] )
goto LABEL_8;
continue;
case 'q':
endptr[0] = 0LL;
*(_DWORD *)(a3 + 28) = strtol(optarg, endptr, 10);
if ( *endptr[0] )
goto LABEL_8;
v4 = 1;
continue;
case 'r':
*(_DWORD *)a3 = 1;
continue;
case 's':
v13 = (unsigned __int8)*optarg;
if ( v13 != 110 || optarg[1] )
{
if ( v13 == 115 && !optarg[1] )
{
LABEL_13:
*(_DWORD *)(a3 + 8) = 3;
continue;
}
v31 = (unsigned __int8)*optarg;
if ( v31 != 115 )
goto LABEL_122;
if ( optarg[1] == 49 && !optarg[2] )
goto LABEL_13;
if ( optarg[1] == 115 && !optarg[2] || optarg[1] == 50 && !optarg[2] )
{
*(_DWORD *)(a3 + 8) = 2;
}
else
{
LABEL_122:
if ( !strcmp(optarg, "sss") || v31 == 115 && optarg[1] == 51 && !optarg[2] )
{
*(_DWORD *)(a3 + 8) = 1;
}
else if ( v13 == 102 && !optarg[1] || v31 == 102 && optarg[1] == 49 && !optarg[2] )
{
*(_DWORD *)(a3 + 8) = 5;
}
else
{
s1 = optarg;
if ( !strcmp(optarg, "ff") || !strcmp(s1, "f2") )
{
*(_DWORD *)(a3 + 8) = 6;
}
else if ( !strcmp(s1, "fff") || !strcmp(s1, "f3") )
{
*(_DWORD *)(a3 + 8) = 7;
}
else
{
if ( strcmp(s1, "p") )
goto LABEL_8;
*(_DWORD *)(a3 + 8) = 0;
}
}
}
}
else
{
*(_DWORD *)(a3 + 8) = 4;
}
continue;
case 'v':
puts("1.2.0");
return 1LL;
default:
return 1LL;
}
}
v22 = stencil_avlbl_loc_num(*(unsigned int *)(a3 + 40));
v23 = *(_DWORD *)(a3 + 20);
if ( v23 )
{
v26 = __OFSUB__(v23, v22);
v24 = v23 == v22;
v25 = v23 - v22 < 0;
v22 = *(_DWORD *)(a3 + 20);
v27 = !(v25 ^ v26 | v24);
}
else
{
*(_DWORD *)(a3 + 20) = v22;
v27 = 0;
}
if ( v22 <= 1
|| v27
|| v4 && ((v32 = *(_DWORD *)(a3 + 28), v32 <= 0) || v32 > v22)
|| (v28 = *(_DWORD *)(a4 + 32), v28 <= 0)
|| v28 > v22 )
{
LABEL_8:
print_help();
result = 1LL;
}
else
{
result = 0LL;
if ( *(_DWORD *)(a3 + 40) == 1 )
{
*(_DWORD *)(a3 + 12) += (*(_DWORD *)(a3 + 16) + 1) / 2;
v29 = 39;
if ( *(int *)(a3 + 12) <= 39 )
v29 = *(_DWORD *)(a3 + 12);
*(_DWORD *)(a3 + 12) = v29;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int argc, char **argv, __int64 a3, __int64 a4)
{
int v4; // er14
int v7; // eax
char *v8; // rax
int v9; // eax
__int64 result; // rax
unsigned int v11; // eax
char *v12; // rdx
int v13; // eax
int v14; // edx
__int64 v15; // r8
int v16; // eax
int v17; // eax
int v18; // edx
char *v19; // rax
__int64 v20; // r8
int v21; // eax
int v22; // eax
int v23; // edx
bool v24; // zf
bool v25; // sf
bool v26; // of
bool v27; // cl
int v28; // edx
int v29; // edx
int v30; // ecx
int v31; // edx
int v32; // edx
const char *s1; // [rsp+8h] [rbp-50h]
char *endptr[8]; // [rsp+18h] [rbp-40h] BYREF

v4 = 0;
*(_QWORD *)a3 = 0x200000000LL;
*(_QWORD *)(a3 + 8) = 0x1500000004LL;
*(_QWORD *)(a3 + 16) = 21LL;
v7 = rand();
*(_QWORD *)(a3 + 28) = 0LL;
*(_DWORD *)(a3 + 24) = v7;
*(_QWORD *)(a3 + 36) = 0x1FFFFFFFFLL;
*(_DWORD *)(a4 + 32) = 1;
*(_QWORD *)a4 = 0x100000000LL;
*(_QWORD *)(a4 + 8) = strdup("19150");
*(_QWORD *)(a4 + 16) = strdup("127.0.0.1");
v8 = strdup("19140");
opterr = 0;
*(_QWORD *)(a4 + 24) = v8;
while ( 1 )
{
v9 = getopt(argc, argv, "hvrTW:H:i:l:q:d:s:R:S:E:e:C:c:");
if ( v9 == -1 )
break;
switch ( v9 )
{
case '?':
case 'h':
goto LABEL_8;
case 'C':
*(_QWORD *)a4 = 1LL;
free(*(void **)(a4 + 16));
*(_QWORD *)(a4 + 16) = strdup(optarg);
continue;
case 'E':
endptr[0] = 0LL;
*(_DWORD *)(a4 + 32) = strtol(optarg, endptr, 10);
if ( *endptr[0] )
goto LABEL_8;
*(_QWORD *)a4 = 0x100000001LL;
continue;
case 'H':
endptr[0] = 0LL;
v20 = strtol(optarg, endptr, 10);
v21 = 14;
if ( v20 > 14 )
v21 = strtol(optarg, endptr, 10);
*(_DWORD *)(a3 + 16) = v21;
if ( *endptr[0] )
goto LABEL_8;
continue;
case 'R':
endptr[0] = 0LL;
v17 = strtol(optarg, endptr, 10);
v18 = v17 >> 31;
*(_DWORD *)(a3 + 24) = v18 ^ v17;
v19 = endptr[0];
*(_DWORD *)(a3 + 24) -= v18;
if ( *v19 || !*optarg )
goto LABEL_8;
continue;
case 'S':
if ( !strcmp(optarg, "rhombus") )
{
*(_DWORD *)(a3 + 40) = 0;
}
else if ( !strcmp(optarg, "rect") )
{
*(_DWORD *)(a3 + 40) = 1;
}
else
{
if ( strcmp(optarg, "hex") )
goto LABEL_8;
*(_DWORD *)(a3 + 40) = 2;
}
continue;
case 'T':
*(_DWORD *)(a3 + 32) = 1;
continue;
case 'W':
endptr[0] = 0LL;
v15 = strtol(optarg, endptr, 10);
v16 = 14;
if ( v15 > 14 )
v16 = strtol(optarg, endptr, 10);
*(_DWORD *)(a3 + 12) = v16;
if ( *endptr[0] )
goto LABEL_8;
continue;
case 'c':
free(*(void **)(a4 + 8));
*(_QWORD *)(a4 + 8) = strdup(optarg);
continue;
case 'd':
v14 = (unsigned __int8)*optarg;
if ( v14 != 110 || optarg[1] )
{
if ( v14 == 101 && !optarg[1] )
{
LABEL_23:
*(_DWORD *)(a3 + 4) = 1;
continue;
}
v30 = (unsigned __int8)*optarg;
if ( v30 != 101 )
goto LABEL_121;
if ( optarg[1] == 49 && !optarg[2] )
goto LABEL_23;
if ( optarg[1] == 101 && !optarg[2] || optarg[1] == 50 && !optarg[2] )
{
*(_DWORD *)(a3 + 4) = 0;
}
else
{
LABEL_121:
if ( v14 == 104 && !optarg[1] )
goto LABEL_64;
if ( v30 != 104 )
goto LABEL_8;
if ( optarg[1] == 49 && !optarg[2] )
{
LABEL_64:
*(_DWORD *)(a3 + 4) = 3;
}
else
{
if ( (optarg[1] != 104 || optarg[2]) && (optarg[1] != 50 || optarg[2]) )
goto LABEL_8;
*(_DWORD *)(a3 + 4) = 4;
}
}
}
else
{
*(_DWORD *)(a3 + 4) = 2;
}
break;
case 'e':
free(*(void **)(a4 + 24));
*(_QWORD *)(a4 + 24) = strdup(optarg);
continue;
case 'i':
endptr[0] = 0LL;
v11 = strtol(optarg, endptr, 10);
v12 = endptr[0];
*(_DWORD *)(a3 + 36) = v11;
if ( *v12 || v11 > 4 )
goto LABEL_8;
continue;
case 'l':
endptr[0] = 0LL;
*(_DWORD *)(a3 + 20) = strtol(optarg, endptr, 10);
if ( *endptr[0] )
goto LABEL_8;
continue;
case 'q':
endptr[0] = 0LL;
*(_DWORD *)(a3 + 28) = strtol(optarg, endptr, 10);
if ( *endptr[0] )
goto LABEL_8;
v4 = 1;
continue;
case 'r':
*(_DWORD *)a3 = 1;
continue;
case 's':
v13 = (unsigned __int8)*optarg;
if ( v13 != 110 || optarg[1] )
{
if ( v13 == 115 && !optarg[1] )
{
LABEL_13:
*(_DWORD *)(a3 + 8) = 3;
continue;
}
v31 = (unsigned __int8)*optarg;
if ( v31 != 115 )
goto LABEL_122;
if ( optarg[1] == 49 && !optarg[2] )
goto LABEL_13;
if ( optarg[1] == 115 && !optarg[2] || optarg[1] == 50 && !optarg[2] )
{
*(_DWORD *)(a3 + 8) = 2;
}
else
{
LABEL_122:
if ( !strcmp(optarg, "sss") || v31 == 115 && optarg[1] == 51 && !optarg[2] )
{
*(_DWORD *)(a3 + 8) = 1;
}
else if ( v13 == 102 && !optarg[1] || v31 == 102 && optarg[1] == 49 && !optarg[2] )
{
*(_DWORD *)(a3 + 8) = 5;
}
else
{
s1 = optarg;
if ( !strcmp(optarg, "ff") || !strcmp(s1, "f2") )
{
*(_DWORD *)(a3 + 8) = 6;
}
else if ( !strcmp(s1, "fff") || !strcmp(s1, "f3") )
{
*(_DWORD *)(a3 + 8) = 7;
}
else
{
if ( strcmp(s1, "p") )
goto LABEL_8;
*(_DWORD *)(a3 + 8) = 0;
}
}
}
}
else
{
*(_DWORD *)(a3 + 8) = 4;
}
continue;
case 'v':
puts("1.2.0");
return 1LL;
default:
return 1LL;
}
}
v22 = stencil_avlbl_loc_num(*(unsigned int *)(a3 + 40));
v23 = *(_DWORD *)(a3 + 20);
if ( v23 )
{
v26 = __OFSUB__(v23, v22);
v24 = v23 == v22;
v25 = v23 - v22 < 0;
v22 = *(_DWORD *)(a3 + 20);
v27 = !(v25 ^ v26 | v24);
}
else
{
*(_DWORD *)(a3 + 20) = v22;
v27 = 0;
}
if ( v22 <= 1
|| v27
|| v4 && ((v32 = *(_DWORD *)(a3 + 28), v32 <= 0) || v32 > v22)
|| (v28 = *(_DWORD *)(a4 + 32), v28 <= 0)
|| v28 > v22 )
{
LABEL_8:
func0();
result = 1LL;
}
else
{
result = 0LL;
if ( *(_DWORD *)(a3 + 40) == 1 )
{
*(_DWORD *)(a3 + 12) += (*(_DWORD *)(a3 + 16) + 1) / 2;
v29 = 39;
if ( *(int *)(a3 + 12) <= 39 )
v29 = *(_DWORD *)(a3 + 12);
*(_DWORD *)(a3 + 12) = v29;
}
}
return result;
}

original_code:
int get_options(int argc, char *argv[], struct basic_options *op, struct multi_options *mop) {
  op->keep_random_flag = 0;
  op->dif = dif_normal;
  op->speed = sp_normal;
  op->w = 21;
  op->h = 21;
  op->loc_num = 0;
  op->map_seed = rand();
  op->conditions = 0;
  op->timeline_flag = 0;
  op->inequality = -1;
  op->shape = st_rect;
  mop->clients_num = 1;
  mop->multiplayer_flag = 0;
  mop->server_flag = 1;
  mop->val_client_port = strdup("19150");
  mop->val_server_addr = strdup("127.0.0.1");
  mop->val_server_port = strdup("19140");
  int conditions_were_set = 0;
  opterr = 0;
  int c;
  while ((c = getopt (argc, argv, "hvrTW:H:i:l:q:d:s:R:S:E:e:C:c:")) != -1){
    switch(c){
      case 'r': op->keep_random_flag = 1; break;
      case 'T': op->timeline_flag = 1; break;
      case 'W': { char* endptr = ((void *)0);
                  op->w = (14<strtol(optarg, &endptr, 10))?(strtol(optarg, &endptr, 10)):(14);
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'H': { char* endptr = ((void *)0);
                  op->h = (14<strtol(optarg, &endptr, 10))?(strtol(optarg, &endptr, 10)):(14);
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'i': { char* endptr = ((void *)0);
                  op->inequality = strtol(optarg, &endptr, 10);
                  if (*endptr != '\0' || op->inequality < 0 || op->inequality > 4) {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'l': { char* endptr = ((void *)0);
                  op->loc_num = strtol(optarg, &endptr, 10);
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'q': { char* endptr = ((void *)0);
                  op->conditions = strtol(optarg, &endptr, 10);
                  conditions_were_set = 1;
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'R': { char* endptr = ((void *)0);
                  op->map_seed = abs(strtol(optarg, &endptr, 10));
                  if (*endptr != '\0' || *optarg == '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'd': if (strcmp(optarg, "n") == 0) op->dif = dif_normal;
                else if (strcmp(optarg, "e") == 0) op->dif = dif_easy;
                else if (strcmp(optarg, "e1") == 0) op->dif = dif_easy;
                else if (strcmp(optarg, "ee") == 0) op->dif = dif_easiest;
                else if (strcmp(optarg, "e2") == 0) op->dif = dif_easiest;
                else if (strcmp(optarg, "h") == 0) op->dif = dif_hard;
                else if (strcmp(optarg, "h1") == 0) op->dif = dif_hard;
                else if (strcmp(optarg, "hh") == 0) op->dif = dif_hardest;
                else if (strcmp(optarg, "h2") == 0) op->dif = dif_hardest;
                else {
                  print_help();
                  return 1;
                }
                break;
      case 's': if (strcmp(optarg, "n") == 0) op->speed = sp_normal;
                else if (strcmp(optarg, "s") == 0 || strcmp(optarg, "s1") == 0) op->speed = sp_slow;
                else if (strcmp(optarg, "ss") == 0 || strcmp(optarg, "s2") == 0) op->speed = sp_slower;
                else if (strcmp(optarg, "sss") == 0 || strcmp(optarg, "s3") == 0) op->speed = sp_slowest;
                else if (strcmp(optarg, "f") == 0 || strcmp(optarg, "f1") == 0) op->speed = sp_fast;
                else if (strcmp(optarg, "ff") == 0 || strcmp(optarg, "f2") == 0) op->speed = sp_faster;
                else if (strcmp(optarg, "fff") == 0 || strcmp(optarg, "f3") == 0) op->speed = sp_fastest;
                else if (strcmp(optarg, "p") == 0) op->speed = sp_pause;
                else {
                  print_help();
                  return 1;
                }
                break;
      case 'S': if (strcmp(optarg, "rhombus") == 0) op->shape = st_rhombus;
                else if (strcmp(optarg, "rect") == 0) op->shape = st_rect;
                else if (strcmp(optarg, "hex") == 0) op->shape = st_hex;
                else {
                  print_help();
                  return 1;
                }
                break;
      case 'E': { char* endptr = ((void *)0);
                  mop->clients_num = strtol(optarg, &endptr, 10);
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                  mop->multiplayer_flag = 1;
                  mop->server_flag = 1;
                }
                break;
      case 'e':
                free(mop->val_server_port);
                mop->val_server_port = strdup(optarg);
                break;
      case 'C':
                mop->multiplayer_flag = 1;
                mop->server_flag = 0;
                free(mop->val_server_addr);
                mop->val_server_addr = strdup(optarg);
                break;
      case 'c':
                free(mop->val_client_port);
                mop->val_client_port = strdup(optarg);
                break;
      case 'v':
          printf("%s\n", "1.2.0");
          return 1;
      case '?': case 'h':
          print_help();
          return 1;
      default:
          return 1;
    }
  }
  int avlbl_loc_num = stencil_avlbl_loc_num (op->shape);
  if(op->loc_num == 0) op->loc_num = avlbl_loc_num;
  if (op->loc_num < 2 || op->loc_num > avlbl_loc_num) {
    print_help();
    return 1;
  }
  if (conditions_were_set && (op->conditions<1 || op->conditions>op->loc_num)) {
    print_help();
    return 1;
  }
  if (mop->clients_num < 1 || mop->clients_num > op->loc_num) {
    print_help();
    return 1;
  }
  if (op->shape == st_rect) {
    op->w = (40 -1<op->w + (op->h + 1)/2)?(40 -1):(op->w + (op->h + 1)/2);
  }
  return 0;
}

canonical_original_code:
int get_options(int argc, char *argv[], struct basic_options *op, struct multi_options *mop) {
  op->keep_random_flag = 0;
  op->dif = dif_normal;
  op->speed = sp_normal;
  op->w = 21;
  op->h = 21;
  op->loc_num = 0;
  op->map_seed = rand();
  op->conditions = 0;
  op->timeline_flag = 0;
  op->inequality = -1;
  op->shape = st_rect;
  mop->clients_num = 1;
  mop->multiplayer_flag = 0;
  mop->server_flag = 1;
  mop->val_client_port = strdup("19150");
  mop->val_server_addr = strdup("127.0.0.1");
  mop->val_server_port = strdup("19140");
  int conditions_were_set = 0;
  opterr = 0;
  int c;
  while ((c = getopt (argc, argv, "hvrTW:H:i:l:q:d:s:R:S:E:e:C:c:")) != -1){
    switch(c){
      case 'r': op->keep_random_flag = 1; break;
      case 'T': op->timeline_flag = 1; break;
      case 'W': { char *endptr = ((void *)0);
                  op->w = (14<strtol(optarg, &endptr, 10))?(strtol(optarg, &endptr, 10)):(14);
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'H': { char *endptr = ((void *)0);
                  op->h = (14<strtol(optarg, &endptr, 10))?(strtol(optarg, &endptr, 10)):(14);
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'i': { char *endptr = ((void *)0);
                  op->inequality = strtol(optarg, &endptr, 10);
                  if (*endptr != '\0' || op->inequality < 0 || op->inequality > 4) {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'l': { char *endptr = ((void *)0);
                  op->loc_num = strtol(optarg, &endptr, 10);
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'q': { char *endptr = ((void *)0);
                  op->conditions = strtol(optarg, &endptr, 10);
                  conditions_were_set = 1;
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'R': { char *endptr = ((void *)0);
                  op->map_seed = abs(strtol(optarg, &endptr, 10));
                  if (*endptr != '\0' || *optarg == '\0') {
                    print_help();
                    return 1;
                  }
                };
                break;
      case 'd': if (strcmp(optarg, "n") == 0) op->dif = dif_normal;
                else if (strcmp(optarg, "e") == 0) op->dif = dif_easy;
                else if (strcmp(optarg, "e1") == 0) op->dif = dif_easy;
                else if (strcmp(optarg, "ee") == 0) op->dif = dif_easiest;
                else if (strcmp(optarg, "e2") == 0) op->dif = dif_easiest;
                else if (strcmp(optarg, "h") == 0) op->dif = dif_hard;
                else if (strcmp(optarg, "h1") == 0) op->dif = dif_hard;
                else if (strcmp(optarg, "hh") == 0) op->dif = dif_hardest;
                else if (strcmp(optarg, "h2") == 0) op->dif = dif_hardest;
                else {
                  print_help();
                  return 1;
                }
                break;
      case 's': if (strcmp(optarg, "n") == 0) op->speed = sp_normal;
                else if (strcmp(optarg, "s") == 0 || strcmp(optarg, "s1") == 0) op->speed = sp_slow;
                else if (strcmp(optarg, "ss") == 0 || strcmp(optarg, "s2") == 0) op->speed = sp_slower;
                else if (strcmp(optarg, "sss") == 0 || strcmp(optarg, "s3") == 0) op->speed = sp_slowest;
                else if (strcmp(optarg, "f") == 0 || strcmp(optarg, "f1") == 0) op->speed = sp_fast;
                else if (strcmp(optarg, "ff") == 0 || strcmp(optarg, "f2") == 0) op->speed = sp_faster;
                else if (strcmp(optarg, "fff") == 0 || strcmp(optarg, "f3") == 0) op->speed = sp_fastest;
                else if (strcmp(optarg, "p") == 0) op->speed = sp_pause;
                else {
                  print_help();
                  return 1;
                }
                break;
      case 'S': if (strcmp(optarg, "rhombus") == 0) op->shape = st_rhombus;
                else if (strcmp(optarg, "rect") == 0) op->shape = st_rect;
                else if (strcmp(optarg, "hex") == 0) op->shape = st_hex;
                else {
                  print_help();
                  return 1;
                }
                break;
      case 'E': { char *endptr = ((void *)0);
                  mop->clients_num = strtol(optarg, &endptr, 10);
                  if (*endptr != '\0') {
                    print_help();
                    return 1;
                  }
                  mop->multiplayer_flag = 1;
                  mop->server_flag = 1;
                }
                break;
      case 'e':
                free(mop->val_server_port);
                mop->val_server_port = strdup(optarg);
                break;
      case 'C':
                mop->multiplayer_flag = 1;
                mop->server_flag = 0;
                free(mop->val_server_addr);
                mop->val_server_addr = strdup(optarg);
                break;
      case 'c':
                free(mop->val_client_port);
                mop->val_client_port = strdup(optarg);
                break;
      case 'v':
          printf("%s\n", "1.2.0");
          return 1;
      case '?': case 'h':
          print_help();
          return 1;
      default:
          return 1;
    }
  }
  int avlbl_loc_num = stencil_avlbl_loc_num (op->shape);
  if(op->loc_num == 0) op->loc_num = avlbl_loc_num;
  if (op->loc_num < 2 || op->loc_num > avlbl_loc_num) {
    print_help();
    return 1;
  }
  if (conditions_were_set && (op->conditions<1 || op->conditions>op->loc_num)) {
    print_help();
    return 1;
  }
  if (mop->clients_num < 1 || mop->clients_num > op->loc_num) {
    print_help();
    return 1;
  }
  if (op->shape == st_rect) {
    op->w = (40 -1<op->w + (op->h + 1)/2)?(40 -1):(op->w + (op->h + 1)/2);
  }
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct basic_options { int keep_random_flag; enum config_dif { dif_easiest=0, dif_easy=1, dif_normal=2, dif_hard=3, dif_hardest=4 } dif; enum config_speed { sp_pause=0, sp_slowest=1, sp_slower=2, sp_slow=3, sp_normal=4, sp_fast=5, sp_faster=6, sp_fastest=7 } speed; int w; int h; int loc_num; unsigned int map_seed; int conditions; int timeline_flag; int inequality; enum stencil { st_rhombus=0, st_rect=1, st_hex=2 } shape; } *

variable_types: struct multi_options { int multiplayer_flag; int server_flag; char *val_client_port; char *val_server_addr; char *val_server_port; int clients_num; } *

variable_types: c int

variable_types:
endptr
char *

return_type: int

user_defined_types: struct basic_options { int keep_random_flag; enum config_dif dif; enum config_speed speed; int w; int h; int loc_num; unsigned int map_seed; int conditions; int timeline_flag; int inequality; enum stencil shape; }


original_code:
int singleplayer_process_input (struct state *st, struct ui *ui, char c) {
  int cursi = ui->cursor.i;
  int cursj = ui->cursor.j;
  switch (c) {
    case 'q': case 'Q':
      return 1;
    case 'f':
      st->prev_speed = st->speed;
      st->speed = faster(st->speed);
      break;
    case 's':
      st->prev_speed = st->speed;
      st->speed = slower(st->speed);
      break;
    case 'p':
      if (st->speed == sp_pause)
        st->speed = st->prev_speed;
      else {
        st->prev_speed = st->speed;
        st->speed = sp_pause;
      }
      break;
    case 'h': case 68:
      cursi--;
      break;
    case 'l': case 67:
      cursi++;
      break;
    case 'k': case 65:
      cursj--;
      if (cursj % 2 == 1)
        cursi++;
      break;
    case 'j': case 66:
      cursj++;
      if (cursj % 2 == 0)
        cursi--;
      break;
    case ' ':
      if (st->fg[st->controlled].flag[ui->cursor.i][ui->cursor.j] == 0)
        add_flag (&st->grid, &st->fg[st->controlled], ui->cursor.i, ui->cursor.j, 8);
      else
        remove_flag (&st->grid, &st->fg[st->controlled], ui->cursor.i, ui->cursor.j, 8);
      break;
    case 'x':
      remove_flags_with_prob (&st->grid, &st->fg[st->controlled], 1.0);
      break;
    case 'c':
      remove_flags_with_prob (&st->grid, &st->fg[st->controlled], 0.5);
      break;
    case 'r':
    case 'v':
      build (&st->grid, &st->country[st->controlled], st->controlled, ui->cursor.i, ui->cursor.j);
      break;
    case '\033':
    case 91:
      break;
  }
  adjust_cursor(st, ui, cursi, cursj);
  return 0;
}

canonical_original_code:
int singleplayer_process_input(struct state *st, struct ui *ui, char c) {
  int cursi = ui->cursor.i;
  int cursj = ui->cursor.j;
  switch (c) {
    case 'q': case 'Q':
      return 1;
    case 'f':
      st->prev_speed = st->speed;
      st->speed = faster(st->speed);
      break;
    case 's':
      st->prev_speed = st->speed;
      st->speed = slower(st->speed);
      break;
    case 'p':
      if (st->speed == sp_pause)
        st->speed = st->prev_speed;
      else {
        st->prev_speed = st->speed;
        st->speed = sp_pause;
      }
      break;
    case 'h': case 68:
      cursi--;
      break;
    case 'l': case 67:
      cursi++;
      break;
    case 'k': case 65:
      cursj--;
      if (cursj % 2 == 1)
        cursi++;
      break;
    case 'j': case 66:
      cursj++;
      if (cursj % 2 == 0)
        cursi--;
      break;
    case ' ':
      if (st->fg[st->controlled].flag[ui->cursor.i][ui->cursor.j] == 0)
        add_flag (&st->grid, &st->fg[st->controlled], ui->cursor.i, ui->cursor.j, 8);
      else
        remove_flag (&st->grid, &st->fg[st->controlled], ui->cursor.i, ui->cursor.j, 8);
      break;
    case 'x':
      remove_flags_with_prob (&st->grid, &st->fg[st->controlled], 1.0);
      break;
    case 'c':
      remove_flags_with_prob (&st->grid, &st->fg[st->controlled], 0.5);
      break;
    case 'r':
    case 'v':
      build (&st->grid, &st->country[st->controlled], st->controlled, ui->cursor.i, ui->cursor.j);
      break;
    case '\033':
    case 91:
      break;
  }
  adjust_cursor(st, ui, cursi, cursj);
  return 0;
}

variable_types: struct state { struct grid { int width; int height; struct tile { enum tile_class { abyss=0, mountain=1, mine=2, grassland=3, village=4, town=5, castle=6 } cl; int pl; int units[8][1]; } tiles[40][29]; } grid; struct flag_grid { int width; int height; int flag[40][29]; int call[40][29]; } fg[8]; struct king { int value[40][29]; int pl; enum strategy { none=0, aggr_greedy=1, one_greedy=2, persistent_greedy=3, opportunist=4, noble=5, midas=6 } strategy; } king[8]; int kings_num; struct timeline { float data[8][72]; unsigned long time[72]; int mark; } timeline; int show_timeline; struct country { long gold; } country[8]; unsigned long time; int map_seed; int controlled; int conditions; int inequality; enum config_speed { sp_pause=0, sp_slowest=1, sp_slower=2, sp_slow=3, sp_normal=4, sp_fast=5, sp_faster=6, sp_fastest=7 } speed; enum config_speed { sp_pause=0, sp_slowest=1, sp_slower=2, sp_slow=3, sp_normal=4, sp_fast=5, sp_faster=6, sp_fastest=7 } prev_speed; enum config_dif { dif_easiest=0, dif_easy=1, dif_normal=2, dif_hard=3, dif_hardest=4 } dif; } *

variable_types: struct ui { struct loc { int i; int j; } cursor; int xskip; int xlength; } *

variable_types: c char

variable_types: cursi int

variable_types: cursj int

user_defined_types: struct state { struct grid grid; struct flag_grid fg[8]; struct king king[8]; int kings_num; struct timeline timeline; int show_timeline; struct country country[8]; unsigned long time; int map_seed; int controlled; int conditions; int inequality; enum config_speed speed; enum config_speed prev_speed; enum config_dif dif; }

user_defined_types: struct ui { struct loc cursor; int xskip; int xlength; }

user_defined_types: struct grid { int width; int height; struct tile tiles[40][29]; }

user_defined_types: struct king { int value[40][29]; int pl; enum strategy strategy; }

user_defined_types: struct tile { enum tile_class cl; int pl; int units[8][1]; }


original_code:
int client_process_msg_s_state (struct state *st, struct msg_s_data *msg) {
  if (ntohl( msg->time ) <= st->time) return -1;
  int p, i, j;
  for (p=0; p<8; ++p) {
    st->country[p].gold = ntohl( msg->gold[p] );
    st->fg[p].width = msg->width;
    st->fg[p].height = msg->height;
  }
  st->time = ntohl( msg->time );
  st->controlled = msg->control;
  st->grid.width = msg->width;
  st->grid.height = msg->height;
  for (i=0; i<40; ++i) {
    for (j=0; j<29; ++j) {
      st->grid.tiles[i][j].cl = (enum tile_class)msg->tile[i][j];
      for (p=0; p<8; ++p)
        st->grid.tiles[i][j].units[p][citizen] = 0;
      st->grid.tiles[i][j].pl = msg->owner[i][j];
      st->grid.tiles[i][j].units[msg->owner[i][j]][citizen] = ntohs( msg->pop[i][j] );
      for (p=0; p<8; ++p){
        st->fg[p].call[i][j] = 0;
        if ( (msg->flag[i][j] & (1<<p)) == 0)
          st->fg[p].flag[i][j] = 0;
        else
          st->fg[p].flag[i][j] = 1;
      }
    }
  }
  return 0;
}

canonical_original_code:
int client_process_msg_s_state(struct state *st, struct msg_s_data *msg) {
  if (ntohl( msg->time ) <= st->time) return -1;
  int p; int i; int j;
  for (p=0; p<8; ++p) {
    st->country[p].gold = ntohl( msg->gold[p] );
    st->fg[p].width = msg->width;
    st->fg[p].height = msg->height;
  }
  st->time = ntohl( msg->time );
  st->controlled = msg->control;
  st->grid.width = msg->width;
  st->grid.height = msg->height;
  for (i=0; i<40; ++i) {
    for (j=0; j<29; ++j) {
      st->grid.tiles[i][j].cl = (enum tile_class)msg->tile[i][j];
      for (p=0; p<8; ++p)
        st->grid.tiles[i][j].units[p][citizen] = 0;
      st->grid.tiles[i][j].pl = msg->owner[i][j];
      st->grid.tiles[i][j].units[msg->owner[i][j]][citizen] = ntohs( msg->pop[i][j] );
      for (p=0; p<8; ++p){
        st->fg[p].call[i][j] = 0;
        if ( (msg->flag[i][j] & (1<<p)) == 0)
          st->fg[p].flag[i][j] = 0;
        else
          st->fg[p].flag[i][j] = 1;
      }
    }
  }
  return 0;
}

variable_types: struct msg_s_data { unsigned char control; unsigned char pause_request; unsigned int gold[8]; unsigned int time; unsigned char width; unsigned char height; unsigned char flag[40][29]; unsigned char owner[40][29]; unsigned short pop[40][29]; unsigned char tile[40][29]; } *

variable_types: p int

variable_types: i int

variable_types: j int

user_defined_types: enum tile_class { abyss=0, mountain=1, mine=2, grassland=3, village=4, town=5, castle=6 }

user_defined_types: struct timeline { float data[8][72]; unsigned long time[72]; int mark; }

user_defined_types: enum config_speed { sp_pause=0, sp_slowest=1, sp_slower=2, sp_slow=3, sp_normal=4, sp_fast=5, sp_faster=6, sp_fastest=7 }

user_defined_types: enum config_dif { dif_easiest=0, dif_easy=1, dif_normal=2, dif_hard=3, dif_hardest=4 }

user_defined_types: struct flag_grid { int width; int height; int flag[40][29]; int call[40][29]; }

user_defined_types: enum strategy { none=0, aggr_greedy=1, one_greedy=2, persistent_greedy=3, opportunist=4, noble=5, midas=6 }


decompiled_code:
__int64 __fastcall client_receive_msg_s(int a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // er8
socklen_t addr_len; // [rsp+Ch] [rbp-8Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-88h] BYREF

addr_len = 128;
v2 = recvfrom(a1, &buf_2, 0xC34FuLL, 0, &addr, &addr_len);
v3 = v2;
if ( v2 == -1 )
return v3;
v3 = 0;
if ( v2 <= 0 )
return v3;
v3 = (unsigned __int8)buf_2;
if ( buf_2 != 10 )
return v3;
if ( v2 <= 5844 )
return (unsigned int)-1;
qmemcpy(msg_data_1, &unk_DEE1, 0x16D4uLL);
client_process_msg_s_state(a2, msg_data_1);
return 10LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // er8
socklen_t addr_len; // [rsp+Ch] [rbp-8Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-88h] BYREF

addr_len = 128;
v2 = recvfrom(a1, &buf_2, 0xC34FuLL, 0, &addr, &addr_len);
v3 = v2;
if ( v2 == -1 )
return v3;
v3 = 0;
if ( v2 <= 0 )
return v3;
v3 = (unsigned __int8)buf_2;
if ( buf_2 != 10 )
return v3;
if ( v2 <= 5844 )
return (unsigned int)-1;
qmemcpy(msg_data_1, &unk_DEE1, 0x16D4uLL);
func2(a2, msg_data_1);
return 10LL;
}

original_code:
int client_receive_msg_s (int sfd, struct state *st) {
  static uint8_t buf[50000];
  static struct msg_s_data msg_data;
  struct sockaddr_storage peer_addr;
  socklen_t peer_addr_len = sizeof(peer_addr);
  int nread = recvfrom(sfd, buf, 50000 -1, 0,
      (struct sockaddr *) &peer_addr, &peer_addr_len);
  if (nread == -1) return -1;
  uint8_t msg = 0;
  if (nread >= 1) {
    msg = buf[0];
    switch (msg) {
      case 10:
        if (nread-1 >= sizeof(struct msg_s_data)) {
          memcpy(&msg_data, buf+1, sizeof(struct msg_s_data));
          client_process_msg_s_state (st, &msg_data);
        }
        else {return -1;}
        break;
    }
  }
  return msg;
}

canonical_original_code:
int client_receive_msg_s(int sfd, struct state *st) {
  static unsigned char buf[50000];
  static struct msg_s_data msg_data;
  struct sockaddr_storage peer_addr;
  unsigned int peer_addr_len = sizeof(peer_addr);
  int nread = recvfrom(sfd, buf, 50000 -1, 0,
      (struct sockaddr *) &peer_addr, &peer_addr_len);
  if (nread == -1) return -1;
  unsigned char msg = 0;
  if (nread >= 1) {
    msg = buf[0];
    switch (msg) {
      case 10:
        if (nread-1 >= sizeof(struct msg_s_data)) {
          memcpy(&msg_data, buf+1, sizeof(struct msg_s_data));
          client_process_msg_s_state (st, &msg_data);
        }
        else {return -1;}
        break;
    }
  }
  return msg;
}

variable_types: sfd int

variable_types:
buf
unsigned char [50000]

variable_types: struct msg_s_data { unsigned char control; unsigned char pause_request; unsigned int gold[8]; unsigned int time; unsigned char width; unsigned char height; unsigned char flag[40][29]; unsigned char owner[40][29]; unsigned short pop[40][29]; unsigned char tile[40][29]; }

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

variable_types: nread int

variable_types:
msg
unsigned char


decompiled_code:
void __fastcall send_msg_c(int a1, __int64 a2, char a3, char a4, char a5, char a6)
{
const struct sockaddr *v6; // r8
socklen_t v7; // er9

byte_4A2 = a5;
v6 = *(const struct sockaddr **)(a2 + 24);
byte_4A3 = a6;
v7 = *(_DWORD *)(a2 + 16);
buf_0 = a3;
byte_4A1 = a4;
if ( (unsigned int)sendto(a1, &buf_0, 4uLL, 0, v6, v7) == -1 )
perror("client: sendto");
}

canonical_decompiled_code:
void __fastcall func4(int a1, __int64 a2, char a3, char a4, char a5, char a6)
{
const struct sockaddr *v6; // r8
socklen_t v7; // er9

byte_4A2 = a5;
v6 = *(const struct sockaddr **)(a2 + 24);
byte_4A3 = a6;
v7 = *(_DWORD *)(a2 + 16);
buf_0 = a3;
byte_4A1 = a4;
if ( (unsigned int)sendto(a1, &buf_0, 4uLL, 0, v6, v7) == -1 )
perror("client: sendto");
}

original_code:
void send_msg_c (int sfd, struct addrinfo *srv_addr, uint8_t msg, uint8_t i, uint8_t j, uint8_t info) {
  struct msg_c_data mcd = {i, j, info};
  static uint8_t buf[50000];
  buf[0] = msg;
  memcpy(buf+1, &mcd, sizeof(mcd));
  int nsent = sendto(sfd, buf, 1+sizeof(mcd), 0, srv_addr->ai_addr, srv_addr->ai_addrlen);
  if (nsent == -1) {
    perror("client: sendto");
  }
}

canonical_original_code:
void send_msg_c(int sfd, struct addrinfo *srv_addr, unsigned char msg, unsigned char i, unsigned char j, unsigned char info) {
  struct msg_c_data mcd = {i, j, info};
  static unsigned char buf[50000];
  buf[0] = msg;
  memcpy(buf+1, &mcd, sizeof(mcd));
  int nsent = sendto(sfd, buf, 1+sizeof(mcd), 0, srv_addr->ai_addr, srv_addr->ai_addrlen);
  if (nsent == -1) {
    perror("client: sendto");
  }
}

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

variable_types:
i
unsigned char

variable_types:
j
unsigned char

variable_types:
info
unsigned char

variable_types: struct msg_c_data { unsigned char i; unsigned char j; unsigned char info; }

variable_types: nsent int

return_type: void

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


decompiled_code:
__int64 __fastcall client_process_input(__int64 a1, unsigned int *a2, char a3, int a4, __int64 a5)
{
unsigned int v5; // er13
unsigned int v6; // er14

v5 = *a2;
v6 = a2[1];
switch ( a3 )
{
case ' ':
if ( *(_DWORD *)(a1 + 4 * ((int)v6 + 29LL * (int)v5 + 2322LL * *(int *)(a1 + 160876) + 11600) + 16) )
send_msg_c(a4, a5, 22, v5, v6, 0);
else
send_msg_c(a4, a5, 21, v5, v6, 0);
goto LABEL_3;
case 'A':
case 'k':
v5 += (int)--v6 % 2 == 1;
goto LABEL_3;
case 'B':
case 'j':
v5 = (__PAIR64__(v5, ++v6 & 1) - 1) >> 32;
goto LABEL_3;
case 'C':
case 'l':
++v5;
goto LABEL_3;
case 'D':
case 'h':
--v5;
goto LABEL_3;
case 'Q':
case 'q':
return 1LL;
case 'c':
send_msg_c(a4, a5, 24, 0, 0, 0);
goto LABEL_3;
case 'p':
if ( *(_DWORD *)(a1 + 160888) )
send_msg_c(a4, a5, 41, 0, 0, 0);
else
send_msg_c(a4, a5, 40, 0, 0, 0);
goto LABEL_3;
case 'r':
case 'v':
send_msg_c(a4, a5, 20, v5, v6, 0);
goto LABEL_3;
case 'x':
send_msg_c(a4, a5, 23, 0, 0, 0);
goto LABEL_3;
default:
LABEL_3:
adjust_cursor(a1, a2, v5, v6);
return 0LL;
}
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned int *a2, char a3, int a4, __int64 a5)
{
unsigned int v5; // er13
unsigned int v6; // er14

v5 = *a2;
v6 = a2[1];
switch ( a3 )
{
case ' ':
if ( *(_DWORD *)(a1 + 4 * ((int)v6 + 29LL * (int)v5 + 2322LL * *(int *)(a1 + 160876) + 11600) + 16) )
func4(a4, a5, 22, v5, v6, 0);
else
func4(a4, a5, 21, v5, v6, 0);
goto LABEL_3;
case 'A':
case 'k':
v5 += (int)--v6 % 2 == 1;
goto LABEL_3;
case 'B':
case 'j':
v5 = (__PAIR64__(v5, ++v6 & 1) - 1) >> 32;
goto LABEL_3;
case 'C':
case 'l':
++v5;
goto LABEL_3;
case 'D':
case 'h':
--v5;
goto LABEL_3;
case 'Q':
case 'q':
return 1LL;
case 'c':
func4(a4, a5, 24, 0, 0, 0);
goto LABEL_3;
case 'p':
if ( *(_DWORD *)(a1 + 160888) )
func4(a4, a5, 41, 0, 0, 0);
else
func4(a4, a5, 40, 0, 0, 0);
goto LABEL_3;
case 'r':
case 'v':
func4(a4, a5, 20, v5, v6, 0);
goto LABEL_3;
case 'x':
func4(a4, a5, 23, 0, 0, 0);
goto LABEL_3;
default:
LABEL_3:
adjust_cursor(a1, a2, v5, v6);
return 0LL;
}
}

original_code:
int client_process_input (struct state *st, struct ui *ui, char c, int sfd, struct addrinfo *srv_addr) {
  int cursi = ui->cursor.i;
  int cursj = ui->cursor.j;
  switch (c) {
      case 'Q':
      case 'q':
        return 1;
      case 'p':
        if (st->speed == sp_pause)
          send_msg_c (sfd, srv_addr, 40, 0, 0, 0);
        else {
          send_msg_c (sfd, srv_addr, 41, 0, 0, 0);
        }
        break;
      case 'h': case 68:
        cursi--;
        break;
      case 'l': case 67:
        cursi++;
        break;
      case 'k': case 65:
        cursj--;
        if (cursj % 2 == 1)
          cursi++;
        break;
      case 'j': case 66:
        cursj++;
        if (cursj % 2 == 0)
          cursi--;
        break;
      case ' ':
        if (st->fg[st->controlled].flag[ui->cursor.i][ui->cursor.j] == 0)
          send_msg_c (sfd, srv_addr, 21, ui->cursor.i, ui->cursor.j, 0);
        else
          send_msg_c (sfd, srv_addr, 22, ui->cursor.i, ui->cursor.j, 0);
        break;
      case 'x':
        send_msg_c (sfd, srv_addr, 23, 0, 0, 0);
        break;
      case 'c':
        send_msg_c (sfd, srv_addr, 24, 0, 0, 0);
        break;
      case 'r':
      case 'v':
        send_msg_c (sfd, srv_addr, 20, ui->cursor.i, ui->cursor.j, 0);
        break;
      case '\033':
      case 91:
        break;
      }
  adjust_cursor(st, ui, cursi, cursj);
  return 0;
}

canonical_original_code:
int client_process_input(struct state *st, struct ui *ui, char c, int sfd, struct addrinfo *srv_addr) {
  int cursi = ui->cursor.i;
  int cursj = ui->cursor.j;
  switch (c) {
      case 'Q':
      case 'q':
        return 1;
      case 'p':
        if (st->speed == sp_pause)
          send_msg_c (sfd, srv_addr, 40, 0, 0, 0);
        else {
          send_msg_c (sfd, srv_addr, 41, 0, 0, 0);
        }
        break;
      case 'h': case 68:
        cursi--;
        break;
      case 'l': case 67:
        cursi++;
        break;
      case 'k': case 65:
        cursj--;
        if (cursj % 2 == 1)
          cursi++;
        break;
      case 'j': case 66:
        cursj++;
        if (cursj % 2 == 0)
          cursi--;
        break;
      case ' ':
        if (st->fg[st->controlled].flag[ui->cursor.i][ui->cursor.j] == 0)
          send_msg_c (sfd, srv_addr, 21, ui->cursor.i, ui->cursor.j, 0);
        else
          send_msg_c (sfd, srv_addr, 22, ui->cursor.i, ui->cursor.j, 0);
        break;
      case 'x':
        send_msg_c (sfd, srv_addr, 23, 0, 0, 0);
        break;
      case 'c':
        send_msg_c (sfd, srv_addr, 24, 0, 0, 0);
        break;
      case 'r':
      case 'v':
        send_msg_c (sfd, srv_addr, 20, ui->cursor.i, ui->cursor.j, 0);
        break;
      case '\033':
      case 91:
        break;
      }
  adjust_cursor(st, ui, cursi, cursj);
  return 0;
}

variable_types: struct state { struct grid { int width; int height; struct tile { enum tile_class { abyss=0, mountain=1, mine=2, grassland=3, village=4, town=5, castle=6 } cl; int pl; int units[8][1]; } tiles[40][29]; } grid; struct flag_grid { int width; int height; int flag[40][29]; int call[40][29]; } fg[8]; struct king { int value[40][29]; int pl; enum strategy { none=0, aggr_greedy=1, one_greedy=2, persistent_greedy=3, opportunist=4, noble=5, midas=6 } strategy; } king[8]; int kings_num; struct timeline { float data[8][72]; unsigned long time[72]; int mark; } timeline; int show_timeline; struct country { long gold; } country[8]; unsigned long time; int map_seed; int controlled; int conditions; int inequality; enum config_speed { sp_pause=0, sp_slowest=1, sp_slower=2, sp_slow=3, sp_normal=4, sp_fast=5, sp_faster=6, sp_fastest=7 } speed; enum config_speed { sp_pause=0, sp_slowest=1, sp_slower=2, sp_slow=3, sp_normal=4, sp_fast=5, sp_faster=6, sp_fastest=7 } prev_speed; enum config_dif { dif_easiest=0, dif_easy=1, dif_normal=2, dif_hard=3, dif_hardest=4 } dif; } *

variable_types: struct ui { struct loc { int i; int j; } cursor; int xskip; int xlength; } *

variable_types: c char

variable_types: cursi int

variable_types: cursj int

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


original_code:
void server_send_msg_s_state (int sfd, struct client_record cl[], int cl_num, struct state *st) {
  static uint8_t buf[50000];
  static struct msg_s_data msg_data;
  int p, i, j;
  for (p=0; p<8; ++p) {
    msg_data.gold[p] = htonl( st->country[p].gold );
    msg_data.width = st->fg[p].width;
    msg_data.height =st->fg[p].height;
  }
  msg_data.time = htonl( st->time );
  msg_data.control = 0;
  msg_data.width = st->grid.width;
  msg_data.height = st->grid.height;
  for (i=0; i<40; ++i) {
    for (j=0; j<29; ++j) {
      msg_data.tile[i][j] = st->grid.tiles[i][j].cl;
      int owner = st->grid.tiles[i][j].pl;
      msg_data.owner[i][j] = owner;
      msg_data.pop[i][j] = htons( st->grid.tiles[i][j].units[owner][citizen] );
      msg_data.flag[i][j] = 0;
      for (p=0; p<8; ++p){
        if (st->fg[p].flag[i][j])
          msg_data.flag[i][j] |= (1<<p);
      }
    }
  }
  buf[0] = 10;
  int size = sizeof(msg_data);
  memcpy(buf+1, &msg_data, size);
  int n_to_send = size+1;
  socklen_t peer_addr_len;
  for (i=0; i<cl_num; ++i) {
    peer_addr_len = sizeof (cl[i].sa);
    buf[1] = cl[i].pl;
    sendto(sfd, buf, n_to_send, 0, (struct sockaddr *) &cl[i].sa, peer_addr_len);
  }
}

canonical_original_code:
void server_send_msg_s_state(int sfd, struct client_record cl[], int cl_num, struct state *st) {
  static unsigned char buf[50000];
  static struct msg_s_data msg_data;
  int p; int i; int j;
  for (p=0; p<8; ++p) {
    msg_data.gold[p] = htonl( st->country[p].gold );
    msg_data.width = st->fg[p].width;
    msg_data.height =st->fg[p].height;
  }
  msg_data.time = htonl( st->time );
  msg_data.control = 0;
  msg_data.width = st->grid.width;
  msg_data.height = st->grid.height;
  for (i=0; i<40; ++i) {
    for (j=0; j<29; ++j) {
      msg_data.tile[i][j] = st->grid.tiles[i][j].cl;
      int owner = st->grid.tiles[i][j].pl;
      msg_data.owner[i][j] = owner;
      msg_data.pop[i][j] = htons( st->grid.tiles[i][j].units[owner][citizen] );
      msg_data.flag[i][j] = 0;
      for (p=0; p<8; ++p){
        if (st->fg[p].flag[i][j])
          msg_data.flag[i][j] |= (1<<p);
      }
    }
  }
  buf[0] = 10;
  int size = sizeof(msg_data);
  memcpy(buf+1, &msg_data, size);
  int n_to_send = size+1;
  unsigned int peer_addr_len;
  for (i=0; i<cl_num; ++i) {
    peer_addr_len = sizeof (cl[i].sa);
    buf[1] = cl[i].pl;
    sendto(sfd, buf, n_to_send, 0, (struct sockaddr *) &cl[i].sa, peer_addr_len);
  }
}

variable_types: sfd int

variable_types: struct client_record { int pl; int id; char *name; struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; } sa; } []

variable_types: p int

variable_types: i int

variable_types: j int

variable_types: owner int

variable_types: size int

user_defined_types: struct msg_s_data { unsigned char control; unsigned char pause_request; unsigned int gold[8]; unsigned int time; unsigned char width; unsigned char height; unsigned char flag[40][29]; unsigned char owner[40][29]; unsigned short pop[40][29]; unsigned char tile[40][29]; }

user_defined_types: struct client_record { int pl; int id; char *name; struct sockaddr_storage sa; }


decompiled_code:
__int64 __fastcall process_msg_c(__int64 a1, unsigned int a2, char a3, unsigned __int8 *a4)
{
__int64 result; // rax

switch ( a3 )
{
case 20:
result = build(a1, a1 + 8LL * (int)a2 + 160800, a2, *a4, a4[1]);
break;
case 21:
result = add_flag(a1, a1 + 9288LL * (int)a2 + 46408, *a4, a4[1], 8LL);
break;
case 22:
result = remove_flag(a1, a1 + 9288LL * (int)a2 + 46408, *a4, a4[1], 8LL);
break;
case 23:
result = remove_flags_with_prob(a1, a1 + 9288LL * (int)a2 + 46408, 1.0);
break;
case 24:
result = remove_flags_with_prob(a1, a1 + 9288LL * (int)a2 + 46408, 0.5);
break;
default:
return result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2, char a3, unsigned __int8 *a4)
{
__int64 result; // rax

switch ( a3 )
{
case 20:
result = build(a1, a1 + 8LL * (int)a2 + 160800, a2, *a4, a4[1]);
break;
case 21:
result = add_flag(a1, a1 + 9288LL * (int)a2 + 46408, *a4, a4[1], 8LL);
break;
case 22:
result = remove_flag(a1, a1 + 9288LL * (int)a2 + 46408, *a4, a4[1], 8LL);
break;
case 23:
result = remove_flags_with_prob(a1, a1 + 9288LL * (int)a2 + 46408, 1.0);
break;
case 24:
result = remove_flags_with_prob(a1, a1 + 9288LL * (int)a2 + 46408, 0.5);
break;
default:
return result;
}
return result;
}

original_code:
void process_msg_c (struct state *st, int pl, uint8_t msg, struct msg_c_data *cm) {
  switch (msg) {
    case 20:
      build (&st->grid, &st->country[pl], pl, cm->i, cm->j);
      break;
    case 21:
      add_flag (&st->grid, &st->fg[pl], cm->i, cm->j, 8);
      break;
    case 22:
      remove_flag (&st->grid, &st->fg[pl], cm->i, cm->j, 8);
      break;
    case 23:
      remove_flags_with_prob (&st->grid, &st->fg[pl], 1.0);
      break;
    case 24:
      remove_flags_with_prob (&st->grid, &st->fg[pl], 0.5);
      break;
    case 30:
      break;
    case 40:
    case 41:
    default:
      break;
  }
}

canonical_original_code:
void process_msg_c(struct state *st, int pl, unsigned char msg, struct msg_c_data *cm) {
  switch (msg) {
    case 20:
      build (&st->grid, &st->country[pl], pl, cm->i, cm->j);
      break;
    case 21:
      add_flag (&st->grid, &st->fg[pl], cm->i, cm->j, 8);
      break;
    case 22:
      remove_flag (&st->grid, &st->fg[pl], cm->i, cm->j, 8);
      break;
    case 23:
      remove_flags_with_prob (&st->grid, &st->fg[pl], 1.0);
      break;
    case 24:
      remove_flags_with_prob (&st->grid, &st->fg[pl], 0.5);
      break;
    case 30:
      break;
    case 40:
    case 41:
    default:
      break;
  }
}

variable_types: pl int

variable_types:
msg
unsigned char

variable_types: struct msg_c_data { unsigned char i; unsigned char j; unsigned char info; } *


decompiled_code:
__int64 __fastcall server_process_msg_c(unsigned __int8 *a1, unsigned int a2, __int64 a3, unsigned int a4)
{
unsigned int v4; // er12

if ( a2 <= 3 )
return (unsigned int)-1;
v4 = *a1;
msg_data_0 = *(_WORD *)(a1 + 1);
byte_362 = a1[3];
process_msg_c(a3, a4, v4, (unsigned __int8 *)&msg_data_0);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int8 *a1, unsigned int a2, __int64 a3, unsigned int a4)
{
unsigned int v4; // er12

if ( a2 <= 3 )
return (unsigned int)-1;
v4 = *a1;
msg_data_0 = *(_WORD *)(a1 + 1);
byte_362 = a1[3];
func3(a3, a4, v4, (unsigned __int8 *)&msg_data_0);
return v4;
}

original_code:
int server_process_msg_c (uint8_t buf[50000], int nread, struct state *st, int pl) {
  uint8_t msg;
  static struct msg_c_data msg_data;
  if (nread >= 1 + sizeof(struct msg_c_data)) {
    msg = buf[0];
    memcpy(&msg_data, buf+1, sizeof(struct msg_c_data));
    process_msg_c(st, pl, msg, &msg_data);
  }
  else {return -1;}
  return msg;
}

canonical_original_code:
int server_process_msg_c(unsigned char buf[50000], int nread, struct state *st, int pl) {
  unsigned char msg;
  static struct msg_c_data msg_data;
  if (nread >= 1 + sizeof(struct msg_c_data)) {
    msg = buf[0];
    memcpy(&msg_data, buf+1, sizeof(struct msg_c_data));
    process_msg_c(st, pl, msg, &msg_data);
  }
  else {return -1;}
  return msg;
}

variable_types:
buf
unsigned char [50000]

variable_types: nread int

variable_types: struct msg_c_data { unsigned char i; unsigned char j; unsigned char info; }


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

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

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

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

original_code:
int server_get_msg (uint8_t buf[50000], int nread) {
  if (nread>=1) return buf[0]; else return 0;
}

canonical_original_code:
int server_get_msg(unsigned char buf[50000], int nread) {
  if (nread>=1) return buf[0]; else return 0;
}


decompiled_code:
__int64 __fastcall get_in_port(__int64 a1)
{
return *(unsigned __int16 *)(a1 + 2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return *(unsigned __int16 *)(a1 + 2);
}

original_code:
in_port_t get_in_port(struct sockaddr *sa) {
  if (sa->sa_family == 2) {
    return (((struct sockaddr_in*)sa)->sin_port);
  }
  return (((struct sockaddr_in6*)sa)->sin6_port);
}

canonical_original_code:
unsigned short get_in_port(struct sockaddr *sa) {
  if (sa->sa_family == 2) {
    return (((struct sockaddr_in *)sa)->sin_port);
  }
  return (((struct sockaddr_in6 *)sa)->sin6_port);
}

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

return_type: unsigned short

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

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }

user_defined_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; }


canonical_original_code:
int eq_6_addr(unsigned char s1[16], unsigned char s2[16]) {
  int i;
  for(i=0; i<16; ++i) {
    if (s1[i] != s2[i]) return 0;
  }
  return 1;
}


original_code:
int sa_match (struct sockaddr_storage *sa1, struct sockaddr_storage *sa2) {
  struct sockaddr *s1 = (struct sockaddr*) sa1;
  struct sockaddr *s2 = (struct sockaddr*) sa2;
  return (
      ( s1->sa_family == 2 && s2->sa_family == 2 &&
        ((struct sockaddr_in*)s1)->sin_addr.s_addr == ((struct sockaddr_in*)s2)->sin_addr.s_addr )
      ||
      ( s1->sa_family == 10 && s2->sa_family == 10 &&
        eq_6_addr (
          ((struct sockaddr_in6*)s1)->sin6_addr.__in6_u.__u6_addr8,
          ((struct sockaddr_in6*)s2)->sin6_addr.__in6_u.__u6_addr8 ) )
    )
    &&
    ( get_in_port(s1) == get_in_port(s2) );
}

canonical_original_code:
int sa_match(struct sockaddr_storage *sa1, struct sockaddr_storage *sa2) {
  struct sockaddr *s1 = (struct sockaddr*) sa1;
  struct sockaddr *s2 = (struct sockaddr*) sa2;
  return (
      ( s1->sa_family == 2 && s2->sa_family == 2 &&
        ((struct sockaddr_in *)s1)->sin_addr.s_addr == ((struct sockaddr_in *)s2)->sin_addr.s_addr )
      ||
      ( s1->sa_family == 10 && s2->sa_family == 10 &&
        eq_6_addr (
          ((struct sockaddr_in6 *)s1)->sin6_addr.__in6_u.__u6_addr8,
          ((struct sockaddr_in6 *)s2)->sin6_addr.__in6_u.__u6_addr8 ) )
    )
    &&
    ( get_in_port(s1) == get_in_port(s2) );
}

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


decompiled_code:
__int64 __fastcall server_init(int *a1, const char *a2)
{
int v2; // eax
struct addrinfo *i; // rbx
int v4; // eax
__int64 result; // rax
const char *v6; // rax
struct addrinfo *pai; // [rsp+Ch] [rbp-50h] BYREF
struct addrinfo req; // [rsp+14h] [rbp-48h] BYREF

*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 2;
req.ai_flags = 1;
*(_OWORD *)&req.ai_canonname = 0LL;
v2 = getaddrinfo(0LL, a2, &req, &pai);
if ( v2 )
{
v6 = gai_strerror(v2);
fprintf(stderr, "getaddrinfo: %s\n", v6);
result = 0xFFFFFFFFLL;
}
else
{
for ( i = pai; i; i = i->ai_next )
{
v4 = socket(i->ai_family, i->ai_socktype, i->ai_protocol);
*a1 = v4;
if ( v4 != -1 )
{
if ( !bind(v4, i->ai_addr, i->ai_addrlen) )
{
freeaddrinfo(pai);
return 0LL;
}
close(*a1);
}
}
fwrite("Could not bind\n", 1uLL, 0xFuLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, const char *a2)
{
int v2; // eax
struct addrinfo *i; // rbx
int v4; // eax
__int64 result; // rax
const char *v6; // rax
struct addrinfo *pai; // [rsp+Ch] [rbp-50h] BYREF
struct addrinfo req; // [rsp+14h] [rbp-48h] BYREF

*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 2;
req.ai_flags = 1;
*(_OWORD *)&req.ai_canonname = 0LL;
v2 = getaddrinfo(0LL, a2, &req, &pai);
if ( v2 )
{
v6 = gai_strerror(v2);
fprintf(stderr, "getaddrinfo: %s\n", v6);
result = 0xFFFFFFFFLL;
}
else
{
for ( i = pai; i; i = i->ai_next )
{
v4 = socket(i->ai_family, i->ai_socktype, i->ai_protocol);
*a1 = v4;
if ( v4 != -1 )
{
if ( !bind(v4, i->ai_addr, i->ai_addrlen) )
{
freeaddrinfo(pai);
return 0LL;
}
close(*a1);
}
}
fwrite("Could not bind\n", 1uLL, 0xFuLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int server_init (int *p_sfd, char*str_port) {
  struct addrinfo hints;
  struct addrinfo *result, *rp;
  int s;
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = 0;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = 0x0001;
  hints.ai_protocol = 0;
  hints.ai_canonname = ((void *)0);
  hints.ai_addr = ((void *)0);
  hints.ai_next = ((void *)0);
  s = getaddrinfo(((void *)0), str_port, &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    return -1;
  }
  for (rp = result; rp != ((void *)0); rp = rp->ai_next) {
    *p_sfd = socket(rp->ai_family, rp->ai_socktype,
    rp->ai_protocol);
    if (*p_sfd == -1)
      continue;
    if (bind(*p_sfd, rp->ai_addr, rp->ai_addrlen) == 0)
    break;
    close(*p_sfd);
  }
  if (rp == ((void *)0)) {
    fprintf(stderr, "Could not bind\n");
    return -1;
  }
  freeaddrinfo(result);
  return 0;
}

canonical_original_code:
int server_init(int *p_sfd, char *str_port) {
  struct addrinfo hints;
  struct addrinfo *result; struct addrinfo *rp;
  int s;
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = 0;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = 0x0001;
  hints.ai_protocol = 0;
  hints.ai_canonname = ((void *)0);
  hints.ai_addr = ((void *)0);
  hints.ai_next = ((void *)0);
  s = getaddrinfo(((void *)0), str_port, &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    return -1;
  }
  for (rp = result; rp != ((void *)0); rp = rp->ai_next) {
    *p_sfd = socket(rp->ai_family, rp->ai_socktype,
    rp->ai_protocol);
    if (*p_sfd == -1)
      continue;
    if (bind(*p_sfd, rp->ai_addr, rp->ai_addrlen) == 0)
    break;
    close(*p_sfd);
  }
  if (rp == ((void *)0)) {
    fprintf(stderr, "Could not bind\n");
    return -1;
  }
  freeaddrinfo(result);
  return 0;
}

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

variable_types: s int


decompiled_code:
int __fastcall client_init_session(int *a1, const char *a2, __m128i *a3, const char *a4, const char *a5)
{
int result; // eax
struct addrinfo *v9; // rbx
int v10; // eax
const __m128i *v11; // rdx
const char *v12; // rax
struct addrinfo *pai; // [rsp+0h] [rbp-60h] BYREF
struct addrinfo req; // [rsp+8h] [rbp-58h] BYREF

*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 2;
req.ai_flags = 1;
*(_OWORD *)&req.ai_canonname = 0LL;
result = getaddrinfo(0LL, a2, &req, &pai);
if ( result )
goto LABEL_12;
v9 = pai;
if ( !pai )
{
LABEL_7:
fwrite("Could not bind\n", 1uLL, 0xFuLL, stderr);
return -1;
}
while ( 1 )
{
v10 = socket(v9->ai_family, v9->ai_socktype, v9->ai_protocol);
*a1 = v10;
if ( v10 != -1 )
break;
LABEL_6:
v9 = v9->ai_next;
if ( !v9 )
goto LABEL_7;
}
if ( bind(v10, v9->ai_addr, v9->ai_addrlen) )
{
close(*a1);
goto LABEL_6;
}
freeaddrinfo(pai);
*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 2;
*(_OWORD *)&req.ai_canonname = 0LL;
result = getaddrinfo(a4, a5, &req, &pai);
if ( result )
{
LABEL_12:
v12 = gai_strerror(result);
fprintf(stderr, "getaddrinfo: %s\n", v12);
return -1;
}
v11 = (const __m128i *)pai;
if ( pai )
{
*a3 = _mm_loadu_si128((const __m128i *)pai);
a3[1] = _mm_loadu_si128(v11 + 1);
a3[2] = _mm_loadu_si128(v11 + 2);
}
else
{
fwrite("Could not connect\n", 1uLL, 0x12uLL, stderr);
result = -1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(int *a1, const char *a2, __m128i *a3, const char *a4, const char *a5)
{
int result; // eax
struct addrinfo *v9; // rbx
int v10; // eax
const __m128i *v11; // rdx
const char *v12; // rax
struct addrinfo *pai; // [rsp+0h] [rbp-60h] BYREF
struct addrinfo req; // [rsp+8h] [rbp-58h] BYREF

*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 2;
req.ai_flags = 1;
*(_OWORD *)&req.ai_canonname = 0LL;
result = getaddrinfo(0LL, a2, &req, &pai);
if ( result )
goto LABEL_12;
v9 = pai;
if ( !pai )
{
LABEL_7:
fwrite("Could not bind\n", 1uLL, 0xFuLL, stderr);
return -1;
}
while ( 1 )
{
v10 = socket(v9->ai_family, v9->ai_socktype, v9->ai_protocol);
*a1 = v10;
if ( v10 != -1 )
break;
LABEL_6:
v9 = v9->ai_next;
if ( !v9 )
goto LABEL_7;
}
if ( bind(v10, v9->ai_addr, v9->ai_addrlen) )
{
close(*a1);
goto LABEL_6;
}
freeaddrinfo(pai);
*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 2;
*(_OWORD *)&req.ai_canonname = 0LL;
result = getaddrinfo(a4, a5, &req, &pai);
if ( result )
{
LABEL_12:
v12 = gai_strerror(result);
fprintf(stderr, "getaddrinfo: %s\n", v12);
return -1;
}
v11 = (const __m128i *)pai;
if ( pai )
{
*a3 = _mm_loadu_si128((const __m128i *)pai);
a3[1] = _mm_loadu_si128(v11 + 1);
a3[2] = _mm_loadu_si128(v11 + 2);
}
else
{
fwrite("Could not connect\n", 1uLL, 0x12uLL, stderr);
result = -1;
}
return result;
}

original_code:
int client_init_session (int *p_sfd, char* str_my_port, struct addrinfo *srv, char *str_server_addr, char *str_server_port) {
  struct addrinfo hints;
  struct addrinfo *result, *rp;
  int s;
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = 0;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = 0x0001;
  hints.ai_protocol = 0;
  hints.ai_canonname = ((void *)0);
  hints.ai_addr = ((void *)0);
  hints.ai_next = ((void *)0);
  s = getaddrinfo(((void *)0), str_my_port, &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    return -1;
  }
  for (rp = result; rp != ((void *)0); rp = rp->ai_next) {
    *p_sfd = socket(rp->ai_family, rp->ai_socktype,
    rp->ai_protocol);
    if (*p_sfd == -1)
      continue;
    if (bind(*p_sfd, rp->ai_addr, rp->ai_addrlen) == 0)
    break;
    close(*p_sfd);
  }
  if (rp == ((void *)0)) {
    fprintf(stderr, "Could not bind\n");
    return -1;
  }
  freeaddrinfo(result);
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = 0;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = 0;
  hints.ai_protocol = 0;
  s = getaddrinfo(str_server_addr, str_server_port, &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    return -1;
  }
  rp = result;
  if (rp == ((void *)0)) {
    fprintf(stderr, "Could not connect\n");
    return -1;
  }
  *srv = *rp;
  return 0;
}

canonical_original_code:
int client_init_session(int *p_sfd, char *str_my_port, struct addrinfo *srv, char *str_server_addr, char *str_server_port) {
  struct addrinfo hints;
  struct addrinfo *result; struct addrinfo *rp;
  int s;
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = 0;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = 0x0001;
  hints.ai_protocol = 0;
  hints.ai_canonname = ((void *)0);
  hints.ai_addr = ((void *)0);
  hints.ai_next = ((void *)0);
  s = getaddrinfo(((void *)0), str_my_port, &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    return -1;
  }
  for (rp = result; rp != ((void *)0); rp = rp->ai_next) {
    *p_sfd = socket(rp->ai_family, rp->ai_socktype,
    rp->ai_protocol);
    if (*p_sfd == -1)
      continue;
    if (bind(*p_sfd, rp->ai_addr, rp->ai_addrlen) == 0)
    break;
    close(*p_sfd);
  }
  if (rp == ((void *)0)) {
    fprintf(stderr, "Could not bind\n");
    return -1;
  }
  freeaddrinfo(result);
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = 0;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = 0;
  hints.ai_protocol = 0;
  s = getaddrinfo(str_server_addr, str_server_port, &hints, &result);
  if (s != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
    return -1;
  }
  rp = result;
  if (rp == ((void *)0)) {
    fprintf(stderr, "Could not connect\n");
    return -1;
  }
  *srv = *rp;
  return 0;
}

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


decompiled_code:
__int64 __fastcall find_node(int a1)
{
__int64 v1; // rdx
__int64 result; // rax

if ( total <= 0 )
return 0LL;
v1 = 0LL;
while ( 1 )
{
result = list[v1];
if ( result )
break;
LABEL_8:
if ( total == ++v1 )
return 0LL;
}
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 8);
if ( !result )
goto LABEL_8;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
__int64 v1; // rdx
__int64 result; // rax

if ( total <= 0 )
return 0LL;
v1 = 0LL;
while ( 1 )
{
result = list[v1];
if ( result )
break;
LABEL_8:
if ( total == ++v1 )
return 0LL;
}
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 8);
if ( !result )
goto LABEL_8;
}
return result;
}

original_code:
Blocks *find_node(int block_num){
    int temp , check = 0;
    Blocks *ptr = ((void *)0);
    for(temp = 0 ; temp < total ; temp++){
        ptr = list[temp];
        while(ptr != ((void *)0)){
            if(ptr->num == block_num){
                check = 1;
                break;
            }else{
                ptr = ptr->next;
            }
        }
        if(check == 1){
            break;
        }
    }
    return ptr;
}

canonical_original_code:
struct Block_struct *find_node(int block_num){
    int temp; int check = 0;
    struct Block_struct *ptr = ((void *)0);
    for(temp = 0 ; temp < total ; temp++){
        ptr = list[temp];
        while(ptr != ((void *)0)){
            if(ptr->num == block_num){
                check = 1;
                break;
            }else{
                ptr = ptr->next;
            }
        }
        if(check == 1){
            break;
        }
    }
    return ptr;
}

variable_types: temp int

variable_types: check int

variable_types: struct Block_struct { int num; int cur_addr; struct Block_struct *next; struct Block_struct *before; } *


move

decompiled_code:
__int64 __fastcall move(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v3; // rdx
__int64 result; // rax

v2 = list[a2];
if ( v2 )
{
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
result = *(_QWORD *)(a1 + 16);
*(_QWORD *)(v3 + 8) = a1;
if ( result )
{
*(_QWORD *)(result + 8) = 0LL;
}
else
{
result = *(int *)(a1 + 4);
list[result] = 0LL;
}
*(_QWORD *)(a1 + 16) = v3;
}
else
{
list[a2] = a1;
result = *(_QWORD *)(a1 + 16);
if ( result )
*(_QWORD *)(result + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
}
do
{
*(_DWORD *)(a1 + 4) = a2;
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v3; // rdx
__int64 result; // rax

v2 = list[a2];
if ( v2 )
{
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
result = *(_QWORD *)(a1 + 16);
*(_QWORD *)(v3 + 8) = a1;
if ( result )
{
*(_QWORD *)(result + 8) = 0LL;
}
else
{
result = *(int *)(a1 + 4);
list[result] = 0LL;
}
*(_QWORD *)(a1 + 16) = v3;
}
else
{
list[a2] = a1;
result = *(_QWORD *)(a1 + 16);
if ( result )
*(_QWORD *)(result + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
}
do
{
*(_DWORD *)(a1 + 4) = a2;
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

original_code:
void move(Blocks *node , int addr_num){
    Blocks *ptr = list[addr_num];
    if(ptr != ((void *)0)){
        while(ptr->next != ((void *)0)){
            ptr = ptr->next;
        }
        ptr->next = node;
        if(node->before != ((void *)0)){
            node->before->next = ((void *)0);
        }else{
            list[node->cur_addr] = ((void *)0);
        }
        node->before = ptr;
    }else{
        list[addr_num] = node;
        if(node->before != ((void *)0)){
            node->before->next = ((void *)0);
        }
        node->before = ((void *)0);
    }
    while(node != ((void *)0)){
        node->cur_addr = addr_num;
        node = node->next;
    }
}

canonical_original_code:
void move(struct Block_struct *node, int addr_num){
    struct Block_struct *ptr = list[addr_num];
    if(ptr != ((void *)0)){
        while(ptr->next != ((void *)0)){
            ptr = ptr->next;
        }
        ptr->next = node;
        if(node->before != ((void *)0)){
            node->before->next = ((void *)0);
        }else{
            list[node->cur_addr] = ((void *)0);
        }
        node->before = ptr;
    }else{
        list[addr_num] = node;
        if(node->before != ((void *)0)){
            node->before->next = ((void *)0);
        }
        node->before = ((void *)0);
    }
    while(node != ((void *)0)){
        node->cur_addr = addr_num;
        node = node->next;
    }
}

user_defined_types: struct Block_struct { int num; int cur_addr; struct Block_struct *next; struct Block_struct *before; }


rollback

decompiled_code:
__int64 __fastcall rollback(__int64 a1)
{
__int64 i; // rcx
__int64 result; // rax

for ( i = *(_QWORD *)(a1 + 8); i; i = *(_QWORD *)(i + 8) )
{
if ( *(_DWORD *)i != *(_DWORD *)(i + 4) )
result = move(i, *(_DWORD *)i);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 i; // rcx
__int64 result; // rax

for ( i = *(_QWORD *)(a1 + 8); i; i = *(_QWORD *)(i + 8) )
{
if ( *(_DWORD *)i != *(_DWORD *)(i + 4) )
result = func8(i, *(_DWORD *)i);
}
return result;
}

original_code:
void rollback(Blocks *node){
    Blocks *ptr = node->next;
    while(ptr != ((void *)0)){
        if(ptr->num != ptr->cur_addr){
            move(ptr , ptr->num);
        }
        ptr = ptr->next;
    }
}

canonical_original_code:
void rollback(struct Block_struct *node){
    struct Block_struct *ptr = node->next;
    while(ptr != ((void *)0)){
        if(ptr->num != ptr->cur_addr){
            move(ptr , ptr->num);
        }
        ptr = ptr->next;
    }
}


original_code:
void init_list(){
    int i = 0 ;
    for(i = 0 ; i < total ; i++){
        Blocks *block = (Blocks *)malloc(sizeof(Blocks));
        block->num = i;
        block->cur_addr = i;
        block->next = ((void *)0);
        block->before = ((void *)0);
        list[i] = block;
    }
}

canonical_original_code:
void init_list(){
    int i = 0;
    for(i = 0 ; i < total ; i++){
        struct Block_struct *block = (Blocks *)malloc(sizeof(Blocks));
        block->num = i;
        block->cur_addr = i;
        block->next = ((void *)0);
        block->before = ((void *)0);
        list[i] = block;
    }
}

variable_types: i int


display

decompiled_code:
int display()
{
int result; // eax
__int64 v1; // rbp
unsigned int *i; // rbx

result = total;
if ( total > 0 )
{
v1 = 0LL;
do
{
printf("%d:", (unsigned int)v1);
for ( i = (unsigned int *)list[v1]; i; i = (unsigned int *)*((_QWORD *)i + 1) )
printf(" %d", *i);
++v1;
result = putchar(10);
}
while ( total > (int)v1 );
}
return result;
}

canonical_decompiled_code:
int func11()
{
int result; // eax
__int64 v1; // rbp
unsigned int *i; // rbx

result = total;
if ( total > 0 )
{
v1 = 0LL;
do
{
printf("%d:", (unsigned int)v1);
for ( i = (unsigned int *)list[v1]; i; i = (unsigned int *)*((_QWORD *)i + 1) )
printf(" %d", *i);
++v1;
result = putchar(10);
}
while ( total > (int)v1 );
}
return result;
}

original_code:
void display(){
    int temp , i;
    Blocks *ptr = ((void *)0);
    for(i = 0 ; i <total ; i++){
        printf("%d:" , i);
        ptr = list[i];
        while(ptr != ((void *)0)){
            printf(" %d" , ptr->num);
            ptr = ptr->next;
        }
        printf("\n");
    }
}

canonical_original_code:
void display(){
    int temp; int i;
    struct Block_struct *ptr = ((void *)0);
    for(i = 0 ; i <total ; i++){
        printf("%d:" , i);
        ptr = list[i];
        while(ptr != ((void *)0)){
            printf(" %d" , ptr->num);
            ptr = ptr->next;
        }
        printf("\n");
    }
}


main

canonical_name: main

original_code:
int main(){
    while(scanf("%d" , &total) == 1){
        if((total >= 0) && (total < 25)){
            break;
        }
    }
    init_list();
    char act[5] , kind[5];
    int a , b , cmd;
    while(scanf("%s" , act) == 1){
        if(act[0] == 'q'){
            break;
        }else{
            scanf("%d %s %d" , &a , kind , &b);
            if((a == b ) || ((a > total) && (b > total))){
                continue;
            }
            Blocks *a_block = find_node(a);
            Blocks *b_block = find_node(b);
            if(a_block->cur_addr == b_block->cur_addr){
                continue;
            }
            if(act[0] == 'm'){
                cmd = 10;
            }else{
                cmd = 20;
            }
            if(kind[1] == 'n'){
                cmd += 1;
            }else{
                cmd += 2;
            }
            switch(cmd){
                case 11:
                    rollback(a_block);
                    rollback(b_block);
                    break;
                case 12:
                    rollback(a_block);
                    break;
                case 21:
                    rollback(b_block);
                    break;
                case 22:
                    break;
            }
            move(a_block , b_block->cur_addr);
        }
    }
    display();
    return 0;
}

canonical_original_code:
int main(){
    while(scanf("%d" , &total) == 1){
        if((total >= 0) && (total < 25)){
            break;
        }
    }
    init_list();
    char act[5]; char kind[5];
    int a; int b; int cmd;
    while(scanf("%s" , act) == 1){
        if(act[0] == 'q'){
            break;
        }else{
            scanf("%d %s %d" , &a , kind , &b);
            if((a == b ) || ((a > total) && (b > total))){
                continue;
            }
            struct Block_struct *a_block = find_node(a);
            struct Block_struct *b_block = find_node(b);
            if(a_block->cur_addr == b_block->cur_addr){
                continue;
            }
            if(act[0] == 'm'){
                cmd = 10;
            }else{
                cmd = 20;
            }
            if(kind[1] == 'n'){
                cmd += 1;
            }else{
                cmd += 2;
            }
            switch(cmd){
                case 11:
                    rollback(a_block);
                    rollback(b_block);
                    break;
                case 12:
                    rollback(a_block);
                    break;
                case 21:
                    rollback(b_block);
                    break;
                case 22:
                    break;
            }
            move(a_block , b_block->cur_addr);
        }
    }
    display();
    return 0;
}

variable_types:
act
char [5]

variable_types:
kind
char [5]

variable_types: a int

variable_types: b int

variable_types: cmd int


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

for ( result = 1LL; a1 != 1; a1 /= 2 )
{
while ( (a1 & 1) != 0 )
{
a1 = 3 * a1 + 1;
result = (unsigned int)(result + 1);
if ( a1 == 1 )
return result;
}
result = (unsigned int)(result + 1);
}
return result;
}

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

for ( result = 1LL; a1 != 1; a1 /= 2 )
{
while ( (a1 & 1) != 0 )
{
a1 = 3 * a1 + 1;
result = (unsigned int)(result + 1);
if ( a1 == 1 )
return result;
}
result = (unsigned int)(result + 1);
}
return result;
}

original_code:
int cycle_length(int num){
    int count = 1 ;
    while(num != 1){
        if(num % 2){
            num = (num * 3) + 1;
        }else{
            num = num / 2;
        }
        count += 1;
    }
    return count;
}

canonical_original_code:
int cycle_length(int num){
    int count = 1;
    while(num != 1){
        if(num % 2){
            num = (num * 3) + 1;
        }else{
            num = num / 2;
        }
        count += 1;
    }
    return count;
}

variable_types: num int

variable_types: count int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er10
unsigned int v4; // er9
int v5; // ecx
int v6; // esi
__int64 v7; // rsi
int v8; // eax
int v9; // ecx
unsigned int v10; // er8
int v12; // [rsp+8h] [rbp-10h] BYREF
int v13; // [rsp+Ch] [rbp-Ch] BYREF

v12 = 0;
v13 = 0;
while ( scanf("%d %d", &v12, &v13) == 2 )
{
v3 = v13;
v4 = v12;
v5 = v12;
v6 = v12;
if ( v13 <= v12 )
v5 = v13;
if ( v13 >= v12 )
v6 = v13;
if ( v5 > v6 )
{
v10 = 0;
}
else
{
v7 = (unsigned int)(v6 + 1);
do
{
v8 = cycle_length((unsigned int)v5, v7);
if ( (int)v10 < v8 )
v10 = v8;
v5 = v9 + 1;
}
while ( (_DWORD)v7 != v5 );
}
printf("%d %d %d\n", v4, v3, v10);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er10
unsigned int v4; // er9
int v5; // ecx
int v6; // esi
__int64 v7; // rsi
int v8; // eax
int v9; // ecx
unsigned int v10; // er8
int v12; // [rsp+8h] [rbp-10h] BYREF
int v13; // [rsp+Ch] [rbp-Ch] BYREF

v12 = 0;
v13 = 0;
while ( scanf("%d %d", &v12, &v13) == 2 )
{
v3 = v13;
v4 = v12;
v5 = v12;
v6 = v12;
if ( v13 <= v12 )
v5 = v13;
if ( v13 >= v12 )
v6 = v13;
if ( v5 > v6 )
{
v10 = 0;
}
else
{
v7 = (unsigned int)(v6 + 1);
do
{
v8 = func7((unsigned int)v5, v7);
if ( (int)v10 < v8 )
v10 = v8;
v5 = v9 + 1;
}
while ( (_DWORD)v7 != v5 );
}
printf("%d %d %d\n", v4, v3, v10);
}
return 0;
}

original_code:
int main(){
    int num1 = 0, num2 = 0 , i = 0 , bg = 0 , temp = 0;
    while(scanf("%d %d" , &num1 , &num2) == 2){
        bg = 0;
        for(i = (((num1) < (num2)) ? (num1) : (num2)) ; i <= (((num1) > (num2)) ? (num1) : (num2)) ; i++){
            temp = cycle_length(i);
            if(bg < temp){
                bg = temp;
            }
        }
        printf("%d %d %d\n" ,num1 , num2 , bg);
    }
    return 0;
}

canonical_original_code:
int main(){
    int num1 = 0; int num2 = 0; int i = 0; int bg = 0; int temp = 0;
    while(scanf("%d %d" , &num1 , &num2) == 2){
        bg = 0;
        for(i = (((num1) < (num2)) ? (num1) : (num2)) ; i <= (((num1) > (num2)) ? (num1) : (num2)) ; i++){
            temp = cycle_length(i);
            if(bg < temp){
                bg = temp;
            }
        }
        printf("%d %d %d\n" ,num1 , num2 , bg);
    }
    return 0;
}

variable_types: bg int


original_code:
double prior_prob (char state_i, char state_j) {
    return -1.3862943611198906;
}

canonical_original_code:
double prior_prob(char state_i, char state_j) {
    return -1.3862943611198906;
}

return_type: double


decompiled_code:
double __fastcall transition_prob(unsigned __int8 a1, unsigned __int8 a2)
{
double result; // xmm0_8

if ( !(a1 | a2) )
return *(double *)&transition_null_to_null;
if ( !a1 && a2 )
return *(double *)&transition_null_to_signal;
if ( !a2 && a1 )
return *(double *)&transition_signal_to_null;
if ( a1 != a2 )
goto LABEL_13;
if ( a1 )
return *(double *)&transition_signal_to_signal;
if ( a2 )
{
LABEL_13:
if ( a1 )
result = *(double *)&transition_signal_to_other_signal;
}
return result;
}

canonical_decompiled_code:
double __fastcall func8(unsigned __int8 a1, unsigned __int8 a2)
{
double result; // xmm0_8

if ( !(a1 | a2) )
return *(double *)&transition_null_to_null;
if ( !a1 && a2 )
return *(double *)&transition_null_to_signal;
if ( !a2 && a1 )
return *(double *)&transition_signal_to_null;
if ( a1 != a2 )
goto LABEL_13;
if ( a1 )
return *(double *)&transition_signal_to_signal;
if ( a2 )
{
LABEL_13:
if ( a1 )
result = *(double *)&transition_signal_to_other_signal;
}
return result;
}

original_code:
double transition_prob (char state_i, char state_j) {
    if (state_i == 0 && state_j == 0)
        return transition_null_to_null;
    else if (state_i == 0 && state_j != 0)
        return transition_null_to_signal;
    else if (state_i != 0 && state_j == 0)
        return transition_signal_to_null;
    else if (state_i != 0 && state_i == state_j)
        return transition_signal_to_signal;
    else if (state_i != 0 && state_i != state_j)
        return transition_signal_to_other_signal;
}

canonical_original_code:
double transition_prob(char state_i, char state_j) {
    if (state_i == 0 && state_j == 0)
        return transition_null_to_null;
    else if (state_i == 0 && state_j != 0)
        return transition_null_to_signal;
    else if (state_i != 0 && state_j == 0)
        return transition_signal_to_null;
    else if (state_i != 0 && state_i == state_j)
        return transition_signal_to_signal;
    else if (state_i != 0 && state_i != state_j)
        return transition_signal_to_other_signal;
}


decompiled_code:
double __fastcall emission_prob(char a1, char a2)
{
double result; // xmm0_8

if ( a1 == 88 && a2 == 88 )
return *(double *)&emission_null_to_null;
if ( a2 != 88 && a1 == 88 )
return *(double *)&emission_null_to_signal;
if ( a2 == 88 && a1 != 88 )
return *(double *)&emission_signal_to_null;
if ( a1 == a2 && a1 != 88 )
return *(double *)&emission_signal_to_signal;
if ( a1 != 88 )
result = *(double *)&emission_signal_to_other_signal;
return result;
}

canonical_decompiled_code:
double __fastcall func9(char a1, char a2)
{
double result; // xmm0_8

if ( a1 == 88 && a2 == 88 )
return *(double *)&emission_null_to_null;
if ( a2 != 88 && a1 == 88 )
return *(double *)&emission_null_to_signal;
if ( a2 == 88 && a1 != 88 )
return *(double *)&emission_signal_to_null;
if ( a1 == a2 && a1 != 88 )
return *(double *)&emission_signal_to_signal;
if ( a1 != 88 )
result = *(double *)&emission_signal_to_other_signal;
return result;
}

original_code:
double emission_prob (char observation, char state) {
    if (observation == 'X' && state == observation)
        return emission_null_to_null;
    if (observation == 'X' && state != 'X')
        return emission_null_to_signal;
    if (observation != 'X' && state == 'X')
        return emission_signal_to_null;
    if (observation != 'X' && state == observation)
        return emission_signal_to_signal;
    if (observation != 'X' && observation != 'X')
        return emission_signal_to_other_signal;
}

canonical_original_code:
double emission_prob(char observation, char state) {
    if (observation == 'X' && state == observation)
        return emission_null_to_null;
    if (observation == 'X' && state != 'X')
        return emission_null_to_signal;
    if (observation != 'X' && state == 'X')
        return emission_signal_to_null;
    if (observation != 'X' && state == observation)
        return emission_signal_to_signal;
    if (observation != 'X' && observation != 'X')
        return emission_signal_to_other_signal;
}

variable_types: observation char

variable_types: state char


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int64 v4; // [rsp+0h] [rbp-18h] BYREF
__int64 v5; // [rsp+8h] [rbp-10h] BYREF

v4 = 0LL;
if ( (unsigned int)(argc - 1) > 1 )
__assert_fail("argc == 2 || argc == 1", "main.c", 8u, "main");
if ( argc == 2 )
{
v4 = strtoull(argv[1], 0LL, 10);
}
else
{
while ( !(unsigned int)__isoc99_scanf() )
{
while ( getchar() != 10 )
;
puts("Bad Input\n");
}
}
if ( v4 <= 1 )
__assert_fail("temp >= 2", "main.c", 0x10u, "main");
printf("%llu=", v4);
while ( !(unsigned __int8)isprime(v4) )
{
prime(&v4, &v5);
printf("%llu*", v5);
}
printf("%llu\n", v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int64 v4; // [rsp+0h] [rbp-18h] BYREF
__int64 v5; // [rsp+8h] [rbp-10h] BYREF

v4 = 0LL;
if ( (unsigned int)(argc - 1) > 1 )
__assert_fail("argc == 2 || argc == 1", "main.c", 8u, "main");
if ( argc == 2 )
{
v4 = strtoull(argv[1], 0LL, 10);
}
else
{
while ( !(unsigned int)__isoc99_scanf() )
{
while ( getchar() != 10 )
;
puts("Bad Input\n");
}
}
if ( v4 <= 1 )
__assert_fail("temp >= 2", "main.c", 0x10u, "main");
printf("%llu=", v4);
while ( !(unsigned __int8)func7(v4) )
{
func8(&v4, &v5);
printf("%llu*", v5);
}
printf("%llu\n", v4);
return 0;
}

original_code:
int main(int argc,char* argv[]){
 bigint temp=0,output;
 ((void) sizeof ((argc == 2 || argc == 1) ? 1 : 0), __extension__ ({ if (argc == 2 || argc == 1) ; else __assert_fail ("argc == 2 || argc == 1", "main.c", 8, __extension__ __PRETTY_FUNCTION__); }));
 if(argc == 2)
  temp=strtoull(argv[1],((void *)0),10);
 else
  while(!scanf("%llu",&temp)){
   while(getchar() != '\n');
   printf("Bad Input\n\n");
  }
 ((void) sizeof ((temp >= 2) ? 1 : 0), __extension__ ({ if (temp >= 2) ; else __assert_fail ("temp >= 2", "main.c", 16, __extension__ __PRETTY_FUNCTION__); }));
 printf("%llu=",temp);
 while(!isprime(temp)){
  prime(&temp,&output);
  printf("%llu*",output);
 }
 printf("%llu\n",temp);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
 unsigned long long temp = 0; unsigned long long output;
 ((void) sizeof ((argc == 2 || argc == 1) ? 1 : 0), __extension__ ({ if (argc == 2 || argc == 1) ; else __assert_fail ("argc == 2 || argc == 1", "main.c", 8, __extension__ __PRETTY_FUNCTION__); }));
 if(argc == 2)
  temp=strtoull(argv[1],((void *)0),10);
 else
  while(!scanf("%llu",&temp)){
   while(getchar() != '\n');
   printf("Bad Input\n\n");
  }
 ((void) sizeof ((temp >= 2) ? 1 : 0), __extension__ ({ if (temp >= 2) ; else __assert_fail ("temp >= 2", "main.c", 16, __extension__ __PRETTY_FUNCTION__); }));
 printf("%llu=",temp);
 while(!isprime(temp)){
  prime(&temp,&output);
  printf("%llu*",output);
 }
 printf("%llu\n",temp);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
temp
unsigned long long

variable_types:
output
unsigned long long


repo: aHelmutSieber/test

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
myPrintHelloMake(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7(argc, argv, envp);
return 0;
}

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


myPrintHelloMake

decompiled_code:
int myPrintHelloMake()
{
puts("[Info] Testing Jenkins");
return puts("[Info] binary ok!");
}

canonical_decompiled_code:
int func7()
{
puts("[Info] Testing Jenkins");
return puts("[Info] binary ok!");
}

original_code:
void myPrintHelloMake(void) {
  printf("[Info] Testing Jenkins\n");
  printf("[Info] binary ok!\n");
  return;
}

canonical_original_code:
void myPrintHelloMake() {
  printf("[Info] Testing Jenkins\n");
  printf("[Info] binary ok!\n");
  return;
}


InitIDTDescriptor

repo: aaSSfxxx/MIAOS

decompiled_code:
void __fastcall InitIDTDescriptor(unsigned __int8 a1, int a2, __int16 a3, char a4)
{
kidt[4 * a1] = a2;
kidt[4 * a1 + 3] = HIWORD(a2);
kidt[4 * a1 + 1] = a3;
HIBYTE(kidt[4 * a1 + 2]) = a4;
LOBYTE(kidt[4 * a1 + 2]) = 0;
}

canonical_decompiled_code:
void __fastcall func0(unsigned __int8 a1, int a2, __int16 a3, char a4)
{
kidt[4 * a1] = a2;
kidt[4 * a1 + 3] = HIWORD(a2);
kidt[4 * a1 + 1] = a3;
HIBYTE(kidt[4 * a1 + 2]) = a4;
LOBYTE(kidt[4 * a1 + 2]) = 0;
}

original_code:
void InitIDTDescriptor (BYTE index,
                        DWORD dwBase,
                        WORD wSelector,
                        BYTE bFlags)
{
    kidt[index].BaseLower = (dwBase & 0xFFFF);
    kidt[index].BaseHigher = (dwBase >> 16) & 0xFFFF;
    kidt[index].Selector = wSelector;
    kidt[index].Flags = bFlags;
    kidt[index].Reserved = 0;
}

canonical_original_code:
void InitIDTDescriptor(unsigned char index, unsigned int dwBase, unsigned short wSelector, unsigned char bFlags)
{
    kidt[index].BaseLower = (dwBase & 0xFFFF);
    kidt[index].BaseHigher = (dwBase >> 16) & 0xFFFF;
    kidt[index].Selector = wSelector;
    kidt[index].Flags = bFlags;
    kidt[index].Reserved = 0;
}

variable_types:
index
unsigned char

variable_types:
dwBase
unsigned int

variable_types:
wSelector
unsigned short

variable_types:
bFlags
unsigned char


LoadIDT

decompiled_code:
void LoadIDT()
{
void *v0; // r8
int v1; // eax
__int16 v2; // dx
char v3; // cl
int v4; // eax
int v5; // eax
__int16 v6; // dx
char v7; // cl
int v8; // eax
__int16 v9; // dx
char v10; // cl
int v11; // eax
__int16 v12; // dx
char v13; // cl
int v14; // eax
__int16 v15; // dx
char v16; // cl
int v17; // eax
__int16 v18; // dx
char v19; // cl
__int16 v20; // ax
__int16 v21; // dx
char v22; // cl
int v23; // eax
__int16 v24; // dx
char v25; // cl

v0 = &default_isr;
LOBYTE(v1) = 0;
do
{
InitIDTDescriptor(v1, (int)v0, 8, 142);
v1 = v4 + 1;
}
while ( v1 != 32 );
InitIDTDescriptor(8u, (int)&isr8, v2, v3);
InitIDTDescriptor(0xAu, v5, v6, v7);
InitIDTDescriptor(0xBu, v8, v9, v10);
InitIDTDescriptor(0xCu, v11, v12, v13);
InitIDTDescriptor(0xDu, v14, v15, v16);
InitIDTDescriptor(0xEu, v17, v18, v19);
*(_WORD *)kidtr = v20;
*(_DWORD *)&kidtr[2] = (_DWORD)kidt;
__lidt(kidtr);
InitIDTDescriptor(0x20u, (int)&isr32, v21, v22);
InitIDTDescriptor(0x80u, v23, v24, v25);
__asm { int 80h; LINUX - }
}

original_code:
void LoadIDT (void)
{
    int i;
    for(i=0; i<32; i++) {
      InitIDTDescriptor(i, (DWORD)default_isr, 0x08, 0x8E);
    }
    InitIDTDescriptor( 8, (DWORD)isr8 , 0x08, 0x8E);
    InitIDTDescriptor( 10, (DWORD)isr10 , 0x08, 0x8E);
    InitIDTDescriptor( 11, (DWORD)isr11 , 0x08, 0x8E);
    InitIDTDescriptor( 12, (DWORD)isr12 , 0x08, 0x8E);
    InitIDTDescriptor( 13, (DWORD)isr13 , 0x08, 0x8E);
    InitIDTDescriptor( 14, (DWORD)isr14 , 0x08, 0x8E);
    kidtr.Limit = sizeof(IDT_DESCRIPTOR) * 256 -1;
    kidtr.Base = (DWORD)kidt;
    asm ("lidt (kidtr)");
 InitIDTDescriptor( 32, (DWORD)isr32 , 0x08, 0x8E);
    InitIDTDescriptor( 0x80, (DWORD)isr0x80 , 0x08, 0x8E);
 asm ("int $0x80");
}

canonical_original_code:
void LoadIDT()
{
    int i;
    for(i=0; i<32; i++) {
      InitIDTDescriptor(i, (unsigned int)default_isr, 0x08, 0x8E);
    }
    InitIDTDescriptor( 8, (unsigned int)isr8 , 0x08, 0x8E);
    InitIDTDescriptor( 10, (unsigned int)isr10 , 0x08, 0x8E);
    InitIDTDescriptor( 11, (unsigned int)isr11 , 0x08, 0x8E);
    InitIDTDescriptor( 12, (unsigned int)isr12 , 0x08, 0x8E);
    InitIDTDescriptor( 13, (unsigned int)isr13 , 0x08, 0x8E);
    InitIDTDescriptor( 14, (unsigned int)isr14 , 0x08, 0x8E);
    kidtr.Limit = sizeof(IDT_DESCRIPTOR) * 256 -1;
    kidtr.Base = (unsigned int)kidt;
    asm ("lidt (kidtr)");
 InitIDTDescriptor( 32, (unsigned int)isr32 , 0x08, 0x8E);
    InitIDTDescriptor( 0x80, (unsigned int)isr0x80 , 0x08, 0x8E);
 asm ("int $0x80");
}

variable_types: i int


UserInterrupt

decompiled_code:
__int64 __fastcall UserInterrupt(__int64 a1)
{
return printk("Interrupt %d called \n", *(unsigned int *)(a1 + 36));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return printk("Interrupt %d called \n", *(unsigned int *)(a1 + 36));
}

original_code:
void UserInterrupt (REGISTERS *pRegisters) {
  printk("Interrupt %d called \n", pRegisters->IntNum);
}

canonical_original_code:
void UserInterrupt(struct registers *pRegisters) {
  printk("Interrupt %d called \n", pRegisters->IntNum);
}

variable_types: struct registers { unsigned int DS; unsigned int EDI; unsigned int IntNum; unsigned int EIP; } *


ISRExceptHandler

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

result = printk("Error %d got \n", *(unsigned int *)(a1 + 36));
if ( *(_DWORD *)(a1 + 36) == 13 )
result = printk("Unhandled interrupt \n");
return result;
}

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

result = printk("Error %d got \n", *(unsigned int *)(a1 + 36));
if ( *(_DWORD *)(a1 + 36) == 13 )
result = printk("Unhandled interrupt \n");
return result;
}

original_code:
void ISRExceptHandler (REGISTERS *pRegisters)
{
    printk("Error %d got \n", pRegisters->IntNum);
    if (pRegisters->IntNum == 13) {
      printk ("Unhandled interrupt \n");
    }
}

canonical_original_code:
void ISRExceptHandler(struct registers *pRegisters)
{
    printk("Error %d got \n", pRegisters->IntNum);
    if (pRegisters->IntNum == 13) {
      printk ("Unhandled interrupt \n");
    }
}

user_defined_types: struct registers { unsigned int DS; unsigned int EDI; unsigned int IntNum; unsigned int EIP; }


ISRDispatcher

decompiled_code:
__int64 __fastcall ISRDispatcher(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7, int a8, int a9, int a10, __int64 a11)
{
__int64 result; // rax

if ( HIDWORD(a11) <= 0x1F )
result = ISRExceptHandler((__int64)&a7);
else
result = UserInterrupt((__int64)&a7);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7, int a8, int a9, int a10, __int64 a11)
{
__int64 result; // rax

if ( HIDWORD(a11) <= 0x1F )
result = func3((__int64)&a7);
else
result = func2((__int64)&a7);
return result;
}

original_code:
void ISRDispatcher (REGISTERS Registers)
{
  if(Registers.IntNum > 31) {
    UserInterrupt (&Registers);
  }
  else {
    ISRExceptHandler(&Registers);
  }
}

canonical_original_code:
void ISRDispatcher(struct registers Registers)
{
  if(Registers.IntNum > 31) {
    UserInterrupt (&Registers);
  }
  else {
    ISRExceptHandler(&Registers);
  }
}

variable_types: struct registers { unsigned int DS; unsigned int EDI; unsigned int IntNum; unsigned int EIP; }


ClockTick

decompiled_code:
__int64 ClockTick()
{
return printk(".");
}

canonical_decompiled_code:
__int64 func5()
{
return printk(".");
}

original_code:
void ClockTick(void) {
  printk (".");
}

canonical_original_code:
void ClockTick() {
  printk (".");
}


KeyboardHandler

decompiled_code:
__int64 KeyboardHandler()
{
return printk("Keyboard \n");
}

canonical_decompiled_code:
__int64 func6()
{
return printk("Keyboard \n");
}

original_code:
void KeyboardHandler (void) {
 printk ("Keyboard \n");
}

canonical_original_code:
void KeyboardHandler() {
 printk ("Keyboard \n");
}


OkMsg

decompiled_code:
__int64 OkMsg()
{
return printk(&unk_E6);
}

canonical_decompiled_code:
__int64 func0()
{
return printk(&unk_E6);
}

original_code:
void OkMsg(void)
{
 printk("OK\n");
}

canonical_original_code:
void OkMsg()
{
 printk("OK\n");
}


InitPIC

decompiled_code:
__int64 InitPIC()
{
printk("Initialize PIC\n");
__outbyte(0x20u, 0x11u);
__outbyte(0xA0u, 0x11u);
__outbyte(0x21u, 0x20u);
__outbyte(0xA1u, 0x70u);
__outbyte(0x21u, 4u);
__outbyte(0xA1u, 2u);
__outbyte(0x21u, 1u);
__outbyte(0xA1u, 1u);
__outbyte(0x21u, 0);
__outbyte(0xA1u, 0);
return printk("PIC configured (or not :') ) \n");
}

canonical_decompiled_code:
__int64 func1()
{
printk("Initialize PIC\n");
__outbyte(0x20u, 0x11u);
__outbyte(0xA0u, 0x11u);
__outbyte(0x21u, 0x20u);
__outbyte(0xA1u, 0x70u);
__outbyte(0x21u, 4u);
__outbyte(0xA1u, 2u);
__outbyte(0x21u, 1u);
__outbyte(0xA1u, 1u);
__outbyte(0x21u, 0);
__outbyte(0xA1u, 0);
return printk("PIC configured (or not :') ) \n");
}

original_code:
void InitPIC(void)
{
 printk ("Initialize PIC\n");
 asm volatile ("outb %%al, %%dx" :: "d" (0x20), "a" (0x11));;
 asm volatile ("outb %%al, %%dx" :: "d" (0xA0), "a" (0x11));;
 asm volatile ("outb %%al, %%dx" :: "d" (0x21), "a" (0x20));;
 asm volatile ("outb %%al, %%dx" :: "d" (0xA1), "a" (0x70));;
 asm volatile ("outb %%al, %%dx" :: "d" (0x21), "a" (0x04));;
 asm volatile ("outb %%al, %%dx" :: "d" (0xA1), "a" (0x02));;
 asm volatile ("outb %%al, %%dx" :: "d" (0x21), "a" (0x01));;
 asm volatile ("outb %%al, %%dx" :: "d" (0xA1), "a" (0x01));;
 asm volatile ("outb %%al, %%dx" :: "d" (0x21), "a" (0x0));;
 asm volatile ("outb %%al, %%dx" :: "d" (0xA1), "a" (0x0));;
 printk ("PIC configured (or not :') ) \n");
}


kmain

decompiled_code:
void __fastcall __noreturn kmain(__int64 a1)
{
printk("RAM detected : %uk (lower), %uk (upper)\n", *(_QWORD *)(a1 + 8), *(_QWORD *)(a1 + 16));
printk("Command line got: %s \n", *(const char **)(a1 + 32));
printk("Initialize GDT ... ");
InitGDT();
OkMsg();
LoadIDT();
printk(aIdtLoaded);
InitPIC();
_enable();
while ( 1 )
;
}

canonical_decompiled_code:
void __fastcall __noreturn func2(__int64 a1)
{
printk("RAM detected : %uk (lower), %uk (upper)\n", *(_QWORD *)(a1 + 8), *(_QWORD *)(a1 + 16));
printk("Command line got: %s \n", *(const char **)(a1 + 32));
printk("Initialize GDT ... ");
InitGDT();
func0();
LoadIDT();
printk(aIdtLoaded);
func1();
_enable();
while ( 1 )
;
}

original_code:
void kmain(struct mb_partial_info *mbi)
{
    printk("RAM detected : %uk (lower), %uk (upper)\n", mbi->low_mem, mbi->high_mem);
    printk("Command line got: %s \n", mbi->cmdline);
 printk ("Initialize GDT ... ");
 InitGDT();
    asm("   movw $0x18, %ax \n                 movw %ax, %ss \n                 movl $0x1FFF0, %esp");
 OkMsg();
 LoadIDT();
    printk ("IDT loaded  éè\n");
    InitPIC();
 asm("sti"::);
 while(1) { }
}

variable_types: struct mb_partial_info { unsigned long flags; unsigned long low_mem; unsigned long high_mem; unsigned long boot_device; unsigned long cmdline; } *


repo: aantn/littler-snitch

decompiled_code:
__int64 __fastcall write_data(const void *a1, size_t a2, size_t a3, FILE *a4)
{
return (int)fwrite(a1, a2, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func7(const void *a1, size_t a2, size_t a3, FILE *a4)
{
return (int)fwrite(a1, a2, a3, a4);
}

original_code:
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
    int written = fwrite(ptr, size, nmemb, (FILE *)stream);
    return written;
}

canonical_original_code:
static unsigned long write_data(void *ptr, unsigned long size, unsigned long nmemb, void *stream)
{
    int written = fwrite(ptr, size, nmemb, (FILE *)stream);
    return written;
}

variable_types:
ptr
void *

variable_types:
size
unsigned long

variable_types:
nmemb
unsigned long

variable_types:
stream
void *

variable_types: written int

return_type: unsigned long


push

repo: aap/abc

decompiled_code:
int push()
{
return printf("\tpush\t%%eax\n");
}

canonical_decompiled_code:
int func0()
{
return printf("\tpush\t%%eax\n");
}

original_code:
void
push(void)
{
 printf("\tpush\t%%eax\n");
}

canonical_original_code:
void push()
{
 printf("\tpush\t%%eax\n");
}


pop

decompiled_code:
int __fastcall pop(const char *a1)
{
return printf("\tpop\t%%%s\n", a1);
}

canonical_decompiled_code:
int __fastcall func1(const char *a1)
{
return printf("\tpop\t%%%s\n", a1);
}

original_code:
void
pop(char *s)
{
 printf("\tpop\t%%%s\n", s);
}

variable_types:
s
char *