decompiled_code:
int test_find_index()
{
if ( (unsigned __int16)find_index("setdir", "setdir") )
_assert_fail("0 == find_index(\"setdir\", test)", "test_util.c", 0x13u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("setpin", "setdir") != 1 )
_assert_fail("1 == find_index(\"setpin\", test)", "test_util.c", 0x14u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("get", "setdir") != 2 )
_assert_fail("2 == find_index(\"get\", test)", "test_util.c", 0x15u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("getpin", "setdir") != 3 )
_assert_fail("3 == find_index(\"getpin\", test)", "test_util.c", 0x16u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("<", "setdir") != 4 )
_assert_fail("4 == find_index(\"<\", test)", "test_util.c", 0x17u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("+", "setdir") != 5 )
_assert_fail("5 == find_index(\"+\", test)", "test_util.c", 0x18u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("set", "setdir") != 6 )
_assert_fail("6 == find_index(\"set\", test)", "test_util.c", 0x19u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("xxx", "setdir") != 0xFFFF )
_assert_fail("-1 == find_index(\"xxx\", test)", "test_util.c", 0x1Au, "test_find_index");
return putchar(46);
}

canonical_decompiled_code:
int func1()
{
if ( (unsigned __int16)find_index("setdir", "setdir") )
_assert_fail("0 == find_index(\"setdir\", test)", "test_util.c", 0x13u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("setpin", "setdir") != 1 )
_assert_fail("1 == find_index(\"setpin\", test)", "test_util.c", 0x14u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("get", "setdir") != 2 )
_assert_fail("2 == find_index(\"get\", test)", "test_util.c", 0x15u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("getpin", "setdir") != 3 )
_assert_fail("3 == find_index(\"getpin\", test)", "test_util.c", 0x16u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("<", "setdir") != 4 )
_assert_fail("4 == find_index(\"<\", test)", "test_util.c", 0x17u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("+", "setdir") != 5 )
_assert_fail("5 == find_index(\"+\", test)", "test_util.c", 0x18u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("set", "setdir") != 6 )
_assert_fail("6 == find_index(\"set\", test)", "test_util.c", 0x19u, "test_find_index");
putchar(46);
if ( (unsigned __int16)find_index("xxx", "setdir") != 0xFFFF )
_assert_fail("-1 == find_index(\"xxx\", test)", "test_util.c", 0x1Au, "test_find_index");
return putchar(46);
}

original_code:
void test_find_index()
{
    const char *test = "setdir\0setpin\0get\0getpin\0<\0+\0set\0\0";
    { ((0 == find_index("setdir", test)) ? (void) (0) : __assert_fail ("0 == find_index(\"setdir\", test)", "test_util.c", 19, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((1 == find_index("setpin", test)) ? (void) (0) : __assert_fail ("1 == find_index(\"setpin\", test)", "test_util.c", 20, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((2 == find_index("get", test)) ? (void) (0) : __assert_fail ("2 == find_index(\"get\", test)", "test_util.c", 21, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((3 == find_index("getpin", test)) ? (void) (0) : __assert_fail ("3 == find_index(\"getpin\", test)", "test_util.c", 22, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((4 == find_index("<", test)) ? (void) (0) : __assert_fail ("4 == find_index(\"<\", test)", "test_util.c", 23, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((5 == find_index("+", test)) ? (void) (0) : __assert_fail ("5 == find_index(\"+\", test)", "test_util.c", 24, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((6 == find_index("set", test)) ? (void) (0) : __assert_fail ("6 == find_index(\"set\", test)", "test_util.c", 25, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((-1 == find_index("xxx", test)) ? (void) (0) : __assert_fail ("-1 == find_index(\"xxx\", test)", "test_util.c", 26, __extension__ __PRETTY_FUNCTION__)); printf(".");};
}

canonical_original_code:
void test_find_index()
{
    char *test = "setdir\0setpin\0get\0getpin\0<\0+\0set\0\0";
    { ((0 == find_index("setdir", test)) ? (void) (0) : __assert_fail ("0 == find_index(\"setdir\", test)", "test_util.c", 19, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((1 == find_index("setpin", test)) ? (void) (0) : __assert_fail ("1 == find_index(\"setpin\", test)", "test_util.c", 20, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((2 == find_index("get", test)) ? (void) (0) : __assert_fail ("2 == find_index(\"get\", test)", "test_util.c", 21, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((3 == find_index("getpin", test)) ? (void) (0) : __assert_fail ("3 == find_index(\"getpin\", test)", "test_util.c", 22, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((4 == find_index("<", test)) ? (void) (0) : __assert_fail ("4 == find_index(\"<\", test)", "test_util.c", 23, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((5 == find_index("+", test)) ? (void) (0) : __assert_fail ("5 == find_index(\"+\", test)", "test_util.c", 24, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((6 == find_index("set", test)) ? (void) (0) : __assert_fail ("6 == find_index(\"set\", test)", "test_util.c", 25, __extension__ __PRETTY_FUNCTION__)); printf(".");};
    { ((-1 == find_index("xxx", test)) ? (void) (0) : __assert_fail ("-1 == find_index(\"xxx\", test)", "test_util.c", 26, __extension__ __PRETTY_FUNCTION__)); printf(".");};
}


repo: phatio/phatio

decompiled_code:
int __fastcall test_parse(__int64 a1, __int16 a2)
{
__int16 v3[5]; // [rsp+Eh] [rbp-Ah] BYREF

v3[0] = 0;
if ( !(unsigned __int8)parse_number(a1, v3) )
_assert_fail("parse_number(str, &parsed_value)", "test_util.c", 0x21u, "test_parse");
if ( v3[0] != a2 )
_assert_fail("value == parsed_value", "test_util.c", 0x22u, "test_parse");
return putchar(46);
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int16 a2)
{
__int16 v3[5]; // [rsp+Eh] [rbp-Ah] BYREF

v3[0] = 0;
if ( !(unsigned __int8)parse_number(a1, v3) )
_assert_fail("parse_number(str, &parsed_value)", "test_util.c", 0x21u, "test_parse");
if ( v3[0] != a2 )
_assert_fail("value == parsed_value", "test_util.c", 0x22u, "test_parse");
return putchar(46);
}

original_code:
void test_parse(char *str, uint16_t value)
{
    uint16_t parsed_value = 0;
    ((parse_number(str, &parsed_value)) ? (void) (0) : __assert_fail ("parse_number(str, &parsed_value)", "test_util.c", 33, __extension__ __PRETTY_FUNCTION__));
    { ((value == parsed_value) ? (void) (0) : __assert_fail ("value == parsed_value", "test_util.c", 34, __extension__ __PRETTY_FUNCTION__)); printf(".");};
}

canonical_original_code:
void test_parse(char *str, unsigned short value)
{
    unsigned short parsed_value = 0;
    ((parse_number(str, &parsed_value)) ? (void) (0) : __assert_fail ("parse_number(str, &parsed_value)", "test_util.c", 33, __extension__ __PRETTY_FUNCTION__));
    { ((value == parsed_value) ? (void) (0) : __assert_fail ("value == parsed_value", "test_util.c", 34, __extension__ __PRETTY_FUNCTION__)); printf(".");};
}

variable_types:
str
char *

variable_types:
value
unsigned short

return_type: void


decompiled_code:
void test_parse_number()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void test_parse_number()
{
}

canonical_original_code:
void test_parse_number()
{
}


decompiled_code:
int test_util()
{
test_string_char_source();
return test_find_index();
}

canonical_decompiled_code:
int func4()
{
func0();
return func1();
}

original_code:
void test_util(void)
{
    test_string_char_source();
    test_find_index();
 test_parse_number();
}

canonical_original_code:
void test_util()
{
    test_string_char_source();
    test_find_index();
 test_parse_number();
}


decompiled_code:
int test_FATBLOCK()
{
putchar(46);
putchar(46);
putchar(46);
putchar(46);
return putchar(46);
}

canonical_decompiled_code:
int func0()
{
putchar(46);
putchar(46);
putchar(46);
putchar(46);
return putchar(46);
}


decompiled_code:
int test_FATOFFSET()
{
putchar(46);
putchar(46);
putchar(46);
putchar(46);
putchar(46);
putchar(46);
return putchar(46);
}

canonical_decompiled_code:
int func1()
{
putchar(46);
putchar(46);
putchar(46);
putchar(46);
putchar(46);
putchar(46);
return putchar(46);
}


decompiled_code:
int test_fat_sfn()
{
_BYTE *v0; // rax
_BYTE *v1; // rcx
__int64 v2; // rax
char v3; // dl
_BYTE *v4; // rax
_BYTE *v5; // rcx
__int64 v6; // rax
char v7; // dl
_BYTE *v8; // rax
_BYTE *v9; // rcx
__int64 v10; // rax
char v11; // dl
_BYTE *v12; // rax
_BYTE *v13; // rcx
__int64 v14; // rax
char v15; // dl
_BYTE *v16; // rax
_BYTE *v17; // rcx
__int64 v18; // rax
char v19; // dl
_BYTE *v20; // rax
_BYTE *v21; // rcx
__int64 v22; // rax
char v23; // dl
_BYTE *v24; // rax
_BYTE *v25; // rcx
__int64 v26; // rax
char v27; // dl
_BYTE *v28; // rax
_BYTE *v29; // rcx
__int64 v30; // rax
char v31; // dl
_BYTE *v32; // rax
_BYTE *v33; // rcx
__int64 v34; // rax
char v35; // dl
_BYTE *v36; // rax
_BYTE *v37; // rcx
__int64 v38; // rax
char v39; // dl
_BYTE *v40; // rax
_BYTE *v41; // rcx
__int64 v42; // rax
char v43; // dl
_BYTE *v44; // rax
_BYTE *v45; // rcx
__int64 v46; // rax
char v47; // dl
_BYTE *v48; // rax
_BYTE *v49; // rcx
__int64 v50; // rax
char v51; // dl
_BYTE *v52; // rax
_BYTE *v53; // rcx
__int64 v54; // rax
char v55; // dl

v0 = (_BYTE *)fat_sfn(".fseventsd");
if ( !v0 || (v1 = v0, *v0 != 70) )
LABEL_72:
_assert_fail("0", "test_fat_impl.c", 0x1Eu, "test_fat_sfn");
v2 = 1LL;
do
{
v3 = byte_67C[v2];
if ( v3 != v1[v2] )
goto LABEL_72;
++v2;
}
while ( v3 );
putchar(46);
v4 = (_BYTE *)fat_sfn("PORTD");
v5 = v4;
if ( !v4 || *v4 != 80 )
LABEL_85:
_assert_fail("0", "test_fat_impl.c", 0x1Fu, "test_fat_sfn");
v6 = 1LL;
do
{
v7 = byte_68E[v6];
if ( v7 != v5[v6] )
goto LABEL_85;
++v6;
}
while ( v7 );
putchar(46);
v8 = (_BYTE *)fat_sfn("test.me");
v9 = v8;
if ( !v8 || *v8 != 84 )
LABEL_84:
_assert_fail("0", "test_fat_impl.c", 0x20u, "test_fat_sfn");
v10 = 1LL;
do
{
v11 = byte_6A2[v10];
if ( v11 != v9[v10] )
goto LABEL_84;
++v10;
}
while ( v11 );
putchar(46);
v12 = (_BYTE *)fat_sfn("test.measdf");
v13 = v12;
if ( !v12 || *v12 != 84 )
LABEL_83:
_assert_fail("0", "test_fat_impl.c", 0x21u, "test_fat_sfn");
v14 = 1LL;
do
{
v15 = byte_6BA[v14];
if ( v15 != v13[v14] )
goto LABEL_83;
++v14;
}
while ( v15 );
putchar(46);
v16 = (_BYTE *)fat_sfn("test.");
v17 = v16;
if ( !v16 || *v16 != 84 )
LABEL_82:
_assert_fail("0", "test_fat_impl.c", 0x22u, "test_fat_sfn");
v18 = 1LL;
do
{
v19 = byte_6CC[v18];
if ( v19 != v17[v18] )
goto LABEL_82;
++v18;
}
while ( v19 );
putchar(46);
v20 = (_BYTE *)fat_sfn("test....");
v21 = v20;
if ( !v20 || *v20 != 84 )
LABEL_81:
_assert_fail("0", "test_fat_impl.c", 0x23u, "test_fat_sfn");
v22 = 1LL;
do
{
v23 = byte_6CC[v22];
if ( v23 != v21[v22] )
goto LABEL_81;
++v22;
}
while ( v23 );
putchar(46);
v24 = (_BYTE *)fat_sfn("test...xafc.");
v25 = v24;
if ( !v24 || *v24 != 84 )
LABEL_80:
_assert_fail("0", "test_fat_impl.c", 0x24u, "test_fat_sfn");
v26 = 1LL;
do
{
v27 = byte_6EE[v26];
if ( v27 != v25[v26] )
goto LABEL_80;
++v26;
}
while ( v27 );
putchar(46);
v28 = (_BYTE *)fat_sfn("test.sad");
v29 = v28;
if ( !v28 || *v28 != 84 )
LABEL_79:
_assert_fail("0", "test_fat_impl.c", 0x25u, "test_fat_sfn");
v30 = 1LL;
do
{
v31 = byte_703[v30];
if ( v31 != v29[v30] )
goto LABEL_79;
++v30;
}
while ( v31 );
putchar(46);
v32 = (_BYTE *)fat_sfn("testaBcD.sad");
v33 = v32;
if ( !v32 || *v32 != 84 )
LABEL_78:
_assert_fail("0", "test_fat_impl.c", 0x26u, "test_fat_sfn");
v34 = 1LL;
do
{
v35 = byte_71C[v34];
if ( v35 != v33[v34] )
goto LABEL_78;
++v34;
}
while ( v35 );
putchar(46);
v36 = (_BYTE *)fat_sfn("testaBcDe.sad");
v37 = v36;
if ( !v36 || *v36 != 84 )
LABEL_77:
_assert_fail("0", "test_fat_impl.c", 0x27u, "test_fat_sfn");
v38 = 1LL;
do
{
v39 = byte_736[v38];
if ( v39 != v37[v38] )
goto LABEL_77;
++v38;
}
while ( v39 );
putchar(46);
v40 = (_BYTE *)fat_sfn("test .,3$ $x.sad");
v41 = v40;
if ( !v40 || *v40 != 84 )
LABEL_76:
_assert_fail("0", "test_fat_impl.c", 0x28u, "test_fat_sfn");
v42 = 1LL;
do
{
v43 = byte_753[v42];
if ( v43 != v41[v42] )
goto LABEL_76;
++v42;
}
while ( v43 );
putchar(46);
v44 = (_BYTE *)fat_sfn("$%'-_@~!().xxx");
v45 = v44;
if ( !v44 || *v44 != 36 )
LABEL_75:
_assert_fail("0", "test_fat_impl.c", 0x29u, "test_fat_sfn");
v46 = 1LL;
do
{
v47 = byte_76E[v46];
if ( v47 != v45[v46] )
goto LABEL_75;
++v46;
}
while ( v47 );
putchar(46);
v48 = (_BYTE *)fat_sfn("$%'-_@~!()");
v49 = v48;
if ( !v48 || *v48 != 36 )
LABEL_74:
_assert_fail("0", "test_fat_impl.c", 0x2Au, "test_fat_sfn");
v50 = 1LL;
do
{
v51 = byte_785[v50];
if ( v51 != v49[v50] )
goto LABEL_74;
++v50;
}
while ( v51 );
putchar(46);
v52 = (_BYTE *)fat_sfn("this.is.a long file.abcdef");
v53 = v52;
if ( !v52 || *v52 != 84 )
LABEL_73:
_assert_fail("0", "test_fat_impl.c", 0x2Bu, "test_fat_sfn");
v54 = 1LL;
do
{
v55 = byte_7AC[v54];
if ( v55 != v53[v54] )
goto LABEL_73;
++v54;
}
while ( v55 );
return putchar(46);
}

canonical_decompiled_code:
int func2()
{
_BYTE *v0; // rax
_BYTE *v1; // rcx
__int64 v2; // rax
char v3; // dl
_BYTE *v4; // rax
_BYTE *v5; // rcx
__int64 v6; // rax
char v7; // dl
_BYTE *v8; // rax
_BYTE *v9; // rcx
__int64 v10; // rax
char v11; // dl
_BYTE *v12; // rax
_BYTE *v13; // rcx
__int64 v14; // rax
char v15; // dl
_BYTE *v16; // rax
_BYTE *v17; // rcx
__int64 v18; // rax
char v19; // dl
_BYTE *v20; // rax
_BYTE *v21; // rcx
__int64 v22; // rax
char v23; // dl
_BYTE *v24; // rax
_BYTE *v25; // rcx
__int64 v26; // rax
char v27; // dl
_BYTE *v28; // rax
_BYTE *v29; // rcx
__int64 v30; // rax
char v31; // dl
_BYTE *v32; // rax
_BYTE *v33; // rcx
__int64 v34; // rax
char v35; // dl
_BYTE *v36; // rax
_BYTE *v37; // rcx
__int64 v38; // rax
char v39; // dl
_BYTE *v40; // rax
_BYTE *v41; // rcx
__int64 v42; // rax
char v43; // dl
_BYTE *v44; // rax
_BYTE *v45; // rcx
__int64 v46; // rax
char v47; // dl
_BYTE *v48; // rax
_BYTE *v49; // rcx
__int64 v50; // rax
char v51; // dl
_BYTE *v52; // rax
_BYTE *v53; // rcx
__int64 v54; // rax
char v55; // dl

v0 = (_BYTE *)fat_sfn(".fseventsd");
if ( !v0 || (v1 = v0, *v0 != 70) )
LABEL_72:
_assert_fail("0", "test_fat_impl.c", 0x1Eu, "test_fat_sfn");
v2 = 1LL;
do
{
v3 = byte_67C[v2];
if ( v3 != v1[v2] )
goto LABEL_72;
++v2;
}
while ( v3 );
putchar(46);
v4 = (_BYTE *)fat_sfn("PORTD");
v5 = v4;
if ( !v4 || *v4 != 80 )
LABEL_85:
_assert_fail("0", "test_fat_impl.c", 0x1Fu, "test_fat_sfn");
v6 = 1LL;
do
{
v7 = byte_68E[v6];
if ( v7 != v5[v6] )
goto LABEL_85;
++v6;
}
while ( v7 );
putchar(46);
v8 = (_BYTE *)fat_sfn("test.me");
v9 = v8;
if ( !v8 || *v8 != 84 )
LABEL_84:
_assert_fail("0", "test_fat_impl.c", 0x20u, "test_fat_sfn");
v10 = 1LL;
do
{
v11 = byte_6A2[v10];
if ( v11 != v9[v10] )
goto LABEL_84;
++v10;
}
while ( v11 );
putchar(46);
v12 = (_BYTE *)fat_sfn("test.measdf");
v13 = v12;
if ( !v12 || *v12 != 84 )
LABEL_83:
_assert_fail("0", "test_fat_impl.c", 0x21u, "test_fat_sfn");
v14 = 1LL;
do
{
v15 = byte_6BA[v14];
if ( v15 != v13[v14] )
goto LABEL_83;
++v14;
}
while ( v15 );
putchar(46);
v16 = (_BYTE *)fat_sfn("test.");
v17 = v16;
if ( !v16 || *v16 != 84 )
LABEL_82:
_assert_fail("0", "test_fat_impl.c", 0x22u, "test_fat_sfn");
v18 = 1LL;
do
{
v19 = byte_6CC[v18];
if ( v19 != v17[v18] )
goto LABEL_82;
++v18;
}
while ( v19 );
putchar(46);
v20 = (_BYTE *)fat_sfn("test....");
v21 = v20;
if ( !v20 || *v20 != 84 )
LABEL_81:
_assert_fail("0", "test_fat_impl.c", 0x23u, "test_fat_sfn");
v22 = 1LL;
do
{
v23 = byte_6CC[v22];
if ( v23 != v21[v22] )
goto LABEL_81;
++v22;
}
while ( v23 );
putchar(46);
v24 = (_BYTE *)fat_sfn("test...xafc.");
v25 = v24;
if ( !v24 || *v24 != 84 )
LABEL_80:
_assert_fail("0", "test_fat_impl.c", 0x24u, "test_fat_sfn");
v26 = 1LL;
do
{
v27 = byte_6EE[v26];
if ( v27 != v25[v26] )
goto LABEL_80;
++v26;
}
while ( v27 );
putchar(46);
v28 = (_BYTE *)fat_sfn("test.sad");
v29 = v28;
if ( !v28 || *v28 != 84 )
LABEL_79:
_assert_fail("0", "test_fat_impl.c", 0x25u, "test_fat_sfn");
v30 = 1LL;
do
{
v31 = byte_703[v30];
if ( v31 != v29[v30] )
goto LABEL_79;
++v30;
}
while ( v31 );
putchar(46);
v32 = (_BYTE *)fat_sfn("testaBcD.sad");
v33 = v32;
if ( !v32 || *v32 != 84 )
LABEL_78:
_assert_fail("0", "test_fat_impl.c", 0x26u, "test_fat_sfn");
v34 = 1LL;
do
{
v35 = byte_71C[v34];
if ( v35 != v33[v34] )
goto LABEL_78;
++v34;
}
while ( v35 );
putchar(46);
v36 = (_BYTE *)fat_sfn("testaBcDe.sad");
v37 = v36;
if ( !v36 || *v36 != 84 )
LABEL_77:
_assert_fail("0", "test_fat_impl.c", 0x27u, "test_fat_sfn");
v38 = 1LL;
do
{
v39 = byte_736[v38];
if ( v39 != v37[v38] )
goto LABEL_77;
++v38;
}
while ( v39 );
putchar(46);
v40 = (_BYTE *)fat_sfn("test .,3$ $x.sad");
v41 = v40;
if ( !v40 || *v40 != 84 )
LABEL_76:
_assert_fail("0", "test_fat_impl.c", 0x28u, "test_fat_sfn");
v42 = 1LL;
do
{
v43 = byte_753[v42];
if ( v43 != v41[v42] )
goto LABEL_76;
++v42;
}
while ( v43 );
putchar(46);
v44 = (_BYTE *)fat_sfn("$%'-_@~!().xxx");
v45 = v44;
if ( !v44 || *v44 != 36 )
LABEL_75:
_assert_fail("0", "test_fat_impl.c", 0x29u, "test_fat_sfn");
v46 = 1LL;
do
{
v47 = byte_76E[v46];
if ( v47 != v45[v46] )
goto LABEL_75;
++v46;
}
while ( v47 );
putchar(46);
v48 = (_BYTE *)fat_sfn("$%'-_@~!()");
v49 = v48;
if ( !v48 || *v48 != 36 )
LABEL_74:
_assert_fail("0", "test_fat_impl.c", 0x2Au, "test_fat_sfn");
v50 = 1LL;
do
{
v51 = byte_785[v50];
if ( v51 != v49[v50] )
goto LABEL_74;
++v50;
}
while ( v51 );
putchar(46);
v52 = (_BYTE *)fat_sfn("this.is.a long file.abcdef");
v53 = v52;
if ( !v52 || *v52 != 84 )
LABEL_73:
_assert_fail("0", "test_fat_impl.c", 0x2Bu, "test_fat_sfn");
v54 = 1LL;
do
{
v55 = byte_7AC[v54];
if ( v55 != v53[v54] )
goto LABEL_73;
++v54;
}
while ( v55 );
return putchar(46);
}

original_code:
void test_fat_sfn()
{
    {const char *e = "FSEVEN~1   "; const char *g = fat_sfn(".fseventsd"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 30, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 30, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "PORTD      "; const char *g = fat_sfn("PORTD"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 31, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 31, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TEST    ME "; const char *g = fat_sfn("test.me"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 32, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 32, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TEST    MEA"; const char *g = fat_sfn("test.measdf"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 33, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 33, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TEST       "; const char *g = fat_sfn("test."); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 34, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 34, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TEST       "; const char *g = fat_sfn("test...."); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 35, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 35, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TEST    XAF"; const char *g = fat_sfn("test...xafc."); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 36, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 36, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TEST    SAD"; const char *g = fat_sfn("test.sad"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 37, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 37, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TESTABCDSAD"; const char *g = fat_sfn("testaBcD.sad"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 38, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 38, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TESTAB~1SAD"; const char *g = fat_sfn("testaBcDe.sad"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 39, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 39, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "TEST_3~1SAD"; const char *g = fat_sfn("test .,3$ $x.sad"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 40, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 40, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "$%'-_@~1XXX"; const char *g = fat_sfn("$%'-_@~!().xxx"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 41, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 41, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "$%'-_@~1   "; const char *g = fat_sfn("$%'-_@~!()"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 42, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 42, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {const char *e = "THISIS~1ABC"; const char *g = fat_sfn("this.is.a long file.abcdef"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 43, __extension__ __PRETTY_FUNCTION__)); for (int i=0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 43, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
}

canonical_original_code:
void test_fat_sfn()
{
    {char *e = "FSEVEN~1   "; char *g = fat_sfn(".fseventsd"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 30, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 30, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "PORTD      "; char *g = fat_sfn("PORTD"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 31, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 31, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TEST    ME "; char *g = fat_sfn("test.me"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 32, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 32, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TEST    MEA"; char *g = fat_sfn("test.measdf"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 33, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 33, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TEST       "; char *g = fat_sfn("test."); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 34, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 34, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TEST       "; char *g = fat_sfn("test...."); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 35, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 35, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TEST    XAF"; char *g = fat_sfn("test...xafc."); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 36, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 36, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TEST    SAD"; char *g = fat_sfn("test.sad"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 37, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 37, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TESTABCDSAD"; char *g = fat_sfn("testaBcD.sad"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 38, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 38, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TESTAB~1SAD"; char *g = fat_sfn("testaBcDe.sad"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 39, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 39, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "TEST_3~1SAD"; char *g = fat_sfn("test .,3$ $x.sad"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 40, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 40, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "$%'-_@~1XXX"; char *g = fat_sfn("$%'-_@~!().xxx"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 41, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 41, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "$%'-_@~1   "; char *g = fat_sfn("$%'-_@~!()"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 42, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 42, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
 {char *e = "THISIS~1ABC"; char *g = fat_sfn("this.is.a long file.abcdef"); if (g == 0 && e != 0) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 43, __extension__ __PRETTY_FUNCTION__)); for (int i = 0; ; i++) { if (e[i] != g[i]) ((0) ? (void) (0) : __assert_fail ("0", "test_fat_impl.c", 43, __extension__ __PRETTY_FUNCTION__)); if (e[i] == 0 && g[i] == 0) break; } printf(".");};
}

variable_types:
e
char *

variable_types:
g
char *

variable_types: i int


decompiled_code:
int test_fat_impl()
{
test_FATBLOCK();
test_FATOFFSET();
return test_fat_sfn();
}

canonical_decompiled_code:
int func3()
{
func0();
func1();
return func2();
}

original_code:
void test_fat_impl(void)
{
 test_FATBLOCK();
 test_FATOFFSET();
 test_fat_sfn();
}

canonical_original_code:
void test_fat_impl()
{
 test_FATBLOCK();
 test_FATOFFSET();
 test_fat_sfn();
}


decompiled_code:
__int64 next_char()
{
return (unsigned __int8)buffer[offset++];
}

canonical_decompiled_code:
__int64 func7()
{
return (unsigned __int8)buffer[offset++];
}

original_code: uint8_t next_char(void) { offset++; return buffer[offset-1];}

canonical_original_code: unsigned char next_char() { offset++; return buffer[offset-1];}

return_type: unsigned char


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

if ( (unsigned __int8)a1 > 0x60u )
return (unsigned int)(a1 - 87);
result = (unsigned int)(a1 - 48);
if ( (unsigned __int8)a1 >= 0x41u )
result = (unsigned int)(a1 - 55);
return result;
}

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

if ( (unsigned __int8)a1 > 0x60u )
return (unsigned int)(a1 - 87);
result = (unsigned int)(a1 - 48);
if ( (unsigned __int8)a1 >= 0x41u )
result = (unsigned int)(a1 - 55);
return result;
}

canonical_original_code: unsigned char hex_char(unsigned char c) {return (c >= 'a') ? (c - 'W') : ((c >= 'A') ? c - '7' : c - '0'); }

variable_types:
c
unsigned char


decompiled_code:
__int64 next_byte()
{
unsigned __int8 v0; // al
unsigned __int8 v1; // al
unsigned int v2; // eax
int v3; // ecx

v0 = next_char();
hex_char(v0);
v1 = next_char();
v2 = hex_char(v1);
return v3 | v2;
}

canonical_decompiled_code:
__int64 func9()
{
unsigned __int8 v0; // al
unsigned __int8 v1; // al
unsigned int v2; // eax
int v3; // ecx

v0 = func7();
func8(v0);
v1 = func7();
v2 = func8(v1);
return v3 | v2;
}

original_code: uint8_t next_byte(void) { return ((hex_char(next_char()) << 4) | hex_char(next_char())); }

canonical_original_code: unsigned char next_byte() { return ((hex_char(next_char()) << 4) | hex_char(next_char())); }


decompiled_code:
__int64 next_word()
{
int v0; // esi

v0 = next_byte();
return (v0 << 8) | (unsigned int)(unsigned __int8)next_byte();
}

canonical_decompiled_code:
__int64 func10()
{
int v0; // esi

v0 = func9();
return (v0 << 8) | (unsigned int)(unsigned __int8)func9();
}

original_code: uint16_t next_word(void) { return ((next_byte() << 8) | next_byte()); }

canonical_original_code: unsigned short next_word() { return ((next_byte() << 8) | next_byte()); }

return_type: unsigned short


decompiled_code:
__int16 __fastcall crc16_update(int a1, unsigned __int8 a2)
{
int v2; // edx
int v3; // eax
char v4; // si
int v5; // ecx

v2 = 8;
v3 = a1 ^ a2;
do
{
v4 = v3;
LOWORD(v3) = (unsigned __int16)v3 >> 1;
HIWORD(v5) = HIWORD(v3);
if ( (v4 & 1) != 0 )
{
LOWORD(v5) = v3 ^ 0xA001;
v3 = v5;
}
--v2;
}
while ( v2 );
return v3;
}

canonical_decompiled_code:
__int16 __fastcall func11(int a1, unsigned __int8 a2)
{
int v2; // edx
int v3; // eax
char v4; // si
int v5; // ecx

v2 = 8;
v3 = a1 ^ a2;
do
{
v4 = v3;
LOWORD(v3) = (unsigned __int16)v3 >> 1;
HIWORD(v5) = HIWORD(v3);
if ( (v4 & 1) != 0 )
{
LOWORD(v5) = v3 ^ 0xA001;
v3 = v5;
}
--v2;
}
while ( v2 );
return v3;
}

original_code:
uint16_t crc16_update(uint16_t crc, uint8_t a)
{
    int i;
    crc ^= a;
    for (i = 0; i < 8; ++i)
    {
        if (crc & 1)
            crc = (crc >> 1) ^ 0xA001;
        else
            crc = (crc >> 1);
    }
    return crc;
}

canonical_original_code:
unsigned short crc16_update(unsigned short crc, unsigned char a)
{
    int i;
    crc ^= a;
    for (i = 0; i < 8; ++i)
    {
        if (crc & 1)
            crc = (crc >> 1) ^ 0xA001;
        else
            crc = (crc >> 1);
    }
    return crc;
}

variable_types:
crc
unsigned short

variable_types:
a
unsigned char


main

canonical_name: main

decompiled_code:
// local variable allocation has failed, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 i; // rbp
__int16 v4; // ax
int v5; // eax
unsigned __int16 v6; // r8
char v8; // r10
unsigned __int8 v9; // al
__int64 v10; // r8
int v11; // er9
__int64 v12; // rdx
__int64 v13; // rcx
char v14; // r9
char v15; // r10

for ( i = 0LL; ; ++i )
{
v4 = getchar();
if ( v4 == -1 )
break;
buffer[i] = v4;
}
offset = 0;
v5 = 0;
v6 = 0;
while ( (int)i > v5 )
{
if ( (unsigned __int8)next_char() == 58 )
{
next_byte(*(_QWORD *)&argc, argv);
next_word();
next_byte(*(_QWORD *)&argc, argv);
if ( v8 )
{
do
{
v9 = next_byte(*(_QWORD *)&argc, argv);
*(_QWORD *)&argc = (unsigned __int16)v10;
argv = (const char **)v9;
crc16_update((unsigned __int16)v10, v9, v12, v13, v10, (unsigned int)(v11 + 1));
}
while ( v15 != v14 );
}
next_byte(*(_QWORD *)&argc, argv);
}
v5 = offset;
}
printf("%04X", v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 i; // rbp
__int16 v4; // ax
int v5; // eax
unsigned __int16 v6; // r8
char v8; // r10
unsigned __int8 v9; // al
__int64 v10; // r8
int v11; // er9
__int64 v12; // rdx
__int64 v13; // rcx
char v14; // r9
char v15; // r10

for ( i = 0LL; ; ++i )
{
v4 = getchar();
if ( v4 == -1 )
break;
buffer[i] = v4;
}
offset = 0;
v5 = 0;
v6 = 0;
while ( (int)i > v5 )
{
if ( (unsigned __int8)func7() == 58 )
{
func9(*(_QWORD *)&argc, argv);
func10();
func9(*(_QWORD *)&argc, argv);
if ( v8 )
{
do
{
v9 = func9(*(_QWORD *)&argc, argv);
*(_QWORD *)&argc = (unsigned __int16)v10;
argv = (const char **)v9;
func11((unsigned __int16)v10, v9, v12, v13, v10, (unsigned int)(v11 + 1));
}
while ( v15 != v14 );
}
func9(*(_QWORD *)&argc, argv);
}
v5 = offset;
}
printf("%04X", v6);
return 0;
}

original_code:
int main(void)
{
    int32_t size = 0;
    uint16_t prog_crc = 0;
    for (int16_t c = 0; (c = getchar()) != (-1); size++) {
        buffer[size] = c;
    }
    int lines=0;
    int bytes=0;
    for (offset = 0; offset < size;) {
        if (next_char() == ':') {
            uint8_t byte_count = next_byte();
            uint16_t address = next_word();
            uint8_t type = next_byte();
            for (uint8_t i = 0; i < byte_count; i++) {
                uint8_t byte = next_byte();
                prog_crc = crc16_update(prog_crc, byte);
            }
            bytes += byte_count;
            uint8_t checksum = next_byte();
            lines++;
        }
    }
    printf("%04X", prog_crc);
}

canonical_original_code:
int main()
{
    int size = 0;
    unsigned short prog_crc = 0;
    for (short c = 0; (c = getchar()) != (-1); size++) {
        buffer[size] = c;
    }
    int lines = 0;
    int bytes = 0;
    for (offset = 0; offset < size;) {
        if (next_char() == ':') {
            unsigned char byte_count = next_byte();
            unsigned short address = next_word();
            unsigned char type = next_byte();
            for (unsigned char i = 0; i < byte_count; i++) {
                unsigned char byte = next_byte();
                prog_crc = crc16_update(prog_crc, byte);
            }
            bytes += byte_count;
            unsigned char checksum = next_byte();
            lines++;
        }
    }
    printf("%04X", prog_crc);
}

variable_types: size int

variable_types: c short

variable_types: lines int

variable_types: bytes int

variable_types:
address
unsigned short

variable_types:
type
unsigned char

variable_types:
i
unsigned char

variable_types:
byte
unsigned char

variable_types:
checksum
unsigned char

return_type: int


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

if ( (a2 & 0x8000u) != 0 )
result = ~a2 + (unsigned int)*(unsigned __int16 *)(a1 + 528);
else
result = (unsigned int)*(unsigned __int16 *)(a1 + 526) + a2 - 2;
return result;
}

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

if ( (a2 & 0x8000u) != 0 )
result = ~a2 + (unsigned int)*(unsigned __int16 *)(a1 + 528);
else
result = (unsigned int)*(unsigned __int16 *)(a1 + 526) + a2 - 2;
return result;
}

original_code:
uint16_t cluster_to_block(sd_disk *sd, int16_t cluster)
{
    return (cluster < 0) ? (sd->root_dir - cluster - 1) : (sd->data_start+cluster-2);
}

canonical_original_code:
unsigned short cluster_to_block(struct sd_disk *sd, short cluster)
{
    return (cluster < 0) ? (sd->root_dir - cluster - 1) : (sd->data_start+cluster-2);
}

variable_types: struct sd_disk { unsigned char sd_type; unsigned int sd_size; unsigned char buf[512]; unsigned int p_size; unsigned short fat_start; unsigned short data_start; unsigned short root_dir; } *

variable_types: cluster short


decompiled_code:
char __fastcall sfn_checksum(_BYTE *a1)
{
_BYTE *v1; // rdx
char result; // al

v1 = a1 + 11;
result = 0;
do
result = *a1++ + __ROR1__(result, 1);
while ( v1 != a1 );
return result;
}

canonical_decompiled_code:
char __fastcall func1(_BYTE *a1)
{
_BYTE *v1; // rdx
char result; // al

v1 = a1 + 11;
result = 0;
do
result = *a1++ + __ROR1__(result, 1);
while ( v1 != a1 );
return result;
}

original_code:
uint8_t sfn_checksum(uint8_t sfn[])
{
     uint8_t checksum = 0;
     for (uint8_t i=0; i<11; i++) {
          checksum = (((checksum & 1) << 7) | ((checksum & 0xfe) >> 1)) + sfn[i];
     }
     return checksum;
}

canonical_original_code:
unsigned char sfn_checksum(unsigned char sfn[])
{
     unsigned char checksum = 0;
     for (unsigned char i = 0; i<11; i++) {
          checksum = (((checksum & 1) << 7) | ((checksum & 0xfe) >> 1)) + sfn[i];
     }
     return checksum;
}

variable_types:
sfn
unsigned char []


decompiled_code:
__int64 __fastcall fat_sfn_safe_char(unsigned int a1)
{
int v1; // edx
int v2; // eax

if ( (_BYTE)a1 == 32 || (_BYTE)a1 == 46 )
return 0LL;
if ( (unsigned __int8)(a1 - 97) <= 0x19u )
return a1 - 32;
if ( (unsigned __int8)(a1 - 65) > 0x19u && (unsigned __int8)(a1 - 48) > 9u )
{
v1 = 0;
v2 = 36;
while ( v2 != (unsigned __int8)a1 )
{
v2 = byte_31C[(unsigned __int8)++v1];
if ( !byte_31C[(unsigned __int8)v1] )
return 95LL;
}
}
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
int v1; // edx
int v2; // eax

if ( (_BYTE)a1 == 32 || (_BYTE)a1 == 46 )
return 0LL;
if ( (unsigned __int8)(a1 - 97) <= 0x19u )
return a1 - 32;
if ( (unsigned __int8)(a1 - 65) > 0x19u && (unsigned __int8)(a1 - 48) > 9u )
{
v1 = 0;
v2 = 36;
while ( v2 != (unsigned __int8)a1 )
{
v2 = byte_31C[(unsigned __int8)++v1];
if ( !byte_31C[(unsigned __int8)v1] )
return 95LL;
}
}
return a1;
}

original_code:
uint8_t fat_sfn_safe_char(uint8_t c)
{
     if (c == ' ' || c =='.') {
          return 0;
     } else if (c >= 'a' && c<= 'z') {
          return c-('a'-'A');
     } else if ((c >= 'A' && c<= 'Z') || (c >= '0' && c<= '9')) {
          return c;
     } else {
          static char *valid = "$%'-_@~'!()";
          for (uint8_t i=0; valid[i]; i++) {
               if (c == valid[i]) {
                    return c;
               }
          }
     }
     return '_';
}

canonical_original_code:
unsigned char fat_sfn_safe_char(unsigned char c)
{
     if (c == ' ' || c =='.') {
          return 0;
     } else if (c >= 'a' && c<= 'z') {
          return c-('a'-'A');
     } else if ((c >= 'A' && c<= 'Z') || (c >= '0' && c<= '9')) {
          return c;
     } else {
          static char *valid = "$%'-_@~'!()";
          for (unsigned char i = 0; valid[i]; i++) {
               if (c == valid[i]) {
                    return c;
               }
          }
     }
     return '_';
}

variable_types:
valid
char *


decompiled_code:
int test_map_keys()
{
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "Aasdf", 1LL) != 1 )
_assert_fail("map_keys(report, \"Aasdf\", 1) == 1", "test_keyboard.c", 0xBu, "test_map_keys");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0xCu, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 4 )
_assert_fail("report[2] == 0x04", "test_keyboard.c", 0xDu, "test_map_keys");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "zasdf", 1LL) != 1 )
_assert_fail("map_keys(report, \"zasdf\", 1) == 1", "test_keyboard.c", 0x10u, "test_map_keys");
putchar(46);
if ( (_BYTE)report )
_assert_fail("report[0] == 0", "test_keyboard.c", 0x11u, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 29 )
_assert_fail("report[2] == 0x1D", "test_keyboard.c", 0x12u, "test_map_keys");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "^asdf", 1LL) != 1 )
_assert_fail("map_keys(report, \"^asdf\", 1) == 1", "test_keyboard.c", 0x15u, "test_map_keys");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0x16u, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 35 )
_assert_fail("report[2] == 0x23", "test_keyboard.c", 0x17u, "test_map_keys");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "%{bad+B+2}", 1LL) != 1 )
_assert_fail("map_keys(report, \"%{bad+B+2}\", 1) == 1", "test_keyboard.c", 0x1Au, "test_map_keys");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0x1Bu, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 34 )
_assert_fail("report[2] == 0x22", "test_keyboard.c", 0x1Cu, "test_map_keys");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "%{LeftGUI+ }rocketnumbernine.com", 1LL) != 12 )
_assert_fail(
"map_keys(report, \"%{LeftGUI+ }rocketnumbernine.com\", 1) == 12",
"test_keyboard.c",
0x1Fu,
"test_map_keys");
putchar(46);
if ( (_BYTE)report != 8 )
_assert_fail("report[0] == (1 << 3)", "test_keyboard.c", 0x20u, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 44 )
_assert_fail("report[2] == 0x2C", "test_keyboard.c", 0x21u, "test_map_keys");
return putchar(46);
}

canonical_decompiled_code:
int func0()
{
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "Aasdf", 1LL) != 1 )
_assert_fail("map_keys(report, \"Aasdf\", 1) == 1", "test_keyboard.c", 0xBu, "test_map_keys");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0xCu, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 4 )
_assert_fail("report[2] == 0x04", "test_keyboard.c", 0xDu, "test_map_keys");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "zasdf", 1LL) != 1 )
_assert_fail("map_keys(report, \"zasdf\", 1) == 1", "test_keyboard.c", 0x10u, "test_map_keys");
putchar(46);
if ( (_BYTE)report )
_assert_fail("report[0] == 0", "test_keyboard.c", 0x11u, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 29 )
_assert_fail("report[2] == 0x1D", "test_keyboard.c", 0x12u, "test_map_keys");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "^asdf", 1LL) != 1 )
_assert_fail("map_keys(report, \"^asdf\", 1) == 1", "test_keyboard.c", 0x15u, "test_map_keys");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0x16u, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 35 )
_assert_fail("report[2] == 0x23", "test_keyboard.c", 0x17u, "test_map_keys");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "%{bad+B+2}", 1LL) != 1 )
_assert_fail("map_keys(report, \"%{bad+B+2}\", 1) == 1", "test_keyboard.c", 0x1Au, "test_map_keys");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0x1Bu, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 34 )
_assert_fail("report[2] == 0x22", "test_keyboard.c", 0x1Cu, "test_map_keys");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_keys(&report, "%{LeftGUI+ }rocketnumbernine.com", 1LL) != 12 )
_assert_fail(
"map_keys(report, \"%{LeftGUI+ }rocketnumbernine.com\", 1) == 12",
"test_keyboard.c",
0x1Fu,
"test_map_keys");
putchar(46);
if ( (_BYTE)report != 8 )
_assert_fail("report[0] == (1 << 3)", "test_keyboard.c", 0x20u, "test_map_keys");
putchar(46);
if ( BYTE2(report) != 44 )
_assert_fail("report[2] == 0x2C", "test_keyboard.c", 0x21u, "test_map_keys");
return putchar(46);
}

original_code:
void test_map_keys()
{
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "Aasdf", 1) == 1) ? (void) (0) : __assert_fail ("map_keys(report, \"Aasdf\", 1) == 1", "test_keyboard.c", 11, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 12, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x04) ? (void) (0) : __assert_fail ("report[2] == 0x04", "test_keyboard.c", 13, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "zasdf", 1) == 1) ? (void) (0) : __assert_fail ("map_keys(report, \"zasdf\", 1) == 1", "test_keyboard.c", 16, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == 0) ? (void) (0) : __assert_fail ("report[0] == 0", "test_keyboard.c", 17, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x1D) ? (void) (0) : __assert_fail ("report[2] == 0x1D", "test_keyboard.c", 18, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "^asdf", 1) == 1) ? (void) (0) : __assert_fail ("map_keys(report, \"^asdf\", 1) == 1", "test_keyboard.c", 21, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 22, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x23) ? (void) (0) : __assert_fail ("report[2] == 0x23", "test_keyboard.c", 23, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "%{bad+B+2}", 1) == 1) ? (void) (0) : __assert_fail ("map_keys(report, \"%{bad+B+2}\", 1) == 1", "test_keyboard.c", 26, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 27, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x22) ? (void) (0) : __assert_fail ("report[2] == 0x22", "test_keyboard.c", 28, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "%{LeftGUI+ }rocketnumbernine.com", 1) == 12) ? (void) (0) : __assert_fail ("map_keys(report, \"%{LeftGUI+ }rocketnumbernine.com\", 1) == 12", "test_keyboard.c", 31, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 3)) ? (void) (0) : __assert_fail ("report[0] == (1 << 3)", "test_keyboard.c", 32, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x2C) ? (void) (0) : __assert_fail ("report[2] == 0x2C", "test_keyboard.c", 33, __extension__ __PRETTY_FUNCTION__)); printf(".");};
}

canonical_original_code:
void test_map_keys()
{
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "Aasdf", 1) == 1) ? (void) (0) : __assert_fail ("map_keys(report, \"Aasdf\", 1) == 1", "test_keyboard.c", 11, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 12, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x04) ? (void) (0) : __assert_fail ("report[2] == 0x04", "test_keyboard.c", 13, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "zasdf", 1) == 1) ? (void) (0) : __assert_fail ("map_keys(report, \"zasdf\", 1) == 1", "test_keyboard.c", 16, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == 0) ? (void) (0) : __assert_fail ("report[0] == 0", "test_keyboard.c", 17, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x1D) ? (void) (0) : __assert_fail ("report[2] == 0x1D", "test_keyboard.c", 18, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "^asdf", 1) == 1) ? (void) (0) : __assert_fail ("map_keys(report, \"^asdf\", 1) == 1", "test_keyboard.c", 21, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 22, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x23) ? (void) (0) : __assert_fail ("report[2] == 0x23", "test_keyboard.c", 23, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "%{bad+B+2}", 1) == 1) ? (void) (0) : __assert_fail ("map_keys(report, \"%{bad+B+2}\", 1) == 1", "test_keyboard.c", 26, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 27, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x22) ? (void) (0) : __assert_fail ("report[2] == 0x22", "test_keyboard.c", 28, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_keys(report, "%{LeftGUI+ }rocketnumbernine.com", 1) == 12) ? (void) (0) : __assert_fail ("map_keys(report, \"%{LeftGUI+ }rocketnumbernine.com\", 1) == 12", "test_keyboard.c", 31, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 3)) ? (void) (0) : __assert_fail ("report[0] == (1 << 3)", "test_keyboard.c", 32, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x2C) ? (void) (0) : __assert_fail ("report[2] == 0x2C", "test_keyboard.c", 33, __extension__ __PRETTY_FUNCTION__)); printf(".");};
}

variable_types: i int


decompiled_code:
int test_map_extension_block()
{
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftControl}") != 14 )
_assert_fail(
"map_extension_block(report, \"%{LeftControl}\") == 14",
"test_keyboard.c",
0x29u,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 1 )
_assert_fail("report[0] == (1 << 0)", "test_keyboard.c", 0x2Au, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{RightGUI}") != 11 )
_assert_fail(
"map_extension_block(report, \"%{RightGUI}\") == 11",
"test_keyboard.c",
0x2Du,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 0x80 )
_assert_fail("report[0] == (1 << 7)", "test_keyboard.c", 0x2Eu, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftGUI+a}") != 12 )
_assert_fail(
"map_extension_block(report, \"%{LeftGUI+a}\") == 12",
"test_keyboard.c",
0x33u,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 8 )
_assert_fail("report[0] == (1 << 3)", "test_keyboard.c", 0x34u, "test_map_extension_block");
putchar(46);
if ( BYTE2(report) != 4 )
_assert_fail("report[2] == 0x04", "test_keyboard.c", 0x35u, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftGUI+B}") != 12 )
_assert_fail(
"map_extension_block(report, \"%{LeftGUI+B}\") == 12",
"test_keyboard.c",
0x39u,
"test_map_extension_block");
putchar(46);
putchar(46);
if ( BYTE2(report) != 5 )
_assert_fail("report[2] == 0x05", "test_keyboard.c", 0x3Bu, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}") != 42 )
_assert_fail(
"map_extension_block(report, \"%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}\") == 42",
"test_keyboard.c",
0x3Fu,
"test_map_extension_block");
putchar(46);
putchar(46);
if ( BYTE2(report) != 5 )
_assert_fail("report[2] == 0x05", "test_keyboard.c", 0x41u, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{.+LeftGUI+B+2}") != 16 )
_assert_fail(
"map_extension_block(report, \"%{.+LeftGUI+B+2}\") == 16",
"test_keyboard.c",
0x45u,
"test_map_extension_block");
putchar(46);
putchar(46);
if ( BYTE2(report) != 55 )
_assert_fail("report[2] == 0x37", "test_keyboard.c", 0x47u, "test_map_extension_block");
putchar(46);
if ( BYTE3(report) != 5 )
_assert_fail("report[3] == 0x05", "test_keyboard.c", 0x48u, "test_map_extension_block");
putchar(46);
if ( BYTE4(report) != 31 )
_assert_fail("report[4] == 0x1F", "test_keyboard.c", 0x49u, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{bad+B+2}") != 1 )
_assert_fail(
"map_extension_block(report, \"%{bad+B+2}\") == 1",
"test_keyboard.c",
0x4Eu,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0x4Fu, "test_map_extension_block");
putchar(46);
if ( BYTE2(report) != 34 )
_assert_fail("report[2] == 0x22", "test_keyboard.c", 0x50u, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftShift+0x31}") != 17 )
_assert_fail(
"map_extension_block(report, \"%{LeftShift+0x31}\") == 17",
"test_keyboard.c",
0x54u,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0x55u, "test_map_extension_block");
putchar(46);
if ( BYTE2(report) != 49 )
_assert_fail("report[2] == 0x31", "test_keyboard.c", 0x56u, "test_map_extension_block");
return putchar(46);
}

canonical_decompiled_code:
int func1()
{
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftControl}") != 14 )
_assert_fail(
"map_extension_block(report, \"%{LeftControl}\") == 14",
"test_keyboard.c",
0x29u,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 1 )
_assert_fail("report[0] == (1 << 0)", "test_keyboard.c", 0x2Au, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{RightGUI}") != 11 )
_assert_fail(
"map_extension_block(report, \"%{RightGUI}\") == 11",
"test_keyboard.c",
0x2Du,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 0x80 )
_assert_fail("report[0] == (1 << 7)", "test_keyboard.c", 0x2Eu, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftGUI+a}") != 12 )
_assert_fail(
"map_extension_block(report, \"%{LeftGUI+a}\") == 12",
"test_keyboard.c",
0x33u,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 8 )
_assert_fail("report[0] == (1 << 3)", "test_keyboard.c", 0x34u, "test_map_extension_block");
putchar(46);
if ( BYTE2(report) != 4 )
_assert_fail("report[2] == 0x04", "test_keyboard.c", 0x35u, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftGUI+B}") != 12 )
_assert_fail(
"map_extension_block(report, \"%{LeftGUI+B}\") == 12",
"test_keyboard.c",
0x39u,
"test_map_extension_block");
putchar(46);
putchar(46);
if ( BYTE2(report) != 5 )
_assert_fail("report[2] == 0x05", "test_keyboard.c", 0x3Bu, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}") != 42 )
_assert_fail(
"map_extension_block(report, \"%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}\") == 42",
"test_keyboard.c",
0x3Fu,
"test_map_extension_block");
putchar(46);
putchar(46);
if ( BYTE2(report) != 5 )
_assert_fail("report[2] == 0x05", "test_keyboard.c", 0x41u, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{.+LeftGUI+B+2}") != 16 )
_assert_fail(
"map_extension_block(report, \"%{.+LeftGUI+B+2}\") == 16",
"test_keyboard.c",
0x45u,
"test_map_extension_block");
putchar(46);
putchar(46);
if ( BYTE2(report) != 55 )
_assert_fail("report[2] == 0x37", "test_keyboard.c", 0x47u, "test_map_extension_block");
putchar(46);
if ( BYTE3(report) != 5 )
_assert_fail("report[3] == 0x05", "test_keyboard.c", 0x48u, "test_map_extension_block");
putchar(46);
if ( BYTE4(report) != 31 )
_assert_fail("report[4] == 0x1F", "test_keyboard.c", 0x49u, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{bad+B+2}") != 1 )
_assert_fail(
"map_extension_block(report, \"%{bad+B+2}\") == 1",
"test_keyboard.c",
0x4Eu,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0x4Fu, "test_map_extension_block");
putchar(46);
if ( BYTE2(report) != 34 )
_assert_fail("report[2] == 0x22", "test_keyboard.c", 0x50u, "test_map_extension_block");
putchar(46);
report = 0LL;
if ( (unsigned __int8)map_extension_block(&report, "%{LeftShift+0x31}") != 17 )
_assert_fail(
"map_extension_block(report, \"%{LeftShift+0x31}\") == 17",
"test_keyboard.c",
0x54u,
"test_map_extension_block");
putchar(46);
if ( (_BYTE)report != 2 )
_assert_fail("report[0] == (1 << 1)", "test_keyboard.c", 0x55u, "test_map_extension_block");
putchar(46);
if ( BYTE2(report) != 49 )
_assert_fail("report[2] == 0x31", "test_keyboard.c", 0x56u, "test_map_extension_block");
return putchar(46);
}

original_code:
void test_map_extension_block()
{
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftControl}") == 14) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftControl}\") == 14", "test_keyboard.c", 41, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 0)) ? (void) (0) : __assert_fail ("report[0] == (1 << 0)", "test_keyboard.c", 42, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{RightGUI}") == 11) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{RightGUI}\") == 11", "test_keyboard.c", 45, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 7)) ? (void) (0) : __assert_fail ("report[0] == (1 << 7)", "test_keyboard.c", 46, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftGUI+a}") == 12) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftGUI+a}\") == 12", "test_keyboard.c", 51, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 3)) ? (void) (0) : __assert_fail ("report[0] == (1 << 3)", "test_keyboard.c", 52, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x04) ? (void) (0) : __assert_fail ("report[2] == 0x04", "test_keyboard.c", 53, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftGUI+B}") == 12) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftGUI+B}\") == 12", "test_keyboard.c", 57, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 3) | (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 3) | (1 << 1)", "test_keyboard.c", 58, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x05) ? (void) (0) : __assert_fail ("report[2] == 0x05", "test_keyboard.c", 59, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}") == 42) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}\") == 42", "test_keyboard.c", 63, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1) | (1 << 0) | (1 << 2) | (1 << 3)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1) | (1 << 0) | (1 << 2) | (1 << 3)", "test_keyboard.c", 64, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x05) ? (void) (0) : __assert_fail ("report[2] == 0x05", "test_keyboard.c", 65, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{.+LeftGUI+B+2}") == 16) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{.+LeftGUI+B+2}\") == 16", "test_keyboard.c", 69, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 3) | (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 3) | (1 << 1)", "test_keyboard.c", 70, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x37) ? (void) (0) : __assert_fail ("report[2] == 0x37", "test_keyboard.c", 71, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[3] == 0x05) ? (void) (0) : __assert_fail ("report[3] == 0x05", "test_keyboard.c", 72, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[4] == 0x1F) ? (void) (0) : __assert_fail ("report[4] == 0x1F", "test_keyboard.c", 73, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{bad+B+2}") == 1) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{bad+B+2}\") == 1", "test_keyboard.c", 78, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 79, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x22) ? (void) (0) : __assert_fail ("report[2] == 0x22", "test_keyboard.c", 80, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i=0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftShift+0x31}") == 17) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftShift+0x31}\") == 17", "test_keyboard.c", 84, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 85, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x31) ? (void) (0) : __assert_fail ("report[2] == 0x31", "test_keyboard.c", 86, __extension__ __PRETTY_FUNCTION__)); printf(".");};
}

canonical_original_code:
void test_map_extension_block()
{
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftControl}") == 14) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftControl}\") == 14", "test_keyboard.c", 41, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 0)) ? (void) (0) : __assert_fail ("report[0] == (1 << 0)", "test_keyboard.c", 42, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{RightGUI}") == 11) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{RightGUI}\") == 11", "test_keyboard.c", 45, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 7)) ? (void) (0) : __assert_fail ("report[0] == (1 << 7)", "test_keyboard.c", 46, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftGUI+a}") == 12) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftGUI+a}\") == 12", "test_keyboard.c", 51, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 3)) ? (void) (0) : __assert_fail ("report[0] == (1 << 3)", "test_keyboard.c", 52, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x04) ? (void) (0) : __assert_fail ("report[2] == 0x04", "test_keyboard.c", 53, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftGUI+B}") == 12) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftGUI+B}\") == 12", "test_keyboard.c", 57, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 3) | (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 3) | (1 << 1)", "test_keyboard.c", 58, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x05) ? (void) (0) : __assert_fail ("report[2] == 0x05", "test_keyboard.c", 59, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}") == 42) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftShift+LeftControl+LeftAlt+LeftGUI+B}\") == 42", "test_keyboard.c", 63, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1) | (1 << 0) | (1 << 2) | (1 << 3)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1) | (1 << 0) | (1 << 2) | (1 << 3)", "test_keyboard.c", 64, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x05) ? (void) (0) : __assert_fail ("report[2] == 0x05", "test_keyboard.c", 65, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{.+LeftGUI+B+2}") == 16) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{.+LeftGUI+B+2}\") == 16", "test_keyboard.c", 69, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 3) | (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 3) | (1 << 1)", "test_keyboard.c", 70, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x37) ? (void) (0) : __assert_fail ("report[2] == 0x37", "test_keyboard.c", 71, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[3] == 0x05) ? (void) (0) : __assert_fail ("report[3] == 0x05", "test_keyboard.c", 72, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[4] == 0x1F) ? (void) (0) : __assert_fail ("report[4] == 0x1F", "test_keyboard.c", 73, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{bad+B+2}") == 1) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{bad+B+2}\") == 1", "test_keyboard.c", 78, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 79, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x22) ? (void) (0) : __assert_fail ("report[2] == 0x22", "test_keyboard.c", 80, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { for (int i = 0; i<8; i++) report[i] = 0;};
 { ((map_extension_block(report, "%{LeftShift+0x31}") == 17) ? (void) (0) : __assert_fail ("map_extension_block(report, \"%{LeftShift+0x31}\") == 17", "test_keyboard.c", 84, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[0] == (1 << 1)) ? (void) (0) : __assert_fail ("report[0] == (1 << 1)", "test_keyboard.c", 85, __extension__ __PRETTY_FUNCTION__)); printf(".");};
 { ((report[2] == 0x31) ? (void) (0) : __assert_fail ("report[2] == 0x31", "test_keyboard.c", 86, __extension__ __PRETTY_FUNCTION__)); printf(".");};
}


decompiled_code:
int test_keyboard()
{
test_map_keys();
return test_map_extension_block();
}

canonical_decompiled_code:
int func2()
{
func0();
return func1();
}

original_code:
void test_keyboard(void)
{
 test_map_keys();
 test_map_extension_block();
}

canonical_original_code:
void test_keyboard()
{
 test_map_keys();
 test_map_extension_block();
}


decompiled_code:
char *__fastcall data_alloc(unsigned __int16 a1)
{
char v1; // al
int v2; // ecx
unsigned __int8 v3; // di
char *result; // rax

v1 = a1;
v2 = a1;
v3 = free_data;
if ( v2 + (unsigned __int8)free_data > 300 )
{
lio_stop("out of memory");
result = 0LL;
}
else
{
free_data += v1;
result = (char *)&data + v3;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(unsigned __int16 a1)
{
char v1; // al
int v2; // ecx
unsigned __int8 v3; // di
char *result; // rax

v1 = a1;
v2 = a1;
v3 = free_data;
if ( v2 + (unsigned __int8)free_data > 300 )
{
lio_stop("out of memory");
result = 0LL;
}
else
{
free_data += v1;
result = (char *)&data + v3;
}
return result;
}

original_code:
void *data_alloc(uint16_t size)
{
    if (free_data+size > 300) {
        lio_stop("out of memory");
        return 0;
    }
    void *allocated = data+free_data;
    free_data += size;
    return allocated;
}

canonical_original_code:
void *data_alloc(unsigned short size)
{
    if (free_data+size > 300) {
        lio_stop("out of memory");
        return 0;
    }
    void *allocated = data+free_data;
    free_data += size;
    return allocated;
}

variable_types:
size
unsigned short

variable_types:
allocated
void *

return_type: void *


decompiled_code:
void __fastcall data_free(char a1)
{
free_data -= a1;
}

canonical_decompiled_code:
void __fastcall func1(char a1)
{
free_data -= a1;
}

original_code:
void data_free(uint16_t size)
{
    free_data -= size;
}

canonical_original_code:
void data_free(unsigned short size)
{
    free_data -= size;
}


decompiled_code:
__int64 __fastcall find_index(__int64 a1, __int64 a2)
{
__int16 v2; // ax
unsigned int v3; // er9
char v4; // dl
char v5; // cl

v2 = 0;
v3 = 0;
v4 = 0;
while ( 1 )
{
v5 = *(_BYTE *)(a2 + v2);
if ( v4 < 0 || *(_BYTE *)(a1 + v4) != v5 )
break;
if ( !v5 )
return v3;
++v4;
LABEL_4:
++v2;
}
if ( v5 )
{
v4 = -1;
goto LABEL_4;
}
++v3;
if ( *(_BYTE *)(a2 + v2 + 1) )
{
v4 = 0;
goto LABEL_4;
}
return (unsigned int)-1;
}

original_code:
int16_t find_index(const char *name, const char map[])
{
    int16_t len = strlen(name);
    int8_t j=0;
    int16_t index = 0;
    for (int16_t i=0; ; i++) {
        char c = *(map+i);
        if (j >= 0 && c==name[j]) {
            if (c==0) {
                return index;
            }
            j++;
        } else if (c==0) {
            index++;
            if (*(map+i+1) == 0) {
                return -1;
            }
            j=0;
        } else {
            j = -1;
        }
    }
    return -1;
}

canonical_original_code:
short find_index(char *name, char map[])
{
    short len = strlen(name);
    char j = 0;
    short index = 0;
    for (short i = 0; ; i++) {
        char c = *(map+i);
        if (j >= 0 && c==name[j]) {
            if (c==0) {
                return index;
            }
            j++;
        } else if (c==0) {
            index++;
            if (*(map+i+1) == 0) {
                return -1;
            }
            j=0;
        } else {
            j = -1;
        }
    }
    return -1;
}

variable_types:
name
char *

variable_types:
map
char []

variable_types: len short

variable_types: j char

variable_types: index short

variable_types: i short

variable_types: c char

return_type: short


decompiled_code:
bool __fastcall parse_number(__int64 a1, __int64 a2)
{
return (unsigned int)_isoc99_sscanf(a1, "%i", a2) == 1;
}

canonical_decompiled_code:
bool __fastcall func3(__int64 a1, __int64 a2)
{
return (unsigned int)_isoc99_sscanf(a1, "%i", a2) == 1;
}

original_code:
_Bool parse_number(const uint8_t *buf, uint16_t *value)
{
    return (sscanf(buf,"%i",value) == 1);
}

canonical_original_code:
_Bool parse_number(unsigned char *buf, unsigned short *value)
{
    return (sscanf(buf,"%i",value) == 1);
}

variable_types:
buf
unsigned char *

variable_types:
value
unsigned short *


decompiled_code:
int __fastcall print_number(char *a1, unsigned __int16 a2)
{
return sprintf(a1, "%d", a2);
}

canonical_decompiled_code:
int __fastcall func4(char *a1, unsigned __int16 a2)
{
return sprintf(a1, "%d", a2);
}

original_code:
uint16_t print_number(uint8_t *buf, const uint16_t value)
{
    return sprintf(buf,"%d",value);
}

canonical_original_code:
unsigned short print_number(unsigned char *buf, unsigned short value)
{
    return sprintf(buf,"%d",value);
}

variable_types:
value
unsigned short


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

result = a1;
do
{
if ( !(_WORD)result )
break;
result = (unsigned int)(result - 1);
}
while ( timeSinceStart < (unsigned int)(unsigned __int16)a1 + timeSinceStart );
return result;
}

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

result = a1;
do
{
if ( !(_WORD)result )
break;
result = (unsigned int)(result - 1);
}
while ( timeSinceStart < (unsigned int)(unsigned __int16)a1 + timeSinceStart );
return result;
}

original_code:
void delay_ms(uint16_t duration)
{
     uint32_t end = _timeSinceStart+duration;
     while(duration-- > 0 && _timeSinceStart < end) {
          ;
     }
}

canonical_original_code:
void delay_ms(unsigned short duration)
{
     unsigned int end = _timeSinceStart+duration;
     while(duration-- > 0 && _timeSinceStart < end) {
          ;
     }
}

variable_types:
duration
unsigned short

variable_types:
end
unsigned int


original_code:
uint8_t map_extension_block(uint8_t* report, uint8_t *input)
{
     int consumed = 2;
     while ((input[consumed] != 0) && (input[consumed] != '}')) {
          uint8_t found = 0;
          for (int modifier=0; !found && modifier<8; modifier++) {
               char *m = (char *)*(&(modifiers[modifier]));
               uint8_t l = strlen(m);
               if (strncmp(input+consumed,m,l) == 0) {
                    report[0] |= (1<<modifier);
                    found = 1;
                    consumed += l;
                    break;
               }
          }
          if (!found && input[consumed] == '0' && input[consumed+1] == 'x') {
               uint16_t hex = 0;
               found = parse_number(&input[consumed], &hex);
               if (found) {
                    consumed += 4;
                    { for (int k=0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = hex; break; }}};
               }
          }
          if ((!found && input[consumed+1] == '+') || input[consumed+1] == '}') {
               found = map_keys(report, input+consumed, 0);
               consumed += found;
          }
          if (!found) {
               return map_keys(report, input, 0);
          }
          if (input[consumed] == '+') {
               consumed++;
               continue;
          }
     }
     return consumed+1;
}

canonical_original_code:
unsigned char map_extension_block(unsigned char *report, unsigned char *input)
{
     int consumed = 2;
     while ((input[consumed] != 0) && (input[consumed] != '}')) {
          unsigned char found = 0;
          for (int modifier = 0; !found && modifier<8; modifier++) {
               char *m = (char *)*(&(modifiers[modifier]));
               unsigned char l = strlen(m);
               if (strncmp(input+consumed,m,l) == 0) {
                    report[0] |= (1<<modifier);
                    found = 1;
                    consumed += l;
                    break;
               }
          }
          if (!found && input[consumed] == '0' && input[consumed+1] == 'x') {
               unsigned short hex = 0;
               found = parse_number(&input[consumed], &hex);
               if (found) {
                    consumed += 4;
                    { for (int k = 0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = hex; break; }}};
               }
          }
          if ((!found && input[consumed+1] == '+') || input[consumed+1] == '}') {
               found = map_keys(report, input+consumed, 0);
               consumed += found;
          }
          if (!found) {
               return map_keys(report, input, 0);
          }
          if (input[consumed] == '+') {
               consumed++;
               continue;
          }
     }
     return consumed+1;
}

variable_types:
report
unsigned char *

variable_types:
input
unsigned char *

variable_types: consumed int

variable_types:
found
unsigned char

variable_types: modifier int

variable_types:
m
char *

variable_types:
l
unsigned char

variable_types:
hex
unsigned short

variable_types: k int


decompiled_code:
__int64 __fastcall map_keys(_BYTE *a1, unsigned __int8 *a2, char a3)
{
int v3; // eax
unsigned int v4; // er8
_BYTE *v5; // rax
_BYTE *v6; // rdi
unsigned __int8 v8; // al
__int64 v9; // rdx
_BYTE *v10; // rdx
_BYTE *v11; // rdx
_BYTE *v12; // rdi
_BYTE *v13; // rax
_BYTE *v14; // rdi

v3 = *a2;
if ( (v3 & 0x80u) != 0 )
return 1LL;
if ( (_BYTE)v3 != 37 )
{
if ( (_BYTE)v3 == 92 )
{
v8 = a2[1];
if ( v8 == 110 )
{
v9 = 0LL;
}
else if ( v8 == 116 )
{
v9 = 1LL;
}
else
{
v4 = 1;
v9 = 2LL;
if ( v8 != 98 )
return v4;
}
v13 = a1 + 2;
v14 = a1 + 8;
while ( *v13 )
{
if ( ++v13 == v14 )
return 2;
}
v4 = 2;
*v13 = escaped_values[v9];
return v4;
}
if ( (unsigned __int8)v3 <= 0x1Fu )
{
v4 = 1;
if ( (_BYTE)v3 == 9 )
{
v5 = a1 + 2;
v6 = a1 + 8;
while ( *v5 )
{
if ( ++v5 == v6 )
goto LABEL_9;
}
*v5 = 43;
v4 = 1;
}
return v4;
}
if ( (unsigned __int8)v3 > 0x40u )
{
if ( (unsigned __int8)v3 > 0x5Au )
{
if ( (unsigned __int8)v3 <= 0x60u )
{
map_ascii_key(a1, ascii_from91[v3 - 91]);
}
else if ( (unsigned __int8)v3 > 0x7Au )
{
map_ascii_key(a1, ascii_from123[v3 - 123]);
LABEL_9:
v4 = 1;
}
else
{
v11 = a1 + 2;
v12 = a1 + 8;
while ( *v11 )
{
if ( v12 == ++v11 )
goto LABEL_9;
}
v4 = 1;
*v11 = v3 - 93;
}
}
else
{
v10 = a1 + 2;
while ( *v10 )
{
if ( a1 + 8 == ++v10 )
goto LABEL_23;
}
*v10 = v3 - 61;
LABEL_23:
*a1 |= 2u;
v4 = 1;
}
return v4;
}
LABEL_12:
map_ascii_key(a1, ascii_from32[v3 - 32]);
return v4;
}
if ( a2[1] != 123 || !a3 )
goto LABEL_12;
return map_extension_block(a1, (__int64)a2);
}

original_code:
uint8_t map_keys(uint8_t* report, uint8_t *input, uint8_t extensions)
{
     uint8_t current_key = *input;
     uint8_t charsRead = 1;
     if (current_key < 128) {
          if ((input[0] == '%') && (input[1] == '{') && extensions) {
               return map_extension_block(report, input);
          }
          if (current_key == '\\') {
              for (uint16_t i=0; i<3; i++) {
                  if (input[1] == escaped_chars[i]) {
                      { for (int k=0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = *(&escaped_values[i]); break; }}};
                      charsRead++;
                      break;
                  }
              }
          } else if (current_key > 31) {
               if (current_key < 65) {
                    map_ascii_key(report, *(&ascii_from32[current_key-32]));
               } else if (current_key < 91) {
                    { for (int k=0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = current_key-(65-4); break; }}};
                    report[0] |= (1 << 1);
               } else if (current_key < 97) {
                    map_ascii_key(report, *(&ascii_from91[current_key-91]));
               } else if (current_key<123) {
                    { for (int k=0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = current_key-(97-4); break; }}};
               } else {
                    map_ascii_key(report, *(&ascii_from123[current_key-123]));
               }
          } else {
              if (current_key == '\t') {
                  { for (int k=0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = 0x2B; break; }}};
               }
          }
     }
     return charsRead;
}

canonical_original_code:
unsigned char map_keys(unsigned char *report, unsigned char *input, unsigned char extensions)
{
     unsigned char current_key = *input;
     unsigned char charsRead = 1;
     if (current_key < 128) {
          if ((input[0] == '%') && (input[1] == '{') && extensions) {
               return map_extension_block(report, input);
          }
          if (current_key == '\\') {
              for (unsigned short i = 0; i<3; i++) {
                  if (input[1] == escaped_chars[i]) {
                      { for (int k = 0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = *(&escaped_values[i]); break; }}};
                      charsRead++;
                      break;
                  }
              }
          } else if (current_key > 31) {
               if (current_key < 65) {
                    map_ascii_key(report, *(&ascii_from32[current_key-32]));
               } else if (current_key < 91) {
                    { for (int k = 0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = current_key-(65-4); break; }}};
                    report[0] |= (1 << 1);
               } else if (current_key < 97) {
                    map_ascii_key(report, *(&ascii_from91[current_key-91]));
               } else if (current_key<123) {
                    { for (int k = 0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = current_key-(97-4); break; }}};
               } else {
                    map_ascii_key(report, *(&ascii_from123[current_key-123]));
               }
          } else {
              if (current_key == '\t') {
                  { for (int k = 0; k<6; k++) { if (report[2+k] == 0) {report[2+k] = 0x2B; break; }}};
               }
          }
     }
     return charsRead;
}

variable_types:
extensions
unsigned char

variable_types:
charsRead
unsigned char

variable_types:
i
unsigned short


findIndex

repo: philcowans/speedy-goat

decompiled_code:
size_t __fastcall findIndex(char *s, __int64 a2)
{
unsigned __int64 i; // rbp
_BYTE *v3; // rax
size_t result; // rax
int v5; // eax

for ( i = 0LL; ; ++i )
{
result = strlen(s);
if ( result <= i )
break;
v5 = (unsigned __int8)s[i];
if ( (unsigned __int8)(v5 - 97) <= 0x19u )
{
v3 = (_BYTE *)(a2 + v5 - 97);
if ( *v3 == 0xFF )
fprintf(stderr, "Invalid entry %s: too many repeated characters\n", s);
else
*v3 = 2 * *v3 + 1;
}
else
{
fprintf(stderr, "Invlid entry %s: contains characters other than lower case a-z\n", s);
}
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func3(char *s, __int64 a2)
{
unsigned __int64 i; // rbp
_BYTE *v3; // rax
size_t result; // rax
int v5; // eax

for ( i = 0LL; ; ++i )
{
result = strlen(s);
if ( result <= i )
break;
v5 = (unsigned __int8)s[i];
if ( (unsigned __int8)(v5 - 97) <= 0x19u )
{
v3 = (_BYTE *)(a2 + v5 - 97);
if ( *v3 == 0xFF )
fprintf(stderr, "Invalid entry %s: too many repeated characters\n", s);
else
*v3 = 2 * *v3 + 1;
}
else
{
fprintf(stderr, "Invlid entry %s: contains characters other than lower case a-z\n", s);
}
}
return result;
}

original_code:
void findIndex(const unsigned char *word, unsigned char *indexEntry) {
  for(int i = 0; i < strlen(word); ++i) {
    unsigned char c = word[i];
    if((c >= 'a') && (c <= 'z')) {
      int offset = c - 'a';
      if(indexEntry[offset] < 255) {
 indexEntry[offset] <<= 1;
 indexEntry[offset] += 1;
      }
      else {
 fprintf(stderr, "Invalid entry %s: too many repeated characters\n", word);
      }
    }
    else {
      fprintf(stderr, "Invlid entry %s: contains characters other than lower case a-z\n", word);
    }
  }
}

canonical_original_code:
void findIndex(unsigned char *word, unsigned char *indexEntry) {
  for(int i = 0; i < strlen(word); ++i) {
    unsigned char c = word[i];
    if((c >= 'a') && (c <= 'z')) {
      int offset = c - 'a';
      if(indexEntry[offset] < 255) {
 indexEntry[offset] <<= 1;
 indexEntry[offset] += 1;
      }
      else {
 fprintf(stderr, "Invalid entry %s: too many repeated characters\n", word);
      }
    }
    else {
      fprintf(stderr, "Invlid entry %s: contains characters other than lower case a-z\n", word);
    }
  }
}

variable_types:
word
unsigned char *

variable_types:
indexEntry
unsigned char *

variable_types: i int

variable_types:
c
unsigned char

variable_types: offset int


check

original_code:
int check(const unsigned char *wordPattern, const unsigned char *boardPattern) {
  for(int i = 0; i < 26; ++i) {
    if((wordPattern[i] & boardPattern[i]) != wordPattern[i]) {
      return 0;
    }
  }
  return 1;
}

canonical_original_code:
int check(unsigned char *wordPattern, unsigned char *boardPattern) {
  for(int i = 0; i < 26; ++i) {
    if((wordPattern[i] & boardPattern[i]) != wordPattern[i]) {
      return 0;
    }
  }
  return 1;
}

variable_types:
wordPattern
unsigned char *

variable_types:
boardPattern
unsigned char *


score

decompiled_code:
__int64 __fastcall score(__int64 a1, __int64 a2)
{
__int64 i; // rsi
char v5; // cl
__int64 v6; // r9
char v7; // cl
int v8; // eax
int v9; // er8
unsigned int v10; // er8

for ( i = 0LL; i != 26; ++i )
{
countBits(*(_BYTE *)(a1 + i) & *(_BYTE *)(a2 + i));
v7 = *(_BYTE *)(v6 + i) & v5;
v8 = countBits(v7);
v10 = v8 + v9;
}
return v10;
}

original_code:
int score(const unsigned char *wordPattern, const unsigned char *onePointPattern, const unsigned char *twoPointPattern) {
  int s = 0;
  for(int i = 0; i < 26; ++i) {
    s += countBits(wordPattern[i] & onePointPattern[i]);
    s += countBits(wordPattern[i] & twoPointPattern[i]);
  }
  return s;
}

canonical_original_code:
int score(unsigned char *wordPattern, unsigned char *onePointPattern, unsigned char *twoPointPattern) {
  int s = 0;
  for(int i = 0; i < 26; ++i) {
    s += countBits(wordPattern[i] & onePointPattern[i]);
    s += countBits(wordPattern[i] & twoPointPattern[i]);
  }
  return s;
}

variable_types:
onePointPattern
unsigned char *

variable_types:
twoPointPattern
unsigned char *

variable_types: s int


entrenched

original_code:
int entrenched(const int i, const unsigned char *ownerships) {
  int row = i / 5;
  int col = i % 5;
  if((row > 0) && (ownerships[i - 5] != ownerships[i])) {
    return 0;
  }
  if((row < 4) && (ownerships[i + 5] != ownerships[i])) {
    return 0;
  }
  if((col > 0) && (ownerships[i - 1] != ownerships[i])) {
    return 0;
  }
  if((col < 4) && (ownerships[i + 1] != ownerships[i])) {
    return 0;
  }
  return 1;
}

canonical_original_code:
int entrenched(int i, unsigned char *ownerships) {
  int row = i / 5;
  int col = i % 5;
  if((row > 0) && (ownerships[i - 5] != ownerships[i])) {
    return 0;
  }
  if((row < 4) && (ownerships[i + 5] != ownerships[i])) {
    return 0;
  }
  if((col > 0) && (ownerships[i - 1] != ownerships[i])) {
    return 0;
  }
  if((col < 4) && (ownerships[i + 1] != ownerships[i])) {
    return 0;
  }
  return 1;
}

variable_types:
ownerships
unsigned char *

variable_types: row int

variable_types: col int


pickMove

original_code:
int pickMove(const unsigned char *index, const int dictionarySize, const unsigned char *board, const unsigned char *onePoint, const unsigned char *twoPoint, int *played) {
  unsigned char *boardPattern = calloc(26, 1);
  findIndex(board, boardPattern);
  unsigned char *onePointPattern = calloc(26, 1);
  findIndex(onePoint, onePointPattern);
  unsigned char *twoPointPattern = calloc(26, 1);
  findIndex(twoPoint, twoPointPattern);
  int maxScore = -1;
  int maxIndex = -1;
  for(int i = 0; i < dictionarySize; ++i) {
    if(!played[i] && check(index + 26 * i, boardPattern)) {
      int s = score(index + 26 * i, onePointPattern, twoPointPattern);
      if(s > maxScore) {
 maxScore = s;
 maxIndex = i;
      }
    }
  }
  free(boardPattern);
  free(onePointPattern);
  free(twoPointPattern);
  return maxIndex;
}

canonical_original_code:
int pickMove(unsigned char *index, int dictionarySize, unsigned char *board, unsigned char *onePoint, unsigned char *twoPoint, int *played) {
  unsigned char *boardPattern = calloc(26, 1);
  findIndex(board, boardPattern);
  unsigned char *onePointPattern = calloc(26, 1);
  findIndex(onePoint, onePointPattern);
  unsigned char *twoPointPattern = calloc(26, 1);
  findIndex(twoPoint, twoPointPattern);
  int maxScore = -1;
  int maxIndex = -1;
  for(int i = 0; i < dictionarySize; ++i) {
    if(!played[i] && check(index + 26 * i, boardPattern)) {
      int s = score(index + 26 * i, onePointPattern, twoPointPattern);
      if(s > maxScore) {
 maxScore = s;
 maxIndex = i;
      }
    }
  }
  free(boardPattern);
  free(onePointPattern);
  free(twoPointPattern);
  return maxIndex;
}

variable_types:
index
unsigned char *

variable_types: dictionarySize int

variable_types:
board
unsigned char *

variable_types:
onePoint
unsigned char *

variable_types:
twoPoint
unsigned char *

variable_types:
played
int *

variable_types: maxScore int

variable_types: maxIndex int


strhextonum

decompiled_code:
__int64 __fastcall strhextonum(char *nptr, __int64 a2, __int64 a3, _QWORD *a4)
{
int *v6; // rax
int v7; // er15
int *v8; // rbx
int v9; // edx
__int64 v10; // rax
__int64 v11; // r8
char *endptr[16]; // [rsp+8h] [rbp-80h] BYREF

endptr[3] = "invalid";
endptr[5] = "too small";
endptr[7] = "too large";
v6 = _errno_location();
v7 = *v6;
v8 = v6;
*v6 = 0;
if ( a2 > a3 || (v11 = strtoll(nptr, endptr, 16), endptr[0] == nptr) || *endptr[0] )
{
v9 = 22;
v10 = 1LL;
goto LABEL_3;
}
if ( v11 == 0x8000000000000000LL )
{
v9 = *v8;
if ( *v8 == 34 )
{
LABEL_19:
v10 = 2LL;
goto LABEL_3;
}
if ( a2 == 0x8000000000000000LL )
goto LABEL_12;
LABEL_18:
v9 = 34;
goto LABEL_19;
}
if ( a2 > v11 )
goto LABEL_18;
if ( v11 == 0x7FFFFFFFFFFFFFFFLL )
{
v9 = *v8;
if ( *v8 == 34 )
{
v10 = 3LL;
LABEL_3:
if ( a4 )
{
v11 = 0LL;
*a4 = endptr[2 * v10 + 1];
*v8 = v9;
}
else
{
*v8 = v9;
v11 = 0LL;
}
return v11;
}
}
v9 = 34;
v10 = 3LL;
if ( a3 < v11 )
goto LABEL_3;
LABEL_12:
if ( a4 )
*a4 = 0LL;
*v8 = v7;
return v11;
}

original_code:
long long
strhextonum(const char *numstr, long long minval, long long maxval,
    const char **errstrp)
{
 long long ll = 0;
 char *ep;
 int error = 0;
 struct errval {
  const char *errstr;
  int err;
 } ev[4] = {
  { ((void *)0), 0 },
  { "invalid", 22 },
  { "too small", 34 },
  { "too large", 34 },
 };
 ev[0].err = (*__errno_location ());
 (*__errno_location ()) = 0;
 if (minval > maxval)
  error = 1;
 else {
  ll = strtoll(numstr, &ep, 16);
  if (numstr == ep || *ep != '\0')
   error = 1;
  else if ((ll == (-0x7fffffffffffffffLL - 1LL) && (*__errno_location ()) == 34) || ll < minval)
   error = 2;
  else if ((ll == 0x7fffffffffffffffLL && (*__errno_location ()) == 34) || ll > maxval)
   error = 3;
 }
 if (errstrp != ((void *)0))
  *errstrp = ev[error].errstr;
 (*__errno_location ()) = ev[error].err;
 if (error)
  ll = 0;
 return (ll);
}

canonical_original_code:
long long strhextonum(char *numstr, long long minval, long long maxval, char **errstrp)
{
 long long ll = 0;
 char *ep;
 int error = 0;
 struct errval ev[4] = {
  { ((void *)0), 0 },
  { "invalid", 22 },
  { "too small", 34 },
  { "too large", 34 },
 };
 ev[0].err = (*__errno_location ());
 (*__errno_location ()) = 0;
 if (minval > maxval)
  error = 1;
 else {
  ll = strtoll(numstr, &ep, 16);
  if (numstr == ep || *ep != '\0')
   error = 1;
  else if ((ll == (-0x7fffffffffffffffLL - 1LL) && (*__errno_location ()) == 34) || ll < minval)
   error = 2;
  else if ((ll == 0x7fffffffffffffffLL && (*__errno_location ()) == 34) || ll > maxval)
   error = 3;
 }
 if (errstrp != ((void *)0))
  *errstrp = ev[error].errstr;
 (*__errno_location ()) = ev[error].err;
 if (error)
  ll = 0;
 return (ll);
}

variable_types:
numstr
char *

variable_types:
minval
long long

variable_types:
maxval
long long

variable_types:
errstrp
char **

variable_types:
ll
long long

variable_types:
ep
char *

variable_types: error int

variable_types: struct errval { char *errstr; int err; } [4]

return_type: long long


dispatch

repo: philipaconrad/mini-vm

decompiled_code:
__int64 __fastcall dispatch(__int64 a1, unsigned __int8 a2)
{
return (*(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 8LL * a2))();
}

original_code:
void dispatch(struct VMContext* ctx, const uint32_t instr) {
    const uint8_t i = (instr & 0xFF);
    (*ctx->funtable[i])(ctx, instr);
}

canonical_original_code:
void dispatch(struct VMContext *ctx, unsigned int instr) {
    unsigned char i = (instr & 0xFF);
    (*ctx->funtable[i])(ctx, instr);
}

variable_types: struct VMContext { unsigned int numRegs; unsigned int numFuns; struct Reg { unsigned int type; unsigned int value; } *r; void (**funtable)(struct VMContext *ctx, unsigned int); } *

variable_types:
instr
unsigned int

variable_types:
i
unsigned char

user_defined_types: struct VMContext { unsigned int numRegs; unsigned int numFuns; struct Reg *r; void (**funtable)(struct VMContext *ctx, unsigned int); }


initVMContext

original_code:
void initVMContext(struct VMContext* ctx, const uint32_t numRegs, const uint32_t numFuns, Reg* registers, FunPtr* funtable) {
    ctx->numRegs = numRegs;
    ctx->numFuns = numFuns;
    ctx->r = registers;
    ctx->funtable = funtable;
}

canonical_original_code:
void initVMContext(struct VMContext *ctx, unsigned int numRegs, unsigned int numFuns, struct Reg *registers, void (**funtable)(struct VMContext *ctx, unsigned int)) {
    ctx->numRegs = numRegs;
    ctx->numFuns = numFuns;
    ctx->r = registers;
    ctx->funtable = funtable;
}

variable_types:
numRegs
unsigned int

variable_types:
numFuns
unsigned int

variable_types:
registers
struct Reg *

variable_types: void (**)(struct VMContext *ctx, unsigned int)

user_defined_types: struct Reg { unsigned int type; unsigned int value; }


stepVMContext

decompiled_code:
__int64 __fastcall stepVMContext(__int64 a1, _DWORD **a2)
{
__int64 result; // rax

result = dispatch(a1, **a2);
++*a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, _DWORD **a2)
{
__int64 result; // rax

result = func12(a1, **a2);
++*a2;
return result;
}

original_code:
void stepVMContext(struct VMContext* ctx, uint32_t** pc) {
    uint32_t instr = **pc;
    dispatch(ctx, instr);
    (*pc)++;
}

canonical_original_code:
void stepVMContext(struct VMContext *ctx, unsigned int **pc) {
    unsigned int instr = **pc;
    dispatch(ctx, instr);
    (*pc)++;
}

variable_types:
pc
unsigned int **


canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, _DWORD **a2)
{
__int64 result; // rax

result = func16(a1, **a2);
++*a2;
return result;
}


main

repo: philipaconrad/theta

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

__gmpf_set_default_prec();
initArray(&state, &in_systemVars, 39LL);
initArray(&minBounds, &in_minBounds, 39LL);
initArray(&maxBounds, &in_maxBounds, 39LL);
initNLSystemContext(v4, &state, &minBounds, &maxBounds, 39LL);
Jianmin();
if ( !(unsigned int)checkBounds(v4, 39LL) )
puts("\nThe system strayed outside of its constraints! Please check your math.");
clearArray(&state, 39LL);
clearArray(&minBounds, 39LL);
clearArray(&maxBounds, 39LL);
return 0;
}

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

__gmpf_set_default_prec();
func7(&state, &in_systemVars, 39LL);
func7(&minBounds, &in_minBounds, 39LL);
func7(&maxBounds, &in_maxBounds, 39LL);
func8(v4, &state, &minBounds, &maxBounds, 39LL);
func11();
if ( !(unsigned int)func9(v4, 39LL) )
puts("\nThe system strayed outside of its constraints! Please check your math.");
func10(&state, 39LL);
func10(&minBounds, 39LL);
func10(&maxBounds, 39LL);
return 0;
}

original_code:
int main(int argc, char** argv[]) {
    NLSystemContext ctx;
    bool inBounds;
    uint32 i;
    __gmpf_set_default_prec(256);
    initArray(state, in_systemVars, 39);
    initArray(minBounds, in_minBounds, 39);
    initArray(maxBounds, in_maxBounds, 39);
    initNLSystemContext(&ctx, state, minBounds, maxBounds, 39);
    Jianmin(&ctx);
    inBounds = checkBounds(&ctx, 39);
    if(inBounds == 0) {
        printf("\nThe system strayed outside of its constraints! Please check your math.\n");
    }
    clearArray(state, 39);
    clearArray(minBounds, 39);
    clearArray(maxBounds, 39);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv[]) {
    struct NLSystemContext ctx;
    int inBounds;
    unsigned int i;
    __gmpf_set_default_prec(256);
    initArray(state, in_systemVars, 39);
    initArray(minBounds, in_minBounds, 39);
    initArray(maxBounds, in_maxBounds, 39);
    initNLSystemContext(&ctx, state, minBounds, maxBounds, 39);
    Jianmin(&ctx);
    inBounds = checkBounds(&ctx, 39);
    if(inBounds == 0) {
        printf("\nThe system strayed outside of its constraints! Please check your math.\n");
    }
    clearArray(state, 39);
    clearArray(minBounds, 39);
    clearArray(maxBounds, 39);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **[]

variable_types: struct NLSystemContext { struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } (*state)[1]; struct __mpf_struct (*minBounds)[1]; struct __mpf_struct (*maxBounds)[1]; unsigned int listSize; }

variable_types: inBounds int

variable_types:
i
unsigned int

user_defined_types: struct NLSystemContext { struct __mpf_struct (*state)[1]; struct __mpf_struct (*minBounds)[1]; struct __mpf_struct (*maxBounds)[1]; unsigned int listSize; }


initArray

decompiled_code:
__int64 __fastcall initArray(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // r12
__int64 v5; // rbx
__int64 result; // rax

if ( a3 )
{
v3 = a2 + 8LL * (unsigned int)(a3 - 1) + 8;
v5 = a2;
do
{
v5 += 8LL;
a1 += 24LL;
result = __gmpf_init_set_d();
}
while ( v5 != v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // r12
__int64 v5; // rbx
__int64 result; // rax

if ( a3 )
{
v3 = a2 + 8LL * (unsigned int)(a3 - 1) + 8;
v5 = a2;
do
{
v5 += 8LL;
a1 += 24LL;
result = __gmpf_init_set_d();
}
while ( v5 != v3 );
}
return result;
}

original_code:
void initArray(bigFloat* dest, double* inputs, uint32 numVars) {
    uint32 i;
    for(i = 0; i < numVars; i++) {
        __gmpf_init_set_d(dest[i], inputs[i]);
    }
}

canonical_original_code:
void initArray(struct __mpf_struct (*dest)[1], double *inputs, unsigned int numVars) {
    unsigned int i;
    for(i = 0; i < numVars; i++) {
        __gmpf_init_set_d(dest[i], inputs[i]);
    }
}

variable_types: struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } (*)[1]

variable_types:
inputs
double *

variable_types:
numVars
unsigned int


initNLSystemContext

original_code:
void initNLSystemContext(NLSystemContext* ctx, bigFloat* initialState, bigFloat* minBounds, bigFloat* maxBounds, uint32 listSize) {
    ctx->state = initialState;
    ctx->minBounds = minBounds;
    ctx->maxBounds = maxBounds;
    ctx->listSize = listSize;
}

canonical_original_code:
void initNLSystemContext(struct NLSystemContext *ctx, struct __mpf_struct (*initialState)[1], struct __mpf_struct (*minBounds)[1], struct __mpf_struct (*maxBounds)[1], unsigned int listSize) {
    ctx->state = initialState;
    ctx->minBounds = minBounds;
    ctx->maxBounds = maxBounds;
    ctx->listSize = listSize;
}

variable_types: struct NLSystemContext { struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } (*state)[1]; struct __mpf_struct (*minBounds)[1]; struct __mpf_struct (*maxBounds)[1]; unsigned int listSize; } *

variable_types:
initialState
struct __mpf_struct (*)[1]

variable_types:
minBounds
struct __mpf_struct (*)[1]

variable_types:
maxBounds
struct __mpf_struct (*)[1]

variable_types:
listSize
unsigned int