decompiled_code:
__int64 __fastcall student_scanf(__int64 a1)
{
return student_fscanf((FILE *)stdin, a1);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
return func12((FILE *)stdin, a1);
}

original_code:
int student_scanf(student_t* student_pointer){
    return student_fscanf(stdin, student_pointer);
}

canonical_original_code:
int student_scanf(struct __student__ *student_pointer){
    return student_fscanf(stdin, student_pointer);
}

variable_types: struct __student__ { unsigned long number; enum gender_t { MALE=expr, FEMALE=expr } gender; char group[8]; char name[32]; enum passed_t { NOT_PASSED=0, PASSED=1 } physical_culture; enum passed_t { NOT_PASSED=0, PASSED=1 } english; enum mark_t { BAD=2, SATISFACTORY=3, GOOD=4, EXCELLENT=5 } mathematical_analysis; enum mark_t { BAD=2, SATISFACTORY=3, GOOD=4, EXCELLENT=5 } discrete_mathematics; enum mark_t { BAD=2, SATISFACTORY=3, GOOD=4, EXCELLENT=5 } linear_algebra; enum mark_t { BAD=2, SATISFACTORY=3, GOOD=4, EXCELLENT=5 } informatics; enum mark_t { BAD=2, SATISFACTORY=3, GOOD=4, EXCELLENT=5 } history; } *

user_defined_types: struct __student__ { unsigned long number; enum gender_t gender; char group[8]; char name[32]; enum passed_t physical_culture; enum passed_t english; enum mark_t mathematical_analysis; enum mark_t discrete_mathematics; enum mark_t linear_algebra; enum mark_t informatics; enum mark_t history; }


decompiled_code:
__int64 __fastcall student_printf(__int64 a1)
{
return student_fprintf(stdout, a1);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
return func14(stdout, a1);
}

original_code:
int student_printf(student_t* student_pointer){
    return student_fprintf(stdout, student_pointer);
}

canonical_original_code:
int student_printf(struct __student__ *student_pointer){
    return student_fprintf(stdout, student_pointer);
}

return_type: int

user_defined_types: enum gender_t { MALE=expr, FEMALE=expr }

user_defined_types: enum passed_t { NOT_PASSED=0, PASSED=1 }

user_defined_types: enum mark_t { BAD=2, SATISFACTORY=3, GOOD=4, EXCELLENT=5 }


decompiled_code:
_BOOL8 __fastcall is_upper(__int16 a1)
{
return (unsigned __int16)(a1 - 65) <= 0x19u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(__int16 a1)
{
return (unsigned __int16)(a1 - 65) <= 0x19u;
}

canonical_original_code:
enum bool_t is_upper(short symbol){
    if (('A' <= symbol) && (symbol <= 'Z'))
        return TRUE;
    return FALSE;
}

variable_types: symbol short

return_type: enum bool_t { FALSE=0, TRUE=1 }


decompiled_code:
_BOOL8 __fastcall is_lower(__int16 a1)
{
return (unsigned __int16)(a1 - 97) <= 0x19u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(__int16 a1)
{
return (unsigned __int16)(a1 - 97) <= 0x19u;
}

canonical_original_code:
enum bool_t is_lower(short symbol){
    if (('a' <= symbol) && (symbol <= 'z'))
        return TRUE;
    return FALSE;
}


cycle

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

result = a1;
if ( (__int16)a1 < (__int16)a2 )
{
do
result = (unsigned int)(result + a3 + 1 - a2);
while ( (__int16)a2 > (__int16)result );
}
for ( ; (__int16)a3 < (__int16)result; result = (unsigned int)(result + a2 - 1 - a3) )
;
return result;
}

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

result = a1;
if ( (__int16)a1 < (__int16)a2 )
{
do
result = (unsigned int)(result + a3 + 1 - a2);
while ( (__int16)a2 > (__int16)result );
}
for ( ; (__int16)a3 < (__int16)result; result = (unsigned int)(result + a2 - 1 - a3) )
;
return result;
}

original_code:
short cycle(short symbol, short start, short stop){
    while (symbol < start){
        symbol = symbol + (stop - start + 1);
    }
    while (stop < symbol){
        symbol = symbol - (stop - start + 1);
    }
    return symbol;
}

variable_types: start short

variable_types: stop short

return_type: short


offset

decompiled_code:
__int64 __fastcall offset(unsigned int a1, __int16 a2)
{
unsigned int v2; // er12
__int16 v3; // bp

v2 = a1;
v3 = a1 + a2;
if ( is_digit(a1) )
return (unsigned int)cycle(v3, 48, 57);
if ( is_lower(a1) )
return (unsigned int)cycle(v3, 97, 122);
if ( is_upper(a1) )
v2 = cycle(v3, 65, 90);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1, __int16 a2)
{
unsigned int v2; // er12
__int16 v3; // bp

v2 = a1;
v3 = a1 + a2;
if ( func7(a1) )
return (unsigned int)func10(v3, 48, 57);
if ( func9(a1) )
return (unsigned int)func10(v3, 97, 122);
if ( func8(a1) )
v2 = func10(v3, 65, 90);
return v2;
}

original_code:
short offset(short symbol, int counter){
    short new_symbol = symbol + counter;
    if (is_digit(symbol)){
        return cycle(new_symbol, '0', '9');
    }
    if (is_lower(symbol)){
        return cycle(new_symbol, 'a', 'z');
    }
    if (is_upper(symbol)){
        return cycle(new_symbol, 'A', 'Z');
    }
    return symbol;
}

variable_types: counter int


decompiled_code:
_BOOL8 __fastcall is_digit(__int16 a1)
{
return (unsigned __int16)(a1 - 48) <= 9u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(__int16 a1)
{
return (unsigned __int16)(a1 - 48) <= 9u;
}

canonical_original_code:
enum bool_t is_digit(short symbol){
    if (('0' <= symbol) && (symbol <= '9'))
        return TRUE;
    return FALSE;
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
__int16 v4; // ax
__int16 v5; // bx
__int16 v6; // ax

LOWORD(v3) = 0;
while ( 1 )
{
v4 = getchar();
v5 = v4;
if ( v4 == -1 )
break;
v6 = offset(v4, v3);
putchar(v6);
if ( v5 == 32 )
v3 = ((__int16)v3 + 1) % 26;
}
putchar(10);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
__int16 v4; // ax
__int16 v5; // bx
__int16 v6; // ax

LOWORD(v3) = 0;
while ( 1 )
{
v4 = getchar();
v5 = v4;
if ( v4 == -1 )
break;
v6 = func11(v4, v3);
putchar(v6);
if ( v5 == 32 )
v3 = ((__int16)v3 + 1) % 26;
}
putchar(10);
return 0;
}

original_code:
int main() {
    short symbol = 0;
    short counter = 0;
    while ((-1) != (symbol = getchar())) {
        short new_symbol = offset(symbol, counter);
        putchar(new_symbol);
        if(' ' == symbol) {
            counter = (counter + 1) % 26;
        }
    }
    putchar('\n');
    return 0;
}

variable_types: counter short


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

switch ( a1 )
{
case '!':
result = 4LL;
break;
case '%':
case '*':
case '/':
result = 3LL;
break;
case '+':
case '-':
result = 2LL;
break;
case '=':
result = 1LL;
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case '!':
result = 4LL;
break;
case '%':
case '*':
case '/':
result = 3LL;
break;
case '+':
case '-':
result = 2LL;
break;
case '=':
result = 1LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
int op_preced(const char c) {
    switch (c) {
        case '!':
            return 4;
        case '*':
        case '/':
        case '%':
            return 3;
        case '+':
        case '-':
            return 2;
        case '=':
            return 1;
    }
    return 0;
}

canonical_original_code:
int op_preced(char c) {
    switch (c) {
        case '!':
            return 4;
        case '*':
        case '/':
        case '%':
            return 3;
        case '+':
        case '-':
            return 2;
        case '=':
            return 1;
    }
    return 0;
}

variable_types: c char


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

switch ( a1 )
{
case '%':
case '*':
case '+':
case '-':
case '/':
case '=':
result = 1LL;
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case '%':
case '*':
case '+':
case '-':
case '/':
case '=':
result = 1LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
_Bool op_left_assoc(const char c) {
    switch (c) {
        case '*':
        case '/':
        case '%':
        case '+':
        case '-':
        case '=':
            return 1;
        case '!':
            return 0;
    }
    return 0;
}

canonical_original_code:
_Bool op_left_assoc(char c) {
    switch (c) {
        case '*':
        case '/':
        case '%':
        case '+':
        case '-':
        case '=':
            return 1;
        case '!':
            return 0;
    }
    return 0;
}


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

switch ( a1 )
{
case '!':
result = 1LL;
break;
case '%':
case '*':
case '+':
case '-':
case '/':
case '=':
result = 2LL;
break;
default:
result = (unsigned int)(a1 - 65);
break;
}
return result;
}

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

switch ( a1 )
{
case '!':
result = 1LL;
break;
case '%':
case '*':
case '+':
case '-':
case '/':
case '=':
result = 2LL;
break;
default:
result = (unsigned int)(a1 - 65);
break;
}
return result;
}

original_code:
unsigned int op_arg_count(const char c) {
    switch (c) {
        case '*':
        case '/':
        case '%':
        case '+':
        case '-':
        case '=':
            return 2;
        case '!':
            return 1;
        default:
            return c - 'A';
    }
    return 0;
}

canonical_original_code:
unsigned int op_arg_count(char c) {
    switch (c) {
        case '*':
        case '/':
        case '%':
        case '+':
        case '-':
        case '=':
            return 2;
        case '!':
            return 1;
        default:
            return c - 'A';
    }
    return 0;
}

return_type: unsigned int


decompiled_code:
__int64 __fastcall shunting_yard(const char *a1, char *a2)
{
unsigned __int64 v2; // r12
const char *v3; // r14
int v5; // ebx
unsigned __int64 v6; // r13
__int64 v7; // rax
char *v8; // r15
char *v9; // rdx
int v10; // eax
__int64 v11; // rax
char *v12; // rax
int v13; // ecx
char *i; // rax
int v16; // ecx
char v17; // al
int v18; // [rsp+10h] [rbp-68h]
int v19; // [rsp+10h] [rbp-68h]
int v20; // [rsp+14h] [rbp-64h]
unsigned __int64 v21; // [rsp+18h] [rbp-60h]
char v22[88]; // [rsp+20h] [rbp-58h] BYREF

v3 = a1;
v21 = (unsigned __int64)&a1[strlen(a1)];
if ( (unsigned __int64)a1 >= v21 )
goto LABEL_41;
v5 = 0;
do
{
v6 = *(unsigned __int8 *)v3;
if ( (_BYTE)v6 != 32 )
{
LOBYTE(v2) = (unsigned __int8)(v6 - 97) <= 0x19u || (unsigned __int8)(v6 - 48) <= 9u;
if ( (_BYTE)v2 )
{
*a2++ = v6;
}
else if ( (unsigned __int8)(v6 - 65) > 0x19u )
{
if ( (_BYTE)v6 == 44 )
{
if ( !v5 )
{
LABEL_18:
puts("Error: separator or parentheses mismatched");
return (unsigned int)v2;
}
v9 = &v22[v5 - 1];
v10 = v5;
while ( 1 )
{
v5 = v10--;
if ( *v9 == 40 )
break;
*a2++ = *v9--;
if ( !v10 )
goto LABEL_18;
}
}
else if ( (unsigned __int8)v6 <= 0x3Du && (v7 = 0x2000AC2200000000LL, _bittest64(&v7, v6)) )
{
v8 = &v22[v5 - 1];
if ( v5 )
{
while ( 1 )
{
v20 = v5--;
v2 = (unsigned __int8)*v8;
if ( (unsigned __int8)v2 > 0x3Du )
break;
v11 = 0x2000AC2200000000LL;
if ( !_bittest64(&v11, v2) )
break;
if ( (unsigned __int8)op_left_assoc(v6) )
{
v19 = op_preced(v6);
if ( v19 > (int)op_preced(v2) )
break;
}
else
{
v18 = op_preced(v6);
if ( v18 >= (int)op_preced(v2) )
break;
}
*a2++ = v2;
--v8;
if ( !v5 )
{
v20 = 0;
break;
}
}
}
else
{
v20 = 0;
}
v22[v20] = v6;
v5 = v20 + 1;
}
else if ( (_BYTE)v6 == 40 )
{
v22[v5++] = 40;
}
else
{
if ( (_BYTE)v6 != 41 )
{
printf("Unknown token %c\n", (unsigned int)(char)v6);
return (unsigned int)v2;
}
if ( !v5 )
{
LABEL_34:
puts("Error: parentheses mismatched");
return (unsigned int)v2;
}
v12 = &v22[v5 - 1];
while ( 1 )
{
v13 = v5--;
if ( *v12 == 40 )
break;
*a2++ = *v12--;
if ( !v5 )
goto LABEL_34;
}
v5 = v13 - 1;
if ( v13 != 1 )
{
v16 = v13 - 2;
v17 = v22[v16];
if ( (unsigned __int8)(v17 - 65) <= 0x19u )
{
*a2++ = v17;
v5 = v16;
}
}
}
}
else
{
v22[v5++] = v6;
}
}
++v3;
}
while ( (const char *)v21 != v3 );
if ( v5 )
{
for ( i = &v22[v5 - 1]; (unsigned __int8)(*i - 40) > 1u; --i )
{
*a2++ = *i;
if ( i == v22 )
goto LABEL_41;
}
puts("Error: parentheses mismatched");
LODWORD(v2) = 0;
}
else
{
LABEL_41:
*a2 = 0;
LODWORD(v2) = 1;
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func10(const char *a1, char *a2)
{
unsigned __int64 v2; // r12
const char *v3; // r14
int v5; // ebx
unsigned __int64 v6; // r13
__int64 v7; // rax
char *v8; // r15
char *v9; // rdx
int v10; // eax
__int64 v11; // rax
char *v12; // rax
int v13; // ecx
char *i; // rax
int v16; // ecx
char v17; // al
int v18; // [rsp+10h] [rbp-68h]
int v19; // [rsp+10h] [rbp-68h]
int v20; // [rsp+14h] [rbp-64h]
unsigned __int64 v21; // [rsp+18h] [rbp-60h]
char v22[88]; // [rsp+20h] [rbp-58h] BYREF

v3 = a1;
v21 = (unsigned __int64)&a1[strlen(a1)];
if ( (unsigned __int64)a1 >= v21 )
goto LABEL_41;
v5 = 0;
do
{
v6 = *(unsigned __int8 *)v3;
if ( (_BYTE)v6 != 32 )
{
LOBYTE(v2) = (unsigned __int8)(v6 - 97) <= 0x19u || (unsigned __int8)(v6 - 48) <= 9u;
if ( (_BYTE)v2 )
{
*a2++ = v6;
}
else if ( (unsigned __int8)(v6 - 65) > 0x19u )
{
if ( (_BYTE)v6 == 44 )
{
if ( !v5 )
{
LABEL_18:
puts("Error: separator or parentheses mismatched");
return (unsigned int)v2;
}
v9 = &v22[v5 - 1];
v10 = v5;
while ( 1 )
{
v5 = v10--;
if ( *v9 == 40 )
break;
*a2++ = *v9--;
if ( !v10 )
goto LABEL_18;
}
}
else if ( (unsigned __int8)v6 <= 0x3Du && (v7 = 0x2000AC2200000000LL, _bittest64(&v7, v6)) )
{
v8 = &v22[v5 - 1];
if ( v5 )
{
while ( 1 )
{
v20 = v5--;
v2 = (unsigned __int8)*v8;
if ( (unsigned __int8)v2 > 0x3Du )
break;
v11 = 0x2000AC2200000000LL;
if ( !_bittest64(&v11, v2) )
break;
if ( (unsigned __int8)func8(v6) )
{
v19 = func7(v6);
if ( v19 > (int)func7(v2) )
break;
}
else
{
v18 = func7(v6);
if ( v18 >= (int)func7(v2) )
break;
}
*a2++ = v2;
--v8;
if ( !v5 )
{
v20 = 0;
break;
}
}
}
else
{
v20 = 0;
}
v22[v20] = v6;
v5 = v20 + 1;
}
else if ( (_BYTE)v6 == 40 )
{
v22[v5++] = 40;
}
else
{
if ( (_BYTE)v6 != 41 )
{
printf("Unknown token %c\n", (unsigned int)(char)v6);
return (unsigned int)v2;
}
if ( !v5 )
{
LABEL_34:
puts("Error: parentheses mismatched");
return (unsigned int)v2;
}
v12 = &v22[v5 - 1];
while ( 1 )
{
v13 = v5--;
if ( *v12 == 40 )
break;
*a2++ = *v12--;
if ( !v5 )
goto LABEL_34;
}
v5 = v13 - 1;
if ( v13 != 1 )
{
v16 = v13 - 2;
v17 = v22[v16];
if ( (unsigned __int8)(v17 - 65) <= 0x19u )
{
*a2++ = v17;
v5 = v16;
}
}
}
}
else
{
v22[v5++] = v6;
}
}
++v3;
}
while ( (const char *)v21 != v3 );
if ( v5 )
{
for ( i = &v22[v5 - 1]; (unsigned __int8)(*i - 40) > 1u; --i )
{
*a2++ = *i;
if ( i == v22 )
goto LABEL_41;
}
puts("Error: parentheses mismatched");
LODWORD(v2) = 0;
}
else
{
LABEL_41:
*a2 = 0;
LODWORD(v2) = 1;
}
return (unsigned int)v2;
}

original_code:
_Bool shunting_yard(const char *input, char *output) {
    const char *strpos = input, *strend = input + strlen(input);
    char c, stack[32], sc, *outpos = output;
    unsigned int sl = 0;
    while (strpos < strend) {
        c = *strpos;
        if (c != ' ') {
            if (((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))) {
                *outpos = c;
                ++outpos;
            }
            else if ((c >= 'A' && c <= 'Z')) {
                stack[sl] = c;
                ++sl;
            }
            else if (c == ',') {
                _Bool pe = 0;
                while (sl > 0) {
                    sc = stack[sl - 1];
                    if (sc == '(') {
                        pe = 1;
                        break;
                    }
                    else {
                        *outpos = sc;
                        ++outpos;
                        sl--;
                    }
                }
                if (!pe) {
                    printf("Error: separator or parentheses mismatched\n");
                    return 0;
                }
            }
            else if ((c == '+' || c == '-' || c == '/' || c == '*' || c == '!' || c == '%' || c == '=')) {
                while (sl > 0) {
                    sc = stack[sl - 1];
                    if ((sc == '+' || sc == '-' || sc == '/' || sc == '*' || sc == '!' || sc == '%' || sc == '=') &&
                        ((op_left_assoc(c) && (op_preced(c) <= op_preced(sc)))
                         || (!op_left_assoc(c)
                             && (op_preced(c) < op_preced(sc))))) {
                        *outpos = sc;
                        ++outpos;
                        sl--;
                    }
                    else {
                        break;
                    }
                }
                stack[sl] = c;
                ++sl;
            }
            else if (c == '(') {
                stack[sl] = c;
                ++sl;
            }
            else if (c == ')') {
                _Bool pe = 0;
                while (sl > 0) {
                    sc = stack[sl - 1];
                    if (sc == '(') {
                        pe = 1;
                        break;
                    }
                    else {
                        *outpos = sc;
                        ++outpos;
                        sl--;
                    }
                }
                if (!pe) {
                    printf("Error: parentheses mismatched\n");
                    return 0;
                }
                sl--;
                if (sl > 0) {
                    sc = stack[sl - 1];
                    if ((sc >= 'A' && sc <= 'Z')) {
                        *outpos = sc;
                        ++outpos;
                        sl--;
                    }
                }
            }
            else {
                printf("Unknown token %c\n", c);
                return 0;
            }
        }
        ++strpos;
    }
    while (sl > 0) {
        sc = stack[sl - 1];
        if (sc == '(' || sc == ')') {
            printf("Error: parentheses mismatched\n");
            return 0;
        }
        *outpos = sc;
        ++outpos;
        --sl;
    }
    *outpos = 0;
    return 1;
}

canonical_original_code:
_Bool shunting_yard(char *input, char *output) {
    char *strpos = input; char *strend = input + strlen(input);
    char c; char stack[32]; char sc; char *outpos = output;
    unsigned int sl = 0;
    while (strpos < strend) {
        c = *strpos;
        if (c != ' ') {
            if (((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))) {
                *outpos = c;
                ++outpos;
            }
            else if ((c >= 'A' && c <= 'Z')) {
                stack[sl] = c;
                ++sl;
            }
            else if (c == ',') {
                _Bool pe = 0;
                while (sl > 0) {
                    sc = stack[sl - 1];
                    if (sc == '(') {
                        pe = 1;
                        break;
                    }
                    else {
                        *outpos = sc;
                        ++outpos;
                        sl--;
                    }
                }
                if (!pe) {
                    printf("Error: separator or parentheses mismatched\n");
                    return 0;
                }
            }
            else if ((c == '+' || c == '-' || c == '/' || c == '*' || c == '!' || c == '%' || c == '=')) {
                while (sl > 0) {
                    sc = stack[sl - 1];
                    if ((sc == '+' || sc == '-' || sc == '/' || sc == '*' || sc == '!' || sc == '%' || sc == '=') &&
                        ((op_left_assoc(c) && (op_preced(c) <= op_preced(sc)))
                         || (!op_left_assoc(c)
                             && (op_preced(c) < op_preced(sc))))) {
                        *outpos = sc;
                        ++outpos;
                        sl--;
                    }
                    else {
                        break;
                    }
                }
                stack[sl] = c;
                ++sl;
            }
            else if (c == '(') {
                stack[sl] = c;
                ++sl;
            }
            else if (c == ')') {
                _Bool pe = 0;
                while (sl > 0) {
                    sc = stack[sl - 1];
                    if (sc == '(') {
                        pe = 1;
                        break;
                    }
                    else {
                        *outpos = sc;
                        ++outpos;
                        sl--;
                    }
                }
                if (!pe) {
                    printf("Error: parentheses mismatched\n");
                    return 0;
                }
                sl--;
                if (sl > 0) {
                    sc = stack[sl - 1];
                    if ((sc >= 'A' && sc <= 'Z')) {
                        *outpos = sc;
                        ++outpos;
                        sl--;
                    }
                }
            }
            else {
                printf("Unknown token %c\n", c);
                return 0;
            }
        }
        ++strpos;
    }
    while (sl > 0) {
        sc = stack[sl - 1];
        if (sc == '(' || sc == ')') {
            printf("Error: parentheses mismatched\n");
            return 0;
        }
        *outpos = sc;
        ++outpos;
        --sl;
    }
    *outpos = 0;
    return 1;
}

variable_types:
input
char *

variable_types:
output
char *

variable_types:
strpos
char *

variable_types:
strend
char *

variable_types:
stack
char [32]

variable_types: sc char

variable_types:
outpos
char *

variable_types:
sl
unsigned int


decompiled_code:
_BOOL8 __fastcall execution_order(char *s)
{
char *v1; // rbp
size_t v2; // rax
char *v3; // r15
unsigned int v4; // er13
unsigned int v5; // er12
__int64 v6; // rax
unsigned int v7; // er14
unsigned int v8; // ebx
unsigned __int64 v9; // rbx
unsigned int i; // ebx
bool v12; // [rsp+Bh] [rbp-CDh]
unsigned int v13; // [rsp+Ch] [rbp-CCh]
int v14[34]; // [rsp+10h] [rbp-C8h]
int v15; // [rsp+98h] [rbp-40h] BYREF
char sa[4]; // [rsp+9Ch] [rbp-3Ch] BYREF

v1 = s;
puts("order: (arguments in reverse order)");
v2 = strlen(s);
v3 = &s[v2];
if ( v1 >= &v1[v2] )
return 0;
v4 = 0;
v5 = 0;
do
{
v9 = (unsigned __int8)*v1;
v12 = (unsigned __int8)(v9 - 97) <= 0x19u || (unsigned __int8)(v9 - 48) <= 9u;
if ( v12 )
{
v14[v5++] = (char)v9;
}
else
{
if ( (unsigned __int8)v9 <= 0x3Du )
{
v6 = 0x2000AC2200000000LL;
if ( !_bittest64(&v6, v9) )
goto LABEL_10;
sprintf(sa, "_%02d", v4);
printf("%s = ", sa);
++v4;
v7 = (char)v9;
v13 = op_arg_count(v9);
if ( v13 > v5 )
return v12;
if ( (unsigned __int8)(v9 - 65) <= 0x19u )
{
LABEL_25:
printf("%c(", v7);
if ( v13 )
{
for ( i = v13 - 1; ; --i )
{
v15 = v14[v5 - 1 - i];
if ( i + 1 <= 1 )
{
printf("%s)\n", (const char *)&v15);
if ( !i )
break;
}
else
{
printf("%s, ", (const char *)&v15);
}
}
}
v8 = v5 - v13;
}
else if ( v13 == 1 )
{
v8 = v5 - 1;
v15 = v14[v5 - 1];
printf("%c %s;\n", v7, (const char *)&v15);
}
else
{
v8 = v5 - 2;
v15 = v14[v5 - 2];
printf("%s %c ", (const char *)&v15, v7);
v15 = v14[v5 - 1];
printf("%s;\n", (const char *)&v15);
}
v14[v8] = *(_DWORD *)sa;
v5 = v8 + 1;
goto LABEL_10;
}
if ( (unsigned __int8)(v9 - 65) <= 0x19u )
{
sprintf(sa, "_%02d", v4);
printf("%s = ", sa);
++v4;
v7 = (char)v9;
v13 = op_arg_count(v9);
if ( v13 > v5 )
return v12;
goto LABEL_25;
}
}
LABEL_10:
++v1;
}
while ( v3 != v1 );
v12 = 0;
if ( v5 == 1 )
{
v15 = v14[0];
printf("%s is a result\n", (const char *)&v15);
v12 = 1;
}
return v12;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(char *s)
{
char *v1; // rbp
size_t v2; // rax
char *v3; // r15
unsigned int v4; // er13
unsigned int v5; // er12
__int64 v6; // rax
unsigned int v7; // er14
unsigned int v8; // ebx
unsigned __int64 v9; // rbx
unsigned int i; // ebx
bool v12; // [rsp+Bh] [rbp-CDh]
unsigned int v13; // [rsp+Ch] [rbp-CCh]
int v14[34]; // [rsp+10h] [rbp-C8h]
int v15; // [rsp+98h] [rbp-40h] BYREF
char sa[4]; // [rsp+9Ch] [rbp-3Ch] BYREF

v1 = s;
puts("order: (arguments in reverse order)");
v2 = strlen(s);
v3 = &s[v2];
if ( v1 >= &v1[v2] )
return 0;
v4 = 0;
v5 = 0;
do
{
v9 = (unsigned __int8)*v1;
v12 = (unsigned __int8)(v9 - 97) <= 0x19u || (unsigned __int8)(v9 - 48) <= 9u;
if ( v12 )
{
v14[v5++] = (char)v9;
}
else
{
if ( (unsigned __int8)v9 <= 0x3Du )
{
v6 = 0x2000AC2200000000LL;
if ( !_bittest64(&v6, v9) )
goto LABEL_10;
sprintf(sa, "_%02d", v4);
printf("%s = ", sa);
++v4;
v7 = (char)v9;
v13 = func9(v9);
if ( v13 > v5 )
return v12;
if ( (unsigned __int8)(v9 - 65) <= 0x19u )
{
LABEL_25:
printf("%c(", v7);
if ( v13 )
{
for ( i = v13 - 1; ; --i )
{
v15 = v14[v5 - 1 - i];
if ( i + 1 <= 1 )
{
printf("%s)\n", (const char *)&v15);
if ( !i )
break;
}
else
{
printf("%s, ", (const char *)&v15);
}
}
}
v8 = v5 - v13;
}
else if ( v13 == 1 )
{
v8 = v5 - 1;
v15 = v14[v5 - 1];
printf("%c %s;\n", v7, (const char *)&v15);
}
else
{
v8 = v5 - 2;
v15 = v14[v5 - 2];
printf("%s %c ", (const char *)&v15, v7);
v15 = v14[v5 - 1];
printf("%s;\n", (const char *)&v15);
}
v14[v8] = *(_DWORD *)sa;
v5 = v8 + 1;
goto LABEL_10;
}
if ( (unsigned __int8)(v9 - 65) <= 0x19u )
{
sprintf(sa, "_%02d", v4);
printf("%s = ", sa);
++v4;
v7 = (char)v9;
v13 = func9(v9);
if ( v13 > v5 )
return v12;
goto LABEL_25;
}
}
LABEL_10:
++v1;
}
while ( v3 != v1 );
v12 = 0;
if ( v5 == 1 )
{
v15 = v14[0];
printf("%s is a result\n", (const char *)&v15);
v12 = 1;
}
return v12;
}

original_code:
_Bool execution_order(const char *input) {
    printf("order: (arguments in reverse order)\n");
    const char *strpos = input, *strend = input + strlen(input);
    char c, res[4];
    unsigned int sl = 0, sc, stack[32], rn = 0;
    while (strpos < strend) {
        c = *strpos;
        if (((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))) {
            stack[sl] = c;
            ++sl;
        }
        else if ((c == '+' || c == '-' || c == '/' || c == '*' || c == '!' || c == '%' || c == '=') || (c >= 'A' && c <= 'Z')) {
            sprintf(res, "_%02d", rn);
            printf("%s = ", res);
            ++rn;
            unsigned int nargs = op_arg_count(c);
            unsigned int Tnargs = nargs;
            if (sl < nargs) {
                return 0;
            }
            if ((c >= 'A' && c <= 'Z')) {
                printf("%c(", c);
                while (nargs > 0) {
                    sc = stack[sl - nargs];
                    if (nargs > 1) {
                        printf("%s, ", (char *) &sc);
                    }
                    else {
                        printf("%s)\n", (char *) &sc);
                    }
                    --nargs;
                }
                sl -= Tnargs;
            }
            else {
                if (nargs == 1) {
                    sc = stack[sl - 1];
                    sl--;
                    printf("%c %s;\n", c, (char *) &sc);
                }
                else {
                    sc = stack[sl - 2];
                    printf("%s %c ", (char *) &sc, c);
                    sc = stack[sl - 1];
                    printf("%s;\n", (char *) &sc);
                    sl -= 2;
                }
            }
            stack[sl] = *(unsigned int *) res;
            ++sl;
        }
        ++strpos;
    }
    if (sl == 1) {
        sc = stack[sl - 1];
        sl--;
        printf("%s is a result\n", (char *) &sc);
        return 1;
    }
    return 0;
}

canonical_original_code:
_Bool execution_order(char *input) {
    printf("order: (arguments in reverse order)\n");
    char *strpos = input; char *strend = input + strlen(input);
    char c; char res[4];
    unsigned int sl = 0; unsigned int sc; unsigned int stack[32]; unsigned int rn = 0;
    while (strpos < strend) {
        c = *strpos;
        if (((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))) {
            stack[sl] = c;
            ++sl;
        }
        else if ((c == '+' || c == '-' || c == '/' || c == '*' || c == '!' || c == '%' || c == '=') || (c >= 'A' && c <= 'Z')) {
            sprintf(res, "_%02d", rn);
            printf("%s = ", res);
            ++rn;
            unsigned int nargs = op_arg_count(c);
            unsigned int Tnargs = nargs;
            if (sl < nargs) {
                return 0;
            }
            if ((c >= 'A' && c <= 'Z')) {
                printf("%c(", c);
                while (nargs > 0) {
                    sc = stack[sl - nargs];
                    if (nargs > 1) {
                        printf("%s, ", (char *) &sc);
                    }
                    else {
                        printf("%s)\n", (char *) &sc);
                    }
                    --nargs;
                }
                sl -= Tnargs;
            }
            else {
                if (nargs == 1) {
                    sc = stack[sl - 1];
                    sl--;
                    printf("%c %s;\n", c, (char *) &sc);
                }
                else {
                    sc = stack[sl - 2];
                    printf("%s %c ", (char *) &sc, c);
                    sc = stack[sl - 1];
                    printf("%s;\n", (char *) &sc);
                    sl -= 2;
                }
            }
            stack[sl] = *(unsigned int *) res;
            ++sl;
        }
        ++strpos;
    }
    if (sl == 1) {
        sc = stack[sl - 1];
        sl--;
        printf("%s is a result\n", (char *) &sc);
        return 1;
    }
    return 0;
}

variable_types:
res
char [4]

variable_types:
sc
unsigned int

variable_types:
stack
unsigned int [32]

variable_types:
rn
unsigned int

variable_types:
nargs
unsigned int

variable_types:
Tnargs
unsigned int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v4[136]; // [rsp+0h] [rbp-88h] BYREF

printf("input: %s\n", "a = D(f - b * c + d, !e, g)");
if ( (unsigned __int8)shunting_yard("a = D(f - b * c + d, !e, g)", v4) )
{
printf("output: %s\n", v4);
execution_order(v4);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v4[136]; // [rsp+0h] [rbp-88h] BYREF

printf("input: %s\n", "a = D(f - b * c + d, !e, g)");
if ( (unsigned __int8)func10("a = D(f - b * c + d, !e, g)", v4) )
{
printf("output: %s\n", v4);
func11(v4);
}
return 0;
}

original_code:
int main() {
    const char *input = "a = D(f - b * c + d, !e, g)";
    char output[128];
    printf("input: %s\n", input);
    if (shunting_yard(input, output)) {
        printf("output: %s\n", output);
        execution_order(output);
    }
    return 0;
}

canonical_original_code:
int main() {
    char *input = "a = D(f - b * c + d, !e, g)";
    char output[128];
    printf("input: %s\n", input);
    if (shunting_yard(input, output)) {
        printf("output: %s\n", output);
        execution_order(output);
    }
    return 0;
}

variable_types:
output
char [128]


decompiled_code:
__int64 __fastcall get_base(int a1, __int64 a2)
{
__int64 result; // rax

if ( a1 <= 1 )
{
fwrite(
"Error: wrong usage: at least one argument required --- the base of number system. \n",
1uLL,
0x53uLL,
stderr);
exit(1);
}
result = abs32(atoi(*(const char **)(a2 + 8)));
if ( (unsigned int)(result - 2) > 0x5D )
{
fwrite("Error: wrong usage: the base of number system should be from 2 to 95. \n", 1uLL, 0x47uLL, stderr);
exit(1);
}
return result;
}

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

if ( a1 <= 1 )
{
fwrite(
"Error: wrong usage: at least one argument required --- the base of number system. \n",
1uLL,
0x53uLL,
stderr);
exit(1);
}
result = abs32(atoi(*(const char **)(a2 + 8)));
if ( (unsigned int)(result - 2) > 0x5D )
{
fwrite("Error: wrong usage: the base of number system should be from 2 to 95. \n", 1uLL, 0x47uLL, stderr);
exit(1);
}
return result;
}

original_code:
number_t get_base (int argc, char* argv[]) {
    int res = 2;
    if(argc < 2){
        fprintf(stderr, "Error: wrong usage: "
                        "at least one argument required --- "
                        "the base of number system. \n");
        exit(1);
    }
    res = abs(atoi(argv[1]));
    if ((2 > res) || (res > 95)){
        fprintf(stderr, "Error: wrong usage: "
                        "the base of number system "
                        "should be from 2 to 95. \n");
        exit(1);
    }
    return res;
}

canonical_original_code:
int get_base(int argc, char *argv[]) {
    int res = 2;
    if(argc < 2){
        fprintf(stderr, "Error: wrong usage: "
                        "at least one argument required --- "
                        "the base of number system. \n");
        exit(1);
    }
    res = abs(atoi(argv[1]));
    if ((2 > res) || (res > 95)){
        fprintf(stderr, "Error: wrong usage: "
                        "the base of number system "
                        "should be from 2 to 95. \n");
        exit(1);
    }
    return res;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: res int


decompiled_code:
__int64 __fastcall get_sep(int a1, __int64 a2)
{
__int64 result; // rax

if ( a1 <= 2 )
result = 0LL;
else
result = *(_QWORD *)(a2 + 16);
return result;
}

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

if ( a1 <= 2 )
result = 0LL;
else
result = *(_QWORD *)(a2 + 16);
return result;
}

original_code:
const char* get_sep(int argc, char* argv[]) {
    if(argc < 3){
        return (char *)((void *)0);
    }
    return argv[2];
}

canonical_original_code:
char *get_sep(int argc, char *argv[]) {
    if(argc < 3){
        return (char *)((void *)0);
    }
    return argv[2];
}

return_type: char *


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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
a1 >>= 1;
}
while ( a1 );
return result;
}

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
a1 >>= 1;
}
while ( a1 );
return result;
}

original_code:
number_t mylog2 (number_t val) {
    number_t ret = 0;
    while (val != 0) {
        val >>= 1;
        ret++;
    }
    return ret;
}

canonical_original_code:
int mylog2(int val) {
    int ret = 0;
    while (val != 0) {
        val >>= 1;
        ret++;
    }
    return ret;
}

variable_types: val int

variable_types: ret int


mylog

decompiled_code:
__int64 __fastcall mylog(int a1, int a2)
{
int v2; // ebx

v2 = mylog2(a2);
return (unsigned int)(v2 / (int)mylog2(a1));
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, int a2)
{
int v2; // ebx

v2 = func9(a2);
return (unsigned int)(v2 / (int)func9(a1));
}

original_code:
number_t mylog (number_t base, number_t val) {
    return mylog2 (val) / mylog2 (base);
}

canonical_original_code:
int mylog(int base, int val) {
    return mylog2 (val) / mylog2 (base);
}

variable_types: base int


decompiled_code:
__int64 __fastcall print_base(__int64 a1, signed int a2, int a3)
{
unsigned int v4; // er13
int v5; // ebx
int v6; // ebp
int i; // er12
__int64 result; // rax

if ( a2 )
{
v4 = a2 % (int)a1;
v5 = print_base(a1, (unsigned int)(a2 / (int)a1), (unsigned int)(a3 == 0) + a3 - 1);
if ( a2 % (int)a1 <= 9 )
{
printf("%d", v4);
v6 = a2 % (int)a1;
}
else
{
v6 = a2 % (int)a1;
if ( v4 - 10 <= 0x19 )
{
putchar(v4 + 55);
LABEL_18:
if ( (unsigned int)(v6 - 78) <= 6 )
{
putchar(v4 - 20);
LABEL_20:
if ( (int)a1 <= 9 )
result = v4 + 10 * v5;
else
result = 100 * v5 + v4;
return result;
}
goto LABEL_6;
}
if ( v4 - 36 <= 0x19 )
{
putchar(v4 + 61);
LABEL_6:
if ( (unsigned int)(v6 - 85) <= 5 )
{
putchar(v4 + 6);
goto LABEL_20;
}
LABEL_15:
if ( (unsigned int)(v6 - 91) <= 3 )
putchar(v4 + 32);
goto LABEL_20;
}
}
if ( (unsigned int)(v6 - 62) <= 0xF )
{
putchar(v4 - 30);
goto LABEL_15;
}
goto LABEL_18;
}
if ( a3 <= 0 )
return 0LL;
for ( i = 0; i != a3; ++i )
putchar(48);
return (unsigned int)a2;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, signed int a2, int a3)
{
unsigned int v4; // er13
int v5; // ebx
int v6; // ebp
int i; // er12
__int64 result; // rax

if ( a2 )
{
v4 = a2 % (int)a1;
v5 = func11(a1, (unsigned int)(a2 / (int)a1), (unsigned int)(a3 == 0) + a3 - 1);
if ( a2 % (int)a1 <= 9 )
{
printf("%d", v4);
v6 = a2 % (int)a1;
}
else
{
v6 = a2 % (int)a1;
if ( v4 - 10 <= 0x19 )
{
putchar(v4 + 55);
LABEL_18:
if ( (unsigned int)(v6 - 78) <= 6 )
{
putchar(v4 - 20);
LABEL_20:
if ( (int)a1 <= 9 )
result = v4 + 10 * v5;
else
result = 100 * v5 + v4;
return result;
}
goto LABEL_6;
}
if ( v4 - 36 <= 0x19 )
{
putchar(v4 + 61);
LABEL_6:
if ( (unsigned int)(v6 - 85) <= 5 )
{
putchar(v4 + 6);
goto LABEL_20;
}
LABEL_15:
if ( (unsigned int)(v6 - 91) <= 3 )
putchar(v4 + 32);
goto LABEL_20;
}
}
if ( (unsigned int)(v6 - 62) <= 0xF )
{
putchar(v4 - 30);
goto LABEL_15;
}
goto LABEL_18;
}
if ( a3 <= 0 )
return 0LL;
for ( i = 0; i != a3; ++i )
putchar(48);
return (unsigned int)a2;
}

original_code:
number_t print_base(number_t base, number_t input, number_t width){
    number_t digit = input % base;
    number_t prevdigits = 0;
    if(!input){
        number_t i;
        for(i = 0; i < width; ++i)
            printf("0");
        return 0;
    }
    prevdigits = print_base(base, input / base, (width) ? (width - 1) : 0);
    if(digit < 10)
        printf("%d", digit);
    if((10 <= digit) && (digit < 36))
        printf("%c", digit + 'A' - 10);
    if((36 <= digit) && (digit < 62))
        printf("%c", digit + 'a' - 36);
    if((62 <= digit) && (digit < 78))
        printf("%c", digit + ' ' - 62);
    if((78 <= digit) && (digit < 85))
        printf("%c", digit + ':' - 78);
    if((85 <= digit) && (digit < 91))
        printf("%c", digit + '[' - 85);
    if((91 <= digit) && (digit < 95))
        printf("%c", digit + '{' - 91);
    if(base < 10)
        return prevdigits * 10 + digit;
    return prevdigits * 100 + digit;
}

canonical_original_code:
int print_base(int base, int input, int width){
    int digit = input % base;
    int prevdigits = 0;
    if(!input){
        int i;
        for(i = 0; i < width; ++i)
            printf("0");
        return 0;
    }
    prevdigits = print_base(base, input / base, (width) ? (width - 1) : 0);
    if(digit < 10)
        printf("%d", digit);
    if((10 <= digit) && (digit < 36))
        printf("%c", digit + 'A' - 10);
    if((36 <= digit) && (digit < 62))
        printf("%c", digit + 'a' - 36);
    if((62 <= digit) && (digit < 78))
        printf("%c", digit + ' ' - 62);
    if((78 <= digit) && (digit < 85))
        printf("%c", digit + ':' - 78);
    if((85 <= digit) && (digit < 91))
        printf("%c", digit + '[' - 85);
    if((91 <= digit) && (digit < 95))
        printf("%c", digit + '{' - 91);
    if(base < 10)
        return prevdigits * 10 + digit;
    return prevdigits * 100 + digit;
}

variable_types: input int

variable_types: width int

variable_types: digit int

variable_types: prevdigits int

variable_types: i int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er13
const char *v4; // r12
int v5; // er14
int i; // ebp
unsigned __int8 v7; // bl

v3 = get_base(argc, (__int64)argv);
v4 = (const char *)get_sep(argc, (__int64)argv);
v5 = mylog(v3, 255) + 1;
for ( i = 1; ; i = 0 )
{
v7 = getchar();
if ( v7 == 0xFF )
break;
if ( v4 )
{
if ( !i )
printf("%s", v4);
}
print_base(v3, v7, v5);
}
putchar(10);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er13
const char *v4; // r12
int v5; // er14
int i; // ebp
unsigned __int8 v7; // bl

v3 = func7(argc, (__int64)argv);
v4 = (const char *)func8(argc, (__int64)argv);
v5 = func10(v3, 255) + 1;
for ( i = 1; ; i = 0 )
{
v7 = getchar();
if ( v7 == 0xFF )
break;
if ( v4 )
{
if ( !i )
printf("%s", v4);
}
func11(v3, v7, v5);
}
putchar(10);
return 0;
}

original_code:
int main(int argc, char* argv[]){
    number_t base = get_base(argc, argv);
    const char* sep = get_sep(argc, argv);
    number_t numberwidth = mylog(base, 255)+1;
    byte_t chr = 0;
    bool_t isfirst = TRUE;
    while((chr = getchar()) != (byte_t)(-1)){
        if((sep) && (FALSE == isfirst)){
            printf("%s", sep);
        }
        if (isfirst)
            isfirst = FALSE;
        print_base(base, (number_t)chr, numberwidth);
    }
    printf("\n");
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
    int base = get_base(argc, argv);
    char *sep = get_sep(argc, argv);
    int numberwidth = mylog(base, 255)+1;
    unsigned char chr = 0;
    enum bool_t isfirst = TRUE;
    while((chr = getchar()) != (byte_t)(-1)){
        if((sep) && (FALSE == isfirst)){
            printf("%s", sep);
        }
        if (isfirst)
            isfirst = FALSE;
        print_base(base, (int)chr, numberwidth);
    }
    printf("\n");
    return 0;
}

variable_types:
sep
char *

variable_types: numberwidth int

variable_types:
chr
unsigned char

variable_types:
isfirst
enum bool_t { FALSE=0, TRUE=1 }


decompiled_code:
_BOOL8 __fastcall is_letter(char a1)
{
return (unsigned __int8)((a1 & 0xDF) - 65) <= 0x19u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(char a1)
{
return (unsigned __int8)((a1 & 0xDF) - 65) <= 0x19u;
}

canonical_original_code:
enum bool_t is_letter(char chr){
    if ((('A' <= chr) && (chr <= 'Z')) || (('a' <= chr) && (chr <= 'z')))
        return TRUE;
    return FALSE;
}

variable_types: chr char


decompiled_code:
_BOOL8 __fastcall is_identifier_start(char a1)
{
return is_letter(a1) || a1 == 95;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(char a1)
{
return func7(a1) || a1 == 95;
}

canonical_original_code:
enum bool_t is_identifier_start(char chr){
    if (is_letter(chr) || ('_' == chr))
        return TRUE;
    return FALSE;
}


decompiled_code:
_BOOL8 __fastcall is_identifier_body(char a1)
{
_BOOL4 v1; // eax
_BOOL8 result; // rax

v1 = is_letter(a1);
if ( a1 == 95 || v1 )
result = 1LL;
else
result = is_digit(a1);
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(char a1)
{
_BOOL4 v1; // eax
_BOOL8 result; // rax

v1 = func7(a1);
if ( a1 == 95 || v1 )
result = 1LL;
else
result = func9(a1);
return result;
}

canonical_original_code:
enum bool_t is_identifier_body(char chr){
    if (is_letter(chr) || ('_' == chr) || is_digit(chr))
        return TRUE;
    return FALSE;
}


decompiled_code:
_BOOL8 __fastcall is_digit(char a1)
{
return (unsigned __int8)(a1 - 48) <= 9u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(char a1)
{
return (unsigned __int8)(a1 - 48) <= 9u;
}

canonical_original_code:
enum bool_t is_digit(char chr){
    if (('0' <= chr) && (chr <= '9'))
        return TRUE;
    return FALSE;
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BOOL4 v3; // er12
int v4; // ebp
__int64 v5; // r13
char v6; // al
char v7; // bl
_BOOL4 v8; // eax

v3 = 0;
v4 = 0;
v5 = 0LL;
while ( 1 )
{
v6 = getchar();
v7 = v6;
if ( v6 == -1 )
break;
if ( !v4 || is_identifier_body(v6) )
{
if ( v3 )
{
if ( is_identifier_start(v7) )
{
v8 = is_identifier_body(v7);
if ( !v8 )
v3 = 0;
if ( !v8 )
v4 = 0;
}
else
{
LABEL_4:
v3 = is_identifier_body(v7);
v4 = 0;
}
}
else
{
v4 = 1;
if ( !is_identifier_start(v7) )
goto LABEL_4;
}
}
else
{
++v5;
v3 = 0;
v4 = 0;
}
}
printf("%ld\n", v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BOOL4 v3; // er12
int v4; // ebp
__int64 v5; // r13
char v6; // al
char v7; // bl
_BOOL4 v8; // eax

v3 = 0;
v4 = 0;
v5 = 0LL;
while ( 1 )
{
v6 = getchar();
v7 = v6;
if ( v6 == -1 )
break;
if ( !v4 || func10(v6) )
{
if ( v3 )
{
if ( func8(v7) )
{
v8 = func10(v7);
if ( !v8 )
v3 = 0;
if ( !v8 )
v4 = 0;
}
else
{
LABEL_4:
v3 = func10(v7);
v4 = 0;
}
}
else
{
v4 = 1;
if ( !func8(v7) )
goto LABEL_4;
}
}
else
{
++v5;
v3 = 0;
v4 = 0;
}
}
printf("%ld\n", v5);
return 0;
}

original_code:
int main(){
    char chr = 0;
    long identifier_counter = 0;
    bool_t is_inside = FALSE;
    bool_t is_fake = FALSE;
    while ((-1) != (chr = getchar())) {
        if (is_inside && !is_identifier_body(chr)) {
            is_inside = FALSE;
            is_fake = FALSE;
            ++identifier_counter;
        } else if (!is_fake && is_identifier_start(chr)) {
            is_inside = TRUE;
            is_fake = FALSE;
        } else if (!is_identifier_start(chr) && is_identifier_body(chr)) {
            is_inside = FALSE;
            is_fake = TRUE;
        } else if (!is_identifier_body(chr)) {
            is_inside = FALSE;
            is_fake = FALSE;
        }
    }
    printf("%ld\n", identifier_counter);
    return 0;
}

canonical_original_code:
int main(){
    char chr = 0;
    long identifier_counter = 0;
    enum bool_t is_inside = FALSE;
    enum bool_t is_fake = FALSE;
    while ((-1) != (chr = getchar())) {
        if (is_inside && !is_identifier_body(chr)) {
            is_inside = FALSE;
            is_fake = FALSE;
            ++identifier_counter;
        } else if (!is_fake && is_identifier_start(chr)) {
            is_inside = TRUE;
            is_fake = FALSE;
        } else if (!is_identifier_start(chr) && is_identifier_body(chr)) {
            is_inside = FALSE;
            is_fake = TRUE;
        } else if (!is_identifier_body(chr)) {
            is_inside = FALSE;
            is_fake = FALSE;
        }
    }
    printf("%ld\n", identifier_counter);
    return 0;
}


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

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

original_code:
stree_t* stree_create() {
    return ((void *)0);
}

canonical_original_code:
struct stree *stree_create() {
    return ((void *)0);
}

return_type: struct stree { struct stree *left; struct stree *right; struct wword_t { unsigned long size; _Bool eoln; int *string; } *value; unsigned long freq; unsigned long counter; unsigned long position; } *

user_defined_types: struct stree { struct stree *left; struct stree *right; struct wword_t *value; unsigned long freq; unsigned long counter; unsigned long position; }


decompiled_code:
void __fastcall stree_destroy(void *ptr)
{
if ( ptr )
{
stree_destroy(*(void **)ptr);
stree_destroy(*((void **)ptr + 1));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func9(void *ptr)
{
if ( ptr )
{
func9(*(void **)ptr);
func9(*((void **)ptr + 1));
free(ptr);
}
}

original_code:
void stree_destroy(stree_t * stree) {
    if (stree) {
        stree_destroy(stree->left);
        stree_destroy(stree->right);
        free(stree);
    }
}

canonical_original_code:
void stree_destroy(struct stree *stree) {
    if (stree) {
        stree_destroy(stree->left);
        stree_destroy(stree->right);
        free(stree);
    }
}

variable_types: struct stree { struct stree *left; struct stree *right; struct wword_t { unsigned long size; _Bool eoln; int *string; } *value; unsigned long freq; unsigned long counter; unsigned long position; } *

return_type: void


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

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

original_code:
xresult_t xresult_create(){
    xresult_t res;
    res.isok = 0;
    return res;
}

canonical_original_code:
struct xresult_t xresult_create(){
    struct xresult_t res;
    res.isok = 0;
    return res;
}

variable_types: struct xresult_t { _Bool isok; void *value; }


decompiled_code:
int __fastcall wword_cmp(__int64 a1, __int64 a2)
{
return memcmp(*(const void **)(a1 + 16), *(const void **)(a2 + 16), 0x400uLL);
}

canonical_decompiled_code:
int __fastcall func14(__int64 a1, __int64 a2)
{
return memcmp(*(const void **)(a1 + 16), *(const void **)(a2 + 16), 0x400uLL);
}

original_code:
int wword_cmp(wword_t* this, wword_t* other) {
    return memcmp (this->string, other->string, 1024);
}

canonical_original_code:
int wword_cmp(struct wword_t *this, struct wword_t *other) {
    return memcmp (this->string, other->string, 1024);
}

variable_types: struct wword_t { unsigned long size; _Bool eoln; int *string; } *

variable_types:
other
struct wword_t *


fact

decompiled_code:
double __fastcall fact(double a1)
{
double result; // xmm0_8

if ( a1 > 1.0 )
result = fact(a1 - 1.0) * a1;
else
result = 1.0;
return result;
}

canonical_decompiled_code:
double __fastcall func10(double a1)
{
double result; // xmm0_8

if ( a1 > 1.0 )
result = func10(a1 - 1.0) * a1;
else
result = 1.0;
return result;
}

original_code:
double fact(double n) {
    if (n <= 1)
        return 1;
    else
        return fact(n - 1) * n;
}

variable_types: n double

return_type: double


findent

decompiled_code:
void findent()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
double findent(double x) {
    return x;
}

canonical_original_code:
double findent(double x) {
    return x;
}

variable_types: x double


epsylone

decompiled_code:
double epsylone()
{
double v0; // rbx
double v1; // rbp

v0 = 1.0;
do
{
v1 = v0;
v0 = v0 * 0.5;
findent();
}
while ( v0 + 1.0 > 1.0 );
return v1;
}

canonical_decompiled_code:
double func8()
{
double v0; // rbx
double v1; // rbp

v0 = 1.0;
do
{
v1 = v0;
v0 = v0 * 0.5;
func7();
}
while ( v0 + 1.0 > 1.0 );
return v1;
}

original_code:
double epsylone() {
    double eps = 1.0;
    while (findent(eps / 2 + 1) > 1)
        eps = eps / 2;
    return eps;
}

variable_types: eps double


power

decompiled_code:
double __fastcall power(int a1, double a2)
{
double result; // xmm0_8
int i; // eax

if ( a1 <= 0 )
return 1.0;
result = 1.0;
for ( i = 0; i != a1; ++i )
result = result * a2;
return result;
}

canonical_decompiled_code:
double __fastcall func9(int a1, double a2)
{
double result; // xmm0_8
int i; // eax

if ( a1 <= 0 )
return 1.0;
result = 1.0;
for ( i = 0; i != a1; ++i )
result = result * a2;
return result;
}

original_code:
double power(double x, int n) {
    int i;
    double p = 1;
    for (i = 0; i < n; i++)
        p = p * x;
    return p;
}

variable_types: n int

variable_types: p double


main

canonical_original_code:
int main() {
    double a = 0.0; double b = 1.0; double x = 0.0; double sumT = 0.0;
    int k = 1; int n = 0; int parts;
    double func; double keps; double termT; double termM; double step; double max = 0.0;
    printf("Input number of evaluations: ");
    scanf("\n%d", &parts);
    step = (b - a) / parts;
    keps = k * epsylone();
    printf("                     Machine epsylone is %.16f\n", epsylone());
    printf("        Table Taylor's series of values and standard functions for\n");
    printf("                       f(x)= 1/(4-x*x*x*x)\n");
    printf(" ---------------------------------------------------------------------\n");
    printf(" | value of x |      sum of series     |      value of f     | iters |\n");
    for (a = 0.0; x <= (keps + b); x += step) {
        for (n = 0; n < 100; n++) {
            termT = taylor(n, x);
            if (keps >= fabs(termT))
                break;
            sumT = sumT + termT;
        }
        func = 1 / (4 - x * x * x * x);
        termM = fabs(func - sumT);
        if (termM >= max)
            max = termM;
        printf(" |------------|------------------------|---------------------|-------|\n");
        printf(" |    %.2f    |   %.17f  | %.17f |   %d   |\n", x, sumT, func, n);
        sumT = 0;
        n = 0;
    }
    printf(" ---------------------------------------------------------------------\n");
    printf("                     Maximal error = %.17f\n", max);
    return 0;
}

variable_types: a double

variable_types: b double

variable_types: sumT double

variable_types: k int

variable_types: parts int

variable_types: func double

variable_types: keps double

variable_types: termT double

variable_types: termM double

variable_types: step double

variable_types: max double


decompiled_code:
__int64 queue_create()
{
void *v0; // rax

v0 = malloc(0x18uLL);
return queue_init((__int64)v0);
}

canonical_decompiled_code:
__int64 func8()
{
void *v0; // rax

v0 = malloc(0x18uLL);
return func7((__int64)v0);
}

original_code:
queue_t *queue_create() {
    queue_t* queue = malloc(sizeof(queue_t));
    queue = queue_init(queue);
    return queue;
}

canonical_original_code:
struct queue_t *queue_create() {
    struct queue_t *queue = malloc(sizeof(queue_t));
    queue = queue_init(queue);
    return queue;
}

variable_types: struct queue_t { struct __queueInner__ { int val; struct __queueInner__ *previous; } *mainQueue; struct __queueInner__ *first; int size; } *

user_defined_types: struct queue_t { struct __queueInner__ *mainQueue; struct __queueInner__ *first; int size; }


original_code:
queue_t *queue_del(queue_t *queue) {
    if (queue->mainQueue->val == 0) {
        printf("Empty\n");
    }
    else {
        printf("%d\n", queue->first->val);
        if (queue->first->previous == ((void *)0))
            queue->first->val = 0;
        else {
            queue->first = queue->first->previous;
        }
        queue->size--;
    }
    return queue;
}

canonical_original_code:
struct queue_t *queue_del(struct queue_t *queue) {
    if (queue->mainQueue->val == 0) {
        printf("Empty\n");
    }
    else {
        printf("%d\n", queue->first->val);
        if (queue->first->previous == ((void *)0))
            queue->first->val = 0;
        else {
            queue->first = queue->first->previous;
        }
        queue->size--;
    }
    return queue;
}

variable_types:
queue
struct queue_t *

return_type: struct queue_t { struct __queueInner__ { int val; struct __queueInner__ *previous; } *mainQueue; struct __queueInner__ *first; int size; } *


decompiled_code:
int __fastcall queue_print(__int64 a1)
{
unsigned int *v1; // rbx
int v2; // ebp
int result; // eax

v1 = *(unsigned int **)(a1 + 8);
if ( *(int *)(a1 + 16) > 0 )
{
v2 = 0;
do
{
result = printf("%d\n", *v1);
v1 = (unsigned int *)*((_QWORD *)v1 + 1);
if ( !v1 )
break;
++v2;
}
while ( *(_DWORD *)(a1 + 16) > v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
unsigned int *v1; // rbx
int v2; // ebp
int result; // eax

v1 = *(unsigned int **)(a1 + 8);
if ( *(int *)(a1 + 16) > 0 )
{
v2 = 0;
do
{
result = printf("%d\n", *v1);
v1 = (unsigned int *)*((_QWORD *)v1 + 1);
if ( !v1 )
break;
++v2;
}
while ( *(_DWORD *)(a1 + 16) > v2 );
}
return result;
}

original_code:
void queue_print(queue_t *mainQueue) {
    int i;
    queueInner_t *go = mainQueue->first;
    for (i = 0; i < mainQueue->size; ++i) {
        printf("%d\n", go->val);
        go = go->previous;
        if (go == ((void *)0)) {
            break;
        }
    }
}

canonical_original_code:
void queue_print(struct queue_t *mainQueue) {
    int i;
    struct __queueInner__ *go = mainQueue->first;
    for (i = 0; i < mainQueue->size; ++i) {
        printf("%d\n", go->val);
        go = go->previous;
        if (go == ((void *)0)) {
            break;
        }
    }
}

variable_types: i int

variable_types: struct __queueInner__ { int val; struct __queueInner__ *previous; } *


sort

original_code:
queueInner_t *sort(queueInner_t *queue, queueInner_t *last, int n) {
    if (n > 1) {
        int i, half = n / 2;
        int* mass = ((void *)0);
        queueInner_t *x, *y;
        queueInner_t *temp = last;
        int xSize = n - half;
        int ySize = half;
        for (i = 1; i < half; ++i) {
            temp = temp->previous;
        }
        queue = sort(queue, temp->previous, n - half);
        queue = sort(temp, last, half);
        mass = malloc(sizeof(int)*n);
        x = temp->previous;
        y = last;
        for (i = 0; i < n; ++i) {
            if ((xSize == 0 && ySize != 0) || (ySize > 0 && x->val > y->val)) {
                mass[i] = y->val;
                y = y->previous;
                ySize--;
                if (xSize == 0 && ySize == 0)
                    break;
            }
            else if ((ySize == 0 && xSize != 0) || (xSize > 0 && x->val <= y->val)) {
                mass[i] = x->val;
                x = x->previous;
                xSize--;
                if (xSize == 0 && ySize == 0)
                    break;
            }
        }
        x = last;
        for (i = 0; i < n; ++i) {
            x->val = mass[i];
            x = x->previous;
        }
        free(mass);
        return queue;
    }
    else
        return queue;
}

canonical_original_code:
struct __queueInner__ *sort(struct __queueInner__ *queue, struct __queueInner__ *last, int n) {
    if (n > 1) {
        int i; int half = n / 2;
        int *mass = ((void *)0);
        struct __queueInner__ *x; struct __queueInner__ *y;
        struct __queueInner__ *temp = last;
        int xSize = n - half;
        int ySize = half;
        for (i = 1; i < half; ++i) {
            temp = temp->previous;
        }
        queue = sort(queue, temp->previous, n - half);
        queue = sort(temp, last, half);
        mass = malloc(sizeof(int)*n);
        x = temp->previous;
        y = last;
        for (i = 0; i < n; ++i) {
            if ((xSize == 0 && ySize != 0) || (ySize > 0 && x->val > y->val)) {
                mass[i] = y->val;
                y = y->previous;
                ySize--;
                if (xSize == 0 && ySize == 0)
                    break;
            }
            else if ((ySize == 0 && xSize != 0) || (xSize > 0 && x->val <= y->val)) {
                mass[i] = x->val;
                x = x->previous;
                xSize--;
                if (xSize == 0 && ySize == 0)
                    break;
            }
        }
        x = last;
        for (i = 0; i < n; ++i) {
            x->val = mass[i];
            x = x->previous;
        }
        free(mass);
        return queue;
    }
    else
        return queue;
}

variable_types:
queue
struct __queueInner__ *

variable_types:
last
struct __queueInner__ *

variable_types: n int

variable_types: half int

variable_types:
mass
int *

variable_types: xSize int

variable_types: ySize int

return_type: struct __queueInner__ { int val; struct __queueInner__ *previous; } *


lenght

decompiled_code:
__int64 __fastcall lenght(int a1)
{
unsigned int v1; // edx

v1 = 1;
if ( a1 )
{
v1 = 0;
do
{
a1 /= 10;
++v1;
}
while ( a1 );
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
unsigned int v1; // edx

v1 = 1;
if ( a1 )
{
v1 = 0;
do
{
a1 /= 10;
++v1;
}
while ( a1 );
}
return v1;
}

original_code:
int lenght(int a) {
    int l = 0;
    if (0 == a)
        return 1;
    while (0 != a) {
        a = a / 10;
        ++l;
    }
    return l;
}

variable_types: a int

variable_types: l int


ipow

decompiled_code:
__int64 __fastcall ipow(int a1, int a2)
{
unsigned int v2; // edx
int i; // eax

if ( !a2 )
return 1;
v2 = 1;
for ( i = 0; i != a2; ++i )
v2 *= a1;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2)
{
unsigned int v2; // edx
int i; // eax

if ( !a2 )
return 1;
v2 = 1;
for ( i = 0; i != a2; ++i )
v2 *= a1;
return v2;
}

original_code:
int ipow(int a, int n) {
    int i;
    int r = 1;
    for (i = 0; i != n; ++i)
        r *= a;
    return r;
}

variable_types: r int


sorted

canonical_original_code:
enum bool_t sorted(int a) {
    int curr;
    int prev;
    int l = lenght(a);
    int p = ipow(10, l - 1);
    int i = 0;
    for (i = 0; l >= 2; ++i) {
        prev = (a / p) % 10;
        curr = ((a - prev * p) / (p / 10)) % 10;
        if (curr < prev)
            return FALSE;
        a = a - ((a / p) % 10) * p;
        p = p / 10;
        --l;
    }
    return TRUE;
}

variable_types: curr int

variable_types: prev int

variable_types: p int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rdi
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

scanf("%d", v5);
v3 = "true";
if ( !(unsigned int)sorted(v5[0]) )
v3 = "false";
puts(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rdi
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

scanf("%d", v5);
v3 = "true";
if ( !(unsigned int)func9(v5[0]) )
v3 = "false";
puts(v3);
return 0;
}

original_code:
int main() {
    int a;
    scanf("%d", &a);
    printf("%s\n", sorted(a) ? "true" : "false");
    return 0;
}


absolute

decompiled_code:
__m128d __fastcall absolute(__m128d result)
{
if ( result.m128d_f64[0] < 0.0 )
result = _mm_xor_pd(result, (__m128d)xmmword_4020F0);
return result;
}

canonical_decompiled_code:
__m128d __fastcall func10(__m128d result)
{
if ( result.m128d_f64[0] < 0.0 )
result = _mm_xor_pd(result, (__m128d)xmmword_4020F0);
return result;
}

original_code:
myfloat_t absolute(myfloat_t x) {
    if (x < 0)
        return -x;
    return x;
}

canonical_original_code:
double absolute(double x) {
    if (x < 0)
        return -x;
    return x;
}

variable_types: x double


decompiled_code:
double __fastcall target_function(double a1)
{
return (a1 * a1 + 1.0) * 0.5 * atan(a1) - 0.5 * a1;
}

canonical_decompiled_code:
double __fastcall func11(double a1)
{
return (a1 * a1 + 1.0) * 0.5 * atan(a1) - 0.5 * a1;
}

original_code:
myfloat_t target_function(myfloat_t x) {
    return (1 + x * x) / 2 * atan(x) - x / 2;
}

canonical_original_code:
double target_function(double x) {
    return (1 + x * x) / 2 * atan(x) - x / 2;
}


decompiled_code:
double __fastcall taylor_function(int a1, double a2)
{
double v3; // r14

v3 = pow(-1.0, (double)(a1 + 1));
return pow(a2, (double)(2 * a1 + 1)) * v3 / (double)(4 * a1 * a1 - 1);
}

canonical_decompiled_code:
double __fastcall func12(int a1, double a2)
{
double v3; // r14

v3 = pow(-1.0, (double)(a1 + 1));
return pow(a2, (double)(2 * a1 + 1)) * v3 / (double)(4 * a1 * a1 - 1);
}

original_code:
myfloat_t taylor_function(myfloat_t x, int n) {
    return pow(-1, n + 1) * pow(x, 2 * n + 1) / (4 * n * n - 1);
}

canonical_original_code:
double taylor_function(double x, int n) {
    return pow(-1, n + 1) * pow(x, 2 * n + 1) / (4 * n * n - 1);
}


findent

original_code:
myfloat_t findent(myfloat_t x) {
    return x;
}


power

original_code:
myfloat_t power(myfloat_t x, int n) {
    int i;
    myfloat_t p = 1;
    for (i = 0; i < n; i++)
        p = p * x;
    return p;
}

canonical_original_code:
double power(double x, int n) {
    int i;
    double p = 1;
    for (i = 0; i < n; i++)
        p = p * x;
    return p;
}

variable_types: p double


main

original_code:
int main() {
    int step = 0;
    int steps = 0;
    myfloat_t delta;
    myfloat_t eps = epsilon();
    myfloat_t x = A;
    int width = ceil(-log10(eps));
    int swidth = width + 2;
    scanf("%d", &steps);
    delta = (B - A) / steps;
    printf("eps = %.*f \n", width, eps);
    printf("width = %d \n", width);
    printf("delta = %f \n", delta);
    printf("\n");
    printf(
        "%3s | %*s | %*s | %*s | %5s |  %*s \n\n",
        "#",
        swidth, "x",
        swidth, "target",
        swidth, "taylor", "iter",
        swidth, "target - taylor"
    );
    for (step = 0; step != (steps + 1); ++step) {
        myfloat_t target = target_function(x);
        int iter = 1;
        myfloat_t taylor = taylor_function(x, iter);
        while ((absolute(taylor - target) >= eps * COEF)
               && (iter < ITER_MAX)) {
            iter = iter + 1;
            taylor += taylor_function(x, iter);
        }
        printf(
            "%3d | %.*f | %.*f | %.*f | %5d | %*.*f\n",
            step,
            width,
            x,
            width, target,
            width, taylor,
            iter,
            width + 3, width, target - taylor
        );
        x = x + delta;
    }
    printf("\n");
    return 0;
}

canonical_original_code:
int main() {
    int step = 0;
    int steps = 0;
    double delta;
    double eps = epsilon();
    double x = A;
    int width = ceil(-log10(eps));
    int swidth = width + 2;
    scanf("%d", &steps);
    delta = (B - A) / steps;
    printf("eps = %.*f \n", width, eps);
    printf("width = %d \n", width);
    printf("delta = %f \n", delta);
    printf("\n");
    printf(
        "%3s | %*s | %*s | %*s | %5s |  %*s \n\n",
        "#",
        swidth, "x",
        swidth, "target",
        swidth, "taylor", "iter",
        swidth, "target - taylor"
    );
    for (step = 0; step != (steps + 1); ++step) {
        double target = target_function(x);
        int iter = 1;
        double taylor = taylor_function(x, iter);
        while ((absolute(taylor - target) >= eps * COEF)
               && (iter < ITER_MAX)) {
            iter = iter + 1;
            taylor += taylor_function(x, iter);
        }
        printf(
            "%3d | %.*f | %.*f | %.*f | %5d | %*.*f\n",
            step,
            width,
            x,
            width, target,
            width, taylor,
            iter,
            width + 3, width, target - taylor
        );
        x = x + delta;
    }
    printf("\n");
    return 0;
}

variable_types: step int

variable_types: steps int

variable_types: delta double

variable_types: eps double

variable_types: width int

variable_types: swidth int

variable_types: target double

variable_types: iter int

variable_types: taylor double


steplen

original_code:
int steplen(step_t step){
    return ceil(log10(step) + 1);
}

canonical_original_code:
int steplen(long step){
    return ceil(log10(step) + 1);
}

variable_types: step long


iterlen

original_code:
int iterlen(iter_t iter){
    return ceil(log10(iter) + 1);
}

canonical_original_code:
int iterlen(long iter){
    return ceil(log10(iter) + 1);
}

variable_types: iter long


epslen

original_code:
int epslen(real_t eps){
    return ceil(-log10(eps));
}

canonical_original_code:
int epslen(double eps){
    return ceil(-log10(eps));
}


decompiled_code:
double __fastcall target_fuction(double a1)
{
return (a1 + a1 - 3.0) / ((a1 - 1.0) * (a1 - 1.0));
}

original_code:
real_t target_fuction(real_t x) {
    return (2 * x - 3) / ((x - 1) * (x - 1));
}

canonical_original_code:
float target_fuction(float x) {
    return (2 * x - 3) / ((x - 1) * (x - 1));
}

variable_types: x float

return_type: float


rabs

decompiled_code:
__m128d __fastcall rabs(__m128d result)
{
if ( result.m128d_f64[0] < 0.0 )
result = _mm_xor_pd(result, (__m128d)xmmword_402030);
return result;
}

canonical_decompiled_code:
__m128d __fastcall func11(__m128d result)
{
if ( result.m128d_f64[0] < 0.0 )
result = _mm_xor_pd(result, (__m128d)xmmword_402030);
return result;
}

original_code:
real_t rabs(real_t x) {
    if (x < 0)
        return -x;
    return x;
}

canonical_original_code:
float rabs(float x) {
    if (x < 0)
        return -x;
    return x;
}


rpow

decompiled_code:
double __fastcall rpow(__int64 a1, double a2)
{
double result; // xmm0_8
__int64 i; // rax

if ( !a1 )
return 1.0;
result = 1.0;
for ( i = 0LL; i != a1; ++i )
result = result * a2;
return result;
}

canonical_decompiled_code:
double __fastcall func12(__int64 a1, double a2)
{
double result; // xmm0_8
__int64 i; // rax

if ( !a1 )
return 1.0;
result = 1.0;
for ( i = 0LL; i != a1; ++i )
result = result * a2;
return result;
}

original_code:
real_t rpow(real_t x, iter_t n) {
    iter_t i;
    real_t res = 1;
    for (i = 0; i != n; ++i) {
        res *= x;
    }
    return res;
}

canonical_original_code:
float rpow(float x, long n) {
    long i;
    float res = 1;
    for (i = 0; i != n; ++i) {
        res *= x;
    }
    return res;
}

variable_types: n long

variable_types: i long

variable_types: res float


decompiled_code:
double __fastcall taylor_fuction(__int64 a1, double a2)
{
return (double)(-3 - (int)a1) * rpow(a1, a2);
}

canonical_decompiled_code:
double __fastcall func13(__int64 a1, double a2)
{
return (double)(-3 - (int)a1) * func12(a1, a2);
}

original_code:
real_t taylor_fuction(real_t x, iter_t n) {
    return -(n + 3) * rpow(x, n);
}

canonical_original_code:
float taylor_fuction(float x, long n) {
    return -(n + 3) * rpow(x, n);
}


decompiled_code:
int __fastcall format_print_table_line(int a1, int a2, int a3)
{
int v3; // eax
int v4; // ebp
int v5; // ebx

v3 = a1 + 3 * a3 + 15;
v4 = v3 + a2 + 15;
if ( v3 + a2 != -15 )
{
v5 = 0;
do
{
putchar(45);
++v5;
}
while ( v4 != v5 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func16(int a1, int a2, int a3)
{
int v3; // eax
int v4; // ebp
int v5; // ebx

v3 = a1 + 3 * a3 + 15;
v4 = v3 + a2 + 15;
if ( v3 + a2 != -15 )
{
v5 = 0;
do
{
putchar(45);
++v5;
}
while ( v4 != v5 );
}
return putchar(10);
}

original_code:
void format_print_table_line(int stepwidth, int iterwidth, int epswidth) {
    int epslength = epswidth + FORMAT_REAL_LENGTH;
    int size = stepwidth + 3 * epslength + iterwidth + FORMAT_LINE_OFFSET;
    int i;
    for (i = 0; i != size; ++i) {
        printf("-");
    }
    printf("\n");
}

variable_types: stepwidth int

variable_types: iterwidth int

variable_types: epswidth int

variable_types: epslength int

variable_types: size int

variable_types: i int


decompiled_code:
int __fastcall format_print_table_head(int a1, int a2, int a3)
{
int v3; // ebx

v3 = a3 + 5;
printf("|%*s |", a1, "#");
printf(" %*s |", v3, "x");
printf(" %*s |", v3, "target");
printf(" %*s |", v3, "taylor");
return printf(" %*s |\n", a2, "n");
}

canonical_decompiled_code:
int __fastcall func17(int a1, int a2, int a3)
{
int v3; // ebx

v3 = a3 + 5;
printf("|%*s |", a1, "#");
printf(" %*s |", v3, "x");
printf(" %*s |", v3, "target");
printf(" %*s |", v3, "taylor");
return printf(" %*s |\n", a2, "n");
}

original_code:
void format_print_table_head(int stepwidth, int iterwidth, int epswidth) {
    int epslength = epswidth + FORMAT_REAL_LENGTH;
    printf("|%*s |", stepwidth, "#");
    printf(" %*s |", epslength, "x");
    printf(" %*s |", epslength, "target");
    printf(" %*s |", epslength, "taylor");
    printf(" %*s |\n", iterwidth, "n");
}


decompiled_code:
int __fastcall format_print_table_row(int a1, int a2, int a3, __int64 a4, __int64 a5, double a6, double a7, double a8)
{
int v10; // er13

v10 = a3 + 5;
printf("|%*ld |", a1, a4);
printf(" %*.*f |", v10, a3, a6);
printf(" %*.*f |", v10, a3, a7);
printf(" %*.*f |", v10, a3, a8);
return printf(" %*ld |\n", a2, a5);
}

original_code:
void format_print_table_row(
    int stepwidth,
    int iterwidth,
    int epswidth,
    step_t step,
    real_t x,
    real_t target,
    real_t taylor,
    iter_t iter
) {
    int epslength = epswidth + FORMAT_REAL_LENGTH;
    printf("|%*" "ld" " |", stepwidth, step);
    printf(" %*.*" "f" " |", epslength, epswidth, x);
    printf(" %*.*" "f" " |", epslength, epswidth, target);
    printf(" %*.*" "f" " |", epslength, epswidth, taylor);
    printf(" %*" "ld" " |\n", iterwidth, iter);
}

canonical_original_code:
void format_print_table_row(int stepwidth, int iterwidth, int epswidth, long step, float x, float target, float taylor, long iter) {
    int epslength = epswidth + FORMAT_REAL_LENGTH;
    printf("|%*" "ld" " |", stepwidth, step);
    printf(" %*.*" "f" " |", epslength, epswidth, x);
    printf(" %*.*" "f" " |", epslength, epswidth, target);
    printf(" %*.*" "f" " |", epslength, epswidth, taylor);
    printf(" %*" "ld" " |\n", iterwidth, iter);
}

variable_types: target float

variable_types: taylor float


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er15
int v4; // er13
int v5; // er14
__int64 v6; // r12
double i; // xmm0_8
double v8; // rbp
__int64 j; // rbx
__m128d v10; // xmm0
double v12; // [rsp+0h] [rbp-68h]
double v13; // [rsp+8h] [rbp-60h]
double v14; // [rsp+10h] [rbp-58h]
double v15; // [rsp+18h] [rbp-50h]
__int64 v16[8]; // [rsp+28h] [rbp-40h] BYREF

v14 = epsylone();
scanf("%ld", v16);
v15 = 0.5 / (double)SLODWORD(v16[0]);
v3 = epslen(v14);
v4 = steplen(v16[0]);
v5 = iterlen(100);
format_print_table_line(v4, v5, v3);
format_print_table_head(v4, v5, v3);
format_print_table_line(v4, v5, v3);
if ( v16[0] != -1 )
{
v6 = 0LL;
v13 = 0.1;
for ( i = taylor_fuction(0LL, 0.1); ; i = taylor_fuction(0LL, v13) )
{
v12 = i;
v8 = target_fuction(v13);
for ( j = 0LL; ; v12 = taylor_fuction(j, v13) + v12 )
{
v10 = (__m128d)*(unsigned __int64 *)&v8;
v10.m128d_f64[0] = v8 - v12;
if ( rabs(v10).m128d_f64[0] < 100.0 * v14 || j > 99 )
break;
++j;
}
format_print_table_row(v4, v5, v3, v6, j, v13, v8, v12);
v13 = v13 + v15;
if ( v16[0] == v6 )
break;
++v6;
}
}
format_print_table_line(v4, v5, v3);
return 0;
}

original_code:
int main() {
    real_t eps = epsylone();
    real_t x;
    real_t delta_x;
    step_t nsteps;
    step_t step;
    int epswidth;
    int stepwidth;
    int iterwidth;
    scanf("%" "ld", &nsteps);
    delta_x = (STOP_X - START_X) / nsteps;
    epswidth = ceil(-log10(eps));
    stepwidth = ceil(log10(nsteps) + 1);
    iterwidth = ceil(log10(ITER_LIMIT) + 1);
    printf("steps    = %ld\n", nsteps);
    printf("Δx       = %.*" "f" "\n", epswidth, delta_x);
    printf("ε        = %.*" "f" "\n", epswidth, eps);
    printf("ε width  = %d\n", epswidth);
    format_print_table_line(stepwidth, iterwidth, epswidth);
    format_print_table_head(stepwidth, iterwidth, epswidth);
    format_print_table_line(stepwidth, iterwidth, epswidth);
    x = START_X;
    for (step = 0; step != (nsteps + 1); ++step) {
        iter_t iter = 0;
        real_t taylor = taylor_fuction(x, iter);
        real_t target = target_fuction(x);
        while ((rabs(target - taylor) >= (eps * COEF)) && iter < ITER_LIMIT) {
            ++iter;
            taylor += taylor_fuction(x, iter);
        }
        format_print_table_row(stepwidth, iterwidth, epswidth,
                               step, x, target, taylor, iter);
        x += delta_x;
    }
    format_print_table_line(stepwidth, iterwidth, epswidth);
    return 0;
}

canonical_original_code:
int main() {
    float eps = epsylone();
    float x;
    float delta_x;
    long nsteps;
    long step;
    int epswidth;
    int stepwidth;
    int iterwidth;
    scanf("%" "ld", &nsteps);
    delta_x = (STOP_X - START_X) / nsteps;
    epswidth = ceil(-log10(eps));
    stepwidth = ceil(log10(nsteps) + 1);
    iterwidth = ceil(log10(ITER_LIMIT) + 1);
    printf("steps    = %ld\n", nsteps);
    printf("Δx       = %.*" "f" "\n", epswidth, delta_x);
    printf("ε        = %.*" "f" "\n", epswidth, eps);
    printf("ε width  = %d\n", epswidth);
    format_print_table_line(stepwidth, iterwidth, epswidth);
    format_print_table_head(stepwidth, iterwidth, epswidth);
    format_print_table_line(stepwidth, iterwidth, epswidth);
    x = START_X;
    for (step = 0; step != (nsteps + 1); ++step) {
        long iter = 0;
        float taylor = taylor_fuction(x, iter);
        float target = target_fuction(x);
        while ((rabs(target - taylor) >= (eps * COEF)) && iter < ITER_LIMIT) {
            ++iter;
            taylor += taylor_fuction(x, iter);
        }
        format_print_table_row(stepwidth, iterwidth, epswidth,
                               step, x, target, taylor, iter);
        x += delta_x;
    }
    format_print_table_line(stepwidth, iterwidth, epswidth);
    return 0;
}

variable_types: eps float

variable_types: nsteps long


decompiled_code:
void __fastcall naive_delay(int a1)
{
int i; // eax

if ( a1 )
{
for ( i = 0; i != a1; ++i )
;
}
}

canonical_decompiled_code:
void __fastcall func11(int a1)
{
int i; // eax

if ( a1 )
{
for ( i = 0; i != a1; ++i )
;
}
}

original_code:
void naive_delay(int time) {
    int i;
    for (i = 0; i != time; ++i) ;
}

variable_types: time int


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int i; // ebx

while ( 1 )
{
for ( i = 0; i != 320; ++i )
fmindicator((FILE *)_bss_start, i, 45, 92, 124, 47, 45, 45);
putchar(10);
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int i; // ebx

while ( 1 )
{
for ( i = 0; i != 320; ++i )
func10((FILE *)_bss_start, i, 45, 92, 124, 47, 45, 45);
putchar(10);
}
}


function

decompiled_code:
void function()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
point_t function(point_t x) {
    return x;
}

canonical_original_code:
double function(double x) {
    return x;
}

variable_types: x double


main

original_code:
int main() {
    point_t eps = epsilon();
    point_t x;
    point_t func;
    point_t tailor;
    point_t step;
    int n;
    int iter;
    int width = ceil(-log10(eps));
    scanf("%d", &n);
    step = (B - A) / n;
    printf(
        "         x                   "
        "сумма ряда              "
        "значение ф-ии   "
        "число итераций\n"
    );
    x = A;
    while (x <= B) {
        func = (3.0 * x - 5.0) / (pow(x, 2) - 4.0 * x + 3.0);
        tailor = 0.0;
        iter = 0;
        while (fabs(func - tailor) >= eps * K) {
            tailor += (-((1.0 + 2.0 / (pow(3.0, iter + 1))) * (pow(x, iter))));
            ++iter;
        }
        printf(
            "%.*" "f"
            "\t%.*" "f"
            "\t%.*" "f"
            "\t%3d\n",
            width, x,
            width, tailor,
            width, func,
            iter
        );
        x += step;
    }
    return 0;
}

canonical_original_code:
int main() {
    double eps = epsilon();
    double x;
    double func;
    double tailor;
    double step;
    int n;
    int iter;
    int width = ceil(-log10(eps));
    scanf("%d", &n);
    step = (B - A) / n;
    printf(
        "         x                   "
        "сумма ряда              "
        "значение ф-ии   "
        "число итераций\n"
    );
    x = A;
    while (x <= B) {
        func = (3.0 * x - 5.0) / (pow(x, 2) - 4.0 * x + 3.0);
        tailor = 0.0;
        iter = 0;
        while (fabs(func - tailor) >= eps * K) {
            tailor += (-((1.0 + 2.0 / (pow(3.0, iter + 1))) * (pow(x, iter))));
            ++iter;
        }
        printf(
            "%.*" "f"
            "\t%.*" "f"
            "\t%.*" "f"
            "\t%3d\n",
            width, x,
            width, tailor,
            width, func,
            iter
        );
        x += step;
    }
    return 0;
}

variable_types: eps double

variable_types: func double

variable_types: tailor double

variable_types: step double

variable_types: n int

variable_types: iter int

variable_types: width int


decompiled_code:
__int64 __fastcall char_to_set(char a1)
{
const __int32_t **v1; // rax
unsigned int v2; // ecx
__int64 result; // rax

v1 = __ctype_tolower_loc();
v2 = (*v1)[a1] - 97;
result = (unsigned int)(1 << (LOBYTE((*v1)[a1]) - 97));
if ( v2 >= 0x1A )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(char a1)
{
const __int32_t **v1; // rax
unsigned int v2; // ecx
__int64 result; // rax

v1 = __ctype_tolower_loc();
v2 = (*v1)[a1] - 97;
result = (unsigned int)(1 << (LOBYTE((*v1)[a1]) - 97));
if ( v2 >= 0x1A )
result = 0LL;
return result;
}

original_code:
unsigned int char_to_set(char c) {
    unsigned int x = tolower(c);
    if (('a' <= x) && (x <= 'z'))
        return 1u << (x - 'a');
    else
        return 0;
}

variable_types: c char

variable_types:
x
unsigned int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // ebp
int v5; // er12
int v6; // eax
int v7; // eax

v3 = 0;
v4 = 0;
v5 = 0;
while ( 1 )
{
v6 = getchar();
if ( v6 == -1 )
break;
v7 = char_to_set(v6);
v3 |= v7;
if ( !v7 && v3 )
{
if ( v4 == v3 )
{
v4 = v3;
v3 = 0;
v5 = 1;
}
else
{
v4 = v3;
v3 = 0;
}
}
}
if ( v5 == 1 )
puts("true");
else
puts("false");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // ebp
int v5; // er12
int v6; // eax
int v7; // eax

v3 = 0;
v4 = 0;
v5 = 0;
while ( 1 )
{
v6 = getchar();
if ( v6 == -1 )
break;
v7 = func7(v6);
v3 |= v7;
if ( !v7 && v3 )
{
if ( v4 == v3 )
{
v4 = v3;
v3 = 0;
v5 = 1;
}
else
{
v4 = v3;
v3 = 0;
}
}
}
if ( v5 == 1 )
puts("true");
else
puts("false");
return 0;
}

original_code:
int main() {
    int c = 0;
    int flag = FALSE;
    unsigned int prev_letters = 0;
    unsigned int curr_letters = 0;
    while ((-1) != (c = getchar())) {
        unsigned int c_set = char_to_set(c);
        curr_letters = curr_letters | c_set;
        if (0 == c_set && 0 != curr_letters) {
            if (curr_letters == prev_letters) {
                flag = TRUE;
            }
            prev_letters = curr_letters;
            curr_letters = 0;
        }
    }
    flag == TRUE ? printf("true\n") : printf("false\n");
    return 0;
}

variable_types: c int

variable_types: flag int


repo: wader/gtktetris

decompiled_code:
__int64 get_config_dir_file()
{
char *v0; // rbx
int v1; // er12
__int64 v2; // rbp
char *v4; // rdi

v0 = getenv("XDG_CONFIG_HOME");
v1 = 0;
if ( !v0 )
{
v4 = getenv("HOME");
if ( !v4 )
v4 = (char *)g_get_home_dir();
v0 = (char *)g_strconcat(v4, "/.config", 0LL);
v1 = 1;
}
v2 = g_strconcat(v0, "/", "games");
if ( v1 )
free(v0);
return v2;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rbx
int v1; // er12
__int64 v2; // rbp
char *v4; // rdi

v0 = getenv("XDG_CONFIG_HOME");
v1 = 0;
if ( !v0 )
{
v4 = getenv("HOME");
if ( !v4 )
v4 = (char *)g_get_home_dir();
v0 = (char *)g_strconcat(v4, "/.config", 0LL);
v1 = 1;
}
v2 = g_strconcat(v0, "/", "games");
if ( v1 )
free(v0);
return v2;
}

original_code:
char * get_config_dir_file (const char * file)
{
    char * config_home = ((void *)0);
    char * res = ((void *)0);
    int freestr = 0;
    const char * HOME = ((void *)0);
    config_home = getenv ("XDG_CONFIG_HOME");
    if (!config_home) {
        HOME = getenv ("HOME");
        if (!HOME) {
            HOME = g_get_home_dir ();
        }
        config_home = g_strconcat (HOME, "/.config", ((void *)0));
        freestr = 1;
    }
    if (file) {
        res = g_strconcat (config_home, "/", "games",
                           "/", file, ((void *)0));
    } else {
        res = g_strconcat (config_home, "/", "games", ((void *)0));
    }
    if (freestr) {
        free (config_home);
    }
    return (res);
}

canonical_original_code:
char *get_config_dir_file(char *file)
{
    char *config_home = ((void *)0);
    char *res = ((void *)0);
    int freestr = 0;
    char *HOME = ((void *)0);
    config_home = getenv ("XDG_CONFIG_HOME");
    if (!config_home) {
        HOME = getenv ("HOME");
        if (!HOME) {
            HOME = g_get_home_dir ();
        }
        config_home = g_strconcat (HOME, "/.config", ((void *)0));
        freestr = 1;
    }
    if (file) {
        res = g_strconcat (config_home, "/", "games",
                           "/", file, ((void *)0));
    } else {
        res = g_strconcat (config_home, "/", "games", ((void *)0));
    }
    if (freestr) {
        free (config_home);
    }
    return (res);
}

variable_types:
file
char *

variable_types:
res
char *

variable_types: freestr int

variable_types:
HOME
char *


decompiled_code:
__int64 ensure_config_dir_exists()
{
const char *v0; // rbp
char *v1; // rbx
char i; // al
const char *v4; // rax

v0 = (const char *)get_config_dir_file("dummy.file");
v1 = (char *)&v0[-(v0 == 0LL) + 1];
for ( i = *v1; *v1; i = *v1 )
{
if ( i == 47 )
{
*v1 = 0;
if ( access(v0, 0) && mkdir(v0, 0x1FDu) == -1 )
{
v4 = (const char *)g_get_prgname();
fprintf(stderr, "%s: Unable to create %s\n", v4, v0);
}
*v1 = 47;
}
++v1;
}
return g_free(v0);
}

canonical_decompiled_code:
__int64 func1()
{
const char *v0; // rbp
char *v1; // rbx
char i; // al
const char *v4; // rax

v0 = (const char *)func0("dummy.file");
v1 = (char *)&v0[-(v0 == 0LL) + 1];
for ( i = *v1; *v1; i = *v1 )
{
if ( i == 47 )
{
*v1 = 0;
if ( access(v0, 0) && mkdir(v0, 0x1FDu) == -1 )
{
v4 = (const char *)g_get_prgname();
fprintf(stderr, "%s: Unable to create %s\n", v4, v0);
}
*v1 = 47;
}
++v1;
}
return g_free(v0);
}

variable_types:
str
char *

variable_types:
p
char *


decompiled_code:
__int64 gtktetris_activate()
{
ensure_config_dir_exists();
options_defaults();
options_read();
return create_main_window();
}

canonical_decompiled_code:
__int64 func2()
{
func1();
options_defaults();
options_read();
return create_main_window();
}

original_code:
static void gtktetris_activate (void)
{
    ensure_config_dir_exists ();
    options_defaults ();
    options_read ();
    create_main_window ();
}

canonical_original_code:
static void gtktetris_activate()
{
    ensure_config_dir_exists ();
    options_defaults ();
    options_read ();
    create_main_window ();
}


decompiled_code:
__int64 gtktetris_exit()
{
free_tetris_blocks();
return gtk_main_quit();
}

canonical_decompiled_code:
__int64 func3()
{
free_tetris_blocks();
return gtk_main_quit();
}

original_code:
void gtktetris_exit (void)
{
    free_tetris_blocks ();
    gtk_main_quit();
}

canonical_original_code:
void gtktetris_exit()
{
    free_tetris_blocks ();
    gtk_main_quit();
}


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

v5[0] = argc;
v4 = argv;
gtk_init(v5, &v4, envp);
gtktetris_activate();
gtk_main();
return 0;
}

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

v5[0] = argc;
v4 = argv;
gtk_init(v5, &v4, envp);
func2();
gtk_main();
return 0;
}

original_code:
int main (int argc, char *argv[])
{
    int status = 0;
    gtk_init (&argc,&argv);
    gtktetris_activate ();
    gtk_main ();
    return status;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int status = 0;
    gtk_init (&argc,&argv);
    gtktetris_activate ();
    gtk_main ();
    return status;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: status int


original_code:
int addto_highscore (char *name, long score, int level, int lines)
{
    int place = 0;
    int temp, namelen;
    int added = (0);
    for (temp=10 -1; temp > -1; temp--)
    {
        if (score > highscore[temp].score || (highscore[temp].score == 0 && strlen(highscore[temp].name) == 0))
        {
            place = temp;
            added = (!(0));
        }
    }
    if (added)
    {
        for(temp=10 -1; temp > place; temp--) {
            memcpy (&highscore[temp], &highscore[temp-1], sizeof(highscore[0]));
        }
        namelen = strlen (name);
        if (namelen > 9) {
            namelen = 9;
        }
        memset (&highscore[place].name, 0, sizeof(highscore[0].name));
        memcpy (&highscore[place].name, name,namelen);
        highscore[place].score = score;
        highscore[place].level = level;
        highscore[place].lines = lines;
    }
    return (place+1);
}

canonical_original_code:
int addto_highscore(char *name, long score, int level, int lines)
{
    int place = 0;
    int temp; int namelen;
    int added = (0);
    for (temp=10 -1; temp > -1; temp--)
    {
        if (score > highscore[temp].score || (highscore[temp].score == 0 && strlen(highscore[temp].name) == 0))
        {
            place = temp;
            added = (!(0));
        }
    }
    if (added)
    {
        for(temp=10 -1; temp > place; temp--) {
            memcpy (&highscore[temp], &highscore[temp-1], sizeof(highscore[0]));
        }
        namelen = strlen (name);
        if (namelen > 9) {
            namelen = 9;
        }
        memset (&highscore[place].name, 0, sizeof(highscore[0].name));
        memcpy (&highscore[place].name, name,namelen);
        highscore[place].score = score;
        highscore[place].level = level;
        highscore[place].lines = lines;
    }
    return (place+1);
}

variable_types:
name
char *

variable_types: score long

variable_types: level int

variable_types: lines int

variable_types: place int

variable_types: temp int

variable_types: namelen int

variable_types: added int


decompiled_code:
__int64 get_hiscore()
{
return highscore[2];
}

canonical_decompiled_code:
__int64 func4()
{
return highscore[2];
}

original_code:
long get_hiscore(void)
{
    return (highscore[0].score);
}

canonical_original_code:
long get_hiscore()
{
    return (highscore[0].score);
}

return_type: long


decompiled_code:
__int64 __fastcall draw_block(int a1, int a2, int a3, int a4, int a5, unsigned int a6)
{
unsigned int v7; // ebp
unsigned __int64 v8; // rbx
unsigned __int64 v9; // r15
__int64 result; // rax

v7 = a3 + 1;
if ( a5 )
v7 = 0;
v8 = 32 * (a4 + 4LL * a3);
v9 = v8 + 16;
do
{
result = set_block((unsigned int)(block_data[v8 / 4] + a1), (unsigned int)(block_data[v8 / 4 + 4] + a2), v7, a6);
v8 += 4LL;
}
while ( v8 != v9 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2, int a3, int a4, int a5, unsigned int a6)
{
unsigned int v7; // ebp
unsigned __int64 v8; // rbx
unsigned __int64 v9; // r15
__int64 result; // rax

v7 = a3 + 1;
if ( a5 )
v7 = 0;
v8 = 32 * (a4 + 4LL * a3);
v9 = v8 + 16;
do
{
result = set_block((unsigned int)(block_data[v8 / 4] + a1), (unsigned int)(block_data[v8 / 4 + 4] + a2), v7, a6);
v8 += 4LL;
}
while ( v8 != v9 );
return result;
}

original_code:
void draw_block(int x,int y,int block,int frame,int clear,int next)
{
    int temp;
    for (temp=0;temp < 4;temp++)
        set_block (x+block_data[block][frame][0][temp],
                   y+block_data[block][frame][1][temp],
                   (clear ? 0 : block+1),
                   next);
}

canonical_original_code:
void draw_block(int x, int y, int block, int frame, int clear, int next)
{
    int temp;
    for (temp=0;temp < 4;temp++)
        set_block (x+block_data[block][frame][0][temp],
                   y+block_data[block][frame][1][temp],
                   (clear ? 0 : block+1),
                   next);
}

variable_types: x int

variable_types: y int

variable_types: block int

variable_types: frame int

variable_types: clear int

variable_types: next int


decompiled_code:
unsigned __int64 to_virtual()
{
int v0; // er9
int v1; // er8
int v2; // edi
unsigned __int64 result; // rax
unsigned __int64 v4; // rsi

v0 = current_y;
v1 = current_x;
v2 = current_block + 1;
result = 32 * (current_frame + 4LL * current_block);
v4 = result + 16;
do
{
*((_DWORD *)&virtual[5 * block_data[result / 4 + 4] + 5 * v0] + block_data[result / 4] + v1) = v2;
result += 4LL;
}
while ( result != v4 );
return result;
}

canonical_decompiled_code:
unsigned __int64 func1()
{
int v0; // er9
int v1; // er8
int v2; // edi
unsigned __int64 result; // rax
unsigned __int64 v4; // rsi

v0 = current_y;
v1 = current_x;
v2 = current_block + 1;
result = 32 * (current_frame + 4LL * current_block);
v4 = result + 16;
do
{
*((_DWORD *)&virtual[5 * block_data[result / 4 + 4] + 5 * v0] + block_data[result / 4] + v1) = v2;
result += 4LL;
}
while ( result != v4 );
return result;
}

original_code:
void to_virtual()
{
    int temp;
    for (temp=0;temp < 4;temp++)
        virtual[current_y+block_data[current_block][current_frame][1][temp]]
            [current_x+block_data[current_block][current_frame][0][temp]] = current_block+1;
}


decompiled_code:
__int64 from_virtual()
{
__int64 v0; // r12
unsigned int i; // ebp
__int64 j; // rbx
__int64 result; // rax

v0 = 0LL;
for ( i = 0; i != 18; ++i )
{
for ( j = 0LL; j != 10; ++j )
result = set_block((unsigned int)j, i, virtual[j + v0], 0LL);
v0 += 10LL;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // r12
unsigned int i; // ebp
__int64 j; // rbx
__int64 result; // rax

v0 = 0LL;
for ( i = 0; i != 18; ++i )
{
for ( j = 0LL; j != 10; ++j )
result = set_block((unsigned int)j, i, virtual[j + v0], 0LL);
v0 += 10LL;
}
return result;
}

original_code:
void from_virtual()
{
    int temp_x,temp_y;
    for (temp_y=0;temp_y < 18;temp_y++)
        for (temp_x=0;temp_x < 10;temp_x++)
            set_block(temp_x,temp_y,virtual[temp_y][temp_x],(0));
}

canonical_original_code:
void from_virtual()
{
    int temp_x; int temp_y;
    for (temp_y=0;temp_y < 18;temp_y++)
        for (temp_x=0;temp_x < 10;temp_x++)
            set_block(temp_x,temp_y,virtual[temp_y][temp_x],(0));
}


decompiled_code:
__int64 __fastcall valid_position(int a1, int a2, int a3, int a4)
{
unsigned __int64 v6; // rax
unsigned __int64 v7; // r10
unsigned int v8; // esi

v6 = 32 * (a4 + 4LL * a3);
v7 = v6 + 16;
while ( 1 )
{
v8 = block_data[v6 / 4 + 4] + a2;
if ( (unsigned int)(block_data[v6 / 4] + a1) > 9 || virtual[10 * v8 + block_data[v6 / 4] + a1] != 0 || v8 > 0x11 )
break;
v6 += 4LL;
if ( v6 == v7 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2, int a3, int a4)
{
unsigned __int64 v6; // rax
unsigned __int64 v7; // r10
unsigned int v8; // esi

v6 = 32 * (a4 + 4LL * a3);
v7 = v6 + 16;
while ( 1 )
{
v8 = block_data[v6 / 4 + 4] + a2;
if ( (unsigned int)(block_data[v6 / 4] + a1) > 9 || virtual[10 * v8 + block_data[v6 / 4] + a1] != 0 || v8 > 0x11 )
break;
v6 += 4LL;
if ( v6 == v7 )
return 1LL;
}
return 0LL;
}

original_code:
int valid_position(int x,int y,int block,int frame)
{
    int temp;
    for (temp=0;temp < 4;temp++) {
        if (virtual[y+block_data[block][frame][1][temp]][x+block_data[block][frame][0][temp]] != 0 ||
            x+block_data[block][frame][0][temp] < 0 ||
            x+block_data[block][frame][0][temp] > 10 -1 ||
            y+block_data[block][frame][1][temp] < 0 ||
            y+block_data[block][frame][1][temp] > 18 -1)
        {
            return (0);
        }
    }
    return (!(0));
}

canonical_original_code:
int valid_position(int x, int y, int block, int frame)
{
    int temp;
    for (temp=0;temp < 4;temp++) {
        if (virtual[y+block_data[block][frame][1][temp]][x+block_data[block][frame][0][temp]] != 0 ||
            x+block_data[block][frame][0][temp] < 0 ||
            x+block_data[block][frame][0][temp] > 10 -1 ||
            y+block_data[block][frame][1][temp] < 0 ||
            y+block_data[block][frame][1][temp] > 18 -1)
        {
            return (0);
        }
    }
    return (!(0));
}


decompiled_code:
__int64 __fastcall move_block(int a1, int a2, int a3)
{
int v3; // er13
int v4; // er12
int v5; // er15
int v6; // er14
__int64 result; // rax

v3 = current_frame;
v4 = current_block;
if ( a3 )
current_frame = (block_frames[current_block] + current_frame + a3) % block_frames[current_block];
v5 = current_y;
v6 = current_x;
result = valid_position(current_x + a1, current_y + a2, current_block, current_frame);
if ( (_DWORD)result )
{
draw_block(v6, v5, v4, v3, 1, 0);
current_x += a1;
current_y += a2;
result = draw_block(current_x, current_y, current_block, current_frame, 0, 0);
}
else
{
current_frame = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2, int a3)
{
int v3; // er13
int v4; // er12
int v5; // er15
int v6; // er14
__int64 result; // rax

v3 = current_frame;
v4 = current_block;
if ( a3 )
current_frame = (block_frames[current_block] + current_frame + a3) % block_frames[current_block];
v5 = current_y;
v6 = current_x;
result = func3(current_x + a1, current_y + a2, current_block, current_frame);
if ( (_DWORD)result )
{
func0(v6, v5, v4, v3, 1, 0);
current_x += a1;
current_y += a2;
result = func0(current_x, current_y, current_block, current_frame, 0, 0);
}
else
{
current_frame = v3;
}
return result;
}

original_code:
void move_block(int x,int y,int f)
{
    int last_frame = current_frame;
    int last_block = current_block;
    if (f != 0)
        current_frame = (block_frames[current_block]+(current_frame+f))%block_frames[current_block];
    if (valid_position(current_x+x,current_y+y,current_block,current_frame))
    {
        draw_block(current_x,current_y,last_block,last_frame,(!(0)),(0));
        current_x += x;
        current_y += y;
        draw_block(current_x,current_y,current_block,current_frame,(0),(0));
    }
    else
    {
        current_block = last_block;
        current_frame = last_frame;
    }
}

canonical_original_code:
void move_block(int x, int y, int f)
{
    int last_frame = current_frame;
    int last_block = current_block;
    if (f != 0)
        current_frame = (block_frames[current_block]+(current_frame+f))%block_frames[current_block];
    if (valid_position(current_x+x,current_y+y,current_block,current_frame))
    {
        draw_block(current_x,current_y,last_block,last_frame,(!(0)),(0));
        current_x += x;
        current_y += y;
        draw_block(current_x,current_y,current_block,current_frame,(0),(0));
    }
    else
    {
        current_block = last_block;
        current_frame = last_frame;
    }
}

variable_types: f int


original_code:
int check_lines()
{
    int temp_x,temp_y,temp,line,lines=0;
    for (temp_y=0;temp_y < 18;temp_y++)
    {
        line = (!(0));
        for (temp_x=0;temp_x < 10;temp_x++)
            if (virtual[temp_y][temp_x] == 0)
                line = (0);
        if (line)
        {
            lines++;
            for (temp=temp_y;temp > 0;temp--) {
                memcpy(virtual[temp],virtual[temp-1],sizeof(virtual[0]));
            }
            memset(virtual[0],0,sizeof(virtual[0]));
            usleep(50000);
            from_virtual();
        }
    }
    return lines;
}

canonical_original_code:
int check_lines()
{
    int temp_x; int temp_y; int temp; int line; int lines = 0;
    for (temp_y=0;temp_y < 18;temp_y++)
    {
        line = (!(0));
        for (temp_x=0;temp_x < 10;temp_x++)
            if (virtual[temp_y][temp_x] == 0)
                line = (0);
        if (line)
        {
            lines++;
            for (temp=temp_y;temp > 0;temp--) {
                memcpy(virtual[temp],virtual[temp-1],sizeof(virtual[0]));
            }
            memset(virtual[0],0,sizeof(virtual[0]));
            usleep(50000);
            from_virtual();
        }
    }
    return lines;
}

variable_types: line int