decompiled_code:
__int64 isaac_calc()
{
unsigned __int8 v0; // al
int v1; // esi
int v2; // er8
__int64 result; // rax
unsigned int v4; // edx
unsigned int v5; // esi
unsigned int v6; // ecx
int v7; // er8
unsigned int v8; // ecx
int v9; // edi
unsigned int v10; // edx
int v11; // er8
unsigned int v12; // edx
unsigned int v13; // edi
unsigned int v14; // ecx
int v15; // er8
unsigned int v16; // ecx
int v17; // edi
int v18; // ecx

v0 = LOBYTE(isaac_default_state[514]) + 1;
LOBYTE(isaac_default_state[514]) = v0;
v1 = isaac_default_state[512];
v2 = isaac_default_state[513] + v0;
for ( result = 0LL; result != 256; result += 4LL )
{
v4 = isaac_default_state[result];
v5 = isaac_default_state[(unsigned __int8)(result + 0x80)] + ((v1 << 13) ^ v1);
v6 = v2 + isaac_default_state[(unsigned __int8)(v4 >> 2)] + v5;
isaac_default_state[result] = v6;
v7 = isaac_default_state[(unsigned __int8)(v6 >> 10)] + v4;
isaac_default_state[result + 256] = v7;
v8 = isaac_default_state[result + 1];
v9 = isaac_default_state[(unsigned __int8)(result - 127)] + (v5 ^ (v5 >> 6));
v10 = v7 + isaac_default_state[(unsigned __int8)(v8 >> 2)] + v9;
isaac_default_state[result + 1] = v10;
v11 = isaac_default_state[(unsigned __int8)(v10 >> 10)] + v8;
isaac_default_state[result + 257] = v11;
v12 = isaac_default_state[result + 2];
v13 = isaac_default_state[(unsigned __int8)(result - 126)] + (v9 ^ (4 * v9));
v14 = v11 + isaac_default_state[(unsigned __int8)(v12 >> 2)] + v13;
isaac_default_state[result + 2] = v14;
v15 = isaac_default_state[(unsigned __int8)(v14 >> 10)] + v12;
isaac_default_state[result + 258] = v15;
v16 = isaac_default_state[result + 3];
v1 = isaac_default_state[(unsigned __int8)(result - 125)] + (v13 ^ HIWORD(v13));
v17 = isaac_default_state[(unsigned __int8)(v16 >> 2)] + v1;
isaac_default_state[result + 3] = v15 + v17;
v18 = isaac_default_state[(unsigned __int8)((unsigned int)(v15 + v17) >> 10)] + v16;
v2 = v18;
isaac_default_state[result + 259] = v18;
}
isaac_default_state[512] = v1;
isaac_default_state[513] = v18;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned __int8 v0; // al
int v1; // esi
int v2; // er8
__int64 result; // rax
unsigned int v4; // edx
unsigned int v5; // esi
unsigned int v6; // ecx
int v7; // er8
unsigned int v8; // ecx
int v9; // edi
unsigned int v10; // edx
int v11; // er8
unsigned int v12; // edx
unsigned int v13; // edi
unsigned int v14; // ecx
int v15; // er8
unsigned int v16; // ecx
int v17; // edi
int v18; // ecx

v0 = LOBYTE(isaac_default_state[514]) + 1;
LOBYTE(isaac_default_state[514]) = v0;
v1 = isaac_default_state[512];
v2 = isaac_default_state[513] + v0;
for ( result = 0LL; result != 256; result += 4LL )
{
v4 = isaac_default_state[result];
v5 = isaac_default_state[(unsigned __int8)(result + 0x80)] + ((v1 << 13) ^ v1);
v6 = v2 + isaac_default_state[(unsigned __int8)(v4 >> 2)] + v5;
isaac_default_state[result] = v6;
v7 = isaac_default_state[(unsigned __int8)(v6 >> 10)] + v4;
isaac_default_state[result + 256] = v7;
v8 = isaac_default_state[result + 1];
v9 = isaac_default_state[(unsigned __int8)(result - 127)] + (v5 ^ (v5 >> 6));
v10 = v7 + isaac_default_state[(unsigned __int8)(v8 >> 2)] + v9;
isaac_default_state[result + 1] = v10;
v11 = isaac_default_state[(unsigned __int8)(v10 >> 10)] + v8;
isaac_default_state[result + 257] = v11;
v12 = isaac_default_state[result + 2];
v13 = isaac_default_state[(unsigned __int8)(result - 126)] + (v9 ^ (4 * v9));
v14 = v11 + isaac_default_state[(unsigned __int8)(v12 >> 2)] + v13;
isaac_default_state[result + 2] = v14;
v15 = isaac_default_state[(unsigned __int8)(v14 >> 10)] + v12;
isaac_default_state[result + 258] = v15;
v16 = isaac_default_state[result + 3];
v1 = isaac_default_state[(unsigned __int8)(result - 125)] + (v13 ^ HIWORD(v13));
v17 = isaac_default_state[(unsigned __int8)(v16 >> 2)] + v1;
isaac_default_state[result + 3] = v15 + v17;
v18 = isaac_default_state[(unsigned __int8)((unsigned int)(v15 + v17) >> 10)] + v16;
v2 = v18;
isaac_default_state[result + 259] = v18;
}
isaac_default_state[512] = v1;
isaac_default_state[513] = v18;
return result;
}

original_code:
void isaac_calc()
{
    unsigned int i,x,y;
    unsigned int a,b;
    isaac_default_state.c++;
    a=isaac_default_state.a;
    b=isaac_default_state.b+isaac_default_state.c;
    for(i = 0; i < 256; i++)
    {
        x = isaac_default_state.wheel[i];
        a = (a^(a<<13)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x = isaac_default_state.wheel[i];
        a = (a^(a>>6)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x=isaac_default_state.wheel[i];
        a= (a^(a<<2)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x=isaac_default_state.wheel[i];
        a= (a^(a>>16)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
    }
    isaac_default_state.a=a;
    isaac_default_state.b=b;
}

canonical_original_code:
void isaac_calc()
{
    unsigned int i; unsigned int x; unsigned int y;
    unsigned int a; unsigned int b;
    isaac_default_state.c++;
    a=isaac_default_state.a;
    b=isaac_default_state.b+isaac_default_state.c;
    for(i = 0; i < 256; i++)
    {
        x = isaac_default_state.wheel[i];
        a = (a^(a<<13)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x = isaac_default_state.wheel[i];
        a = (a^(a>>6)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x=isaac_default_state.wheel[i];
        a= (a^(a<<2)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x=isaac_default_state.wheel[i];
        a= (a^(a>>16)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
    }
    isaac_default_state.a=a;
    isaac_default_state.b=b;
}

variable_types:
x
unsigned int

variable_types:
a
unsigned int


repo: Noxbru/Rands

decompiled_code:
void __fastcall isaac_clear_st(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func3(void *a1)
{
free(a1);
}

original_code:
inline void isaac_clear_st(isaac_state *st)
{
    free(st);
}

canonical_original_code:
inline void isaac_clear_st(struct _isaac_state *st)
{
    free(st);
}

variable_types: struct _isaac_state { unsigned int wheel[256]; unsigned int wheel2[256]; unsigned int a; unsigned char c; unsigned char index; } *

return_type: void


decompiled_code:
int __fastcall isaac_srand_st(__int64 a1, unsigned int a2)
{
int *v2; // rbx
int result; // eax

srand(a2);
v2 = (int *)a1;
do
{
result = rand();
*v2++ = result;
}
while ( v2 != (int *)(a1 + 1024) );
*(_DWORD *)(a1 + 2048) = 0;
*(_DWORD *)(a1 + 2052) = 0;
*(_BYTE *)(a1 + 2056) = 0;
*(_BYTE *)(a1 + 2057) = 0;
return result;
}

original_code:
void isaac_srand_st(isaac_state *st, unsigned long int seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 256; i++)
        st->wheel[i]=rand();
    st->a=0;
    st->b=0;
    st->c=0;
    st->index=0;
}

canonical_original_code:
void isaac_srand_st(struct _isaac_state *st, unsigned long seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 256; i++)
        st->wheel[i]=rand();
    st->a=0;
    st->b=0;
    st->c=0;
    st->index=0;
}

variable_types:
seed
unsigned long

variable_types:
i
unsigned int

user_defined_types: struct _isaac_state { unsigned int wheel[256]; unsigned int wheel2[256]; unsigned int a; unsigned char c; unsigned char index; }


decompiled_code:
unsigned int *__fastcall isaac_calc_st(__int64 a1)
{
unsigned __int8 v1; // al
int v2; // er8
int v3; // er10
unsigned int *result; // rax
int i; // esi
unsigned int v6; // edx
unsigned int v7; // er9
unsigned int v8; // ecx
unsigned int v9; // er10
unsigned int v10; // ecx
int v11; // er9
unsigned int v12; // edx
unsigned int v13; // er10
unsigned int v14; // edx
unsigned int v15; // er8
unsigned int v16; // ecx
unsigned int v17; // er9
unsigned int v18; // ecx
unsigned int v19; // edx
int v20; // ecx

v1 = *(_BYTE *)(a1 + 2056) + 1;
*(_BYTE *)(a1 + 2056) = v1;
v2 = *(_DWORD *)(a1 + 2048);
v3 = *(_DWORD *)(a1 + 2052) + v1;
result = (unsigned int *)a1;
for ( i = 128; i != 384; i += 4 )
{
v6 = *result;
v7 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)i) + ((v2 << 13) ^ v2);
v8 = v3 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(*result >> 2)) + v7;
*result = v8;
v9 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v8 >> 10)) + v6;
result[256] = v9;
v10 = result[1];
v11 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(i + 1)) + (v7 ^ (v7 >> 6));
v12 = v9 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v10 >> 2)) + v11;
result[1] = v12;
v13 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v12 >> 10)) + v10;
result[257] = v13;
v14 = result[2];
v15 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(i + 2)) + (v11 ^ (4 * v11));
v16 = v13 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v14 >> 2)) + v15;
result[2] = v16;
v17 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v16 >> 10)) + v14;
result[258] = v17;
v18 = result[3];
v2 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(i + 3)) + (HIWORD(v15) ^ v15);
v19 = v17 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v18 >> 2)) + v2;
result[3] = v19;
v20 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v19 >> 10)) + v18;
v3 = v20;
result[259] = v20;
result += 4;
}
*(_DWORD *)(a1 + 2048) = v2;
*(_DWORD *)(a1 + 2052) = v20;
return result;
}

canonical_decompiled_code:
unsigned int *__fastcall func5(__int64 a1)
{
unsigned __int8 v1; // al
int v2; // er8
int v3; // er10
unsigned int *result; // rax
int i; // esi
unsigned int v6; // edx
unsigned int v7; // er9
unsigned int v8; // ecx
unsigned int v9; // er10
unsigned int v10; // ecx
int v11; // er9
unsigned int v12; // edx
unsigned int v13; // er10
unsigned int v14; // edx
unsigned int v15; // er8
unsigned int v16; // ecx
unsigned int v17; // er9
unsigned int v18; // ecx
unsigned int v19; // edx
int v20; // ecx

v1 = *(_BYTE *)(a1 + 2056) + 1;
*(_BYTE *)(a1 + 2056) = v1;
v2 = *(_DWORD *)(a1 + 2048);
v3 = *(_DWORD *)(a1 + 2052) + v1;
result = (unsigned int *)a1;
for ( i = 128; i != 384; i += 4 )
{
v6 = *result;
v7 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)i) + ((v2 << 13) ^ v2);
v8 = v3 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(*result >> 2)) + v7;
*result = v8;
v9 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v8 >> 10)) + v6;
result[256] = v9;
v10 = result[1];
v11 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(i + 1)) + (v7 ^ (v7 >> 6));
v12 = v9 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v10 >> 2)) + v11;
result[1] = v12;
v13 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v12 >> 10)) + v10;
result[257] = v13;
v14 = result[2];
v15 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(i + 2)) + (v11 ^ (4 * v11));
v16 = v13 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v14 >> 2)) + v15;
result[2] = v16;
v17 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v16 >> 10)) + v14;
result[258] = v17;
v18 = result[3];
v2 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(i + 3)) + (HIWORD(v15) ^ v15);
v19 = v17 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v18 >> 2)) + v2;
result[3] = v19;
v20 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v19 >> 10)) + v18;
v3 = v20;
result[259] = v20;
result += 4;
}
*(_DWORD *)(a1 + 2048) = v2;
*(_DWORD *)(a1 + 2052) = v20;
return result;
}

variable_types:
y
unsigned int

variable_types:
b
unsigned int


SocketOpen

repo: NpoSaut/cSocketCanLib

decompiled_code:
__int64 __fastcall SocketOpen(char *src, int a2, int a3)
{
int v3; // eax
unsigned int v4; // ebx
int v6; // [rsp+8h] [rbp-80h] BYREF
int v7; // [rsp+Ch] [rbp-7Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-78h] BYREF
int v9; // [rsp+2Ch] [rbp-5Ch] BYREF
int v10; // [rsp+30h] [rbp-58h] BYREF
int v11; // [rsp+34h] [rbp-54h] BYREF
int v12; // [rsp+38h] [rbp-50h] BYREF
int optval; // [rsp+3Ch] [rbp-4Ch] BYREF
char dest[16]; // [rsp+40h] [rbp-48h] BYREF
int v15; // [rsp+50h] [rbp-38h]

v7 = a2;
v6 = a3;
v3 = socket(29, 3, 1);
if ( v3 < 0 )
return (unsigned int)(-100 * *_errno_location());
v4 = v3;
strcpy(dest, src);
ioctl(v4, 0x8933uLL, dest);
if ( v15 < 0 )
return (unsigned int)(-10000 * *_errno_location());
optval = 1;
setsockopt(v4, 101, 4, &optval, 4u);
v12 = 1;
if ( setsockopt(v4, 1, 37, &v12, 4u) < 0 )
{
perror("setsockopt SO_TIMESTAMPING");
v4 = -9;
}
else
{
v11 = 1;
if ( setsockopt(v4, 1, 29, &v11, 4u) < 0 )
{
perror("setsockopt SO_TIMESTAMP");
v4 = -10;
}
else
{
v10 = 511;
if ( setsockopt(v4, 101, 2, &v10, 4u) < 0 )
{
perror("setsockopt CAN_RAW_ERR_FILTER");
v4 = -11;
}
else
{
v7 *= 352;
v6 *= 352;
if ( setsockopt(v4, 1, 7, &v7, 4u) < 0 )
{
perror("setsockopt SO_SNDBUF");
v4 = -12;
}
else if ( setsockopt(v4, 1, 8, &v6, 4u) < 0 )
{
perror("setsockopt SO_RCVBUF");
v4 = -13;
}
else
{
v9 = 1;
if ( setsockopt(v4, 1, 40, &v9, 4u) < 0 )
{
perror("setsockopt SO_RXQ_OVFL");
v4 = -14;
}
else
{
*(_DWORD *)&addr.sa_family = 29;
*(_QWORD *)&addr.sa_data[6] = 0LL;
*(_DWORD *)&addr.sa_data[2] = v15;
if ( bind(v4, &addr, 0x10u) )
v4 = -1000000 * *_errno_location();
}
}
}
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src, int a2, int a3)
{
int v3; // eax
unsigned int v4; // ebx
int v6; // [rsp+8h] [rbp-80h] BYREF
int v7; // [rsp+Ch] [rbp-7Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-78h] BYREF
int v9; // [rsp+2Ch] [rbp-5Ch] BYREF
int v10; // [rsp+30h] [rbp-58h] BYREF
int v11; // [rsp+34h] [rbp-54h] BYREF
int v12; // [rsp+38h] [rbp-50h] BYREF
int optval; // [rsp+3Ch] [rbp-4Ch] BYREF
char dest[16]; // [rsp+40h] [rbp-48h] BYREF
int v15; // [rsp+50h] [rbp-38h]

v7 = a2;
v6 = a3;
v3 = socket(29, 3, 1);
if ( v3 < 0 )
return (unsigned int)(-100 * *_errno_location());
v4 = v3;
strcpy(dest, src);
ioctl(v4, 0x8933uLL, dest);
if ( v15 < 0 )
return (unsigned int)(-10000 * *_errno_location());
optval = 1;
setsockopt(v4, 101, 4, &optval, 4u);
v12 = 1;
if ( setsockopt(v4, 1, 37, &v12, 4u) < 0 )
{
perror("setsockopt SO_TIMESTAMPING");
v4 = -9;
}
else
{
v11 = 1;
if ( setsockopt(v4, 1, 29, &v11, 4u) < 0 )
{
perror("setsockopt SO_TIMESTAMP");
v4 = -10;
}
else
{
v10 = 511;
if ( setsockopt(v4, 101, 2, &v10, 4u) < 0 )
{
perror("setsockopt CAN_RAW_ERR_FILTER");
v4 = -11;
}
else
{
v7 *= 352;
v6 *= 352;
if ( setsockopt(v4, 1, 7, &v7, 4u) < 0 )
{
perror("setsockopt SO_SNDBUF");
v4 = -12;
}
else if ( setsockopt(v4, 1, 8, &v6, 4u) < 0 )
{
perror("setsockopt SO_RCVBUF");
v4 = -13;
}
else
{
v9 = 1;
if ( setsockopt(v4, 1, 40, &v9, 4u) < 0 )
{
perror("setsockopt SO_RXQ_OVFL");
v4 = -14;
}
else
{
*(_DWORD *)&addr.sa_family = 29;
*(_QWORD *)&addr.sa_data[6] = 0LL;
*(_DWORD *)&addr.sa_data[2] = v15;
if ( bind(v4, &addr, 0x10u) )
v4 = -1000000 * *_errno_location();
}
}
}
}
}
return v4;
}

original_code:
int SocketOpen (const char *InterfaceName, int TxBuffSize, int RxBuffSize)
{
    int number;
    number = socket(29, SOCK_RAW, 1);
    if(number < 0)
    {
 int errsv = (*__errno_location ());
 return -100*errsv;
    }
    struct ifreq ifr;
    strcpy(ifr.ifr_ifrn.ifrn_name, InterfaceName);
    ioctl(number, 0x8933, &ifr);
    if(ifr.ifr_ifru.ifru_ivalue < 0)
    {
 int errsv = (*__errno_location ());
 return -10000*errsv;
    }
    int recv_own_msgs = 1;
    setsockopt(number, (100 + 1), CAN_RAW_RECV_OWN_MSGS,
       &recv_own_msgs, sizeof(recv_own_msgs));
    const int timestamping_on = 1;
    if (setsockopt(number, 1, 37,
      &timestamping_on, sizeof(timestamping_on)) < 0) {
      perror("setsockopt SO_TIMESTAMPING");
      return -9;
    }
    const int timestamp_on = 1;
    if (setsockopt(number, 1, 29,
      &timestamp_on, sizeof(timestamp_on)) < 0) {
      perror("setsockopt SO_TIMESTAMP");
      return -10;
    }
    can_err_mask_t err_mask = ( 0x00000001U | 0x00000002U | 0x00000004U | 0x00000008U | 0x00000010U | 0x00000020U
    | 0x00000040U | 0x00000080U | 0x00000100U );
    if (setsockopt(number, (100 + 1), CAN_RAW_ERR_FILTER,
  &err_mask, sizeof(err_mask)) < 0) {
 perror("setsockopt CAN_RAW_ERR_FILTER");
 return -11;
    }
    TxBuffSize = 352*TxBuffSize;
    RxBuffSize = 352*RxBuffSize;
    if (setsockopt(number, 1, 7,
      &TxBuffSize, sizeof(TxBuffSize)) < 0) {
      perror("setsockopt SO_SNDBUF");
      return -12;
    }
    if (setsockopt(number, 1, 8,
      &RxBuffSize, sizeof(RxBuffSize)) < 0) {
      perror("setsockopt SO_RCVBUF");
      return -13;
    }
    const int dropmonitor_on = 1;
    if (setsockopt(number, 1, 40,
      &dropmonitor_on, sizeof(dropmonitor_on)) < 0) {
      perror("setsockopt SO_RXQ_OVFL");
      return -14;
    }
    struct sockaddr_can addr;
    memset(&addr, 0, sizeof(addr));
    addr.can_family = 29;
    addr.can_ifindex = ifr.ifr_ifru.ifru_ivalue;
    if ( bind(number, (const struct sockaddr*)&addr, sizeof(addr)) != 0 )
    {
 int errsv = (*__errno_location ());
 return -1000000*errsv;
    }
    return number;
}

canonical_original_code:
int SocketOpen(char *InterfaceName, int TxBuffSize, int RxBuffSize)
{
    int number;
    number = socket(29, SOCK_RAW, 1);
    if(number < 0)
    {
 int errsv = (*__errno_location ());
 return -100*errsv;
    }
    struct ifreq ifr;
    strcpy(ifr.ifr_ifrn.ifrn_name, InterfaceName);
    ioctl(number, 0x8933, &ifr);
    if(ifr.ifr_ifru.ifru_ivalue < 0)
    {
 int errsv = (*__errno_location ());
 return -10000*errsv;
    }
    int recv_own_msgs = 1;
    setsockopt(number, (100 + 1), CAN_RAW_RECV_OWN_MSGS,
       &recv_own_msgs, sizeof(recv_own_msgs));
    int timestamping_on = 1;
    if (setsockopt(number, 1, 37,
      &timestamping_on, sizeof(timestamping_on)) < 0) {
      perror("setsockopt SO_TIMESTAMPING");
      return -9;
    }
    int timestamp_on = 1;
    if (setsockopt(number, 1, 29,
      &timestamp_on, sizeof(timestamp_on)) < 0) {
      perror("setsockopt SO_TIMESTAMP");
      return -10;
    }
    unsigned int err_mask = ( 0x00000001U | 0x00000002U | 0x00000004U | 0x00000008U | 0x00000010U | 0x00000020U
    | 0x00000040U | 0x00000080U | 0x00000100U );
    if (setsockopt(number, (100 + 1), CAN_RAW_ERR_FILTER,
  &err_mask, sizeof(err_mask)) < 0) {
 perror("setsockopt CAN_RAW_ERR_FILTER");
 return -11;
    }
    TxBuffSize = 352*TxBuffSize;
    RxBuffSize = 352*RxBuffSize;
    if (setsockopt(number, 1, 7,
      &TxBuffSize, sizeof(TxBuffSize)) < 0) {
      perror("setsockopt SO_SNDBUF");
      return -12;
    }
    if (setsockopt(number, 1, 8,
      &RxBuffSize, sizeof(RxBuffSize)) < 0) {
      perror("setsockopt SO_RCVBUF");
      return -13;
    }
    int dropmonitor_on = 1;
    if (setsockopt(number, 1, 40,
      &dropmonitor_on, sizeof(dropmonitor_on)) < 0) {
      perror("setsockopt SO_RXQ_OVFL");
      return -14;
    }
    struct sockaddr_can addr;
    memset(&addr, 0, sizeof(addr));
    addr.can_family = 29;
    addr.can_ifindex = ifr.ifr_ifru.ifru_ivalue;
    if ( bind(number, (struct sockaddr *)&addr, sizeof(addr)) != 0 )
    {
 int errsv = (*__errno_location ());
 return -1000000*errsv;
    }
    return number;
}

variable_types:
InterfaceName
char *

variable_types: TxBuffSize int

variable_types: RxBuffSize int

variable_types: number int

variable_types: errsv int

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

variable_types: struct sockaddr_can { unsigned short can_family; int can_ifindex; union { struct { unsigned int rx_id; } tp; } can_addr; }

return_type: int

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


SocketClose

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

result = close(a1);
if ( result )
result = -*_errno_location();
return result;
}

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

result = close(a1);
if ( result )
result = -*_errno_location();
return result;
}

original_code:
int SocketClose (int number)
{
    if ( close (number) != 0)
    {
 int errsv = (*__errno_location ());
 return -1*errsv;
    }
    else
    {
 return 0;
    }
}

canonical_original_code:
int SocketClose(int number)
{
    if ( close (number) != 0)
    {
 int errsv = (*__errno_location ());
 return -1*errsv;
    }
    else
    {
 return 0;
    }
}


initTimers

original_code:
void initTimers (struct timeval *now, struct timeval *end, int timeoutMs)
{
    gettimeofday (now, ((void *)0));
    struct timeval timeout;
    timeout.tv_sec = timeoutMs / 1000;
    timeout.tv_usec = (timeoutMs % 1000) * 1000;
    do { (end)->tv_sec = (now)->tv_sec + (&timeout)->tv_sec; (end)->tv_usec = (now)->tv_usec + (&timeout)->tv_usec; if ((end)->tv_usec >= 1000000) { ++(end)->tv_sec; (end)->tv_usec -= 1000000; } } while (0);
}

canonical_original_code:
void initTimers(struct timeval *now, struct timeval *end, int timeoutMs)
{
    gettimeofday (now, ((void *)0));
    struct timeval timeout;
    timeout.tv_sec = timeoutMs / 1000;
    timeout.tv_usec = (timeoutMs % 1000) * 1000;
    do { (end)->tv_sec = (now)->tv_sec + (&timeout)->tv_sec; (end)->tv_usec = (now)->tv_usec + (&timeout)->tv_usec; if ((end)->tv_usec >= 1000000) { ++(end)->tv_sec; (end)->tv_usec -= 1000000; } } while (0);
}

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

variable_types:
end
struct timeval *

variable_types: timeoutMs int


SocketRead

decompiled_code:
__int64 __fastcall SocketRead(int fd, char *a2, unsigned int a3, int a4)
{
void *v7; // rsp
void *v8; // rsp
void *v9; // rsp
struct mmsghdr *v10; // rax
char *v11; // rdi
struct mmsghdr *v12; // rdx
struct mmsghdr *v13; // rcx
int v14; // eax
unsigned int v15; // ebx
struct mmsghdr *v17; // r13
__int64 v18; // r12
struct mmsghdr *v19; // r15
__int64 v20; // rax
struct cmsghdr *i; // rsi
int v22; // eax
struct mmsghdr v23; // [rsp+0h] [rbp-60h] BYREF

*(_QWORD *)&v23.msg_hdr.msg_namelen = a2;
v7 = alloca(16 * ((((unsigned __int64)a3 << 6) + 15) / 0x10));
v8 = alloca(16 * ((16 * (unsigned __int64)a3 + 15) / 0x10));
v9 = alloca(16 * ((56 * (unsigned __int64)a3 + 15) / 0x10));
if ( a3 )
{
v10 = &v23;
v11 = a2;
v12 = &v23;
v13 = &v23;
do
{
v10->msg_hdr.msg_name = 0LL;
v10->msg_hdr.msg_namelen = 0;
v12->msg_hdr.msg_name = v11;
*(_QWORD *)&v12->msg_hdr.msg_namelen = 16LL;
v10->msg_hdr.msg_iov = (struct iovec *)v12;
v10->msg_hdr.msg_iovlen = 1LL;
v10->msg_hdr.msg_control = v13;
v10->msg_hdr.msg_controllen = 56LL;
v10->msg_hdr.msg_flags = 0;
++v10;
v11 += 29;
v12 = (struct mmsghdr *)((char *)v12 + 16);
v13 = (struct mmsghdr *)((char *)v13 + 56);
}
while ( v10 != &v23 + a3 );
}
initTimers((struct timeval *)&v23.msg_hdr.msg_control, (__time_t *)&v23.msg_hdr.msg_iov, a4);
while ( 1 )
{
if ( v23.msg_hdr.msg_control == v23.msg_hdr.msg_iov )
{
if ( (__int64)v23.msg_hdr.msg_controllen >= (__int64)v23.msg_hdr.msg_iovlen )
return 0;
}
else if ( (__int64)v23.msg_hdr.msg_control >= (__int64)v23.msg_hdr.msg_iov )
{
return 0;
}
v14 = recvmmsg(fd, &v23, a3, 64, 0LL);
v15 = v14;
if ( v14 >= 0 )
break;
v15 = *_errno_location();
if ( v15 != 11 )
return v15;
gettimeofday((struct timeval *)&v23.msg_hdr.msg_control, 0LL);
}
if ( !v14 )
return 0;
v17 = &v23;
v18 = *(_QWORD *)&v23.msg_hdr.msg_namelen + 16LL;
v19 = &v23 + (unsigned __int64)(unsigned int)(v14 - 1) + 1;
do
{
if ( v17->msg_hdr.msg_controllen > 0xF )
{
for ( i = (struct cmsghdr *)v17->msg_hdr.msg_control; i; i = _cmsg_nxthdr(&v17->msg_hdr, i) )
{
if ( i->cmsg_level != 1 )
break;
v22 = i->cmsg_type;
if ( v22 == 29 )
{
v20 = *(_QWORD *)&i->__cmsg_data[8];
*(_DWORD *)v18 = *(_QWORD *)i->__cmsg_data;
*(_DWORD *)(v18 + 4) = v20;
}
else if ( v22 == 40 )
{
*(_DWORD *)(v18 + 9) = *(_DWORD *)i->__cmsg_data;
}
}
}
if ( (v17->msg_hdr.msg_flags & 0x800) != 0 )
*(_BYTE *)(v18 + 8) |= 1u;
++v17;
v18 += 29LL;
}
while ( v17 != v19 );
return v15;
}

canonical_decompiled_code:
__int64 __fastcall func3(int fd, char *a2, unsigned int a3, int a4)
{
void *v7; // rsp
void *v8; // rsp
void *v9; // rsp
struct mmsghdr *v10; // rax
char *v11; // rdi
struct mmsghdr *v12; // rdx
struct mmsghdr *v13; // rcx
int v14; // eax
unsigned int v15; // ebx
struct mmsghdr *v17; // r13
__int64 v18; // r12
struct mmsghdr *v19; // r15
__int64 v20; // rax
struct cmsghdr *i; // rsi
int v22; // eax
struct mmsghdr v23; // [rsp+0h] [rbp-60h] BYREF

*(_QWORD *)&v23.msg_hdr.msg_namelen = a2;
v7 = alloca(16 * ((((unsigned __int64)a3 << 6) + 15) / 0x10));
v8 = alloca(16 * ((16 * (unsigned __int64)a3 + 15) / 0x10));
v9 = alloca(16 * ((56 * (unsigned __int64)a3 + 15) / 0x10));
if ( a3 )
{
v10 = &v23;
v11 = a2;
v12 = &v23;
v13 = &v23;
do
{
v10->msg_hdr.msg_name = 0LL;
v10->msg_hdr.msg_namelen = 0;
v12->msg_hdr.msg_name = v11;
*(_QWORD *)&v12->msg_hdr.msg_namelen = 16LL;
v10->msg_hdr.msg_iov = (struct iovec *)v12;
v10->msg_hdr.msg_iovlen = 1LL;
v10->msg_hdr.msg_control = v13;
v10->msg_hdr.msg_controllen = 56LL;
v10->msg_hdr.msg_flags = 0;
++v10;
v11 += 29;
v12 = (struct mmsghdr *)((char *)v12 + 16);
v13 = (struct mmsghdr *)((char *)v13 + 56);
}
while ( v10 != &v23 + a3 );
}
func2((struct timeval *)&v23.msg_hdr.msg_control, (__time_t *)&v23.msg_hdr.msg_iov, a4);
while ( 1 )
{
if ( v23.msg_hdr.msg_control == v23.msg_hdr.msg_iov )
{
if ( (__int64)v23.msg_hdr.msg_controllen >= (__int64)v23.msg_hdr.msg_iovlen )
return 0;
}
else if ( (__int64)v23.msg_hdr.msg_control >= (__int64)v23.msg_hdr.msg_iov )
{
return 0;
}
v14 = recvmmsg(fd, &v23, a3, 64, 0LL);
v15 = v14;
if ( v14 >= 0 )
break;
v15 = *_errno_location();
if ( v15 != 11 )
return v15;
gettimeofday((struct timeval *)&v23.msg_hdr.msg_control, 0LL);
}
if ( !v14 )
return 0;
v17 = &v23;
v18 = *(_QWORD *)&v23.msg_hdr.msg_namelen + 16LL;
v19 = &v23 + (unsigned __int64)(unsigned int)(v14 - 1) + 1;
do
{
if ( v17->msg_hdr.msg_controllen > 0xF )
{
for ( i = (struct cmsghdr *)v17->msg_hdr.msg_control; i; i = _cmsg_nxthdr(&v17->msg_hdr, i) )
{
if ( i->cmsg_level != 1 )
break;
v22 = i->cmsg_type;
if ( v22 == 29 )
{
v20 = *(_QWORD *)&i->__cmsg_data[8];
*(_DWORD *)v18 = *(_QWORD *)i->__cmsg_data;
*(_DWORD *)(v18 + 4) = v20;
}
else if ( v22 == 40 )
{
*(_DWORD *)(v18 + 9) = *(_DWORD *)i->__cmsg_data;
}
}
}
if ( (v17->msg_hdr.msg_flags & 0x800) != 0 )
*(_BYTE *)(v18 + 8) |= 1u;
++v17;
v18 += 29LL;
}
while ( v17 != v19 );
return v15;
}

original_code:
int SocketRead (int Socket, struct FrameBag *Bags, unsigned int BagsCount, int TimeoutMs)
{
    struct mmsghdr msgs[BagsCount];
    struct iovec iovs[BagsCount];
    char ctrlmsgs[BagsCount][(((((sizeof(struct timeval)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))) + ((((sizeof(__u32)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))))];
    unsigned int i;
    for (i = 0; i < BagsCount; i++)
    {
        msgs[i].msg_hdr.msg_name = ((void *)0);
        msgs[i].msg_hdr.msg_namelen = 0;
        iovs[i].iov_base = (void *) &Bags[i];
        iovs[i].iov_len = sizeof(struct can_frame);
        msgs[i].msg_hdr.msg_iov = &iovs[i];
        msgs[i].msg_hdr.msg_iovlen = 1;
        msgs[i].msg_hdr.msg_control = &ctrlmsgs[i];
        msgs[i].msg_hdr.msg_controllen = sizeof(ctrlmsgs[0]);
        msgs[i].msg_hdr.msg_flags = 0;
    }
    struct timeval tNow, tEnd;
    for ( initTimers(&tNow, &tEnd, TimeoutMs); (((&tNow)->tv_sec == (&tEnd)->tv_sec) ? ((&tNow)->tv_usec < (&tEnd)->tv_usec) : ((&tNow)->tv_sec < (&tEnd)->tv_sec)); gettimeofday (&tNow, ((void *)0)) )
    {
        int rcount;
        rcount = recvmmsg(Socket, msgs, BagsCount, MSG_DONTWAIT, ((void *)0));
        if (rcount >= 0)
        {
            for (i = 0; i < rcount; i ++)
            {
                struct timeval tv;
                struct cmsghdr *cmsg;
                for (cmsg = ((size_t) (&msgs[i].msg_hdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (&msgs[i].msg_hdr)->msg_control : (struct cmsghdr *) 0);
                    cmsg && (cmsg->cmsg_level == 1);
                    cmsg = __cmsg_nxthdr (&msgs[i].msg_hdr, cmsg))
                {
                    if (cmsg->cmsg_type == 29)
                    {
                      tv = *(struct timeval *)((cmsg)->__cmsg_data);
                      Bags[i].TimeStamp.seconds = tv.tv_sec;
                      Bags[i].TimeStamp.microseconds = tv.tv_usec;
                    }
                    else if (cmsg->cmsg_type == 40)
                      Bags[i].DroppedMessagesCount = *(__u32 *)((cmsg)->__cmsg_data);
                }
                if (msgs[i].msg_hdr.msg_flags & MSG_CONFIRM)
                    Bags[i].Flags |= (1 << 0);
            }
            return rcount;
        }
        else
        {
            int errsv = (*__errno_location ());
            if (errsv == 11)
                continue;
            else
                return errsv;
        }
    }
    return 0;
}

canonical_original_code:
int SocketRead(int Socket, struct FrameBag *Bags, unsigned int BagsCount, int TimeoutMs)
{
    struct mmsghdr msgs[-1];
    struct iovec iovs[-1];
    char ctrlmsgs[-1][-1];
    unsigned int i;
    for (i = 0; i < BagsCount; i++)
    {
        msgs[i].msg_hdr.msg_name = ((void *)0);
        msgs[i].msg_hdr.msg_namelen = 0;
        iovs[i].iov_base = (void *) &Bags[i];
        iovs[i].iov_len = sizeof(struct can_frame);
        msgs[i].msg_hdr.msg_iov = &iovs[i];
        msgs[i].msg_hdr.msg_iovlen = 1;
        msgs[i].msg_hdr.msg_control = &ctrlmsgs[i];
        msgs[i].msg_hdr.msg_controllen = sizeof(ctrlmsgs[0]);
        msgs[i].msg_hdr.msg_flags = 0;
    }
    struct timeval tNow; struct timeval tEnd;
    for ( initTimers(&tNow, &tEnd, TimeoutMs); (((&tNow)->tv_sec == (&tEnd)->tv_sec) ? ((&tNow)->tv_usec < (&tEnd)->tv_usec) : ((&tNow)->tv_sec < (&tEnd)->tv_sec)); gettimeofday (&tNow, ((void *)0)) )
    {
        int rcount;
        rcount = recvmmsg(Socket, msgs, BagsCount, MSG_DONTWAIT, ((void *)0));
        if (rcount >= 0)
        {
            for (i = 0; i < rcount; i ++)
            {
                struct timeval tv;
                struct cmsghdr *cmsg;
                for (cmsg = ((unsigned long) (&msgs[i].msg_hdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (&msgs[i].msg_hdr)->msg_control : (struct cmsghdr *) 0);
                    cmsg && (cmsg->cmsg_level == 1);
                    cmsg = __cmsg_nxthdr (&msgs[i].msg_hdr, cmsg))
                {
                    if (cmsg->cmsg_type == 29)
                    {
                      tv = *(struct timeval *)((cmsg)->__cmsg_data);
                      Bags[i].TimeStamp.seconds = tv.tv_sec;
                      Bags[i].TimeStamp.microseconds = tv.tv_usec;
                    }
                    else if (cmsg->cmsg_type == 40)
                      Bags[i].DroppedMessagesCount = *(unsigned int *)((cmsg)->__cmsg_data);
                }
                if (msgs[i].msg_hdr.msg_flags & MSG_CONFIRM)
                    Bags[i].Flags |= (1 << 0);
            }
            return rcount;
        }
        else
        {
            int errsv = (*__errno_location ());
            if (errsv == 11)
                continue;
            else
                return errsv;
        }
    }
    return 0;
}

variable_types: Socket int

variable_types: struct FrameBag { struct can_frame { unsigned int can_id; unsigned char can_dlc; unsigned char __pad; unsigned char __res0; unsigned char __res1; unsigned char data[8]; } Frame; struct TimeVal { unsigned int seconds; unsigned int microseconds; } TimeStamp; unsigned char Flags; unsigned int DroppedMessagesCount; } *

variable_types:
BagsCount
unsigned int

variable_types: TimeoutMs int

variable_types: struct mmsghdr { struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec { void *iov_base; unsigned long iov_len; } *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; } msg_hdr; unsigned int msg_len; } [-1]

variable_types: struct iovec { void *iov_base; unsigned long iov_len; } [-1]

variable_types:
ctrlmsgs
char [-1][-1]

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

variable_types: rcount int

variable_types: struct cmsghdr { unsigned long cmsg_len; int cmsg_level; int cmsg_type; unsigned char __cmsg_data[]; } *

user_defined_types: struct FrameBag { struct can_frame Frame; struct TimeVal TimeStamp; unsigned char Flags; unsigned int DroppedMessagesCount; }

user_defined_types: struct mmsghdr { struct msghdr msg_hdr; unsigned int msg_len; }

user_defined_types: struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; }


SocketWrite

decompiled_code:
int __fastcall SocketWrite(socklen_t a1, char *a2, signed int a3)
{
size_t v5; // rcx
void *v6; // rsp
size_t v7; // r14
void *v8; // rsp
struct mmsghdr *v9; // rbx
struct mmsghdr *v10; // rax
int result; // eax
struct mmsghdr v12; // [rsp+0h] [rbp-40h] BYREF

*(&v12.msg_hdr.msg_namelen + 1) = a1;
v5 = (__int64)a3 << 6;
v6 = alloca(16 * ((v5 + 15) / 0x10));
v7 = 16LL * a3;
v8 = alloca(16 * ((v7 + 15) / 0x10));
v9 = &v12;
memset(&v12, 0, v5);
memset(&v12, 0, v7);
if ( a3 )
{
v10 = &v12;
do
{
v10->msg_hdr.msg_name = 0LL;
v10->msg_hdr.msg_namelen = 0;
v9->msg_hdr.msg_name = a2;
*(_QWORD *)&v9->msg_hdr.msg_namelen = 16LL;
v10->msg_hdr.msg_iov = (struct iovec *)v9;
v10->msg_hdr.msg_iovlen = 1LL;
++v10;
a2 += 16;
v9 = (struct mmsghdr *)((char *)v9 + 16);
}
while ( v10 != &v12 + (unsigned int)(a3 - 1) + 1 );
}
result = sendmmsg(*((int *)&v12.msg_hdr.msg_namelen + 1), &v12, a3, 0);
if ( result < 0 )
result = -*_errno_location();
return result;
}

canonical_decompiled_code:
int __fastcall func4(socklen_t a1, char *a2, signed int a3)
{
size_t v5; // rcx
void *v6; // rsp
size_t v7; // r14
void *v8; // rsp
struct mmsghdr *v9; // rbx
struct mmsghdr *v10; // rax
int result; // eax
struct mmsghdr v12; // [rsp+0h] [rbp-40h] BYREF

*(&v12.msg_hdr.msg_namelen + 1) = a1;
v5 = (__int64)a3 << 6;
v6 = alloca(16 * ((v5 + 15) / 0x10));
v7 = 16LL * a3;
v8 = alloca(16 * ((v7 + 15) / 0x10));
v9 = &v12;
memset(&v12, 0, v5);
memset(&v12, 0, v7);
if ( a3 )
{
v10 = &v12;
do
{
v10->msg_hdr.msg_name = 0LL;
v10->msg_hdr.msg_namelen = 0;
v9->msg_hdr.msg_name = a2;
*(_QWORD *)&v9->msg_hdr.msg_namelen = 16LL;
v10->msg_hdr.msg_iov = (struct iovec *)v9;
v10->msg_hdr.msg_iovlen = 1LL;
++v10;
a2 += 16;
v9 = (struct mmsghdr *)((char *)v9 + 16);
}
while ( v10 != &v12 + (unsigned int)(a3 - 1) + 1 );
}
result = sendmmsg(*((int *)&v12.msg_hdr.msg_namelen + 1), &v12, a3, 0);
if ( result < 0 )
result = -*_errno_location();
return result;
}

original_code:
int SocketWrite (int Socket, struct can_frame *Frame, int FramesCount)
{
  struct mmsghdr msgs[FramesCount];
  struct iovec iovs[FramesCount];
  memset (msgs, 0, sizeof (msgs));
  memset (iovs, 0, sizeof (iovs));
  unsigned int i;
  for (i = 0; i < FramesCount; i++) {
    msgs[i].msg_hdr.msg_name = ((void *)0);;
    msgs[i].msg_hdr.msg_namelen = 0;
    iovs[i].iov_base = (void *) &Frame[i];
    iovs[i].iov_len = sizeof(struct can_frame);
    msgs[i].msg_hdr.msg_iov = &iovs[i];
    msgs[i].msg_hdr.msg_iovlen = 1;
  }
  int scount;
  scount = sendmmsg(Socket, msgs, FramesCount, 0);
  if ( scount < 0 )
  {
    int errsv = (*__errno_location ());
    return -errsv;
  }
  else
  {
    return scount;
  }
}

canonical_original_code:
int SocketWrite(int Socket, struct can_frame *Frame, int FramesCount)
{
  struct mmsghdr msgs[-1];
  struct iovec iovs[-1];
  memset (msgs, 0, sizeof (msgs));
  memset (iovs, 0, sizeof (iovs));
  unsigned int i;
  for (i = 0; i < FramesCount; i++) {
    msgs[i].msg_hdr.msg_name = ((void *)0);;
    msgs[i].msg_hdr.msg_namelen = 0;
    iovs[i].iov_base = (void *) &Frame[i];
    iovs[i].iov_len = sizeof(struct can_frame);
    msgs[i].msg_hdr.msg_iov = &iovs[i];
    msgs[i].msg_hdr.msg_iovlen = 1;
  }
  int scount;
  scount = sendmmsg(Socket, msgs, FramesCount, 0);
  if ( scount < 0 )
  {
    int errsv = (*__errno_location ());
    return -errsv;
  }
  else
  {
    return scount;
  }
}

variable_types: struct can_frame { unsigned int can_id; unsigned char can_dlc; unsigned char __pad; unsigned char __res0; unsigned char __res1; unsigned char data[8]; } *

variable_types: FramesCount int

variable_types:
i
unsigned int

variable_types: scount int

user_defined_types: struct iovec { void *iov_base; unsigned long iov_len; }


SocketFlushInBuffer

decompiled_code:
__int64 __fastcall SocketFlushInBuffer(int fd)
{
__int64 result; // rax
_BYTE savedregs[328]; // [rsp+0h] [rbp+0h] BYREF

do
result = SocketRead(fd, savedregs, 0xAu, 1);
while ( (int)result > 0 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int fd)
{
__int64 result; // rax
_BYTE savedregs[328]; // [rsp+0h] [rbp+0h] BYREF

do
result = func3(fd, savedregs, 0xAu, 1);
while ( (int)result > 0 );
return result;
}

original_code:
int SocketFlushInBuffer (int Socket)
{
  struct FrameBag bags[10];
  int lost = 1;
  while (lost)
  {
    lost = SocketRead (Socket, bags, 10, 1);
    if (lost < 0)
      return lost;
  }
  return 0;
}

canonical_original_code:
int SocketFlushInBuffer(int Socket)
{
  struct FrameBag bags[10];
  int lost = 1;
  while (lost)
  {
    lost = SocketRead (Socket, bags, 10, 1);
    if (lost < 0)
      return lost;
  }
  return 0;
}

variable_types: struct FrameBag { struct can_frame { unsigned int can_id; unsigned char can_dlc; unsigned char __pad; unsigned char __res0; unsigned char __res1; unsigned char data[8]; } Frame; struct TimeVal { unsigned int seconds; unsigned int microseconds; } TimeStamp; unsigned char Flags; unsigned int DroppedMessagesCount; } [10]

variable_types: lost int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
unsigned int v4; // [rsp+4h] [rbp-14h] BYREF
unsigned int v5; // [rsp+8h] [rbp-10h] BYREF
unsigned int v6[3]; // [rsp+Ch] [rbp-Ch] BYREF

do
{
if ( (unsigned int)getDate("Geben Sie bitte ein gueltiges Datum ein: ", v6, &v5, &v4) )
printf("Das Datum %02i.%02i.%04i ist gueltig!\n", v6[0], v5, v4);
else
puts("Das eingegebene Datum ist ungueltig!");
result = askAgain();
}
while ( result );
return result;
}

original_code:
int main()
{
 int D,M,Y;
 do
 {
  if (getDate("Geben Sie bitte ein gueltiges Datum ein: ", &D, &M, &Y))
   printf("Das Datum %02i.%02i.%04i ist gueltig!\n", D, M, Y);
  else
   printf("Das eingegebene Datum ist ungueltig!\n");
 } while (askAgain());
 return 0;
}

canonical_original_code:
int main()
{
 int D; int M; int Y;
 do
 {
  if (getDate("Geben Sie bitte ein gueltiges Datum ein: ", &D, &M, &Y))
   printf("Das Datum %02i.%02i.%04i ist gueltig!\n", D, M, Y);
  else
   printf("Das eingegebene Datum ist ungueltig!\n");
 } while (askAgain());
 return 0;
}

variable_types: D int

variable_types: M int

variable_types: Y int


clearBuffer

decompiled_code:
__int64 clearBuffer()
{
__int64 result; // rax
char v1[9]; // [rsp+Fh] [rbp-9h] BYREF

do
result = _isoc99_scanf(&unk_B5, v1);
while ( v1[0] != 10 );
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
char v1[9]; // [rsp+Fh] [rbp-9h] BYREF

do
result = _isoc99_scanf(&unk_B5, v1);
while ( v1[0] != 10 );
return result;
}

original_code:
void clearBuffer()
{
 char Dummy;
 do
 {
  scanf("%c", &Dummy);
 } while (Dummy != '\n');
}

variable_types: Dummy char


askAgain

decompiled_code:
__int64 askAgain()
{
int v1; // eax
int v2; // ebx
char v3[9]; // [rsp+Fh] [rbp-9h] BYREF

while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
printf(aM);
v1 = _isoc99_scanf(&unk_B5, v3);
v2 = v1;
if ( v3[0] != 10 )
break;
if ( !v1 )
LABEL_8:
printf("Sie haben nicht j oder n eingegeben");
}
clearBuffer();
if ( !v2 )
goto LABEL_8;
if ( v3[0] == 78 )
return 0LL;
if ( v3[0] > 78 )
break;
if ( v3[0] == 74 )
return 1LL;
}
if ( v3[0] == 106 )
return 1LL;
if ( v3[0] == 110 )
return 0LL;
}
}

canonical_decompiled_code:
__int64 func1()
{
int v1; // eax
int v2; // ebx
char v3[9]; // [rsp+Fh] [rbp-9h] BYREF

while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
printf(aM);
v1 = _isoc99_scanf(&unk_B5, v3);
v2 = v1;
if ( v3[0] != 10 )
break;
if ( !v1 )
LABEL_8:
printf("Sie haben nicht j oder n eingegeben");
}
func0();
if ( !v2 )
goto LABEL_8;
if ( v3[0] == 78 )
return 0LL;
if ( v3[0] > 78 )
break;
if ( v3[0] == 74 )
return 1LL;
}
if ( v3[0] == 106 )
return 1LL;
if ( v3[0] == 110 )
return 0LL;
}
}

original_code:
int askAgain()
{
 int weiter;
 int auswahlGetroffen;
 char eingabe;
 do
 {
  printf("Möchten Sie noch einmal j/n ");
  auswahlGetroffen = scanf("%c", &eingabe);
  if( eingabe!='\n')
  {
   clearBuffer();
  }
  if(!auswahlGetroffen)
  {
   printf("Sie haben nicht j oder n eingegeben");
  }
  else
  {
   switch (eingabe)
   {
    case 'j':
    case 'J':
        weiter = 1; break;
    case 'n':
    case 'N':
        weiter = 0; break;
    default:
     auswahlGetroffen = 0;
   }
  }
 } while (!auswahlGetroffen);
 return weiter;
}

variable_types: weiter int

variable_types: auswahlGetroffen int

variable_types: eingabe char


decompiled_code:
void __fastcall read_from_file(int fd, void *buf, size_t nbytes, __off_t offset)
{
unsigned int v4; // ebp

if ( fd != -1 )
{
v4 = nbytes;
lseek(fd, (unsigned int)offset, 0);
if ( (unsigned int)read(fd, buf, v4) == -1 )
{
perror("READ");
exit(1);
}
}
}

canonical_decompiled_code:
void __fastcall func0(int fd, void *buf, size_t nbytes, __off_t offset)
{
unsigned int v4; // ebp

if ( fd != -1 )
{
v4 = nbytes;
lseek(fd, (unsigned int)offset, 0);
if ( (unsigned int)read(fd, buf, v4) == -1 )
{
perror("READ");
exit(1);
}
}
}

original_code:
void read_from_file(int fdes, unsigned char *buffer, unsigned int bytes_to_read, unsigned int start) {
 int nr=0;
 if(fdes!=-1) {
  lseek(fdes,start,0);
  if((nr = read(fdes,buffer,bytes_to_read))==-1) {
   perror("READ");
   exit(1);
  }
 }
}

canonical_original_code:
void read_from_file(int fdes, unsigned char *buffer, unsigned int bytes_to_read, unsigned int start) {
 int nr = 0;
 if(fdes!=-1) {
  lseek(fdes,start,0);
  if((nr = read(fdes,buffer,bytes_to_read))==-1) {
   perror("READ");
   exit(1);
  }
 }
}

variable_types: fdes int

variable_types:
buffer
unsigned char *

variable_types:
start
unsigned int

variable_types: nr int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbx
int v4; // eax
int v5; // ebx
_DWORD v7[130]; // [rsp+0h] [rbp-208h] BYREF

v3 = "sd_128mb.img";
if ( argc > 1 )
v3 = argv[1];
printf("filename: %s\n", v3);
v4 = open(v3, 1052672);
v5 = v4;
if ( v4 == -1 )
{
perror("Open");
exit(1);
}
read_from_file(v4, v7, 0x10uLL, 446LL);
print_partition(v7);
read_from_file(v5, v7, 0x200uLL, (unsigned int)(v7[2] << 9));
puts("--- FAT ---");
dump_eboot_F32(v7);
if ( close(v5) == -1 )
{
perror("Close");
exit(1);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbx
int v4; // eax
int v5; // ebx
_DWORD v7[130]; // [rsp+0h] [rbp-208h] BYREF

v3 = "sd_128mb.img";
if ( argc > 1 )
v3 = argv[1];
printf("filename: %s\n", v3);
v4 = open(v3, 1052672);
v5 = v4;
if ( v4 == -1 )
{
perror("Open");
exit(1);
}
func0(v4, v7, 0x10uLL, 446LL);
print_partition(v7);
func0(v5, v7, 0x200uLL, (unsigned int)(v7[2] << 9));
puts("--- FAT ---");
dump_eboot_F32(v7);
if ( close(v5) == -1 )
{
perror("Close");
exit(1);
}
return 0;
}

original_code:
int main(int argc, char** argv) {
 char* filename = "sd_128mb.img";
 unsigned char buffer[512];
 if(argc>=2) {
  filename=argv[1];
 }
 printf("filename: %s\n",filename);
 int ddes=-1, pos=-1, ret=0;
 if((ddes=open(filename, 00 | 04010000))==-1) {
  perror("Open");
  exit(1);
 }
 read_from_file(ddes,buffer,sizeof(struct partitionInfo_t),0x1be);
 struct partitionInfo_t* partition = (struct partitionInfo_t*)buffer;
 print_partition(partition);
 int relative_sector = ((partition->firstSector)*512);
 read_from_file(ddes,buffer,sizeof(struct eboot_param_block_F32_t),relative_sector);
 printf("--- FAT ---\n");
 struct eboot_param_block_F32_t* ebpb = (struct eboot_param_block_F32_t*)buffer;
 dump_eboot_F32(ebpb);
 ret=close(ddes);
 if(ret==-1) {
  perror("Close");
  exit(1);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 char *filename = "sd_128mb.img";
 unsigned char buffer[512];
 if(argc>=2) {
  filename=argv[1];
 }
 printf("filename: %s\n",filename);
 int ddes = -1; int pos = -1; int ret = 0;
 if((ddes=open(filename, 00 | 04010000))==-1) {
  perror("Open");
  exit(1);
 }
 read_from_file(ddes,buffer,sizeof(struct partitionInfo_t),0x1be);
 struct partitionInfo_t *partition = (struct partitionInfo_t*)buffer;
 print_partition(partition);
 int relative_sector = ((partition->firstSector)*512);
 read_from_file(ddes,buffer,sizeof(struct eboot_param_block_F32_t),relative_sector);
 printf("--- FAT ---\n");
 struct eboot_param_block_F32_t *ebpb = (struct eboot_param_block_F32_t*)buffer;
 dump_eboot_F32(ebpb);
 ret=close(ddes);
 if(ret==-1) {
  perror("Close");
  exit(1);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
filename
char *

variable_types:
buffer
unsigned char [512]

variable_types: ddes int

variable_types: pos int

variable_types: ret int

variable_types: struct partitionInfo_t { unsigned char status; unsigned char headStart; unsigned short cylSectStart; unsigned char type; unsigned char headEnd; unsigned short cylSectEnd; unsigned int firstSector; unsigned int sectorsTotal; } *

variable_types: struct eboot_param_block_F32_t { unsigned char jumpBoot[3]; char OEMName[8]; unsigned short bytesPerSector; unsigned char sectorPerCluster; unsigned short reservedSectorCount; unsigned char numberofFATs; unsigned short rootEntryCount; unsigned short totalSectors_F16; unsigned char mediaType; unsigned short FATsize_F16; short sectorsPerTrack; unsigned short numberofHeads; unsigned int hiddenSectors; unsigned int totalSectors_F32; unsigned int FATsize_F32; unsigned short extFlags; unsigned short FSversion; unsigned int rootCluster; unsigned short FSinfo; unsigned short BackupBootSector; unsigned char reserved[12]; unsigned char driveNumber; unsigned char reserved1; unsigned char bootSignature; unsigned int volumeID; char volumeLabel[11]; char fileSystemType[8]; unsigned char bootData[420]; unsigned short bootEndSignature; } *


decompiled_code:
int __fastcall print_hex_bytes(__int64 a1, int a2)
{
__int64 i; // rbx
int result; // eax

if ( a2 > 0 )
{
for ( i = 0LL; i != a2; result = printf("%02x ", *(unsigned __int8 *)(a1 + i++)) )
{
if ( (i & 0xF) == 0 )
printf("\n\t");
}
}
return result;
}

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

if ( a2 > 0 )
{
for ( i = 0LL; i != a2; result = printf("%02x ", *(unsigned __int8 *)(a1 + i++)) )
{
if ( (i & 0xF) == 0 )
printf("\n\t");
}
}
return result;
}

original_code:
void print_hex_bytes(unsigned char* data,int numBytes) {
 int i=0;
 for(i=0; i<numBytes;i++) {
  if(i%16==0) printf("\n\t");
  printf("%02x ",data[i]);
 }
}

canonical_original_code:
void print_hex_bytes(unsigned char *data, int numBytes) {
 int i = 0;
 for(i=0; i<numBytes;i++) {
  if(i%16==0) printf("\n\t");
  printf("%02x ",data[i]);
 }
}

variable_types:
data
unsigned char *

variable_types: numBytes int

variable_types: i int


decompiled_code:
int __fastcall print_char_bytes(char *a1, int a2)
{
char *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
putchar(*v2++);
while ( v2 != &a1[a2 - 1 + 1] );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func1(char *a1, int a2)
{
char *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
putchar(*v2++);
while ( v2 != &a1[a2 - 1 + 1] );
}
return putchar(10);
}

original_code:
void print_char_bytes(char* data, int numBytes) {
 int i=0;
 for(i=0; i<numBytes;i++) {
  printf("%c",(char)data[i]);
 }
 printf("\n");
}

canonical_original_code:
void print_char_bytes(char *data, int numBytes) {
 int i = 0;
 for(i=0; i<numBytes;i++) {
  printf("%c",(char)data[i]);
 }
 printf("\n");
}

variable_types:
data
char *


decompiled_code:
int __fastcall print_partition(__int64 a1)
{
const char *v2; // rsi
unsigned __int16 v3; // bp
unsigned __int16 v4; // bp

if ( !*(_DWORD *)(a1 + 12) || !*(_BYTE *)(a1 + 4) )
return puts("This is not an initialized partition");
v2 = "True";
if ( *(_BYTE *)a1 != 0x80 )
v2 = "False";
printf("Bootflag: %s\n", v2);
printf("Starting Head: %d\n", *(unsigned __int8 *)(a1 + 1));
v3 = *(_WORD *)(a1 + 2);
printf("Starting Sector: %d\n", v3 >> 10);
printf("Starting Cylinder: %d\n", v3 & 0x3FF);
printf("System ID: %02x\n", *(unsigned __int8 *)(a1 + 4));
printf("Ending Head: %d\n", *(unsigned __int8 *)(a1 + 5));
v4 = *(_WORD *)(a1 + 6);
printf("Ending Sector: %d\n", v4 >> 10);
printf("Ending Cylinder: %d\n", v4 & 0x3FF);
printf("Relative Sector: %d\n", *(unsigned int *)(a1 + 8));
return printf("Total sectors: %d\n", *(unsigned int *)(a1 + 12));
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
const char *v2; // rsi
unsigned __int16 v3; // bp
unsigned __int16 v4; // bp

if ( !*(_DWORD *)(a1 + 12) || !*(_BYTE *)(a1 + 4) )
return puts("This is not an initialized partition");
v2 = "True";
if ( *(_BYTE *)a1 != 0x80 )
v2 = "False";
printf("Bootflag: %s\n", v2);
printf("Starting Head: %d\n", *(unsigned __int8 *)(a1 + 1));
v3 = *(_WORD *)(a1 + 2);
printf("Starting Sector: %d\n", v3 >> 10);
printf("Starting Cylinder: %d\n", v3 & 0x3FF);
printf("System ID: %02x\n", *(unsigned __int8 *)(a1 + 4));
printf("Ending Head: %d\n", *(unsigned __int8 *)(a1 + 5));
v4 = *(_WORD *)(a1 + 6);
printf("Ending Sector: %d\n", v4 >> 10);
printf("Ending Cylinder: %d\n", v4 & 0x3FF);
printf("Relative Sector: %d\n", *(unsigned int *)(a1 + 8));
return printf("Total sectors: %d\n", *(unsigned int *)(a1 + 12));
}

original_code:
void print_partition(struct partitionInfo_t* table) {
 if(table->sectorsTotal<=0 || table->type==0) {
  printf("This is not an initialized partition\n");
 } else {
  printf("Bootflag: %s\n",table->status==0x80?"True":"False");
  printf("Starting Head: %d\n",table->headStart);
  int start_sect = ((table->cylSectStart)>>10)&0x3F;
  int start_cyl = (table->cylSectStart)&0x3FF;
  printf("Starting Sector: %d\n",start_sect);
  printf("Starting Cylinder: %d\n",start_cyl);
  printf("System ID: %02x\n",table->type);
  printf("Ending Head: %d\n",table->headEnd);
  int end_sect = ((table->cylSectEnd)>>10)&0x3F;
  int end_cyl = (table->cylSectEnd)&0x3FF;
  printf("Ending Sector: %d\n",end_sect);
  printf("Ending Cylinder: %d\n",end_cyl);
  printf("Relative Sector: %d\n",table->firstSector);
  printf("Total sectors: %d\n",table->sectorsTotal);
 }
}

canonical_original_code:
void print_partition(struct partitionInfo_t *table) {
 if(table->sectorsTotal<=0 || table->type==0) {
  printf("This is not an initialized partition\n");
 } else {
  printf("Bootflag: %s\n",table->status==0x80?"True":"False");
  printf("Starting Head: %d\n",table->headStart);
  int start_sect = ((table->cylSectStart)>>10)&0x3F;
  int start_cyl = (table->cylSectStart)&0x3FF;
  printf("Starting Sector: %d\n",start_sect);
  printf("Starting Cylinder: %d\n",start_cyl);
  printf("System ID: %02x\n",table->type);
  printf("Ending Head: %d\n",table->headEnd);
  int end_sect = ((table->cylSectEnd)>>10)&0x3F;
  int end_cyl = (table->cylSectEnd)&0x3FF;
  printf("Ending Sector: %d\n",end_sect);
  printf("Ending Cylinder: %d\n",end_cyl);
  printf("Relative Sector: %d\n",table->firstSector);
  printf("Total sectors: %d\n",table->sectorsTotal);
 }
}

user_defined_types: struct partitionInfo_t { unsigned char status; unsigned char headStart; unsigned short cylSectStart; unsigned char type; unsigned char headEnd; unsigned short cylSectEnd; unsigned int firstSector; unsigned int sectorsTotal; }


decompiled_code:
int __fastcall dump_eboot_F16(__int64 a1)
{
printf("Jump Assembly: ");
print_hex_bytes(a1, 3);
putchar(10);
printf("OEM Identifier: %s\n", (const char *)(a1 + 3));
printf("Bytes per sector: %d\n", *(unsigned __int16 *)(a1 + 11));
printf("Sectors per cluster: %d\n", *(unsigned __int8 *)(a1 + 13));
printf("Reserved sectors: %d\n", *(unsigned __int16 *)(a1 + 14));
printf("Number of FAT tables: %d\n", *(unsigned __int8 *)(a1 + 16));
printf("Number of Directory entries: %d\n", *(unsigned __int16 *)(a1 + 17));
printf("Total sectors (F16): %d\n", *(unsigned __int16 *)(a1 + 19));
printf("Media Descriptor: %02x\n", *(unsigned __int8 *)(a1 + 21));
printf("Sectors per FAT (F16): %d\n", *(unsigned __int16 *)(a1 + 22));
printf("Sectors per track: %d\n", (unsigned int)*(__int16 *)(a1 + 24));
printf("Head count: %d\n", *(unsigned __int16 *)(a1 + 26));
printf("Hidden sectors: %d\n", *(unsigned int *)(a1 + 28));
printf("Total Sectors (F32): %d\n", *(unsigned int *)(a1 + 32));
printf("Drive Number: %d\n", *(unsigned __int8 *)(a1 + 36));
printf("Boot Signature: %02X\n", *(unsigned __int8 *)(a1 + 38));
printf("Volume ID: %d\n", *(unsigned int *)(a1 + 39));
printf("Volume Label: ");
print_char_bytes((char *)(a1 + 43), 11);
putchar(10);
printf("Filesystem Type: ");
print_char_bytes((char *)(a1 + 54), 8);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
printf("Jump Assembly: ");
func0(a1, 3);
putchar(10);
printf("OEM Identifier: %s\n", (const char *)(a1 + 3));
printf("Bytes per sector: %d\n", *(unsigned __int16 *)(a1 + 11));
printf("Sectors per cluster: %d\n", *(unsigned __int8 *)(a1 + 13));
printf("Reserved sectors: %d\n", *(unsigned __int16 *)(a1 + 14));
printf("Number of FAT tables: %d\n", *(unsigned __int8 *)(a1 + 16));
printf("Number of Directory entries: %d\n", *(unsigned __int16 *)(a1 + 17));
printf("Total sectors (F16): %d\n", *(unsigned __int16 *)(a1 + 19));
printf("Media Descriptor: %02x\n", *(unsigned __int8 *)(a1 + 21));
printf("Sectors per FAT (F16): %d\n", *(unsigned __int16 *)(a1 + 22));
printf("Sectors per track: %d\n", (unsigned int)*(__int16 *)(a1 + 24));
printf("Head count: %d\n", *(unsigned __int16 *)(a1 + 26));
printf("Hidden sectors: %d\n", *(unsigned int *)(a1 + 28));
printf("Total Sectors (F32): %d\n", *(unsigned int *)(a1 + 32));
printf("Drive Number: %d\n", *(unsigned __int8 *)(a1 + 36));
printf("Boot Signature: %02X\n", *(unsigned __int8 *)(a1 + 38));
printf("Volume ID: %d\n", *(unsigned int *)(a1 + 39));
printf("Volume Label: ");
func1((char *)(a1 + 43), 11);
putchar(10);
printf("Filesystem Type: ");
func1((char *)(a1 + 54), 8);
return putchar(10);
}

original_code:
void dump_eboot_F16(struct eboot_param_block_F16_t* block) {
 printf("Jump Assembly: ");
 print_hex_bytes(block->jumpBoot,3);
 printf("\n");
 printf("OEM Identifier: %s\n",block->OEMName);
 printf("Bytes per sector: %d\n",block->bytesPerSector);
 printf("Sectors per cluster: %d\n",block->sectorPerCluster);
 printf("Reserved sectors: %d\n",block->reservedSectorCount);
 printf("Number of FAT tables: %d\n",block->numberofFATs);
 printf("Number of Directory entries: %d\n",block->rootEntryCount);
 printf("Total sectors (F16): %d\n",block->totalSectors_F16);
 printf("Media Descriptor: %02x\n",block->mediaType);
 printf("Sectors per FAT (F16): %d\n",block->FATsize_F16);
 printf("Sectors per track: %d\n",block->sectorsPerTrack);
 printf("Head count: %d\n",block->numberofHeads);
 printf("Hidden sectors: %d\n", block->hiddenSectors);
 printf("Total Sectors (F32): %d\n", block->totalSectors_F32);
 printf("Drive Number: %d\n", block->driveNumber);
 printf("Boot Signature: %02X\n",block->bootSignature);
 printf("Volume ID: %d\n",block->volumeID);
 printf("Volume Label: ");
 print_char_bytes(block->volumeLabel,11);
 printf("\n");
 printf("Filesystem Type: ");
 print_char_bytes(block->fileSystemType,8);
 printf("\n");
}

canonical_original_code:
void dump_eboot_F16(struct eboot_param_block_F16_t *block) {
 printf("Jump Assembly: ");
 print_hex_bytes(block->jumpBoot,3);
 printf("\n");
 printf("OEM Identifier: %s\n",block->OEMName);
 printf("Bytes per sector: %d\n",block->bytesPerSector);
 printf("Sectors per cluster: %d\n",block->sectorPerCluster);
 printf("Reserved sectors: %d\n",block->reservedSectorCount);
 printf("Number of FAT tables: %d\n",block->numberofFATs);
 printf("Number of Directory entries: %d\n",block->rootEntryCount);
 printf("Total sectors (F16): %d\n",block->totalSectors_F16);
 printf("Media Descriptor: %02x\n",block->mediaType);
 printf("Sectors per FAT (F16): %d\n",block->FATsize_F16);
 printf("Sectors per track: %d\n",block->sectorsPerTrack);
 printf("Head count: %d\n",block->numberofHeads);
 printf("Hidden sectors: %d\n", block->hiddenSectors);
 printf("Total Sectors (F32): %d\n", block->totalSectors_F32);
 printf("Drive Number: %d\n", block->driveNumber);
 printf("Boot Signature: %02X\n",block->bootSignature);
 printf("Volume ID: %d\n",block->volumeID);
 printf("Volume Label: ");
 print_char_bytes(block->volumeLabel,11);
 printf("\n");
 printf("Filesystem Type: ");
 print_char_bytes(block->fileSystemType,8);
 printf("\n");
}

variable_types: struct eboot_param_block_F16_t { unsigned char jumpBoot[3]; char OEMName[8]; unsigned short bytesPerSector; unsigned char sectorPerCluster; unsigned short reservedSectorCount; unsigned char numberofFATs; unsigned short rootEntryCount; unsigned short totalSectors_F16; unsigned char mediaType; unsigned short FATsize_F16; short sectorsPerTrack; unsigned short numberofHeads; unsigned int hiddenSectors; unsigned int totalSectors_F32; unsigned char driveNumber; unsigned char reserved; unsigned char bootSignature; unsigned int volumeID; char volumeLabel[11]; char fileSystemType[8]; unsigned char bootData[448]; unsigned short bootEndSignature; } *


decompiled_code:
int __fastcall dump_eboot_F32(__int64 a1)
{
printf("Jump Assembly: ");
print_hex_bytes(a1, 3);
putchar(10);
printf("OEM Identifier: %s\n", (const char *)(a1 + 3));
printf("Bytes per sector: %d\n", *(unsigned __int16 *)(a1 + 11));
printf("Sectors per cluster: %d\n", *(unsigned __int8 *)(a1 + 13));
printf("Reserved sectors: %d\n", *(unsigned __int16 *)(a1 + 14));
printf("Number of FAT tables: %d\n", *(unsigned __int8 *)(a1 + 16));
printf("Number of Directory entries: %d\n", *(unsigned __int16 *)(a1 + 17));
printf("Total sectors (F16): %d\n", *(unsigned __int16 *)(a1 + 19));
printf("Media Descriptor: %02x\n", *(unsigned __int8 *)(a1 + 21));
printf("Sectors per FAT (F16): %d\n", *(unsigned __int16 *)(a1 + 22));
printf("Sectors per track: %d\n", (unsigned int)*(__int16 *)(a1 + 24));
printf("Head count: %d\n", *(unsigned __int16 *)(a1 + 26));
printf("Hidden sectors: %d\n", *(unsigned int *)(a1 + 28));
printf("Total Sectors (F32): %d\n", *(unsigned int *)(a1 + 32));
printf("Sectors per FAT (F32): %d\n", *(unsigned int *)(a1 + 36));
printf("Flags: %d\n", *(unsigned __int16 *)(a1 + 40));
printf("FAT Version Number: %d\n", *(unsigned __int16 *)(a1 + 42));
printf("Root directory cluster: %d\n", *(unsigned int *)(a1 + 44));
printf("FileSystem Info cluster: %d\n", *(unsigned __int16 *)(a1 + 48));
printf("Backup BootSector cluster: %d\n", *(unsigned __int16 *)(a1 + 50));
printf("Reserved: ");
print_hex_bytes(a1 + 52, 12);
putchar(10);
printf("Drive Number: %d\n", *(unsigned __int8 *)(a1 + 64));
printf("Reserved: %d\n", *(unsigned __int8 *)(a1 + 65));
printf("Boot Signature: %02X\n", *(unsigned __int8 *)(a1 + 66));
printf("Volume ID: %d\n", *(unsigned int *)(a1 + 67));
printf("Volume Label: ");
print_char_bytes((char *)(a1 + 71), 11);
printf("Filesystem Type: ");
return print_char_bytes((char *)(a1 + 82), 8);
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
printf("Jump Assembly: ");
func0(a1, 3);
putchar(10);
printf("OEM Identifier: %s\n", (const char *)(a1 + 3));
printf("Bytes per sector: %d\n", *(unsigned __int16 *)(a1 + 11));
printf("Sectors per cluster: %d\n", *(unsigned __int8 *)(a1 + 13));
printf("Reserved sectors: %d\n", *(unsigned __int16 *)(a1 + 14));
printf("Number of FAT tables: %d\n", *(unsigned __int8 *)(a1 + 16));
printf("Number of Directory entries: %d\n", *(unsigned __int16 *)(a1 + 17));
printf("Total sectors (F16): %d\n", *(unsigned __int16 *)(a1 + 19));
printf("Media Descriptor: %02x\n", *(unsigned __int8 *)(a1 + 21));
printf("Sectors per FAT (F16): %d\n", *(unsigned __int16 *)(a1 + 22));
printf("Sectors per track: %d\n", (unsigned int)*(__int16 *)(a1 + 24));
printf("Head count: %d\n", *(unsigned __int16 *)(a1 + 26));
printf("Hidden sectors: %d\n", *(unsigned int *)(a1 + 28));
printf("Total Sectors (F32): %d\n", *(unsigned int *)(a1 + 32));
printf("Sectors per FAT (F32): %d\n", *(unsigned int *)(a1 + 36));
printf("Flags: %d\n", *(unsigned __int16 *)(a1 + 40));
printf("FAT Version Number: %d\n", *(unsigned __int16 *)(a1 + 42));
printf("Root directory cluster: %d\n", *(unsigned int *)(a1 + 44));
printf("FileSystem Info cluster: %d\n", *(unsigned __int16 *)(a1 + 48));
printf("Backup BootSector cluster: %d\n", *(unsigned __int16 *)(a1 + 50));
printf("Reserved: ");
func0(a1 + 52, 12);
putchar(10);
printf("Drive Number: %d\n", *(unsigned __int8 *)(a1 + 64));
printf("Reserved: %d\n", *(unsigned __int8 *)(a1 + 65));
printf("Boot Signature: %02X\n", *(unsigned __int8 *)(a1 + 66));
printf("Volume ID: %d\n", *(unsigned int *)(a1 + 67));
printf("Volume Label: ");
func1((char *)(a1 + 71), 11);
printf("Filesystem Type: ");
return func1((char *)(a1 + 82), 8);
}

original_code:
void dump_eboot_F32(struct eboot_param_block_F32_t* block) {
 printf("Jump Assembly: ");
 print_hex_bytes(block->jumpBoot,3);
 printf("\n");
 printf("OEM Identifier: %s\n",block->OEMName);
 printf("Bytes per sector: %d\n",block->bytesPerSector);
 printf("Sectors per cluster: %d\n",block->sectorPerCluster);
 printf("Reserved sectors: %d\n",block->reservedSectorCount);
 printf("Number of FAT tables: %d\n",block->numberofFATs);
 printf("Number of Directory entries: %d\n",block->rootEntryCount);
 printf("Total sectors (F16): %d\n",block->totalSectors_F16);
 printf("Media Descriptor: %02x\n",block->mediaType);
 printf("Sectors per FAT (F16): %d\n",block->FATsize_F16);
 printf("Sectors per track: %d\n",block->sectorsPerTrack);
 printf("Head count: %d\n",block->numberofHeads);
 printf("Hidden sectors: %d\n", block->hiddenSectors);
 printf("Total Sectors (F32): %d\n", block->totalSectors_F32);
 printf("Sectors per FAT (F32): %d\n", block->FATsize_F32);
 printf("Flags: %d\n", block->extFlags);
 printf("FAT Version Number: %d\n", block->FSversion);
 printf("Root directory cluster: %d\n",block->rootCluster);
 printf("FileSystem Info cluster: %d\n",block->FSinfo);
 printf("Backup BootSector cluster: %d\n",block->BackupBootSector);
 printf("Reserved: ");
 print_hex_bytes(block->reserved,12);
 printf("\n");
 printf("Drive Number: %d\n",block->driveNumber);
 printf("Reserved: %d\n", block->reserved1);
 printf("Boot Signature: %02X\n", block->bootSignature);
 printf("Volume ID: %d\n", block->volumeID);
 printf("Volume Label: ");
 print_char_bytes(block->volumeLabel,11);
 printf("Filesystem Type: ");
 print_char_bytes(block->fileSystemType,8);
}

canonical_original_code:
void dump_eboot_F32(struct eboot_param_block_F32_t *block) {
 printf("Jump Assembly: ");
 print_hex_bytes(block->jumpBoot,3);
 printf("\n");
 printf("OEM Identifier: %s\n",block->OEMName);
 printf("Bytes per sector: %d\n",block->bytesPerSector);
 printf("Sectors per cluster: %d\n",block->sectorPerCluster);
 printf("Reserved sectors: %d\n",block->reservedSectorCount);
 printf("Number of FAT tables: %d\n",block->numberofFATs);
 printf("Number of Directory entries: %d\n",block->rootEntryCount);
 printf("Total sectors (F16): %d\n",block->totalSectors_F16);
 printf("Media Descriptor: %02x\n",block->mediaType);
 printf("Sectors per FAT (F16): %d\n",block->FATsize_F16);
 printf("Sectors per track: %d\n",block->sectorsPerTrack);
 printf("Head count: %d\n",block->numberofHeads);
 printf("Hidden sectors: %d\n", block->hiddenSectors);
 printf("Total Sectors (F32): %d\n", block->totalSectors_F32);
 printf("Sectors per FAT (F32): %d\n", block->FATsize_F32);
 printf("Flags: %d\n", block->extFlags);
 printf("FAT Version Number: %d\n", block->FSversion);
 printf("Root directory cluster: %d\n",block->rootCluster);
 printf("FileSystem Info cluster: %d\n",block->FSinfo);
 printf("Backup BootSector cluster: %d\n",block->BackupBootSector);
 printf("Reserved: ");
 print_hex_bytes(block->reserved,12);
 printf("\n");
 printf("Drive Number: %d\n",block->driveNumber);
 printf("Reserved: %d\n", block->reserved1);
 printf("Boot Signature: %02X\n", block->bootSignature);
 printf("Volume ID: %d\n", block->volumeID);
 printf("Volume Label: ");
 print_char_bytes(block->volumeLabel,11);
 printf("Filesystem Type: ");
 print_char_bytes(block->fileSystemType,8);
}

user_defined_types: struct eboot_param_block_F32_t { unsigned char jumpBoot[3]; char OEMName[8]; unsigned short bytesPerSector; unsigned char sectorPerCluster; unsigned short reservedSectorCount; unsigned char numberofFATs; unsigned short rootEntryCount; unsigned short totalSectors_F16; unsigned char mediaType; unsigned short FATsize_F16; short sectorsPerTrack; unsigned short numberofHeads; unsigned int hiddenSectors; unsigned int totalSectors_F32; unsigned int FATsize_F32; unsigned short extFlags; unsigned short FSversion; unsigned int rootCluster; unsigned short FSinfo; unsigned short BackupBootSector; unsigned char reserved[12]; unsigned char driveNumber; unsigned char reserved1; unsigned char bootSignature; unsigned int volumeID; char volumeLabel[11]; char fileSystemType[8]; unsigned char bootData[420]; unsigned short bootEndSignature; }


repo: OHamm/IGOsat

decompiled_code:
int __fastcall print_long_long_int_bin(__int64 a1)
{
int i; // ebx
int result; // eax

for ( i = 63; i != -1; --i )
result = printf("%d", (a1 >> i) & 1);
return result;
}

canonical_decompiled_code:
int __fastcall func13(__int64 a1)
{
int i; // ebx
int result; // eax

for ( i = 63; i != -1; --i )
result = printf("%d", (a1 >> i) & 1);
return result;
}

original_code:
void print_long_long_int_bin(long long int n) {
 int i;
 for(i=0; i<64; i++)
  printf("%d", (int) (n >> (63 - i)) & 1);
}

canonical_original_code:
void print_long_long_int_bin(long long n) {
 int i;
 for(i=0; i<64; i++)
  printf("%d", (int) (n >> (63 - i)) & 1);
}

variable_types:
n
long long


decompiled_code:
int __fastcall print_char(char a1)
{
int i; // ebx
int result; // eax

for ( i = 7; i != -1; --i )
result = printf("%d", (a1 >> i) & 1);
return result;
}

canonical_decompiled_code:
int __fastcall func14(char a1)
{
int i; // ebx
int result; // eax

for ( i = 7; i != -1; --i )
result = printf("%d", (a1 >> i) & 1);
return result;
}

original_code:
void print_char(char c) {
 int i;
 for(i=0; i<8; i++) printf("%d", (c >> (7-i)) & 1);
}

variable_types: c char


decompiled_code:
int __fastcall print_chars(__int64 a1, int a2)
{
char *v2; // rbx
int result; // eax

if ( a2 > 0 )
{
v2 = (char *)(a1 + a2 - 1);
do
result = print_char(*v2--);
while ( v2 != (char *)(a1 + a2 - 2 - (unsigned int)(a2 - 1)) );
}
return result;
}

canonical_decompiled_code:
int __fastcall func15(__int64 a1, int a2)
{
char *v2; // rbx
int result; // eax

if ( a2 > 0 )
{
v2 = (char *)(a1 + a2 - 1);
do
result = func14(*v2--);
while ( v2 != (char *)(a1 + a2 - 2 - (unsigned int)(a2 - 1)) );
}
return result;
}

original_code:
void print_chars(char* str, int l) {
 int i;
 for(i=0; i<l; i++) print_char(str[l-1-i]);
}

canonical_original_code:
void print_chars(char *str, int l) {
 int i;
 for(i=0; i<l; i++) print_char(str[l-1-i]);
}

variable_types:
str
char *

variable_types: l int


decompiled_code:
__int64 __fastcall combine_two(unsigned int a1, unsigned int a2, int a3)
{
__int64 result; // rax

switch ( a3 )
{
case 0:
result = a2;
break;
case 1:
result = a2 & 0x7F | a1 & 0xFFFFFF80;
break;
case 2:
result = a2 & 0x3F | a1 & 0xFFFFFFC0;
break;
case 3:
result = a2 & 0x1F | a1 & 0xFFFFFFE0;
break;
case 4:
result = a2 & 0xF | a1 & 0xFFFFFFF0;
break;
case 5:
result = a2 & 7 | a1 & 0xFFFFFFF8;
break;
case 6:
result = a2 & 3 | a1 & 0xFFFFFFFC;
break;
case 7:
result = a2 & 1 | a1 & 0xFFFFFFFE;
break;
case 8:
result = a1;
break;
default:
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1, unsigned int a2, int a3)
{
__int64 result; // rax

switch ( a3 )
{
case 0:
result = a2;
break;
case 1:
result = a2 & 0x7F | a1 & 0xFFFFFF80;
break;
case 2:
result = a2 & 0x3F | a1 & 0xFFFFFFC0;
break;
case 3:
result = a2 & 0x1F | a1 & 0xFFFFFFE0;
break;
case 4:
result = a2 & 0xF | a1 & 0xFFFFFFF0;
break;
case 5:
result = a2 & 7 | a1 & 0xFFFFFFF8;
break;
case 6:
result = a2 & 3 | a1 & 0xFFFFFFFC;
break;
case 7:
result = a2 & 1 | a1 & 0xFFFFFFFE;
break;
case 8:
result = a1;
break;
default:
result = 0LL;
break;
}
return result;
}

variable_types: first char

variable_types: second char

return_type: char


variable_types:
capteurs
int *

variable_types:
retour
int *


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

set_players();
v0 = ((__int64 (__fastcall *)(__int64))io_func[2])(7LL);
set_player_name(0LL, v0);
v1 = ((__int64 (__fastcall *)(__int64))io_func[2])(8LL);
set_player_name(1LL, v1);
result = io_func[0]();
if ( (_BYTE)result )
exit(2);
return result;
}

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

set_players();
v0 = ((__int64 (__fastcall *)(__int64))io_func[2])(7LL);
set_player_name(0LL, v0);
v1 = ((__int64 (__fastcall *)(__int64))io_func[2])(8LL);
set_player_name(1LL, v1);
result = io_func[0]();
if ( (_BYTE)result )
exit(2);
return result;
}

original_code:
static void global_init() {
   set_players();
   set_player_name(0, io_func.get_code_str(DEFAULT_PLAYER_NAME1));
   set_player_name(1, io_func.get_code_str(DEFAULT_PLAYER_NAME2));
   if (io_func.init_io())
      exit(2);
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 v3; // r12
void **v4; // rax
void **v5; // rbp
void **v6; // rbx
void **v7; // r12
char v8; // al
bool v9; // bl
char v10; // r12
void (*v11)(void); // rax
void (*v12)(void); // rax
void (*v13)(void); // rax
void (*v14)(void); // rax
__int64 v15; // rbx
unsigned __int8 v16; // al
char v17; // r12
char v18; // al
__int64 v19; // rbx
__int64 (*v21)(void); // rbx
__int64 v22; // rax
const char *v23; // rdi
void (*v24)(void); // rax
void (*v25)(void); // rax
char v26[2]; // [rsp+Ch] [rbp-1Ch] BYREF
unsigned __int8 v27; // [rsp+Eh] [rbp-1Ah] BYREF
unsigned __int8 v28; // [rsp+Fh] [rbp-19h]

global_init(argc, argv, envp);
if ( (unsigned __int8)is_error() )
exit(1);
if ( (unsigned __int8)show_start_menu() == 4 )
{
if ( !(unsigned __int8)is_error() )
goto LABEL_40;
v5 = 0LL;
}
else
{
rule_func(&v27);
v3 = v28;
v4 = (void **)calloc(v28, 8uLL);
v5 = v4;
if ( v3 )
{
v6 = v4;
v7 = &v4[v3];
do
*v6++ = calloc(v27, 1uLL);
while ( v6 != v7 );
}
while ( 1 )
{
(*(&rule_func + 1))(v5);
v13 = *(void (**)(void))*g_player;
if ( v13 )
v13();
v14 = (void (*)(void))***((_QWORD ***)&g_player + 1);
if ( v14 )
v14();
((void (__fastcall *)(void **, unsigned __int8 *))io_func[4])(v5, &v27);
v15 = g_player;
v10 = is_error();
if ( v10 )
break;
while ( 1 )
{
do
{
while ( !(*(unsigned int (__fastcall **)(char *, __int64))(*(_QWORD *)v15 + 8LL))(v26, v15) )
{
if ( (unsigned __int8)is_error() )
goto LABEL_34;
v8 = show_context_menu();
if ( v8 )
{
v9 = v8 != 2;
v10 = 1;
goto LABEL_11;
}
((void (__fastcall *)(void **, unsigned __int8 *))io_func[4])(v5, &v27);
}
}
while ( !((unsigned __int8 (__fastcall *)(bool, char *))*(&rule_func + 3))(g_player != v15, v26) );
((void (__fastcall *)(void **, unsigned __int8 *))io_func[4])(v5, &v27);
v16 = ((__int64 (*)(void))*(&rule_func + 4))();
if ( v16 != 3 )
break;
if ( (unsigned __int8)is_error() )
goto LABEL_34;
v15 = *((_QWORD *)&g_player + (g_player == v15));
}
((void (__fastcall *)(_QWORD, __int64))io_func[5])(v16, v15);
v9 = 1;
LABEL_11:
v11 = *(void (**)(void))(*g_player + 16LL);
if ( v11 )
v11();
v12 = *(void (**)(void))(**((_QWORD **)&g_player + 1) + 16LL);
if ( v12 )
v12();
if ( (unsigned __int8)is_error() )
break;
if ( !v10 )
{
v17 = show_finish_menu();
v18 = is_error();
if ( v17 == 4 || v18 )
break;
if ( v17 == 2 )
goto LABEL_33;
}
if ( !v9 )
{
LABEL_33:
if ( (unsigned __int8)show_start_menu() == 4 )
break;
}
}
LABEL_34:
if ( !(unsigned __int8)is_error() )
goto LABEL_35;
}
v23 = (const char *)get_error();
if ( !strncmp(v23, "quit", 5uLL) )
{
clear_error();
}
else
{
v21 = io_func[8];
v22 = get_error();
((void (__fastcall *)(__int64))v21)(v22);
}
v24 = *(void (**)(void))(*g_player + 16LL);
if ( v24 )
v24();
v25 = *(void (**)(void))(**((_QWORD **)&g_player + 1) + 16LL);
if ( v25 )
v25();
LABEL_35:
if ( v5 )
{
if ( v28 )
{
v19 = 0LL;
do
free(v5[v19++]);
while ( v28 > (int)v19 );
}
free(v5);
}
LABEL_40:
io_func[1]();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 v3; // r12
void **v4; // rax
void **v5; // rbp
void **v6; // rbx
void **v7; // r12
char v8; // al
bool v9; // bl
char v10; // r12
void (*v11)(void); // rax
void (*v12)(void); // rax
void (*v13)(void); // rax
void (*v14)(void); // rax
__int64 v15; // rbx
unsigned __int8 v16; // al
char v17; // r12
char v18; // al
__int64 v19; // rbx
__int64 (*v21)(void); // rbx
__int64 v22; // rax
const char *v23; // rdi
void (*v24)(void); // rax
void (*v25)(void); // rax
char v26[2]; // [rsp+Ch] [rbp-1Ch] BYREF
unsigned __int8 v27; // [rsp+Eh] [rbp-1Ah] BYREF
unsigned __int8 v28; // [rsp+Fh] [rbp-19h]

func0(argc, argv, envp);
if ( (unsigned __int8)is_error() )
exit(1);
if ( (unsigned __int8)show_start_menu() == 4 )
{
if ( !(unsigned __int8)is_error() )
goto LABEL_40;
v5 = 0LL;
}
else
{
rule_func(&v27);
v3 = v28;
v4 = (void **)calloc(v28, 8uLL);
v5 = v4;
if ( v3 )
{
v6 = v4;
v7 = &v4[v3];
do
*v6++ = calloc(v27, 1uLL);
while ( v6 != v7 );
}
while ( 1 )
{
(*(&rule_func + 1))(v5);
v13 = *(void (**)(void))*g_player;
if ( v13 )
v13();
v14 = (void (*)(void))***((_QWORD ***)&g_player + 1);
if ( v14 )
v14();
((void (__fastcall *)(void **, unsigned __int8 *))io_func[4])(v5, &v27);
v15 = g_player;
v10 = is_error();
if ( v10 )
break;
while ( 1 )
{
do
{
while ( !(*(unsigned int (__fastcall **)(char *, __int64))(*(_QWORD *)v15 + 8LL))(v26, v15) )
{
if ( (unsigned __int8)is_error() )
goto LABEL_34;
v8 = show_context_menu();
if ( v8 )
{
v9 = v8 != 2;
v10 = 1;
goto LABEL_11;
}
((void (__fastcall *)(void **, unsigned __int8 *))io_func[4])(v5, &v27);
}
}
while ( !((unsigned __int8 (__fastcall *)(bool, char *))*(&rule_func + 3))(g_player != v15, v26) );
((void (__fastcall *)(void **, unsigned __int8 *))io_func[4])(v5, &v27);
v16 = ((__int64 (*)(void))*(&rule_func + 4))();
if ( v16 != 3 )
break;
if ( (unsigned __int8)is_error() )
goto LABEL_34;
v15 = *((_QWORD *)&g_player + (g_player == v15));
}
((void (__fastcall *)(_QWORD, __int64))io_func[5])(v16, v15);
v9 = 1;
LABEL_11:
v11 = *(void (**)(void))(*g_player + 16LL);
if ( v11 )
v11();
v12 = *(void (**)(void))(**((_QWORD **)&g_player + 1) + 16LL);
if ( v12 )
v12();
if ( (unsigned __int8)is_error() )
break;
if ( !v10 )
{
v17 = show_finish_menu();
v18 = is_error();
if ( v17 == 4 || v18 )
break;
if ( v17 == 2 )
goto LABEL_33;
}
if ( !v9 )
{
LABEL_33:
if ( (unsigned __int8)show_start_menu() == 4 )
break;
}
}
LABEL_34:
if ( !(unsigned __int8)is_error() )
goto LABEL_35;
}
v23 = (const char *)get_error();
if ( !strncmp(v23, "quit", 5uLL) )
{
clear_error();
}
else
{
v21 = io_func[8];
v22 = get_error();
((void (__fastcall *)(__int64))v21)(v22);
}
v24 = *(void (**)(void))(*g_player + 16LL);
if ( v24 )
v24();
v25 = *(void (**)(void))(**((_QWORD **)&g_player + 1) + 16LL);
if ( v25 )
v25();
LABEL_35:
if ( v5 )
{
if ( v28 )
{
v19 = 0LL;
do
free(v5[v19++]);
while ( v28 > (int)v19 );
}
free(v5);
}
LABEL_40:
io_func[1]();
return 0;
}

original_code:
int main(int argc, char *argv[]) {
   uint8_t **field = ((void *)0);
   point_t field_size, input;
   uint8_t state;
   player_ent_t *cur_player;
   uint8_t skip_finish_menu = 0, skip_start_menu = 1;
   global_init();
   if (is_error())
      exit(1);
   if (show_start_menu() == MC_EXIT)
      goto exit;
   rule_func.get_field_size(&field_size);
   field = (uint8_t **) calloc(field_size.y, sizeof(uint8_t *));
   for (int i = 0; i < field_size.y; i++)
      field[i] = (uint8_t *) calloc(field_size.x, sizeof(uint8_t));
   while (1) {
      if (!skip_start_menu && show_start_menu() == MC_EXIT)
         break;
      skip_start_menu = 1;
      rule_func.fill_field(field);
      if (g_player[0]->func_list->init_player)
         g_player[0]->func_list->init_player(g_player[0]);
      if (g_player[1]->func_list->init_player)
         g_player[1]->func_list->init_player(g_player[1]);
      io_func.show_field(field, &field_size);
      cur_player = g_player[0];
      if (is_error())
         goto exit;
      while(1) {
         if (!cur_player->func_list->get_player_input(&input, cur_player)) {
            if (is_error())
               goto exit;
            uint8_t choice = show_context_menu();
            if (choice == MC_CONTINUE_GAME) {
               io_func.show_field(field, &field_size);
               continue;
            }
            else {
               skip_finish_menu = 1;
               if (choice == MC_MAIN_MENU)
                  skip_start_menu = 0;
               break;
            }
            if (is_error())
               goto exit;
         }
         if (!rule_func.check_and_apply_move((cur_player == g_player[0] ? 0 : 1),
            (void *) &input)) {
            continue;
         }
         io_func.show_field(field, &field_size);
         state = rule_func.check_end_conditions();
         if (state != GS_ONGOING) {
            io_func.show_result(state, cur_player);
            break;
         }
         if (is_error())
            goto exit;
         cur_player = g_player[(cur_player == g_player[0] ? 1 : 0)];
      }
      if (g_player[0]->func_list->clear_data)
         g_player[0]->func_list->clear_data(g_player[0]);
      if (g_player[1]->func_list->clear_data)
         g_player[1]->func_list->clear_data(g_player[1]);
      if (is_error())
         goto exit;
      if (!skip_finish_menu) {
         uint8_t choice = show_finish_menu();
         if (is_error())
            goto exit;
         if (choice == MC_EXIT)
            break;
         if (choice == MC_MAIN_MENU)
            skip_start_menu = 0;
      }
      else
         skip_finish_menu = 0;
   }
exit:
   if (is_error()) {
      if (!strncmp(get_error(), "quit", 5))
         clear_error();
      else
         io_func.show_error(get_error());
      if (g_player[0]->func_list->clear_data)
         g_player[0]->func_list->clear_data(g_player[0]);
      if (g_player[1]->func_list->clear_data)
         g_player[1]->func_list->clear_data(g_player[1]);
   }
   if (field) {
      for (int i = 0; i < field_size.y; i++)
         free(field[i]);
      free(field);
   }
   io_func.clear_io();
}

canonical_original_code:
int main(int argc, char *argv[]) {
   unsigned char **field = ((void *)0);
   struct point_t field_size; struct point_t input;
   unsigned char state;
   struct player_ent_t *cur_player;
   unsigned char skip_finish_menu = 0; unsigned char skip_start_menu = 1;
   global_init();
   if (is_error())
      exit(1);
   if (show_start_menu() == MC_EXIT)
      goto exit;
   rule_func.get_field_size(&field_size);
   field = (unsigned char **) calloc(field_size.y, sizeof(unsigned char *));
   for (int i = 0; i < field_size.y; i++)
      field[i] = (unsigned char *) calloc(field_size.x, sizeof(unsigned char));
   while (1) {
      if (!skip_start_menu && show_start_menu() == MC_EXIT)
         break;
      skip_start_menu = 1;
      rule_func.fill_field(field);
      if (g_player[0]->func_list->init_player)
         g_player[0]->func_list->init_player(g_player[0]);
      if (g_player[1]->func_list->init_player)
         g_player[1]->func_list->init_player(g_player[1]);
      io_func.show_field(field, &field_size);
      cur_player = g_player[0];
      if (is_error())
         goto exit;
      while(1) {
         if (!cur_player->func_list->get_player_input(&input, cur_player)) {
            if (is_error())
               goto exit;
            unsigned char choice = show_context_menu();
            if (choice == MC_CONTINUE_GAME) {
               io_func.show_field(field, &field_size);
               continue;
            }
            else {
               skip_finish_menu = 1;
               if (choice == MC_MAIN_MENU)
                  skip_start_menu = 0;
               break;
            }
            if (is_error())
               goto exit;
         }
         if (!rule_func.check_and_apply_move((cur_player == g_player[0] ? 0 : 1),
            (void *) &input)) {
            continue;
         }
         io_func.show_field(field, &field_size);
         state = rule_func.check_end_conditions();
         if (state != GS_ONGOING) {
            io_func.show_result(state, cur_player);
            break;
         }
         if (is_error())
            goto exit;
         cur_player = g_player[(cur_player == g_player[0] ? 1 : 0)];
      }
      if (g_player[0]->func_list->clear_data)
         g_player[0]->func_list->clear_data(g_player[0]);
      if (g_player[1]->func_list->clear_data)
         g_player[1]->func_list->clear_data(g_player[1]);
      if (is_error())
         goto exit;
      if (!skip_finish_menu) {
         unsigned char choice = show_finish_menu();
         if (is_error())
            goto exit;
         if (choice == MC_EXIT)
            break;
         if (choice == MC_MAIN_MENU)
            skip_start_menu = 0;
      }
      else
         skip_finish_menu = 0;
   }
exit:
   if (is_error()) {
      if (!strncmp(get_error(), "quit", 5))
         clear_error();
      else
         io_func.show_error(get_error());
      if (g_player[0]->func_list->clear_data)
         g_player[0]->func_list->clear_data(g_player[0]);
      if (g_player[1]->func_list->clear_data)
         g_player[1]->func_list->clear_data(g_player[1]);
   }
   if (field) {
      for (int i = 0; i < field_size.y; i++)
         free(field[i]);
      free(field);
   }
   io_func.clear_io();
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
field
unsigned char **

variable_types:
state
unsigned char

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

variable_types:
choice
unsigned char

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

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


decompiled_code:
_BOOL8 __fastcall check_horizontal(unsigned __int8 a1)
{
_BYTE *v1; // rdx
_BOOL8 result; // rax

v1 = *(_BYTE **)(main_field + 8LL * a1);
result = 0LL;
if ( *v1 == v1[1] )
result = v1[2] == *v1;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned __int8 a1)
{
_BYTE *v1; // rdx
_BOOL8 result; // rax

v1 = *(_BYTE **)(main_field + 8LL * a1);
result = 0LL;
if ( *v1 == v1[1] )
result = v1[2] == *v1;
return result;
}

original_code:
static uint8_t check_horizontal(uint8_t line) {
   return main_field[line][0] == main_field[line][1] &&
      main_field[line][0] == main_field[line][2];
}

canonical_original_code:
static unsigned char check_horizontal(unsigned char line) {
   return main_field[line][0] == main_field[line][1] &&
      main_field[line][0] == main_field[line][2];
}

variable_types:
line
unsigned char

return_type: unsigned char


decompiled_code:
_BOOL8 __fastcall check_vertical(unsigned __int8 a1)
{
unsigned __int8 v1; // cl
_BOOL8 result; // rax

v1 = *(_BYTE *)(*(_QWORD *)main_field + a1);
result = 0LL;
if ( v1 == *(_BYTE *)(*(_QWORD *)(main_field + 8) + a1) )
result = *(_BYTE *)(*(_QWORD *)(main_field + 16) + a1) == v1;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned __int8 a1)
{
unsigned __int8 v1; // cl
_BOOL8 result; // rax

v1 = *(_BYTE *)(*(_QWORD *)main_field + a1);
result = 0LL;
if ( v1 == *(_BYTE *)(*(_QWORD *)(main_field + 8) + a1) )
result = *(_BYTE *)(*(_QWORD *)(main_field + 16) + a1) == v1;
return result;
}

original_code:
static uint8_t check_vertical(uint8_t col) {
   return main_field[0][col] == main_field[1][col] &&
      main_field[0][col] == main_field[2][col];
}

canonical_original_code:
static unsigned char check_vertical(unsigned char col) {
   return main_field[0][col] == main_field[1][col] &&
      main_field[0][col] == main_field[2][col];
}

variable_types:
col
unsigned char


decompiled_code:
_BOOL8 __fastcall check_diagonal(char a1)
{
unsigned __int8 *v1; // rdx
unsigned __int8 v2; // dl
__int64 v4; // rcx
__int64 v5; // rax

v1 = *(unsigned __int8 **)main_field;
if ( !a1 )
{
v2 = v1[2];
if ( v2 != *(_BYTE *)(*(_QWORD *)(main_field + 8) + 1LL) )
return 0LL;
v4 = *(_QWORD *)(main_field + 16);
v5 = 0LL;
return *(_BYTE *)(v4 + v5) == v2;
}
v2 = *v1;
if ( v2 == *(_BYTE *)(*(_QWORD *)(main_field + 8) + 1LL) )
{
v4 = *(_QWORD *)(main_field + 16);
v5 = 2LL;
return *(_BYTE *)(v4 + v5) == v2;
}
return 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(char a1)
{
unsigned __int8 *v1; // rdx
unsigned __int8 v2; // dl
__int64 v4; // rcx
__int64 v5; // rax

v1 = *(unsigned __int8 **)main_field;
if ( !a1 )
{
v2 = v1[2];
if ( v2 != *(_BYTE *)(*(_QWORD *)(main_field + 8) + 1LL) )
return 0LL;
v4 = *(_QWORD *)(main_field + 16);
v5 = 0LL;
return *(_BYTE *)(v4 + v5) == v2;
}
v2 = *v1;
if ( v2 == *(_BYTE *)(*(_QWORD *)(main_field + 8) + 1LL) )
{
v4 = *(_QWORD *)(main_field + 16);
v5 = 2LL;
return *(_BYTE *)(v4 + v5) == v2;
}
return 0LL;
}

original_code:
static uint8_t check_diagonal(uint8_t main_diag) {
   return main_field[0][main_diag ? 0 : 2] == main_field[1][1] &&
      main_field[0][main_diag ? 0 : 2] == main_field[2][main_diag ? 2 : 0];
}

canonical_original_code:
static unsigned char check_diagonal(unsigned char main_diag) {
   return main_field[0][main_diag ? 0 : 2] == main_field[1][1] &&
      main_field[0][main_diag ? 0 : 2] == main_field[2][main_diag ? 2 : 0];
}


decompiled_code:
__int64 get_field()
{
return main_field;
}

canonical_decompiled_code:
__int64 func4()
{
return main_field;
}

original_code:
uint8_t **get_field() {
   return main_field;
}

canonical_original_code:
unsigned char **get_field() {
   return main_field;
}

return_type: unsigned char **


decompiled_code:
__int64 __fastcall check_and_apply_move(char a1, unsigned __int8 *a2)
{
unsigned int v2; // edx
unsigned __int8 v3; // cl
_BYTE *v4; // rax

v2 = 0;
if ( *a2 <= 2u )
{
v3 = a2[1];
if ( v3 <= 2u )
{
v4 = (_BYTE *)(*(_QWORD *)(main_field + 8LL * v3) + *a2);
v2 = 0;
if ( !*v4 )
{
*v4 = 1 - ((a1 == 0) - 1);
v2 = 1;
}
}
}
return v2;
}

original_code:
uint8_t check_and_apply_move(uint8_t turn, void *data) {
   point_t *move = (point_t *) data;
   if (move->x >= 3 || move->y >= 3) {
      return 0;
   }
   if (main_field[move->y][move->x] != EMPTY) {
      return 0;
   }
   main_field[move->y][move->x] = (turn == 0 ? CROSS : NOUGHT);
   return 1;
}

canonical_original_code:
unsigned char check_and_apply_move(unsigned char turn, void *data) {
   struct point_t *move = (point_t *) data;
   if (move->x >= 3 || move->y >= 3) {
      return 0;
   }
   if (main_field[move->y][move->x] != EMPTY) {
      return 0;
   }
   main_field[move->y][move->x] = (turn == 0 ? CROSS : NOUGHT);
   return 1;
}

variable_types:
turn
unsigned char

variable_types:
data
void *

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


decompiled_code:
char check_end_conditions()
{
__int64 v0; // r12
char v1; // r15
char v2; // di
__int64 i; // rbx
char v4; // bp

v0 = 0LL;
v1 = 0;
while ( 2 )
{
for ( i = 0LL; i != 3; ++i )
{
v4 = *(_BYTE *)(*(_QWORD *)(main_field + 8 * v0) + i);
if ( v4 )
{
if ( (unsigned __int8)(v4 - 1) > 1u )
{
set_error("rule error: wrong sign", 22LL);
}
else if ( (_DWORD)v0 )
{
if ( !(_DWORD)i && check_horizontal(v0) )
return v4 != 1;
}
else
{
if ( check_vertical(i) )
return v4 != 1;
if ( (_DWORD)i )
{
if ( (i & 0xFFFFFFFD) != 0 )
continue;
v2 = 0;
}
else
{
if ( check_horizontal(0) )
return v4 != 1;
v2 = 1;
}
if ( check_diagonal(v2) )
return v4 != 1;
}
}
else
{
v1 = 1;
}
}
if ( ++v0 != 3 )
continue;
break;
}
return v1 + 2;
}

canonical_decompiled_code:
char func7()
{
__int64 v0; // r12
char v1; // r15
char v2; // di
__int64 i; // rbx
char v4; // bp

v0 = 0LL;
v1 = 0;
while ( 2 )
{
for ( i = 0LL; i != 3; ++i )
{
v4 = *(_BYTE *)(*(_QWORD *)(main_field + 8 * v0) + i);
if ( v4 )
{
if ( (unsigned __int8)(v4 - 1) > 1u )
{
set_error("rule error: wrong sign", 22LL);
}
else if ( (_DWORD)v0 )
{
if ( !(_DWORD)i && func0(v0) )
return v4 != 1;
}
else
{
if ( func1(i) )
return v4 != 1;
if ( (_DWORD)i )
{
if ( (i & 0xFFFFFFFD) != 0 )
continue;
v2 = 0;
}
else
{
if ( func0(0) )
return v4 != 1;
v2 = 1;
}
if ( func2(v2) )
return v4 != 1;
}
}
else
{
v1 = 1;
}
}
if ( ++v0 != 3 )
continue;
break;
}
return v1 + 2;
}

original_code:
uint8_t check_end_conditions() {
   uint8_t is_empty = 0;
   for (int i = 0; i < 3; i++) {
      for ( int j = 0; j < 3; j++) {
         switch (main_field[i][j]) {
         case EMPTY:
            is_empty = 1;
            break;
         case CROSS:
         case NOUGHT:
            if ((i == 0 && check_vertical(j)) || (j == 0 &&
               check_horizontal(i)) || (i == 0 && (j == 0 || j == 2)
               && check_diagonal((j == 0)))) {
               return main_field[i][j] == CROSS ? GS_PLAYER1_VICTORY :
                  GS_PLAYER2_VICTORY;
            }
            break;
         default: set_error("rule error: wrong sign",
            strlen("rule error: wrong sign"));
         }
      }
   }
   return is_empty ? GS_ONGOING : GS_DRAW;
}

canonical_original_code:
unsigned char check_end_conditions() {
   unsigned char is_empty = 0;
   for (int i = 0; i < 3; i++) {
      for ( int j = 0; j < 3; j++) {
         switch (main_field[i][j]) {
         case EMPTY:
            is_empty = 1;
            break;
         case CROSS:
         case NOUGHT:
            if ((i == 0 && check_vertical(j)) || (j == 0 &&
               check_horizontal(i)) || (i == 0 && (j == 0 || j == 2)
               && check_diagonal((j == 0)))) {
               return main_field[i][j] == CROSS ? GS_PLAYER1_VICTORY :
                  GS_PLAYER2_VICTORY;
            }
            break;
         default: set_error("rule error: wrong sign",
            strlen("rule error: wrong sign"));
         }
      }
   }
   return is_empty ? GS_ONGOING : GS_DRAW;
}

variable_types: i int

variable_types: j int


decompiled_code:
_BOOL8 __fastcall get_winning_cond(_BYTE *a1)
{
int v1; // ebx
_BOOL8 result; // rax

if ( check_diagonal(1) )
{
*a1 = 1;
a1[1] = 1;
a1[2] = 3;
a1[3] = 3;
result = 1LL;
}
else
{
v1 = 0;
if ( check_diagonal(0) )
{
*a1 = 1;
a1[1] = 3;
a1[2] = 3;
a1[3] = 1;
result = 1LL;
}
else
{
while ( 1 )
{
if ( check_vertical(v1) )
{
*a1 = 1;
a1[1] = v1 + 1;
a1[2] = 3;
a1[3] = v1 + 1;
return 1LL;
}
result = check_horizontal(v1);
if ( result )
break;
if ( ++v1 == 3 )
return result;
}
*a1 = v1 + 1;
a1[1] = 1;
a1[2] = v1 + 1;
a1[3] = 3;
result = 1LL;
}
}
return result;
}

original_code:
uint8_t get_winning_cond(void *data) {
   winning_data_t *winning_data = (winning_data_t *) data;
   if (check_diagonal(1)) {
      winning_data->start_point.x = 1;
      winning_data->start_point.y = 1;
      winning_data->end_point.x = 3;
      winning_data->end_point.y = 3;
      return 1;
   }
   else if (check_diagonal(0)) {
      winning_data->start_point.x = 1;
      winning_data->start_point.y = 3;
      winning_data->end_point.x = 3;
      winning_data->end_point.y = 1;
      return 1;
   }
   else {
      for (uint8_t i = 0; i < 3; i++) {
         if (check_vertical(i)) {
            winning_data->start_point.x = 1;
            winning_data->start_point.y = i + 1;
            winning_data->end_point.x = 3;
            winning_data->end_point.y = i + 1;
            return 1;
         }
         if (check_horizontal(i)) {
            winning_data->start_point.x = i + 1;
            winning_data->start_point.y = 1;
            winning_data->end_point.x = i + 1;
            winning_data->end_point.y = 3;
            return 1;
         }
      }
   }
   return 0;
}

canonical_original_code:
unsigned char get_winning_cond(void *data) {
   struct winning_data_t *winning_data = (winning_data_t *) data;
   if (check_diagonal(1)) {
      winning_data->start_point.x = 1;
      winning_data->start_point.y = 1;
      winning_data->end_point.x = 3;
      winning_data->end_point.y = 3;
      return 1;
   }
   else if (check_diagonal(0)) {
      winning_data->start_point.x = 1;
      winning_data->start_point.y = 3;
      winning_data->end_point.x = 3;
      winning_data->end_point.y = 1;
      return 1;
   }
   else {
      for (unsigned char i = 0; i < 3; i++) {
         if (check_vertical(i)) {
            winning_data->start_point.x = 1;
            winning_data->start_point.y = i + 1;
            winning_data->end_point.x = 3;
            winning_data->end_point.y = i + 1;
            return 1;
         }
         if (check_horizontal(i)) {
            winning_data->start_point.x = i + 1;
            winning_data->start_point.y = 1;
            winning_data->end_point.x = i + 1;
            winning_data->end_point.y = 3;
            return 1;
         }
      }
   }
   return 0;
}

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

variable_types:
i
unsigned char

user_defined_types: struct winning_data_t { struct point_t start_point; struct point_t end_point; }


decompiled_code:
__int64 simple_start_game()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 1LL;
}

original_code:
uint8_t simple_start_game(menu_item_t const *ctx) {
   return MC_START_NEW_GAME;
}

canonical_original_code:
unsigned char simple_start_game(struct menu_item *ctx) {
   return MC_START_NEW_GAME;
}

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

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


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

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

original_code:
uint8_t continue_game(menu_item_t const *ctx) {
   return MC_CONTINUE_GAME;
}

canonical_original_code:
unsigned char continue_game(struct menu_item *ctx) {
   return MC_CONTINUE_GAME;
}

user_defined_types: enum menu_item_type_t { MENU_ITEM_CLICKABLE=0, MENU_ITEM_EDITABLE=1, MENU_ITEM_TEXT=2 }


decompiled_code:
__int64 show_main_menu()
{
return 2LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 2LL;
}

original_code:
uint8_t show_main_menu(menu_item_t const *ctx) {
   return MC_MAIN_MENU;
}

canonical_original_code:
unsigned char show_main_menu(struct menu_item *ctx) {
   return MC_MAIN_MENU;
}