original_code:
sexpr path_normalise (sexpr path)
{
    sexpr rv = ((sexpr)((((int_pointer)(1)) << 3) | 0x5));
    if ((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)path))->type == sxt_cons)))
    {
        rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5));
        while ((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)path))->type == sxt_cons)))
        {
            rv = sx_set_add (rv, path_normalise (((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)path))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)path))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)))));
            path = ((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)path))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)path))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
    }
    else if ((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)path))->type == sxt_string)))
    {
        int l = 0, i = 0, levels = 0;
        const char *s = (const char *)((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)path))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)path))->character_data) : "#nonexistent");
        char *f;
        char is_start = (char)1;
        while (s[l] != (char)0)
        {
            l++;
        }
        l++;
        f = (char *)aalloc (l);
        l = 0;
        while (s[l] != (char)0)
        {
            switch (s[l])
            {
                case '/':
                    is_start = (char)1;
                    levels++;
                    f[i] = '/';
                    i++;
                    break;
                case '.':
                    if (is_start == (char)1)
                    {
                        if (s[(l+1)] == '/')
                        {
                            while (s[(l+1)] == '/')
                            {
                                l++;
                            }
                            break;
                        }
                    }
                default:
                    f[i] = s[l];
                    i++;
                    is_start = (char)0;
                    break;
            }
            l++;
        }
        f[i] = (char)0;
        rv = make_string_l (f, i);
        afree (l, (void *)f);
    }
    return rv;
}

canonical_original_code:
unsigned long path_normalise(unsigned long path)
{
    unsigned long rv = ((sexpr)((((int_pointer)(1)) << 3) | 0x5));
    if ((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)path))->type == sxt_cons)))
    {
        rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5));
        while ((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)path))->type == sxt_cons)))
        {
            rv = sx_set_add (rv, path_normalise (((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)path))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)path))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)))));
            path = ((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)path))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)path))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
    }
    else if ((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)path))->type == sxt_string)))
    {
        int l = 0; int i = 0; int levels = 0;
        char *s = (const char *)((((((int_pointer)(path)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)path))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)path))->character_data) : "#nonexistent");
        char *f;
        char is_start = (char)1;
        while (s[l] != (char)0)
        {
            l++;
        }
        l++;
        f = (char *)aalloc (l);
        l = 0;
        while (s[l] != (char)0)
        {
            switch (s[l])
            {
                case '/':
                    is_start = (char)1;
                    levels++;
                    f[i] = '/';
                    i++;
                    break;
                case '.':
                    if (is_start == (char)1)
                    {
                        if (s[(l+1)] == '/')
                        {
                            while (s[(l+1)] == '/')
                            {
                                l++;
                            }
                            break;
                        }
                    }
                default:
                    f[i] = s[l];
                    i++;
                    is_start = (char)0;
                    break;
            }
            l++;
        }
        f[i] = (char)0;
        rv = make_string_l (f, i);
        afree (l, (void *)f);
    }
    return rv;
}

variable_types:
path
unsigned long

variable_types:
rv
unsigned long

variable_types: l int

variable_types: i int

variable_types: levels int

variable_types:
s
char *

variable_types:
f
char *

user_defined_types: struct sexpr_cons { enum sx_type type; unsigned long car; unsigned long cdr; }

user_defined_types: enum sx_type { sxt_string=4, sxt_symbol=5, sxt_cons=6, sxt_rational=20 }


repo: kyuba/curie

original_code:
sexpr path_prefix (sexpr list)
{
    sexpr l = list, n = ((((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)l))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    const char *s;
    char buf[0x1000];
    int i = 0, li;
    for (s = (const char *)((((((int_pointer)(n)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)n))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)n))->character_data) : "#nonexistent"); (s[i] != (char)0) && (i < 0xfff); i++)
    {
        buf[i] = s[i];
    }
    buf[i] = (char)0;
    for (l = ((((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)l))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))); (((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)); l = ((((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)l))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))))
    {
        n = ((((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)l))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        s = (const char *)((((((int_pointer)(n)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)n))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)n))->character_data) : "#nonexistent");
        for (i = 0; (s[i] != (char)0) && (buf[i] != (char)0); i++)
        {
            if (buf[i] != s[i])
            {
                buf[i] = 0;
                break;
            }
        }
    }
    for (i = li = 0; (buf[i] != (char)0); i++)
    {
        if ((buf[i] == '/') || (buf[i] == '\\'))
        {
            li = i+1;
            i++;
        }
    }
    buf[li] = (char)0;
    return make_string (buf);
}

canonical_original_code:
unsigned long path_prefix(unsigned long list)
{
    unsigned long l = list; unsigned long n = ((((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)l))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    char *s;
    char buf[4096];
    int i = 0; int li;
    for (s = (char *)((((((int_pointer)(n)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)n))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)n))->character_data) : "#nonexistent"); (s[i] != (char)0) && (i < 0xfff); i++)
    {
        buf[i] = s[i];
    }
    buf[i] = (char)0;
    for (l = ((((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)l))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))); (((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)); l = ((((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)l))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))))
    {
        n = ((((((int_pointer)(l)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)l))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)l))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        s = (char *)((((((int_pointer)(n)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)n))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)n))->character_data) : "#nonexistent");
        for (i = 0; (s[i] != (char)0) && (buf[i] != (char)0); i++)
        {
            if (buf[i] != s[i])
            {
                buf[i] = 0;
                break;
            }
        }
    }
    for (i = li = 0; (buf[i] != (char)0); i++)
    {
        if ((buf[i] == '/') || (buf[i] == '\\'))
        {
            li = i+1;
            i++;
        }
    }
    buf[li] = (char)0;
    return make_string (buf);
}

variable_types:
list
unsigned long

variable_types:
l
unsigned long

variable_types:
n
unsigned long

variable_types:
buf
char [4096]

variable_types: li int

return_type: unsigned long

user_defined_types: struct sexpr_string_or_symbol { enum sx_type type; char character_data[]; }


decompiled_code:
__int64 __fastcall path_normalise_prefix(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax
const char *v4; // rdx
__int64 v5; // r13
__int64 v6; // rax
__int64 i; // rbp
_DWORD *v8; // r14
const char *v9; // rdi
__int64 v10; // rax
__int64 v11; // rax

v2 = path_normalise(a1);
v3 = path_prefix(v2);
v4 = "#nonexistent";
v5 = v3 & 1;
if ( (v3 & 1) == 0 && *(_DWORD *)v3 == 4 )
{
if ( !*(_BYTE *)(v3 + 4) )
goto LABEL_5;
v4 = (const char *)(v3 + 4);
}
v6 = 1LL;
do
v5 = v6++;
while ( v4[v6 - 1] );
LABEL_5:
for ( i = 45LL; (v2 & 1) == 0; v2 = *(_QWORD *)(v2 + 16) )
{
if ( *(_DWORD *)v2 != 6 )
break;
v8 = *(_DWORD **)(v2 + 8);
v9 = "#nonexistent";
if ( ((unsigned __int8)v8 & 1) == 0 )
{
v9 = (const char *)(v8 + 1);
if ( *v8 != 4 )
v9 = "#nonexistent";
}
v10 = make_string(&v9[v5], a2);
v11 = cons(v8, v10);
a2 = i;
i = cons(v11, i);
if ( *(_DWORD *)v2 != 6 )
break;
}
return i;
}

original_code:
sexpr path_normalise_prefix (sexpr path)
{
    sexpr p = path_normalise(path), rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5)), n,
          px = path_prefix (p);
    int i = 0;
    const char *s = (const char *)((((((int_pointer)(px)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)px))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)px))->character_data) : "#nonexistent");
    while (s[i] != (char)0)
    {
        i++;
    }
    while ((((((int_pointer)(p)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)p))->type == sxt_cons)))
    {
        n = ((((((int_pointer)(p)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)p))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)p))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        s = (const char *)((((((int_pointer)(n)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)n))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)n))->character_data) : "#nonexistent");
        rv = cons (cons (n, make_string (s + i)), rv);
        p = ((((((int_pointer)(p)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)p))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)p))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return rv;
}

canonical_original_code:
unsigned long path_normalise_prefix(unsigned long path)
{
    unsigned long p = path_normalise(path); unsigned long rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5)); unsigned long n; unsigned long px = path_prefix (p);
    int i = 0;
    char *s = (const char *)((((((int_pointer)(px)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)px))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)px))->character_data) : "#nonexistent");
    while (s[i] != (char)0)
    {
        i++;
    }
    while ((((((int_pointer)(p)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)p))->type == sxt_cons)))
    {
        n = ((((((int_pointer)(p)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)p))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)p))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        s = (char *)((((((int_pointer)(n)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)n))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)n))->character_data) : "#nonexistent");
        rv = cons (cons (n, make_string (s + i)), rv);
        p = ((((((int_pointer)(p)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)p))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)p))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return rv;
}

variable_types:
p
unsigned long

variable_types:
px
unsigned long


decompiled_code:
__int64 get_io_struct_real()
{
return get_pool_mem(io_struct_pool);
}

canonical_decompiled_code:
__int64 func0()
{
return get_pool_mem(io_struct_pool);
}

original_code:
static struct io *get_io_struct_real ()
{
    return get_pool_mem (io_struct_pool);
}

canonical_original_code:
static struct io *get_io_struct_real()
{
    return get_pool_mem (io_struct_pool);
}

return_type: struct io { int fd; char *buffer; enum io_type { iot_undefined=0, iot_read=1, iot_write=2, iot_special_read=3, iot_special_write=4, iot_buffer=5 } type; enum io_result { io_undefined=0, io_end_of_file=1, io_changes=2, io_unrecoverable_error=3, io_no_change=4, io_complete=5, io_incomplete=6, io_finalising=7 } status; unsigned int length; unsigned int position; unsigned int buffersize; } *

user_defined_types: struct io { int fd; char *buffer; enum io_type type; enum io_result status; unsigned int length; unsigned int position; unsigned int buffersize; }


decompiled_code:
__int64 get_io_struct_init()
{
__int64 v0; // rax

v0 = create_memory_pool(40LL);
get_io_struct = get_io_struct_real;
io_struct_pool = v0;
return get_io_struct_real();
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rax

v0 = create_memory_pool(40LL);
get_io_struct = get_io_struct_real;
io_struct_pool = v0;
return func0();
}

original_code:
static struct io *get_io_struct_init ()
{
    io_struct_pool = create_memory_pool (sizeof (struct io));
    get_io_struct = get_io_struct_real;
    return get_io_struct_real();
}

canonical_original_code:
static struct io *get_io_struct_init()
{
    io_struct_pool = create_memory_pool (sizeof (struct io));
    get_io_struct = get_io_struct_real;
    return get_io_struct_real();
}

user_defined_types: enum io_type { iot_undefined=0, iot_read=1, iot_write=2, iot_special_read=3, iot_special_write=4, iot_buffer=5 }

user_defined_types: enum io_result { io_undefined=0, io_end_of_file=1, io_changes=2, io_unrecoverable_error=3, io_no_change=4, io_complete=5, io_incomplete=6, io_finalising=7 }


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

result = get_io_struct();
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = 0x100000005LL;
*(_DWORD *)(result + 24) = a2;
*(_QWORD *)(result + 28) = 0LL;
*(_DWORD *)result = -1;
return result;
}

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

result = get_io_struct();
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = 0x100000005LL;
*(_DWORD *)(result + 24) = a2;
*(_QWORD *)(result + 28) = 0LL;
*(_DWORD *)result = -1;
return result;
}

original_code:
struct io *io_open_buffer (void *buffer, unsigned int size)
{
    struct io *io = get_io_struct ();
    io->buffer = buffer;
    io->type = iot_buffer;
    io->status = io_end_of_file;
    io->length = size;
    io->position = 0;
    io->buffersize = 0;
    io->fd = -1;
    return io;
}

canonical_original_code:
struct io *io_open_buffer(void *buffer, unsigned int size)
{
    struct io *io = get_io_struct ();
    io->buffer = buffer;
    io->type = iot_buffer;
    io->status = io_end_of_file;
    io->length = size;
    io->position = 0;
    io->buffersize = 0;
    io->fd = -1;
    return io;
}

variable_types:
buffer
void *

variable_types:
size
unsigned int

variable_types: struct io { int fd; char *buffer; enum io_type { iot_undefined=0, iot_read=1, iot_write=2, iot_special_read=3, iot_special_write=4, iot_buffer=5 } type; enum io_result { io_undefined=0, io_end_of_file=1, io_changes=2, io_unrecoverable_error=3, io_no_change=4, io_complete=5, io_incomplete=6, io_finalising=7 } status; unsigned int length; unsigned int position; unsigned int buffersize; } *


original_code:
struct io *io_create ()
{
    struct io *io = get_io_struct ();
    io->buffer = get_mem (0x1000);
    io->status = io_undefined;
    io->length = 0;
    io->position = 0;
    io->buffersize = 0x1000;
    return io;
}

canonical_original_code:
struct io *io_create()
{
    struct io *io = get_io_struct ();
    io->buffer = get_mem (0x1000);
    io->status = io_undefined;
    io->length = 0;
    io->position = 0;
    io->buffersize = 0x1000;
    return io;
}


decompiled_code:
// attributes: thunk
__int64 io_destroy()
{
return free_pool_mem();
}

canonical_decompiled_code:
__int64 func4()
{
return free_pool_mem();
}

original_code:
void io_destroy (struct io *io)
{
    free_pool_mem ((void *)(io));
}

canonical_original_code:
void io_destroy(struct io *io)
{
    free_pool_mem ((void *)(io));
}

return_type: void


decompiled_code:
signed __int64 dt_get_time()
{
return sys_time_constprop_0() % 86400;
}

canonical_decompiled_code:
signed __int64 func4()
{
return func0() % 86400;
}

original_code:
unsigned int dt_get_time (void)
{
    return sys_time(0) % SECONDS_PER_DAY;
}

canonical_original_code:
unsigned int dt_get_time()
{
    return sys_time(0) % SECONDS_PER_DAY;
}

return_type: unsigned int


decompiled_code:
signed __int64 a_wait_all()
{
signed __int64 result; // rax
_DWORD *v1; // r8
int v2; // [rsp+Ch] [rbp-4h] BYREF

result = sys_wait4_constprop_0(-1, &v2);
if ( (v2 & 0x7F) == 0 )
*v1 = BYTE1(v2);
return result;
}

canonical_decompiled_code:
signed __int64 func2()
{
signed __int64 result; // rax
_DWORD *v1; // r8
int v2; // [rsp+Ch] [rbp-4h] BYREF

result = func0(-1, &v2);
if ( (v2 & 0x7F) == 0 )
*v1 = BYTE1(v2);
return result;
}

original_code:
int a_wait_all(int *status) {
    int st, r;

    r = sys_wait4((signed int)-1, &st, 0x1 /*WNOHANG*/, (void *)0);

    if ((st & 0x7f) == 0) /* see above */
    {
        *status = ((st & 0xff00) >> 8);
    }

    return r;
}

canonical_original_code:
int a_wait_all(int *status) {
    int st; int r;

    r = sys_wait4((int)-1, &st, 0x1 /*WNOHANG*/, (void *)0);

    if ((st & 0x7f) == 0) /* see above */
    {
        *status = ((st & 0xff00) >> 8);
    }

    return r;
}

variable_types:
status
int *

variable_types: st int

variable_types: r int

return_type: int


decompiled_code:
__int64 __fastcall with_metadata_indirect(__int64 a1, __int64 a2)
{
return (*(__int64 (__fastcall **)(__int64, _QWORD))a2)(a1, *(_QWORD *)(a2 + 8));
}

original_code:
static void with_metadata_indirect (struct metadata *metadata, void *aux)
{
    struct metadata_indirection *i = (struct metadata_indirection *)aux;
    i->with_metadata (metadata, i->aux);
}

canonical_original_code:
static void with_metadata_indirect(struct metadata *metadata, void *aux)
{
    struct metadata_indirection *i = (struct metadata_indirection *)aux;
    i->with_metadata (metadata, i->aux);
}

variable_types:
aux
void *

variable_types: struct metadata_indirection { void (*with_metadata)(struct metadata { int datetime_count; int relation_count; int acl_count; struct metadata_datetime { enum metadata_datetime_purpose { mdp_unknown=0, mdp_creation=1, mdp_link_creation=2, mdp_last_access=3, mdp_last_modification=4, mdp_last_status_change=5, mdp_expiry=6 } purpose; struct datetime { unsigned long long date; unsigned int time; } datetime; } *datetime; struct metadata_relation { enum metadata_relation_type { mrt_unknown=0, mrt_owning_user=1, mrt_owning_group=2, mrt_creating_user=3, mrt_creating_group=4 } type; char *target; } *relation; struct metadata_acl { enum metadata_acl_target_type { mct_unknown=0, mct_creating_user=1, mct_creating_group=2, mct_owning_user=3, mct_owning_group=4, mct_user=5, mct_group=6, mct_default=7 } target_type; char *target; int access; } *acl; struct metadata_classification { enum metadata_classification_type { mdt_unknown=0, mdt_mime=1, mdt_unix=2 } type; } **classification; struct metadata_attribute { enum metadata_attribute_type { mat_unknown=0, mat_key_value=1, mat_description=2, mat_link_target=3, mat_link_device_id=4, mat_source_device_id=5, mat_inode=6, mat_link_count=7, mat_size=8, mat_user_id=9, mat_group_id=10, mat_flags=11 } type; } **attribute; struct metadata_signature { enum metadata_signature_type { mst_unknown=0, mst_hash_md4=1, mst_hash_md5=2, mst_hash_murmur=3, mst_hash_sha1=4, mst_hash_sha256=5, mst_hash_crc8=6, mst_hash_crc16=7, mst_hash_crc32=8 } type; } **signature; } *, void *); void *aux; } *

user_defined_types: struct metadata { int datetime_count; int relation_count; int acl_count; struct metadata_datetime *datetime; struct metadata_relation *relation; struct metadata_acl *acl; struct metadata_classification **classification; struct metadata_attribute **attribute; struct metadata_signature **signature; }

user_defined_types: struct metadata_indirection { void (*with_metadata)(struct metadata *, void *); void *aux; }

user_defined_types: struct metadata_datetime { enum metadata_datetime_purpose purpose; struct datetime datetime; }

user_defined_types: struct metadata_relation { enum metadata_relation_type type; char *target; }

user_defined_types: struct metadata_acl { enum metadata_acl_target_type target_type; char *target; int access; }

user_defined_types: struct metadata_classification { enum metadata_classification_type type; }

user_defined_types: struct metadata_attribute { enum metadata_attribute_type type; }

user_defined_types: struct metadata_signature { enum metadata_signature_type type; }


original_code:
void metadata_from_path
    (const char *path,
     void (*with_metadata) (struct metadata *, void *), void *aux)
{
    struct stat st;
    if (sys_stat ((char *)path, &st) != 0)
    {
        struct metadata metadata = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        with_metadata (&metadata, aux);
    }
    else
    {
        struct metadata_indirection i = { with_metadata, aux };
        enum metadata_classification_unix c;
        int attributes = 0;
             if (0xc000 & st.st_mode) { c = mcu_socket; }
        else if (0xa000 & st.st_mode) { c = mcu_symbolic_link; }
        else if (0x8000 & st.st_mode) { c = mcu_file; }
        else if (0x6000 & st.st_mode) { c = mcu_block_device; }
        else if (0x4000 & st.st_mode) { c = mcu_directory; }
        else if (0x2000 & st.st_mode) { c = mcu_character_device; }
        else if (0x1000 & st.st_mode) { c = mcu_fifo; }
        else { c = mcu_unknown; }
        if (0x0800 & st.st_mode) { attributes |= (1 << 0x0); }
        if (0x0400 & st.st_mode) { attributes |= (1 << 0x1); }
        if (0x0200 & st.st_mode) { attributes |= (1 << 0x2); }
        metadata_from_unix
            (c, st.st_uid, st.st_gid, st.st_mode, st.st_atime, st.st_mtime,
             st.st_ctime, st.st_size, st.st_dev, attributes,
             with_metadata_indirect, &i);
    }
}

canonical_original_code:
void metadata_from_path(char *path, void (*with_metadata)(struct metadata *, void *), void *aux)
{
    struct stat st;
    if (sys_stat ((char *)path, &st) != 0)
    {
        struct metadata metadata = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        with_metadata (&metadata, aux);
    }
    else
    {
        struct metadata_indirection i = { with_metadata, aux };
        enum metadata_classification_unix c;
        int attributes = 0;
             if (0xc000 & st.st_mode) { c = mcu_socket; }
        else if (0xa000 & st.st_mode) { c = mcu_symbolic_link; }
        else if (0x8000 & st.st_mode) { c = mcu_file; }
        else if (0x6000 & st.st_mode) { c = mcu_block_device; }
        else if (0x4000 & st.st_mode) { c = mcu_directory; }
        else if (0x2000 & st.st_mode) { c = mcu_character_device; }
        else if (0x1000 & st.st_mode) { c = mcu_fifo; }
        else { c = mcu_unknown; }
        if (0x0800 & st.st_mode) { attributes |= (1 << 0x0); }
        if (0x0400 & st.st_mode) { attributes |= (1 << 0x1); }
        if (0x0200 & st.st_mode) { attributes |= (1 << 0x2); }
        metadata_from_unix
            (c, st.st_uid, st.st_gid, st.st_mode, st.st_atime, st.st_mtime,
             st.st_ctime, st.st_size, st.st_dev, attributes,
             with_metadata_indirect, &i);
    }
}

variable_types:
path
char *

variable_types: void (*)(struct metadata { int datetime_count; int relation_count; int acl_count; struct metadata_datetime { enum metadata_datetime_purpose { mdp_unknown=0, mdp_creation=1, mdp_link_creation=2, mdp_last_access=3, mdp_last_modification=4, mdp_last_status_change=5, mdp_expiry=6 } purpose; struct datetime { unsigned long long date; unsigned int time; } datetime; } *datetime; struct metadata_relation { enum metadata_relation_type { mrt_unknown=0, mrt_owning_user=1, mrt_owning_group=2, mrt_creating_user=3, mrt_creating_group=4 } type; char *target; } *relation; struct metadata_acl { enum metadata_acl_target_type { mct_unknown=0, mct_creating_user=1, mct_creating_group=2, mct_owning_user=3, mct_owning_group=4, mct_user=5, mct_group=6, mct_default=7 } target_type; char *target; int access; } *acl; struct metadata_classification { enum metadata_classification_type { mdt_unknown=0, mdt_mime=1, mdt_unix=2 } type; } **classification; struct metadata_attribute { enum metadata_attribute_type { mat_unknown=0, mat_key_value=1, mat_description=2, mat_link_target=3, mat_link_device_id=4, mat_source_device_id=5, mat_inode=6, mat_link_count=7, mat_size=8, mat_user_id=9, mat_group_id=10, mat_flags=11 } type; } **attribute; struct metadata_signature { enum metadata_signature_type { mst_unknown=0, mst_hash_md4=1, mst_hash_md5=2, mst_hash_murmur=3, mst_hash_sha1=4, mst_hash_sha256=5, mst_hash_crc8=6, mst_hash_crc16=7, mst_hash_crc32=8 } type; } **signature; } *, void *)

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; unsigned int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; unsigned long st_atime; unsigned long st_atime_nsec; unsigned long st_mtime; unsigned long st_mtime_nsec; unsigned long st_ctime; unsigned long st_ctime_nsec; long __unused[3]; }

variable_types: struct metadata_indirection { void (*with_metadata)(struct metadata { int datetime_count; int relation_count; int acl_count; struct metadata_datetime { enum metadata_datetime_purpose { mdp_unknown=0, mdp_creation=1, mdp_link_creation=2, mdp_last_access=3, mdp_last_modification=4, mdp_last_status_change=5, mdp_expiry=6 } purpose; struct datetime { unsigned long long date; unsigned int time; } datetime; } *datetime; struct metadata_relation { enum metadata_relation_type { mrt_unknown=0, mrt_owning_user=1, mrt_owning_group=2, mrt_creating_user=3, mrt_creating_group=4 } type; char *target; } *relation; struct metadata_acl { enum metadata_acl_target_type { mct_unknown=0, mct_creating_user=1, mct_creating_group=2, mct_owning_user=3, mct_owning_group=4, mct_user=5, mct_group=6, mct_default=7 } target_type; char *target; int access; } *acl; struct metadata_classification { enum metadata_classification_type { mdt_unknown=0, mdt_mime=1, mdt_unix=2 } type; } **classification; struct metadata_attribute { enum metadata_attribute_type { mat_unknown=0, mat_key_value=1, mat_description=2, mat_link_target=3, mat_link_device_id=4, mat_source_device_id=5, mat_inode=6, mat_link_count=7, mat_size=8, mat_user_id=9, mat_group_id=10, mat_flags=11 } type; } **attribute; struct metadata_signature { enum metadata_signature_type { mst_unknown=0, mst_hash_md4=1, mst_hash_md5=2, mst_hash_murmur=3, mst_hash_sha1=4, mst_hash_sha256=5, mst_hash_crc8=6, mst_hash_crc16=7, mst_hash_crc32=8 } type; } **signature; } *, void *); void *aux; }

variable_types: enum metadata_classification_unix { mcu_unknown=0, mcu_file=1, mcu_directory=2, mcu_fifo=3, mcu_pipe=4, mcu_socket=5, mcu_symbolic_link=6, mcu_block_device=7, mcu_character_device=8 }

variable_types: attributes int


decompiled_code:
signed __int64 __fastcall metadata_to_path(__int64 a1, char *a2)
{
int v3; // esi
char v5[4]; // [rsp+10h] [rbp-50h] BYREF
unsigned int v6; // [rsp+14h] [rbp-4Ch] BYREF
unsigned int v7; // [rsp+18h] [rbp-48h] BYREF
int v8; // [rsp+1Ch] [rbp-44h] BYREF
char v9[4]; // [rsp+20h] [rbp-40h] BYREF
int v10; // [rsp+24h] [rbp-3Ch] BYREF
struct utimbuf v11; // [rsp+28h] [rbp-38h] BYREF
__int64 v12; // [rsp+38h] [rbp-28h] BYREF
char v13[8]; // [rsp+40h] [rbp-20h] BYREF
struct utimbuf v14; // [rsp+48h] [rbp-18h] BYREF

v11.actime = 0LL;
v11.modtime = 0LL;
v12 = 0LL;
metadata_to_unix(a1, v5, &v6, &v7, &v8, &v11, &v11.modtime, &v12, v13, v9, &v10);
v3 = v8;
if ( (v10 & 1) != 0 )
{
v3 = v8 | 0x800;
v8 |= 0x800u;
}
if ( (v10 & 2) != 0 )
{
v3 |= 0x400u;
v8 = v3;
}
if ( (v10 & 4) != 0 )
{
v3 |= 0x200u;
v8 = v3;
}
sys_chmod_isra_0(a2, v3);
sys_chown_isra_0(a2, v6, v7);
v14 = v11;
return sys_utime_isra_0(a2, &v14);
}

canonical_decompiled_code:
signed __int64 __fastcall func6(__int64 a1, char *a2)
{
int v3; // esi
char v5[4]; // [rsp+10h] [rbp-50h] BYREF
unsigned int v6; // [rsp+14h] [rbp-4Ch] BYREF
unsigned int v7; // [rsp+18h] [rbp-48h] BYREF
int v8; // [rsp+1Ch] [rbp-44h] BYREF
char v9[4]; // [rsp+20h] [rbp-40h] BYREF
int v10; // [rsp+24h] [rbp-3Ch] BYREF
struct utimbuf v11; // [rsp+28h] [rbp-38h] BYREF
__int64 v12; // [rsp+38h] [rbp-28h] BYREF
char v13[8]; // [rsp+40h] [rbp-20h] BYREF
struct utimbuf v14; // [rsp+48h] [rbp-18h] BYREF

v11.actime = 0LL;
v11.modtime = 0LL;
v12 = 0LL;
metadata_to_unix(a1, v5, &v6, &v7, &v8, &v11, &v11.modtime, &v12, v13, v9, &v10);
v3 = v8;
if ( (v10 & 1) != 0 )
{
v3 = v8 | 0x800;
v8 |= 0x800u;
}
if ( (v10 & 2) != 0 )
{
v3 |= 0x400u;
v8 = v3;
}
if ( (v10 & 4) != 0 )
{
v3 |= 0x200u;
v8 = v3;
}
func4(a2, v3);
func3(a2, v6, v7);
v14 = v11;
return func2(a2, &v14);
}

original_code:
void metadata_to_path
    (struct metadata *metadata,
     const char *path)
{
    enum metadata_classification_unix classification;
    int uid, gid, mode, device, attributes;
    long atime = 0, mtime = 0, ctime = 0, size;
    long times[2];
    metadata_to_unix
        (metadata, &classification, &uid, &gid, &mode, &atime, &mtime, &ctime,
         &size, &device, &attributes);
    if (attributes & (1 << 0x0)) { mode |= 0x0800; }
    if (attributes & (1 << 0x1)) { mode |= 0x0400; }
    if (attributes & (1 << 0x2)) { mode |= 0x0200; }
    sys_chmod (path, mode);
    sys_chown (path, uid, gid);
    times[0] = atime;
    times[1] = mtime;
    sys_utime ((char *)path, times);
}

canonical_original_code:
void metadata_to_path(struct metadata *metadata, char *path)
{
    enum metadata_classification_unix classification;
    int uid; int gid; int mode; int device; int attributes;
    long atime = 0; long mtime = 0; long ctime = 0; long size;
    long times[2];
    metadata_to_unix
        (metadata, &classification, &uid, &gid, &mode, &atime, &mtime, &ctime,
         &size, &device, &attributes);
    if (attributes & (1 << 0x0)) { mode |= 0x0800; }
    if (attributes & (1 << 0x1)) { mode |= 0x0400; }
    if (attributes & (1 << 0x2)) { mode |= 0x0200; }
    sys_chmod (path, mode);
    sys_chown (path, uid, gid);
    times[0] = atime;
    times[1] = mtime;
    sys_utime ((char *)path, times);
}

variable_types: struct metadata { int datetime_count; int relation_count; int acl_count; struct metadata_datetime { enum metadata_datetime_purpose { mdp_unknown=0, mdp_creation=1, mdp_link_creation=2, mdp_last_access=3, mdp_last_modification=4, mdp_last_status_change=5, mdp_expiry=6 } purpose; struct datetime { unsigned long long date; unsigned int time; } datetime; } *datetime; struct metadata_relation { enum metadata_relation_type { mrt_unknown=0, mrt_owning_user=1, mrt_owning_group=2, mrt_creating_user=3, mrt_creating_group=4 } type; char *target; } *relation; struct metadata_acl { enum metadata_acl_target_type { mct_unknown=0, mct_creating_user=1, mct_creating_group=2, mct_owning_user=3, mct_owning_group=4, mct_user=5, mct_group=6, mct_default=7 } target_type; char *target; int access; } *acl; struct metadata_classification { enum metadata_classification_type { mdt_unknown=0, mdt_mime=1, mdt_unix=2 } type; } **classification; struct metadata_attribute { enum metadata_attribute_type { mat_unknown=0, mat_key_value=1, mat_description=2, mat_link_target=3, mat_link_device_id=4, mat_source_device_id=5, mat_inode=6, mat_link_count=7, mat_size=8, mat_user_id=9, mat_group_id=10, mat_flags=11 } type; } **attribute; struct metadata_signature { enum metadata_signature_type { mst_unknown=0, mst_hash_md4=1, mst_hash_md5=2, mst_hash_murmur=3, mst_hash_sha1=4, mst_hash_sha256=5, mst_hash_crc8=6, mst_hash_crc16=7, mst_hash_crc32=8 } type; } **signature; } *

variable_types: uid int

variable_types: gid int

variable_types: mode int

variable_types: device int

variable_types: atime long

variable_types: mtime long

variable_types: ctime long

variable_types: size long

variable_types:
times
long [2]

user_defined_types: enum metadata_classification_unix { mcu_unknown=0, mcu_file=1, mcu_directory=2, mcu_fifo=3, mcu_pipe=4, mcu_socket=5, mcu_symbolic_link=6, mcu_block_device=7, mcu_character_device=8 }


abort

decompiled_code:
// attributes: thunk
void __noreturn abort()
{
sys_exit_constprop_0();
JUMPOUT(0x14LL);
}

canonical_decompiled_code:
void __noreturn func1()
{
func0();
JUMPOUT(0x14LL);
}

original_code:
void abort ( void )
{
    sys_exit (-1);
}

canonical_original_code:
void abort()
{
    sys_exit (-1);
}


memcpy

original_code:
void *memcpy(void *dest, const void *src, unsigned long n)
{
    const char *sc = (const char *)src;
    char *dc = (char *)dest;

    for (unsigned long i = 0; i < n; i++)
    {
        dc[i] = sc[i];
    }

    return dest;
}

canonical_original_code:
void *memcpy(void *dest, void *src, unsigned long n)
{
    char *sc = (const char *)src;
    char *dc = (char *)dest;

    for (unsigned long i = 0; i < n; i++)
    {
        dc[i] = sc[i];
    }

    return dest;
}

variable_types:
dest
void *

variable_types:
src
void *

variable_types:
n
unsigned long

variable_types:
sc
char *

variable_types:
dc
char *

variable_types:
i
unsigned long

return_type: void *


strlen

decompiled_code:
__int64 __fastcall strlen(_BYTE *a1)
{
__int64 result; // rax

result = 0LL;
if ( *a1 )
{
do
++result;
while ( a1[result] );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1)
{
__int64 result; // rax

result = 0LL;
if ( *a1 )
{
do
++result;
while ( a1[result] );
}
return result;
}

original_code:
unsigned long strlen(const char *s)
{
    unsigned long i = 0;

    while (s[i] != (const char)0) i++;

    return i;
}

canonical_original_code:
unsigned long strlen(char *s)
{
    unsigned long i = 0;

    while (s[i] != (char)0) i++;

    return i;
}

variable_types:
s
char *


strcpy

decompiled_code:
__int64 __fastcall strcpy(__int64 a1, char *a2)
{
char v2; // al
int v3; // ecx
__int64 v4; // rdx

v2 = *a2;
if ( *a2 )
{
v3 = 0;
v4 = 0LL;
do
{
*(_BYTE *)(a1 + v4) = v2;
v4 = (unsigned int)(v3 + 1);
v2 = a2[v4];
++v3;
}
while ( v2 );
}
return a1;
}

original_code:
char *strcpy(char *restrict s1, const char *restrict s2)
{
    for (unsigned int i = 0; s2[i] != 0; i++)
    {
        s1[i] = s2[i];
    }

    return s1;
}

canonical_original_code:
char *strcpy(char *s1, char *s2)
{
    for (unsigned int i = 0; s2[i] != 0; i++)
    {
        s1[i] = s2[i];
    }

    return s1;
}

variable_types:
i
unsigned int

return_type: char *


memcmp

decompiled_code:
__int64 __fastcall memcmp(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r8
int v5; // edx
int v6; // eax

if ( !a3 )
return 0LL;
v4 = 0LL;
while ( 1 )
{
v5 = *(unsigned __int8 *)(a1 + v4);
v6 = *(unsigned __int8 *)(a2 + v4);
if ( (_BYTE)v5 != (_BYTE)v6 )
break;
if ( ++v4 == a3 )
return 0LL;
}
return (unsigned int)(v6 - v5);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r8
int v5; // edx
int v6; // eax

if ( !a3 )
return 0LL;
v4 = 0LL;
while ( 1 )
{
v5 = *(unsigned __int8 *)(a1 + v4);
v6 = *(unsigned __int8 *)(a2 + v4);
if ( (_BYTE)v5 != (_BYTE)v6 )
break;
if ( ++v4 == a3 )
return 0LL;
}
return (unsigned int)(v6 - v5);
}

original_code:
int memcmp(const void *s1, const void *s2, unsigned long count)
{
    for (long i = 0; i < count; i++)
    {
        if (((unsigned char *)s1)[i] == ((unsigned char *)s2)[i]) continue;
        return (((unsigned char *)s2)[i] - ((unsigned char *)s1)[i]);
    }

    return 0;
}

canonical_original_code:
int memcmp(void *s1, void *s2, unsigned long count)
{
    for (long i = 0; i < count; i++)
    {
        if (((unsigned char *)s1)[i] == ((unsigned char *)s2)[i]) continue;
        return (((unsigned char *)s2)[i] - ((unsigned char *)s1)[i]);
    }

    return 0;
}

variable_types:
count
unsigned long

variable_types: i long


strncmp

decompiled_code:
__int64 __fastcall strncmp(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r8
int v5; // edx
int v6; // eax

v4 = 0LL;
if ( a3 )
{
do
{
v5 = *(unsigned __int8 *)(a1 + v4);
if ( !(_BYTE)v5 )
break;
v6 = *(unsigned __int8 *)(a2 + v4);
if ( !(_BYTE)v6 )
break;
if ( (_BYTE)v5 != (_BYTE)v6 )
return (unsigned int)(v6 - v5);
++v4;
}
while ( v4 != a3 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r8
int v5; // edx
int v6; // eax

v4 = 0LL;
if ( a3 )
{
do
{
v5 = *(unsigned __int8 *)(a1 + v4);
if ( !(_BYTE)v5 )
break;
v6 = *(unsigned __int8 *)(a2 + v4);
if ( !(_BYTE)v6 )
break;
if ( (_BYTE)v5 != (_BYTE)v6 )
return (unsigned int)(v6 - v5);
++v4;
}
while ( v4 != a3 );
}
return 0LL;
}

original_code:
int strncmp(const char *s1, const char *s2, unsigned long count)
{
    for (long i = 0; (i < count) && (s1[i] != 0) && (s2[i] != 0); i++)
    {
        if ((unsigned char)(s1[i]) == (unsigned char)(s2[i])) continue;
        return ((unsigned char)(s2[i]) - (unsigned char)(s1[i]));
    }

    return 0;
}

canonical_original_code:
int strncmp(char *s1, char *s2, unsigned long count)
{
    for (long i = 0; (i < count) && (s1[i] != 0) && (s2[i] != 0); i++)
    {
        if ((unsigned char)(s1[i]) == (unsigned char)(s2[i])) continue;
        return ((unsigned char)(s2[i]) - (unsigned char)(s1[i]));
    }

    return 0;
}


renderMap

repo: sevko/termcrate

decompiled_code:
__int64 renderMap()
{
char *v0; // rbx
const char *v1; // rsi

v0 = &mapBuf;
xt_par0("\x1B[33m");
do
{
v1 = v0;
v0 += 178;
printf("%s", v1);
}
while ( v0 != &mapBuf + 7832 );
return xt_par0("\x1B[0m");
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rbx
const char *v1; // rsi

v0 = &mapBuf;
xt_par0("\x1B[33m");
do
{
v1 = v0;
v0 += 178;
printf("%s", v1);
}
while ( v0 != &mapBuf + 7832 );
return xt_par0("\x1B[0m");
}

original_code:
void renderMap(){
 int row;
 xt_par0("\033[33m");
 for(row = 0; row < 44; row++)
  printf("%s", mapBuf[row]);
 xt_par0("\033[0m");
}

variable_types: row int


addActor

decompiled_code:
__int64 __fastcall addActor(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int128 a7, int a8)
{
__m128i v8; // xmm1
__int64 v9; // rax
int v10; // edx
__int64 result; // rax
__int64 v12; // rax
__m128i v13; // xmm0
int v14; // edx

if ( a1 && numEnemies <= 49 )
{
v8 = _mm_loadu_si128((const __m128i *)&a7);
v9 = 5LL * numEnemies;
++numEnemies;
v10 = a8;
result = 4 * v9;
*(__m128i *)((char *)&enemies + result) = v8;
*(_DWORD *)((char *)&enemies + result + 16) = v10;
}
else
{
result = numBullets;
if ( numBullets <= 49 )
{
v12 = 5LL * numBullets;
v13 = _mm_loadu_si128((const __m128i *)&a7);
++numBullets;
v14 = a8;
result = 4 * v12;
*(__m128i *)((char *)&bullets + result) = v13;
*(_DWORD *)((char *)&bullets + result + 16) = v14;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int128 a7, int a8)
{
__m128i v8; // xmm1
__int64 v9; // rax
int v10; // edx
__int64 result; // rax
__int64 v12; // rax
__m128i v13; // xmm0
int v14; // edx

if ( a1 && numEnemies <= 49 )
{
v8 = _mm_loadu_si128((const __m128i *)&a7);
v9 = 5LL * numEnemies;
++numEnemies;
v10 = a8;
result = 4 * v9;
*(__m128i *)((char *)&enemies + result) = v8;
*(_DWORD *)((char *)&enemies + result + 16) = v10;
}
else
{
result = numBullets;
if ( numBullets <= 49 )
{
v12 = 5LL * numBullets;
v13 = _mm_loadu_si128((const __m128i *)&a7);
++numBullets;
v14 = a8;
result = 4 * v12;
*(__m128i *)((char *)&bullets + result) = v13;
*(_DWORD *)((char *)&bullets + result + 16) = v14;
}
}
return result;
}

original_code:
void addActor(int enem, Actor_t newActor){
 if(enem && _numEnemies < 50) {
  _enemies[_numEnemies++] = newActor;
 }
 else if(_numBullets < 50) {
  _bullets[_numBullets++] = newActor;
 }
}

canonical_original_code:
void addActor(int enem, struct Actor_t newActor){
 if(enem && _numEnemies < 50) {
  _enemies[_numEnemies++] = newActor;
 }
 else if(_numBullets < 50) {
  _bullets[_numBullets++] = newActor;
 }
}

variable_types: enem int

variable_types: struct Actor_t { struct Geometry_t { int x; } geo; int dirMotion; }

user_defined_types: struct Actor_t { struct Geometry_t geo; int dirMotion; }


drawSprite

decompiled_code:
__int64 __fastcall drawSprite(const char *a1, __int64 a2)
{
xt_par0("\x1B[1m");
xt_par0(a2);
printf("%s", a1);
return xt_par0("\x1B[0m");
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, __int64 a2)
{
xt_par0("\x1B[1m");
xt_par0(a2);
printf("%s", a1);
return xt_par0("\x1B[0m");
}

original_code:
void drawSprite(char * sprite, char * color){
 xt_par0("\033[1m");
 xt_par0(color);
 printf("%s", sprite);
 xt_par0("\033[0m");
}

canonical_original_code:
void drawSprite(char *sprite, char *color){
 xt_par0("\033[1m");
 xt_par0(color);
 printf("%s", sprite);
 xt_par0("\033[0m");
}

variable_types:
sprite
char *

variable_types:
color
char *


renderActors

decompiled_code:
__int64 renderActors()
{
unsigned int *v0; // rbx
int v1; // ebp
__int64 v2; // rsi
__int64 v3; // rdx
unsigned int *v4; // rbx
int v5; // ebp
__int64 v6; // rsi
__int64 v7; // rdx

if ( numEnemies > 0 )
{
v0 = (unsigned int *)&enemies;
v1 = 0;
do
{
v2 = v0[1];
v3 = *v0;
++v1;
v0 += 5;
xt_par2("\x1B[%d;%dH", v2, v3);
drawSprite("X", (__int64)"\x1B[32m");
}
while ( numEnemies > v1 );
}
if ( numBullets > 0 )
{
v4 = (unsigned int *)&bullets;
v5 = 0;
do
{
v6 = v4[1];
v7 = *v4;
++v5;
v4 += 5;
xt_par2("\x1B[%d;%dH", v6, v7);
drawSprite(byte_5B8, (__int64)"\x1B[34m");
}
while ( numBullets > v5 );
}
xt_par2("\x1B[%d;%dH", *((unsigned int *)&crate + 1), crate);
drawSprite("I", (__int64)"\x1B[33m");
xt_par2("\x1B[%d;%dH", *((unsigned int *)&player + 1), player);
return drawSprite("O", (__int64)"\x1B[35m");
}

canonical_decompiled_code:
__int64 func3()
{
unsigned int *v0; // rbx
int v1; // ebp
__int64 v2; // rsi
__int64 v3; // rdx
unsigned int *v4; // rbx
int v5; // ebp
__int64 v6; // rsi
__int64 v7; // rdx

if ( numEnemies > 0 )
{
v0 = (unsigned int *)&enemies;
v1 = 0;
do
{
v2 = v0[1];
v3 = *v0;
++v1;
v0 += 5;
xt_par2("\x1B[%d;%dH", v2, v3);
func2("X", (__int64)"\x1B[32m");
}
while ( numEnemies > v1 );
}
if ( numBullets > 0 )
{
v4 = (unsigned int *)&bullets;
v5 = 0;
do
{
v6 = v4[1];
v7 = *v4;
++v5;
v4 += 5;
xt_par2("\x1B[%d;%dH", v6, v7);
func2(byte_5B8, (__int64)"\x1B[34m");
}
while ( numBullets > v5 );
}
xt_par2("\x1B[%d;%dH", *((unsigned int *)&crate + 1), crate);
func2("I", (__int64)"\x1B[33m");
xt_par2("\x1B[%d;%dH", *((unsigned int *)&player + 1), player);
return func2("O", (__int64)"\x1B[35m");
}

original_code:
void renderActors(){
 int enem;
 for(enem = 0; enem < _numEnemies; enem++){
  Actor_t mob = _enemies[enem];
  xt_par2("\033[%d;%dH", mob.geo.y, mob.geo.x);
  drawSprite("X", "\033[32m");
 }
 int bull;
 for(bull = 0; bull < _numBullets; bull++){
  Actor_t bullet = _bullets[bull];
  xt_par2("\033[%d;%dH", bullet.geo.y, bullet.geo.x);
  drawSprite("·", "\033[34m");
 }
 xt_par2("\033[%d;%dH", _crate.geo.y, _crate.geo.x);
 drawSprite("I", "\033[33m");
 xt_par2("\033[%d;%dH", _player.geo.y, _player.geo.x);
 drawSprite("O", "\033[35m");
}

canonical_original_code:
void renderActors(){
 int enem;
 for(enem = 0; enem < _numEnemies; enem++){
  struct Actor_t mob = _enemies[enem];
  xt_par2("\033[%d;%dH", mob.geo.y, mob.geo.x);
  drawSprite("X", "\033[32m");
 }
 int bull;
 for(bull = 0; bull < _numBullets; bull++){
  struct Actor_t bullet = _bullets[bull];
  xt_par2("\033[%d;%dH", bullet.geo.y, bullet.geo.x);
  drawSprite("·", "\033[34m");
 }
 xt_par2("\033[%d;%dH", _crate.geo.y, _crate.geo.x);
 drawSprite("I", "\033[33m");
 xt_par2("\033[%d;%dH", _player.geo.y, _player.geo.x);
 drawSprite("O", "\033[35m");
}

variable_types: bull int


drawString

decompiled_code:
size_t __fastcall drawString(char *s, int a2, int a3)
{
int v3; // er15
int v5; // er12
unsigned __int64 v6; // rbx
size_t result; // rax
__int64 v8; // rdx

v3 = 0;
v5 = 0;
v6 = 0LL;
result = strlen(s);
while ( v6 < result )
{
if ( s[v6] == 10 )
{
++v3;
v5 = 0;
}
else
{
v8 = (unsigned int)(v5 + a2);
++v5;
xt_par2("\x1B[%d;%dH", (unsigned int)(v3 + a3), v8);
putchar(s[v6]);
result = strlen(s);
}
++v6;
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func4(char *s, int a2, int a3)
{
int v3; // er15
int v5; // er12
unsigned __int64 v6; // rbx
size_t result; // rax
__int64 v8; // rdx

v3 = 0;
v5 = 0;
v6 = 0LL;
result = strlen(s);
while ( v6 < result )
{
if ( s[v6] == 10 )
{
++v3;
v5 = 0;
}
else
{
v8 = (unsigned int)(v5 + a2);
++v5;
xt_par2("\x1B[%d;%dH", (unsigned int)(v3 + a3), v8);
putchar(s[v6]);
result = strlen(s);
}
++v6;
}
return result;
}

original_code:
void drawString(char * text, int x, int y) {
 int row = 0, col = 0 , len = 0;
 while(len < strlen(text)) {
  if(text[len] == '\n'){
   row++;
   col = 0;
  } else {
   xt_par2("\033[%d;%dH", y + row, x + col);
   printf("%c", text[len]);
   col++;
  }
  len++;
 }
}

canonical_original_code:
void drawString(char *text, int x, int y) {
 int row = 0; int col = 0; int len = 0;
 while(len < strlen(text)) {
  if(text[len] == '\n'){
   row++;
   col = 0;
  } else {
   xt_par2("\033[%d;%dH", y + row, x + col);
   printf("%c", text[len]);
   col++;
  }
  len++;
 }
}

variable_types:
text
char *

variable_types: x int

variable_types: y int

variable_types: col int

variable_types: len int


renderScore

original_code:
void renderScore(){
 int score = _player.score;
 int numDig = (int)log10(score) + 1;
 int dig;
 xt_par0("\033[37m");
 for(dig = numDig - 1; dig >= 0; dig--){
  int xPos = 176 / 2 + numDig * 5 / 2 - (numDig - dig - 1) * 5;
  drawString(_numberSprites[score % 10], xPos, 44 * 0.1);
  score /= 10;
 }
 xt_par0("\033[0m");
}

variable_types: score int

variable_types: numDig int

variable_types: dig int

variable_types: xPos int


drawMessage

original_code:
void drawMessage(Message_t * message) {
    xt_par0("\033[1m");
    xt_par0("\033[31m");
    drawString(message->text, message->geo.x, message->geo.y);
    message->display -= 1;
    xt_par0("\033[0m");
}

canonical_original_code:
void drawMessage(struct Message_t *message) {
    xt_par0("\033[1m");
    xt_par0("\033[31m");
    drawString(message->text, message->geo.x, message->geo.y);
    message->display -= 1;
    xt_par0("\033[0m");
}

variable_types: struct Message_t { char *text; int display; struct Geometry_t { int x; } geo; } *

user_defined_types: struct Message_t { char *text; int display; struct Geometry_t geo; }


renderMessages

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

if ( messages[2] )
{
drawMessage((__int64)messages);
if ( !messages[8] )
{
LABEL_3:
result = messages[14];
if ( !(_DWORD)result )
return result;
return drawMessage((unsigned int)((_DWORD)messages + 48));
}
}
else if ( !messages[8] )
{
goto LABEL_3;
}
drawMessage((unsigned int)((_DWORD)messages + 24));
result = messages[14];
if ( (_DWORD)result )
return drawMessage((unsigned int)((_DWORD)messages + 48));
return result;
}

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

if ( messages[2] )
{
func6((__int64)messages);
if ( !messages[8] )
{
LABEL_3:
result = messages[14];
if ( !(_DWORD)result )
return result;
return func6((unsigned int)((_DWORD)messages + 48));
}
}
else if ( !messages[8] )
{
goto LABEL_3;
}
func6((unsigned int)((_DWORD)messages + 24));
result = messages[14];
if ( (_DWORD)result )
return func6((unsigned int)((_DWORD)messages + 48));
return result;
}

original_code:
void renderMessages() {
 if(_messages[0].display) {
  drawMessage(&_messages[0]);
 }
 if(_messages[1].display) {
  drawMessage(&_messages[1]);
 }
 if(_messages[2].display) {
  drawMessage(&_messages[2]);
 }
}


resetCursor

decompiled_code:
__int64 resetCursor()
{
return xt_par2("\x1B[%d;%dH", 1LL, 1LL);
}

canonical_decompiled_code:
__int64 func8()
{
return xt_par2("\x1B[%d;%dH", 1LL, 1LL);
}

original_code:
void resetCursor(){
 xt_par2("\033[%d;%dH", 1, 1);
}


clearScreen

decompiled_code:
__int64 clearScreen()
{
resetCursor();
return xt_par0("\x1B[2J");
}

canonical_decompiled_code:
__int64 func9()
{
func8();
return xt_par0("\x1B[2J");
}

original_code:
void clearScreen(){
 resetCursor();
 xt_par0("\033[2J");
}


renderMenu

variable_types: button int

variable_types: struct Button_t { int x; int num; char name[10]; }


render

decompiled_code:
__int64 render()
{
clearScreen();
renderMap();
renderActors();
renderScore();
renderMessages();
return resetCursor();
}

canonical_decompiled_code:
__int64 func11()
{
func9();
func0();
func3();
func5();
func7();
return func8();
}

original_code:
void render(){
 clearScreen();
 renderMap();
 renderActors();
 renderScore();
 renderMessages();
 resetCursor();
}


loadWeapons

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

weapons[0] = elements[12];
weapons[1] = 0x1E00000014LL;
result = 0x200000064LL;
weapons[2] = 0x200000064LL;
return result;
}

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

weapons[0] = elements[12];
weapons[1] = 0x1E00000014LL;
result = 0x200000064LL;
weapons[2] = 0x200000064LL;
return result;
}

original_code:
void loadWeapons(){
 Weapon_t shotgun = { .ammo = 20, .rof = 30 };
 Weapon_t machineGun = { .ammo = 100, .rof = 2 };
 _weapons[0] = _elements.pistol;
 _weapons[1] = shotgun;
 _weapons[2] = machineGun;
}

canonical_original_code:
void loadWeapons(){
 struct Weapon_t shotgun = { .ammo = 20, .rof = 30 };
 struct Weapon_t machineGun = { .ammo = 100, .rof = 2 };
 _weapons[0] = _elements.pistol;
 _weapons[1] = shotgun;
 _weapons[2] = machineGun;
}

variable_types:
shotgun
struct Weapon_t { int ammo; }

variable_types:
machineGun
struct Weapon_t { int ammo; }


loadElements

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

elements[2] = 0xA00000001LL;
elements[3] = 0x100000005LL;
elements[8] = 0x100000005LL;
result = 0xF000F4240LL;
elements[0] = 0x50000000ALL;
elements[1] = 0x100000001LL;
elements[4] = 0x100000001LL;
elements[5] = 0x50000000ALL;
elements[6] = 0xF424000000001LL;
elements[7] = 0xA0000000FLL;
elements[9] = 0xF000F4240LL;
elements[10] = 1LL;
elements[11] = 0LL;
elements[12] = 0xF000F4240LL;
return result;
}

original_code:
void loadElements(){
 Geometry_t geo = {
  .x = 10,
  .y = 5,
  .rad = 1
 };
 Actor_t actor = {
  .geo = geo,
  .dirMotion = 1,
  .alive = 1
 };
 Weapon_t pistol = { .ammo = 1000000, .rof = 15 };
 Crate_t crate = { .geo = geo, .weapon = pistol};
 Player_t player = {
  .geo = geo,
  .dirMotion = 1,
  .jumpTime = 0,
  .weapon = pistol,
  .score = 0
 };
 _elements.enemy = actor;
 _elements.bullet = actor;
 _elements.crate = crate;
 _elements.player = player;
 _elements.pistol = pistol;
}

canonical_original_code:
void loadElements(){
 struct Geometry_t geo = {
  .x = 10,
  .y = 5,
  .rad = 1
 };
 struct Actor_t actor = {
  .geo = geo,
  .dirMotion = 1,
  .alive = 1
 };
 struct Weapon_t pistol = { .ammo = 1000000, .rof = 15 };
 struct Crate_t crate = { .geo = geo, .weapon = pistol};
 struct Player_t player = {
  .geo = geo,
  .dirMotion = 1,
  .jumpTime = 0,
  .weapon = pistol,
  .score = 0
 };
 _elements.enemy = actor;
 _elements.bullet = actor;
 _elements.crate = crate;
 _elements.player = player;
 _elements.pistol = pistol;
}

variable_types:
geo
struct Geometry_t { int x; }

variable_types: struct Actor_t { struct Geometry_t { int x; } geo; int dirMotion; }

variable_types:
pistol
struct Weapon_t { int ammo; }

variable_types: struct Crate_t { struct Geometry_t { int x; } geo; struct Weapon_t { int ammo; } weapon; }

variable_types: struct Player_t { struct Geometry_t { int x; } geo; struct Weapon_t { int ammo; } weapon; int dirMotion; int reload; int jumpTime; int score; }

user_defined_types: struct Crate_t { struct Geometry_t geo; struct Weapon_t weapon; }

user_defined_types: struct Player_t { struct Geometry_t geo; struct Weapon_t weapon; int dirMotion; int reload; int jumpTime; int score; }


loadMessages

variable_types: struct Message_t { char *text; int display; struct Geometry_t { int x; } geo; }


config

decompiled_code:
__int64 config()
{
int v0; // eax
__m128i v1; // xmm0
__m128i v2; // xmm1
__m128i v3; // xmm2
int v4; // eax

numEnemies = 0;
numBullets = 0;
gameLost = 0;
tickCount = 0;
loadMap();
loadElements();
loadWeapons();
loadMessages();
loadNumbers();
v0 = HIDWORD(elements[11]);
v1 = _mm_loadu_si128((const __m128i *)((char *)&elements[7] + 4));
keys[0] = 0LL;
v2 = _mm_loadu_si128((const __m128i *)((char *)&elements[9] + 4));
v3 = _mm_loadu_si128((const __m128i *)&elements[5]);
keys[1] = 0LL;
*((_DWORD *)&player + 8) = v0;
v4 = elements[7];
player = v1;
*((_DWORD *)&crate + 4) = v4;
*((__m128i *)&player + 1) = v2;
crate = v3;
resetCrate();
return audio("res/audio/themeGame.wav");
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // eax
__m128i v1; // xmm0
__m128i v2; // xmm1
__m128i v3; // xmm2
int v4; // eax

numEnemies = 0;
numBullets = 0;
gameLost = 0;
tickCount = 0;
loadMap();
func1();
func0();
func2();
func3();
v0 = HIDWORD(elements[11]);
v1 = _mm_loadu_si128((const __m128i *)((char *)&elements[7] + 4));
keys[0] = 0LL;
v2 = _mm_loadu_si128((const __m128i *)((char *)&elements[9] + 4));
v3 = _mm_loadu_si128((const __m128i *)&elements[5]);
keys[1] = 0LL;
*((_DWORD *)&player + 8) = v0;
v4 = elements[7];
player = v1;
*((_DWORD *)&crate + 4) = v4;
*((__m128i *)&player + 1) = v2;
crate = v3;
resetCrate();
return audio("res/audio/themeGame.wav");
}

original_code:
void config(){
 _numEnemies = 0;
 _numBullets = 0;
 _gameLost = 0;
 _tickCount = 0;
 loadMap();
 loadElements();
 loadWeapons();
 loadMessages();
 loadNumbers();
 _player = _elements.player;
 _crate = _elements.crate;
 Keys_t keys = { 0 };
 _keys = keys;
 resetCrate();
 audio("res/audio/" "themeGame.wav");
}

canonical_original_code:
void config(){
 _numEnemies = 0;
 _numBullets = 0;
 _gameLost = 0;
 _tickCount = 0;
 loadMap();
 loadElements();
 loadWeapons();
 loadMessages();
 loadNumbers();
 _player = _elements.player;
 _crate = _elements.crate;
 struct Keys_t keys = { 0 };
 _keys = keys;
 resetCrate();
 audio("res/audio/" "themeGame.wav");
}

variable_types:
keys
struct Keys_t { int up; int fire; }


abs

decompiled_code:
__int64 __fastcall abs(int a1)
{
return abs32(a1);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return abs32(a1);
}

original_code:
int abs(int val){
 if(val < 0)
  return val * -1;
 return val;
}

variable_types: val int


collision

decompiled_code:
_BOOL8 __fastcall collision(__int64 a1, int a2, __int64 a3, int a4)
{
int v4; // ecx
_BOOL4 v5; // er8

v4 = a2 + a4;
v5 = 0;
if ( (int)abs32(HIDWORD(a1) - HIDWORD(a3) + 1) < v4 )
v5 = (int)abs32(a1 - a3 + 1) < v4;
return v5;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1, int a2, __int64 a3, int a4)
{
int v4; // ecx
_BOOL4 v5; // er8

v4 = a2 + a4;
v5 = 0;
if ( (int)abs32(HIDWORD(a1) - HIDWORD(a3) + 1) < v4 )
v5 = (int)abs32(a1 - a3 + 1) < v4;
return v5;
}

original_code:
int collision(Geometry_t g1, Geometry_t g2){
 int sumRad = g1.rad + g2.rad;
 return abs(g1.y - g2.y + 1) < sumRad && abs(g1.x - g2.x + 1) < sumRad;
}

canonical_original_code:
int collision(struct Geometry_t g1, struct Geometry_t g2){
 int sumRad = g1.rad + g2.rad;
 return abs(g1.y - g2.y + 1) < sumRad && abs(g1.x - g2.x + 1) < sumRad;
}

variable_types: sumRad int


onSurface

decompiled_code:
_BOOL8 __fastcall onSurface(__int64 a1)
{
return mapBuf[178 * (a1 >> 32) - 1 + (int)a1] == 64;
}

original_code:
int onSurface(Geometry_t geo) {
 return mapBuf[geo.y][geo.x - 1] == '@';
}

canonical_original_code:
int onSurface(struct Geometry_t geo) {
 return mapBuf[geo.y][geo.x - 1] == '@';
}


belowSurface

decompiled_code:
_BOOL8 __fastcall belowSurface(__int64 a1)
{
return mapBuf[178 * HIDWORD(a1) - 357 + (int)a1] == 64;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(__int64 a1)
{
return mapBuf[178 * HIDWORD(a1) - 357 + (int)a1] == 64;
}

original_code:
int belowSurface(Geometry_t geo) {
 return mapBuf[geo.y - 2][geo.x - 1] == '@';
}

canonical_original_code:
int belowSurface(struct Geometry_t geo) {
 return mapBuf[geo.y - 2][geo.x - 1] == '@';
}


clearKeys

decompiled_code:
void clearKeys()
{
keys[0] = 0LL;
keys[1] = 0LL;
}

canonical_decompiled_code:
void func9()
{
keys[0] = 0LL;
keys[1] = 0LL;
}

original_code:
void clearKeys() {
 Keys_t keys = {0};
 _keys = keys;
}

canonical_original_code:
void clearKeys() {
 struct Keys_t keys = {0};
 _keys = keys;
}


expireActors

original_code:
void expireActors(Actor_t * actors, int * numAct) {
 int act;
 for(act = 0; act < *numAct; act++)
  if(!actors[act].alive) {
   int shift;
   for(shift = act; shift <= *numAct; shift++)
    actors[shift] = actors[shift + 1];
   (*numAct)--;
  }
}

canonical_original_code:
void expireActors(struct Actor_t *actors, int *numAct) {
 int act;
 for(act = 0; act < *numAct; act++)
  if(!actors[act].alive) {
   int shift;
   for(shift = act; shift <= *numAct; shift++)
    actors[shift] = actors[shift + 1];
   (*numAct)--;
  }
}

variable_types: struct Actor_t { struct Geometry_t { int x; } geo; int dirMotion; } *

variable_types:
numAct
int *

variable_types: act int

variable_types: shift int


gravity

decompiled_code:
__int64 gravity()
{
__int64 result; // rax
__int64 v1; // r8
int v2; // eax

result = (unsigned int)(-1431655765 * tickCount + 715827882);
if ( (unsigned int)result <= 0x55555554 )
{
if ( belowSurface(player) )
{
*((_DWORD *)&player + 7) = 0;
}
else
{
v2 = *((_DWORD *)&player + 7);
if ( v2 )
{
result = (unsigned int)(v2 - 1);
--*((_DWORD *)&player + 1);
*((_DWORD *)&player + 7) = result;
return result;
}
}
result = onSurface(v1);
if ( !(_DWORD)result )
++*((_DWORD *)&player + 1);
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 result; // rax
__int64 v1; // r8
int v2; // eax

result = (unsigned int)(-1431655765 * tickCount + 715827882);
if ( (unsigned int)result <= 0x55555554 )
{
if ( func8(player) )
{
*((_DWORD *)&player + 7) = 0;
}
else
{
v2 = *((_DWORD *)&player + 7);
if ( v2 )
{
result = (unsigned int)(v2 - 1);
--*((_DWORD *)&player + 1);
*((_DWORD *)&player + 7) = result;
return result;
}
}
result = func7(v1);
if ( !(_DWORD)result )
++*((_DWORD *)&player + 1);
}
return result;
}

original_code:
void gravity() {
 if(_tickCount % 3 == 0) {
  if(belowSurface(_player.geo))
   _player.jumpTime = 0;
  if(_player.jumpTime) {
   _player.geo.y -= 1;
   _player.jumpTime -= 1;
  } else if(!onSurface(_player.geo)) {
   _player.geo.y += 1;
  }
 }
}


decompiled_code:
void *__fastcall readlink_malloc(char *path)
{
void *v1; // rbp
size_t i; // rbx
int v3; // eax
void *v4; // rdi

v1 = 0LL;
for ( i = 10LL; ; i += 10LL )
{
v1 = realloc(v1, i);
v3 = readlink(path, (char *)v1, i);
if ( v3 < 0 )
break;
if ( v3 < (int)i )
return v1;
}
v4 = v1;
v1 = 0LL;
free(v4);
return v1;
}

canonical_decompiled_code:
void *__fastcall func0(char *path)
{
void *v1; // rbp
size_t i; // rbx
int v3; // eax
void *v4; // rdi

v1 = 0LL;
for ( i = 10LL; ; i += 10LL )
{
v1 = realloc(v1, i);
v3 = readlink(path, (char *)v1, i);
if ( v3 < 0 )
break;
if ( v3 < (int)i )
return v1;
}
v4 = v1;
v1 = 0LL;
free(v4);
return v1;
}

original_code:
char *readlink_malloc(const char *filename)
{
    int size = 10;
    char *buffer = ((void *)0);
    while(1)
    {
        buffer = (char*) realloc(buffer, size);
        int nchars = readlink(filename, buffer, size);
        if(nchars < 0)
        {
            free(buffer);
            return ((void *)0);
        }
        if(nchars < size)
            return buffer;
        size += 10;
    }
}

canonical_original_code:
char *readlink_malloc(char *filename)
{
    int size = 10;
    char *buffer = ((void *)0);
    while(1)
    {
        buffer = (char *) realloc(buffer, size);
        int nchars = readlink(filename, buffer, size);
        if(nchars < 0)
        {
            free(buffer);
            return ((void *)0);
        }
        if(nchars < size)
            return buffer;
        size += 10;
    }
}

variable_types:
filename
char *

variable_types: size int

variable_types:
buffer
char *

variable_types: nchars int


decompiled_code:
__int64 __fastcall create_spk(const char *a1, int a2, const char **a3)
{
return create_spk_ex(a1, a2, a3, 0LL, 0, 0);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, int a2, const char **a3)
{
return func1(a1, a2, a3, 0LL, 0, 0);
}

original_code:
short create_spk(char *outfile, int inlen, char *in[])
{
    return create_spk_ex(outfile, inlen, in, 0, 0, 0);
}

variable_types:
outfile
char *

variable_types: inlen int

variable_types:
in
char *[]

return_type: short


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
char v4; // r14
const char *v5; // rbp
__int64 v6; // rax
const char *v7; // rax
__int16 v8; // bp
__int64 *v9; // rax
__int64 *v10; // r13
const char **v11; // rbx
const char *v12; // r15
const char *v13; // rax
__int64 v14; // rax
int v15; // er12
unsigned int v16; // er12
_QWORD *v17; // r15
_QWORD *v18; // rbx
__int64 v19; // rcx
__int64 *v20; // rdi
const char *v21; // rax
unsigned __int8 v23; // [rsp+4h] [rbp-44h]
bool v24; // [rsp+Bh] [rbp-3Dh]
int v25; // [rsp+Ch] [rbp-3Ch]

if ( argc <= 2 )
goto LABEL_31;
v3 = 2LL;
v23 = 0;
v24 = strchr(argv[1], 118) != 0LL;
v4 = 0;
while ( 1 )
{
v5 = argv[v3];
if ( *v5 != 45 )
break;
if ( !strcmp(argv[v3], "--no-uid-gid") )
{
v23 = 1;
goto LABEL_4;
}
if ( !strcmp(argv[v3], "--no-mode") )
{
++v3;
v4 = 1;
if ( v3 == argc )
{
LABEL_9:
fwrite("No archive specified\n", 1uLL, 0x15uLL, stderr);
LODWORD(v6) = 1;
return v6;
}
}
else
{
fprintf(stderr, "Unknown argument %s\n", argv[v3]);
LABEL_4:
if ( ++v3 == argc )
goto LABEL_9;
}
}
v7 = argv[1];
if ( *v7 != 99 )
{
if ( *v7 != 120 )
{
v8 = 1;
fprintf(stderr, "Unknown operation %c\n", (unsigned int)*v7);
return v8 != 0;
}
v8 = extract_spk_ex(argv[v3], ".", v24, v23, v4 & 1);
if ( v8 )
{
LABEL_30:
v21 = (const char *)strerror_spk((unsigned int)v8);
fprintf(stderr, "%s\n", v21);
}
return v8 != 0;
}
v25 = v3;
if ( argc == 3 )
{
LABEL_31:
print_usage();
LODWORD(v6) = 0;
return v6;
}
v9 = (__int64 *)malloc(0x10uLL);
v10 = v9;
if ( v9 )
{
v9[1] = 0LL;
*v9 = 0LL;
if ( argc <= (int)v3 + 1 )
goto LABEL_32;
v11 = &argv[(int)v3 + 1];
do
{
v12 = *v11;
v13 = &v12[strlen(*v11) - 1];
if ( *v13 == 47 )
{
*v13 = 0;
v12 = *v11;
}
++v11;
recursive_add_to_array(v10, v12);
}
while ( v11 != &(&argv[argc - 2 - v25])[(__int64)v25 + 2] );
v14 = v10[1];
if ( v14 )
{
v15 = 0;
do
{
v14 = *(_QWORD *)(v14 + 8);
++v15;
}
while ( v14 );
}
else
{
LABEL_32:
v15 = 0;
}
v16 = v15 + 1;
v17 = malloc(8LL * (int)v16);
v18 = v17;
if ( v17 )
{
do
{
v19 = *v10;
v20 = v10;
v10 = (__int64 *)v10[1];
*v18++ = v19;
free(v20);
}
while ( v10 );
v8 = create_spk_ex(v5, v16, v17, v24, v23 & 1, v4 & 1);
free(v17);
if ( v8 )
goto LABEL_30;
return v8 != 0;
}
}
fwrite("Not enough memory available\n", 1uLL, 0x1CuLL, stderr);
LODWORD(v6) = 1;
return v6;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
char v4; // r14
const char *v5; // rbp
__int64 v6; // rax
const char *v7; // rax
__int16 v8; // bp
__int64 *v9; // rax
__int64 *v10; // r13
const char **v11; // rbx
const char *v12; // r15
const char *v13; // rax
__int64 v14; // rax
int v15; // er12
unsigned int v16; // er12
_QWORD *v17; // r15
_QWORD *v18; // rbx
__int64 v19; // rcx
__int64 *v20; // rdi
const char *v21; // rax
unsigned __int8 v23; // [rsp+4h] [rbp-44h]
bool v24; // [rsp+Bh] [rbp-3Dh]
int v25; // [rsp+Ch] [rbp-3Ch]

if ( argc <= 2 )
goto LABEL_31;
v3 = 2LL;
v23 = 0;
v24 = strchr(argv[1], 118) != 0LL;
v4 = 0;
while ( 1 )
{
v5 = argv[v3];
if ( *v5 != 45 )
break;
if ( !strcmp(argv[v3], "--no-uid-gid") )
{
v23 = 1;
goto LABEL_4;
}
if ( !strcmp(argv[v3], "--no-mode") )
{
++v3;
v4 = 1;
if ( v3 == argc )
{
LABEL_9:
fwrite("No archive specified\n", 1uLL, 0x15uLL, stderr);
LODWORD(v6) = 1;
return v6;
}
}
else
{
fprintf(stderr, "Unknown argument %s\n", argv[v3]);
LABEL_4:
if ( ++v3 == argc )
goto LABEL_9;
}
}
v7 = argv[1];
if ( *v7 != 99 )
{
if ( *v7 != 120 )
{
v8 = 1;
fprintf(stderr, "Unknown operation %c\n", (unsigned int)*v7);
return v8 != 0;
}
v8 = extract_spk_ex(argv[v3], ".", v24, v23, v4 & 1);
if ( v8 )
{
LABEL_30:
v21 = (const char *)strerror_spk((unsigned int)v8);
fprintf(stderr, "%s\n", v21);
}
return v8 != 0;
}
v25 = v3;
if ( argc == 3 )
{
LABEL_31:
func2();
LODWORD(v6) = 0;
return v6;
}
v9 = (__int64 *)malloc(0x10uLL);
v10 = v9;
if ( v9 )
{
v9[1] = 0LL;
*v9 = 0LL;
if ( argc <= (int)v3 + 1 )
goto LABEL_32;
v11 = &argv[(int)v3 + 1];
do
{
v12 = *v11;
v13 = &v12[strlen(*v11) - 1];
if ( *v13 == 47 )
{
*v13 = 0;
v12 = *v11;
}
++v11;
func1(v10, v12);
}
while ( v11 != &(&argv[argc - 2 - v25])[(__int64)v25 + 2] );
v14 = v10[1];
if ( v14 )
{
v15 = 0;
do
{
v14 = *(_QWORD *)(v14 + 8);
++v15;
}
while ( v14 );
}
else
{
LABEL_32:
v15 = 0;
}
v16 = v15 + 1;
v17 = malloc(8LL * (int)v16);
v18 = v17;
if ( v17 )
{
do
{
v19 = *v10;
v20 = v10;
v10 = (__int64 *)v10[1];
*v18++ = v19;
free(v20);
}
while ( v10 );
v8 = create_spk_ex(v5, v16, v17, v24, v23 & 1, v4 & 1);
free(v17);
if ( v8 )
goto LABEL_30;
return v8 != 0;
}
}
fwrite("Not enough memory available\n", 1uLL, 0x1CuLL, stderr);
LODWORD(v6) = 1;
return v6;
}

original_code:
int main(int argc, char *argv[])
{
    short co = 1;
    if(argc < 3)
    {
        print_usage();
        return 0;
    }
    else
    {
        _Bool verbose = (strchr(argv[1], 'v') != ((void *)0));
        _Bool no_gid_uid = 0, no_mode = 0;
        int i, archiven;
        char *archivep = ((void *)0);
        for(i = 2; i < argc; i++)
        {
            if(argv[i][0] != '-')
            {
                archivep = argv[i];
                archiven = i;
                break;
            }
            if(!strcmp(argv[i], "--no-uid-gid")) { no_gid_uid = 1; continue; }
            if(!strcmp(argv[i], "--no-mode")) { no_mode = 1; continue; }
            fprintf(stderr, "Unknown argument %s\n", argv[i]);
        }
        if(archivep == ((void *)0)) { fprintf(stderr, "No archive specified\n"); return 1; }
        switch(argv[1][0])
        {
            case 'c':
                if(argc < 4)
                {
                    print_usage();
                    return 0;
                }
                int i, len;
                ll_node *in, *cur, *tmp;
                char **arr;
                in = malloc(sizeof(ll_node));
                if(in == ((void *)0))
                {
                    fprintf(stderr, "Not enough memory available\n");
                    return 1;
                }
                in->next = ((void *)0);
                in->v = (const char*) ((void *)0);
                for(i = archiven + 1; i < argc; i++)
                {
                    if(argv[i][strlen(argv[i]) - 1] == '/') argv[i][strlen(argv[i]) - 1] = 0;
                    recursive_add_to_array(in, argv[i]);
                }
                cur = in;
                len = 0;
                while((cur = cur->next) != ((void *)0))
                    len++;
                len++;
                arr = malloc(len * sizeof(char*));
                if(arr == ((void *)0))
                {
                    fprintf(stderr, "Not enough memory available\n");
                    return 1;
                }
                cur = in;
                i = 0;
                while(cur != ((void *)0))
                {
                    arr[i] = (char*) cur->v;
                    i++;
                    tmp = cur;
                    cur = cur->next;
                    free(tmp);
                }
                co = create_spk_ex(archivep, len, arr, verbose, no_gid_uid, no_mode);
                free(arr);
                if(co != 0x00) fprintf(stderr, "%s\n", strerror_spk(co));
                break;
            case 'x':
                co = extract_spk_ex(archivep, ".", verbose, no_gid_uid, no_mode);
                if(co != 0x00) fprintf(stderr, "%s\n", strerror_spk(co));
                break;
            default:
                fprintf(stderr, "Unknown operation %c\n", argv[1][0]);
                break;
        }
    }
    return (co == 0x00)?0:1;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    short co = 1;
    if(argc < 3)
    {
        print_usage();
        return 0;
    }
    else
    {
        _Bool verbose = (strchr(argv[1], 'v') != ((void *)0));
        _Bool no_gid_uid = 0; _Bool no_mode = 0;
        int i; int archiven;
        char *archivep = ((void *)0);
        for(i = 2; i < argc; i++)
        {
            if(argv[i][0] != '-')
            {
                archivep = argv[i];
                archiven = i;
                break;
            }
            if(!strcmp(argv[i], "--no-uid-gid")) { no_gid_uid = 1; continue; }
            if(!strcmp(argv[i], "--no-mode")) { no_mode = 1; continue; }
            fprintf(stderr, "Unknown argument %s\n", argv[i]);
        }
        if(archivep == ((void *)0)) { fprintf(stderr, "No archive specified\n"); return 1; }
        switch(argv[1][0])
        {
            case 'c':
                if(argc < 4)
                {
                    print_usage();
                    return 0;
                }
                int i; int len;
                struct ll_node *in; struct ll_node *cur; struct ll_node *tmp;
                char **arr;
                in = malloc(sizeof(ll_node));
                if(in == ((void *)0))
                {
                    fprintf(stderr, "Not enough memory available\n");
                    return 1;
                }
                in->next = ((void *)0);
                in->v = (char *) ((void *)0);
                for(i = archiven + 1; i < argc; i++)
                {
                    if(argv[i][strlen(argv[i]) - 1] == '/') argv[i][strlen(argv[i]) - 1] = 0;
                    recursive_add_to_array(in, argv[i]);
                }
                cur = in;
                len = 0;
                while((cur = cur->next) != ((void *)0))
                    len++;
                len++;
                arr = malloc(len * sizeof(char *));
                if(arr == ((void *)0))
                {
                    fprintf(stderr, "Not enough memory available\n");
                    return 1;
                }
                cur = in;
                i = 0;
                while(cur != ((void *)0))
                {
                    arr[i] = (char *) cur->v;
                    i++;
                    tmp = cur;
                    cur = cur->next;
                    free(tmp);
                }
                co = create_spk_ex(archivep, len, arr, verbose, no_gid_uid, no_mode);
                free(arr);
                if(co != 0x00) fprintf(stderr, "%s\n", strerror_spk(co));
                break;
            case 'x':
                co = extract_spk_ex(archivep, ".", verbose, no_gid_uid, no_mode);
                if(co != 0x00) fprintf(stderr, "%s\n", strerror_spk(co));
                break;
            default:
                fprintf(stderr, "Unknown operation %c\n", argv[1][0]);
                break;
        }
    }
    return (co == 0x00)?0:1;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: co short

variable_types: i int

variable_types: archiven int

variable_types:
archivep
char *

variable_types: len int

variable_types: struct ll_node { char *v; struct ll_node *next; } *

variable_types:
arr
char **


decompiled_code:
__int64 __fastcall extract_spk(char *a1, char *a2)
{
return extract_spk_ex(a1, a2, 0, 0, 0);
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1, char *a2)
{
return func0(a1, a2, 0, 0, 0);
}

original_code:
short extract_spk(char *filename, char *outdir)
{
    return extract_spk_ex(filename, outdir, 0, 0, 0);
}

variable_types:
outdir
char *


stringtodouble

repo: sfeek/ballistics

decompiled_code:
__int64 __fastcall stringtodouble(char *nptr, double *a2)
{
int *v2; // rax
int *v3; // rbx
double v4; // xmm0_8
bool v5; // zf
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v2 = _errno_location();
*v2 = 0;
v3 = v2;
v4 = strtod(nptr, &endptr);
v5 = *v3 == 34;
*a2 = v4;
if ( v5 )
{
puts("\nNumber Overflow/Underflow Error!");
result = 1LL;
}
else
{
result = 0LL;
if ( endptr == nptr )
{
puts("\nInvalid Number Conversion Error!");
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *nptr, double *a2)
{
int *v2; // rax
int *v3; // rbx
double v4; // xmm0_8
bool v5; // zf
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v2 = _errno_location();
*v2 = 0;
v3 = v2;
v4 = strtod(nptr, &endptr);
v5 = *v3 == 34;
*a2 = v4;
if ( v5 )
{
puts("\nNumber Overflow/Underflow Error!");
result = 1LL;
}
else
{
result = 0LL;
if ( endptr == nptr )
{
puts("\nInvalid Number Conversion Error!");
result = 1LL;
}
}
return result;
}

original_code:
int stringtodouble (const char *str, double *v)
{
 char *ptr;
 (*__errno_location ()) = 0;
 *v = strtod (str, &ptr);
 if ((*__errno_location ()) == 34)
 {
  printf ("\nNumber Overflow/Underflow Error!\n");
  return 1;
 }
 if (str == ptr)
 {
  printf ("\nInvalid Number Conversion Error!\n");
  return 1;
 }
 return 0;
}

canonical_original_code:
int stringtodouble(char *str, double *v)
{
 char *ptr;
 (*__errno_location ()) = 0;
 *v = strtod (str, &ptr);
 if ((*__errno_location ()) == 34)
 {
  printf ("\nNumber Overflow/Underflow Error!\n");
  return 1;
 }
 if (str == ptr)
 {
  printf ("\nInvalid Number Conversion Error!\n");
  return 1;
 }
 return 0;
}

variable_types:
str
char *

variable_types:
v
double *

variable_types:
ptr
char *


stringtoint

decompiled_code:
__int64 __fastcall stringtoint(char *nptr, _DWORD *a2)
{
int *v2; // rax
int *v3; // rbx
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v2 = _errno_location();
*v2 = 0;
v3 = v2;
*a2 = strtol(nptr, &endptr, 10);
if ( *v3 == 34 )
{
puts("\nNumber Overflow/Underflow Error!");
result = 1LL;
}
else
{
result = 0LL;
if ( endptr == nptr )
{
puts("\nInvalid Number Conversion Error!");
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *nptr, _DWORD *a2)
{
int *v2; // rax
int *v3; // rbx
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v2 = _errno_location();
*v2 = 0;
v3 = v2;
*a2 = strtol(nptr, &endptr, 10);
if ( *v3 == 34 )
{
puts("\nNumber Overflow/Underflow Error!");
result = 1LL;
}
else
{
result = 0LL;
if ( endptr == nptr )
{
puts("\nInvalid Number Conversion Error!");
result = 1LL;
}
}
return result;
}

original_code:
int stringtoint (const char *str, int *v)
{
 char *ptr;
 (*__errno_location ()) = 0;
 *v = (int) strtol (str, &ptr, 10);
 if ((*__errno_location ()) == 34)
 {
  printf ("\nNumber Overflow/Underflow Error!\n");
  return 1;
 }
 if (str == ptr)
 {
  printf ("\nInvalid Number Conversion Error!\n");
  return 1;
 }
 return 0;
}

canonical_original_code:
int stringtoint(char *str, int *v)
{
 char *ptr;
 (*__errno_location ()) = 0;
 *v = (int) strtol (str, &ptr, 10);
 if ((*__errno_location ()) == 34)
 {
  printf ("\nNumber Overflow/Underflow Error!\n");
  return 1;
 }
 if (str == ptr)
 {
  printf ("\nInvalid Number Conversion Error!\n");
  return 1;
 }
 return 0;
}

variable_types:
v
int *


getdouble

decompiled_code:
double __fastcall getdouble(const char *a1)
{
char *v1; // rbp
int v2; // ebx
double v4[4]; // [rsp+8h] [rbp-20h] BYREF

do
{
v1 = getstring(a1);
v2 = stringtodouble(v1, v4);
free(v1);
}
while ( v2 );
return v4[0];
}

canonical_decompiled_code:
double __fastcall func3(const char *a1)
{
char *v1; // rbp
int v2; // ebx
double v4[4]; // [rsp+8h] [rbp-20h] BYREF

do
{
v1 = func0(a1);
v2 = func1(v1, v4);
free(v1);
}
while ( v2 );
return v4[0];
}

original_code:
double getdouble (const char *display)
{
 char *buffer;
 double value;
 int rtn;
 while (1)
 {
  buffer = getstring (display);
  rtn = stringtodouble (buffer, &value);
  free (buffer);
  if (rtn == 0)
   return value;
 }
}

canonical_original_code:
double getdouble(char *display)
{
 char *buffer;
 double value;
 int rtn;
 while (1)
 {
  buffer = getstring (display);
  rtn = stringtodouble (buffer, &value);
  free (buffer);
  if (rtn == 0)
   return value;
 }
}

variable_types:
display
char *

variable_types:
buffer
char *

variable_types: value double

variable_types: rtn int

return_type: double


getint

decompiled_code:
__int64 __fastcall getint(const char *a1)
{
char *v1; // rbp
int v2; // ebx
unsigned int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

do
{
v1 = getstring(a1);
v2 = stringtoint(v1, v4);
free(v1);
}
while ( v2 );
return v4[0];
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
char *v1; // rbp
int v2; // ebx
unsigned int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

do
{
v1 = func0(a1);
v2 = func2(v1, v4);
free(v1);
}
while ( v2 );
return v4[0];
}

original_code:
int getint (const char *display)
{
 char *buffer;
 int value;
 int rtn;
 while (1)
 {
  buffer = getstring (display);
  rtn = stringtoint (buffer, &value);
  free (buffer);
  if (rtn == 0)
   return value;
 }
}

canonical_original_code:
int getint(char *display)
{
 char *buffer;
 int value;
 int rtn;
 while (1)
 {
  buffer = getstring (display);
  rtn = stringtoint (buffer, &value);
  free (buffer);
  if (rtn == 0)
   return value;
 }
}

variable_types: value int


repo: sfeek/plogger

decompiled_code:
void signal_handler_IO()
{
wait_flag = 0;
}

canonical_decompiled_code:
void func7()
{
wait_flag = 0;
}

original_code:
void signal_handler_IO (int status)
{
 wait_flag = 0;
}

canonical_original_code:
void signal_handler_IO(int status)
{
 wait_flag = 0;
}

variable_types: status int


getkey

decompiled_code:
__int64 getkey()
{
int v0; // eax
__m128i v1; // xmm0
__m128i v2; // xmm1
__m128i v3; // xmm2
int v4; // eax
unsigned int v5; // er12
int v6; // eax
struct termios v8; // [rsp+0h] [rbp-88h] BYREF
struct termios termios_p; // [rsp+40h] [rbp-48h] BYREF

v0 = fileno(stdin);
tcgetattr(v0, &v8);
v1 = _mm_loadu_si128((const __m128i *)&v8);
v2 = _mm_loadu_si128((const __m128i *)&v8.c_line);
v3 = _mm_loadu_si128((const __m128i *)&v8.c_cc[15]);
*(_QWORD *)&termios_p.c_cc[31] = *(_QWORD *)&v8.c_cc[31];
*(__m128i *)&termios_p.c_iflag = v1;
termios_p.c_ospeed = v8.c_ospeed;
*(__m128i *)&termios_p.c_line = v2;
*(__m128i *)&termios_p.c_cc[15] = v3;
termios_p.c_lflag = v1.m128i_i32[3] & 0xFFFFFFF5;
*(_WORD *)&termios_p.c_cc[5] = 0;
v4 = fileno(stdin);
tcsetattr(v4, 0, &termios_p);
v5 = fgetc(stdin);
v6 = fileno(stdin);
tcsetattr(v6, 0, &v8);
return v5;
}

canonical_decompiled_code:
__int64 func8()
{
int v0; // eax
__m128i v1; // xmm0
__m128i v2; // xmm1
__m128i v3; // xmm2
int v4; // eax
unsigned int v5; // er12
int v6; // eax
struct termios v8; // [rsp+0h] [rbp-88h] BYREF
struct termios termios_p; // [rsp+40h] [rbp-48h] BYREF

v0 = fileno(stdin);
tcgetattr(v0, &v8);
v1 = _mm_loadu_si128((const __m128i *)&v8);
v2 = _mm_loadu_si128((const __m128i *)&v8.c_line);
v3 = _mm_loadu_si128((const __m128i *)&v8.c_cc[15]);
*(_QWORD *)&termios_p.c_cc[31] = *(_QWORD *)&v8.c_cc[31];
*(__m128i *)&termios_p.c_iflag = v1;
termios_p.c_ospeed = v8.c_ospeed;
*(__m128i *)&termios_p.c_line = v2;
*(__m128i *)&termios_p.c_cc[15] = v3;
termios_p.c_lflag = v1.m128i_i32[3] & 0xFFFFFFF5;
*(_WORD *)&termios_p.c_cc[5] = 0;
v4 = fileno(stdin);
tcsetattr(v4, 0, &termios_p);
v5 = fgetc(stdin);
v6 = fileno(stdin);
tcsetattr(v6, 0, &v8);
return v5;
}

original_code:
int getkey()
{
 int character;
 struct termios orig_term_attr;
 struct termios new_term_attr;
 tcgetattr (fileno (stdin), &orig_term_attr);
 memcpy (&new_term_attr, &orig_term_attr, sizeof (struct termios));
 new_term_attr.c_lflag &= ~ (0000010 | 0000002);
 new_term_attr.c_cc[5] = 0;
 new_term_attr.c_cc[6] = 0;
 tcsetattr (fileno (stdin), 0, &new_term_attr);
 character = fgetc (stdin);
 tcsetattr (fileno (stdin), 0, &orig_term_attr);
 return character;
}

variable_types: character int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


stringtodouble

repo: sfeek/rfassistant


showfrequency

original_code:
void showfrequency (double v)
{
 double a = fabs (v);
 if (a >= 1e9)
 {
  printf ("%3.3f GHz", v / 1e9);
  return;
 }
 if (a >= 1e6)
 {
  printf ("%3.3f MHz", v / 1e6);
  return;
 }
 if (a >= 1e3)
 {
  printf ("%3.3f KHz", v / 1e3);
  return;
 }
 printf ("%3.3f Hz", v);
 return;
}

canonical_original_code:
void showfrequency(double v)
{
 double a = fabs (v);
 if (a >= 1e9)
 {
  printf ("%3.3f GHz", v / 1e9);
  return;
 }
 if (a >= 1e6)
 {
  printf ("%3.3f MHz", v / 1e6);
  return;
 }
 if (a >= 1e3)
 {
  printf ("%3.3f KHz", v / 1e3);
  return;
 }
 printf ("%3.3f Hz", v);
 return;
}

variable_types: v double

variable_types: a double


showcapacitance

original_code:
void showcapacitance (double v)
{
 double a = fabs (v);
 if (a >= 1e0)
 {
  printf ("%3.3f F", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mF", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μF", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nF", v / 1e-9);
  return;
 }
 if (a >= 1e-12)
 {
  printf ("%3.3f pF", v / 1e-12);
  return;
 }
 printf ("%e F", v);
 return;
}

canonical_original_code:
void showcapacitance(double v)
{
 double a = fabs (v);
 if (a >= 1e0)
 {
  printf ("%3.3f F", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mF", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μF", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nF", v / 1e-9);
  return;
 }
 if (a >= 1e-12)
 {
  printf ("%3.3f pF", v / 1e-12);
  return;
 }
 printf ("%e F", v);
 return;
}


showinductance

original_code:
void showinductance (double v)
{
 double a = fabs (v);
 if (a >= 1e0)
 {
  printf ("%3.3f H", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mH", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μH", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nH", v / 1e-9);
  return;
 }
 if (a >= 1e-12)
 {
  printf ("%3.3f pH", v / 1e-12);
  return;
 }
 printf ("%e H", v);
 return;
}

canonical_original_code:
void showinductance(double v)
{
 double a = fabs (v);
 if (a >= 1e0)
 {
  printf ("%3.3f H", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mH", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μH", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nH", v / 1e-9);
  return;
 }
 if (a >= 1e-12)
 {
  printf ("%3.3f pH", v / 1e-12);
  return;
 }
 printf ("%e H", v);
 return;
}


showresistance

original_code:
void showresistance (double v)
{
 double a = fabs (v);
 if (a >= 1e9)
 {
  printf ("%3.3f GΩ", v / 1e9);
  return;
 }
 if (a >= 1e6)
 {
  printf ("%3.3f MΩ", v / 1e6);
  return;
 }
 if (a >= 1e3)
 {
  printf ("%3.3f KΩ", v / 1e3);
  return;
 }
 if (a >= 1e0)
 {
  printf ("%3.3f Ω ", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mΩ", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μΩ", v / 1e-6);
  return;
 }
 printf ("%e Ω", v);
 return;
}

canonical_original_code:
void showresistance(double v)
{
 double a = fabs (v);
 if (a >= 1e9)
 {
  printf ("%3.3f GΩ", v / 1e9);
  return;
 }
 if (a >= 1e6)
 {
  printf ("%3.3f MΩ", v / 1e6);
  return;
 }
 if (a >= 1e3)
 {
  printf ("%3.3f KΩ", v / 1e3);
  return;
 }
 if (a >= 1e0)
 {
  printf ("%3.3f Ω ", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mΩ", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μΩ", v / 1e-6);
  return;
 }
 printf ("%e Ω", v);
 return;
}


showpower

original_code:
void showpower (double v)
{
 double a = fabs (v);
 if (a >= 1e9)
 {
  printf ("%3.3f GW", v / 1e9);
  return;
 }
 if (a >= 1e6)
 {
  printf ("%3.3f MW", v / 1e6);
  return;
 }
 if (a >= 1e3)
 {
  printf ("%3.3f KW", v / 1e3);
  return;
 }
 if (a >= 1e0)
 {
  printf ("%3.3f W", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mW", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μW", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nW", v / 1e-9);
  return;
 }
 if (a >= 1e-12)
 {
  printf ("%3.3f pW", v / 1e-12);
  return;
 }
 printf ("%e W", v);
 return;
}

canonical_original_code:
void showpower(double v)
{
 double a = fabs (v);
 if (a >= 1e9)
 {
  printf ("%3.3f GW", v / 1e9);
  return;
 }
 if (a >= 1e6)
 {
  printf ("%3.3f MW", v / 1e6);
  return;
 }
 if (a >= 1e3)
 {
  printf ("%3.3f KW", v / 1e3);
  return;
 }
 if (a >= 1e0)
 {
  printf ("%3.3f W", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mW", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μW", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nW", v / 1e-9);
  return;
 }
 if (a >= 1e-12)
 {
  printf ("%3.3f pW", v / 1e-12);
  return;
 }
 printf ("%e W", v);
 return;
}


showvoltage

original_code:
void showvoltage (double v)
{
 double a = fabs (v);
 if (a >= 1e6)
 {
  printf ("%3.3f MV", v / 1e6);
  return;
 }
 if (a >= 1e3)
 {
  printf ("%3.3f KV", v / 1e3);
  return;
 }
 if (a >= 1e0)
 {
  printf ("%3.3f V", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mV", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μV", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nV", v / 1e-9);
  return;
 }
 printf ("%e V", v);
 return;
}

canonical_original_code:
void showvoltage(double v)
{
 double a = fabs (v);
 if (a >= 1e6)
 {
  printf ("%3.3f MV", v / 1e6);
  return;
 }
 if (a >= 1e3)
 {
  printf ("%3.3f KV", v / 1e3);
  return;
 }
 if (a >= 1e0)
 {
  printf ("%3.3f V", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mV", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μV", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nV", v / 1e-9);
  return;
 }
 printf ("%e V", v);
 return;
}


showamperage

original_code:
void showamperage (double v)
{
 double a = fabs (v);
 if (a >= 1e3)
 {
  printf ("%3.3f KA", v / 1e3);
  return;
 }
 if (a >= 1e0)
 {
  printf ("%3.3f A", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mA", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μA", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nA", v / 1e-9);
  return;
 }
 printf ("%e A", v);
 return;
}

canonical_original_code:
void showamperage(double v)
{
 double a = fabs (v);
 if (a >= 1e3)
 {
  printf ("%3.3f KA", v / 1e3);
  return;
 }
 if (a >= 1e0)
 {
  printf ("%3.3f A", v);
  return;
 }
 if (a >= 1e-3)
 {
  printf ("%3.3f mA", v / 1e-3);
  return;
 }
 if (a >= 1e-6)
 {
  printf ("%3.3f μA", v / 1e-6);
  return;
 }
 if (a >= 1e-9)
 {
  printf ("%3.3f nA", v / 1e-9);
  return;
 }
 printf ("%e A", v);
 return;
}


getfrequency

decompiled_code:
double __fastcall getfrequency(const char *a1)
{
int v1; // eax
double result; // xmm0_8
double v3; // [rsp+8h] [rbp-10h]

while ( 1 )
{
v3 = getdouble(a1);
v1 = getint("\n1)Hz 2)KHz 3)MHz 4)GHz : ");
result = v3;
if ( v1 == 3 )
break;
if ( v1 > 3 )
{
if ( v1 == 4 )
return v3 * 1000000000.0;
}
else
{
if ( v1 == 1 )
return result;
if ( v1 == 2 )
return v3 * 1000.0;
}
}
return v3 * 1000000.0;
}

canonical_decompiled_code:
double __fastcall func12(const char *a1)
{
int v1; // eax
double result; // xmm0_8
double v3; // [rsp+8h] [rbp-10h]

while ( 1 )
{
v3 = func3(a1);
v1 = func4("\n1)Hz 2)KHz 3)MHz 4)GHz : ");
result = v3;
if ( v1 == 3 )
break;
if ( v1 > 3 )
{
if ( v1 == 4 )
return v3 * 1000000000.0;
}
else
{
if ( v1 == 1 )
return result;
if ( v1 == 2 )
return v3 * 1000.0;
}
}
return v3 * 1000000.0;
}

original_code:
double getfrequency (const char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)Hz  2)KHz  3)MHz  4)GHz : ");
  switch (i)
  {
   case 1:
    return v;
   case 2:
    return v * 1e3;
   case 3:
    return v * 1e6;
   case 4:
    return v * 1e9;
  }
 }
}

canonical_original_code:
double getfrequency(char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)Hz  2)KHz  3)MHz  4)GHz : ");
  switch (i)
  {
   case 1:
    return v;
   case 2:
    return v * 1e3;
   case 3:
    return v * 1e6;
   case 4:
    return v * 1e9;
  }
 }
}

variable_types: i int


getcapacitance

decompiled_code:
double __fastcall getcapacitance(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = getdouble(a1);
switch ( (unsigned int)getint(a1F2Mf3) )
{
case 1u:
return result;
case 2u:
result = result * 0.001;
break;
case 3u:
result = result * 0.000001;
break;
case 4u:
result = result * 0.000000001;
break;
case 5u:
result = result * 1.0e-12;
break;
default:
continue;
}
break;
}
return result;
}

canonical_decompiled_code:
double __fastcall func13(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = func3(a1);
switch ( (unsigned int)func4(a1F2Mf3) )
{
case 1u:
return result;
case 2u:
result = result * 0.001;
break;
case 3u:
result = result * 0.000001;
break;
case 4u:
result = result * 0.000000001;
break;
case 5u:
result = result * 1.0e-12;
break;
default:
continue;
}
break;
}
return result;
}

original_code:
double getcapacitance (const char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)F  2)mF  3)μF  4)nF  5)pF : ");
  switch (i)
  {
   case 1:
    return v;
   case 2:
    return v * 1e-3;
   case 3:
    return v * 1e-6;
   case 4:
    return v * 1e-9;
   case 5:
    return v * 1e-12;
  }
 }
}

canonical_original_code:
double getcapacitance(char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)F  2)mF  3)μF  4)nF  5)pF : ");
  switch (i)
  {
   case 1:
    return v;
   case 2:
    return v * 1e-3;
   case 3:
    return v * 1e-6;
   case 4:
    return v * 1e-9;
   case 5:
    return v * 1e-12;
  }
 }
}


getinductance

decompiled_code:
double __fastcall getinductance(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = getdouble(a1);
switch ( (unsigned int)getint(a1H2Mh3) )
{
case 1u:
return result;
case 2u:
result = result * 0.001;
break;
case 3u:
result = result * 0.000001;
break;
case 4u:
result = result * 0.000000001;
break;
case 5u:
result = result * 1.0e-12;
break;
default:
continue;
}
break;
}
return result;
}

canonical_decompiled_code:
double __fastcall func14(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = func3(a1);
switch ( (unsigned int)func4(a1H2Mh3) )
{
case 1u:
return result;
case 2u:
result = result * 0.001;
break;
case 3u:
result = result * 0.000001;
break;
case 4u:
result = result * 0.000000001;
break;
case 5u:
result = result * 1.0e-12;
break;
default:
continue;
}
break;
}
return result;
}

original_code:
double getinductance (const char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)H  2)mH  3)μH  4)nH  5)pH : ");
  switch (i)
  {
   case 1:
    return v;
   case 2:
    return v * 1e-3;
   case 3:
    return v * 1e-6;
   case 4:
    return v * 1e-9;
   case 5:
    return v * 1e-12;
  }
 }
}

canonical_original_code:
double getinductance(char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)H  2)mH  3)μH  4)nH  5)pH : ");
  switch (i)
  {
   case 1:
    return v;
   case 2:
    return v * 1e-3;
   case 3:
    return v * 1e-6;
   case 4:
    return v * 1e-9;
   case 5:
    return v * 1e-12;
  }
 }
}


getresistance

decompiled_code:
double __fastcall getresistance(const char *a1)
{
int v1; // eax
double result; // xmm0_8
double v3; // [rsp+8h] [rbp-10h]

while ( 1 )
{
v3 = getdouble(a1);
v1 = getint(a1M);
result = v3;
if ( v1 == 3 )
break;
if ( v1 > 3 )
{
if ( v1 == 4 )
return v3 * 0.001;
}
else
{
if ( v1 == 1 )
return v3 * 1000000.0;
if ( v1 == 2 )
return v3 * 1000.0;
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func15(const char *a1)
{
int v1; // eax
double result; // xmm0_8
double v3; // [rsp+8h] [rbp-10h]

while ( 1 )
{
v3 = func3(a1);
v1 = func4(a1M);
result = v3;
if ( v1 == 3 )
break;
if ( v1 > 3 )
{
if ( v1 == 4 )
return v3 * 0.001;
}
else
{
if ( v1 == 1 )
return v3 * 1000000.0;
if ( v1 == 2 )
return v3 * 1000.0;
}
}
return result;
}

original_code:
double getresistance (const char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)MΩ  2)KΩ  3)Ω  4)mΩ : ");
  switch (i)
  {
   case 1:
    return v * 1e6;
   case 2:
    return v * 1e3;
   case 3:
    return v;
   case 4:
    return v * 1e-3;
  }
 }
}

canonical_original_code:
double getresistance(char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)MΩ  2)KΩ  3)Ω  4)mΩ : ");
  switch (i)
  {
   case 1:
    return v * 1e6;
   case 2:
    return v * 1e3;
   case 3:
    return v;
   case 4:
    return v * 1e-3;
  }
 }
}


getpower

decompiled_code:
double __fastcall getpower(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = getdouble(a1);
switch ( (unsigned int)getint(a1Mw2Kw3W4Mw5) )
{
case 1u:
result = result * 1000000.0;
break;
case 2u:
result = result * 1000.0;
break;
case 3u:
return result;
case 4u:
result = result * 0.001;
break;
case 5u:
result = result * 0.000001;
break;
default:
continue;
}
break;
}
return result;
}

canonical_decompiled_code:
double __fastcall func16(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = func3(a1);
switch ( (unsigned int)func4(a1Mw2Kw3W4Mw5) )
{
case 1u:
result = result * 1000000.0;
break;
case 2u:
result = result * 1000.0;
break;
case 3u:
return result;
case 4u:
result = result * 0.001;
break;
case 5u:
result = result * 0.000001;
break;
default:
continue;
}
break;
}
return result;
}

original_code:
double getpower (const char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)MW  2)KW  3)W  4)mW  5)μW : ");
  switch (i)
  {
   case 1:
    return v * 1e6;
   case 2:
    return v * 1e3;
   case 3:
    return v;
   case 4:
    return v * 1e-3;
   case 5:
    return v * 1e-6;
  }
 }
}

canonical_original_code:
double getpower(char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)MW  2)KW  3)W  4)mW  5)μW : ");
  switch (i)
  {
   case 1:
    return v * 1e6;
   case 2:
    return v * 1e3;
   case 3:
    return v;
   case 4:
    return v * 1e-3;
   case 5:
    return v * 1e-6;
  }
 }
}


getvoltage

decompiled_code:
double __fastcall getvoltage(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = getdouble(a1);
switch ( (unsigned int)getint(a1Mv2Kv3V4Mv5) )
{
case 1u:
result = result * 1000000.0;
break;
case 2u:
result = result * 1000.0;
break;
case 3u:
return result;
case 4u:
result = result * 0.001;
break;
case 5u:
result = result * 0.000001;
break;
case 6u:
result = result * 0.000000001;
break;
default:
continue;
}
break;
}
return result;
}

canonical_decompiled_code:
double __fastcall func17(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = func3(a1);
switch ( (unsigned int)func4(a1Mv2Kv3V4Mv5) )
{
case 1u:
result = result * 1000000.0;
break;
case 2u:
result = result * 1000.0;
break;
case 3u:
return result;
case 4u:
result = result * 0.001;
break;
case 5u:
result = result * 0.000001;
break;
case 6u:
result = result * 0.000000001;
break;
default:
continue;
}
break;
}
return result;
}

original_code:
double getvoltage (const char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)MV  2)KV  3)V  4)mV  5)μV  6)nV: ");
  switch (i)
  {
   case 1:
    return v * 1e6;
   case 2:
    return v * 1e3;
   case 3:
    return v;
   case 4:
    return v * 1e-3;
   case 5:
    return v * 1e-6;
   case 6:
    return v * 1e-9;
  }
 }
}

canonical_original_code:
double getvoltage(char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)MV  2)KV  3)V  4)mV  5)μV  6)nV: ");
  switch (i)
  {
   case 1:
    return v * 1e6;
   case 2:
    return v * 1e3;
   case 3:
    return v;
   case 4:
    return v * 1e-3;
   case 5:
    return v * 1e-6;
   case 6:
    return v * 1e-9;
  }
 }
}


getamperage

decompiled_code:
double __fastcall getamperage(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = getdouble(a1);
switch ( (unsigned int)getint(a1Ka2A3Ma4) )
{
case 1u:
result = result * 1000.0;
break;
case 2u:
return result;
case 3u:
result = result * 0.001;
break;
case 4u:
result = result * 0.000001;
break;
case 5u:
result = result * 0.000000001;
break;
default:
continue;
}
break;
}
return result;
}

canonical_decompiled_code:
double __fastcall func18(const char *a1)
{
double result; // xmm0_8

while ( 2 )
{
result = func3(a1);
switch ( (unsigned int)func4(a1Ka2A3Ma4) )
{
case 1u:
result = result * 1000.0;
break;
case 2u:
return result;
case 3u:
result = result * 0.001;
break;
case 4u:
result = result * 0.000001;
break;
case 5u:
result = result * 0.000000001;
break;
default:
continue;
}
break;
}
return result;
}

original_code:
double getamperage (const char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)KA  2)A  3)mA  4)μA  5)nA: ");
  switch (i)
  {
   case 1:
    return v * 1e3;
   case 2:
    return v;
   case 3:
    return v * 1e-3;
   case 4:
    return v * 1e-6;
   case 5:
    return v * 1e-9;
  }
 }
}

canonical_original_code:
double getamperage(char *display)
{
 double v;
 int i;
 while (1)
 {
  v = getdouble (display);
  i = getint ("\n1)KA  2)A  3)mA  4)μA  5)nA: ");
  switch (i)
  {
   case 1:
    return v * 1e3;
   case 2:
    return v;
   case 3:
    return v * 1e-3;
   case 4:
    return v * 1e-6;
   case 5:
    return v * 1e-9;
  }
 }
}


repo: sgerin/DCT

decompiled_code:
void coef_dct()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void coef_dct(int nbe, float **table)
{
}

variable_types: nbe int

variable_types:
table
float **


dct

decompiled_code:
void dct()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void dct(int inverse,
  int nbe,
  const float *entree,
  float *sortie
  )
{
}

canonical_original_code:
void dct(int inverse, int nbe, float *entree, float *sortie)
{
}

variable_types: inverse int

variable_types:
entree
float *

variable_types:
sortie
float *