original_code:
void metadata_from_unix
    (enum metadata_classification_unix classification,
     int uid, int gid, int mode, long atime, long mtime, long ctime,
     long size, int device, int attributes,
     void (*with_metadata) (struct metadata *, void *), void *aux)
{
    struct metadata_datetime datetime[3] =
        { { mdp_last_access, { 0, 0 } },
          { mdp_last_modification, { 0, 0 } },
          { mdp_last_status_change, { 0, 0 } } };
    struct metadata_acl acl[3] =
        { { mct_owning_user, (const char *)0, 0 },
          { mct_owning_group, (const char *)0, 0 },
          { mct_default, (const char *)0, 0 } };
    struct metadata_classification_unix_type classification_unix =
        { mdt_unix, classification };
    struct metadata_attribute_integer attribute_flags =
        { mat_flags, attributes };
    struct metadata_attribute_integer attribute_user_id =
        { mat_user_id, uid };
    struct metadata_attribute_integer attribute_group_id =
        { mat_group_id, gid };
    struct metadata_attribute_integer attribute_device =
        { mat_link_device_id, device };
    struct metadata_classification *classification_a[2] =
        { (struct metadata_classification *)((void *)&classification_unix),
          (struct metadata_classification *)0 };
    struct metadata_attribute *attributes_a[5] =
        { (struct metadata_attribute *)((void *)&attribute_flags),
          (struct metadata_attribute *)((void *)&attribute_user_id),
          (struct metadata_attribute *)((void *)&attribute_group_id),
          (struct metadata_attribute *)((void *)&attribute_device),
          (struct metadata_attribute *)0 };
    struct metadata metadata =
        { 3, 0, 3,
          datetime,
          (struct metadata_relation *)0,
          acl,
          classification_a,
          attributes_a,
          (struct metadata_signature **)0 };
    datetime[0].datetime = dt_from_unix (atime);
    datetime[1].datetime = dt_from_unix (mtime);
    datetime[2].datetime = dt_from_unix (ctime);
    acl[0].access = (1 << 0x2) | ((mode & 0100) ? (1 << 0x7) : 0)
                            | ((mode & 0200) ? (1 << 0x6) : 0)
                            | ((mode & 0400) ? (1 << 0x5) : 0);
    acl[1].access = (1 << 0x2) | ((mode & 0010) ? (1 << 0x7) : 0)
                            | ((mode & 0020) ? (1 << 0x6) : 0)
                            | ((mode & 0040) ? (1 << 0x5) : 0);
    acl[2].access = (1 << 0x2) | ((mode & 0001) ? (1 << 0x7) : 0)
                            | ((mode & 0002) ? (1 << 0x6) : 0)
                            | ((mode & 0004) ? (1 << 0x5) : 0);
    with_metadata (&metadata, aux);
}

canonical_original_code:
void metadata_from_unix(enum metadata_classification_unix classification, int uid, int gid, int mode, long atime, long mtime, long ctime, long size, int device, int attributes, void (*with_metadata)(struct metadata *, void *), void *aux)
{
    struct metadata_datetime datetime[3] = { { mdp_last_access, { 0, 0 } },
          { mdp_last_modification, { 0, 0 } },
          { mdp_last_status_change, { 0, 0 } } };
    struct metadata_acl acl[3] = { { mct_owning_user, (const char *)0, 0 },
          { mct_owning_group, (const char *)0, 0 },
          { mct_default, (const char *)0, 0 } };
    struct metadata_classification_unix_type classification_unix = { mdt_unix, classification };
    struct metadata_attribute_integer attribute_flags = { mat_flags, attributes };
    struct metadata_attribute_integer attribute_user_id = { mat_user_id, uid };
    struct metadata_attribute_integer attribute_group_id = { mat_group_id, gid };
    struct metadata_attribute_integer attribute_device = { mat_link_device_id, device };
    struct metadata_classification *classification_a[2] = { (struct metadata_classification *)((void *)&classification_unix),
          (struct metadata_classification *)0 };
    struct metadata_attribute *attributes_a[5] = { (struct metadata_attribute *)((void *)&attribute_flags),
          (struct metadata_attribute *)((void *)&attribute_user_id),
          (struct metadata_attribute *)((void *)&attribute_group_id),
          (struct metadata_attribute *)((void *)&attribute_device),
          (struct metadata_attribute *)0 };
    struct metadata metadata = { 3, 0, 3,
          datetime,
          (struct metadata_relation *)0,
          acl,
          classification_a,
          attributes_a,
          (struct metadata_signature **)0 };
    datetime[0].datetime = dt_from_unix (atime);
    datetime[1].datetime = dt_from_unix (mtime);
    datetime[2].datetime = dt_from_unix (ctime);
    acl[0].access = (1 << 0x2) | ((mode & 0100) ? (1 << 0x7) : 0)
                            | ((mode & 0200) ? (1 << 0x6) : 0)
                            | ((mode & 0400) ? (1 << 0x5) : 0);
    acl[1].access = (1 << 0x2) | ((mode & 0010) ? (1 << 0x7) : 0)
                            | ((mode & 0020) ? (1 << 0x6) : 0)
                            | ((mode & 0040) ? (1 << 0x5) : 0);
    acl[2].access = (1 << 0x2) | ((mode & 0001) ? (1 << 0x7) : 0)
                            | ((mode & 0002) ? (1 << 0x6) : 0)
                            | ((mode & 0004) ? (1 << 0x5) : 0);
    with_metadata (&metadata, aux);
}

variable_types: uid int

variable_types: gid int

variable_types: mode int

variable_types: atime long

variable_types: mtime long

variable_types: ctime long

variable_types: size long

variable_types: device int

variable_types: attributes int

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:
aux
void *

variable_types: 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; } [3]

variable_types: 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; } [3]

variable_types: struct metadata_classification_unix_type { enum metadata_classification_type { mdt_unknown=0, mdt_mime=1, mdt_unix=2 } type; 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 } classification; }

variable_types: struct metadata_attribute_integer { 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; long long integer; }

variable_types: struct metadata_classification { enum metadata_classification_type { mdt_unknown=0, mdt_mime=1, mdt_unix=2 } type; } *[2]

variable_types: 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; } *[5]

user_defined_types: struct metadata_classification_unix_type { enum metadata_classification_type type; enum metadata_classification_unix classification; }

user_defined_types: struct metadata_attribute_integer { enum metadata_attribute_type type; long long integer; }

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_datetime { enum metadata_datetime_purpose purpose; struct datetime datetime; }

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_relation { enum metadata_relation_type type; char *target; }

user_defined_types: struct metadata_signature { enum metadata_signature_type type; }


repo: kyuba/curie

original_code:
void metadata_to_unix
    (struct metadata *metadata,
     enum metadata_classification_unix *classification,
     int *uid, int *gid, int *mode, long *atime, long *mtime, long *ctime,
     long *size, int *device, int *attributes)
{
    int i;
    for (i = 0; i < metadata->datetime_count; i++)
    {
        switch (metadata->datetime[i].purpose)
        {
            case mdp_last_access:
                *atime = (long)dt_to_unix (metadata->datetime[i].datetime);
                break;
            case mdp_last_modification:
                *mtime = (long)dt_to_unix (metadata->datetime[i].datetime);
                break;
            case mdp_last_status_change:
                *ctime = (long)dt_to_unix (metadata->datetime[i].datetime);
                break;
            default: break;
        }
    }
    for (i = 0; i < metadata->acl_count; i++)
    {
        struct metadata_acl *acl = metadata->acl + i;
        switch (acl->target_type)
        {
            case mct_owning_user:
                *mode = ((*mode) & ~0700)
                      | ((acl->access & (1 << 0x5)) ? 0400 : 0)
                      | ((acl->access & (1 << 0x6)) ? 0200 : 0)
                      | ((acl->access & (1 << 0x7)) ? 0100 : 0);
                break;
            case mct_owning_group:
                *mode = ((*mode) & ~0070)
                      | ((acl->access & (1 << 0x5)) ? 0040 : 0)
                      | ((acl->access & (1 << 0x6)) ? 0020 : 0)
                      | ((acl->access & (1 << 0x7)) ? 0010 : 0);
                break;
            case mct_default:
                *mode = ((*mode) & ~0007)
                      | ((acl->access & (1 << 0x5)) ? 0004 : 0)
                      | ((acl->access & (1 << 0x6)) ? 0002 : 0)
                      | ((acl->access & (1 << 0x7)) ? 0001 : 0);
                break;
            default:
                break;
        }
   }
    if (metadata->classification != (struct metadata_classification **)0)
    {
        struct metadata_classification **c = metadata->classification;
        struct metadata_classification_unix_type *cu;
        while ((*c) != (struct metadata_classification *)0)
        {
            cu = (struct metadata_classification_unix_type *)(*c);
            switch ((*c)->type)
            {
                case mdt_unix:
                    *classification = cu->classification;
                    break;
                default:
                    break;
            }
            c++;
        }
    }
    if (metadata->attribute != (struct metadata_attribute **)0)
    {
        struct metadata_attribute **a = metadata->attribute;
        struct metadata_attribute_integer *ai;
        while ((*a) != (struct metadata_attribute *)0)
        {
            ai = (struct metadata_attribute_integer *)(*a);
            switch ((*a)->type)
            {
                case mat_source_device_id:
                    *device = ai->integer;
                    break;
                case mat_user_id:
                    *uid = ai->integer;
                    break;
                case mat_group_id:
                    *gid = ai->integer;
                    break;
                case mat_flags:
                    *mode |= ((ai->integer & (1 << 0x0)) ? 0x800 : 0)
                           | ((ai->integer & (1 << 0x1)) ? 0x400 : 0)
                           | ((ai->integer & (1 << 0x2)) ? 0x200 : 0);
                    break;
                default:
                    break;
            }
            a++;
        }
    }
}

canonical_original_code:
void metadata_to_unix(struct metadata *metadata, enum metadata_classification_unix *classification, int *uid, int *gid, int *mode, long *atime, long *mtime, long *ctime, long *size, int *device, int *attributes)
{
    int i;
    for (i = 0; i < metadata->datetime_count; i++)
    {
        switch (metadata->datetime[i].purpose)
        {
            case mdp_last_access:
                *atime = (long)dt_to_unix (metadata->datetime[i].datetime);
                break;
            case mdp_last_modification:
                *mtime = (long)dt_to_unix (metadata->datetime[i].datetime);
                break;
            case mdp_last_status_change:
                *ctime = (long)dt_to_unix (metadata->datetime[i].datetime);
                break;
            default: break;
        }
    }
    for (i = 0; i < metadata->acl_count; i++)
    {
        struct metadata_acl *acl = metadata->acl + i;
        switch (acl->target_type)
        {
            case mct_owning_user:
                *mode = ((*mode) & ~0700)
                      | ((acl->access & (1 << 0x5)) ? 0400 : 0)
                      | ((acl->access & (1 << 0x6)) ? 0200 : 0)
                      | ((acl->access & (1 << 0x7)) ? 0100 : 0);
                break;
            case mct_owning_group:
                *mode = ((*mode) & ~0070)
                      | ((acl->access & (1 << 0x5)) ? 0040 : 0)
                      | ((acl->access & (1 << 0x6)) ? 0020 : 0)
                      | ((acl->access & (1 << 0x7)) ? 0010 : 0);
                break;
            case mct_default:
                *mode = ((*mode) & ~0007)
                      | ((acl->access & (1 << 0x5)) ? 0004 : 0)
                      | ((acl->access & (1 << 0x6)) ? 0002 : 0)
                      | ((acl->access & (1 << 0x7)) ? 0001 : 0);
                break;
            default:
                break;
        }
   }
    if (metadata->classification != (struct metadata_classification **)0)
    {
        struct metadata_classification **c = metadata->classification;
        struct metadata_classification_unix_type *cu;
        while ((*c) != (struct metadata_classification *)0)
        {
            cu = (struct metadata_classification_unix_type *)(*c);
            switch ((*c)->type)
            {
                case mdt_unix:
                    *classification = cu->classification;
                    break;
                default:
                    break;
            }
            c++;
        }
    }
    if (metadata->attribute != (struct metadata_attribute **)0)
    {
        struct metadata_attribute **a = metadata->attribute;
        struct metadata_attribute_integer *ai;
        while ((*a) != (struct metadata_attribute *)0)
        {
            ai = (struct metadata_attribute_integer *)(*a);
            switch ((*a)->type)
            {
                case mat_source_device_id:
                    *device = ai->integer;
                    break;
                case mat_user_id:
                    *uid = ai->integer;
                    break;
                case mat_group_id:
                    *gid = ai->integer;
                    break;
                case mat_flags:
                    *mode |= ((ai->integer & (1 << 0x0)) ? 0x800 : 0)
                           | ((ai->integer & (1 << 0x1)) ? 0x400 : 0)
                           | ((ai->integer & (1 << 0x2)) ? 0x200 : 0);
                    break;
                default:
                    break;
            }
            a++;
        }
    }
}

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: 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:
uid
int *

variable_types:
gid
int *

variable_types:
mode
int *

variable_types:
atime
long *

variable_types:
mtime
long *

variable_types:
ctime
long *

variable_types:
size
long *

variable_types:
device
int *

variable_types:
attributes
int *

variable_types: i int

variable_types: struct metadata_classification_unix_type { enum metadata_classification_type { mdt_unknown=0, mdt_mime=1, mdt_unix=2 } type; 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 } classification; } *

variable_types: struct metadata_attribute_integer { 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; long long integer; } *

return_type: void


decompiled_code:
__int64 __fastcall sx_split(_DWORD *a1, __int64 a2)
{
__int64 v2; // rsi
__int64 v3; // rbp
__int64 result; // rax
_QWORD *v5; // rbx
__int64 v6; // rbp
__int64 v7; // rax
_QWORD *v8; // rbx
__int64 v9; // rax

if ( (a2 & 1) == 0 && (*(_DWORD *)a2 == 5 || *(_DWORD *)a2 == 4) )
v2 = (unsigned int)*(char *)(a2 + 4);
else
v2 = a2 >> 3;
if ( ((unsigned __int8)a1 & 1) != 0 )
return 45LL;
if ( *a1 == 5 )
{
v8 = (_QWORD *)str_split(a1 + 1, v2);
if ( *v8 )
{
v3 = 45LL;
do
{
v9 = make_symbol();
++v8;
v3 = cons(v9, v3);
}
while ( *v8 );
return v3;
}
return 45LL;
}
if ( *a1 != 4 )
return 45LL;
v5 = (_QWORD *)str_split(a1 + 1, v2);
if ( !*v5 )
return 45LL;
v6 = 45LL;
do
{
v7 = make_string();
++v5;
result = cons(v7, v6);
v6 = result;
}
while ( *v5 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1, __int64 a2)
{
__int64 v2; // rsi
__int64 v3; // rbp
__int64 result; // rax
_QWORD *v5; // rbx
__int64 v6; // rbp
__int64 v7; // rax
_QWORD *v8; // rbx
__int64 v9; // rax

if ( (a2 & 1) == 0 && (*(_DWORD *)a2 == 5 || *(_DWORD *)a2 == 4) )
v2 = (unsigned int)*(char *)(a2 + 4);
else
v2 = a2 >> 3;
if ( ((unsigned __int8)a1 & 1) != 0 )
return 45LL;
if ( *a1 == 5 )
{
v8 = (_QWORD *)str_split(a1 + 1, v2);
if ( *v8 )
{
v3 = 45LL;
do
{
v9 = make_symbol();
++v8;
v3 = cons(v9, v3);
}
while ( *v8 );
return v3;
}
return 45LL;
}
if ( *a1 != 4 )
return 45LL;
v5 = (_QWORD *)str_split(a1 + 1, v2);
if ( !*v5 )
return 45LL;
v6 = 45LL;
do
{
v7 = make_string();
++v5;
result = cons(v7, v6);
v6 = result;
}
while ( *v5 );
return result;
}

original_code:
sexpr sx_split (sexpr item, sexpr separator)
{
    sexpr rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5));
    const char *s;
    char **set;
    int sep;
    if ((((((int_pointer)(separator)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)separator))->type == sxt_symbol)))
    {
        s = (const char *)((((((int_pointer)(separator)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)separator))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)separator))->character_data) : "#nonexistent");
        sep = (int)(s[0]);
    }
    else if ((((((int_pointer)(separator)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)separator))->type == sxt_string)))
    {
        s = (const char *)((((((int_pointer)(separator)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)separator))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)separator))->character_data) : "#nonexistent");
        sep = (int)(s[0]);
    }
    else
    {
        sep = ((int_pointer_s)(separator & (~0x7)) >> 3);
    }
    if ((((((int_pointer)(item)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)item))->type == sxt_symbol)))
    {
        s = (const char *)((((((int_pointer)(item)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)item))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)item))->character_data) : "#nonexistent");
        set = str_split (s, sep);
        while (*set != (char *)0)
        {
            rv = cons (make_symbol (*set), rv);
            set++;
        }
        return rv;
    }
    else if ((((((int_pointer)(item)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)item))->type == sxt_string)))
    {
        s = (const char *)((((((int_pointer)(item)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)item))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)item))->character_data) : "#nonexistent");
        set = str_split (s, sep);
        while (*set != (char *)0)
        {
            rv = cons (make_string (*set), rv);
            set++;
        }
        return rv;
    }
    return ((sexpr)((((int_pointer)(5)) << 3) | 0x5));
}

canonical_original_code:
unsigned long sx_split(unsigned long item, unsigned long separator)
{
    unsigned long rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5));
    char *s;
    char **set;
    int sep;
    if ((((((int_pointer)(separator)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)separator))->type == sxt_symbol)))
    {
        s = (char *)((((((int_pointer)(separator)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)separator))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)separator))->character_data) : "#nonexistent");
        sep = (int)(s[0]);
    }
    else if ((((((int_pointer)(separator)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)separator))->type == sxt_string)))
    {
        s = (char *)((((((int_pointer)(separator)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)separator))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)separator))->character_data) : "#nonexistent");
        sep = (int)(s[0]);
    }
    else
    {
        sep = ((int_pointer_s)(separator & (~0x7)) >> 3);
    }
    if ((((((int_pointer)(item)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)item))->type == sxt_symbol)))
    {
        s = (char *)((((((int_pointer)(item)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)item))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)item))->character_data) : "#nonexistent");
        set = str_split (s, sep);
        while (*set != (char *)0)
        {
            rv = cons (make_symbol (*set), rv);
            set++;
        }
        return rv;
    }
    else if ((((((int_pointer)(item)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)item))->type == sxt_string)))
    {
        s = (char *)((((((int_pointer)(item)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)item))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)item))->character_data) : "#nonexistent");
        set = str_split (s, sep);
        while (*set != (char *)0)
        {
            rv = cons (make_string (*set), rv);
            set++;
        }
        return rv;
    }
    return ((sexpr)((((int_pointer)(5)) << 3) | 0x5));
}

variable_types:
item
unsigned long

variable_types:
separator
unsigned long

variable_types:
rv
unsigned long

variable_types:
s
char *

variable_types:
set
char **

variable_types: sep int

return_type: unsigned long

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

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


original_code:
sexpr sx_merge (sexpr set, sexpr glue)
{
    sexpr t;
    const char *s;
    char **sset = (char **)0;
    while ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)set))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        if ((((((int_pointer)(t)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)t))->type == sxt_string)))
        {
            sset = str_set_add (sset, (const char *)((((((int_pointer)(t)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)t))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)t))->character_data) : "#nonexistent"));
        }
        else if ((((((int_pointer)(t)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)t))->type == sxt_symbol)))
        {
            sset = str_set_add (sset, (const char *)((((((int_pointer)(t)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)t))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)t))->character_data) : "#nonexistent"));
        }
        set = ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)set))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    if (sset == (char **)0)
    {
        return ((sexpr)((((int_pointer)(1)) << 3) | 0x5));
    }
    if ((((((int_pointer)(glue)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)glue))->type == sxt_string)))
    {
        s = (const char *)((((((int_pointer)(glue)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)glue))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)glue))->character_data) : "#nonexistent");
        return make_string (str_merge (sset, (int)(s[0])));
    }
    else if ((((((int_pointer)(glue)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)glue))->type == sxt_symbol)))
    {
        s = (const char *)((((((int_pointer)(glue)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)glue))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)glue))->character_data) : "#nonexistent");
        return make_symbol (str_merge (sset, (int)(s[0])));
    }
    return make_string (str_merge (sset, ((int_pointer_s)(glue & (~0x7)) >> 3)));
}

canonical_original_code:
unsigned long sx_merge(unsigned long set, unsigned long glue)
{
    unsigned long t;
    char *s;
    char **sset = (char **)0;
    while ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)set))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        if ((((((int_pointer)(t)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)t))->type == sxt_string)))
        {
            sset = str_set_add (sset, (char *)((((((int_pointer)(t)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)t))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)t))->character_data) : "#nonexistent"));
        }
        else if ((((((int_pointer)(t)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)t))->type == sxt_symbol)))
        {
            sset = str_set_add (sset, (char *)((((((int_pointer)(t)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)t))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)t))->character_data) : "#nonexistent"));
        }
        set = ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)set))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    if (sset == (char **)0)
    {
        return ((sexpr)((((int_pointer)(1)) << 3) | 0x5));
    }
    if ((((((int_pointer)(glue)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)glue))->type == sxt_string)))
    {
        s = (char *)((((((int_pointer)(glue)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)glue))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)glue))->character_data) : "#nonexistent");
        return make_string (str_merge (sset, (int)(s[0])));
    }
    else if ((((((int_pointer)(glue)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)glue))->type == sxt_symbol)))
    {
        s = (char *)((((((int_pointer)(glue)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)glue))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)glue))->character_data) : "#nonexistent");
        return make_symbol (str_merge (sset, (int)(s[0])));
    }
    return make_string (str_merge (sset, ((int_pointer_s)(glue & (~0x7)) >> 3)));
}

variable_types:
set
unsigned long

variable_types:
glue
unsigned long

variable_types:
t
unsigned long

variable_types:
sset
char **

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


original_code:
static sexpr sx_join_work (sexpr a, sexpr b, sexpr c, char *g)
{
    const char *s;
    int i = 0, j = 0;
    s = (((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? (const char *)((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)a))->character_data) : "#nonexistent") : (const char *)((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)a))->character_data) : "#nonexistent");
    for (j = 0; s[j]; j++) {
        g[i] = s[j];
        i++;
    }
    if ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) || (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) ? (const char *)((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)b))->character_data) : "#nonexistent") : (const char *)((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)b))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) {
            g[i] = s[j];
            i++;
        }
    }
    if ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) || (((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) ? (const char *)((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)c))->character_data) : "#nonexistent") : (const char *)((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)c))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) {
            g[i] = s[j];
            i++;
        }
    }
    g[i] = 0;
    return (((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? make_string (g) : make_symbol (g);
}

canonical_original_code:
static unsigned long sx_join_work(unsigned long a, unsigned long b, unsigned long c, char *g)
{
    char *s;
    int i = 0; int j = 0;
    s = (((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? (char *)((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)a))->character_data) : "#nonexistent") : (char *)((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)a))->character_data) : "#nonexistent");
    for (j = 0; s[j]; j++) {
        g[i] = s[j];
        i++;
    }
    if ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) || (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) ? (char *)((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)b))->character_data) : "#nonexistent") : (char *)((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)b))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) {
            g[i] = s[j];
            i++;
        }
    }
    if ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) || (((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) ? (char *)((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)c))->character_data) : "#nonexistent") : (char *)((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)c))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) {
            g[i] = s[j];
            i++;
        }
    }
    g[i] = 0;
    return (((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? make_string (g) : make_symbol (g);
}

variable_types:
a
unsigned long

variable_types:
b
unsigned long

variable_types:
c
unsigned long

variable_types:
g
char *

variable_types: j int


equalp

original_code:
sexpr equalp (sexpr a, sexpr b)
{
    if (a == b) return ((sexpr)((((int_pointer)(3)) << 3) | 0x5));
    if (!((((int_pointer)(a)) & 0x1) == 0x0) || !((((int_pointer)(b)) & 0x1) == 0x0)) return ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
    if (((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) && (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string))) || ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_symbol)) && (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol))))
    {
        struct sexpr_string_or_symbol
                *sa = (struct sexpr_string_or_symbol *)((void *)a),
                *sb = (struct sexpr_string_or_symbol *)((void *)b);
        unsigned long i;
        return (str_hash(sa->character_data, &i) ==
                str_hash(sb->character_data, &i))
                ? ((sexpr)((((int_pointer)(3)) << 3) | 0x5)) : ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
    }
    else if ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) && (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)))
    {
        return ((((sexpr)(equalp(((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)a))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))))) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))) &&
                 ((sexpr)(equalp(((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)a))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))))) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))) ?
                ((sexpr)((((int_pointer)(3)) << 3) | 0x5)) : ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
    }
    else if ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_partial *)((void *)a))->type > 127)) && (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_partial *)((void *)b))->type > 127)))
    {
        int type = ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_partial *)((void *)a))->type > 127)) ? (((struct sexpr_partial *)((void *)a))->type) : 0);
        if (type == ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_partial *)((void *)b))->type > 127)) ? (((struct sexpr_partial *)((void *)b))->type) : 0))
        {
            struct sexpr_type_descriptor *d = sx_get_descriptor (type);
            if ((d != (struct sexpr_type_descriptor *)0) &&
                (d->equalp != (void *)0))
            {
                return d->equalp (a, b);
            }
        }
    }
    return ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
}

canonical_original_code:
unsigned long equalp(unsigned long a, unsigned long b)
{
    if (a == b) return ((sexpr)((((int_pointer)(3)) << 3) | 0x5));
    if (!((((int_pointer)(a)) & 0x1) == 0x0) || !((((int_pointer)(b)) & 0x1) == 0x0)) return ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
    if (((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) && (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string))) || ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_symbol)) && (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol))))
    {
        struct sexpr_string_or_symbol *sa = (struct sexpr_string_or_symbol *)((void *)a); struct sexpr_string_or_symbol *sb = (struct sexpr_string_or_symbol *)((void *)b);
        unsigned long i;
        return (str_hash(sa->character_data, &i) ==
                str_hash(sb->character_data, &i))
                ? ((sexpr)((((int_pointer)(3)) << 3) | 0x5)) : ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
    }
    else if ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) && (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)))
    {
        return ((((sexpr)(equalp(((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)a))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))))) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))) &&
                 ((sexpr)(equalp(((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)a))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))))) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))) ?
                ((sexpr)((((int_pointer)(3)) << 3) | 0x5)) : ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
    }
    else if ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_partial *)((void *)a))->type > 127)) && (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_partial *)((void *)b))->type > 127)))
    {
        int type = ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_partial *)((void *)a))->type > 127)) ? (((struct sexpr_partial *)((void *)a))->type) : 0);
        if (type == ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_partial *)((void *)b))->type > 127)) ? (((struct sexpr_partial *)((void *)b))->type) : 0))
        {
            struct sexpr_type_descriptor *d = sx_get_descriptor (type);
            if ((d != (struct sexpr_type_descriptor *)0) &&
                (d->equalp != (void *)0))
            {
                return d->equalp (a, b);
            }
        }
    }
    return ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
}

variable_types: struct sexpr_string_or_symbol { enum sx_type { sxt_string=4, sxt_symbol=5, sxt_cons=6, sxt_rational=20 } type; char character_data[]; } *

variable_types:
i
unsigned long

variable_types: type int

variable_types: struct sexpr_type_descriptor { unsigned int type; unsigned long (*serialise)(unsigned long); unsigned long (*unserialise)(unsigned long); void (*tag)(unsigned long); void (*destroy)(unsigned long); void (*call)(); unsigned long (*equalp)(unsigned long, unsigned long); struct sexpr_type_descriptor *next; } *

user_defined_types: struct sexpr_partial { unsigned int type; }


original_code:
sexpr sx_join (sexpr a, sexpr b, sexpr c)
{
    unsigned int j = 0, k = 0;
    const char *s;
    if (((((int_pointer)(a)) & 0x7) == 0x3))
    {
        a = sx_to_string (a);
    }
    if (((((int_pointer)(b)) & 0x7) == 0x3))
    {
        b = sx_to_string (b);
    }
    if (((((int_pointer)(c)) & 0x7) == 0x3))
    {
        c = sx_to_string (c);
    }
    if ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) || (((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? (const char *)((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)a))->character_data) : "#nonexistent") : (const char *)((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)a))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) k++;
    }
    else
    {
        return ((sexpr)((((int_pointer)(1)) << 3) | 0x5));
    }
    if ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) || (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) ? (const char *)((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)b))->character_data) : "#nonexistent") : (const char *)((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)b))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) k++;
    }
    if ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) || (((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) ? (const char *)((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)c))->character_data) : "#nonexistent") : (const char *)((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)c))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) k++;
    }
    k++;
    if (k < 0x1000)
    {
        char buf[0x1000];
        return sx_join_work (a, b, c, buf);
    }
    else
    {
        char *g = get_mem (k);
        sexpr rv;
        rv = sx_join_work (a, b, c, g);
        free_mem (k, g);
        return rv;
    }
}

canonical_original_code:
unsigned long sx_join(unsigned long a, unsigned long b, unsigned long c)
{
    unsigned int j = 0; unsigned int k = 0;
    char *s;
    if (((((int_pointer)(a)) & 0x7) == 0x3))
    {
        a = sx_to_string (a);
    }
    if (((((int_pointer)(b)) & 0x7) == 0x3))
    {
        b = sx_to_string (b);
    }
    if (((((int_pointer)(c)) & 0x7) == 0x3))
    {
        c = sx_to_string (c);
    }
    if ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) || (((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? (char *)((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)a))->character_data) : "#nonexistent") : (char *)((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)a))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)a))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) k++;
    }
    else
    {
        return ((sexpr)((((int_pointer)(1)) << 3) | 0x5));
    }
    if ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) || (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) ? (char *)((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)b))->character_data) : "#nonexistent") : (char *)((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)b))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)b))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) k++;
    }
    if ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) || (((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_symbol)))
    {
        s = (((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) ? (char *)((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_string)) ? (((struct sexpr_string_or_symbol *)((void *)c))->character_data) : "#nonexistent") : (char *)((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_string_or_symbol *)((void *)c))->type == sxt_symbol)) ? (((struct sexpr_string_or_symbol *)((void *)c))->character_data) : "#nonexistent");
        for (j = 0; s[j]; j++) k++;
    }
    k++;
    if (k < 0x1000)
    {
        char buf[4096];
        return sx_join_work (a, b, c, buf);
    }
    else
    {
        char *g = get_mem (k);
        unsigned long rv;
        rv = sx_join_work (a, b, c, g);
        free_mem (k, g);
        return rv;
    }
}

variable_types:
j
unsigned int

variable_types:
k
unsigned int

variable_types:
buf
char [4096]

variable_types:
rv
unsigned long


original_code:
sexpr sx_reverse (sexpr sx)
{
    sexpr result = ((sexpr)((((int_pointer)(5)) << 3) | 0x5));
    sexpr reverse = sx;
    while ((((((int_pointer)(reverse)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)reverse))->type == sxt_cons))) {
        sexpr ncar = ((((((int_pointer)(reverse)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)reverse))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)reverse))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        if (((sexpr)(ncar) == ((sexpr)((((int_pointer)(9)) << 3) | 0x5)))) {
            sexpr nresult = ((((((int_pointer)(result)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)result))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)result))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
            result = nresult;
        } else {
            result = cons(ncar, result);
        }
        reverse = ((((((int_pointer)(reverse)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)reverse))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)reverse))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return result;
}

canonical_original_code:
unsigned long sx_reverse(unsigned long sx)
{
    unsigned long result = ((sexpr)((((int_pointer)(5)) << 3) | 0x5));
    unsigned long reverse = sx;
    while ((((((int_pointer)(reverse)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)reverse))->type == sxt_cons))) {
        unsigned long ncar = ((((((int_pointer)(reverse)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)reverse))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)reverse))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        if (((sexpr)(ncar) == ((sexpr)((((int_pointer)(9)) << 3) | 0x5)))) {
            unsigned long nresult = ((((((int_pointer)(result)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)result))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)result))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
            result = nresult;
        } else {
            result = cons(ncar, result);
        }
        reverse = ((((((int_pointer)(reverse)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)reverse))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)reverse))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return result;
}

variable_types:
sx
unsigned long

variable_types:
result
unsigned long

variable_types:
reverse
unsigned long

variable_types:
ncar
unsigned long

variable_types:
nresult
unsigned long


getInput

repo: kzaklova/FIT

decompiled_code:
double __fastcall getInput(_QWORD *a1)
{
int v1; // eax
double result; // xmm0_8

v1 = __isoc99_scanf();
if ( v1 )
{
result = 0.0;
if ( v1 == -1 )
result = -1.0;
}
else
{
__isoc99_scanf();
result = NAN;
*a1 = 0x7FF8000000000000LL;
}
return result;
}

canonical_decompiled_code:
double __fastcall func9(_QWORD *a1)
{
int v1; // eax
double result; // xmm0_8

v1 = __isoc99_scanf();
if ( v1 )
{
result = 0.0;
if ( v1 == -1 )
result = -1.0;
}
else
{
__isoc99_scanf();
result = NAN;
*a1 = 0x7FF8000000000000LL;
}
return result;
}

original_code:
double getInput (double *x)
{
 int getin;
 getin = scanf ("%lf", x);
 if (getin == 0)
 {
  scanf ("%*s");
  *x = (__builtin_nanf (""));
  return *x;
 }
 if (getin != (-1))
 {
  if(getin == 0)
  {
   scanf ("%*s");
   *x = (__builtin_nanf (""));
   return *x;
  }
 }
 else if(getin == (-1)) return getin;
 return 0;
}

canonical_original_code:
double getInput(double *x)
{
 int getin;
 getin = scanf ("%lf", x);
 if (getin == 0)
 {
  scanf ("%*s");
  *x = (__builtin_nanf (""));
  return *x;
 }
 if (getin != (-1))
 {
  if(getin == 0)
  {
   scanf ("%*s");
   *x = (__builtin_nanf (""));
   return *x;
  }
 }
 else if(getin == (-1)) return getin;
 return 0;
}

variable_types:
x
double *

variable_types: getin int

return_type: double


logar

decompiled_code:
double __fastcall logar(const char *a1, double result, double a3)
{
double v3; // xmm7_8
double v4; // xmm2_8
double v5; // xmm5_8
double v6; // xmm11_8
double v7; // xmm4_8
double v8; // xmm3_8

v3 = 0.0;
if ( result < 0.0 )
return NAN;
v4 = result;
if ( result == 0.0 )
return -INFINITY;
if ( result != INFINITY )
{
if ( result > 1.5 )
{
do
{
v4 = v4 / 1.5;
v3 = v3 + logar(a1, 1.5);
}
while ( v4 > 1.5 );
}
for ( ; v4 < 0.5; v3 = v3 + logar(a1, 0.5) )
v4 = v4 + v4;
v5 = 1.0;
v6 = (v4 - 1.0) / (v4 + 1.0);
if ( a3 <= 1.0 )
{
v7 = 1.0;
v8 = 1.0;
do
{
v8 = v8 + 2.0;
v7 = v7 * ((v8 - 2.0) * (v6 * v6) / v8);
v5 = v5 + v7;
}
while ( fabs(v7) >= fabs(v5) * a3 );
}
result = (v6 + v6) * v5 + v3;
}
return result;
}

canonical_decompiled_code:
double __fastcall func10(const char *a1, double result, double a3)
{
double v3; // xmm7_8
double v4; // xmm2_8
double v5; // xmm5_8
double v6; // xmm11_8
double v7; // xmm4_8
double v8; // xmm3_8

v3 = 0.0;
if ( result < 0.0 )
return NAN;
v4 = result;
if ( result == 0.0 )
return -INFINITY;
if ( result != INFINITY )
{
if ( result > 1.5 )
{
do
{
v4 = v4 / 1.5;
v3 = v3 + func10(a1, 1.5);
}
while ( v4 > 1.5 );
}
for ( ; v4 < 0.5; v3 = v3 + func10(a1, 0.5) )
v4 = v4 + v4;
v5 = 1.0;
v6 = (v4 - 1.0) / (v4 + 1.0);
if ( a3 <= 1.0 )
{
v7 = 1.0;
v8 = 1.0;
do
{
v8 = v8 + 2.0;
v7 = v7 * ((v8 - 2.0) * (v6 * v6) / v8);
v5 = v5 + v7;
}
while ( fabs(v7) >= fabs(v5) * a3 );
}
result = (v6 + v6) * v5 + v3;
}
return result;
}

original_code:
double logar (double x, double eps)
{
 double res = 0;
 if (x < 0)
 {
  res = (__builtin_nanf (""));
  return res;
 }
 if (x == 0)
 {
  res = -(__builtin_inff ());
  return res;
 }
 if (x == (__builtin_inff ()))
 {
  res = (__builtin_inff ());
  return res;
 }
 double hb = 1.5;
 double lb = 0.5;
 double av = 0;
 if (x > hb)
 {
  while (x > hb)
  {
   x /= hb;
   av += logar (hb, eps);
  }
 }
 if (x < lb)
 {
  while (x < lb)
  {
   x /= lb;
   av += logar (lb, eps);
  }
 }
 double k = 1;
 double item_ln = 1;
 double sum_ln = item_ln;
 double t = (x - 1) / (x + 1);
 double pw = t * t;
 while (fabs (item_ln) >= eps*fabs (sum_ln))
 {
  k += 2;
  item_ln = item_ln * (pw * (k - 2) / k);
  sum_ln += item_ln;
 }
 sum_ln = 2 * t * sum_ln;
 sum_ln = sum_ln + av;
 res = sum_ln;
 return res;
}

canonical_original_code:
double logar(double x, double eps)
{
 double res = 0;
 if (x < 0)
 {
  res = (__builtin_nanf (""));
  return res;
 }
 if (x == 0)
 {
  res = -(__builtin_inff ());
  return res;
 }
 if (x == (__builtin_inff ()))
 {
  res = (__builtin_inff ());
  return res;
 }
 double hb = 1.5;
 double lb = 0.5;
 double av = 0;
 if (x > hb)
 {
  while (x > hb)
  {
   x /= hb;
   av += logar (hb, eps);
  }
 }
 if (x < lb)
 {
  while (x < lb)
  {
   x /= lb;
   av += logar (lb, eps);
  }
 }
 double k = 1;
 double item_ln = 1;
 double sum_ln = item_ln;
 double t = (x - 1) / (x + 1);
 double pw = t * t;
 while (fabs (item_ln) >= eps*fabs (sum_ln))
 {
  k += 2;
  item_ln = item_ln * (pw * (k - 2) / k);
  sum_ln += item_ln;
 }
 sum_ln = 2 * t * sum_ln;
 sum_ln = sum_ln + av;
 res = sum_ln;
 return res;
}

variable_types: x double

variable_types: eps double

variable_types: res double

variable_types: hb double

variable_types: lb double

variable_types: av double

variable_types: k double

variable_types: t double

variable_types: pw double


arsin

original_code:
double arsin(double x, double eps)
{
 double res = 0;
 int sq = 0;
 int one = 0;
 int neg = 0;
 if (x < 0)
 {
  x = fabs(x);
  neg = 1;
 }
 if (x > 1)
 {
  res = (__builtin_nanf (""));
  return res;
 }
 x = x / sqrt((1 - x) * (1 + x));
 if (x > 1)
 {
  x = 1 / x;
  one = 1;
 }
 if(x > (2 - sqrt(3)) && x <= 1)
 {
  sq = 1;
  x = ((sqrt(3) * x - 1) / (sqrt(3) + x));
 }
 double i = 1;
 double item_as = x;
 double pw = x * x;
 double sum_as = item_as;
 double prev_as = 0;
 while (fabs (prev_as - sum_as) >= eps)
 {
  i += 2;
  item_as = (-item_as * pw * (i - 2)) / i;
  prev_as = sum_as;
  sum_as += item_as;
 }
 if (sq == 1) sum_as = IZP_PI_6 + sum_as;
 if (one == 1) sum_as = IZP_PI_2 - sum_as;
 res = sum_as;
 if (neg == 1) res = -(res);
 if (res == -0) res = 0;
 return res;
}

variable_types: sq int

variable_types: one int

variable_types: neg int

variable_types: i double


countLbe

original_code:
void countLbe (TPrev *prev, TNext *next, TRes *res, double err)
{
 double w, h, wmin, hmin, wmax, hmax, tmp1, tmp2;
 tmp1 = 0, tmp2 = 0;
 w = fabs(next->x - prev->x);
 h = fabs(next->y - prev->y);
 wmin = w - 2*err;
 hmin = h - 2*err;
 wmax = w + 2*err;
 hmax = h + 2*err;
 if (w == 0 && h == 0) tmp1 = 0;
 else if (w == 0 && h != 0) tmp1 = hmin;
 else if (w != 0 && h == 0) tmp1 = wmin;
 else tmp1 = sqrt((wmin*wmin) + (hmin*hmin));
 if (wmin < 0 && hmin < 0) tmp1 = 0;
 res->res1 = res->res1 + tmp1;
 if (w == 0 && h == 0) tmp2 = 0;
 else tmp2 = sqrt((wmax*wmax) + (hmax*hmax));
 res->res2 = res->res2 + tmp2;
 prev->x = next->x;
 prev->y = next->y;
}

canonical_original_code:
void countLbe(struct prev *prev, struct next *next, struct result *res, double err)
{
 double w; double h; double wmin; double hmin; double wmax; double hmax; double tmp1; double tmp2;
 tmp1 = 0, tmp2 = 0;
 w = fabs(next->x - prev->x);
 h = fabs(next->y - prev->y);
 wmin = w - 2*err;
 hmin = h - 2*err;
 wmax = w + 2*err;
 hmax = h + 2*err;
 if (w == 0 && h == 0) tmp1 = 0;
 else if (w == 0 && h != 0) tmp1 = hmin;
 else if (w != 0 && h == 0) tmp1 = wmin;
 else tmp1 = sqrt((wmin*wmin) + (hmin*hmin));
 if (wmin < 0 && hmin < 0) tmp1 = 0;
 res->res1 = res->res1 + tmp1;
 if (w == 0 && h == 0) tmp2 = 0;
 else tmp2 = sqrt((wmax*wmax) + (hmax*hmax));
 res->res2 = res->res2 + tmp2;
 prev->x = next->x;
 prev->y = next->y;
}

variable_types:
prev
struct prev { double x; } *

variable_types:
next
struct next { double x; } *

variable_types: struct result { double res1; double res2; } *

variable_types: err double

variable_types: w double

variable_types: h double

variable_types: wmin double

variable_types: hmin double

variable_types: wmax double

variable_types: hmax double


power

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

if ( a2 == 0.0 )
a1 = 1.0;
v3 = a1;
result = 2LL;
if ( a2 >= 2.0 )
{
do
{
v3 = v3 * a1;
result = (unsigned int)(result + 1);
}
while ( a2 >= (double)(int)result );
}
return result;
}

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

if ( a2 == 0.0 )
a1 = 1.0;
v3 = a1;
result = 2LL;
if ( a2 >= 2.0 )
{
do
{
v3 = v3 * a1;
result = (unsigned int)(result + 1);
}
while ( a2 >= (double)(int)result );
}
return result;
}

original_code:
double power (double x, double y)
{
 int i;
 double j;
 if (y == 0) x = 1;
 j = x;
 for (i = 2; i <= y; i++)
 {
  x = x*j;
 }
 return x;
}

canonical_original_code:
double power(double x, double y)
{
 int i;
 double j;
 if (y == 0) x = 1;
 j = x;
 for (i = 2; i <= y; i++)
 {
  x = x*j;
 }
 return x;
}

variable_types: x double

variable_types: y double

variable_types: i int

variable_types: j double


main

canonical_name: main

original_code:
int main(int argc, char *argv[])
{
 TParams params = getParams(argc, argv);
 if (params.ecode != EOK)
 {
  printECode(params.ecode);
  return 1;
 }
 if (params.state == CHELP)
 {
  printf("%s", HELPMSG);
  return 0;
 }
 TPrev prev;
 prev.x = 0;
 prev.y = 0;
 TNext next;
 next.x = 0;
 next.y = 0;
 TRes res;
 res.res1 = 0;
 res.res2 = 0;
 int ecode = EOK;
 double eps = 0;
 double x = 0.1;
 double fakeerr = 0;
 double aux = 0;
 if(params.state == CLBL || params.state == CLBE)
 {
  getInput(&prev.x);
  getInput(&prev.y);
  if (__builtin_isnan (prev.x) || __builtin_isnan (prev.y)) printf ("%.10e\n", (__builtin_nanf ("")));
  else printf("%.10e\n", res.res1);
  if (params.state == CLBE)
  {
   if (__builtin_isnan (prev.x) || __builtin_isnan (prev.y)) printf ("%.10e\n", (__builtin_nanf ("")));
   else printf("%.10e\n", res.res1);
  }
  while (getInput(&next.x) != (-1))
  {
   aux = getInput(&next.y);
   if (aux == (-1)) next.y = (__builtin_nanf (""));
   if (params.state == CLBL)
   {
    countLbe(&prev, &next, &res, fakeerr);
    printf("%.10e\n", res.res1);
   }
   else if (params.state == CLBE)
   {
    countLbe(&prev, &next, &res, params.err);
    printf("%.10e\n", res.res1);
    printf("%.10e\n", res.res2);
   }
  }
 }
 else if(params.state == CARS || params.state == CLOG)
 {
  eps = power(x,(params.sigdig + 1));
  while(getInput(&prev.x) != (-1))
  {
   if(params.state == CLOG)
   {
    next.x = params.a;
    printf ("%.10e\n", (logar(prev.x, eps)/logar(next.x, eps)));
   }
   else if(params.state == CARS)
   {
    printf("%.10e\n", arsin(prev.x, eps));
   }
  }
 }
 if (ecode != EOK)
 {
  printECode(ecode);
  return 1;
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct params params = getParams(argc, argv);
 if (params.ecode != EOK)
 {
  printECode(params.ecode);
  return 1;
 }
 if (params.state == CHELP)
 {
  printf("%s", HELPMSG);
  return 0;
 }
 struct prev prev;
 prev.x = 0;
 prev.y = 0;
 struct next next;
 next.x = 0;
 next.y = 0;
 struct result res;
 res.res1 = 0;
 res.res2 = 0;
 int ecode = EOK;
 double eps = 0;
 double x = 0.1;
 double fakeerr = 0;
 double aux = 0;
 if(params.state == CLBL || params.state == CLBE)
 {
  getInput(&prev.x);
  getInput(&prev.y);
  if (__builtin_isnan (prev.x) || __builtin_isnan (prev.y)) printf ("%.10e\n", (__builtin_nanf ("")));
  else printf("%.10e\n", res.res1);
  if (params.state == CLBE)
  {
   if (__builtin_isnan (prev.x) || __builtin_isnan (prev.y)) printf ("%.10e\n", (__builtin_nanf ("")));
   else printf("%.10e\n", res.res1);
  }
  while (getInput(&next.x) != (-1))
  {
   aux = getInput(&next.y);
   if (aux == (-1)) next.y = (__builtin_nanf (""));
   if (params.state == CLBL)
   {
    countLbe(&prev, &next, &res, fakeerr);
    printf("%.10e\n", res.res1);
   }
   else if (params.state == CLBE)
   {
    countLbe(&prev, &next, &res, params.err);
    printf("%.10e\n", res.res1);
    printf("%.10e\n", res.res2);
   }
  }
 }
 else if(params.state == CARS || params.state == CLOG)
 {
  eps = power(x,(params.sigdig + 1));
  while(getInput(&prev.x) != (-1))
  {
   if(params.state == CLOG)
   {
    next.x = params.a;
    printf ("%.10e\n", (logar(prev.x, eps)/logar(next.x, eps)));
   }
   else if(params.state == CARS)
   {
    printf("%.10e\n", arsin(prev.x, eps));
   }
  }
 }
 if (ecode != EOK)
 {
  printECode(ecode);
  return 1;
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct params { unsigned int sigdig; double a; double err; int ecode; int state; }

variable_types:
prev
struct prev { double x; }

variable_types:
next
struct next { double x; }

variable_types: struct result { double res1; double res2; }

variable_types: ecode int

variable_types: eps double

variable_types: fakeerr double

variable_types: aux double

return_type: int


printECode

decompiled_code:
int __fastcall printECode(unsigned int a1)
{
if ( a1 >= 6 )
a1 = 6;
return fputs((&ECODEMSG)[a1], stderr);
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1)
{
if ( a1 >= 6 )
a1 = 6;
return fputs((&ECODEMSG)[a1], stderr);
}

original_code:
void printECode(int ecode)
{
 if (ecode < EOK || ecode > EER)
 { ecode = EUNKNOWN; }
 fprintf(stderr, "%s", ECODEMSG[ecode]);
}


getParams

original_code:
TParams getParams(int argc, char *argv[])
{
 TParams result =
 {
  .sigdig = 0,
  .a = 0,
  .err = 0,
  .ecode = EOK,
  .state = CLBL,
 };
 if (argc == 1) result.ecode = EHELP;
 if (argc == 2)
 {
  if (strcmp ("-h", argv[1]) == 0) result.state = CHELP;
  else if (strcmp ("--lbl", argv[1]) == 0) result.state = CLBL;
  else result.ecode = EHELP;
 }
 else if (argc == 3 && strcmp ("--lble", argv[1]) == 0 )
 {
  char *pAux;
  result.err = strtod((argv[2]), &pAux);
  if (*pAux != '\0' || (result.err < 0) || (result.err > ((double)1.79769313486231570814527423731704357e+308L))) result.ecode = EER;
  else result.state = CLBE;
 }
 else if ((argc == 3 && strcmp ("--lble", argv[1]) != 0)|| argc == 4)
 {
  char *pAux2;
  result.sigdig = strtol((argv[2]), &pAux2, 10);
  if (*pAux2 != '\0' || (result.sigdig < 1) || (result.sigdig > 15)) result.ecode = ESIG;
  else result.ecode = EOK;
  if (argc == 3 && strcmp ("--arcsin", argv [1]) == 0) result.state = CARS;
  else if (argc == 4 && strcmp ("--logax", argv [1]) == 0)
  {
   char *pAux3;
   result.a = strtod((argv[3]), &pAux3);
   if (*pAux2 != '\0' || result.a <= 0 || result.a == 1) result.ecode = ELOG;
   else result.state = CLOG;
   }
  else result.ecode = EHELP;
 }
 else result.ecode = ECLWRONG;
 return result;
}

canonical_original_code:
struct params getParams(int argc, char *argv[])
{
 struct params result = {
  .sigdig = 0,
  .a = 0,
  .err = 0,
  .ecode = EOK,
  .state = CLBL,
 };
 if (argc == 1) result.ecode = EHELP;
 if (argc == 2)
 {
  if (strcmp ("-h", argv[1]) == 0) result.state = CHELP;
  else if (strcmp ("--lbl", argv[1]) == 0) result.state = CLBL;
  else result.ecode = EHELP;
 }
 else if (argc == 3 && strcmp ("--lble", argv[1]) == 0 )
 {
  char *pAux;
  result.err = strtod((argv[2]), &pAux);
  if (*pAux != '\0' || (result.err < 0) || (result.err > ((double)1.79769313486231570814527423731704357e+308L))) result.ecode = EER;
  else result.state = CLBE;
 }
 else if ((argc == 3 && strcmp ("--lble", argv[1]) != 0)|| argc == 4)
 {
  char *pAux2;
  result.sigdig = strtol((argv[2]), &pAux2, 10);
  if (*pAux2 != '\0' || (result.sigdig < 1) || (result.sigdig > 15)) result.ecode = ESIG;
  else result.ecode = EOK;
  if (argc == 3 && strcmp ("--arcsin", argv [1]) == 0) result.state = CARS;
  else if (argc == 4 && strcmp ("--logax", argv [1]) == 0)
  {
   char *pAux3;
   result.a = strtod((argv[3]), &pAux3);
   if (*pAux2 != '\0' || result.a <= 0 || result.a == 1) result.ecode = ELOG;
   else result.state = CLOG;
   }
  else result.ecode = EHELP;
 }
 else result.ecode = ECLWRONG;
 return result;
}

variable_types:
pAux
char *

return_type: struct params { unsigned int sigdig; double a; double err; int ecode; int state; }


MakeInst

decompiled_code:
__int64 __fastcall MakeInst(int a1, __int64 a2, __int64 a3, __int64 a4, int a5)
{
__int64 v7; // r12
void *v8; // rax
__int64 v9; // r9
unsigned int v10; // er13
char *v12; // rdi
__int64 v13; // rbx
__int64 v14; // rbx
char *v15; // r12
void *v16; // rax
__int64 v17; // rdx
int v18; // er14
int v19; // ecx
char *v20; // rax
char *v21; // rdx
_QWORD *v22; // rax
_QWORD *v23; // rdx
__int64 v24[6]; // [rsp+8h] [rbp-30h] BYREF

v7 = a5;
v8 = malloc(0x20uLL);
if ( !v8 )
goto LABEL_11;
InstCreate((__int64)v8, a1, a2, a3, a4);
InsertLast(InstList, v9);
v10 = ErrorFlag;
if ( !ErrorFlag )
{
if ( a1 != 34 )
{
if ( a1 == 38 )
{
v17 = control[1];
v24[0] = 0LL;
if ( (unsigned int)getVarTree(v24, STable, v17) == 9
|| (unsigned int)CopyTree(v24[0], (char *)funcArray + 24 * v7 - 16) == 9 )
{
v10 = 9;
AddError(0LL, 5LL);
}
}
return v10;
}
v12 = (char *)funcArray;
if ( funcArray )
{
v13 = (int)v7;
if ( __ROR4__(-858993459 * v7 + 429496728, 2) > 0xCCCCCCCu )
goto LABEL_8;
v18 = (int)v7 / 20;
if ( realloc(funcArray, 960LL * ((int)v7 / 20)) )
{
v12 = (char *)funcArray;
v19 = 20 * v18;
if ( 20 * v18 < 40 * v18 )
{
v20 = (char *)funcArray + 24 * v19;
v21 = (char *)funcArray + 24 * v19 + 24 * (unsigned __int64)(unsigned int)(40 * v18 - 1 - v19) + 24;
do
{
*((_QWORD *)v20 + 2) = 0LL;
v20 += 24;
*((_QWORD *)v20 - 3) = 0LL;
*((_QWORD *)v20 - 2) = 0LL;
}
while ( v20 != v21 );
}
LABEL_8:
v14 = 24 * v13;
v15 = &v12[v14 - 24];
*((_QWORD *)v15 + 2) = InstList[1];
v16 = malloc(0x10uLL);
*(_QWORD *)v15 = v16;
if ( v16
&& (unsigned int)strInit(v16) != 1
&& !(unsigned int)strCopyString(*(_QWORD *)((char *)funcArray + v14 - 24), a2) )
{
return v10;
}
goto LABEL_11;
}
}
else
{
v22 = malloc(0x1E0uLL);
funcArray = v22;
v12 = (char *)v22;
if ( v22 )
{
v23 = v22 + 60;
do
{
v22[2] = 0LL;
v22 += 3;
*(v22 - 3) = 0LL;
*(v22 - 2) = 0LL;
}
while ( v22 != v23 );
v13 = (int)v7;
goto LABEL_8;
}
}
LABEL_11:
v10 = 1;
AddError(line, 5LL);
return v10;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, __int64 a2, __int64 a3, __int64 a4, int a5)
{
__int64 v7; // r12
void *v8; // rax
__int64 v9; // r9
unsigned int v10; // er13
char *v12; // rdi
__int64 v13; // rbx
__int64 v14; // rbx
char *v15; // r12
void *v16; // rax
__int64 v17; // rdx
int v18; // er14
int v19; // ecx
char *v20; // rax
char *v21; // rdx
_QWORD *v22; // rax
_QWORD *v23; // rdx
__int64 v24[6]; // [rsp+8h] [rbp-30h] BYREF

v7 = a5;
v8 = malloc(0x20uLL);
if ( !v8 )
goto LABEL_11;
func0((__int64)v8, a1, a2, a3, a4);
InsertLast(InstList, v9);
v10 = ErrorFlag;
if ( !ErrorFlag )
{
if ( a1 != 34 )
{
if ( a1 == 38 )
{
v17 = control[1];
v24[0] = 0LL;
if ( (unsigned int)getVarTree(v24, STable, v17) == 9
|| (unsigned int)CopyTree(v24[0], (char *)funcArray + 24 * v7 - 16) == 9 )
{
v10 = 9;
AddError(0LL, 5LL);
}
}
return v10;
}
v12 = (char *)funcArray;
if ( funcArray )
{
v13 = (int)v7;
if ( __ROR4__(-858993459 * v7 + 429496728, 2) > 0xCCCCCCCu )
goto LABEL_8;
v18 = (int)v7 / 20;
if ( realloc(funcArray, 960LL * ((int)v7 / 20)) )
{
v12 = (char *)funcArray;
v19 = 20 * v18;
if ( 20 * v18 < 40 * v18 )
{
v20 = (char *)funcArray + 24 * v19;
v21 = (char *)funcArray + 24 * v19 + 24 * (unsigned __int64)(unsigned int)(40 * v18 - 1 - v19) + 24;
do
{
*((_QWORD *)v20 + 2) = 0LL;
v20 += 24;
*((_QWORD *)v20 - 3) = 0LL;
*((_QWORD *)v20 - 2) = 0LL;
}
while ( v20 != v21 );
}
LABEL_8:
v14 = 24 * v13;
v15 = &v12[v14 - 24];
*((_QWORD *)v15 + 2) = InstList[1];
v16 = malloc(0x10uLL);
*(_QWORD *)v15 = v16;
if ( v16
&& (unsigned int)strInit(v16) != 1
&& !(unsigned int)strCopyString(*(_QWORD *)((char *)funcArray + v14 - 24), a2) )
{
return v10;
}
goto LABEL_11;
}
}
else
{
v22 = malloc(0x1E0uLL);
funcArray = v22;
v12 = (char *)v22;
if ( v22 )
{
v23 = v22 + 60;
do
{
v22[2] = 0LL;
v22 += 3;
*(v22 - 3) = 0LL;
*(v22 - 2) = 0LL;
}
while ( v22 != v23 );
v13 = (int)v7;
goto LABEL_8;
}
}
LABEL_11:
v10 = 1;
AddError(line, 5LL);
return v10;
}
return 1LL;
}

original_code:
int MakeInst(int type, void *addr1, void *addr2, void *addr3, int FuncCounter)
{
tInst *p_new_inst;
if((p_new_inst=malloc(sizeof(tInst))) == ((void *)0))
  {
  AddError(line, 5);
  return 1;
  }
*p_new_inst= InstCreate(type, addr1,addr2,addr3);
InsertLast(&InstList,p_new_inst);
if(ErrorFlag != 0) return 1;
if(type == 34)
  {
  if(funcArray != ((void *)0))
    {
    if((FuncCounter % 20) == 0)
      {
      tFunc *p_temp= ((void *)0);
      int pocet = FuncCounter / 20;
      if((p_temp=realloc(funcArray, (sizeof(tFunc) * 20 * (pocet*2)))) == ((void *)0))
        {
        AddError(line, 5);
        return 1;
        }
      for(int i = (pocet * 20);(i < (pocet * 2 * 20)); i++)
        {
        funcArray[i].function =((void *)0);
        funcArray[i].identif = ((void *)0);
        funcArray[i].VarTree = ((void *)0);
        }
      }
    }
  else
    {
    if((funcArray = malloc(sizeof(tFunc) * 20)) == ((void *)0))
      {
      AddError(line, 5);
      return 1;
      }
    for(int i=0;i<20;i++)
      {
      funcArray[i].function =((void *)0);
      funcArray[i].identif = ((void *)0);
      funcArray[i].VarTree = ((void *)0);
      }
    }
    funcArray[FuncCounter-1].function= InstList.Last;
    if((funcArray[FuncCounter-1].identif= malloc(sizeof(string))) == ((void *)0))
      {
      AddError(line, 5);
      return 1;
      }
    if(strInit(funcArray[FuncCounter-1].identif) == 1)
      {
      AddError(line, 5);
      return 1;
      }
    if(strCopyString(funcArray[FuncCounter-1].identif , (string *)addr1))
      {
      AddError(line, 5);
      return 1;
      }
  }
 if(type == 38)
  {
  tVarTreeItem **p_var_help = ((void *)0);
  if((getVarTree(&(p_var_help), &(*STable), control.function )) == 9)
    {
    AddError(0, 5);
    return 9;
    }
  if((CopyTree(p_var_help, &(funcArray[FuncCounter-1].VarTree)) == 9))
    {
    AddError(0, 5);
    return 9;
    }
  }
return 0;
}

canonical_original_code:
int MakeInst(int type, void *addr1, void *addr2, void *addr3, int FuncCounter)
{
struct tInst *p_new_inst;
if((p_new_inst=malloc(sizeof(tInst))) == ((void *)0))
  {
  AddError(line, 5);
  return 1;
  }
*p_new_inst= InstCreate(type, addr1,addr2,addr3);
InsertLast(&InstList,p_new_inst);
if(ErrorFlag != 0) return 1;
if(type == 34)
  {
  if(funcArray != ((void *)0))
    {
    if((FuncCounter % 20) == 0)
      {
      struct tFunc *p_temp = ((void *)0);
      int pocet = FuncCounter / 20;
      if((p_temp=realloc(funcArray, (sizeof(tFunc) * 20 * (pocet*2)))) == ((void *)0))
        {
        AddError(line, 5);
        return 1;
        }
      for(int i = (pocet * 20);(i < (pocet * 2 * 20)); i++)
        {
        funcArray[i].function =((void *)0);
        funcArray[i].identif = ((void *)0);
        funcArray[i].VarTree = ((void *)0);
        }
      }
    }
  else
    {
    if((funcArray = malloc(sizeof(tFunc) * 20)) == ((void *)0))
      {
      AddError(line, 5);
      return 1;
      }
    for(int i = 0;i<20;i++)
      {
      funcArray[i].function =((void *)0);
      funcArray[i].identif = ((void *)0);
      funcArray[i].VarTree = ((void *)0);
      }
    }
    funcArray[FuncCounter-1].function= InstList.Last;
    if((funcArray[FuncCounter-1].identif= malloc(sizeof(string))) == ((void *)0))
      {
      AddError(line, 5);
      return 1;
      }
    if(strInit(funcArray[FuncCounter-1].identif) == 1)
      {
      AddError(line, 5);
      return 1;
      }
    if(strCopyString(funcArray[FuncCounter-1].identif , (struct string *)addr1))
      {
      AddError(line, 5);
      return 1;
      }
  }
 if(type == 38)
  {
  struct VarTreeItem **p_var_help = ((void *)0);
  if((getVarTree(&(p_var_help), &(*STable), control.function )) == 9)
    {
    AddError(0, 5);
    return 9;
    }
  if((CopyTree(p_var_help, &(funcArray[FuncCounter-1].VarTree)) == 9))
    {
    AddError(0, 5);
    return 9;
    }
  }
return 0;
}

variable_types: type int

variable_types: FuncCounter int

variable_types: struct tFunc { struct string { char *str; int length; int allocSize; } *identif; struct VarTreeItem { struct string *key; struct varValue { int type; int integer; double real; struct string *stringVar; _Bool boolean; } *data; struct VarTreeItem *LeftRoot; struct VarTreeItem *RightRoot; } *VarTree; struct polozkaList { int line_number; struct tInst { int action; void *addr1; void *addr2; void *addr3; } *data; struct polozkaList *next; } *function; } *

variable_types: pocet int

variable_types: struct VarTreeItem { struct string { char *str; int length; int allocSize; } *key; struct varValue { int type; int integer; double real; struct string *stringVar; _Bool boolean; } *data; struct VarTreeItem *LeftRoot; struct VarTreeItem *RightRoot; } **

user_defined_types: struct tFunc { struct string *identif; struct VarTreeItem *VarTree; struct polozkaList *function; }

user_defined_types: struct VarTreeItem { struct string *key; struct varValue *data; struct VarTreeItem *LeftRoot; struct VarTreeItem *RightRoot; }

user_defined_types: struct polozkaList { int line_number; struct tInst *data; struct polozkaList *next; }


CopyFirst

original_code:
void CopyFirst (tInstList *L, tInst *new_instr)
{
  if(L->First != ((void *)0))
    {
    new_instr->action = L->First->data->action;
    new_instr->addr1 = L->First->data->addr1;
    new_instr->addr2 = L->First->data->addr2;
    new_instr->addr3 = L->First->data->addr3;
    }
  return;
}

canonical_original_code:
void CopyFirst(struct tInstList *L, struct tInst *new_instr)
{
  if(L->First != ((void *)0))
    {
    new_instr->action = L->First->data->action;
    new_instr->addr1 = L->First->data->addr1;
    new_instr->addr2 = L->First->data->addr2;
    new_instr->addr3 = L->First->data->addr3;
    }
  return;
}

variable_types: struct tInstList { struct polozkaList { int line_number; struct tInst { int action; void *addr1; void *addr2; void *addr3; } *data; struct polozkaList *next; } *First; struct polozkaList *Last; struct polozkaList *Active; } *

user_defined_types: struct tInstList { struct polozkaList *First; struct polozkaList *Last; struct polozkaList *Active; }


Copy

decompiled_code:
void Copy()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void Copy (tInstList *L, tInst *new_instr)
{
 if(L->Active == ((void *)0))
   {
   }
 else new_instr = L->Active->data;
 return;
}

canonical_original_code:
void Copy(struct tInstList *L, struct tInst *new_instr)
{
 if(L->Active == ((void *)0))
   {
   }
 else new_instr = L->Active->data;
 return;
}

user_defined_types: struct tInst { int action; void *addr1; void *addr2; void *addr3; }


Actualize

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

result = *(_QWORD *)(a1 + 16);
if ( result )
*(_QWORD *)(result + 8) = a2;
return result;
}

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

result = *(_QWORD *)(a1 + 16);
if ( result )
*(_QWORD *)(result + 8) = a2;
return result;
}

original_code:
void Actualize (tInstList *L, tInst *new_instr)
{
 if(L->Active != ((void *)0)) L->Active->data = new_instr;
 return;
 }

canonical_original_code:
void Actualize(struct tInstList *L, struct tInst *new_instr)
{
 if(L->Active != ((void *)0)) L->Active->data = new_instr;
 return;
 }


Succ

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

result = *(_QWORD *)(a1 + 16);
if ( result )
{
result = *(_QWORD *)(result + 16);
*(_QWORD *)(a1 + 16) = result;
}
return result;
}

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

result = *(_QWORD *)(a1 + 16);
if ( result )
{
result = *(_QWORD *)(result + 16);
*(_QWORD *)(a1 + 16) = result;
}
return result;
}

original_code:
void Succ (tInstList *L)
{
 if(L->Active != ((void *)0))
   {
   if(L->Active->next == ((void *)0)) L->Active = ((void *)0);
   else L->Active = L->Active->next;
   }
 return;
}

canonical_original_code:
void Succ(struct tInstList *L)
{
 if(L->Active != ((void *)0))
   {
   if(L->Active->next == ((void *)0)) L->Active = ((void *)0);
   else L->Active = L->Active->next;
   }
 return;
}


Active

decompiled_code:
_BOOL8 __fastcall Active(__int64 a1)
{
return *(_QWORD *)(a1 + 16) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func12(__int64 a1)
{
return *(_QWORD *)(a1 + 16) != 0LL;
}

original_code:
int Active (tInstList *L)
{
return (L->Active != ((void *)0));
}

canonical_original_code:
int Active(struct tInstList *L)
{
return (L->Active != ((void *)0));
}


ListJump

decompiled_code:
void __fastcall ListJump(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 16) = a2;
}

original_code:
void ListJump(tInstList *L, tPolozkaList *jump_instr)
{
L->Active=(tPolozkaList *)jump_instr;
}

canonical_original_code:
void ListJump(struct tInstList *L, struct polozkaList *jump_instr)
{
L->Active=(struct polozkaList *)jump_instr;
}


PrintErrItem

decompiled_code:
int __fastcall PrintErrItem(unsigned int *a1)
{
__int64 v1; // rax
FILE *v2; // r8

v1 = (int)a1[1];
v2 = stderr;
if ( (unsigned int)(v1 + 1) > 6 )
{
a1[1] = -1;
v1 = -1LL;
return fprintf(v2, "Na riadku %d %s \n", *a1, (&ECODEMSG)[v1]);
}
if ( (_DWORD)v1 != 5 )
return fprintf(v2, "Na riadku %d %s \n", *a1, (&ECODEMSG)[v1]);
return fprintf(stderr, "\n%s", *(&ECODEMSG + 5));
}

canonical_decompiled_code:
int __fastcall func0(unsigned int *a1)
{
__int64 v1; // rax
FILE *v2; // r8

v1 = (int)a1[1];
v2 = stderr;
if ( (unsigned int)(v1 + 1) > 6 )
{
a1[1] = -1;
v1 = -1LL;
return fprintf(v2, "Na riadku %d %s \n", *a1, (&ECODEMSG)[v1]);
}
if ( (_DWORD)v1 != 5 )
return fprintf(v2, "Na riadku %d %s \n", *a1, (&ECODEMSG)[v1]);
return fprintf(stderr, "\n%s", *(&ECODEMSG + 5));
}

original_code:
void PrintErrItem(TError *p_temp)
{
if((p_temp->ErrorType < -1) || (p_temp->ErrorType > 5))
  {
  p_temp->ErrorType = -1;
  }
if(p_temp->ErrorType == 5) fprintf(stderr, "\n%s",ECODEMSG[p_temp->ErrorType]);
else fprintf(stderr, "Na riadku %d %s \n", p_temp->LineNumber, ECODEMSG[(p_temp->ErrorType)]);
}

canonical_original_code:
void PrintErrItem(struct chyba *p_temp)
{
if((p_temp->ErrorType < -1) || (p_temp->ErrorType > 5))
  {
  p_temp->ErrorType = -1;
  }
if(p_temp->ErrorType == 5) fprintf(stderr, "\n%s",ECODEMSG[p_temp->ErrorType]);
else fprintf(stderr, "Na riadku %d %s \n", p_temp->LineNumber, ECODEMSG[(p_temp->ErrorType)]);
}

variable_types: struct chyba { int LineNumber; int ErrorType; } *


PrintError

decompiled_code:
int PrintError()
{
int result; // eax
__int64 v1; // rbx
unsigned int *v2; // rdi

result = ErrorCounter;
if ( ErrorCounter > 0 )
{
v1 = 0LL;
do
{
v2 = (unsigned int *)((char *)ErrorList + 8 * v1++);
result = PrintErrItem(v2);
}
while ( ErrorCounter > (int)v1 );
}
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax
__int64 v1; // rbx
unsigned int *v2; // rdi

result = ErrorCounter;
if ( ErrorCounter > 0 )
{
v1 = 0LL;
do
{
v2 = (unsigned int *)((char *)ErrorList + 8 * v1++);
result = func0(v2);
}
while ( ErrorCounter > (int)v1 );
}
return result;
}

original_code:
void PrintError(void)
{
for(int i=0;i <ErrorCounter; i++)
   {
   PrintErrItem(&(ErrorList[i]));
   }
}

canonical_original_code:
void PrintError()
{
for(int i = 0;i <ErrorCounter; i++)
   {
   PrintErrItem(&(ErrorList[i]));
   }
}

variable_types: i int


FreeError

decompiled_code:
void FreeError()
{
free(ErrorList);
ErrorList = 0LL;
}

canonical_decompiled_code:
void func2()
{
free(ErrorList);
ErrorList = 0LL;
}

original_code:
void FreeError(void)
{
free(ErrorList);
ErrorList = ((void *)0);
}

canonical_original_code:
void FreeError()
{
free(ErrorList);
ErrorList = ((void *)0);
}


MakeErrList

decompiled_code:
__int64 MakeErrList()
{
_DWORD *v0; // rax
_DWORD *v1; // rdx
__int64 result; // rax

v0 = malloc(0xF0uLL);
ErrorList = v0;
if ( v0 )
{
v1 = v0 + 60;
do
{
*v0 = 0;
v0 += 2;
*(v0 - 1) = 0;
}
while ( v0 != v1 );
result = 0LL;
}
else
{
fprintf(stderr, "\n%s", *(&ECODEMSG + 5));
FreeError();
result = 5LL;
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
_DWORD *v0; // rax
_DWORD *v1; // rdx
__int64 result; // rax

v0 = malloc(0xF0uLL);
ErrorList = v0;
if ( v0 )
{
v1 = v0 + 60;
do
{
*v0 = 0;
v0 += 2;
*(v0 - 1) = 0;
}
while ( v0 != v1 );
result = 0LL;
}
else
{
fprintf(stderr, "\n%s", *(&ECODEMSG + 5));
func2();
result = 5LL;
}
return result;
}

original_code:
int MakeErrList(void)
{
if(((ErrorList) = malloc((sizeof(TError))*30)) == ((void *)0))
  {
  fprintf(stderr, "\n%s",ECODEMSG[5]);
  FreeError();
  return 5;
  }
for(int i=0; i< 30; i++)
  {
  ErrorList[i].LineNumber = 0;
  ErrorList[i].ErrorType = 0;
  }
return 0;
}

canonical_original_code:
int MakeErrList()
{
if(((ErrorList) = malloc((sizeof(TError))*30)) == ((void *)0))
  {
  fprintf(stderr, "\n%s",ECODEMSG[5]);
  FreeError();
  return 5;
  }
for(int i = 0; i< 30; i++)
  {
  ErrorList[i].LineNumber = 0;
  ErrorList[i].ErrorType = 0;
  }
return 0;
}


AddError

decompiled_code:
__int64 __fastcall AddError(int a1, int a2)
{
char *v2; // r12
int v3; // eax
__int64 v4; // rdx
__int64 result; // rax
char *v6; // rdx

ErrorFlag = a2;
v2 = (char *)ErrorList;
v3 = ErrorCounter;
if ( 30 * (ReallocCounter + 1) - 1 <= ErrorCounter )
{
++ReallocCounter;
v2 = (char *)realloc(ErrorList, 0xF8uLL);
if ( !v2 )
{
fprintf(stderr, "\n%s", *(&ECODEMSG + 5));
FreeError();
}
ErrorList = v2;
v3 = ErrorCounter;
}
v4 = v3;
result = (unsigned int)(v3 + 1);
v6 = &v2[8 * v4];
*(_DWORD *)v6 = a1;
*((_DWORD *)v6 + 1) = a2;
ErrorCounter = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2)
{
char *v2; // r12
int v3; // eax
__int64 v4; // rdx
__int64 result; // rax
char *v6; // rdx

ErrorFlag = a2;
v2 = (char *)ErrorList;
v3 = ErrorCounter;
if ( 30 * (ReallocCounter + 1) - 1 <= ErrorCounter )
{
++ReallocCounter;
v2 = (char *)realloc(ErrorList, 0xF8uLL);
if ( !v2 )
{
fprintf(stderr, "\n%s", *(&ECODEMSG + 5));
func2();
}
ErrorList = v2;
v3 = ErrorCounter;
}
v4 = v3;
result = (unsigned int)(v3 + 1);
v6 = &v2[8 * v4];
*(_DWORD *)v6 = a1;
*((_DWORD *)v6 + 1) = a2;
ErrorCounter = result;
return result;
}

original_code:
void AddError(int CisloRadku, int TypChyby)
{
TError *p_temp;
ErrorFlag = TypChyby;
if(ErrorCounter >= (30 + 30 * ReallocCounter -1))
   {
   ReallocCounter++;
   if((p_temp =realloc((ErrorList),sizeof(TError)*(30 +1))) == ((void *)0))
      {
      fprintf(stderr, "\n%s",ECODEMSG[5]);
      FreeError();
      }
   ErrorList = p_temp;
   }
ErrorList[ErrorCounter].LineNumber = CisloRadku;
ErrorList[ErrorCounter].ErrorType = TypChyby;
ErrorCounter++;
}

canonical_original_code:
void AddError(int CisloRadku, int TypChyby)
{
struct chyba *p_temp;
ErrorFlag = TypChyby;
if(ErrorCounter >= (30 + 30 * ReallocCounter -1))
   {
   ReallocCounter++;
   if((p_temp =realloc((ErrorList),sizeof(TError)*(30 +1))) == ((void *)0))
      {
      fprintf(stderr, "\n%s",ECODEMSG[5]);
      FreeError();
      }
   ErrorList = p_temp;
   }
ErrorList[ErrorCounter].LineNumber = CisloRadku;
ErrorList[ErrorCounter].ErrorType = TypChyby;
ErrorCounter++;
}

variable_types: CisloRadku int

variable_types: TypChyby int

user_defined_types: struct chyba { int LineNumber; int ErrorType; }


InitList

original_code:
void InitList (tList *L)
{
 L->Act = ((void *)0);
 L->First = ((void *)0);
 L->Last = ((void *)0);
 L->length = 0;
}

canonical_original_code:
void InitList(struct tList *L)
{
 L->Act = ((void *)0);
 L->First = ((void *)0);
 L->Last = ((void *)0);
 L->length = 0;
}

variable_types: struct tList { struct tElem { struct tElem *lptr; struct tElem *rptr; int *data; } *Act; struct tElem *First; struct tElem *Last; int length; } *

user_defined_types: struct tList { struct tElem *Act; struct tElem *First; struct tElem *Last; int length; }


InsertFirst

original_code:
int InsertFirst (tList *L, wchar_t *arr)
{
 tElemPtr new = ((void *)0);
 if ((new = malloc(sizeof(struct tElem))) == ((void *)0)) return EALLOC;
 else
 {
  L->length++;
  new->data = arr;
  new->lptr = ((void *)0);
  new->rptr = L->First;
  if (L->First == ((void *)0)) L->Last = new;
  else L->First->lptr = new;
  L->First = new;
 }
 return EOK;
}

canonical_original_code:
int InsertFirst(struct tList *L, int *arr)
{
 struct tElem *new = ((void *)0);
 if ((new = malloc(sizeof(struct tElem))) == ((void *)0)) return EALLOC;
 else
 {
  L->length++;
  new->data = arr;
  new->lptr = ((void *)0);
  new->rptr = L->First;
  if (L->First == ((void *)0)) L->Last = new;
  else L->First->lptr = new;
  L->First = new;
 }
 return EOK;
}

variable_types:
arr
int *

variable_types: struct tElem { struct tElem *lptr; struct tElem *rptr; int *data; } *


stringCompare

decompiled_code:
__int64 __fastcall stringCompare(const wchar_t *a1, const wchar_t *a2)
{
unsigned int v4; // er13
unsigned int v5; // eax
wchar_t v6; // er14
FILE **v7; // r9
unsigned int v8; // er10
unsigned int v9; // er11
unsigned int v10; // edi
__int64 v11; // rsi
wchar_t v12; // edx
wchar_t v13; // ecx
__int64 v14; // r8
wchar_t v15; // eax
__int64 v16; // r8
wchar_t v17; // eax
unsigned int v18; // er8
unsigned int v19; // eax
__int64 result; // rax

v4 = wcslen(a1);
v5 = wcslen(a2);
v6 = *a1;
v7 = (FILE **)&TAB;
v8 = v5;
v9 = v5 - 1;
do
{
v10 = 0;
LODWORD(v11) = 0;
if ( v6 )
{
do
{
v12 = a2[v10];
if ( !v12 )
break;
v13 = a1[(unsigned int)v11];
while ( 1 )
{
if ( v13 != 32 && v13 != 9 )
{
if ( v12 == 32 )
goto LABEL_11;
LABEL_15:
if ( v12 != 9 )
goto LABEL_16;
goto LABEL_11;
}
v14 = (unsigned int)(v11 + 1);
v15 = a1[v14];
if ( v15 != 32 && v15 != 9 )
break;
v13 = a1[v14];
LODWORD(v11) = v11 + 1;
}
while ( 1 )
{
if ( v12 != 32 )
goto LABEL_15;
LABEL_11:
v16 = v10 + 1;
v17 = a2[v16];
if ( v17 != 32 && v17 != 9 )
break;
v12 = a2[v16];
++v10;
}
LABEL_16:
v18 = *(&(*v7)->_flags + v13);
v19 = *(&(*v7)->_flags + v12);
if ( (v13 & 0xFFFFFFDF) == 67 && (a1[(unsigned int)(v11 + 1)] & 0xFFFFFFDF) == 72 && v4 - 1 > (unsigned int)v11 )
{
LODWORD(v11) = v11 + 1;
v18 = 15;
}
if ( (v12 & 0xFFFFFFDF) == 67 && (a2[v10 + 1] & 0xFFFFFFDF) == 72 && v9 > v10 )
{
++v10;
v19 = 15;
}
if ( v18 < v19 )
return 0xFFFFFFFFLL;
if ( v18 > v19 )
return 1LL;
++v10;
v11 = (unsigned int)(v11 + 1);
}
while ( a1[v11] );
}
++v7;
}
while ( &_bss_start != v7 );
result = v4 > v8;
if ( v4 < v8 )
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(const wchar_t *a1, const wchar_t *a2)
{
unsigned int v4; // er13
unsigned int v5; // eax
wchar_t v6; // er14
FILE **v7; // r9
unsigned int v8; // er10
unsigned int v9; // er11
unsigned int v10; // edi
__int64 v11; // rsi
wchar_t v12; // edx
wchar_t v13; // ecx
__int64 v14; // r8
wchar_t v15; // eax
__int64 v16; // r8
wchar_t v17; // eax
unsigned int v18; // er8
unsigned int v19; // eax
__int64 result; // rax

v4 = wcslen(a1);
v5 = wcslen(a2);
v6 = *a1;
v7 = (FILE **)&TAB;
v8 = v5;
v9 = v5 - 1;
do
{
v10 = 0;
LODWORD(v11) = 0;
if ( v6 )
{
do
{
v12 = a2[v10];
if ( !v12 )
break;
v13 = a1[(unsigned int)v11];
while ( 1 )
{
if ( v13 != 32 && v13 != 9 )
{
if ( v12 == 32 )
goto LABEL_11;
LABEL_15:
if ( v12 != 9 )
goto LABEL_16;
goto LABEL_11;
}
v14 = (unsigned int)(v11 + 1);
v15 = a1[v14];
if ( v15 != 32 && v15 != 9 )
break;
v13 = a1[v14];
LODWORD(v11) = v11 + 1;
}
while ( 1 )
{
if ( v12 != 32 )
goto LABEL_15;
LABEL_11:
v16 = v10 + 1;
v17 = a2[v16];
if ( v17 != 32 && v17 != 9 )
break;
v12 = a2[v16];
++v10;
}
LABEL_16:
v18 = *(&(*v7)->_flags + v13);
v19 = *(&(*v7)->_flags + v12);
if ( (v13 & 0xFFFFFFDF) == 67 && (a1[(unsigned int)(v11 + 1)] & 0xFFFFFFDF) == 72 && v4 - 1 > (unsigned int)v11 )
{
LODWORD(v11) = v11 + 1;
v18 = 15;
}
if ( (v12 & 0xFFFFFFDF) == 67 && (a2[v10 + 1] & 0xFFFFFFDF) == 72 && v9 > v10 )
{
++v10;
v19 = 15;
}
if ( v18 < v19 )
return 0xFFFFFFFFLL;
if ( v18 > v19 )
return 1LL;
++v10;
v11 = (unsigned int)(v11 + 1);
}
while ( a1[v11] );
}
++v7;
}
while ( &_bss_start != v7 );
result = v4 > v8;
if ( v4 < v8 )
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int stringCompare(wchar_t *first, wchar_t *second)
{
 wint_t value_f, value_s;
 wint_t slen_f, slen_s;
 wint_t i = 0, j = 0;
 slen_f = wcslen(first);
 slen_s = wcslen(second);
for (int tab = 0; tab <= 1; tab++)
{
 i=0, j=0;
 while (first[i] != L'\0' && second[j] != L'\0')
 {
  while((first[i] == L' ' || first[i] == L'\t') && (first[i+1] == L' ' || first[i+1] == L'\t')) i++;
  while((second[j] == L' ' || second[j] == L'\t') && (second[j+1] == L' ' || second[j+1] == L'\t')) j++;
  value_f = TAB[tab][(wchar_t) first[i]];
  value_s = TAB[tab][(wchar_t) second[j]];
  if ((first[i] == (L'c') || first[i] == (L'C')) && (first[i+1] == (L'h') || first[i+1] == (L'H')) && i < slen_f-1)
  {
   value_f = 15;
   i++;
  }
  if ((second[j] == (L'c') || second[j] == (L'C')) && (second[j+1] == (L'h') || second[j+1] == (L'H')) && j < slen_s-1)
  {
   value_s = 15;
   j++;
  }
  if(value_f < value_s) return -1;
  else if (value_f > value_s) return 1;
  else
  {
   i++;
   j++;
  }
 }
}
 if (slen_f < slen_s) return -1;
 else if (slen_f > slen_s) return 1;
 else
 {
  return 0;
 }
}

canonical_original_code:
int stringCompare(int *first, int *second)
{
 unsigned int value_f; unsigned int value_s;
 unsigned int slen_f; unsigned int slen_s;
 unsigned int i = 0; unsigned int j = 0;
 slen_f = wcslen(first);
 slen_s = wcslen(second);
for (int tab = 0; tab <= 1; tab++)
{
 i=0, j=0;
 while (first[i] != L'\0' && second[j] != L'\0')
 {
  while((first[i] == L' ' || first[i] == L'\t') && (first[i+1] == L' ' || first[i+1] == L'\t')) i++;
  while((second[j] == L' ' || second[j] == L'\t') && (second[j+1] == L' ' || second[j+1] == L'\t')) j++;
  value_f = TAB[tab][(int) first[i]];
  value_s = TAB[tab][(int) second[j]];
  if ((first[i] == (L'c') || first[i] == (L'C')) && (first[i+1] == (L'h') || first[i+1] == (L'H')) && i < slen_f-1)
  {
   value_f = 15;
   i++;
  }
  if ((second[j] == (L'c') || second[j] == (L'C')) && (second[j+1] == (L'h') || second[j+1] == (L'H')) && j < slen_s-1)
  {
   value_s = 15;
   j++;
  }
  if(value_f < value_s) return -1;
  else if (value_f > value_s) return 1;
  else
  {
   i++;
   j++;
  }
 }
}
 if (slen_f < slen_s) return -1;
 else if (slen_f > slen_s) return 1;
 else
 {
  return 0;
 }
}

variable_types:
first
int *

variable_types:
second
int *

variable_types:
i
unsigned int

variable_types:
j
unsigned int

variable_types: tab int


sortList

decompiled_code:
__int64 __fastcall sortList(__int64 *a1)
{
__int64 result; // rax
__int64 v2; // rbx
int v3; // er15
__int64 v4; // r13
const wchar_t *v5; // r14
const wchar_t *v6; // r12
unsigned int i; // [rsp+10h] [rbp-48h]
int v8; // [rsp+14h] [rbp-44h]
__int64 v9; // [rsp+18h] [rbp-40h]

v8 = *((_DWORD *)a1 + 6);
result = a1[1];
v9 = result;
*a1 = result;
if ( a1[2] != result || result )
{
result = (unsigned int)v8;
if ( v8 > 0 )
{
for ( i = 0; i != v8; result = i )
{
if ( v8 != 1 )
{
v2 = *a1;
v3 = 0;
do
{
v4 = v2;
v2 = *(_QWORD *)(v2 + 8);
v5 = *(const wchar_t **)(v4 + 16);
v6 = *(const wchar_t **)(v2 + 16);
if ( (unsigned int)stringCompare(v5, v6) == -1 )
{
*(_QWORD *)(v4 + 16) = v6;
*(_QWORD *)(v2 + 16) = v5;
}
*a1 = v2;
++v3;
}
while ( v8 - 1 != v3 );
}
++i;
*a1 = v9;
}
}
}
return result;
}

original_code:
void sortList(tList * L)
{
 int count = L->length;
 wchar_t *dataHelper;
 L->Act = L->First;
 if (L->First != L->Last || L->First != ((void *)0))
 {
  for (int i=0; i < count; i++)
  {
   for (int j = 0; j < count - 1; j++)
   {
    if (stringCompare(L->Act->data, L->Act->rptr->data) == -1)
    {
     dataHelper = L->Act->data;
     L->Act->data = L->Act->rptr->data;
     L->Act->rptr->data = dataHelper;
    }
    L->Act = L->Act->rptr;
   }
  L->Act = L->First;
  }
 }
}

canonical_original_code:
void sortList(struct tList *L)
{
 int count = L->length;
 int *dataHelper;
 L->Act = L->First;
 if (L->First != L->Last || L->First != ((void *)0))
 {
  for (int i = 0; i < count; i++)
  {
   for (int j = 0; j < count - 1; j++)
   {
    if (stringCompare(L->Act->data, L->Act->rptr->data) == -1)
    {
     dataHelper = L->Act->data;
     L->Act->data = L->Act->rptr->data;
     L->Act->rptr->data = dataHelper;
    }
    L->Act = L->Act->rptr;
   }
  L->Act = L->First;
  }
 }
}

variable_types: count int

variable_types:
dataHelper
int *

variable_types: j int

user_defined_types: struct tElem { struct tElem *lptr; struct tElem *rptr; int *data; }


locale

decompiled_code:
__int64 __fastcall locale(char *a1)
{
if ( a1 )
{
if ( setlocale(6, a1) )
return 0LL;
}
else
{
setlocale(6, byte_40208D);
if ( setlocale(6, 0LL) )
return 0LL;
}
return 6LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(char *a1)
{
if ( a1 )
{
if ( setlocale(6, a1) )
return 0LL;
}
else
{
setlocale(6, byte_40208D);
if ( setlocale(6, 0LL) )
return 0LL;
}
return 6LL;
}

original_code:
int locale (char* loc)
{
 if (loc == ((void *)0))
 {
  setlocale(6,"");
  if(setlocale(6, loc) == ((void *)0)) return ELOC;
 }
 else
 {
  if(setlocale(6, loc) == ((void *)0)) return ELOC;
 }
 return EOK;
}

canonical_original_code:
int locale(char *loc)
{
 if (loc == ((void *)0))
 {
  setlocale(6,"");
  if(setlocale(6, loc) == ((void *)0)) return ELOC;
 }
 else
 {
  if(setlocale(6, loc) == ((void *)0)) return ELOC;
 }
 return EOK;
}

variable_types:
loc
char *