TestSyckMapUpdate

decompiled_code:
__int64 __fastcall TestSyckMapUpdate(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // r13
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax

v1 = syck_new_map(51116LL, 51117LL);
syck_map_add(v1, 51118LL, 51119LL);
v2 = syck_new_map(51126LL, 51127LL);
syck_map_add(v2, 51128LL, 51129LL);
syck_map_update(v1, v2);
v3 = syck_map_read(v1, 0LL, 2LL);
CuAssert(a1, "Invalid key at '2'", v3 == 51126);
v4 = syck_map_read(v1, 0LL, 3LL);
CuAssert(a1, "Invalid key at '3'", v4 == 51128);
v5 = syck_map_read(v1, 1LL, 2LL);
CuAssert(a1, "Invalid value at '2'", v5 == 51127);
v6 = syck_map_read(v1, 1LL, 3LL);
CuAssert(a1, "Invalid value at '3'", v6 == 51129);
syck_free_node(v2);
return syck_free_node(v1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // r13
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax

v1 = syck_new_map(51116LL, 51117LL);
syck_map_add(v1, 51118LL, 51119LL);
v2 = syck_new_map(51126LL, 51127LL);
syck_map_add(v2, 51128LL, 51129LL);
syck_map_update(v1, v2);
v3 = syck_map_read(v1, 0LL, 2LL);
CuAssert(a1, "Invalid key at '2'", v3 == 51126);
v4 = syck_map_read(v1, 0LL, 3LL);
CuAssert(a1, "Invalid key at '3'", v4 == 51128);
v5 = syck_map_read(v1, 1LL, 2LL);
CuAssert(a1, "Invalid value at '2'", v5 == 51127);
v6 = syck_map_read(v1, 1LL, 3LL);
CuAssert(a1, "Invalid value at '3'", v6 == 51129);
syck_free_node(v2);
return syck_free_node(v1);
}

original_code:
void
TestSyckMapUpdate( CuTest *tc )
{
    SyckNode *n1, *n2;
    n1 = syck_new_map( 51116, 51117 );
    syck_map_add( n1, 51118, 51119 );
    n2 = syck_new_map( 51126, 51127 );
    syck_map_add( n2, 51128, 51129 );
    syck_map_update( n1, n2 );
    CuAssert( tc, "Invalid key at '2'", 51126 == syck_map_read( n1, map_key, 2 ) );
    CuAssert( tc, "Invalid key at '3'", 51128 == syck_map_read( n1, map_key, 3 ) );
    CuAssert( tc, "Invalid value at '2'", 51127 == syck_map_read( n1, map_value, 2 ) );
    CuAssert( tc, "Invalid value at '3'", 51129 == syck_map_read( n1, map_value, 3 ) );
    syck_free_node( n2 );
    syck_free_node( n1 );
}

canonical_original_code:
void TestSyckMapUpdate(struct CuTest *tc)
{
    struct _syck_node *n1; struct _syck_node *n2;
    n1 = syck_new_map( 51116, 51117 );
    syck_map_add( n1, 51118, 51119 );
    n2 = syck_new_map( 51126, 51127 );
    syck_map_add( n2, 51128, 51129 );
    syck_map_update( n1, n2 );
    CuAssert( tc, "Invalid key at '2'", 51126 == syck_map_read( n1, map_key, 2 ) );
    CuAssert( tc, "Invalid key at '3'", 51128 == syck_map_read( n1, map_key, 3 ) );
    CuAssert( tc, "Invalid value at '2'", 51127 == syck_map_read( n1, map_value, 2 ) );
    CuAssert( tc, "Invalid value at '3'", 51129 == syck_map_read( n1, map_value, 3 ) );
    syck_free_node( n2 );
    syck_free_node( n1 );
}


main

canonical_name: main

repo: xxx/mkrf

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
__int64 v4; // rbp
int v5; // er13

v3 = CuStringNew(argc, argv, envp);
v4 = SyckGetSuite();
CuSuiteRun(v4);
CuSuiteSummary(v4, v3);
CuSuiteDetails(v4, v3);
puts(*(const char **)(v3 + 8));
v5 = *(_DWORD *)(v4 + 8200);
CuStringFree(v3);
CuSuiteFree(v4);
return v5;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
__int64 v4; // rbp
int v5; // er13

v3 = CuStringNew(argc, argv, envp);
v4 = func4();
CuSuiteRun(v4);
CuSuiteSummary(v4, v3);
CuSuiteDetails(v4, v3);
puts(*(const char **)(v3 + 8));
v5 = *(_DWORD *)(v4 + 8200);
CuStringFree(v3);
CuSuiteFree(v4);
return v5;
}

original_code:
int main(void)
{
 CuString *output = CuStringNew();
 CuSuite* suite = SyckGetSuite();
    int count;
 CuSuiteRun(suite);
 CuSuiteSummary(suite, output);
 CuSuiteDetails(suite, output);
 printf("%s\n", output->buffer);
    count = suite->failCount;
    CuStringFree( output );
    CuSuiteFree( suite );
    return count;
}

canonical_original_code:
int main()
{
 struct CuString *output = CuStringNew();
 struct CuSuite *suite = SyckGetSuite();
    int count;
 CuSuiteRun(suite);
 CuSuiteSummary(suite, output);
 CuSuiteDetails(suite, output);
 printf("%s\n", output->buffer);
    count = suite->failCount;
    CuStringFree( output );
    CuSuiteFree( suite );
    return count;
}

variable_types: struct CuString { int length; int size; char *buffer; } *

variable_types: struct CuSuite { int count; struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*jumpBuf)[1]; } *list[1024]; int failCount; } *

variable_types: count int

return_type: int

user_defined_types: struct CuSuite { int count; struct CuTest *list[1024]; int failCount; }

user_defined_types: struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag (*jumpBuf)[1]; }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


decompiled_code:
void __fastcall syck_add_transfer(void *ptr, __int64 a2, int a3)
{
void *v5; // rdi

v5 = *(void **)(a2 + 16);
if ( v5 )
{
free(v5);
*(_QWORD *)(a2 + 16) = 0LL;
}
if ( a3 )
{
*(_QWORD *)(a2 + 16) = syck_type_id_to_uri(ptr);
free(ptr);
}
else
{
*(_QWORD *)(a2 + 16) = ptr;
}
}

canonical_decompiled_code:
void __fastcall func4(void *ptr, __int64 a2, int a3)
{
void *v5; // rdi

v5 = *(void **)(a2 + 16);
if ( v5 )
{
free(v5);
*(_QWORD *)(a2 + 16) = 0LL;
}
if ( a3 )
{
*(_QWORD *)(a2 + 16) = syck_type_id_to_uri(ptr);
free(ptr);
}
else
{
*(_QWORD *)(a2 + 16) = ptr;
}
}

original_code:
void
syck_add_transfer( char *uri, SyckNode *n, int taguri )
{
    if ( n->type_id != ((void *)0) )
    {
        free(n->type_id); n->type_id = ((void *)0);;
    }
    if ( taguri == 0 )
    {
        n->type_id = uri;
        return;
    }
    n->type_id = syck_type_id_to_uri( uri );
    free(uri); uri = ((void *)0);;
}

canonical_original_code:
void syck_add_transfer(char *uri, struct _syck_node *n, int taguri)
{
    if ( n->type_id != ((void *)0) )
    {
        free(n->type_id); n->type_id = ((void *)0);;
    }
    if ( taguri == 0 )
    {
        n->type_id = uri;
        return;
    }
    n->type_id = syck_type_id_to_uri( uri );
    free(uri); uri = ((void *)0);;
}

variable_types:
uri
char *

variable_types: struct _syck_node { unsigned long id; enum syck_kind_tag { syck_map_kind=0, syck_seq_kind=1, syck_str_kind=2 } kind; char *type_id; char *anchor; union { struct SyckMap { enum map_style { map_none=0, map_inline=1 } style; unsigned long *keys; unsigned long *values; long capa; long idx; } *pairs; struct SyckSeq { enum seq_style { seq_none=0, seq_inline=1 } style; unsigned long *items; long capa; long idx; } *list; struct SyckStr { enum scalar_style { scalar_none=0, scalar_1quote=1, scalar_2quote=2, scalar_fold=3, scalar_literal=4, scalar_plain=5 } style; char *ptr; long len; } *str; } data; void *shortcut; } *

variable_types: taguri int

return_type: void

user_defined_types: struct _syck_node { unsigned long id; enum syck_kind_tag kind; char *type_id; char *anchor; union { struct SyckMap *pairs; struct SyckSeq *list; struct SyckStr *str; } data; void *shortcut; }

user_defined_types: struct SyckMap { enum map_style style; unsigned long *keys; unsigned long *values; long capa; long idx; }

user_defined_types: struct SyckSeq { enum seq_style style; unsigned long *items; long capa; long idx; }

user_defined_types: struct SyckStr { enum scalar_style style; char *ptr; long len; }


decompiled_code:
char *__fastcall syck_xprivate(char *src, int a2)
{
char *v2; // rax

v2 = (char *)malloc(a2 + 14);
strcpy(v2, "x-private:");
return strncat(v2, src, a2);
}

canonical_decompiled_code:
char *__fastcall func5(char *src, int a2)
{
char *v2; // rax

v2 = (char *)malloc(a2 + 14);
strcpy(v2, "x-private:");
return strncat(v2, src, a2);
}

original_code:
char *
syck_xprivate( char *type_id, int type_len )
{
    char *uri = (char*)malloc(sizeof(char)*(type_len + 14));
    uri[0] = '\0';
    strcat( uri, "x-private:" );
    strncat( uri, type_id, type_len );
    return uri;
}

canonical_original_code:
char *syck_xprivate(char *type_id, int type_len)
{
    char *uri = (char*)malloc(sizeof(char)*(type_len + 14));
    uri[0] = '\0';
    strcat( uri, "x-private:" );
    strncat( uri, type_id, type_len );
    return uri;
}

return_type: char *


decompiled_code:
char *__fastcall syck_taguri(void *src, char *a2, int a3)
{
size_t v3; // r13
size_t v4; // rbx
char *v5; // rax
char *v6; // r12

v3 = a3;
v4 = strlen((const char *)src);
v5 = (char *)malloc(v3 + v4 + 14);
*(_DWORD *)v5 = 979853684;
v6 = v5;
memcpy(v5 + 4, src, v4);
*(_WORD *)&v6[v4 + 4] = 58;
return strncat(v6, a2, v3);
}

canonical_decompiled_code:
char *__fastcall func6(void *src, char *a2, int a3)
{
size_t v3; // r13
size_t v4; // rbx
char *v5; // rax
char *v6; // r12

v3 = a3;
v4 = strlen((const char *)src);
v5 = (char *)malloc(v3 + v4 + 14);
*(_DWORD *)v5 = 979853684;
v6 = v5;
memcpy(v5 + 4, src, v4);
*(_WORD *)&v6[v4 + 4] = 58;
return strncat(v6, a2, v3);
}

original_code:
char *
syck_taguri( char *domain, char *type_id, int type_len )
{
    char *uri = (char*)malloc(sizeof(char)*(strlen( domain ) + type_len + 14));
    uri[0] = '\0';
    strcat( uri, "tag:" );
    strcat( uri, domain );
    strcat( uri, ":" );
    strncat( uri, type_id, type_len );
    return uri;
}

canonical_original_code:
char *syck_taguri(char *domain, char *type_id, int type_len)
{
    char *uri = (char*)malloc(sizeof(char)*(strlen( domain ) + type_len + 14));
    uri[0] = '\0';
    strcat( uri, "tag:" );
    strcat( uri, domain );
    strcat( uri, ":" );
    strncat( uri, type_id, type_len );
    return uri;
}

variable_types:
domain
char *


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

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

original_code:
int
syck_try_implicit( SyckNode *n )
{
    return 1;
}

canonical_original_code:
int syck_try_implicit(struct _syck_node *n)
{
    return 1;
}

user_defined_types: enum syck_kind_tag { syck_map_kind=0, syck_seq_kind=1, syck_str_kind=2 }

user_defined_types: enum map_style { map_none=0, map_inline=1 }

user_defined_types: enum seq_style { seq_none=0, seq_inline=1 }

user_defined_types: enum scalar_style { scalar_none=0, scalar_1quote=1, scalar_2quote=2, scalar_fold=3, scalar_literal=4, scalar_plain=5 }


decompiled_code:
_DWORD *syck_alloc_map()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x28uLL);
*(_DWORD *)v0 = 0;
v1 = v0;
v0[4] = 0LL;
v0[3] = 8LL;
v0[1] = malloc(0x40uLL);
v1[2] = malloc(0x40uLL);
result = syck_alloc_node(0);
*((_QWORD *)result + 4) = v1;
return result;
}

canonical_decompiled_code:
_DWORD *func0()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x28uLL);
*(_DWORD *)v0 = 0;
v1 = v0;
v0[4] = 0LL;
v0[3] = 8LL;
v0[1] = malloc(0x40uLL);
v1[2] = malloc(0x40uLL);
result = syck_alloc_node(0);
*((_QWORD *)result + 4) = v1;
return result;
}

original_code:
SyckNode *
syck_alloc_map()
{
    SyckNode *n;
    struct SyckMap *m;
    m = (struct SyckMap*)malloc(sizeof(struct SyckMap));
    m->style = map_none;
    m->idx = 0;
    m->capa = 8;
    m->keys = (unsigned long*)malloc(sizeof(unsigned long)*(m->capa));
    m->values = (unsigned long*)malloc(sizeof(unsigned long)*(m->capa));
    n = syck_alloc_node( syck_map_kind );
    n->data.pairs = m;
    return n;
}

canonical_original_code:
struct _syck_node *syck_alloc_map()
{
    struct _syck_node *n;
    struct SyckMap *m;
    m = (struct SyckMap *)malloc(sizeof(struct SyckMap));
    m->style = map_none;
    m->idx = 0;
    m->capa = 8;
    m->keys = (unsigned long *)malloc(sizeof(unsigned long)*(m->capa));
    m->values = (unsigned long *)malloc(sizeof(unsigned long)*(m->capa));
    n = syck_alloc_node( syck_map_kind );
    n->data.pairs = m;
    return n;
}

return_type: struct _syck_node { unsigned long id; enum syck_kind_tag { syck_map_kind=0, syck_seq_kind=1, syck_str_kind=2 } kind; char *type_id; char *anchor; union { struct SyckMap { enum map_style { map_none=0, map_inline=1 } style; unsigned long *keys; unsigned long *values; long capa; long idx; } *pairs; struct SyckSeq { enum seq_style { seq_none=0, seq_inline=1 } style; unsigned long *items; long capa; long idx; } *list; struct SyckStr { enum scalar_style { scalar_none=0, scalar_1quote=1, scalar_2quote=2, scalar_fold=3, scalar_literal=4, scalar_plain=5 } style; char *ptr; long len; } *str; } data; void *shortcut; } *


decompiled_code:
_DWORD *syck_alloc_seq()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x20uLL);
*(_DWORD *)v0 = 0;
v1 = v0;
v0[3] = 0LL;
v0[2] = 8LL;
v0[1] = malloc(0x40uLL);
result = syck_alloc_node(1);
*((_QWORD *)result + 4) = v1;
return result;
}

canonical_decompiled_code:
_DWORD *func1()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x20uLL);
*(_DWORD *)v0 = 0;
v1 = v0;
v0[3] = 0LL;
v0[2] = 8LL;
v0[1] = malloc(0x40uLL);
result = syck_alloc_node(1);
*((_QWORD *)result + 4) = v1;
return result;
}

original_code:
SyckNode *
syck_alloc_seq()
{
    SyckNode *n;
    struct SyckSeq *s;
    s = (struct SyckSeq*)malloc(sizeof(struct SyckSeq));
    s->style = seq_none;
    s->idx = 0;
    s->capa = 8;
    s->items = (unsigned long*)malloc(sizeof(unsigned long)*(s->capa));
    n = syck_alloc_node( syck_seq_kind );
    n->data.list = s;
    return n;
}

canonical_original_code:
struct _syck_node *syck_alloc_seq()
{
    struct _syck_node *n;
    struct SyckSeq *s;
    s = (struct SyckSeq *)malloc(sizeof(struct SyckSeq));
    s->style = seq_none;
    s->idx = 0;
    s->capa = 8;
    s->items = (unsigned long *)malloc(sizeof(unsigned long)*(s->capa));
    n = syck_alloc_node( syck_seq_kind );
    n->data.list = s;
    return n;
}

variable_types: struct SyckSeq { enum seq_style { seq_none=0, seq_inline=1 } style; unsigned long *items; long capa; long idx; } *


decompiled_code:
_DWORD *syck_alloc_str()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x18uLL);
v0[2] = 0LL;
v1 = v0;
v0[1] = 0LL;
*(_DWORD *)v0 = 0;
result = syck_alloc_node(2);
*((_QWORD *)result + 4) = v1;
return result;
}

canonical_decompiled_code:
_DWORD *func2()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x18uLL);
v0[2] = 0LL;
v1 = v0;
v0[1] = 0LL;
*(_DWORD *)v0 = 0;
result = syck_alloc_node(2);
*((_QWORD *)result + 4) = v1;
return result;
}

original_code:
SyckNode *
syck_alloc_str()
{
    SyckNode *n;
    struct SyckStr *s;
    s = (struct SyckStr*)malloc(sizeof(struct SyckStr));
    s->len = 0;
    s->ptr = ((void *)0);
    s->style = scalar_none;
    n = syck_alloc_node( syck_str_kind );
    n->data.str = s;
    return n;
}

canonical_original_code:
struct _syck_node *syck_alloc_str()
{
    struct _syck_node *n;
    struct SyckStr *s;
    s = (struct SyckStr *)malloc(sizeof(struct SyckStr));
    s->len = 0;
    s->ptr = ((void *)0);
    s->style = scalar_none;
    n = syck_alloc_node( syck_str_kind );
    n->data.str = s;
    return n;
}

variable_types: struct SyckStr { enum scalar_style { scalar_none=0, scalar_1quote=1, scalar_2quote=2, scalar_fold=3, scalar_literal=4, scalar_plain=5 } style; char *ptr; long len; } *


decompiled_code:
__int64 __fastcall syck_replace_str(__int64 a1, const char *a2, int a3)
{
size_t v4; // rax

v4 = strlen(a2);
return syck_replace_str2(a1, a2, v4, a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char *a2, int a3)
{
size_t v4; // rax

v4 = strlen(a2);
return func3(a1, a2, v4, a3);
}

original_code:
void
syck_replace_str( SyckNode *n, char *str, enum scalar_style style )
{
    return syck_replace_str2( n, str, strlen( str ), style );
}

canonical_original_code:
void syck_replace_str(struct _syck_node *n, char *str, enum scalar_style style)
{
    return syck_replace_str2( n, str, strlen( str ), style );
}

variable_types:
str
char *

variable_types: enum scalar_style { scalar_none=0, scalar_1quote=1, scalar_2quote=2, scalar_fold=3, scalar_literal=4, scalar_plain=5 }


decompiled_code:
__int64 __fastcall syck_str_blow_away_commas(__int64 a1)
{
__int64 v2; // rdx
__int64 v3; // rax
unsigned __int8 *v4; // rdi
__int64 v5; // rbp
__int64 result; // rax
unsigned __int8 *v7; // rbx
__int64 v8; // rdx

v2 = *(_QWORD *)(a1 + 32);
v3 = *(_QWORD *)(v2 + 8);
v4 = (unsigned __int8 *)(v3 + 1);
v5 = v3 + *(_QWORD *)(v2 + 16);
for ( result = *(unsigned __int8 *)(v3 + 1); (_BYTE)result; ++v4 )
{
while ( 1 )
{
v7 = v4 + 1;
if ( (_BYTE)result == 44 )
break;
result = *v7;
++v4;
if ( !(_BYTE)result )
return result;
}
v8 = v5--;
--*(_QWORD *)(*(_QWORD *)(a1 + 32) + 16LL);
memmove(v4, v4 + 1, v8 - (_QWORD)v4);
result = *v7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v2; // rdx
__int64 v3; // rax
unsigned __int8 *v4; // rdi
__int64 v5; // rbp
__int64 result; // rax
unsigned __int8 *v7; // rbx
__int64 v8; // rdx

v2 = *(_QWORD *)(a1 + 32);
v3 = *(_QWORD *)(v2 + 8);
v4 = (unsigned __int8 *)(v3 + 1);
v5 = v3 + *(_QWORD *)(v2 + 16);
for ( result = *(unsigned __int8 *)(v3 + 1); (_BYTE)result; ++v4 )
{
while ( 1 )
{
v7 = v4 + 1;
if ( (_BYTE)result == 44 )
break;
result = *v7;
++v4;
if ( !(_BYTE)result )
return result;
}
v8 = v5--;
--*(_QWORD *)(*(_QWORD *)(a1 + 32) + 16LL);
memmove(v4, v4 + 1, v8 - (_QWORD)v4);
result = *v7;
}
return result;
}

original_code:
void
syck_str_blow_away_commas( SyckNode *n )
{
    char *go, *end;
    go = n->data.str->ptr;
    end = go + n->data.str->len;
    while ( *(++go) != '\0' )
    {
        if ( *go == ',' )
        {
            n->data.str->len -= 1;
            memmove( go, go + 1, end - go );
            end -= 1;
        }
    }
}

canonical_original_code:
void syck_str_blow_away_commas(struct _syck_node *n)
{
    char *go; char *end;
    go = n->data.str->ptr;
    end = go + n->data.str->len;
    while ( *(++go) != '\0' )
    {
        if ( *go == ',' )
        {
            n->data.str->len -= 1;
            memmove( go, go + 1, end - go );
            end -= 1;
        }
    }
}

variable_types:
go
char *

variable_types:
end
char *


decompiled_code:
__int64 __fastcall syck_str_read(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL);
}

original_code:
char *
syck_str_read( SyckNode *n )
{
    ;
    return n->data.str->ptr;
}

canonical_original_code:
char *syck_str_read(struct _syck_node *n)
{
    ;
    return n->data.str->ptr;
}


original_code:
void
syck_map_update( SyckNode *map1, SyckNode *map2 )
{
    struct SyckMap *m1, *m2;
    long new_idx, new_capa;
    ;
    ;
    m1 = map1->data.pairs;
    m2 = map2->data.pairs;
    if ( m2->idx < 1 ) return;
    new_idx = m1->idx;
    new_idx += m2->idx;
    new_capa = m1->capa;
    while ( new_idx > new_capa )
    {
        new_capa += 8;
    }
    if ( new_capa > m1->capa )
    {
        m1->capa = new_capa;
        (m1->keys)=(unsigned long*)realloc((char*)(m1->keys),sizeof(unsigned long)*(m1->capa));
        (m1->values)=(unsigned long*)realloc((char*)(m1->values),sizeof(unsigned long)*(m1->capa));
    }
    for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ )
    {
        m1->keys[m1->idx] = m2->keys[new_idx];
        m1->values[m1->idx] = m2->values[new_idx];
    }
}

canonical_original_code:
void syck_map_update(struct _syck_node *map1, struct _syck_node *map2)
{
    struct SyckMap *m1; struct SyckMap *m2;
    long new_idx; long new_capa;
    ;
    ;
    m1 = map1->data.pairs;
    m2 = map2->data.pairs;
    if ( m2->idx < 1 ) return;
    new_idx = m1->idx;
    new_idx += m2->idx;
    new_capa = m1->capa;
    while ( new_idx > new_capa )
    {
        new_capa += 8;
    }
    if ( new_capa > m1->capa )
    {
        m1->capa = new_capa;
        (m1->keys)=(unsigned long *)realloc((char *)(m1->keys),sizeof(unsigned long)*(m1->capa));
        (m1->values)=(unsigned long *)realloc((char *)(m1->values),sizeof(unsigned long)*(m1->capa));
    }
    for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ )
    {
        m1->keys[m1->idx] = m2->keys[new_idx];
        m1->values[m1->idx] = m2->values[new_idx];
    }
}

variable_types: struct SyckMap { enum map_style { map_none=0, map_inline=1 } style; unsigned long *keys; unsigned long *values; long capa; long idx; } *


decompiled_code:
__int64 __fastcall syck_map_count(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 32LL);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 32LL);
}

original_code:
long
syck_map_count( SyckNode *map )
{
    ;
    ;
    return map->data.pairs->idx;
}

canonical_original_code:
long syck_map_count(struct _syck_node *map)
{
    ;
    ;
    return map->data.pairs->idx;
}

return_type: long


decompiled_code:
__int64 __fastcall syck_map_assign(__int64 a1, int a2, __int64 a3, __int64 a4)
{
__int64 v4; // rax
__int64 result; // rax

v4 = *(_QWORD *)(a1 + 32);
if ( a2 )
result = *(_QWORD *)(v4 + 16);
else
result = *(_QWORD *)(v4 + 8);
*(_QWORD *)(result + 8 * a3) = a4;
return result;
}

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

v4 = *(_QWORD *)(a1 + 32);
if ( a2 )
result = *(_QWORD *)(v4 + 16);
else
result = *(_QWORD *)(v4 + 8);
*(_QWORD *)(result + 8 * a3) = a4;
return result;
}

original_code:
void
syck_map_assign( SyckNode *map, enum map_part p, long idx, unsigned long id )
{
    struct SyckMap *m;
    ;
    m = map->data.pairs;
    ;
    if ( p == map_key )
    {
        m->keys[idx] = id;
    }
    else
    {
        m->values[idx] = id;
    }
}

canonical_original_code:
void syck_map_assign(struct _syck_node *map, enum map_part p, long idx, unsigned long id)
{
    struct SyckMap *m;
    ;
    m = map->data.pairs;
    ;
    if ( p == map_key )
    {
        m->keys[idx] = id;
    }
    else
    {
        m->values[idx] = id;
    }
}

variable_types: enum map_part { map_key=0, map_value=1 }

variable_types: idx long

variable_types:
id
unsigned long


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

v3 = *(_QWORD *)(a1 + 32);
if ( a2 )
result = *(_QWORD *)(*(_QWORD *)(v3 + 16) + 8 * a3);
else
result = *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * a3);
return result;
}

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

v3 = *(_QWORD *)(a1 + 32);
if ( a2 )
result = *(_QWORD *)(*(_QWORD *)(v3 + 16) + 8 * a3);
else
result = *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * a3);
return result;
}

original_code:
unsigned long
syck_map_read( SyckNode *map, enum map_part p, long idx )
{
    struct SyckMap *m;
    ;
    m = map->data.pairs;
    ;
    if ( p == map_key )
    {
        return m->keys[idx];
    }
    else
    {
        return m->values[idx];
    }
}

canonical_original_code:
unsigned long syck_map_read(struct _syck_node *map, enum map_part p, long idx)
{
    struct SyckMap *m;
    ;
    m = map->data.pairs;
    ;
    if ( p == map_key )
    {
        return m->keys[idx];
    }
    else
    {
        return m->values[idx];
    }
}

return_type: unsigned long

user_defined_types: enum map_part { map_key=0, map_value=1 }


decompiled_code:
__int64 __fastcall syck_seq_count(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 24LL);
}

original_code:
long
syck_seq_count( SyckNode *seq )
{
    ;
    ;
    return seq->data.list->idx;
}

canonical_original_code:
long syck_seq_count(struct _syck_node *seq)
{
    ;
    ;
    return seq->data.list->idx;
}


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

result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL);
*(_QWORD *)(result + 8 * a2) = a3;
return result;
}

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

result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL);
*(_QWORD *)(result + 8 * a2) = a3;
return result;
}

original_code:
void
syck_seq_assign( SyckNode *seq, long idx, unsigned long id )
{
    struct SyckSeq *s;
    ;
    s = seq->data.list;
    ;
    s->items[idx] = id;
}

canonical_original_code:
void syck_seq_assign(struct _syck_node *seq, long idx, unsigned long id)
{
    struct SyckSeq *s;
    ;
    s = seq->data.list;
    ;
    s->items[idx] = id;
}


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

original_code:
unsigned long
syck_seq_read( SyckNode *seq, long idx )
{
    struct SyckSeq *s;
    ;
    s = seq->data.list;
    ;
    return s->items[idx];
}

canonical_original_code:
unsigned long syck_seq_read(struct _syck_node *seq, long idx)
{
    struct SyckSeq *s;
    ;
    s = seq->data.list;
    ;
    return s->items[idx];
}


original_code:
void
syck_free_members( SyckNode *n )
{
    if ( n == ((void *)0) ) return;
    switch ( n->kind )
    {
        case syck_str_kind:
            if ( n->data.str != ((void *)0) )
            {
                free(n->data.str->ptr); n->data.str->ptr = ((void *)0);;
                n->data.str->ptr = ((void *)0);
                n->data.str->len = 0;
                free(n->data.str); n->data.str = ((void *)0);;
                n->data.str = ((void *)0);
            }
        break;
        case syck_seq_kind:
            if ( n->data.list != ((void *)0) )
            {
                free(n->data.list->items); n->data.list->items = ((void *)0);;
                free(n->data.list); n->data.list = ((void *)0);;
                n->data.list = ((void *)0);
            }
        break;
        case syck_map_kind:
            if ( n->data.pairs != ((void *)0) )
            {
                free(n->data.pairs->keys); n->data.pairs->keys = ((void *)0);;
                free(n->data.pairs->values); n->data.pairs->values = ((void *)0);;
                free(n->data.pairs); n->data.pairs = ((void *)0);;
                n->data.pairs = ((void *)0);
            }
        break;
    }
}

canonical_original_code:
void syck_free_members(struct _syck_node *n)
{
    if ( n == ((void *)0) ) return;
    switch ( n->kind )
    {
        case syck_str_kind:
            if ( n->data.str != ((void *)0) )
            {
                free(n->data.str->ptr); n->data.str->ptr = ((void *)0);;
                n->data.str->ptr = ((void *)0);
                n->data.str->len = 0;
                free(n->data.str); n->data.str = ((void *)0);;
                n->data.str = ((void *)0);
            }
        break;
        case syck_seq_kind:
            if ( n->data.list != ((void *)0) )
            {
                free(n->data.list->items); n->data.list->items = ((void *)0);;
                free(n->data.list); n->data.list = ((void *)0);;
                n->data.list = ((void *)0);
            }
        break;
        case syck_map_kind:
            if ( n->data.pairs != ((void *)0) )
            {
                free(n->data.pairs->keys); n->data.pairs->keys = ((void *)0);;
                free(n->data.pairs->values); n->data.pairs->values = ((void *)0);;
                free(n->data.pairs); n->data.pairs = ((void *)0);;
                n->data.pairs = ((void *)0);
            }
        break;
    }
}


decompiled_code:
void __fastcall syck_free_node(void *ptr)
{
void *v2; // rdi
void *v3; // rdi

syck_free_members((__int64)ptr);
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 3);
if ( v3 )
free(v3);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func17(void *ptr)
{
void *v2; // rdi
void *v3; // rdi

func16((__int64)ptr);
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 3);
if ( v3 )
free(v3);
free(ptr);
}

original_code:
void
syck_free_node( SyckNode *n )
{
    syck_free_members( n );
    if ( n->type_id != ((void *)0) )
    {
        free(n->type_id); n->type_id = ((void *)0);;
        n->type_id = ((void *)0);
    }
    if ( n->anchor != ((void *)0) )
    {
        free(n->anchor); n->anchor = ((void *)0);;
        n->anchor = ((void *)0);
    }
    free(n); n = ((void *)0);;
}

canonical_original_code:
void syck_free_node(struct _syck_node *n)
{
    syck_free_members( n );
    if ( n->type_id != ((void *)0) )
    {
        free(n->type_id); n->type_id = ((void *)0);;
        n->type_id = ((void *)0);
    }
    if ( n->anchor != ((void *)0) )
    {
        free(n->anchor); n->anchor = ((void *)0);;
        n->anchor = ((void *)0);
    }
    free(n); n = ((void *)0);;
}


CuStrAlloc

decompiled_code:
void *__fastcall CuStrAlloc(int a1)
{
return malloc(a1);
}

canonical_decompiled_code:
void *__fastcall func0(int a1)
{
return malloc(a1);
}

original_code:
char* CuStrAlloc(int size)
{
 char* new = (char*) malloc( sizeof(char) * (size) );
 return new;
}

canonical_original_code:
char *CuStrAlloc(int size)
{
 char *new = (char*) malloc( sizeof(char) * (size) );
 return new;
}

variable_types: size int

variable_types:
new
char *


CuStrCopy

decompiled_code:
char *__fastcall CuStrCopy(char *src)
{
int v1; // eax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)CuStrAlloc(v1 + 1);
return strcpy(v2, src);
}

canonical_decompiled_code:
char *__fastcall func1(char *src)
{
int v1; // eax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)func0(v1 + 1);
return strcpy(v2, src);
}

original_code:
char* CuStrCopy(char* old)
{
 int len = strlen(old);
 char* new = CuStrAlloc(len + 1);
 strcpy(new, old);
 return new;
}

canonical_original_code:
char *CuStrCopy(char *old)
{
 int len = strlen(old);
 char *new = CuStrAlloc(len + 1);
 strcpy(new, old);
 return new;
}

variable_types:
old
char *

variable_types: len int


CuStringNew

decompiled_code:
_QWORD *CuStringNew()
{
_QWORD *v0; // r12
_BYTE *v1; // rax

v0 = malloc(0x10uLL);
*v0 = 0x10000000000LL;
v1 = malloc(0x100uLL);
v0[1] = v1;
*v1 = 0;
return v0;
}

original_code:
CuString* CuStringNew(void)
{
 CuString* str = (CuString*) malloc(sizeof(CuString));
 str->length = 0;
 str->size = 256;
 str->buffer = (char*) malloc(sizeof(char) * str->size);
 str->buffer[0] = '\0';
 return str;
}

canonical_original_code:
struct CuString *CuStringNew()
{
 struct CuString *str = (CuString*) malloc(sizeof(CuString));
 str->length = 0;
 str->size = 256;
 str->buffer = (char *) malloc(sizeof(char) * str->size);
 str->buffer[0] = '\0';
 return str;
}

variable_types: struct CuString { int length; int size; char *buffer; } *


CuStringResize

decompiled_code:
void *__fastcall CuStringResize(__int64 a1, int a2)
{
void *result; // rax

result = realloc(*(void **)(a1 + 8), a2);
*(_DWORD *)(a1 + 4) = a2;
*(_QWORD *)(a1 + 8) = result;
return result;
}

canonical_decompiled_code:
void *__fastcall func3(__int64 a1, int a2)
{
void *result; // rax

result = realloc(*(void **)(a1 + 8), a2);
*(_DWORD *)(a1 + 4) = a2;
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
void CuStringResize(CuString* str, int newSize)
{
 str->buffer = (char*) realloc(str->buffer, sizeof(char) * newSize);
 str->size = newSize;
}

canonical_original_code:
void CuStringResize(struct CuString *str, int newSize)
{
 str->buffer = (char *) realloc(str->buffer, sizeof(char) * newSize);
 str->size = newSize;
}

variable_types: newSize int

user_defined_types: struct CuString { int length; int size; char *buffer; }


CuStringAppendLen

decompiled_code:
char *__fastcall CuStringAppendLen(int *a1, const char *a2, __int64 a3)
{
__int64 v5; // rdx
char *v6; // rdi

v5 = *a1;
if ( a3 + v5 + 1 >= a1[1] )
{
CuStringResize((__int64)a1, v5 + a3 + 257);
LODWORD(v5) = *a1;
}
v6 = (char *)*((_QWORD *)a1 + 1);
*a1 = a3 + v5;
return strcat(v6, a2);
}

original_code:
void CuStringAppendLen(CuString* str, char* text, long length)
{
 if (str->length + length + 1 >= str->size)
  CuStringResize(str, str->length + length + 1 + 256);
 str->length += length;
 strcat(str->buffer, text);
}

canonical_original_code:
void CuStringAppendLen(struct CuString *str, char *text, long length)
{
 if (str->length + length + 1 >= str->size)
  CuStringResize(str, str->length + length + 1 + 256);
 str->length += length;
 strcat(str->buffer, text);
}

variable_types:
text
char *

variable_types: length long


CuStringAppend

decompiled_code:
char *__fastcall CuStringAppend(int *a1, const char *a2)
{
int v2; // eax

v2 = strlen(a2);
return CuStringAppendLen(a1, a2, v2);
}

canonical_decompiled_code:
char *__fastcall func5(int *a1, const char *a2)
{
int v2; // eax

v2 = strlen(a2);
return func4(a1, a2, v2);
}

original_code:
void CuStringAppend(CuString* str, char* text)
{
 int length = strlen(text);
    CuStringAppendLen(str, text, length);
}

canonical_original_code:
void CuStringAppend(struct CuString *str, char *text)
{
 int length = strlen(text);
    CuStringAppendLen(str, text, length);
}

variable_types: length int


CuStringAppendChar

decompiled_code:
char *__fastcall CuStringAppendChar(int *a1, char a2)
{
char v3[10]; // [rsp+Eh] [rbp-Ah] BYREF

v3[0] = a2;
v3[1] = 0;
return CuStringAppend(a1, v3);
}

canonical_decompiled_code:
char *__fastcall func6(int *a1, char a2)
{
char v3[10]; // [rsp+Eh] [rbp-Ah] BYREF

v3[0] = a2;
v3[1] = 0;
return func5(a1, v3);
}

original_code:
void CuStringAppendChar(CuString* str, char ch)
{
 char text[2];
 text[0] = ch;
 text[1] = '\0';
 CuStringAppend(str, text);
}

canonical_original_code:
void CuStringAppendChar(struct CuString *str, char ch)
{
 char text[2];
 text[0] = ch;
 text[1] = '\0';
 CuStringAppend(str, text);
}

variable_types: ch char

variable_types:
text
char [2]


CuStringAppendFormat

decompiled_code:
char *CuStringAppendFormat(int *a1, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-20D0h] BYREF
char s[8192]; // [rsp+20h] [rbp-20B8h] BYREF

va_start(arg, a2);
vsprintf(s, a2, arg);
return CuStringAppend(a1, s);
}

canonical_decompiled_code:
char *func7(int *a1, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-20D0h] BYREF
char s[8192]; // [rsp+20h] [rbp-20B8h] BYREF

va_start(arg, a2);
vsprintf(s, a2, arg);
return func5(a1, s);
}

original_code:
void CuStringAppendFormat(CuString* str, char* format, ...)
{
 va_list argp;
 char buf[8192];
 __builtin_va_start(argp,format);
 vsprintf(buf, format, argp);
 __builtin_va_end(argp);
 CuStringAppend(str, buf);
}

canonical_original_code:
void CuStringAppendFormat(struct CuString *str, char *format, ...)
{
 __builtin_va_list argp;
 char buf[8192];
 __builtin_va_start(argp,format);
 vsprintf(buf, format, argp);
 __builtin_va_end(argp);
 CuStringAppend(str, buf);
}

variable_types:
format
char *

variable_types:
buf
char [8192]


CuStringFree

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

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

original_code:
void CuStringFree(CuString* str)
{
    if ( str != ((void *)0) )
    {
        free( str->buffer );
        free( str );
    }
}

canonical_original_code:
void CuStringFree(struct CuString *str)
{
    if ( str != ((void *)0) )
    {
        free( str->buffer );
        free( str );
    }
}


CuTestInit

decompiled_code:
char *__fastcall CuTestInit(char **a1, char *a2, char *a3)
{
char *result; // rax

result = CuStrCopy(a2);
a1[1] = a3;
*a1 = result;
a1[2] = 0LL;
a1[3] = 0LL;
a1[4] = 0LL;
return result;
}

canonical_decompiled_code:
char *__fastcall func9(char **a1, char *a2, char *a3)
{
char *result; // rax

result = func1(a2);
a1[1] = a3;
*a1 = result;
a1[2] = 0LL;
a1[3] = 0LL;
a1[4] = 0LL;
return result;
}

original_code:
void CuTestInit(CuTest* t, char* name, TestFunction function)
{
 t->name = CuStrCopy(name);
 t->failed = 0;
 t->ran = 0;
 t->message = ((void *)0);
 t->function = function;
 t->jumpBuf = ((void *)0);
}

canonical_original_code:
void CuTestInit(struct CuTest *t, char *name, void (*function)(struct CuTest *))
{
 t->name = CuStrCopy(name);
 t->failed = 0;
 t->ran = 0;
 t->message = ((void *)0);
 t->function = function;
 t->jumpBuf = ((void *)0);
}

variable_types: struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*jumpBuf)[1]; } *

variable_types:
name
char *

variable_types:
function
void (*)(struct CuTest *)


CuTestNew

decompiled_code:
char **__fastcall CuTestNew(char *a1, char *a2)
{
char **v2; // r12

v2 = (char **)malloc(0x28uLL);
CuTestInit(v2, a1, a2);
return v2;
}

canonical_decompiled_code:
char **__fastcall func10(char *a1, char *a2)
{
char **v2; // r12

v2 = (char **)malloc(0x28uLL);
func9(v2, a1, a2);
return v2;
}

original_code:
CuTest* CuTestNew(char* name, TestFunction function)
{
 CuTest* tc = ((CuTest*) malloc(sizeof(CuTest)));
 CuTestInit(tc, name, function);
 return tc;
}

canonical_original_code:
struct CuTest *CuTestNew(char *name, void (*function)(struct CuTest *))
{
 struct CuTest *tc = ((CuTest*) malloc(sizeof(CuTest)));
 CuTestInit(tc, name, function);
 return tc;
}

return_type: struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*jumpBuf)[1]; } *


CuTestFree

decompiled_code:
void __fastcall CuTestFree(void *ptr)
{
if ( ptr )
{
free(*(void **)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func11(void *ptr)
{
if ( ptr )
{
free(*(void **)ptr);
free(ptr);
}
}

original_code:
void CuTestFree(CuTest* t)
{
    if ( t != ((void *)0) )
    {
        free( t->name );
        free( t );
    }
}

canonical_original_code:
void CuTestFree(struct CuTest *t)
{
    if ( t != ((void *)0) )
    {
        free( t->name );
        free( t );
    }
}

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }


CuFail

decompiled_code:
char *__fastcall CuFail(__int64 a1, char *a2)
{
char *result; // rax
struct __jmp_buf_tag *v4; // rdi

*(_DWORD *)(a1 + 16) = 1;
result = CuStrCopy(a2);
v4 = *(struct __jmp_buf_tag **)(a1 + 32);
*(_QWORD *)(a1 + 24) = result;
if ( v4 )
longjmp(v4, 0);
return result;
}

canonical_decompiled_code:
char *__fastcall func12(__int64 a1, char *a2)
{
char *result; // rax
struct __jmp_buf_tag *v4; // rdi

*(_DWORD *)(a1 + 16) = 1;
result = func1(a2);
v4 = *(struct __jmp_buf_tag **)(a1 + 32);
*(_QWORD *)(a1 + 24) = result;
if ( v4 )
longjmp(v4, 0);
return result;
}

original_code:
void CuFail(CuTest* tc, char* message)
{
 tc->failed = 1;
 tc->message = CuStrCopy(message);
 if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
}

canonical_original_code:
void CuFail(struct CuTest *tc, char *message)
{
 tc->failed = 1;
 tc->message = CuStrCopy(message);
 if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
}

variable_types:
message
char *


CuAssert

decompiled_code:
char *__fastcall CuAssert(__int64 a1, char *a2, int a3)
{
char *result; // rax

if ( !a3 )
result = CuFail(a1, a2);
return result;
}

canonical_decompiled_code:
char *__fastcall func13(__int64 a1, char *a2, int a3)
{
char *result; // rax

if ( !a3 )
result = func12(a1, a2);
return result;
}

original_code:
void CuAssert(CuTest* tc, char* message, int condition)
{
 if (condition) return;
 CuFail(tc, message);
}

canonical_original_code:
void CuAssert(struct CuTest *tc, char *message, int condition)
{
 if (condition) return;
 CuFail(tc, message);
}

variable_types: condition int


CuAssertTrue

decompiled_code:
char *__fastcall CuAssertTrue(__int64 a1, int a2)
{
char *result; // rax

if ( !a2 )
result = CuFail(a1, "assert failed");
return result;
}

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

if ( !a2 )
result = func12(a1, "assert failed");
return result;
}

original_code:
void CuAssertTrue(CuTest* tc, int condition)
{
 if (condition) return;
 CuFail(tc, "assert failed");
}

canonical_original_code:
void CuAssertTrue(struct CuTest *tc, int condition)
{
 if (condition) return;
 CuFail(tc, "assert failed");
}


CuAssertStrEquals

decompiled_code:
int __fastcall CuAssertStrEquals(__int64 a1, const char *a2, const char *a3)
{
int result; // eax
int *v5; // rbx

result = strcmp(a2, a3);
if ( result )
{
v5 = (int *)CuStringNew();
CuStringAppend(v5, "expected <");
CuStringAppend(v5, a2);
CuStringAppend(v5, "> but was <");
CuStringAppend(v5, a3);
CuStringAppend(v5, ">");
result = (unsigned int)CuFail(a1, *((char **)v5 + 1));
}
return result;
}

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

result = strcmp(a2, a3);
if ( result )
{
v5 = (int *)func2();
func5(v5, "expected <");
func5(v5, a2);
func5(v5, "> but was <");
func5(v5, a3);
func5(v5, ">");
result = (unsigned int)func12(a1, *((char **)v5 + 1));
}
return result;
}

original_code:
void CuAssertStrEquals(CuTest* tc, char* expected, char* actual)
{
 CuString* message;
 if (strcmp(expected, actual) == 0) return;
 message = CuStringNew();
 CuStringAppend(message, "expected <");
 CuStringAppend(message, expected);
 CuStringAppend(message, "> but was <");
 CuStringAppend(message, actual);
 CuStringAppend(message, ">");
 CuFail(tc, message->buffer);
}

canonical_original_code:
void CuAssertStrEquals(struct CuTest *tc, char *expected, char *actual)
{
 struct CuString *message;
 if (strcmp(expected, actual) == 0) return;
 message = CuStringNew();
 CuStringAppend(message, "expected <");
 CuStringAppend(message, expected);
 CuStringAppend(message, "> but was <");
 CuStringAppend(message, actual);
 CuStringAppend(message, ">");
 CuFail(tc, message->buffer);
}

variable_types:
expected
char *

variable_types:
actual
char *


CuAssertIntEquals

decompiled_code:
char *__fastcall CuAssertIntEquals(__int64 a1, unsigned int a2, unsigned int a3)
{
char *result; // rax
char v4[264]; // [rsp-108h] [rbp-108h] BYREF

if ( a2 != a3 )
{
sprintf(v4, "expected <%d> but was <%d>", a2, a3);
result = CuFail(a1, v4);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func16(__int64 a1, unsigned int a2, unsigned int a3)
{
char *result; // rax
char v4[264]; // [rsp-108h] [rbp-108h] BYREF

if ( a2 != a3 )
{
sprintf(v4, "expected <%d> but was <%d>", a2, a3);
result = func12(a1, v4);
}
return result;
}

original_code:
void CuAssertIntEquals(CuTest* tc, int expected, int actual)
{
 char buf[256];
 if (expected == actual) return;
 sprintf(buf, "expected <%d> but was <%d>", expected, actual);
 CuFail(tc, buf);
}

canonical_original_code:
void CuAssertIntEquals(struct CuTest *tc, int expected, int actual)
{
 char buf[256];
 if (expected == actual) return;
 sprintf(buf, "expected <%d> but was <%d>", expected, actual);
 CuFail(tc, buf);
}

variable_types: expected int

variable_types: actual int

variable_types:
buf
char [256]


CuAssertPtrEquals

decompiled_code:
char *__fastcall CuAssertPtrEquals(__int64 a1, const void *a2, const void *a3)
{
char *result; // rax
char v4[264]; // [rsp-108h] [rbp-108h] BYREF

if ( a2 != a3 )
{
sprintf(v4, "expected pointer <0x%p> but was <0x%p>", a2, a3);
result = CuFail(a1, v4);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func17(__int64 a1, const void *a2, const void *a3)
{
char *result; // rax
char v4[264]; // [rsp-108h] [rbp-108h] BYREF

if ( a2 != a3 )
{
sprintf(v4, "expected pointer <0x%p> but was <0x%p>", a2, a3);
result = func12(a1, v4);
}
return result;
}

original_code:
void CuAssertPtrEquals(CuTest* tc, void* expected, void* actual)
{
 char buf[256];
 if (expected == actual) return;
 sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual);
 CuFail(tc, buf);
}

canonical_original_code:
void CuAssertPtrEquals(struct CuTest *tc, void *expected, void *actual)
{
 char buf[256];
 if (expected == actual) return;
 sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual);
 CuFail(tc, buf);
}

variable_types:
expected
void *

variable_types:
actual
void *


CuAssertPtrNotNull

decompiled_code:
char *__fastcall CuAssertPtrNotNull(__int64 a1, __int64 a2)
{
char *result; // rax
__m128i v3; // [rsp+0h] [rbp-108h] BYREF
__int64 v4; // [rsp+10h] [rbp-F8h]

if ( !a2 )
{
v4 = 0x64657463657078LL;
v3 = _mm_load_si128((const __m128i *)&LC6);
result = CuFail(a1, v3.m128i_i8);
}
return result;
}

original_code:
void CuAssertPtrNotNull(CuTest* tc, void* pointer)
{
 char buf[256];
 if (pointer != ((void *)0) ) return;
 sprintf(buf, "null pointer unexpected");
 CuFail(tc, buf);
}

canonical_original_code:
void CuAssertPtrNotNull(struct CuTest *tc, void *pointer)
{
 char buf[256];
 if (pointer != ((void *)0) ) return;
 sprintf(buf, "null pointer unexpected");
 CuFail(tc, buf);
}

variable_types:
pointer
void *


CuTestRun

decompiled_code:
__int64 __fastcall CuTestRun(__int64 a1)
{
__int64 result; // rax
jmp_buf env; // [rsp+10h] [rbp-D8h] BYREF

*(_QWORD *)(a1 + 32) = env;
if ( !setjmp(env) )
{
*(_DWORD *)(a1 + 20) = 1;
(*(void (__fastcall **)(__int64))(a1 + 8))(a1);
}
result = a1;
*(_QWORD *)(a1 + 32) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
__int64 result; // rax
jmp_buf env; // [rsp+10h] [rbp-D8h] BYREF

*(_QWORD *)(a1 + 32) = env;
if ( !setjmp(env) )
{
*(_DWORD *)(a1 + 20) = 1;
(*(void (__fastcall **)(__int64))(a1 + 8))(a1);
}
result = a1;
*(_QWORD *)(a1 + 32) = 0LL;
return result;
}

original_code:
void CuTestRun(CuTest* tc)
{
 jmp_buf buf;
 tc->jumpBuf = &buf;
 if (_setjmp (buf) == 0)
 {
  tc->ran = 1;
  (tc->function)(tc);
 }
 tc->jumpBuf = 0;
}

canonical_original_code:
void CuTestRun(struct CuTest *tc)
{
 struct __jmp_buf_tag buf[1];
 tc->jumpBuf = &buf;
 if (_setjmp (buf) == 0)
 {
  tc->ran = 1;
  (tc->function)(tc);
 }
 tc->jumpBuf = 0;
}

variable_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } [1]


CuSuiteNew

decompiled_code:
void CuSuiteNew()
{
_DWORD *v0; // rax

v0 = malloc(0x2010uLL);
CuSuiteInit(v0);
}

canonical_decompiled_code:
void func21()
{
_DWORD *v0; // rax

v0 = malloc(0x2010uLL);
func20(v0);
}

original_code:
CuSuite* CuSuiteNew()
{
 CuSuite* testSuite = ((CuSuite*) malloc(sizeof(CuSuite)));
 CuSuiteInit(testSuite);
 return testSuite;
}

canonical_original_code:
struct CuSuite *CuSuiteNew()
{
 struct CuSuite *testSuite = ((CuSuite*) malloc(sizeof(CuSuite)));
 CuSuiteInit(testSuite);
 return testSuite;
}

variable_types: struct CuSuite { int count; struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*jumpBuf)[1]; } *list[1024]; int failCount; } *


CuSuiteFree

decompiled_code:
void __fastcall CuSuiteFree(void *ptr)
{
__int64 v2; // rbx
void *v3; // rdi

if ( *(int *)ptr > 0 )
{
v2 = 0LL;
do
{
v3 = (void *)*((_QWORD *)ptr + ++v2);
CuTestFree(v3);
}
while ( *(_DWORD *)ptr > (int)v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func22(void *ptr)
{
__int64 v2; // rbx
void *v3; // rdi

if ( *(int *)ptr > 0 )
{
v2 = 0LL;
do
{
v3 = (void *)*((_QWORD *)ptr + ++v2);
func11(v3);
}
while ( *(_DWORD *)ptr > (int)v2 );
}
free(ptr);
}

original_code:
void CuSuiteFree(CuSuite* testSuite)
{
 int i;
 for (i = 0 ; i < testSuite->count ; ++i)
 {
  CuTestFree( testSuite->list[i] );
 }
    free( testSuite );
}

canonical_original_code:
void CuSuiteFree(struct CuSuite *testSuite)
{
 int i;
 for (i = 0 ; i < testSuite->count ; ++i)
 {
  CuTestFree( testSuite->list[i] );
 }
    free( testSuite );
}

variable_types: i int


CuSuiteAdd

decompiled_code:
__int64 __fastcall CuSuiteAdd(int *a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax

v2 = *a1;
if ( *a1 > 1023 )
_assert_fail("testSuite->count < MAX_TEST_CASES", "CuTest.c", 0xDFu, "CuSuiteAdd");
v3 = v2;
result = (unsigned int)(v2 + 1);
*(_QWORD *)&a1[2 * v3 + 2] = a2;
*a1 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(int *a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax

v2 = *a1;
if ( *a1 > 1023 )
_assert_fail("testSuite->count < MAX_TEST_CASES", "CuTest.c", 0xDFu, "CuSuiteAdd");
v3 = v2;
result = (unsigned int)(v2 + 1);
*(_QWORD *)&a1[2 * v3 + 2] = a2;
*a1 = result;
return result;
}

original_code:
void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase)
{
 ((void) sizeof ((testSuite->count < 1024) ? 1 : 0), __extension__ ({ if (testSuite->count < 1024) ; else __assert_fail ("testSuite->count < MAX_TEST_CASES", "CuTest.c", 223, __extension__ __PRETTY_FUNCTION__); }));
 testSuite->list[testSuite->count] = testCase;
 testSuite->count++;
}

canonical_original_code:
void CuSuiteAdd(struct CuSuite *testSuite, struct CuTest *testCase)
{
 ((void) sizeof ((testSuite->count < 1024) ? 1 : 0), __extension__ ({ if (testSuite->count < 1024) ; else __assert_fail ("testSuite->count < MAX_TEST_CASES", "CuTest.c", 223, __extension__ __PRETTY_FUNCTION__); }));
 testSuite->list[testSuite->count] = testCase;
 testSuite->count++;
}

variable_types:
testCase
struct CuTest *


CuSuiteAddSuite

decompiled_code:
__int64 __fastcall CuSuiteAddSuite(int *a1, _DWORD *a2)
{
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // rsi

result = (unsigned int)*a2;
if ( (int)result > 0 )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)&a2[2 * v4++ + 2];
result = CuSuiteAdd(a1, v5);
}
while ( *a2 > (int)v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(int *a1, _DWORD *a2)
{
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // rsi

result = (unsigned int)*a2;
if ( (int)result > 0 )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)&a2[2 * v4++ + 2];
result = func23(a1, v5);
}
while ( *a2 > (int)v4 );
}
return result;
}

original_code:
void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2)
{
 int i;
 for (i = 0 ; i < testSuite2->count ; ++i)
 {
  CuTest* testCase = testSuite2->list[i];
  CuSuiteAdd(testSuite, testCase);
 }
}

canonical_original_code:
void CuSuiteAddSuite(struct CuSuite *testSuite, struct CuSuite *testSuite2)
{
 int i;
 for (i = 0 ; i < testSuite2->count ; ++i)
 {
  struct CuTest *testCase = testSuite2->list[i];
  CuSuiteAdd(testSuite, testCase);
 }
}

variable_types: struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*jumpBuf)[1]; } *


CuSuiteRun

decompiled_code:
__int64 __fastcall CuSuiteRun(int *a1)
{
__int64 v1; // rbx
__int64 v2; // r12
__int64 result; // rax

if ( *a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)&a1[2 * v1 + 2];
CuTestRun(v2);
result = *(unsigned int *)(v2 + 16);
if ( (_DWORD)result )
++a1[2050];
++v1;
}
while ( *a1 > (int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func25(int *a1)
{
__int64 v1; // rbx
__int64 v2; // r12
__int64 result; // rax

if ( *a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)&a1[2 * v1 + 2];
func19(v2);
result = *(unsigned int *)(v2 + 16);
if ( (_DWORD)result )
++a1[2050];
++v1;
}
while ( *a1 > (int)v1 );
}
return result;
}

original_code:
void CuSuiteRun(CuSuite* testSuite)
{
 int i;
 for (i = 0 ; i < testSuite->count ; ++i)
 {
  CuTest* testCase = testSuite->list[i];
  CuTestRun(testCase);
  if (testCase->failed) { testSuite->failCount += 1; }
 }
}

canonical_original_code:
void CuSuiteRun(struct CuSuite *testSuite)
{
 int i;
 for (i = 0 ; i < testSuite->count ; ++i)
 {
  struct CuTest *testCase = testSuite->list[i];
  CuTestRun(testCase);
  if (testCase->failed) { testSuite->failCount += 1; }
 }
}


CuSuiteSummary

decompiled_code:
char *__fastcall CuSuiteSummary(int *a1, int *a2)
{
__int64 v3; // rbx
const char *v4; // rsi

if ( *a1 > 0 )
{
v3 = 0LL;
do
{
v4 = ".";
if ( *(_DWORD *)(*(_QWORD *)&a1[2 * v3 + 2] + 16LL) )
v4 = "F";
++v3;
CuStringAppend(a2, v4);
}
while ( *a1 > (int)v3 );
}
return CuStringAppend(a2, "\n\n");
}

original_code:
void CuSuiteSummary(CuSuite* testSuite, CuString* summary)
{
 int i;
 for (i = 0 ; i < testSuite->count ; ++i)
 {
  CuTest* testCase = testSuite->list[i];
  CuStringAppend(summary, testCase->failed ? "F" : ".");
 }
 CuStringAppend(summary, "\n\n");
}

canonical_original_code:
void CuSuiteSummary(struct CuSuite *testSuite, struct CuString *summary)
{
 int i;
 for (i = 0 ; i < testSuite->count ; ++i)
 {
  struct CuTest *testCase = testSuite->list[i];
  CuStringAppend(summary, testCase->failed ? "F" : ".");
 }
 CuStringAppend(summary, "\n\n");
}

variable_types: struct CuString { int length; int size; char *buffer; } *


CuSuiteDetails

decompiled_code:
char *__fastcall CuSuiteDetails(unsigned int *a1, int *a2)
{
__int64 v2; // rdx
__int64 v3; // rdx
const char *v4; // rcx
char *result; // rax
__int64 v6; // rbx
unsigned int v7; // er13
__int64 v8; // rax

v2 = a1[2050];
if ( (_DWORD)v2 )
{
if ( (_DWORD)v2 == 1 )
CuStringAppend(a2, "There was 1 failure:\n");
else
CuStringAppendFormat(a2, "There were %d failures:\n", v2);
v6 = 0LL;
v7 = 0;
while ( (int)*a1 > (int)v6 )
{
while ( 1 )
{
v8 = *(_QWORD *)&a1[2 * v6 + 2];
if ( *(_DWORD *)(v8 + 16) )
break;
if ( (int)*a1 <= (int)++v6 )
goto LABEL_12;
}
++v7;
++v6;
CuStringAppendFormat(a2, "%d) %s: %s\n", v7, *(const char **)v8, *(const char **)(v8 + 24));
}
LABEL_12:
CuStringAppend(a2, "\n!!!FAILURES!!!\n");
CuStringAppendFormat(a2, "Runs: %d ", *a1);
CuStringAppendFormat(a2, "Passes: %d ", *a1 - a1[2050]);
result = CuStringAppendFormat(a2, "Fails: %d\n", a1[2050]);
}
else
{
v3 = *a1;
v4 = "test";
if ( (_DWORD)v3 != 1 )
v4 = "tests";
result = CuStringAppendFormat(a2, "OK (%d %s)\n", v3, v4);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func27(unsigned int *a1, int *a2)
{
__int64 v2; // rdx
__int64 v3; // rdx
const char *v4; // rcx
char *result; // rax
__int64 v6; // rbx
unsigned int v7; // er13
__int64 v8; // rax

v2 = a1[2050];
if ( (_DWORD)v2 )
{
if ( (_DWORD)v2 == 1 )
func5(a2, "There was 1 failure:\n");
else
func7(a2, "There were %d failures:\n", v2);
v6 = 0LL;
v7 = 0;
while ( (int)*a1 > (int)v6 )
{
while ( 1 )
{
v8 = *(_QWORD *)&a1[2 * v6 + 2];
if ( *(_DWORD *)(v8 + 16) )
break;
if ( (int)*a1 <= (int)++v6 )
goto LABEL_12;
}
++v7;
++v6;
func7(a2, "%d) %s: %s\n", v7, *(const char **)v8, *(const char **)(v8 + 24));
}
LABEL_12:
func5(a2, "\n!!!FAILURES!!!\n");
func7(a2, "Runs: %d ", *a1);
func7(a2, "Passes: %d ", *a1 - a1[2050]);
result = func7(a2, "Fails: %d\n", a1[2050]);
}
else
{
v3 = *a1;
v4 = "test";
if ( (_DWORD)v3 != 1 )
v4 = "tests";
result = func7(a2, "OK (%d %s)\n", v3, v4);
}
return result;
}

original_code:
void CuSuiteDetails(CuSuite* testSuite, CuString* details)
{
 int i;
 int failCount = 0;
 if (testSuite->failCount == 0)
 {
  int passCount = testSuite->count - testSuite->failCount;
  char* testWord = passCount == 1 ? "test" : "tests";
  CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord);
 }
 else
 {
  if (testSuite->failCount == 1)
   CuStringAppend(details, "There was 1 failure:\n");
  else
   CuStringAppendFormat(details, "There were %d failures:\n", testSuite->failCount);
  for (i = 0 ; i < testSuite->count ; ++i)
  {
   CuTest* testCase = testSuite->list[i];
   if (testCase->failed)
   {
    failCount++;
    CuStringAppendFormat(details, "%d) %s: %s\n",
     failCount, testCase->name, testCase->message);
   }
  }
  CuStringAppend(details, "\n!!!FAILURES!!!\n");
  CuStringAppendFormat(details, "Runs: %d ", testSuite->count);
  CuStringAppendFormat(details, "Passes: %d ", testSuite->count - testSuite->failCount);
  CuStringAppendFormat(details, "Fails: %d\n", testSuite->failCount);
 }
}

canonical_original_code:
void CuSuiteDetails(struct CuSuite *testSuite, struct CuString *details)
{
 int i;
 int failCount = 0;
 if (testSuite->failCount == 0)
 {
  int passCount = testSuite->count - testSuite->failCount;
  char *testWord = passCount == 1 ? "test" : "tests";
  CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord);
 }
 else
 {
  if (testSuite->failCount == 1)
   CuStringAppend(details, "There was 1 failure:\n");
  else
   CuStringAppendFormat(details, "There were %d failures:\n", testSuite->failCount);
  for (i = 0 ; i < testSuite->count ; ++i)
  {
   struct CuTest *testCase = testSuite->list[i];
   if (testCase->failed)
   {
    failCount++;
    CuStringAppendFormat(details, "%d) %s: %s\n",
     failCount, testCase->name, testCase->message);
   }
  }
  CuStringAppend(details, "\n!!!FAILURES!!!\n");
  CuStringAppendFormat(details, "Runs: %d ", testSuite->count);
  CuStringAppendFormat(details, "Passes: %d ", testSuite->count - testSuite->failCount);
  CuStringAppendFormat(details, "Fails: %d\n", testSuite->failCount);
 }
}

variable_types: failCount int

variable_types: passCount int

variable_types:
testWord
char *


original_code:
bytestring_t *bytestring_alloc() {
    bytestring_t *ret;
    ret = (bytestring_t*)malloc(sizeof(bytestring_t));
    ret->hash = ((long)0xCAFECAFE);
    ret->length = 64;
    ret->remaining = ret->length;
    ret->buffer = (char*)malloc(sizeof(char)*(ret->length + 1));
    ret->buffer[0] = 0;
    ret->printed = 0;
    return ret;
}

canonical_original_code:
struct bytestring_t *bytestring_alloc() {
    struct bytestring_t *ret;
    ret = (struct bytestring_t *)malloc(sizeof(bytestring_t));
    ret->hash = ((long)0xCAFECAFE);
    ret->length = 64;
    ret->remaining = ret->length;
    ret->buffer = (char *)malloc(sizeof(char)*(ret->length + 1));
    ret->buffer[0] = 0;
    ret->printed = 0;
    return ret;
}

variable_types: struct bytestring_t { long hash; char *buffer; long length; long remaining; int printed; } *


original_code:
void bytestring_append(bytestring_t *str, char code,
                       char *start, char *finish)
{
    long grow;
    long length = 2;
    char *curr;
    ((void) sizeof ((str && ((long)0xCAFECAFE) == str->hash) ? 1 : 0), __extension__ ({ if (str && ((long)0xCAFECAFE) == str->hash) ; else __assert_fail ("str && HASH == str->hash", "yaml2byte.c", 55, __extension__ __PRETTY_FUNCTION__); }));
    if(start) {
        if(!finish)
            finish = start + strlen(start);
        length += (finish-start);
    }
    if(length > str->remaining) {
        grow = (length - str->remaining) + 64;
        str->remaining += grow;
        str->length += grow;
        str->buffer = (str->buffer)=(char*)realloc((char*)(str->buffer),sizeof(char)*(str->length + 1));
        ((void) sizeof ((str->buffer) ? 1 : 0), __extension__ ({ if (str->buffer) ; else __assert_fail ("str->buffer", "yaml2byte.c", 67, __extension__ __PRETTY_FUNCTION__); }));
    }
    curr = str->buffer + (str->length - str->remaining);
    *curr = code;
    curr += 1;
    if(start)
        while(start < finish)
            *curr ++ = *start ++;
    *curr = '\n';
    curr += 1;
    *curr = 0;
    str->remaining = str->remaining - length;
    ((void) sizeof (((str->buffer + str->length) - str->remaining) ? 1 : 0), __extension__ ({ if ((str->buffer + str->length) - str->remaining) ; else __assert_fail ("(str->buffer + str->length) - str->remaining", "yaml2byte.c", 79, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
void bytestring_append(struct bytestring_t *str, char code, char *start, char *finish)
{
    long grow;
    long length = 2;
    char *curr;
    ((void) sizeof ((str && ((long)0xCAFECAFE) == str->hash) ? 1 : 0), __extension__ ({ if (str && ((long)0xCAFECAFE) == str->hash) ; else __assert_fail ("str && HASH == str->hash", "yaml2byte.c", 55, __extension__ __PRETTY_FUNCTION__); }));
    if(start) {
        if(!finish)
            finish = start + strlen(start);
        length += (finish-start);
    }
    if(length > str->remaining) {
        grow = (length - str->remaining) + 64;
        str->remaining += grow;
        str->length += grow;
        str->buffer = (str->buffer)=(char *)realloc((char *)(str->buffer),sizeof(char)*(str->length + 1));
        ((void) sizeof ((str->buffer) ? 1 : 0), __extension__ ({ if (str->buffer) ; else __assert_fail ("str->buffer", "yaml2byte.c", 67, __extension__ __PRETTY_FUNCTION__); }));
    }
    curr = str->buffer + (str->length - str->remaining);
    *curr = code;
    curr += 1;
    if(start)
        while(start < finish)
            *curr ++ = *start ++;
    *curr = '\n';
    curr += 1;
    *curr = 0;
    str->remaining = str->remaining - length;
    ((void) sizeof (((str->buffer + str->length) - str->remaining) ? 1 : 0), __extension__ ({ if ((str->buffer + str->length) - str->remaining) ; else __assert_fail ("(str->buffer + str->length) - str->remaining", "yaml2byte.c", 79, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: code char

variable_types:
start
char *

variable_types:
finish
char *

variable_types: grow long

variable_types: length long

variable_types:
curr
char *

user_defined_types: struct bytestring_t { long hash; char *buffer; long length; long remaining; int printed; }


original_code:
void bytestring_extend(bytestring_t *str, bytestring_t *ext)
{
    char *from;
    char *curr;
    char *stop;
    long grow;
    long length;
    ((void) sizeof ((str && ((long)0xCAFECAFE) == str->hash) ? 1 : 0), __extension__ ({ if (str && ((long)0xCAFECAFE) == str->hash) ; else __assert_fail ("str && HASH == str->hash", "yaml2byte.c", 88, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((ext && ((long)0xCAFECAFE) == ext->hash) ? 1 : 0), __extension__ ({ if (ext && ((long)0xCAFECAFE) == ext->hash) ; else __assert_fail ("ext && HASH == ext->hash", "yaml2byte.c", 89, __extension__ __PRETTY_FUNCTION__); }));
    if(ext->printed) {
        ((void) sizeof ((ext->buffer[0] ==((yamlbyte_char_t)'A')) ? 1 : 0), __extension__ ({ if (ext->buffer[0] ==((yamlbyte_char_t)'A')) ; else __assert_fail ("ext->buffer[0] ==YAMLBYTE_ANCHOR", "yaml2byte.c", 91, __extension__ __PRETTY_FUNCTION__); }));
        curr = ext->buffer;
        while( '\n' != *curr)
            curr++;
        bytestring_append(str, ((yamlbyte_char_t)'R'), ext->buffer + 1, curr);
    } else {
        ext->printed = 1;
        length = (ext->length - ext->remaining);
        if(length > str->remaining) {
            grow = (length - str->remaining) + 64;
            str->remaining += grow;
            str->length += grow;
            str->buffer = (str->buffer)=(char*)realloc((char*)(str->buffer),sizeof(char)*(str->length + 1));
        }
        curr = str->buffer + (str->length - str->remaining);
        from = ext->buffer;
        stop = ext->buffer + length;
        while( from < stop )
            *curr ++ = *from ++;
        *curr = 0;
        str->remaining = str->remaining - length;
        ((void) sizeof (((str->buffer + str->length) - str->remaining) ? 1 : 0), __extension__ ({ if ((str->buffer + str->length) - str->remaining) ; else __assert_fail ("(str->buffer + str->length) - str->remaining", "yaml2byte.c", 112, __extension__ __PRETTY_FUNCTION__); }));
    }
}

canonical_original_code:
void bytestring_extend(struct bytestring_t *str, struct bytestring_t *ext)
{
    char *from;
    char *curr;
    char *stop;
    long grow;
    long length;
    ((void) sizeof ((str && ((long)0xCAFECAFE) == str->hash) ? 1 : 0), __extension__ ({ if (str && ((long)0xCAFECAFE) == str->hash) ; else __assert_fail ("str && HASH == str->hash", "yaml2byte.c", 88, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((ext && ((long)0xCAFECAFE) == ext->hash) ? 1 : 0), __extension__ ({ if (ext && ((long)0xCAFECAFE) == ext->hash) ; else __assert_fail ("ext && HASH == ext->hash", "yaml2byte.c", 89, __extension__ __PRETTY_FUNCTION__); }));
    if(ext->printed) {
        ((void) sizeof ((ext->buffer[0] ==((unsigned char)'A')) ? 1 : 0), __extension__ ({ if (ext->buffer[0] ==((unsigned char)'A')) ; else __assert_fail ("ext->buffer[0] ==YAMLBYTE_ANCHOR", "yaml2byte.c", 91, __extension__ __PRETTY_FUNCTION__); }));
        curr = ext->buffer;
        while( '\n' != *curr)
            curr++;
        bytestring_append(str, ((unsigned char)'R'), ext->buffer + 1, curr);
    } else {
        ext->printed = 1;
        length = (ext->length - ext->remaining);
        if(length > str->remaining) {
            grow = (length - str->remaining) + 64;
            str->remaining += grow;
            str->length += grow;
            str->buffer = (str->buffer)=(char *)realloc((char *)(str->buffer),sizeof(char)*(str->length + 1));
        }
        curr = str->buffer + (str->length - str->remaining);
        from = ext->buffer;
        stop = ext->buffer + length;
        while( from < stop )
            *curr ++ = *from ++;
        *curr = 0;
        str->remaining = str->remaining - length;
        ((void) sizeof (((str->buffer + str->length) - str->remaining) ? 1 : 0), __extension__ ({ if ((str->buffer + str->length) - str->remaining) ; else __assert_fail ("(str->buffer + str->length) - str->remaining", "yaml2byte.c", 112, __extension__ __PRETTY_FUNCTION__); }));
    }
}

variable_types:
ext
struct bytestring_t *

variable_types:
from
char *

variable_types:
stop
char *


original_code:
long
syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
{
    char *beg;
    long len = 0;
    ;
    beg = str->ptr;
    if ( max_size >= 0 )
    {
        max_size -= skip;
        if ( max_size <= 0 ) max_size = 0;
        else str->ptr += max_size;
        if ( str->ptr > str->end )
        {
            str->ptr = str->end;
        }
    }
    else
    {
        while ( str->ptr < str->end ) {
            if (*(str->ptr++) == '\n') break;
        }
    }
    if ( beg < str->ptr )
    {
        len = ( str->ptr - beg );
        memcpy((buf + skip), (beg), sizeof(char)*(len));
    }
    len += skip;
    buf[len] = '\0';
    return len;
}

canonical_original_code:
long syck_io_str_read(char *buf, struct _syck_str *str, long max_size, long skip)
{
    char *beg;
    long len = 0;
    ;
    beg = str->ptr;
    if ( max_size >= 0 )
    {
        max_size -= skip;
        if ( max_size <= 0 ) max_size = 0;
        else str->ptr += max_size;
        if ( str->ptr > str->end )
        {
            str->ptr = str->end;
        }
    }
    else
    {
        while ( str->ptr < str->end ) {
            if (*(str->ptr++) == '\n') break;
        }
    }
    if ( beg < str->ptr )
    {
        len = ( str->ptr - beg );
        memcpy((buf + skip), (beg), sizeof(char)*(len));
    }
    len += skip;
    buf[len] = '\0';
    return len;
}

variable_types:
buf
char *

variable_types: struct _syck_str { char *beg; long (*read)(char *, struct _syck_str *, long, long); } *

variable_types: skip long

variable_types:
beg
char *

variable_types: len long


decompiled_code:
__int64 __fastcall syck_st_free_nodes(__int64 a1, __int64 a2)
{
if ( a2 != 1 )
syck_free_node(a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
if ( a2 != 1 )
syck_free_node(a2);
return 0LL;
}

original_code:
int
syck_st_free_nodes( char *key, SyckNode *n, char *arg )
{
    if ( n != (void *)1 ) syck_free_node( n );
    n = ((void *)0);
    return ST_CONTINUE;
}

canonical_original_code:
int syck_st_free_nodes(char *key, struct _syck_node *n, char *arg)
{
    if ( n != (void *)1 ) syck_free_node( n );
    n = ((void *)0);
    return ST_CONTINUE;
}

variable_types:
key
char *

variable_types: struct _syck_node { unsigned long id; enum syck_kind_tag { syck_map_kind=0, syck_seq_kind=1, syck_str_kind=2 } kind; char *type_id; char *anchor; union { struct SyckMap { enum map_style { map_none=0, map_inline=1 } style; unsigned long *keys; unsigned long *values; long capa; long idx; } *pairs; struct SyckSeq { enum seq_style { seq_none=0, seq_inline=1 } style; unsigned long *items; long capa; long idx; } *list; struct SyckStr { enum scalar_style { scalar_none=0, scalar_1quote=1, scalar_2quote=2, scalar_fold=3, scalar_literal=4, scalar_plain=5 } style; char *ptr; long len; } *str; } data; void *shortcut; } *

variable_types:
arg
char *


decompiled_code:
void __fastcall __noreturn syck_assert(const char *a1, unsigned int a2)
{
fflush(0LL);
fprintf(stderr, "\nAssertion failed: %s, line %u\n", a1, a2);
fflush(stderr);
abort();
}

canonical_decompiled_code:
void __fastcall __noreturn func3(const char *a1, unsigned int a2)
{
fflush(0LL);
fprintf(stderr, "\nAssertion failed: %s, line %u\n", a1, a2);
fflush(stderr);
abort();
}

original_code:
void
syck_assert( char *file_name, unsigned line_num )
{
    fflush( ((void *)0) );
    fprintf( stderr, "\nAssertion failed: %s, line %u\n",
             file_name, line_num );
    fflush( stderr );
    abort();
}

canonical_original_code:
void syck_assert(char *file_name, unsigned int line_num)
{
    fflush( ((void *)0) );
    fprintf( stderr, "\nAssertion failed: %s, line %u\n",
             file_name, line_num );
    fflush( stderr );
    abort();
}


decompiled_code:
void *__fastcall syck_strndup(void *src, size_t n)
{
void *v2; // rax

v2 = calloc(n + 1, 1uLL);
return memcpy(v2, src, n);
}

canonical_decompiled_code:
void *__fastcall func4(void *src, size_t n)
{
void *v2; // rax

v2 = calloc(n + 1, 1uLL);
return memcpy(v2, src, n);
}

original_code:
char *
syck_strndup( char *buf, long len )
{
    char *new = (char*)malloc(sizeof(char)*(len + 1));
    memset((new), 0, sizeof(char)*(len + 1));
    memcpy((new), (buf), sizeof(char)*(len));
    return new;
}

canonical_original_code:
char *syck_strndup(char *buf, long len)
{
    char *new = (char*)malloc(sizeof(char)*(len + 1));
    memset((new), 0, sizeof(char)*(len + 1));
    memcpy((new), (buf), sizeof(char)*(len));
    return new;
}

variable_types:
new
char *


decompiled_code:
_DWORD *st_init_numtable()
{
return st_init_table((__int64)&type_numhash);
}

canonical_decompiled_code:
_DWORD *func6()
{
return st_init_table((__int64)&type_numhash);
}

original_code:
st_table*
st_init_numtable()
{
    return st_init_table(&type_numhash);
}

canonical_original_code:
struct st_table *st_init_numtable()
{
    return st_init_table(&type_numhash);
}

return_type: struct st_table { struct st_hash_type { int (*compare)(); int (*hash)(); } *type; int num_bins; int num_entries; struct st_table_entry { unsigned int hash; char *key; char *record; struct st_table_entry *next; } **bins; } *

user_defined_types: struct st_table { struct st_hash_type *type; int num_bins; int num_entries; struct st_table_entry **bins; }


decompiled_code:
_DWORD *st_init_strtable()
{
return st_init_table((__int64)&type_strhash);
}

canonical_decompiled_code:
_DWORD *func7()
{
return st_init_table((__int64)&type_strhash);
}

original_code:
st_table*
st_init_strtable()
{
    return st_init_table(&type_strhash);
}

canonical_original_code:
struct st_table *st_init_strtable()
{
    return st_init_table(&type_strhash);
}

user_defined_types: struct st_hash_type { int (*compare)(); int (*hash)(); }

user_defined_types: struct st_table_entry { unsigned int hash; char *key; char *record; struct st_table_entry *next; }


ListAnchors

decompiled_code:
__int64 __fastcall ListAnchors(__int64 a1, __int64 a2, __int64 a3)
{
void *v4; // rbp

v4 = (void *)syck_strndup(*(_QWORD *)(*(_QWORD *)(a2 + 32) + 8LL), *(_QWORD *)(*(_QWORD *)(a2 + 32) + 16LL));
CuAssertStrEquals(a3, "test", a1);
CuAssertStrEquals(a3, "13", v4);
free(v4);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
void *v4; // rbp

v4 = (void *)syck_strndup(*(_QWORD *)(*(_QWORD *)(a2 + 32) + 8LL), *(_QWORD *)(*(_QWORD *)(a2 + 32) + 16LL));
CuAssertStrEquals(a3, "test", a1);
CuAssertStrEquals(a3, "13", v4);
free(v4);
return 0LL;
}

original_code:
enum st_retval
ListAnchors( char *key, SyckNode *n, CuTest *tc )
{
    char *sd = syck_strndup( n->data.str->ptr, n->data.str->len );
    CuAssertStrEquals( tc, "test", key );
    CuAssertStrEquals( tc, "13", sd );
    free( sd );
    return ST_CONTINUE;
}

canonical_original_code:
enum st_retval ListAnchors(char *key, struct _syck_node *n, struct CuTest *tc)
{
    char *sd = syck_strndup( n->data.str->ptr, n->data.str->len );
    CuAssertStrEquals( tc, "test", key );
    CuAssertStrEquals( tc, "13", sd );
    free( sd );
    return ST_CONTINUE;
}

variable_types: struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*jumpBuf)[1]; } *

variable_types:
sd
char *

return_type: enum st_retval { ST_CONTINUE=0, ST_STOP=1, ST_DELETE=2 }

user_defined_types: struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag (*jumpBuf)[1]; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
__int64 v4; // rbp
int v5; // er13

v3 = CuStringNew(argc, argv, envp);
v4 = SyckGetSuite();
CuSuiteRun(v4);
CuSuiteSummary(v4, v3);
CuSuiteDetails(v4, v3);
puts(*(const char **)(v3 + 8));
v5 = *(_DWORD *)(v4 + 8200);
CuStringFree(v3);
CuSuiteFree(v4);
return v5;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
__int64 v4; // rbp
int v5; // er13

v3 = CuStringNew(argc, argv, envp);
v4 = func9();
CuSuiteRun(v4);
CuSuiteSummary(v4, v3);
CuSuiteDetails(v4, v3);
puts(*(const char **)(v3 + 8));
v5 = *(_DWORD *)(v4 + 8200);
CuStringFree(v3);
CuSuiteFree(v4);
return v5;
}

original_code:
int main(void)
{
 CuString *output = CuStringNew();
 CuSuite* suite = SyckGetSuite();
    int count;
 CuSuiteRun(suite);
 CuSuiteSummary(suite, output);
 CuSuiteDetails(suite, output);
 printf("%s\n", output->buffer);
    count = suite->failCount;
    CuStringFree( output );
    CuSuiteFree( suite );
    return count;
}

canonical_original_code:
int main()
{
 struct CuString *output = CuStringNew();
 struct CuSuite *suite = SyckGetSuite();
    int count;
 CuSuiteRun(suite);
 CuSuiteSummary(suite, output);
 CuSuiteDetails(suite, output);
 printf("%s\n", output->buffer);
    count = suite->failCount;
    CuStringFree( output );
    CuSuiteFree( suite );
    return count;
}

variable_types: struct CuString { int length; int size; char *buffer; } *

variable_types: struct CuSuite { int count; struct CuTest { char *name; void (*function)(struct CuTest *); int failed; int ran; char *message; struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*jumpBuf)[1]; } *list[1024]; int failCount; } *

variable_types: count int

user_defined_types: struct CuSuite { int count; struct CuTest *list[1024]; int failCount; }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


variable_types:
gif
char []

variable_types:
enc
char *


canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
__int64 v4; // rbp
int v5; // er13

v3 = CuStringNew(argc, argv, envp);
v4 = func3();
CuSuiteRun(v4);
CuSuiteSummary(v4, v3);
CuSuiteDetails(v4, v3);
puts(*(const char **)(v3 + 8));
v5 = *(_DWORD *)(v4 + 8200);
CuStringFree(v3);
CuSuiteFree(v4);
return v5;
}


fatalError

repo: y-mitsui/harmonicCluster

decompiled_code:
void __fastcall __noreturn fatalError(const char *a1)
{
fputs(a1, stderr);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1)
{
fputs(a1, stderr);
exit(1);
}

original_code:
void fatalError(char *message){
 fprintf(stderr,"%s",message);
 exit(1);
}

variable_types:
message
char *


vectorScalarMult

decompiled_code:
double *__fastcall vectorScalarMult(__int64 a1, int a2, double a3)
{
double v3; // xmm1_8
double *v4; // r12
__int64 i; // rax

v3 = a3;
v4 = (double *)malloc(8LL * a2);
if ( !v4 )
{
fatalError("out of memory", a3, a3);
v3 = a3;
}
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
v4[i] = *(double *)(a1 + 8 * i) * v3;
}
return v4;
}

canonical_decompiled_code:
double *__fastcall func0(__int64 a1, int a2, double a3)
{
double v3; // xmm1_8
double *v4; // r12
__int64 i; // rax

v3 = a3;
v4 = (double *)malloc(8LL * a2);
if ( !v4 )
{
fatalError("out of memory", a3, a3);
v3 = a3;
}
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
v4[i] = *(double *)(a1 + 8 * i) * v3;
}
return v4;
}

original_code:
double* vectorScalarMult(double *x,int num,double y){
 double *result;
 { if((result=malloc(sizeof(double)*num))==((void *)0)){ fatalError("out of memory"); } };
 int i;
 for(i=0;i<num;i++){
  result[i]=x[i]*y;
 }
 return result;
}

canonical_original_code:
double *vectorScalarMult(double *x, int num, double y){
 double *result;
 { if((result=malloc(sizeof(double)*num))==((void *)0)){ fatalError("out of memory"); } };
 int i;
 for(i=0;i<num;i++){
  result[i]=x[i]*y;
 }
 return result;
}

variable_types:
x
double *

variable_types: num int

variable_types: y double

variable_types:
result
double *

variable_types: i int

return_type: double *


vectorVectorAdd

decompiled_code:
double *__fastcall vectorVectorAdd(__int64 a1, int a2, __int64 a3, double a4, double a5)
{
double *v6; // r12
__int64 i; // rax

v6 = (double *)malloc(8LL * a2);
if ( !v6 )
fatalError("out of memory", a4, a5);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
v6[i] = *(double *)(a1 + 8 * i) + *(double *)(a3 + 8 * i);
}
return v6;
}

canonical_decompiled_code:
double *__fastcall func1(__int64 a1, int a2, __int64 a3, double a4, double a5)
{
double *v6; // r12
__int64 i; // rax

v6 = (double *)malloc(8LL * a2);
if ( !v6 )
fatalError("out of memory", a4, a5);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
v6[i] = *(double *)(a1 + 8 * i) + *(double *)(a3 + 8 * i);
}
return v6;
}

original_code:
double* vectorVectorAdd(double* x,int num,double* y){
 double *result;
 { if((result=malloc(sizeof(double)*num))==((void *)0)){ fatalError("out of memory"); } };
 int i;
 for(i=0;i<num;i++){
  result[i]=x[i]+y[i];
 }
 return result;
}

canonical_original_code:
double *vectorVectorAdd(double *x, int num, double *y){
 double *result;
 { if((result=malloc(sizeof(double)*num))==((void *)0)){ fatalError("out of memory"); } };
 int i;
 for(i=0;i<num;i++){
  result[i]=x[i]+y[i];
 }
 return result;
}

variable_types:
y
double *


autocorr

decompiled_code:
double *__fastcall autocorr(double *a1, int a2, int a3, double a4, double a5)
{
__int64 v5; // r13
double *v7; // r12
__int64 v8; // rdx
double v9; // xmm1_8
double *v10; // rax
double v11; // xmm0_8

v5 = a3;
v7 = (double *)calloc(1uLL, 8LL * a3);
if ( !v7 )
fatalError("out of memory", a4, a5);
if ( a3 > 0 )
{
v8 = 0LL;
do
{
if ( a2 - (int)v8 > 0 )
{
v9 = v7[v8];
v10 = a1;
do
{
v11 = *v10 * v10[v8];
++v10;
v9 = v9 + v11;
}
while ( &a1[(unsigned int)(a2 - 1 - v8) + 1] != v10 );
v7[v8] = v9;
}
++v8;
}
while ( v5 != v8 );
}
return v7;
}

canonical_decompiled_code:
double *__fastcall func2(double *a1, int a2, int a3, double a4, double a5)
{
__int64 v5; // r13
double *v7; // r12
__int64 v8; // rdx
double v9; // xmm1_8
double *v10; // rax
double v11; // xmm0_8

v5 = a3;
v7 = (double *)calloc(1uLL, 8LL * a3);
if ( !v7 )
fatalError("out of memory", a4, a5);
if ( a3 > 0 )
{
v8 = 0LL;
do
{
if ( a2 - (int)v8 > 0 )
{
v9 = v7[v8];
v10 = a1;
do
{
v11 = *v10 * v10[v8];
++v10;
v9 = v9 + v11;
}
while ( &a1[(unsigned int)(a2 - 1 - v8) + 1] != v10 );
v7[v8] = v9;
}
++v8;
}
while ( v5 != v8 );
}
return v7;
}

original_code:
double *autocorr(const double *x,const int len,const int lagSize){
 double *r;
 int lag,j;
 { if((r=calloc(1,lagSize*sizeof(double)))==((void *)0)){ fatalError("out of memory"); } };
 for(lag=0;lag<lagSize;lag++){
  for(j=0;j<len-lag;j++){
   r[lag]+=(double)x[j] * x[j + lag];
  }
 }
 return r;
}

canonical_original_code:
double *autocorr(double *x, int len, int lagSize){
 double *r;
 int lag; int j;
 { if((r=calloc(1,lagSize*sizeof(double)))==((void *)0)){ fatalError("out of memory"); } };
 for(lag=0;lag<lagSize;lag++){
  for(j=0;j<len-lag;j++){
   r[lag]+=(double)x[j] * x[j + lag];
  }
 }
 return r;
}

variable_types: len int

variable_types: lagSize int

variable_types:
r
double *

variable_types: lag int

variable_types: j int


LevinsonDurbin

original_code:
double LevinsonDurbin(const double *r,double **A,const int lpcOrder){
 double *Ak;
 { if((Ak=calloc(1,(lpcOrder+1)*sizeof(double)))==((void *)0)){ fatalError("out of memory"); } };
 int k,j;
 double *U,*V;
 Ak[0] = 1.0;
 Ak[1] = - r[1] / r[0];
 double Ek = r[0] + r[1] * Ak[1];
 double lambda = - r[1] / r[0];
 { if((U=calloc(1,sizeof(double)*(lpcOrder+2)))==((void *)0)){ fatalError("out of memory"); } };
 { if((V=calloc(1,sizeof(double)*(lpcOrder+2)))==((void *)0)){ fatalError("out of memory"); } };
 for(k=1;k<lpcOrder;k++){
  lambda = 0.0;
  for(j=0;j<k+1;j++){
   lambda -= Ak[ j ] * r[ k + 1 - j ];
  }
  lambda /= Ek;
  U[0]=1.0;
  for(j=1;j<k+1;j++)
   U[j]=Ak[j];
  U[j]=0.0;
  V[0]=0.0;
  for(j=k;j>0;j--)
   V[k-j+1]=Ak[j];
  V[k-j+1]=1.0;
  double *v=vectorScalarMult(V,k+2,lambda);
  free(Ak);
  Ak=vectorVectorAdd(U,k+2,v);
  free(v);
  Ek *= 1.0 - lambda * lambda;
 }
 *A=&Ak[0];
 free(U);
 free(V);
 return Ek;
}

canonical_original_code:
double LevinsonDurbin(double *r, double **A, int lpcOrder){
 double *Ak;
 { if((Ak=calloc(1,(lpcOrder+1)*sizeof(double)))==((void *)0)){ fatalError("out of memory"); } };
 int k; int j;
 double *U; double *V;
 Ak[0] = 1.0;
 Ak[1] = - r[1] / r[0];
 double Ek = r[0] + r[1] * Ak[1];
 double lambda = - r[1] / r[0];
 { if((U=calloc(1,sizeof(double)*(lpcOrder+2)))==((void *)0)){ fatalError("out of memory"); } };
 { if((V=calloc(1,sizeof(double)*(lpcOrder+2)))==((void *)0)){ fatalError("out of memory"); } };
 for(k=1;k<lpcOrder;k++){
  lambda = 0.0;
  for(j=0;j<k+1;j++){
   lambda -= Ak[ j ] * r[ k + 1 - j ];
  }
  lambda /= Ek;
  U[0]=1.0;
  for(j=1;j<k+1;j++)
   U[j]=Ak[j];
  U[j]=0.0;
  V[0]=0.0;
  for(j=k;j>0;j--)
   V[k-j+1]=Ak[j];
  V[k-j+1]=1.0;
  double *v = vectorScalarMult(V,k+2,lambda);
  free(Ak);
  Ak=vectorVectorAdd(U,k+2,v);
  free(v);
  Ek *= 1.0 - lambda * lambda;
 }
 *A=&Ak[0];
 free(U);
 free(V);
 return Ek;
}

variable_types:
A
double **

variable_types: lpcOrder int

variable_types:
Ak
double *

variable_types: k int

variable_types:
U
double *

variable_types:
V
double *

variable_types: Ek double

variable_types: lambda double

variable_types:
v
double *

return_type: double


deleteList

decompiled_code:
__int64 __fastcall deleteList(_QWORD **a1)
{
_QWORD *v1; // r8

v1 = *a1;
if ( !*a1 )
return 0xFFFFFFFFLL;
*a1 = (_QWORD *)*v1;
free(v1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD **a1)
{
_QWORD *v1; // r8

v1 = *a1;
if ( !*a1 )
return 0xFFFFFFFFLL;
*a1 = (_QWORD *)*v1;
free(v1);
return 0LL;
}

original_code:
int
deleteList(cell_t* p)
{
  cell_t *tmp;
  if(p->next == ((void *)0))
  {
    return(-1);
  }
  tmp = p->next;
  p->next = tmp->next;
  free(tmp);
  return(0);
}

canonical_original_code:
int deleteList(struct _cell_t *p)
{
  struct _cell_t *tmp;
  if(p->next == ((void *)0))
  {
    return(-1);
  }
  tmp = p->next;
  p->next = tmp->next;
  free(tmp);
  return(0);
}

variable_types: struct _cell_t { struct _cell_t *next; void *data; } *


decompiled_code:
void __fastcall Free_Sound(void *ptr)
{
__int16 v1; // ax

if ( *(_WORD *)ptr == 1 )
{
v1 = *((_WORD *)ptr + 8);
if ( v1 == 8 )
{
free(*((void **)ptr + 4));
goto LABEL_5;
}
if ( v1 == 16 )
{
free(*((void **)ptr + 5));
goto LABEL_5;
}
}
else if ( *(_WORD *)ptr == 2 && *((_WORD *)ptr + 8) == 8 )
{
free(*((void **)ptr + 6));
goto LABEL_5;
}
free(*((void **)ptr + 7));
LABEL_5:
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
__int16 v1; // ax

if ( *(_WORD *)ptr == 1 )
{
v1 = *((_WORD *)ptr + 8);
if ( v1 == 8 )
{
free(*((void **)ptr + 4));
goto LABEL_5;
}
if ( v1 == 16 )
{
free(*((void **)ptr + 5));
goto LABEL_5;
}
}
else if ( *(_WORD *)ptr == 2 && *((_WORD *)ptr + 8) == 8 )
{
free(*((void **)ptr + 6));
goto LABEL_5;
}
free(*((void **)ptr + 7));
LABEL_5:
free(ptr);
}

original_code:
void Free_Sound(Sound *snd)
{
 if(snd->channelnum == 1 && snd->bit_per_sample == 8){
  free(snd->monaural8);
 }else if(snd->channelnum == 1 && snd->bit_per_sample == 16){
  free(snd->monaural16);
 }else if(snd->channelnum == 2 && snd->bit_per_sample == 8){
  free(snd->stereo8);
 }else{
  free(snd->stereo16);
 }
 free(snd);
}

canonical_original_code:
void Free_Sound(struct Sound *snd)
{
 if(snd->channelnum == 1 && snd->bit_per_sample == 8){
  free(snd->monaural8);
 }else if(snd->channelnum == 1 && snd->bit_per_sample == 16){
  free(snd->monaural16);
 }else if(snd->channelnum == 2 && snd->bit_per_sample == 8){
  free(snd->stereo8);
 }else{
  free(snd->stereo16);
 }
 free(snd);
}

variable_types: struct Sound { unsigned short channelnum; unsigned long samplingrate; unsigned short bit_per_sample; unsigned long datanum; unsigned char *monaural8; short *monaural16; struct Soundsample8 { unsigned char l; unsigned char r; } *stereo8; struct Soundsample16 { short l; short r; } *stereo16; } *

user_defined_types: struct Sound { unsigned short channelnum; unsigned long samplingrate; unsigned short bit_per_sample; unsigned long datanum; unsigned char *monaural8; short *monaural16; struct Soundsample8 *stereo8; struct Soundsample16 *stereo16; }


fatalError

repo: y-mitsui/kernelRegression

canonical_original_code:
void fatalError(char *message){
 fprintf(stderr,"%s",message);
 exit(1);
}

variable_types:
message
char *


kernel

original_code:
double kernel(double *x1,double *x2,int num,double gamma){
 VEC *xVector,*yVector,*diffVector;
 int i;
 xVector=v_get(num);
 memcpy(xVector->ve,x1,sizeof(double)*num);
 yVector=v_get(num);
 memcpy(yVector->ve,x2,sizeof(double)*num);
 diffVector=v_sub(xVector,yVector,((void *)0));
 double sum=0.0;
 for(i=0;i<num;i++){
  sum+=diffVector->ve[i]*diffVector->ve[i];
 }
 v_free(diffVector);
 v_free(xVector);
 v_free(yVector);
 return exp(-gamma*sum);
}

canonical_original_code:
double kernel(double *x1, double *x2, int num, double gamma){
 struct VEC *xVector; struct VEC *yVector; struct VEC *diffVector;
 int i;
 xVector=v_get(num);
 memcpy(xVector->ve,x1,sizeof(double)*num);
 yVector=v_get(num);
 memcpy(yVector->ve,x2,sizeof(double)*num);
 diffVector=v_sub(xVector,yVector,((void *)0));
 double sum = 0.0;
 for(i=0;i<num;i++){
  sum+=diffVector->ve[i]*diffVector->ve[i];
 }
 v_free(diffVector);
 v_free(xVector);
 v_free(yVector);
 return exp(-gamma*sum);
}

variable_types: num int

variable_types: gamma double

variable_types: struct VEC { unsigned int dim; double *ve; } *

variable_types: i int

variable_types: sum double


kernelRegression

original_code:
double *kernelRegression(double **x,int dimention,double *y,int num,double gamma,double regilarization){
 VEC *label;
 MAT *gram,*ident,*inv;
 int i,j;
 double *result;
 ident = m_get(num,num);
 label = v_get(num);
 memcpy(label->ve,y,sizeof(double)*num);
 gram = m_get(num,num);
 ident = m_get(num,num);
 for(i=0;i<num;i++){
  for(j=0;j<num;j++){
   gram->me[i][j]=kernel(x[i],x[j],dimention,gamma);
  }
 }
 inv=m_add(gram,sm_mlt(regilarization,m_ident(ident),((void *)0)),((void *)0));
 inv=m_inverse(inv,((void *)0));
 VEC *coefficient=v_get(num);
 mv_mlt(inv,label,coefficient);
 result=malloc(sizeof(double)*num);
 memcpy(result,coefficient->ve,sizeof(double)*num);
 m_free(ident);
 m_free(gram);
 m_free(inv);
 v_free(label);
 v_free(coefficient);
 return result;
}

canonical_original_code:
double *kernelRegression(double **x, int dimention, double *y, int num, double gamma, double regilarization){
 struct VEC *label;
 struct MAT *gram; struct MAT *ident; struct MAT *inv;
 int i; int j;
 double *result;
 ident = m_get(num,num);
 label = v_get(num);
 memcpy(label->ve,y,sizeof(double)*num);
 gram = m_get(num,num);
 ident = m_get(num,num);
 for(i=0;i<num;i++){
  for(j=0;j<num;j++){
   gram->me[i][j]=kernel(x[i],x[j],dimention,gamma);
  }
 }
 inv=m_add(gram,sm_mlt(regilarization,m_ident(ident),((void *)0)),((void *)0));
 inv=m_inverse(inv,((void *)0));
 struct VEC *coefficient = v_get(num);
 mv_mlt(inv,label,coefficient);
 result=malloc(sizeof(double)*num);
 memcpy(result,coefficient->ve,sizeof(double)*num);
 m_free(ident);
 m_free(gram);
 m_free(inv);
 v_free(label);
 v_free(coefficient);
 return result;
}

variable_types:
x
double **

variable_types: dimention int

variable_types:
y
double *

variable_types: regilarization double

variable_types: struct MAT { unsigned int m; unsigned int max_m; double **me; } *

variable_types: j int

variable_types:
result
double *

user_defined_types: struct VEC { unsigned int dim; double *ve; }


repo: ya-jeks/gsmmux

decompiled_code:
__int64 __fastcall make_fcs(_BYTE *a1, int a2)
{
__int64 v2; // rdx
int v3; // eax
unsigned __int8 v4; // al

if ( a2 <= 0 )
return 0LL;
v2 = (__int64)&a1[a2 - 1 + 1];
LOBYTE(v3) = -1;
do
{
v4 = *a1++ ^ v3;
v3 = (unsigned __int8)r_crctable[v4];
}
while ( (_BYTE *)v2 != a1 );
return (unsigned int)~v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, int a2)
{
__int64 v2; // rdx
int v3; // eax
unsigned __int8 v4; // al

if ( a2 <= 0 )
return 0LL;
v2 = (__int64)&a1[a2 - 1 + 1];
LOBYTE(v3) = -1;
do
{
v4 = *a1++ ^ v3;
v3 = (unsigned __int8)r_crctable[v4];
}
while ( (_BYTE *)v2 != a1 );
return (unsigned int)~v3;
}

original_code:
unsigned char make_fcs(const unsigned char *input, int count) {
  unsigned char fcs = 0xFF;
  int i;
  for (i = 0; i < count; i++) {
    fcs = r_crctable[fcs^input[i]];
  }
  return (0xFF-fcs);
}

canonical_original_code:
unsigned char make_fcs(unsigned char *input, int count) {
  unsigned char fcs = 0xFF;
  int i;
  for (i = 0; i < count; i++) {
    fcs = r_crctable[fcs^input[i]];
  }
  return (0xFF-fcs);
}

variable_types:
input
unsigned char *

variable_types: count int

variable_types:
fcs
unsigned char

return_type: unsigned char


decompiled_code:
_QWORD *gsm0710_buffer_init()
{
_QWORD *result; // rax

result = calloc(0x830uLL, 1uLL);
if ( result )
{
result[256] = result;
result[257] = result;
result[258] = result + 256;
}
return result;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *result; // rax

result = calloc(0x830uLL, 1uLL);
if ( result )
{
result[256] = result;
result[257] = result;
result[258] = result + 256;
}
return result;
}

original_code:
GSM0710_Buffer *gsm0710_buffer_init() {
  GSM0710_Buffer *buf;
  if ((buf = malloc(sizeof(GSM0710_Buffer)))) {
    memset(buf, 0, sizeof(GSM0710_Buffer));
    buf->readp = buf->data;
    buf->writep = buf->data;
    buf->endp = buf->data + 2048;
  }
  return buf;
}

canonical_original_code:
struct GSM0710_Buffer *gsm0710_buffer_init() {
  struct GSM0710_Buffer *buf;
  if ((buf = malloc(sizeof(GSM0710_Buffer)))) {
    memset(buf, 0, sizeof(GSM0710_Buffer));
    buf->readp = buf->data;
    buf->writep = buf->data;
    buf->endp = buf->data + 2048;
  }
  return buf;
}

variable_types: struct GSM0710_Buffer { unsigned char data[2048]; unsigned char *readp; unsigned char *writep; unsigned char *endp; int flag_found; unsigned long received_count; unsigned long dropped_count; } *


decompiled_code:
// attributes: thunk
void gsm0710_buffer_destroy(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func2(void *ptr)
{
free(ptr);
}

original_code:
void gsm0710_buffer_destroy(GSM0710_Buffer *buf) {
  free(buf);
}

canonical_original_code:
void gsm0710_buffer_destroy(struct GSM0710_Buffer *buf) {
  free(buf);
}

user_defined_types: struct GSM0710_Buffer { unsigned char data[2048]; unsigned char *readp; unsigned char *writep; unsigned char *endp; int flag_found; unsigned long received_count; unsigned long dropped_count; }


decompiled_code:
__int64 __fastcall gsm0710_buffer_write(void *dest, char *a2, int a3)
{
unsigned __int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rbx
void *v7; // rdi
int v8; // er12
__int64 v9; // rdx
char *v10; // rsi
size_t v11; // rdx
char *v12; // r12
__int64 result; // rax
__int64 v14; // r12

v4 = *((_QWORD *)dest + 256);
v5 = *((_QWORD *)dest + 258);
v6 = a3;
v7 = (void *)*((_QWORD *)dest + 257);
v8 = v5 - (_DWORD)v7;
v9 = v4 - (_QWORD)v7 + 2048;
if ( (unsigned __int64)v7 < v4 )
v9 = v4 - (_QWORD)v7;
if ( v6 > v9 )
LODWORD(v6) = v9;
if ( v8 < (int)v6 )
{
memcpy(v7, a2, v8);
v10 = &a2[v8];
v11 = (int)v6 - v8;
v12 = (char *)dest + v11;
memcpy(dest, v10, v11);
*((_QWORD *)dest + 257) = v12;
return (unsigned int)v6;
}
memcpy(v7, a2, (int)v6);
v14 = *((_QWORD *)dest + 257) + (int)v6;
*((_QWORD *)dest + 257) = v14;
if ( v14 != *((_QWORD *)dest + 258) )
return (unsigned int)v6;
result = (unsigned int)v6;
*((_QWORD *)dest + 257) = dest;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *dest, char *a2, int a3)
{
unsigned __int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rbx
void *v7; // rdi
int v8; // er12
__int64 v9; // rdx
char *v10; // rsi
size_t v11; // rdx
char *v12; // r12
__int64 result; // rax
__int64 v14; // r12

v4 = *((_QWORD *)dest + 256);
v5 = *((_QWORD *)dest + 258);
v6 = a3;
v7 = (void *)*((_QWORD *)dest + 257);
v8 = v5 - (_DWORD)v7;
v9 = v4 - (_QWORD)v7 + 2048;
if ( (unsigned __int64)v7 < v4 )
v9 = v4 - (_QWORD)v7;
if ( v6 > v9 )
LODWORD(v6) = v9;
if ( v8 < (int)v6 )
{
memcpy(v7, a2, v8);
v10 = &a2[v8];
v11 = (int)v6 - v8;
v12 = (char *)dest + v11;
memcpy(dest, v10, v11);
*((_QWORD *)dest + 257) = v12;
return (unsigned int)v6;
}
memcpy(v7, a2, (int)v6);
v14 = *((_QWORD *)dest + 257) + (int)v6;
*((_QWORD *)dest + 257) = v14;
if ( v14 != *((_QWORD *)dest + 258) )
return (unsigned int)v6;
result = (unsigned int)v6;
*((_QWORD *)dest + 257) = dest;
return result;
}

original_code:
int gsm0710_buffer_write(GSM0710_Buffer *buf, const char *input, int count) {
  int c=buf->endp - buf->writep;
  count = ((count < ((buf->readp > buf->writep) ? (buf->readp - buf->writep) : (2048 - (buf->writep-buf->readp)))) ? count :((buf->readp > buf->writep) ? (buf->readp - buf->writep) : (2048 - (buf->writep-buf->readp))));
  if (count > c) {
    memcpy(buf->writep, input, c);
    memcpy(buf->data, input+c, count-c);
    buf->writep = buf->data + (count-c);
  } else {
    memcpy(buf->writep, input, count);
    buf->writep += count;
    if (buf->writep == buf->endp)
      buf->writep = buf->data;
  }
  return count;
}

canonical_original_code:
int gsm0710_buffer_write(struct GSM0710_Buffer *buf, char *input, int count) {
  int c = buf->endp - buf->writep;
  count = ((count < ((buf->readp > buf->writep) ? (buf->readp - buf->writep) : (2048 - (buf->writep-buf->readp)))) ? count :((buf->readp > buf->writep) ? (buf->readp - buf->writep) : (2048 - (buf->writep-buf->readp))));
  if (count > c) {
    memcpy(buf->writep, input, c);
    memcpy(buf->data, input+c, count-c);
    buf->writep = buf->data + (count-c);
  } else {
    memcpy(buf->writep, input, count);
    buf->writep += count;
    if (buf->writep == buf->endp)
      buf->writep = buf->data;
  }
  return count;
}

variable_types:
input
char *

variable_types: c int


decompiled_code:
void __fastcall destroy_frame(void *ptr)
{
if ( *((int *)ptr + 1) > 0 )
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
if ( *((int *)ptr + 1) > 0 )
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void destroy_frame(GSM0710_Frame *frame) {
  if (frame->data_length > 0)
    free(frame->data);
  free(frame);
}

canonical_original_code:
void destroy_frame(struct GSM0710_Frame *frame) {
  if (frame->data_length > 0)
    free(frame->data);
  free(frame);
}

variable_types: struct GSM0710_Frame { unsigned char channel; unsigned char control; int data_length; unsigned char *data; } *


DeleteArgument

repo: yabuki/xfireworks

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

result = (unsigned int)*a1;
*a1 = result - 1;
if ( (int)result - 1 > a3 )
result = (unsigned __int64)memmove(
(void *)(a2 + 8LL * a3),
(const void *)(a2 + 8LL * a3 + 8),
8LL * (unsigned int)(result - a3 - 2) + 8);
return result;
}

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

result = (unsigned int)*a1;
*a1 = result - 1;
if ( (int)result - 1 > a3 )
result = (unsigned __int64)memmove(
(void *)(a2 + 8LL * a3),
(const void *)(a2 + 8LL * a3 + 8),
8LL * (unsigned int)(result - a3 - 2) + 8);
return result;
}

original_code:
static void DeleteArgument(int * argc, char ** argv, int i)
{
  (*argc)--;
  for (; i < (*argc); i++)
    argv[i] = argv[i + 1];
}

canonical_original_code:
static void DeleteArgument(int *argc, char **argv, int i)
{
  (*argc)--;
  for (; i < (*argc); i++)
    argv[i] = argv[i + 1];
}

variable_types:
argc
int *

variable_types:
argv
char **


CheckArguments

decompiled_code:
__int64 __fastcall CheckArguments(int *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
unsigned int v5; // er13

if ( *a1 <= 1 )
return 0LL;
v4 = 1LL;
v5 = 0;
do
{
while ( (unsigned int)StringCmp(a3, *(_QWORD *)(a2 + 8 * v4)) )
{
if ( *a1 <= (int)++v4 )
return v5;
}
v5 = 1;
DeleteArgument(a1, a2, v4++);
}
while ( *a1 > (int)v4 );
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
unsigned int v5; // er13

if ( *a1 <= 1 )
return 0LL;
v4 = 1LL;
v5 = 0;
do
{
while ( (unsigned int)StringCmp(a3, *(_QWORD *)(a2 + 8 * v4)) )
{
if ( *a1 <= (int)++v4 )
return v5;
}
v5 = 1;
func0(a1, a2, v4++);
}
while ( *a1 > (int)v4 );
return v5;
}

original_code:
static int CheckArguments(int * argc, char ** argv, char * s)
{
  int i, r = 0;
  for (i = 1; i < *argc; i++) {
    if (!StringCmp(s, argv[i])) {
      DeleteArgument(argc, argv, i);
      r = 1;
    }
  }
  return (r);
}

canonical_original_code:
static int CheckArguments(int *argc, char **argv, char *s)
{
  int i; int r = 0;
  for (i = 1; i < *argc; i++) {
    if (!StringCmp(s, argv[i])) {
      DeleteArgument(argc, argv, i);
      r = 1;
    }
  }
  return (r);
}

variable_types:
s
char *

variable_types: i int

variable_types: r int


GetStringFromArguments

decompiled_code:
__int64 __fastcall GetStringFromArguments(int *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
__int64 v5; // r14
int v6; // edx

if ( *a1 <= 1 )
return 0LL;
v4 = 1LL;
v5 = 0LL;
do
{
if ( !(unsigned int)StringCmp(a3, *(_QWORD *)(a2 + 8 * v4)) )
{
v6 = *a1 - 1;
if ( v6 != (_DWORD)v4 )
{
DeleteArgument(a1, a2, v4);
v5 = *(_QWORD *)(a2 + 8 * v4);
v6 = v4;
}
DeleteArgument(a1, a2, v6);
}
++v4;
}
while ( *a1 > (int)v4 );
return v5;
}

original_code:
static char * GetStringFromArguments(int * argc, char ** argv, char * s)
{
  int i;
  char * p = (char *)((void *)0);
  for (i = 1; i < *argc; i++) {
    if (!StringCmp(s, argv[i])) {
      if (i == *argc - 1) {
        DeleteArgument(argc, argv, i);
      } else {
        DeleteArgument(argc, argv, i);
        p = argv[i];
        DeleteArgument(argc, argv, i);
      }
    }
  }
  return (p);
}

canonical_original_code:
static char *GetStringFromArguments(int *argc, char **argv, char *s)
{
  int i;
  char *p = (char *)((void *)0);
  for (i = 1; i < *argc; i++) {
    if (!StringCmp(s, argv[i])) {
      if (i == *argc - 1) {
        DeleteArgument(argc, argv, i);
      } else {
        DeleteArgument(argc, argv, i);
        p = argv[i];
        DeleteArgument(argc, argv, i);
      }
    }
  }
  return (p);
}

variable_types:
p
char *