decompiled_code:
char __fastcall us_osc_msg_bundle_print(__int64 a1, __int64 a2)
{
char result; // al
__int64 i; // rbx

result = a2 != 0 && a1 != 0;
if ( result )
{
result = (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_bundle_t: timetag: 0x%08lx%08lx\n",
*(unsigned int *)(a1 + 32),
*(unsigned int *)(a1 + 36));
for ( i = *(_QWORD *)(a1 + 40); i; i = *(_QWORD *)(i + 72) )
{
if ( !result )
break;
result = (*(__int64 (__fastcall **)(__int64, __int64))(i + 16))(i, a2);
}
}
return result;
}

canonical_decompiled_code:
char __fastcall func0(__int64 a1, __int64 a2)
{
char result; // al
__int64 i; // rbx

result = a2 != 0 && a1 != 0;
if ( result )
{
result = (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_bundle_t: timetag: 0x%08lx%08lx\n",
*(unsigned int *)(a1 + 32),
*(unsigned int *)(a1 + 36));
for ( i = *(_QWORD *)(a1 + 40); i; i = *(_QWORD *)(i + 72) )
{
if ( !result )
break;
result = (*(__int64 (__fastcall **)(__int64, __int64))(i + 16))(i, a2);
}
}
return result;
}

original_code:
_Bool us_osc_msg_bundle_print( const us_osc_msg_bundle_t *self, us_print_t *printer )
{
    _Bool r = 0;
    if ( self && printer )
    {
        us_osc_msg_t *cur = 0;
        r = 1;
        r &= printer->printf( printer, "msg_bundle_t:  timetag: 0x%08lx%08lx\n", self->m_timetag_high, self->m_timetag_low );
        cur = self->m_first_msg;
        while ( cur && r )
        {
            r &= cur->print( cur, printer );
            cur = cur->m_next;
        }
    }
    return r;
}

canonical_original_code:
_Bool us_osc_msg_bundle_print(struct us_osc_msg_bundle_s *self, struct us_print_s *printer)
{
    _Bool r = 0;
    if ( self && printer )
    {
        struct us_osc_msg_s *cur = 0;
        r = 1;
        r &= printer->printf( printer, "msg_bundle_t:  timetag: 0x%08lx%08lx\n", self->m_timetag_high, self->m_timetag_low );
        cur = self->m_first_msg;
        while ( cur && r )
        {
            r &= cur->print( cur, printer );
            cur = cur->m_next;
        }
    }
    return r;
}

variable_types: struct us_osc_msg_bundle_s { void (*destroy)(struct us_osc_msg_bundle_s *self); struct us_osc_msg_s { void (*destroy)(struct us_osc_msg_s *self); struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } *(*append)(struct us_osc_msg_s *self, struct us_osc_msg_element_s *element); _Bool (*print)(struct us_osc_msg_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_s *self, struct us_buffer_s *buf, int *length); struct us_allocator_s *m_allocator; char *m_address; unsigned int m_address_code; struct us_osc_msg_element_s *m_first_element; struct us_osc_msg_element_s *m_last_element; struct us_osc_msg_s *m_next; } *(*append)(struct us_osc_msg_bundle_s *self, struct us_osc_msg_s *msg); _Bool (*print)(struct us_osc_msg_bundle_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_bundle_s *self, struct us_buffer_s *buf, int *length); unsigned int m_timetag_high; unsigned int m_timetag_low; struct us_osc_msg_s *m_first_msg; struct us_osc_msg_s *m_last_msg; } *

variable_types:
printer
struct us_print_s *

user_defined_types: struct us_osc_msg_bundle_s { void (*destroy)(struct us_osc_msg_bundle_s *self); struct us_osc_msg_s *(*append)(struct us_osc_msg_bundle_s *self, struct us_osc_msg_s *msg); _Bool (*print)(struct us_osc_msg_bundle_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_bundle_s *self, struct us_buffer_s *buf, int *length); unsigned int m_timetag_high; unsigned int m_timetag_low; struct us_osc_msg_s *m_first_msg; struct us_osc_msg_s *m_last_msg; }

user_defined_types: struct us_osc_msg_s { void (*destroy)(struct us_osc_msg_s *self); struct us_osc_msg_element_s *(*append)(struct us_osc_msg_s *self, struct us_osc_msg_element_s *element); _Bool (*print)(struct us_osc_msg_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_s *self, struct us_buffer_s *buf, int *length); struct us_allocator_s *m_allocator; char *m_address; unsigned int m_address_code; struct us_osc_msg_element_s *m_first_element; struct us_osc_msg_element_s *m_last_element; struct us_osc_msg_s *m_next; }

user_defined_types: struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; }


repo: jdkoftinoff/microsupport

decompiled_code:
char __fastcall us_osc_msg_print(__int64 a1, __int64 a2)
{
char result; // al
__int64 i; // rbx

result = a2 != 0 && a1 != 0;
if ( result )
{
result = (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_t: address: '%s'\n",
*(const char **)(a1 + 40));
for ( i = *(_QWORD *)(a1 + 56); i; i = *(_QWORD *)(i + 24) )
{
if ( !result )
break;
result = (*(__int64 (__fastcall **)(__int64, __int64))(i + 8))(i, a2);
}
}
return result;
}

canonical_decompiled_code:
char __fastcall func1(__int64 a1, __int64 a2)
{
char result; // al
__int64 i; // rbx

result = a2 != 0 && a1 != 0;
if ( result )
{
result = (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_t: address: '%s'\n",
*(const char **)(a1 + 40));
for ( i = *(_QWORD *)(a1 + 56); i; i = *(_QWORD *)(i + 24) )
{
if ( !result )
break;
result = (*(__int64 (__fastcall **)(__int64, __int64))(i + 8))(i, a2);
}
}
return result;
}

original_code:
_Bool us_osc_msg_print( const us_osc_msg_t *self, us_print_t *printer )
{
    _Bool r = 0;
    if ( self && printer )
    {
        us_osc_msg_element_t *cur = 0;
        r = 1;
        r &= printer->printf( printer, "msg_t: address: '%s'\n", self->m_address );
        cur = self->m_first_element;
        while ( cur && r )
        {
            r &= cur->print( cur, printer );
            cur = cur->m_next;
        }
    }
    return r;
}

canonical_original_code:
_Bool us_osc_msg_print(struct us_osc_msg_s *self, struct us_print_s *printer)
{
    _Bool r = 0;
    if ( self && printer )
    {
        struct us_osc_msg_element_s *cur = 0;
        r = 1;
        r &= printer->printf( printer, "msg_t: address: '%s'\n", self->m_address );
        cur = self->m_first_element;
        while ( cur && r )
        {
            r &= cur->print( cur, printer );
            cur = cur->m_next;
        }
    }
    return r;
}

variable_types: struct us_osc_msg_s { void (*destroy)(struct us_osc_msg_s *self); struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } *(*append)(struct us_osc_msg_s *self, struct us_osc_msg_element_s *element); _Bool (*print)(struct us_osc_msg_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_s *self, struct us_buffer_s *buf, int *length); struct us_allocator_s *m_allocator; char *m_address; unsigned int m_address_code; struct us_osc_msg_element_s *m_first_element; struct us_osc_msg_element_s *m_last_element; struct us_osc_msg_s *m_next; } *


decompiled_code:
__int64 __fastcall us_osc_msg_element_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"UNKNOWN TYPE: '%c'\n",
(unsigned int)*(char *)(a1 + 32));
}

original_code:
_Bool us_osc_msg_element_print( const us_osc_msg_element_t *self, us_print_t *printer )
{
    return printer->printf( printer, "UNKNOWN TYPE: '%c'\n", self->m_code );
}

canonical_original_code:
_Bool us_osc_msg_element_print(struct us_osc_msg_element_s *self, struct us_print_s *printer)
{
    return printer->printf( printer, "UNKNOWN TYPE: '%c'\n", self->m_code );
}

variable_types: struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } *


decompiled_code:
__int64 __fastcall us_osc_msg_element_a_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t: 0x%08lx%08lx\n",
(unsigned int)*(char *)(a1 + 32),
*(unsigned int *)(a1 + 40),
*(unsigned int *)(a1 + 44));
}

original_code:
_Bool us_osc_msg_element_a_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_a_t *self = (us_osc_msg_element_a_t *)self_;
    return printer->printf(
        printer, "msg_element_%c_t: 0x%08lx%08lx\n", self->m_base.m_code, self->m_time_high, self->m_time_low );
}

canonical_original_code:
_Bool us_osc_msg_element_a_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_a_s *self = (us_osc_msg_element_a_t *)self_;
    return printer->printf(
        printer, "msg_element_%c_t: 0x%08lx%08lx\n", self->m_base.m_code, self->m_time_high, self->m_time_low );
}

variable_types: struct us_osc_msg_element_a_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; unsigned int m_time_high; unsigned int m_time_low; } *

user_defined_types: struct us_osc_msg_element_a_s { struct us_osc_msg_element_s m_base; unsigned int m_time_high; unsigned int m_time_low; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_B_print(__int64 a1, __int64 a2)
{
int v3; // ebx
int v4; // ebx

v3 = (*(__int64 (__fastcall **)(__int64, const char *))(a2 + 8))(a2, "msg_element_B_t: ");
v4 = (*(__int64 (__fastcall **)(_QWORD, __int64))(*(_QWORD *)(a1 + 40) + 16LL))(*(_QWORD *)(a1 + 40), a2) & v3;
return v4 & (*(unsigned int (__fastcall **)(__int64, const char *))(a2 + 8))(a2, "\n");
}

original_code:
_Bool us_osc_msg_element_B_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    _Bool r = 1;
    us_osc_msg_element_B_t *self = (us_osc_msg_element_B_t *)self_;
    r &= printer->printf( printer, "msg_element_B_t: " );
    r &= self->m_bundle->print( self->m_bundle, printer );
    r &= printer->printf( printer, "\n" );
    return r;
}

canonical_original_code:
_Bool us_osc_msg_element_B_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    _Bool r = 1;
    struct us_osc_msg_element_B_s *self = (us_osc_msg_element_B_t *)self_;
    r &= printer->printf( printer, "msg_element_B_t: " );
    r &= self->m_bundle->print( self->m_bundle, printer );
    r &= printer->printf( printer, "\n" );
    return r;
}

variable_types: struct us_osc_msg_element_B_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; struct us_osc_msg_bundle_s { void (*destroy)(struct us_osc_msg_bundle_s *self); struct us_osc_msg_s { void (*destroy)(struct us_osc_msg_s *self); struct us_osc_msg_element_s *(*append)(struct us_osc_msg_s *self, struct us_osc_msg_element_s *element); _Bool (*print)(struct us_osc_msg_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_s *self, struct us_buffer_s *buf, int *length); struct us_allocator_s *m_allocator; char *m_address; unsigned int m_address_code; struct us_osc_msg_element_s *m_first_element; struct us_osc_msg_element_s *m_last_element; struct us_osc_msg_s *m_next; } *(*append)(struct us_osc_msg_bundle_s *self, struct us_osc_msg_s *msg); _Bool (*print)(struct us_osc_msg_bundle_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_bundle_s *self, struct us_buffer_s *buf, int *length); unsigned int m_timetag_high; unsigned int m_timetag_low; struct us_osc_msg_s *m_first_msg; struct us_osc_msg_s *m_last_msg; } *m_bundle; } *

user_defined_types: struct us_osc_msg_element_B_s { struct us_osc_msg_element_s m_base; struct us_osc_msg_bundle_s *m_bundle; }


original_code:
_Bool us_osc_msg_element_b_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    _Bool r = 1;
    int i;
    us_osc_msg_element_b_t *self = (us_osc_msg_element_b_t *)self_;
    r &= printer->printf( printer, "msg_element_%c_t: data length: %d, data: ", self->m_base.m_code, self->m_length );
    for ( i = 0; i < self->m_length; ++i )
    {
        r &= printer->printf( printer, "%02x", self->m_data[i] );
    }
    r &= printer->printf( printer, "\n" );
    return r;
}

canonical_original_code:
_Bool us_osc_msg_element_b_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    _Bool r = 1;
    int i;
    struct us_osc_msg_element_b_s *self = (us_osc_msg_element_b_t *)self_;
    r &= printer->printf( printer, "msg_element_%c_t: data length: %d, data: ", self->m_base.m_code, self->m_length );
    for ( i = 0; i < self->m_length; ++i )
    {
        r &= printer->printf( printer, "%02x", self->m_data[i] );
    }
    r &= printer->printf( printer, "\n" );
    return r;
}

variable_types: i int

variable_types: struct us_osc_msg_element_b_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; unsigned char *m_data; int m_length; } *

user_defined_types: struct us_osc_msg_element_b_s { struct us_osc_msg_element_s m_base; unsigned char *m_data; int m_length; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_d_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t: %g\n",
(unsigned int)*(char *)(a1 + 32),
*(double *)(a1 + 40));
}

original_code:
_Bool us_osc_msg_element_d_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_d_t *self = (us_osc_msg_element_d_t *)self_;
    return printer->printf( printer, "msg_element_%c_t: %g\n", self->m_base.m_code, self->m_value );
}

canonical_original_code:
_Bool us_osc_msg_element_d_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_d_s *self = (us_osc_msg_element_d_t *)self_;
    return printer->printf( printer, "msg_element_%c_t: %g\n", self->m_base.m_code, self->m_value );
}

variable_types: struct us_osc_msg_element_d_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; double m_value; } *

user_defined_types: struct us_osc_msg_element_d_s { struct us_osc_msg_element_s m_base; double m_value; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_f_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t: %f\n",
(unsigned int)*(char *)(a1 + 32),
*(float *)(a1 + 40));
}

original_code:
_Bool us_osc_msg_element_f_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_f_t *self = (us_osc_msg_element_f_t *)self_;
    return printer->printf( printer, "msg_element_%c_t: %f\n", self->m_base.m_code, self->m_value );
}

canonical_original_code:
_Bool us_osc_msg_element_f_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_f_s *self = (us_osc_msg_element_f_t *)self_;
    return printer->printf( printer, "msg_element_%c_t: %f\n", self->m_base.m_code, self->m_value );
}

variable_types: struct us_osc_msg_element_f_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; float m_value; } *

user_defined_types: struct us_osc_msg_element_f_s { struct us_osc_msg_element_s m_base; float m_value; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_h_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t: 0x%08lx%08lx\n",
(unsigned int)*(char *)(a1 + 32),
*(unsigned int *)(a1 + 40),
*(unsigned int *)(a1 + 44));
}

original_code:
_Bool us_osc_msg_element_h_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_h_t *self = (us_osc_msg_element_h_t *)self_;
    return printer->printf(
        printer, "msg_element_%c_t: 0x%08lx%08lx\n", self->m_base.m_code, self->m_value_high, self->m_value_low );
}

canonical_original_code:
_Bool us_osc_msg_element_h_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_h_s *self = (us_osc_msg_element_h_t *)self_;
    return printer->printf(
        printer, "msg_element_%c_t: 0x%08lx%08lx\n", self->m_base.m_code, self->m_value_high, self->m_value_low );
}

variable_types: struct us_osc_msg_element_h_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; unsigned int m_value_high; unsigned int m_value_low; } *

user_defined_types: struct us_osc_msg_element_h_s { struct us_osc_msg_element_s m_base; unsigned int m_value_high; unsigned int m_value_low; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_i_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t: %d\n",
(unsigned int)*(char *)(a1 + 32),
*(unsigned int *)(a1 + 40));
}

original_code:
_Bool us_osc_msg_element_i_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_i_t *self = (us_osc_msg_element_i_t *)self_;
    return printer->printf( printer, "msg_element_%c_t: %d\n", self->m_base.m_code, self->m_value );
}

canonical_original_code:
_Bool us_osc_msg_element_i_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_i_s *self = (us_osc_msg_element_i_t *)self_;
    return printer->printf( printer, "msg_element_%c_t: %d\n", self->m_base.m_code, self->m_value );
}

variable_types: struct us_osc_msg_element_i_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; int m_value; } *

user_defined_types: struct us_osc_msg_element_i_s { struct us_osc_msg_element_s m_base; int m_value; }


original_code:
_Bool us_osc_msg_element_s_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    _Bool r = 1;
    int i;
    us_osc_msg_element_s_t *self = (us_osc_msg_element_s_t *)self_;
    r &= printer->printf( printer, "msg_element_%c_t: string length: %d, value: '", self->m_base.m_code, self->m_length );
    for ( i = 0; i < self->m_length; ++i )
    {
        r &= printer->printf( printer, "%c", self->m_value[i] );
    }
    r &= printer->printf( printer, "'\n" );
    return r;
}

canonical_original_code:
_Bool us_osc_msg_element_s_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    _Bool r = 1;
    int i;
    struct us_osc_msg_element_s_s *self = (us_osc_msg_element_s_t *)self_;
    r &= printer->printf( printer, "msg_element_%c_t: string length: %d, value: '", self->m_base.m_code, self->m_length );
    for ( i = 0; i < self->m_length; ++i )
    {
        r &= printer->printf( printer, "%c", self->m_value[i] );
    }
    r &= printer->printf( printer, "'\n" );
    return r;
}

variable_types: struct us_osc_msg_element_s_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; char *m_value; int m_length; } *

user_defined_types: struct us_osc_msg_element_s_s { struct us_osc_msg_element_s m_base; char *m_value; int m_length; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_t_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t: 0x%08lx%08lx\n",
(unsigned int)*(char *)(a1 + 32),
*(unsigned int *)(a1 + 40),
*(unsigned int *)(a1 + 44));
}

original_code:
_Bool us_osc_msg_element_t_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_t_t *self = (us_osc_msg_element_t_t *)self_;
    return printer->printf(
        printer, "msg_element_%c_t: 0x%08lx%08lx\n", self->m_base.m_code, self->m_time_high, self->m_time_low );
}

canonical_original_code:
_Bool us_osc_msg_element_t_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_t_s *self = (us_osc_msg_element_t_t *)self_;
    return printer->printf(
        printer, "msg_element_%c_t: 0x%08lx%08lx\n", self->m_base.m_code, self->m_time_high, self->m_time_low );
}

variable_types: struct us_osc_msg_element_t_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; unsigned int m_time_high; unsigned int m_time_low; } *

user_defined_types: struct us_osc_msg_element_t_s { struct us_osc_msg_element_s m_base; unsigned int m_time_high; unsigned int m_time_low; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_T_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t:\n",
(unsigned int)*(char *)(a1 + 32));
}

original_code:
_Bool us_osc_msg_element_T_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_T_t *self = (us_osc_msg_element_T_t *)self_;
    return printer->printf( printer, "msg_element_%c_t:\n", self->m_base.m_code );
}

canonical_original_code:
_Bool us_osc_msg_element_T_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_T_s *self = (us_osc_msg_element_T_t *)self_;
    return printer->printf( printer, "msg_element_%c_t:\n", self->m_base.m_code );
}

variable_types: struct us_osc_msg_element_T_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; } *

user_defined_types: struct us_osc_msg_element_T_s { struct us_osc_msg_element_s m_base; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_F_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t:\n",
(unsigned int)*(char *)(a1 + 32));
}

original_code:
_Bool us_osc_msg_element_F_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_F_t *self = (us_osc_msg_element_F_t *)self_;
    return printer->printf( printer, "msg_element_%c_t:\n", self->m_base.m_code );
}

canonical_original_code:
_Bool us_osc_msg_element_F_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_F_s *self = (us_osc_msg_element_F_t *)self_;
    return printer->printf( printer, "msg_element_%c_t:\n", self->m_base.m_code );
}

variable_types: struct us_osc_msg_element_F_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; } *

user_defined_types: struct us_osc_msg_element_F_s { struct us_osc_msg_element_s m_base; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_M_print(__int64 a1, __int64 a2)
{
int v3; // ebx
int v4; // ebx

v3 = (*(__int64 (__fastcall **)(__int64, const char *))(a2 + 8))(a2, "msg_element_M_t: ");
v4 = (*(__int64 (__fastcall **)(_QWORD, __int64))(*(_QWORD *)(a1 + 40) + 16LL))(*(_QWORD *)(a1 + 40), a2) & v3;
return v4 & (*(unsigned int (__fastcall **)(__int64, const char *))(a2 + 8))(a2, "\n");
}

original_code:
_Bool us_osc_msg_element_M_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    _Bool r = 1;
    us_osc_msg_element_M_t *self = (us_osc_msg_element_M_t *)self_;
    r &= printer->printf( printer, "msg_element_M_t: " );
    r &= self->m_msg->print( self->m_msg, printer );
    r &= printer->printf( printer, "\n" );
    return r;
}

canonical_original_code:
_Bool us_osc_msg_element_M_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    _Bool r = 1;
    struct us_osc_msg_element_M_s *self = (us_osc_msg_element_M_t *)self_;
    r &= printer->printf( printer, "msg_element_M_t: " );
    r &= self->m_msg->print( self->m_msg, printer );
    r &= printer->printf( printer, "\n" );
    return r;
}

variable_types: struct us_osc_msg_element_M_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; struct us_osc_msg_s { void (*destroy)(struct us_osc_msg_s *self); struct us_osc_msg_element_s *(*append)(struct us_osc_msg_s *self, struct us_osc_msg_element_s *element); _Bool (*print)(struct us_osc_msg_s *self, struct us_print_s *printer); _Bool (*flatten)(struct us_osc_msg_s *self, struct us_buffer_s *buf, int *length); struct us_allocator_s *m_allocator; char *m_address; unsigned int m_address_code; struct us_osc_msg_element_s *m_first_element; struct us_osc_msg_element_s *m_last_element; struct us_osc_msg_s *m_next; } *m_msg; } *

user_defined_types: struct us_osc_msg_element_M_s { struct us_osc_msg_element_s m_base; struct us_osc_msg_s *m_msg; }


decompiled_code:
__int64 __fastcall us_osc_msg_element_N_print(__int64 a1, __int64 a2)
{
return (*(__int64 (**)(__int64, const char *, ...))(a2 + 8))(
a2,
"msg_element_%c_t:\n",
(unsigned int)*(char *)(a1 + 32));
}

original_code:
_Bool us_osc_msg_element_N_print( const us_osc_msg_element_t *self_, us_print_t *printer )
{
    us_osc_msg_element_N_t *self = (us_osc_msg_element_N_t *)self_;
    return printer->printf( printer, "msg_element_%c_t:\n", self->m_base.m_code );
}

canonical_original_code:
_Bool us_osc_msg_element_N_print(struct us_osc_msg_element_s *self_, struct us_print_s *printer)
{
    struct us_osc_msg_element_N_s *self = (us_osc_msg_element_N_t *)self_;
    return printer->printf( printer, "msg_element_%c_t:\n", self->m_base.m_code );
}

variable_types: struct us_osc_msg_element_N_s { struct us_osc_msg_element_s { void (*destroy)(struct us_osc_msg_element_s *self, struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *allocator); _Bool (*print)(struct us_osc_msg_element_s *self, struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *printer); _Bool (*flatten)(struct us_osc_msg_element_s *self, struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *buf, int *length); struct us_osc_msg_element_s *m_next; char m_code; } m_base; } *

user_defined_types: struct us_osc_msg_element_N_s { struct us_osc_msg_element_s m_base; }


decompiled_code:
void us_logger_printer_finish()
{
us_log_error_proc = &us_log_null;
us_log_warn_proc = &us_log_null;
us_log_info_proc = &us_log_null;
us_log_debug_proc = &us_log_null;
us_logger_finish = &us_logger_null_finish;
}

canonical_decompiled_code:
void func0()
{
us_log_error_proc = &us_log_null;
us_log_warn_proc = &us_log_null;
us_log_info_proc = &us_log_null;
us_log_debug_proc = &us_log_null;
us_logger_finish = &us_logger_null_finish;
}

original_code:
void us_logger_printer_finish( void )
{
    us_log_error_proc = us_log_null;
    us_log_warn_proc = us_log_null;
    us_log_info_proc = us_log_null;
    us_log_debug_proc = us_log_null;
    us_logger_finish = us_logger_null_finish;
}

canonical_original_code:
void us_logger_printer_finish()
{
    us_log_error_proc = us_log_null;
    us_log_warn_proc = us_log_null;
    us_log_info_proc = us_log_null;
    us_log_debug_proc = us_log_null;
    us_logger_finish = us_logger_null_finish;
}

return_type: void


decompiled_code:
void *us_log_error_printer(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_err )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_err + 8))(us_logger_printer_err, "ERROR:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_err + 16))(
us_logger_printer_err,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_err + 8))(
us_logger_printer_err,
"\n");
}
return result;
}

canonical_decompiled_code:
void *func1(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_err )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_err + 8))(us_logger_printer_err, "ERROR:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_err + 16))(
us_logger_printer_err,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_err + 8))(
us_logger_printer_err,
"\n");
}
return result;
}

original_code:
void us_log_error_printer( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_err )
    {
        us_logger_printer_err->printf( us_logger_printer_err, "ERROR:\t" );
        us_logger_printer_err->vprintf( us_logger_printer_err, fmt, ap );
        us_logger_printer_err->printf( us_logger_printer_err, "\n" );
    }
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_error_printer(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_err )
    {
        us_logger_printer_err->printf( us_logger_printer_err, "ERROR:\t" );
        us_logger_printer_err->vprintf( us_logger_printer_err, fmt, ap );
        us_logger_printer_err->printf( us_logger_printer_err, "\n" );
    }
    __builtin_va_end(ap);
}

variable_types:
fmt
char *


decompiled_code:
void *us_log_warn_printer(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_err )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_err + 8))(us_logger_printer_err, "WARNING:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_err + 16))(
us_logger_printer_err,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_err + 8))(
us_logger_printer_err,
"\n");
}
return result;
}

canonical_decompiled_code:
void *func2(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_err )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_err + 8))(us_logger_printer_err, "WARNING:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_err + 16))(
us_logger_printer_err,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_err + 8))(
us_logger_printer_err,
"\n");
}
return result;
}

original_code:
void us_log_warn_printer( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_err )
    {
        us_logger_printer_err->printf( us_logger_printer_err, "WARNING:\t" );
        us_logger_printer_err->vprintf( us_logger_printer_err, fmt, ap );
        us_logger_printer_err->printf( us_logger_printer_err, "\n" );
    }
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_warn_printer(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_err )
    {
        us_logger_printer_err->printf( us_logger_printer_err, "WARNING:\t" );
        us_logger_printer_err->vprintf( us_logger_printer_err, fmt, ap );
        us_logger_printer_err->printf( us_logger_printer_err, "\n" );
    }
    __builtin_va_end(ap);
}


decompiled_code:
void *us_log_info_printer(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_out )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(us_logger_printer_out, "INFO:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_out + 16))(
us_logger_printer_out,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(
us_logger_printer_out,
"\n");
}
return result;
}

canonical_decompiled_code:
void *func3(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_out )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(us_logger_printer_out, "INFO:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_out + 16))(
us_logger_printer_out,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(
us_logger_printer_out,
"\n");
}
return result;
}

original_code:
void us_log_info_printer( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_out )
    {
        us_logger_printer_out->printf( us_logger_printer_out, "INFO:\t" );
        us_logger_printer_out->vprintf( us_logger_printer_out, fmt, ap );
        us_logger_printer_out->printf( us_logger_printer_out, "\n" );
    }
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_info_printer(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_out )
    {
        us_logger_printer_out->printf( us_logger_printer_out, "INFO:\t" );
        us_logger_printer_out->vprintf( us_logger_printer_out, fmt, ap );
        us_logger_printer_out->printf( us_logger_printer_out, "\n" );
    }
    __builtin_va_end(ap);
}


decompiled_code:
void *us_log_debug_printer(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_out )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(us_logger_printer_out, "DEBUG:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_out + 16))(
us_logger_printer_out,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(
us_logger_printer_out,
"\n");
}
return result;
}

canonical_decompiled_code:
void *func4(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_out )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(us_logger_printer_out, "DEBUG:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_out + 16))(
us_logger_printer_out,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(
us_logger_printer_out,
"\n");
}
return result;
}

original_code:
void us_log_debug_printer( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_out )
    {
        us_logger_printer_out->printf( us_logger_printer_out, "DEBUG:\t" );
        us_logger_printer_out->vprintf( us_logger_printer_out, fmt, ap );
        us_logger_printer_out->printf( us_logger_printer_out, "\n" );
    }
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_debug_printer(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_out )
    {
        us_logger_printer_out->printf( us_logger_printer_out, "DEBUG:\t" );
        us_logger_printer_out->vprintf( us_logger_printer_out, fmt, ap );
        us_logger_printer_out->printf( us_logger_printer_out, "\n" );
    }
    __builtin_va_end(ap);
}


decompiled_code:
void *us_log_trace_printer(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_out )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(us_logger_printer_out, "TRACE:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_out + 16))(
us_logger_printer_out,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(
us_logger_printer_out,
"\n");
}
return result;
}

canonical_decompiled_code:
void *func5(__int64 a1, ...)
{
void *result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
result = va[0].reg_save_area;
if ( us_logger_printer_out )
{
(*(void (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(us_logger_printer_out, "TRACE:\t");
(*(void (__fastcall **)(__int64, __int64, __va_list_tag *))(us_logger_printer_out + 16))(
us_logger_printer_out,
a1,
va);
result = (void *)(*(__int64 (__fastcall **)(__int64, const char *))(us_logger_printer_out + 8))(
us_logger_printer_out,
"\n");
}
return result;
}

original_code:
void us_log_trace_printer( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_out )
    {
        us_logger_printer_out->printf( us_logger_printer_out, "TRACE:\t" );
        us_logger_printer_out->vprintf( us_logger_printer_out, fmt, ap );
        us_logger_printer_out->printf( us_logger_printer_out, "\n" );
    }
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_trace_printer(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    if ( us_logger_printer_out )
    {
        us_logger_printer_out->printf( us_logger_printer_out, "TRACE:\t" );
        us_logger_printer_out->vprintf( us_logger_printer_out, fmt, ap );
        us_logger_printer_out->printf( us_logger_printer_out, "\n" );
    }
    __builtin_va_end(ap);
}


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

us_logger_printer_out = a1;
result = 1LL;
us_logger_printer_err = a2;
us_log_error_proc = us_log_error_printer;
us_log_warn_proc = us_log_warn_printer;
us_log_info_proc = us_log_info_printer;
us_log_debug_proc = us_log_debug_printer;
us_log_trace_proc = us_log_trace_printer;
us_logger_finish = us_logger_printer_finish;
return result;
}

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

us_logger_printer_out = a1;
result = 1LL;
us_logger_printer_err = a2;
us_log_error_proc = us_log_error_printer;
us_log_warn_proc = us_log_warn_printer;
us_log_info_proc = us_log_info_printer;
us_log_debug_proc = us_log_debug_printer;
us_log_trace_proc = us_log_trace_printer;
us_logger_finish = us_logger_printer_finish;
return result;
}

original_code:
_Bool us_logger_printer_start( us_print_t *out_printer, us_print_t *err_printer )
{
    us_logger_printer_out = out_printer;
    us_logger_printer_err = err_printer;
    us_log_error_proc = us_log_error_printer;
    us_log_warn_proc = us_log_warn_printer;
    us_log_info_proc = us_log_info_printer;
    us_log_debug_proc = us_log_debug_printer;
    us_log_trace_proc = us_log_trace_printer;
    us_logger_finish = us_logger_printer_finish;
    return 1;
}

canonical_original_code:
_Bool us_logger_printer_start(struct us_print_s *out_printer, struct us_print_s *err_printer)
{
    us_logger_printer_out = out_printer;
    us_logger_printer_err = err_printer;
    us_log_error_proc = us_log_error_printer;
    us_log_warn_proc = us_log_warn_printer;
    us_log_info_proc = us_log_info_printer;
    us_log_debug_proc = us_log_debug_printer;
    us_log_trace_proc = us_log_trace_printer;
    us_logger_finish = us_logger_printer_finish;
    return 1;
}

variable_types: struct us_print_s { void (*destroy)(struct us_print_s *self); _Bool (*printf)(struct us_print_s *self, char *fmt, ...); _Bool (*vprintf)(struct us_print_s *self, char *fmt, __builtin_va_list ap); } *


decompiled_code:
__int64 __fastcall us_buffer_readable_count(_QWORD *a1)
{
return (a1[5] + a1[3] - a1[4]) % a1[5];
}

original_code:
static inline size_t us_buffer_readable_count( const us_buffer_t *self )
{
    return ( self->m_next_in - self->m_next_out + self->m_max_length ) % self->m_max_length;
}

canonical_original_code:
static inline unsigned long us_buffer_readable_count(struct us_buffer_s *self)
{
    return ( self->m_next_in - self->m_next_out + self->m_max_length ) % self->m_max_length;
}

variable_types: struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *

return_type: unsigned long

user_defined_types: struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; }


decompiled_code:
__int64 __fastcall us_buffer_read_byte(_QWORD *a1)
{
__int64 v1; // rax
unsigned __int64 v2; // rdx
__int64 result; // rax

v1 = a1[4];
v2 = (unsigned __int64)(v1 + 1) % a1[5];
result = *(unsigned __int8 *)(a1[2] + v1);
a1[4] = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
__int64 v1; // rax
unsigned __int64 v2; // rdx
__int64 result; // rax

v1 = a1[4];
v2 = (unsigned __int64)(v1 + 1) % a1[5];
result = *(unsigned __int8 *)(a1[2] + v1);
a1[4] = v2;
return result;
}

original_code:
static inline uint8_t us_buffer_read_byte( us_buffer_t *self )
{
    uint8_t r = self->m_buffer[self->m_next_out];
    self->m_next_out = ( self->m_next_out + 1 ) % self->m_max_length;
    return r;
}

canonical_original_code:
static inline unsigned char us_buffer_read_byte(struct us_buffer_s *self)
{
    unsigned char r = self->m_buffer[self->m_next_out];
    self->m_next_out = ( self->m_next_out + 1 ) % self->m_max_length;
    return r;
}

variable_types:
r
unsigned char

return_type: unsigned char

user_defined_types: struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); }


decompiled_code:
__int64 __fastcall us_buffer_peek(_QWORD *a1, __int64 a2)
{
return *(unsigned __int8 *)(a1[2] + (unsigned __int64)(a2 + a1[4]) % a1[5]);
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, __int64 a2)
{
return *(unsigned __int8 *)(a1[2] + (unsigned __int64)(a2 + a1[4]) % a1[5]);
}

original_code:
static inline uint8_t us_buffer_peek( const us_buffer_t *self, size_t offset )
{
    return self->m_buffer[( self->m_next_out + offset ) % self->m_max_length];
}

canonical_original_code:
static inline unsigned char us_buffer_peek(struct us_buffer_s *self, unsigned long offset)
{
    return self->m_buffer[( self->m_next_out + offset ) % self->m_max_length];
}

variable_types:
offset
unsigned long


decompiled_code:
bool __fastcall us_buffer_can_write_byte(_QWORD *a1)
{
return (unsigned __int64)(a1[3] + 1LL) % a1[5] != a1[4];
}

canonical_decompiled_code:
bool __fastcall func3(_QWORD *a1)
{
return (unsigned __int64)(a1[3] + 1LL) % a1[5] != a1[4];
}

original_code:
static inline _Bool us_buffer_can_write_byte( const us_buffer_t *self )
{
    return ( ( self->m_next_in + 1 ) % self->m_max_length ) != self->m_next_out;
}

canonical_original_code:
static inline _Bool us_buffer_can_write_byte(struct us_buffer_s *self)
{
    return ( ( self->m_next_in + 1 ) % self->m_max_length ) != self->m_next_out;
}


decompiled_code:
bool __fastcall us_buffer_append_byte(_QWORD *a1, char a2)
{
bool result; // al
bool v3; // [rsp+7h] [rbp-1h]

result = us_buffer_can_write_byte(a1);
if ( result )
{
v3 = result;
us_buffer_write_byte(a1, a2);
result = v3;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func5(_QWORD *a1, char a2)
{
bool result; // al
bool v3; // [rsp+7h] [rbp-1h]

result = func3(a1);
if ( result )
{
v3 = result;
func4(a1, a2);
result = v3;
}
return result;
}

original_code:
static inline _Bool us_buffer_append_byte( us_buffer_t *self, int value )
{
    _Bool r = 0;
    if ( us_buffer_can_write_byte( self ) )
    {
        uint8_t byte_value = (uint8_t)value;
        us_buffer_write_byte( self, byte_value );
        r = 1;
    }
    return r;
}

canonical_original_code:
static inline _Bool us_buffer_append_byte(struct us_buffer_s *self, int value)
{
    _Bool r = 0;
    if ( us_buffer_can_write_byte( self ) )
    {
        unsigned char byte_value = (uint8_t)value;
        us_buffer_write_byte( self, byte_value );
        r = 1;
    }
    return r;
}

variable_types: value int


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

*(_DWORD *)a1 = 0;
result = a1;
*(_QWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 16) = a3;
return result;
}

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

*(_DWORD *)a1 = 0;
result = a1;
*(_QWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 16) = a3;
return result;
}

original_code:
us_slip_decoder_t *
    us_slip_decoder_init( us_slip_decoder_t *self, us_buffer_t *buffer, us_slip_decoder_proc packet_formed_callback )
{
    self->m_state = us_slip_state_before_packet;
    self->m_buffer = buffer;
    self->m_packet_formed_callback = packet_formed_callback;
    return self;
}

canonical_original_code:
struct us_slip_decoder_s *us_slip_decoder_init(struct us_slip_decoder_s *self, struct us_buffer_s *buffer, void (*packet_formed_callback)(struct us_slip_decoder_s *self, struct us_buffer_s *buf))
{
    self->m_state = us_slip_state_before_packet;
    self->m_buffer = buffer;
    self->m_packet_formed_callback = packet_formed_callback;
    return self;
}

variable_types:
self
struct us_slip_decoder_s *

variable_types:
buffer
struct us_buffer_s *

variable_types: void (*)(struct us_slip_decoder_s *self, struct us_buffer_s *buf)

return_type: struct us_slip_decoder_s { enum us_slip_state_enum { us_slip_state_before_packet=0, us_slip_state_in_packet=1, us_slip_state_in_esc=2 } m_state; struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *m_buffer; void (*m_packet_formed_callback)(struct us_slip_decoder_s *self, struct us_buffer_s *buf); } *

user_defined_types: struct us_slip_decoder_s { enum us_slip_state_enum m_state; struct us_buffer_s *m_buffer; void (*m_packet_formed_callback)(struct us_slip_decoder_s *self, struct us_buffer_s *buf); }


decompiled_code:
__int64 __fastcall us_slip_decoder_create(__int64 a1, int a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rsi
__int64 result; // rax

v4 = (*(__int64 (__fastcall **)(__int64, __int64, __int64))(a1 + 8))(a1, 24LL, 1LL);
if ( v4 && (v5 = v4, (v6 = us_buffer_create(a1, a2)) != 0) )
result = us_slip_decoder_init(v5, v6, a3);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rsi
__int64 result; // rax

v4 = (*(__int64 (__fastcall **)(__int64, __int64, __int64))(a1 + 8))(a1, 24LL, 1LL);
if ( v4 && (v5 = v4, (v6 = us_buffer_create(a1, a2)) != 0) )
result = func6(v5, v6, a3);
else
result = 0LL;
return result;
}

original_code:
us_slip_decoder_t *
    us_slip_decoder_create( us_allocator_t *allocator, int32_t max_packet_len, us_slip_decoder_proc packet_formed_callback )
{
    us_slip_decoder_t *self;
    us_buffer_t *buffer;
    self = ( us_slip_decoder_t * )( ( allocator )->alloc( ( allocator ), (int32_t)sizeof( us_slip_decoder_t ), 1 ) );
    if ( self )
    {
        buffer = us_buffer_create( allocator, max_packet_len );
        if ( buffer )
        {
            self = us_slip_decoder_init( self, buffer, packet_formed_callback );
        }
        else
        {
            self = 0;
        }
    }
    return self;
}

canonical_original_code:
struct us_slip_decoder_s *us_slip_decoder_create(struct us_allocator_s *allocator, int max_packet_len, void (*packet_formed_callback)(struct us_slip_decoder_s *self, struct us_buffer_s *buf))
{
    struct us_slip_decoder_s *self;
    struct us_buffer_s *buffer;
    self = ( struct us_slip_decoder_s * )( ( allocator )->alloc( ( allocator ), (int)sizeof( us_slip_decoder_t ), 1 ) );
    if ( self )
    {
        buffer = us_buffer_create( allocator, max_packet_len );
        if ( buffer )
        {
            self = us_slip_decoder_init( self, buffer, packet_formed_callback );
        }
        else
        {
            self = 0;
        }
    }
    return self;
}

variable_types:
allocator
struct us_allocator_s *

variable_types: struct us_slip_decoder_s { enum us_slip_state_enum { us_slip_state_before_packet=0, us_slip_state_in_packet=1, us_slip_state_in_esc=2 } m_state; struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *m_buffer; void (*m_packet_formed_callback)(struct us_slip_decoder_s *self, struct us_buffer_s *buf); } *


decompiled_code:
__int64 __fastcall us_slip_decoder_reset(__int64 a1)
{
*(_DWORD *)a1 = 0;
return us_buffer_reset(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
*(_DWORD *)a1 = 0;
return us_buffer_reset(*(_QWORD *)(a1 + 8));
}

original_code:
void us_slip_decoder_reset( us_slip_decoder_t *self )
{
    self->m_state = us_slip_state_before_packet;
    us_buffer_reset( self->m_buffer );
}

canonical_original_code:
void us_slip_decoder_reset(struct us_slip_decoder_s *self)
{
    self->m_state = us_slip_state_before_packet;
    us_buffer_reset( self->m_buffer );
}

user_defined_types: enum us_slip_state_enum { us_slip_state_before_packet=0, us_slip_state_in_packet=1, us_slip_state_in_esc=2 }


decompiled_code:
__int64 __fastcall us_slip_decoder_parse(__int64 a1, char *a2, int a3)
{
char *v4; // rbx
unsigned int v5; // er12
__int64 v6; // rbp
int v7; // eax
char v8; // si
_QWORD *v10; // rdi

if ( a3 > 0 )
{
v4 = a2;
v5 = 0;
v6 = (__int64)&a2[a3 - 1 + 1];
while ( 1 )
{
while ( 1 )
{
v7 = *(_DWORD *)a1;
v8 = *v4;
if ( *(_DWORD *)a1 != 1 )
break;
if ( v8 == -64 )
{
v10 = *(_QWORD **)(a1 + 8);
if ( !us_buffer_readable_count(v10) )
goto LABEL_20;
++v5;
(*(void (__fastcall **)(__int64, _QWORD *))(a1 + 16))(a1, v10);
us_buffer_reset(*(_QWORD *)(a1 + 8));
}
else
{
if ( v8 != -37 )
{
v10 = *(_QWORD **)(a1 + 8);
LABEL_20:
us_buffer_append_byte(v10, v8);
goto LABEL_5;
}
*(_DWORD *)a1 = 2;
}
LABEL_5:
if ( ++v4 == (char *)v6 )
return v5;
}
if ( v7 != 2 )
break;
if ( v8 == -36 )
{
us_buffer_append_byte(*(_QWORD **)(a1 + 8), 192);
*(_DWORD *)a1 = 1;
goto LABEL_5;
}
if ( v8 != -35 )
goto LABEL_4;
++v4;
us_buffer_append_byte(*(_QWORD **)(a1 + 8), 219);
*(_DWORD *)a1 = 1;
if ( v4 == (char *)v6 )
return v5;
}
if ( !v7 )
{
if ( v8 == -64 )
*(_DWORD *)a1 = 1;
goto LABEL_5;
}
LABEL_4:
us_slip_decoder_reset(a1);
goto LABEL_5;
}
return 0LL;
}

original_code:
int us_slip_decoder_parse( us_slip_decoder_t *self, const uint8_t *data, int data_len )
{
    int packet_count = 0;
    int i;
    for ( i = 0; i < data_len; ++i )
    {
        uint8_t c = data[i];
        switch ( self->m_state )
        {
        case us_slip_state_before_packet:
            if ( c == ( 0300 ) )
            {
                self->m_state = us_slip_state_in_packet;
            }
            break;
        case us_slip_state_in_packet:
            if ( c == ( 0300 ) && us_buffer_readable_count( self->m_buffer ) > 0 )
            {
                self->m_packet_formed_callback( self, self->m_buffer );
                us_buffer_reset( self->m_buffer );
                packet_count++;
            }
            else if ( c == ( 0333 ) )
            {
                self->m_state = us_slip_state_in_esc;
            }
            else
            {
                us_buffer_append_byte( self->m_buffer, c );
            }
            break;
        case us_slip_state_in_esc:
            if ( c == ( 0334 ) )
            {
                us_buffer_append_byte( self->m_buffer, ( 0300 ) );
                self->m_state = us_slip_state_in_packet;
            }
            else if ( c == ( 0335 ) )
            {
                us_buffer_append_byte( self->m_buffer, ( 0333 ) );
                self->m_state = us_slip_state_in_packet;
            }
            else
            {
                us_slip_decoder_reset( self );
            }
            break;
        default:
            us_slip_decoder_reset( self );
            break;
        }
    }
    return packet_count;
}

canonical_original_code:
int us_slip_decoder_parse(struct us_slip_decoder_s *self, unsigned char *data, int data_len)
{
    int packet_count = 0;
    int i;
    for ( i = 0; i < data_len; ++i )
    {
        unsigned char c = data[i];
        switch ( self->m_state )
        {
        case us_slip_state_before_packet:
            if ( c == ( 0300 ) )
            {
                self->m_state = us_slip_state_in_packet;
            }
            break;
        case us_slip_state_in_packet:
            if ( c == ( 0300 ) && us_buffer_readable_count( self->m_buffer ) > 0 )
            {
                self->m_packet_formed_callback( self, self->m_buffer );
                us_buffer_reset( self->m_buffer );
                packet_count++;
            }
            else if ( c == ( 0333 ) )
            {
                self->m_state = us_slip_state_in_esc;
            }
            else
            {
                us_buffer_append_byte( self->m_buffer, c );
            }
            break;
        case us_slip_state_in_esc:
            if ( c == ( 0334 ) )
            {
                us_buffer_append_byte( self->m_buffer, ( 0300 ) );
                self->m_state = us_slip_state_in_packet;
            }
            else if ( c == ( 0335 ) )
            {
                us_buffer_append_byte( self->m_buffer, ( 0333 ) );
                self->m_state = us_slip_state_in_packet;
            }
            else
            {
                us_slip_decoder_reset( self );
            }
            break;
        default:
            us_slip_decoder_reset( self );
            break;
        }
    }
    return packet_count;
}

variable_types:
data
unsigned char *

variable_types: i int

variable_types:
c
unsigned char

return_type: int


decompiled_code:
__int64 __fastcall us_slip_decoder_parse_buffer(__int64 a1, _QWORD *a2)
{
int v3; // eax
int v5; // er13
int v6; // ebx
unsigned int v7; // er14
char v8; // si
int v9; // eax
_QWORD *v11; // rdi

v3 = us_buffer_readable_count(a2);
if ( v3 > 0 )
{
v5 = v3;
v6 = 0;
v7 = 0;
while ( 1 )
{
while ( 1 )
{
v8 = us_buffer_read_byte(a2);
v9 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 != 1 )
break;
if ( v8 == -64 )
{
v11 = *(_QWORD **)(a1 + 8);
if ( !us_buffer_readable_count(v11) )
goto LABEL_20;
++v7;
(*(void (__fastcall **)(__int64, _QWORD *))(a1 + 16))(a1, v11);
us_buffer_reset(*(_QWORD *)(a1 + 8));
}
else
{
if ( v8 != -37 )
{
v11 = *(_QWORD **)(a1 + 8);
LABEL_20:
us_buffer_append_byte(v11, v8);
goto LABEL_5;
}
*(_DWORD *)a1 = 2;
}
LABEL_5:
if ( v5 == ++v6 )
return v7;
}
if ( v9 != 2 )
break;
if ( v8 == -36 )
{
us_buffer_append_byte(*(_QWORD **)(a1 + 8), 192);
*(_DWORD *)a1 = 1;
goto LABEL_5;
}
if ( v8 != -35 )
goto LABEL_4;
++v6;
us_buffer_append_byte(*(_QWORD **)(a1 + 8), 219);
*(_DWORD *)a1 = 1;
if ( v5 == v6 )
return v7;
}
if ( !v9 )
{
if ( v8 == -64 )
*(_DWORD *)a1 = 1;
goto LABEL_5;
}
LABEL_4:
us_slip_decoder_reset(a1);
goto LABEL_5;
}
return 0LL;
}

original_code:
int us_slip_decoder_parse_buffer( us_slip_decoder_t *self, us_buffer_t *buffer )
{
    int packet_count = 0;
    int i;
    int len = (int)us_buffer_readable_count( buffer );
    for ( i = 0; i < len; ++i )
    {
        uint8_t c = us_buffer_read_byte( buffer );
        switch ( self->m_state )
        {
        case us_slip_state_before_packet:
            if ( c == ( 0300 ) )
            {
                self->m_state = us_slip_state_in_packet;
            }
            break;
        case us_slip_state_in_packet:
            if ( c == ( 0300 ) && us_buffer_readable_count( self->m_buffer ) > 0 )
            {
                self->m_packet_formed_callback( self, self->m_buffer );
                us_buffer_reset( self->m_buffer );
                packet_count++;
            }
            else if ( c == ( 0333 ) )
            {
                self->m_state = us_slip_state_in_esc;
            }
            else
            {
                us_buffer_append_byte( self->m_buffer, c );
            }
            break;
        case us_slip_state_in_esc:
            if ( c == ( 0334 ) )
            {
                us_buffer_append_byte( self->m_buffer, ( 0300 ) );
                self->m_state = us_slip_state_in_packet;
            }
            else if ( c == ( 0335 ) )
            {
                us_buffer_append_byte( self->m_buffer, ( 0333 ) );
                self->m_state = us_slip_state_in_packet;
            }
            else
            {
                us_slip_decoder_reset( self );
            }
            break;
        default:
            us_slip_decoder_reset( self );
            break;
        }
    }
    return packet_count;
}

canonical_original_code:
int us_slip_decoder_parse_buffer(struct us_slip_decoder_s *self, struct us_buffer_s *buffer)
{
    int packet_count = 0;
    int i;
    int len = (int)us_buffer_readable_count( buffer );
    for ( i = 0; i < len; ++i )
    {
        unsigned char c = us_buffer_read_byte( buffer );
        switch ( self->m_state )
        {
        case us_slip_state_before_packet:
            if ( c == ( 0300 ) )
            {
                self->m_state = us_slip_state_in_packet;
            }
            break;
        case us_slip_state_in_packet:
            if ( c == ( 0300 ) && us_buffer_readable_count( self->m_buffer ) > 0 )
            {
                self->m_packet_formed_callback( self, self->m_buffer );
                us_buffer_reset( self->m_buffer );
                packet_count++;
            }
            else if ( c == ( 0333 ) )
            {
                self->m_state = us_slip_state_in_esc;
            }
            else
            {
                us_buffer_append_byte( self->m_buffer, c );
            }
            break;
        case us_slip_state_in_esc:
            if ( c == ( 0334 ) )
            {
                us_buffer_append_byte( self->m_buffer, ( 0300 ) );
                self->m_state = us_slip_state_in_packet;
            }
            else if ( c == ( 0335 ) )
            {
                us_buffer_append_byte( self->m_buffer, ( 0333 ) );
                self->m_state = us_slip_state_in_packet;
            }
            else
            {
                us_slip_decoder_reset( self );
            }
            break;
        default:
            us_slip_decoder_reset( self );
            break;
        }
    }
    return packet_count;
}

variable_types: len int


decompiled_code:
__int64 __fastcall us_slip_encode(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // r8
int v3; // er10
__int64 result; // rax
char v5; // cl
_QWORD *v6; // r8
_QWORD *v7; // r9
__int64 v8; // r11
__int64 v9; // r10
__int64 v10; // r11
__int64 v11; // rax
char v12; // al
_QWORD *v13; // r8
_QWORD *v14; // rdi
bool v15; // al
char v16; // cl
__int64 v17; // r11
__int64 v18; // r10
unsigned int v19; // eax
int v20; // ecx
_QWORD *v21; // rdi
bool v22; // al
char v23; // cl

v3 = us_buffer_readable_count(a2);
result = 1LL;
if ( v3 > 0 )
{
v5 = us_buffer_append_byte(v2, 192);
while ( 1 )
{
if ( !v5 )
{
LABEL_10:
LOBYTE(v19) = us_buffer_append_byte(v6, 192);
return v20 & v19;
}
v12 = us_buffer_peek(v7, v8);
if ( v12 == -64 )
break;
if ( v12 != -37 )
{
v5 = us_buffer_append_byte(v13, v12);
goto LABEL_4;
}
v14 = v13;
us_buffer_append_byte(v13, 219);
v15 = us_buffer_append_byte(v14, 221);
v5 = v15 & v16;
v11 = v17 + 1;
if ( v17 == v18 )
goto LABEL_10;
LABEL_5:
v8 = v11;
}
v21 = v13;
us_buffer_append_byte(v13, 219);
v22 = us_buffer_append_byte(v21, 220);
v5 = v22 & v23;
LABEL_4:
v11 = v10 + 1;
if ( v10 == v9 )
goto LABEL_10;
goto LABEL_5;
}
return result;
}

original_code:
_Bool us_slip_encode( us_buffer_t *dest_buffer, us_buffer_t *src_buffer )
{
    _Bool r = 1;
    int32_t i;
    int32_t len = (int32_t)us_buffer_readable_count( src_buffer );
    if ( len > 0 )
    {
        r &= us_buffer_append_byte( dest_buffer, ( 0300 ) );
        for ( i = 0; i < len; ++i )
        {
            uint8_t c;
            if ( !r )
                break;
            c = us_buffer_peek( src_buffer, i );
            if ( c == ( 0300 ) )
            {
                r &= us_buffer_append_byte( dest_buffer, ( 0333 ) );
                r &= us_buffer_append_byte( dest_buffer, ( 0334 ) );
            }
            else if ( c == ( 0333 ) )
            {
                r &= us_buffer_append_byte( dest_buffer, ( 0333 ) );
                r &= us_buffer_append_byte( dest_buffer, ( 0335 ) );
            }
            else
            {
                r &= us_buffer_append_byte( dest_buffer, c );
            }
        }
        r &= us_buffer_append_byte( dest_buffer, ( 0300 ) );
    }
    return r;
}

canonical_original_code:
_Bool us_slip_encode(struct us_buffer_s *dest_buffer, struct us_buffer_s *src_buffer)
{
    _Bool r = 1;
    int i;
    int len = (int32_t)us_buffer_readable_count( src_buffer );
    if ( len > 0 )
    {
        r &= us_buffer_append_byte( dest_buffer, ( 0300 ) );
        for ( i = 0; i < len; ++i )
        {
            unsigned char c;
            if ( !r )
                break;
            c = us_buffer_peek( src_buffer, i );
            if ( c == ( 0300 ) )
            {
                r &= us_buffer_append_byte( dest_buffer, ( 0333 ) );
                r &= us_buffer_append_byte( dest_buffer, ( 0334 ) );
            }
            else if ( c == ( 0333 ) )
            {
                r &= us_buffer_append_byte( dest_buffer, ( 0333 ) );
                r &= us_buffer_append_byte( dest_buffer, ( 0335 ) );
            }
            else
            {
                r &= us_buffer_append_byte( dest_buffer, c );
            }
        }
        r &= us_buffer_append_byte( dest_buffer, ( 0300 ) );
    }
    return r;
}


decompiled_code:
void us_logger_syslog_finish()
{
closelog();
us_log_error_proc = &us_log_null;
us_log_warn_proc = &us_log_null;
us_log_info_proc = &us_log_null;
us_log_debug_proc = &us_log_null;
us_logger_finish = &us_logger_null_finish;
}

canonical_decompiled_code:
void func0()
{
closelog();
us_log_error_proc = &us_log_null;
us_log_warn_proc = &us_log_null;
us_log_info_proc = &us_log_null;
us_log_debug_proc = &us_log_null;
us_logger_finish = &us_logger_null_finish;
}

original_code:
void us_logger_syslog_finish()
{
    closelog();
    us_log_error_proc = us_log_null;
    us_log_warn_proc = us_log_null;
    us_log_info_proc = us_log_null;
    us_log_debug_proc = us_log_null;
    us_logger_finish = us_logger_null_finish;
}


decompiled_code:
void us_log_error_syslog(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(1, fmt, va);
}

canonical_decompiled_code:
void func1(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(1, fmt, va);
}

original_code:
void us_log_error_syslog( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 1, fmt, ap );
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_error_syslog(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 1, fmt, ap );
    __builtin_va_end(ap);
}


decompiled_code:
void us_log_warn_syslog(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(4, fmt, va);
}

canonical_decompiled_code:
void func2(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(4, fmt, va);
}

original_code:
void us_log_warn_syslog( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 4, fmt, ap );
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_warn_syslog(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 4, fmt, ap );
    __builtin_va_end(ap);
}


decompiled_code:
void us_log_info_syslog(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(6, fmt, va);
}

canonical_decompiled_code:
void func3(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(6, fmt, va);
}

original_code:
void us_log_info_syslog( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 6, fmt, ap );
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_info_syslog(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 6, fmt, ap );
    __builtin_va_end(ap);
}


decompiled_code:
void us_log_debug_syslog(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(7, fmt, va);
}

canonical_decompiled_code:
void func4(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(7, fmt, va);
}

original_code:
void us_log_debug_syslog( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 7, fmt, ap );
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_debug_syslog(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 7, fmt, ap );
    __builtin_va_end(ap);
}


decompiled_code:
void us_log_trace_syslog(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(7, fmt, va);
}

canonical_decompiled_code:
void func5(char *fmt, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, fmt);
syslog(7, fmt, va);
}

original_code:
void us_log_trace_syslog( const char *fmt, ... )
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 7, fmt, ap );
    __builtin_va_end(ap);
}

canonical_original_code:
void us_log_trace_syslog(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    syslog( 7, fmt, ap );
    __builtin_va_end(ap);
}


decompiled_code:
__int64 __fastcall us_logger_syslog_start(const char *a1)
{
__int64 result; // rax

openlog(a1, 35, 24);
setlogmask(255);
result = 1LL;
us_log_error_proc = us_log_error_syslog;
us_log_warn_proc = us_log_warn_syslog;
us_log_info_proc = us_log_info_syslog;
us_log_debug_proc = us_log_debug_syslog;
us_log_trace_proc = us_log_trace_syslog;
us_logger_finish = us_logger_syslog_finish;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1)
{
__int64 result; // rax

openlog(a1, 35, 24);
setlogmask(255);
result = 1LL;
us_log_error_proc = us_log_error_syslog;
us_log_warn_proc = us_log_warn_syslog;
us_log_info_proc = us_log_info_syslog;
us_log_debug_proc = us_log_debug_syslog;
us_log_trace_proc = us_log_trace_syslog;
us_logger_finish = us_logger_syslog_finish;
return result;
}

original_code:
_Bool us_logger_syslog_start( const char *ident )
{
    openlog( ident, ( 0x02 | 0x20 | 0x01 ), (3<<3) );
    setlogmask( ((1 << ((7)+1)) - 1) );
    us_log_error_proc = us_log_error_syslog;
    us_log_warn_proc = us_log_warn_syslog;
    us_log_info_proc = us_log_info_syslog;
    us_log_debug_proc = us_log_debug_syslog;
    us_log_trace_proc = us_log_trace_syslog;
    us_logger_finish = us_logger_syslog_finish;
    return 1;
}

canonical_original_code:
_Bool us_logger_syslog_start(char *ident)
{
    openlog( ident, ( 0x02 | 0x20 | 0x01 ), (3<<3) );
    setlogmask( ((1 << ((7)+1)) - 1) );
    us_log_error_proc = us_log_error_syslog;
    us_log_warn_proc = us_log_warn_syslog;
    us_log_info_proc = us_log_info_syslog;
    us_log_debug_proc = us_log_debug_syslog;
    us_log_trace_proc = us_log_trace_syslog;
    us_logger_finish = us_logger_syslog_finish;
    return 1;
}

variable_types:
ident
char *


decompiled_code:
__int64 __fastcall us_test_slip_callback(__int64 a1, __int64 a2)
{
if ( us_log_level > 2 )
us_log_info_proc("Successfully parsed slip encoded buffer");
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"contents of decoded buffer:\n");
us_buffer_print(a2, us_testutil_printer_stdout);
return (*(__int64 (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"\n");
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
if ( us_log_level > 2 )
us_log_info_proc("Successfully parsed slip encoded buffer");
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"contents of decoded buffer:\n");
us_buffer_print(a2, us_testutil_printer_stdout);
return (*(__int64 (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"\n");
}

original_code:
static void us_test_slip_callback( us_slip_decoder_t *self, us_buffer_t *buf )
{
    (void)self;
    do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "Successfully parsed slip encoded buffer" ); } while ( 0 );
    us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "contents of decoded buffer:\n" );
    us_buffer_print( buf, us_testutil_printer_stdout );
    us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "\n" );
}

canonical_original_code:
static void us_test_slip_callback(struct us_slip_decoder_s *self, struct us_buffer_s *buf)
{
    (void)self;
    do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "Successfully parsed slip encoded buffer" ); } while ( 0 );
    us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "contents of decoded buffer:\n" );
    us_buffer_print( buf, us_testutil_printer_stdout );
    us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "\n" );
}

variable_types:
buf
struct us_buffer_s *


decompiled_code:
__int64 us_test_slip_fill_buffer()
{
__int64 v0; // rax
__int64 v1; // r12

v0 = us_buffer_create(us_testutil_sys_allocator, 1024LL);
v1 = v0;
if ( v0 )
{
if ( (unsigned __int8)us_buffer_append_rounded_string(v0, "Rounded String")
&& (unsigned __int8)us_buffer_append_int32(v1, 305447032LL)
&& (unsigned __int8)us_buffer_append_uint64(v1, 2309737967LL, 19088859LL) )
{
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"contents of test buffer:\n");
us_buffer_print(v1, us_testutil_printer_stdout);
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"\n");
return v1;
}
return 0LL;
}
if ( us_log_level <= 0 )
return 0LL;
us_log_error_proc("expected to allocate 1024 bytes from allocator for buffer but failed");
return 0LL;
}

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

v0 = us_buffer_create(us_testutil_sys_allocator, 1024LL);
v1 = v0;
if ( v0 )
{
if ( (unsigned __int8)us_buffer_append_rounded_string(v0, "Rounded String")
&& (unsigned __int8)us_buffer_append_int32(v1, 305447032LL)
&& (unsigned __int8)us_buffer_append_uint64(v1, 2309737967LL, 19088859LL) )
{
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"contents of test buffer:\n");
us_buffer_print(v1, us_testutil_printer_stdout);
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"\n");
return v1;
}
return 0LL;
}
if ( us_log_level <= 0 )
return 0LL;
us_log_error_proc("expected to allocate 1024 bytes from allocator for buffer but failed");
return 0LL;
}

original_code:
static us_buffer_t *us_test_slip_fill_buffer( void )
{
    _Bool r = 0;
    us_buffer_t *buf = us_buffer_create( us_testutil_sys_allocator, 1024 );
    if ( buf )
    {
        if ( us_buffer_append_rounded_string( buf, "Rounded String" ) )
        {
            if ( us_buffer_append_int32( buf, 0x1234c078 ) )
            {
                if ( us_buffer_append_uint64( buf, 0x89abcdef, 0x012345db ) )
                {
                    us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "contents of test buffer:\n" );
                    us_buffer_print( buf, us_testutil_printer_stdout );
                    us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "\n" );
                    r = 1;
                }
            }
        }
    }
    else
    {
        do { if ( us_log_level >= ( 1 ) ) us_log_error_proc( "expected to allocate 1024 bytes from allocator for buffer but failed" ); } while ( 0 );
    }
    if ( !r )
        buf = 0;
    return buf;
}

canonical_original_code:
static struct us_buffer_s *us_test_slip_fill_buffer()
{
    _Bool r = 0;
    struct us_buffer_s *buf = us_buffer_create( us_testutil_sys_allocator, 1024 );
    if ( buf )
    {
        if ( us_buffer_append_rounded_string( buf, "Rounded String" ) )
        {
            if ( us_buffer_append_int32( buf, 0x1234c078 ) )
            {
                if ( us_buffer_append_uint64( buf, 0x89abcdef, 0x012345db ) )
                {
                    us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "contents of test buffer:\n" );
                    us_buffer_print( buf, us_testutil_printer_stdout );
                    us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "\n" );
                    r = 1;
                }
            }
        }
    }
    else
    {
        do { if ( us_log_level >= ( 1 ) ) us_log_error_proc( "expected to allocate 1024 bytes from allocator for buffer but failed" ); } while ( 0 );
    }
    if ( !r )
        buf = 0;
    return buf;
}

return_type: struct us_buffer_s { void (*destroy)(struct us_buffer_s *self); struct us_allocator_s { void (*destroy)(struct us_allocator_s *self); void *(*alloc)(struct us_allocator_s *self, int length, int count); void *(*realloc)(struct us_allocator_s *self, void *orig_ptr, int length, int count); void (*free)(struct us_allocator_s *self, void *ptr); } *m_allocator; unsigned char *m_buffer; unsigned long m_next_in; unsigned long m_next_out; unsigned long m_max_length; } *


decompiled_code:
__int64 __fastcall us_test_slip()
{
unsigned int v0; // er12
__int64 v1; // r13
__int64 v2; // rbp
__int64 v3; // r14

v1 = us_test_slip_fill_buffer();
v2 = us_buffer_create(us_testutil_sys_allocator, 1024LL);
v3 = us_slip_decoder_create(us_testutil_sys_allocator, 1024LL, us_test_slip_callback);
LOBYTE(v0) = v2 != 0 && v1 != 0 && v3 != 0;
if ( !(_BYTE)v0 )
{
if ( us_log_level > 0 )
{
us_log_error_proc("Error allocating buffers or slip decoder");
return v0;
}
return 0LL;
}
if ( us_log_level > 2 )
us_log_info_proc("encoding buffer");
if ( !(unsigned __int8)us_slip_encode(v2, v1) )
return 0LL;
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"contents of encoded buffer:\n");
us_buffer_print(v2, us_testutil_printer_stdout);
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(us_testutil_printer_stdout, "\n");
if ( us_log_level > 2 )
us_log_info_proc("decoding buffer");
LOBYTE(v0) = (unsigned int)us_slip_decoder_parse_buffer(v3, v2) == 1;
return v0;
}

canonical_decompiled_code:
__int64 __fastcall func2()
{
unsigned int v0; // er12
__int64 v1; // r13
__int64 v2; // rbp
__int64 v3; // r14

v1 = func1();
v2 = us_buffer_create(us_testutil_sys_allocator, 1024LL);
v3 = us_slip_decoder_create(us_testutil_sys_allocator, 1024LL, us_test_slip_callback);
LOBYTE(v0) = v2 != 0 && v1 != 0 && v3 != 0;
if ( !(_BYTE)v0 )
{
if ( us_log_level > 0 )
{
us_log_error_proc("Error allocating buffers or slip decoder");
return v0;
}
return 0LL;
}
if ( us_log_level > 2 )
us_log_info_proc("encoding buffer");
if ( !(unsigned __int8)us_slip_encode(v2, v1) )
return 0LL;
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(
us_testutil_printer_stdout,
"contents of encoded buffer:\n");
us_buffer_print(v2, us_testutil_printer_stdout);
(*(void (__fastcall **)(_QWORD, const char *))(us_testutil_printer_stdout + 8LL))(us_testutil_printer_stdout, "\n");
if ( us_log_level > 2 )
us_log_info_proc("decoding buffer");
LOBYTE(v0) = (unsigned int)us_slip_decoder_parse_buffer(v3, v2) == 1;
return v0;
}

original_code:
static _Bool us_test_slip( void )
{
    _Bool r = 0;
    us_buffer_t *src_buf = us_test_slip_fill_buffer();
    us_buffer_t *slipped_buf = us_buffer_create( us_testutil_sys_allocator, 1024 );
    us_slip_decoder_t *slip_decoder = us_slip_decoder_create( us_testutil_sys_allocator, 1024, us_test_slip_callback );
    if ( src_buf && slipped_buf && slip_decoder )
    {
        do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "encoding buffer" ); } while ( 0 );
        if ( us_slip_encode( slipped_buf, src_buf ) )
        {
            us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "contents of encoded buffer:\n" );
            us_buffer_print( slipped_buf, us_testutil_printer_stdout );
            us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "\n" );
            do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "decoding buffer" ); } while ( 0 );
            if ( us_slip_decoder_parse_buffer( slip_decoder, slipped_buf ) == 1 )
            {
                r = 1;
            }
        }
    }
    else
    {
        do { if ( us_log_level >= ( 1 ) ) us_log_error_proc( "Error allocating buffers or slip decoder" ); } while ( 0 );
    }
    return r;
}

canonical_original_code:
static _Bool us_test_slip()
{
    _Bool r = 0;
    struct us_buffer_s *src_buf = us_test_slip_fill_buffer();
    struct us_buffer_s *slipped_buf = us_buffer_create( us_testutil_sys_allocator, 1024 );
    struct us_slip_decoder_s *slip_decoder = us_slip_decoder_create( us_testutil_sys_allocator, 1024, us_test_slip_callback );
    if ( src_buf && slipped_buf && slip_decoder )
    {
        do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "encoding buffer" ); } while ( 0 );
        if ( us_slip_encode( slipped_buf, src_buf ) )
        {
            us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "contents of encoded buffer:\n" );
            us_buffer_print( slipped_buf, us_testutil_printer_stdout );
            us_testutil_printer_stdout->printf( us_testutil_printer_stdout, "\n" );
            do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "decoding buffer" ); } while ( 0 );
            if ( us_slip_decoder_parse_buffer( slip_decoder, slipped_buf ) == 1 )
            {
                r = 1;
            }
        }
    }
    else
    {
        do { if ( us_log_level >= ( 1 ) ) us_log_error_proc( "Error allocating buffers or slip decoder" ); } while ( 0 );
    }
    return r;
}


decompiled_code:
__int64 __fastcall us_test_slip_main(unsigned int a1, __int64 a2)
{
unsigned int v3; // er12

if ( !(unsigned __int8)us_testutil_start(4096LL, 4096LL, a1, a2) )
return 1LL;
us_logger_printer_start(us_testutil_printer_stdout, us_testutil_printer_stderr);
us_log_level = 4;
us_log_info_proc("Hello world from %s compiled on %s", "../../../src/us_test_slip_main.c", "May 23 2025");
v3 = (unsigned __int8)us_test_slip() ^ 1;
if ( us_log_level > 2 )
us_log_info_proc("Finishing us_test_slip");
us_logger_finish();
us_testutil_finish();
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, __int64 a2)
{
unsigned int v3; // er12

if ( !(unsigned __int8)us_testutil_start(4096LL, 4096LL, a1, a2) )
return 1LL;
us_logger_printer_start(us_testutil_printer_stdout, us_testutil_printer_stderr);
us_log_level = 4;
us_log_info_proc("Hello world from %s compiled on %s", "../../../src/us_test_slip_main.c", "May 23 2025");
v3 = (unsigned __int8)func2() ^ 1;
if ( us_log_level > 2 )
us_log_info_proc("Finishing us_test_slip");
us_logger_finish();
us_testutil_finish();
return v3;
}

original_code:
int us_test_slip_main( int argc, const char **argv )
{
    int r = 1;
    if ( us_testutil_start( 4096, 4096, argc, argv ) )
    {
        us_logger_printer_start( us_testutil_printer_stdout, us_testutil_printer_stderr );
        do { us_log_level = ( ( 4 ) ); } while ( 0 );
        do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "Hello world from %s compiled on %s", "../../../src/us_test_slip_main.c", "Apr 24 2024" ); } while ( 0 );
        if ( us_test_slip() )
            r = 0;
        do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "Finishing us_test_slip" ); } while ( 0 );
        us_logger_finish();
        us_testutil_finish();
    }
    return r;
}

canonical_original_code:
int us_test_slip_main(int argc, char **argv)
{
    int r = 1;
    if ( us_testutil_start( 4096, 4096, argc, argv ) )
    {
        us_logger_printer_start( us_testutil_printer_stdout, us_testutil_printer_stderr );
        do { us_log_level = ( ( 4 ) ); } while ( 0 );
        do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "Hello world from %s compiled on %s", "../../../src/us_test_slip_main.c", "Apr 24 2024" ); } while ( 0 );
        if ( us_test_slip() )
            r = 0;
        do { if ( us_log_level >= ( 3 ) ) us_log_info_proc( "Finishing us_test_slip" ); } while ( 0 );
        us_logger_finish();
        us_testutil_finish();
    }
    return r;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: r int