decompiled_code:
__int64 __fastcall search_queue(char *s2)
{
pthread_mutex_t *v1; // rbx
__int64 v2; // rbx
__int64 result; // rax

v1 = qbase;
pthread_mutex_lock(qbase);
v2 = v1[1].__align;
if ( v2 )
{
while ( strcmp((const char *)(v2 + 136), s2) )
{
v2 = *(_QWORD *)v2;
if ( !v2 )
goto LABEL_6;
}
pthread_mutex_unlock(qbase);
result = v2;
}
else
{
LABEL_6:
pthread_mutex_unlock(qbase);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s2)
{
pthread_mutex_t *v1; // rbx
__int64 v2; // rbx
__int64 result; // rax

v1 = qbase;
pthread_mutex_lock(qbase);
v2 = v1[1].__align;
if ( v2 )
{
while ( strcmp((const char *)(v2 + 136), s2) )
{
v2 = *(_QWORD *)v2;
if ( !v2 )
goto LABEL_6;
}
pthread_mutex_unlock(qbase);
result = v2;
}
else
{
LABEL_6:
pthread_mutex_unlock(qbase);
result = 0LL;
}
return result;
}

user_defined_types: struct _hlist_head { struct _hlist_node *first; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


repo: opendaylight/opendove

decompiled_code:
__int64 __fastcall create_queue(char *a1, int a2, int a3, _QWORD *a4)
{
_QWORD *v6; // rax
_QWORD *v7; // rbp
__int64 v8; // rax
size_t v9; // rdx
void *v10; // rax
__int64 result; // rax

if ( search_queue(a1) )
{
printf("Queue %s already exists!\r\n", a1);
result = 0xFFFFFFFFLL;
}
else
{
v6 = calloc(0xA0uLL, 1uLL);
v7 = v6;
if ( v6
&& (*a4 = v6,
hlist_node_init(v6),
strncpy((char *)(v8 + 136), a1, v9),
*((_DWORD *)v7 + 4) = a2,
*((_DWORD *)v7 + 5) = a3,
v10 = malloc((unsigned int)(a3 * a2)),
(v7[3] = v10) != 0LL) )
{
pthread_cond_init((pthread_cond_t *)v7 + 1, 0LL);
pthread_mutex_init((pthread_mutex_t *)(v7 + 12), 0LL);
pthread_mutex_lock(qbase);
hlist_head_add(&qbase[1].__align, v7);
pthread_mutex_unlock(qbase);
result = 0LL;
}
else
{
puts("No suffient memory to create a message queue!\r");
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1, int a2, int a3, _QWORD *a4)
{
_QWORD *v6; // rax
_QWORD *v7; // rbp
__int64 v8; // rax
size_t v9; // rdx
void *v10; // rax
__int64 result; // rax

if ( func3(a1) )
{
printf("Queue %s already exists!\r\n", a1);
result = 0xFFFFFFFFLL;
}
else
{
v6 = calloc(0xA0uLL, 1uLL);
v7 = v6;
if ( v6
&& (*a4 = v6,
func0(v6),
strncpy((char *)(v8 + 136), a1, v9),
*((_DWORD *)v7 + 4) = a2,
*((_DWORD *)v7 + 5) = a3,
v10 = malloc((unsigned int)(a3 * a2)),
(v7[3] = v10) != 0LL) )
{
pthread_cond_init((pthread_cond_t *)v7 + 1, 0LL);
pthread_mutex_init((pthread_mutex_t *)(v7 + 12), 0LL);
pthread_mutex_lock(qbase);
func1(&qbase[1].__align, v7);
pthread_mutex_unlock(qbase);
result = 0LL;
}
else
{
puts("No suffient memory to create a message queue!\r");
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int create_queue(const char *name, unsigned int msg_len, unsigned int msg_num, long *qid)
{
    queue_info *qi;
    if (search_queue(name))
    {
        printf("Queue %s already exists!\r\n", name);
        return -1;
    }
    qi = (queue_info *)malloc(sizeof(queue_info));
    if (qi == ((void *)0))
    {
        printf("No suffient memory to create a message queue!\r\n");
        return -1;
    }
    memset(qi, 0, sizeof(queue_info));
    *qid = (long)qi;
    hlist_node_init(&qi->entry);
    strncpy(qi->name, name, 16);
    qi->msg_len = msg_len;
    qi->msg_num = msg_num;
    if ((qi->buffer = (char *)malloc(msg_len*msg_num)) == ((void *)0))
    {
        printf("No suffient memory to create a message queue!\r\n");
        return -1;
    }
    pthread_cond_init(&qi->cond, ((void *)0));
    pthread_mutex_init(&qi->lock, ((void *)0));
    pthread_mutex_lock(&qbase->lock);
    hlist_head_add(&qbase->queue_list, &qi->entry);
    pthread_mutex_unlock(&qbase->lock);
    return 0;
}

canonical_original_code:
int create_queue(char *name, unsigned int msg_len, unsigned int msg_num, long *qid)
{
    struct _queue_info *qi;
    if (search_queue(name))
    {
        printf("Queue %s already exists!\r\n", name);
        return -1;
    }
    qi = (struct _queue_info *)malloc(sizeof(queue_info));
    if (qi == ((void *)0))
    {
        printf("No suffient memory to create a message queue!\r\n");
        return -1;
    }
    memset(qi, 0, sizeof(queue_info));
    *qid = (long)qi;
    hlist_node_init(&qi->entry);
    strncpy(qi->name, name, 16);
    qi->msg_len = msg_len;
    qi->msg_num = msg_num;
    if ((qi->buffer = (char *)malloc(msg_len*msg_num)) == ((void *)0))
    {
        printf("No suffient memory to create a message queue!\r\n");
        return -1;
    }
    pthread_cond_init(&qi->cond, ((void *)0));
    pthread_mutex_init(&qi->lock, ((void *)0));
    pthread_mutex_lock(&qbase->lock);
    hlist_head_add(&qbase->queue_list, &qi->entry);
    pthread_mutex_unlock(&qbase->lock);
    return 0;
}

variable_types:
name
char *

variable_types:
qid
long *

variable_types: struct _queue_info { struct _hlist_node { struct _hlist_node *next; struct _hlist_node **pprevious; } entry; unsigned int msg_len; unsigned int msg_num; char *buffer; unsigned int write_index; unsigned int read_index; unsigned int avail_num; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; char name[-1]; } *

return_type: int

user_defined_types: struct _queue_info { struct _hlist_node entry; unsigned int msg_len; unsigned int msg_num; char *buffer; unsigned int write_index; unsigned int read_index; unsigned int avail_num; union pthread_cond_t cond; union pthread_mutex_t lock; char name[-1]; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
void __fastcall del_queue(void *ptr)
{
pthread_mutex_lock(qbase);
hlist_node_remove((__int64 *)ptr);
pthread_mutex_unlock(qbase);
pthread_mutex_destroy((pthread_mutex_t *)((char *)ptr + 96));
pthread_cond_destroy((pthread_cond_t *)ptr + 1);
free(*((void **)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func5(void *ptr)
{
pthread_mutex_lock(qbase);
func2((__int64 *)ptr);
pthread_mutex_unlock(qbase);
pthread_mutex_destroy((pthread_mutex_t *)((char *)ptr + 96));
pthread_cond_destroy((pthread_cond_t *)ptr + 1);
free(*((void **)ptr + 3));
free(ptr);
}

original_code:
void del_queue(long qid)
{
    queue_info *qi = (queue_info *)qid;
    pthread_mutex_lock(&qbase->lock);
    hlist_node_remove(&qi->entry);
    pthread_mutex_unlock(&qbase->lock);
    pthread_mutex_destroy(&qi->lock);
    pthread_cond_destroy(&qi->cond);
    free(qi->buffer);
    free(qi);
    return;
}

canonical_original_code:
void del_queue(long qid)
{
    struct _queue_info *qi = (queue_info *)qid;
    pthread_mutex_lock(&qbase->lock);
    hlist_node_remove(&qi->entry);
    pthread_mutex_unlock(&qbase->lock);
    pthread_mutex_destroy(&qi->lock);
    pthread_cond_destroy(&qi->cond);
    free(qi->buffer);
    free(qi);
    return;
}

variable_types: qid long

return_type: void

user_defined_types: struct _hlist_node { struct _hlist_node *next; struct _hlist_node **pprevious; }

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }


decompiled_code:
__int64 __fastcall queue_send(__int64 a1, const void *a2, unsigned int a3)
{
pthread_mutex_t *v3; // r12
int v5; // eax
__int64 result; // rax

if ( *(_DWORD *)(a1 + 16) < a3 )
return 0xFFFFFFFFLL;
v3 = (pthread_mutex_t *)(a1 + 96);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 96));
if ( *(_DWORD *)(a1 + 40) >= *(_DWORD *)(a1 + 20) )
{
pthread_mutex_unlock(v3);
result = 0xFFFFFFFFLL;
}
else
{
memcpy((void *)(*(_QWORD *)(a1 + 24) + (unsigned int)(*(_DWORD *)(a1 + 16) * *(_DWORD *)(a1 + 32))), a2, a3);
v5 = *(_DWORD *)(a1 + 32);
++*(_DWORD *)(a1 + 40);
*(_DWORD *)(a1 + 32) = (unsigned int)(v5 + 1) % *(_DWORD *)(a1 + 20);
pthread_cond_signal((pthread_cond_t *)(a1 + 48));
pthread_mutex_unlock(v3);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const void *a2, unsigned int a3)
{
pthread_mutex_t *v3; // r12
int v5; // eax
__int64 result; // rax

if ( *(_DWORD *)(a1 + 16) < a3 )
return 0xFFFFFFFFLL;
v3 = (pthread_mutex_t *)(a1 + 96);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 96));
if ( *(_DWORD *)(a1 + 40) >= *(_DWORD *)(a1 + 20) )
{
pthread_mutex_unlock(v3);
result = 0xFFFFFFFFLL;
}
else
{
memcpy((void *)(*(_QWORD *)(a1 + 24) + (unsigned int)(*(_DWORD *)(a1 + 16) * *(_DWORD *)(a1 + 32))), a2, a3);
v5 = *(_DWORD *)(a1 + 32);
++*(_DWORD *)(a1 + 40);
*(_DWORD *)(a1 + 32) = (unsigned int)(v5 + 1) % *(_DWORD *)(a1 + 20);
pthread_cond_signal((pthread_cond_t *)(a1 + 48));
pthread_mutex_unlock(v3);
result = 0LL;
}
return result;
}

original_code:
int queue_send(long qid, char *msg_buf, unsigned int msg_len)
{
    queue_info *qi = (queue_info *)qid;
    char *data_ptr;
    if (msg_len > qi->msg_len)
        return -1;
    pthread_mutex_lock(&qi->lock);
    if (qi->avail_num >= qi->msg_num)
    {
        pthread_mutex_unlock(&qi->lock);
        return -1;
    }
    data_ptr = qi->buffer + qi->write_index*qi->msg_len;
    memcpy(data_ptr, msg_buf, msg_len);
    qi->write_index = (qi->write_index + 1) % qi->msg_num;
    qi->avail_num++;
    pthread_cond_signal(&qi->cond);
    pthread_mutex_unlock(&qi->lock);
    return 0;
}

canonical_original_code:
int queue_send(long qid, char *msg_buf, unsigned int msg_len)
{
    struct _queue_info *qi = (queue_info *)qid;
    char *data_ptr;
    if (msg_len > qi->msg_len)
        return -1;
    pthread_mutex_lock(&qi->lock);
    if (qi->avail_num >= qi->msg_num)
    {
        pthread_mutex_unlock(&qi->lock);
        return -1;
    }
    data_ptr = qi->buffer + qi->write_index*qi->msg_len;
    memcpy(data_ptr, msg_buf, msg_len);
    qi->write_index = (qi->write_index + 1) % qi->msg_num;
    qi->avail_num++;
    pthread_cond_signal(&qi->cond);
    pthread_mutex_unlock(&qi->lock);
    return 0;
}


decompiled_code:
__int64 __fastcall queue_receive(__int64 a1, void *a2, unsigned int a3, int a4)
{
pthread_mutex_t *v4; // r14
unsigned int v6; // ebp
int v7; // eax
int v9; // eax
unsigned int v10; // er13
__int64 v11; // rax
struct timespec v12; // [rsp+0h] [rbp-48h] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF

v4 = (pthread_mutex_t *)(a1 + 96);
v6 = a3;
if ( *(_DWORD *)(a1 + 16) <= a3 )
v6 = *(_DWORD *)(a1 + 16);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 96));
if ( a4 )
{
v9 = *(_DWORD *)(a1 + 40);
if ( a4 == -1 )
{
if ( !v9 )
{
do
pthread_cond_wait((pthread_cond_t *)(a1 + 48), v4);
while ( !*(_DWORD *)(a1 + 40) );
}
goto LABEL_5;
}
if ( v9 )
goto LABEL_5;
gettimeofday(&tv, 0LL);
v10 = LODWORD(tv.tv_usec) + 1000 * a4;
v11 = 0LL;
if ( v10 > 0xF4240 )
{
v11 = v10 / 0xF4240;
v10 %= 0xF4240u;
}
v12.tv_sec = tv.tv_sec + v11;
v12.tv_nsec = 1000 * v10;
if ( pthread_cond_timedwait((pthread_cond_t *)(a1 + 48), v4, &v12) != 110 )
{
LABEL_5:
memcpy(a2, (const void *)(*(_QWORD *)(a1 + 24) + (unsigned int)(*(_DWORD *)(a1 + 16) * *(_DWORD *)(a1 + 36))), v6);
v7 = *(_DWORD *)(a1 + 36);
--*(_DWORD *)(a1 + 40);
*(_DWORD *)(a1 + 36) = (unsigned int)(v7 + 1) % *(_DWORD *)(a1 + 20);
pthread_mutex_unlock(v4);
return 0LL;
}
}
else if ( *(_DWORD *)(a1 + 40) )
{
goto LABEL_5;
}
pthread_mutex_unlock(v4);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, void *a2, unsigned int a3, int a4)
{
pthread_mutex_t *v4; // r14
unsigned int v6; // ebp
int v7; // eax
int v9; // eax
unsigned int v10; // er13
__int64 v11; // rax
struct timespec v12; // [rsp+0h] [rbp-48h] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF

v4 = (pthread_mutex_t *)(a1 + 96);
v6 = a3;
if ( *(_DWORD *)(a1 + 16) <= a3 )
v6 = *(_DWORD *)(a1 + 16);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 96));
if ( a4 )
{
v9 = *(_DWORD *)(a1 + 40);
if ( a4 == -1 )
{
if ( !v9 )
{
do
pthread_cond_wait((pthread_cond_t *)(a1 + 48), v4);
while ( !*(_DWORD *)(a1 + 40) );
}
goto LABEL_5;
}
if ( v9 )
goto LABEL_5;
gettimeofday(&tv, 0LL);
v10 = LODWORD(tv.tv_usec) + 1000 * a4;
v11 = 0LL;
if ( v10 > 0xF4240 )
{
v11 = v10 / 0xF4240;
v10 %= 0xF4240u;
}
v12.tv_sec = tv.tv_sec + v11;
v12.tv_nsec = 1000 * v10;
if ( pthread_cond_timedwait((pthread_cond_t *)(a1 + 48), v4, &v12) != 110 )
{
LABEL_5:
memcpy(a2, (const void *)(*(_QWORD *)(a1 + 24) + (unsigned int)(*(_DWORD *)(a1 + 16) * *(_DWORD *)(a1 + 36))), v6);
v7 = *(_DWORD *)(a1 + 36);
--*(_DWORD *)(a1 + 40);
*(_DWORD *)(a1 + 36) = (unsigned int)(v7 + 1) % *(_DWORD *)(a1 + 20);
pthread_mutex_unlock(v4);
return 0LL;
}
}
else if ( *(_DWORD *)(a1 + 40) )
{
goto LABEL_5;
}
pthread_mutex_unlock(v4);
return 0xFFFFFFFFLL;
}

original_code:
int queue_receive(long qid, char *msg_buf, unsigned int msg_len, int timeout)
{
    queue_info *qi = (queue_info *)qid;
    struct timespec ts;
    struct timeval tp;
    unsigned int sec = 0 , usec = 0;
    char *data_ptr;
    int rc;
    if (msg_len > qi->msg_len)
        msg_len = qi->msg_len;
    pthread_mutex_lock(&qi->lock);
    if (timeout == 0)
    {
        if (qi->avail_num == 0)
        {
            pthread_mutex_unlock(&qi->lock);
            return -1;
        }
    }
    else if (timeout == (int)(~0UL))
    {
        while (qi->avail_num == 0)
            pthread_cond_wait(&qi->cond, &qi->lock);
    }
    else
    {
        if (qi->avail_num == 0)
        {
            gettimeofday(&tp, ((void *)0));
            usec = tp.tv_usec + timeout * 1000;
            if (usec > 1000000)
            {
                sec = usec/1000000;
                usec = usec%1000000;
            }
            ts.tv_sec = tp.tv_sec + sec;
            ts.tv_nsec = usec * 1000;
            rc = pthread_cond_timedwait(&qi->cond, &qi->lock, &ts);
            if (rc == 110)
            {
                pthread_mutex_unlock(&qi->lock);
                return -1;
            }
        }
    }
    data_ptr = qi->buffer + qi->read_index*qi->msg_len;
    memcpy(msg_buf, data_ptr, msg_len);
    qi->read_index = (qi->read_index + 1) % qi->msg_num;
    qi->avail_num--;
    pthread_mutex_unlock(&qi->lock);
    return 0;
}

canonical_original_code:
int queue_receive(long qid, char *msg_buf, unsigned int msg_len, int timeout)
{
    struct _queue_info *qi = (queue_info *)qid;
    struct timespec ts;
    struct timeval tp;
    unsigned int sec = 0; unsigned int usec = 0;
    char *data_ptr;
    int rc;
    if (msg_len > qi->msg_len)
        msg_len = qi->msg_len;
    pthread_mutex_lock(&qi->lock);
    if (timeout == 0)
    {
        if (qi->avail_num == 0)
        {
            pthread_mutex_unlock(&qi->lock);
            return -1;
        }
    }
    else if (timeout == (int)(~0UL))
    {
        while (qi->avail_num == 0)
            pthread_cond_wait(&qi->cond, &qi->lock);
    }
    else
    {
        if (qi->avail_num == 0)
        {
            gettimeofday(&tp, ((void *)0));
            usec = tp.tv_usec + timeout * 1000;
            if (usec > 1000000)
            {
                sec = usec/1000000;
                usec = usec%1000000;
            }
            ts.tv_sec = tp.tv_sec + sec;
            ts.tv_nsec = usec * 1000;
            rc = pthread_cond_timedwait(&qi->cond, &qi->lock, &ts);
            if (rc == 110)
            {
                pthread_mutex_unlock(&qi->lock);
                return -1;
            }
        }
    }
    data_ptr = qi->buffer + qi->read_index*qi->msg_len;
    memcpy(msg_buf, data_ptr, msg_len);
    qi->read_index = (qi->read_index + 1) % qi->msg_num;
    qi->avail_num--;
    pthread_mutex_unlock(&qi->lock);
    return 0;
}

variable_types: timeout int

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types:
sec
unsigned int

variable_types:
usec
unsigned int

variable_types: rc int


decompiled_code:
__int64 queue_base_init()
{
pthread_mutex_t *v0; // rax
__int64 result; // rax

v0 = (pthread_mutex_t *)calloc(0x30uLL, 1uLL);
qbase = v0;
if ( v0 )
{
pthread_mutex_init(v0, 0LL);
qbase[1].__align = 0LL;
result = 0LL;
}
else
{
puts("Fail to memory allocation!\r");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
pthread_mutex_t *v0; // rax
__int64 result; // rax

v0 = (pthread_mutex_t *)calloc(0x30uLL, 1uLL);
qbase = v0;
if ( v0 )
{
pthread_mutex_init(v0, 0LL);
qbase[1].__align = 0LL;
result = 0LL;
}
else
{
puts("Fail to memory allocation!\r");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int queue_base_init(void)
{
    qbase = (queue_base *)malloc(sizeof(queue_base));
    if (qbase == ((void *)0))
    {
        printf("Fail to memory allocation!\r\n");
        return -1;
    }
    memset(qbase, 0, sizeof(queue_base));
    pthread_mutex_init(&qbase->lock, ((void *)0));
    ((&qbase->queue_list)->first = ((void *)0));
    return 0;
}

canonical_original_code:
int queue_base_init()
{
    qbase = (struct _queue_base *)malloc(sizeof(queue_base));
    if (qbase == ((void *)0))
    {
        printf("Fail to memory allocation!\r\n");
        return -1;
    }
    memset(qbase, 0, sizeof(queue_base));
    pthread_mutex_init(&qbase->lock, ((void *)0));
    ((&qbase->queue_list)->first = ((void *)0));
    return 0;
}

user_defined_types: struct _queue_base { union pthread_mutex_t lock; struct _hlist_head queue_list; }


decompiled_code:
const char *__fastcall search_sem(const char *a1)
{
char v1; // al
const char **v3; // [rsp+18h] [rbp-18h]
const char *v4; // [rsp+20h] [rbp-10h]
const char *i; // [rsp+28h] [rbp-8h]

v3 = (const char **)&sembase[1];
v4 = 0LL;
pthread_mutex_lock(sembase);
for ( i = *v3; ; i = *(const char **)i )
{
if ( i )
{
v4 = i;
v1 = 1;
}
else
{
v1 = 0;
}
if ( !v1 )
break;
if ( !strcmp(v4 + 48, a1) )
{
pthread_mutex_unlock(sembase);
return v4;
}
}
pthread_mutex_unlock(sembase);
return 0LL;
}

canonical_decompiled_code:
const char *__fastcall func0(const char *a1)
{
char v1; // al
const char **v3; // [rsp+18h] [rbp-18h]
const char *v4; // [rsp+20h] [rbp-10h]
const char *i; // [rsp+28h] [rbp-8h]

v3 = (const char **)&sembase[1];
v4 = 0LL;
pthread_mutex_lock(sembase);
for ( i = *v3; ; i = *(const char **)i )
{
if ( i )
{
v4 = i;
v1 = 1;
}
else
{
v1 = 0;
}
if ( !v1 )
break;
if ( !strcmp(v4 + 48, a1) )
{
pthread_mutex_unlock(sembase);
return v4;
}
}
pthread_mutex_unlock(sembase);
return 0LL;
}

original_code:
static long search_sem(const char *name)
{
    hlist_head *hhead = &sembase->sem_list;
    hlist_node *hnode = ((void *)0);
    sem_info *si = ((void *)0);
    pthread_mutex_lock(&sembase->lock);
    for (hnode = (hhead)->first; hnode && ({ si = ((sem_info *) ((char *) (hnode) - ((long) &((sem_info *)0)->entry))); 1;}); hnode = hnode->next)
    {
        if (!strcmp(si->name, name))
        {
            pthread_mutex_unlock(&sembase->lock);
            return (long)si;
        }
    }
    pthread_mutex_unlock(&sembase->lock);
    return 0;
}

canonical_original_code:
static long search_sem(char *name)
{
    struct _hlist_head *hhead = &sembase->sem_list;
    struct _hlist_node *hnode = ((void *)0);
    struct _sem_info *si = ((void *)0);
    pthread_mutex_lock(&sembase->lock);
    for (hnode = (hhead)->first; hnode && ({ si = ((struct _sem_info *) ((char *) (hnode) - ((long) &((struct _sem_info *)0)->entry))); 1;}); hnode = hnode->next)
    {
        if (!strcmp(si->name, name))
        {
            pthread_mutex_unlock(&sembase->lock);
            return (long)si;
        }
    }
    pthread_mutex_unlock(&sembase->lock);
    return 0;
}

variable_types: struct _hlist_head { struct _hlist_node { struct _hlist_node *next; struct _hlist_node **pprevious; } *first; } *

variable_types: struct _sem_info { struct _hlist_node { struct _hlist_node *next; struct _hlist_node **pprevious; } entry; union sem_t { char __size[32]; long __align; } id; char name[-1]; } *

return_type: long

user_defined_types: struct _sem_info { struct _hlist_node entry; union sem_t id; char name[-1]; }


decompiled_code:
__int64 __fastcall create_sem(const char *a1, unsigned int a2, unsigned int a3, __int64 *a4)
{
__int64 result; // rax
_QWORD *s; // [rsp+28h] [rbp-8h]

if ( search_sem(a1) )
{
printf("Semaphore %s already exists!\r\n", a1);
result = 0xFFFFFFFFLL;
}
else
{
s = malloc(0x48uLL);
if ( s )
{
memset(s, 0, 0x48uLL);
*a4 = (__int64)s;
hlist_node_init(s);
strncpy((char *)s + 48, a1, 0x10uLL);
pthread_mutex_lock(sembase);
hlist_head_add(&sembase[1].__align, s);
if ( sem_init((sem_t *)(s + 2), 0, a2) >= 0 )
{
pthread_mutex_unlock(sembase);
result = 0LL;
}
else
{
hlist_node_remove(s);
pthread_mutex_unlock(sembase);
result = 0xFFFFFFFFLL;
}
}
else
{
puts("No suffient memory to create a semaphore!\r");
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, unsigned int a2, unsigned int a3, __int64 *a4)
{
__int64 result; // rax
_QWORD *s; // [rsp+28h] [rbp-8h]

if ( func0(a1) )
{
printf("Semaphore %s already exists!\r\n", a1);
result = 0xFFFFFFFFLL;
}
else
{
s = malloc(0x48uLL);
if ( s )
{
memset(s, 0, 0x48uLL);
*a4 = (__int64)s;
hlist_node_init(s);
strncpy((char *)s + 48, a1, 0x10uLL);
pthread_mutex_lock(sembase);
hlist_head_add(&sembase[1].__align, s);
if ( sem_init((sem_t *)(s + 2), 0, a2) >= 0 )
{
pthread_mutex_unlock(sembase);
result = 0LL;
}
else
{
hlist_node_remove(s);
pthread_mutex_unlock(sembase);
result = 0xFFFFFFFFLL;
}
}
else
{
puts("No suffient memory to create a semaphore!\r");
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int create_sem(const char *name, unsigned int init_val, unsigned int flag, long *sid)
{
    sem_info *si;
    if (search_sem(name))
    {
        printf("Semaphore %s already exists!\r\n", name);
        return -1;
    }
    si = (sem_info *)malloc(sizeof(sem_info));
    if (si == ((void *)0))
    {
        printf("No suffient memory to create a semaphore!\r\n");
        return -1;
    }
    memset(si, 0, sizeof(sem_info));
    *sid = (long)si;
    hlist_node_init(&si->entry);
    strncpy(si->name, name, 16);
    pthread_mutex_lock(&sembase->lock);
    hlist_head_add(&sembase->sem_list, &si->entry);
    if (sem_init(&si->id, 0, init_val) < 0)
    {
        hlist_node_remove(&si->entry);
        pthread_mutex_unlock(&sembase->lock);
        return -1;
    }
    pthread_mutex_unlock(&sembase->lock);
    return 0;
}

canonical_original_code:
int create_sem(char *name, unsigned int init_val, unsigned int flag, long *sid)
{
    struct _sem_info *si;
    if (search_sem(name))
    {
        printf("Semaphore %s already exists!\r\n", name);
        return -1;
    }
    si = (struct _sem_info *)malloc(sizeof(sem_info));
    if (si == ((void *)0))
    {
        printf("No suffient memory to create a semaphore!\r\n");
        return -1;
    }
    memset(si, 0, sizeof(sem_info));
    *sid = (long)si;
    hlist_node_init(&si->entry);
    strncpy(si->name, name, 16);
    pthread_mutex_lock(&sembase->lock);
    hlist_head_add(&sembase->sem_list, &si->entry);
    if (sem_init(&si->id, 0, init_val) < 0)
    {
        hlist_node_remove(&si->entry);
        pthread_mutex_unlock(&sembase->lock);
        return -1;
    }
    pthread_mutex_unlock(&sembase->lock);
    return 0;
}

variable_types:
flag
unsigned int

variable_types:
sid
long *

user_defined_types: union sem_t { char __size[32]; long __align; }


decompiled_code:
int __fastcall del_sem(__int64 a1)
{
pthread_mutex_lock(sembase);
hlist_node_remove((_QWORD *)a1);
pthread_mutex_unlock(sembase);
return sem_destroy((sem_t *)(a1 + 16));
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
pthread_mutex_lock(sembase);
hlist_node_remove((_QWORD *)a1);
pthread_mutex_unlock(sembase);
return sem_destroy((sem_t *)(a1 + 16));
}

original_code:
void del_sem(long sid)
{
    sem_info *si = (sem_info *)sid;
    pthread_mutex_lock(&sembase->lock);
    hlist_node_remove(&si->entry);
    pthread_mutex_unlock(&sembase->lock);
    sem_destroy(&si->id);
    return;
}

canonical_original_code:
void del_sem(long sid)
{
    struct _sem_info *si = (sem_info *)sid;
    pthread_mutex_lock(&sembase->lock);
    hlist_node_remove(&si->entry);
    pthread_mutex_unlock(&sembase->lock);
    sem_destroy(&si->id);
    return;
}

variable_types: sid long


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

if ( sem_wait((sem_t *)(a1 + 16)) >= 0 )
result = 0LL;
else
result = 0xFFFFFFFFLL;
return result;
}

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

if ( sem_wait((sem_t *)(a1 + 16)) >= 0 )
result = 0LL;
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int sem_take(long sid)
{
    sem_info *si = (sem_info *)sid;
    if (sem_wait(&si->id) < 0)
        return -1;
    return 0;
}

canonical_original_code:
int sem_take(long sid)
{
    struct _sem_info *si = (sem_info *)sid;
    if (sem_wait(&si->id) < 0)
        return -1;
    return 0;
}


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

if ( sem_post((sem_t *)(a1 + 16)) >= 0 )
result = 0LL;
else
result = 0xFFFFFFFFLL;
return result;
}

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

if ( sem_post((sem_t *)(a1 + 16)) >= 0 )
result = 0LL;
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int sem_give(long sid)
{
    sem_info *si = (sem_info *)sid;
    if (sem_post(&si->id) < 0)
        return -1;
    return 0;
}

canonical_original_code:
int sem_give(long sid)
{
    struct _sem_info *si = (sem_info *)sid;
    if (sem_post(&si->id) < 0)
        return -1;
    return 0;
}


decompiled_code:
__int64 sem_base_init(void)
{
__int64 result; // rax

sembase = (pthread_mutex_t *)malloc(0x30uLL);
if ( sembase )
{
memset(sembase, 0, 0x30uLL);
pthread_mutex_init(sembase, 0LL);
sembase[1].__align = 0LL;
result = 0LL;
}
else
{
puts("Fail to memory allocation!\r");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func5(void)
{
__int64 result; // rax

sembase = (pthread_mutex_t *)malloc(0x30uLL);
if ( sembase )
{
memset(sembase, 0, 0x30uLL);
pthread_mutex_init(sembase, 0LL);
sembase[1].__align = 0LL;
result = 0LL;
}
else
{
puts("Fail to memory allocation!\r");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int sem_base_init(void)
{
    sembase = (sem_base *)malloc(sizeof(sem_base));
    if (sembase == ((void *)0))
    {
        printf("Fail to memory allocation!\r\n");
        return -1;
    }
    memset(sembase, 0, sizeof(sem_base));
    pthread_mutex_init(&sembase->lock, ((void *)0));
    ((&sembase->sem_list)->first = ((void *)0));
    return 0;
}

canonical_original_code:
int sem_base_init()
{
    sembase = (struct _sem_base *)malloc(sizeof(sem_base));
    if (sembase == ((void *)0))
    {
        printf("Fail to memory allocation!\r\n");
        return -1;
    }
    memset(sembase, 0, sizeof(sem_base));
    pthread_mutex_init(&sembase->lock, ((void *)0));
    ((&sembase->sem_list)->first = ((void *)0));
    return 0;
}

user_defined_types: struct _sem_base { union pthread_mutex_t lock; struct _hlist_head sem_list; }


repo: openrobots-dev/uROSnode

decompiled_code:
__int64 __fastcall pub_tpc__benchmark__output(_QWORD *a1)
{
__int64 v1; // rax
__m128i *v2; // r12
unsigned int v3; // er13
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // rdx
int v8[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v1 = urosAlloc(0LL, 16LL);
v2 = (__m128i *)v1;
if ( v1 )
{
init_msg__std_msgs__String(v1);
while ( !(unsigned __int8)urosTcpRosStatusCheckExit(a1) )
{
urosMutexLock(&benchmark);
v3 = *((_DWORD *)&benchmark + 10);
*v2 = _mm_loadu_si128((const __m128i *)&benchmark + 3);
urosMutexUnlock(&benchmark);
v4 = *(_QWORD *)(a1[1] + 32LL);
v8[0] = length_msg__std_msgs__String(v2);
while ( (unsigned int)urosTcpRosSend(a1, v8, 4LL) )
{
if ( *(_DWORD *)a1 != -100 || *(_QWORD *)(a1[1] + 32LL) != v4 || (unsigned __int8)urosTcpRosStatusCheckExit(a1) )
goto LABEL_13;
}
send_msg__std_msgs__String(a1, v2);
if ( *(_DWORD *)a1 )
goto LABEL_13;
urosMutexLock(&benchmark);
v5 = v2->m128i_i64[0];
v6 = *((_QWORD *)&benchmark + 30);
++*((_QWORD *)&benchmark + 29);
++*((_QWORD *)&benchmark + 31);
*((_QWORD *)&benchmark + 30) = v5 + v6 + 8;
*((_QWORD *)&benchmark + 32) += v5 + 8;
urosMutexUnlock(&benchmark);
if ( v3 )
urosThreadSleepUsec(0xF4240 / v3, v2, 0xF4240 % v3);
}
*(_DWORD *)a1 = 0;
}
else
{
*(_DWORD *)a1 = -101;
}
LABEL_13:
clean_msg__std_msgs__String(v2);
urosFree(v2);
return *(unsigned int *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
__int64 v1; // rax
__m128i *v2; // r12
unsigned int v3; // er13
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // rdx
int v8[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v1 = urosAlloc(0LL, 16LL);
v2 = (__m128i *)v1;
if ( v1 )
{
init_msg__std_msgs__String(v1);
while ( !(unsigned __int8)urosTcpRosStatusCheckExit(a1) )
{
urosMutexLock(&benchmark);
v3 = *((_DWORD *)&benchmark + 10);
*v2 = _mm_loadu_si128((const __m128i *)&benchmark + 3);
urosMutexUnlock(&benchmark);
v4 = *(_QWORD *)(a1[1] + 32LL);
v8[0] = length_msg__std_msgs__String(v2);
while ( (unsigned int)urosTcpRosSend(a1, v8, 4LL) )
{
if ( *(_DWORD *)a1 != -100 || *(_QWORD *)(a1[1] + 32LL) != v4 || (unsigned __int8)urosTcpRosStatusCheckExit(a1) )
goto LABEL_13;
}
send_msg__std_msgs__String(a1, v2);
if ( *(_DWORD *)a1 )
goto LABEL_13;
urosMutexLock(&benchmark);
v5 = v2->m128i_i64[0];
v6 = *((_QWORD *)&benchmark + 30);
++*((_QWORD *)&benchmark + 29);
++*((_QWORD *)&benchmark + 31);
*((_QWORD *)&benchmark + 30) = v5 + v6 + 8;
*((_QWORD *)&benchmark + 32) += v5 + 8;
urosMutexUnlock(&benchmark);
if ( v3 )
urosThreadSleepUsec(0xF4240 / v3, v2, 0xF4240 % v3);
}
*(_DWORD *)a1 = 0;
}
else
{
*(_DWORD *)a1 = -101;
}
LABEL_13:
clean_msg__std_msgs__String(v2);
urosFree(v2);
return *(unsigned int *)a1;
}

original_code:
uros_err_t pub_tpc__benchmark__output(UrosTcpRosStatus *tcpstp) {
  uint32_t rate;
  struct msg__std_msgs__String *msgp = ((void *)0); uint32_t msglen; (void)(0); (void)(0); (void)(0); (void)(0); { msgp = ((struct msg__std_msgs__String *)urosAlloc(((void *)0), sizeof(struct msg__std_msgs__String))); if (msgp == ((void *)0)) { (tcpstp)->err = UROS_ERR_NOMEM; goto _finally; } init_msg__std_msgs__String(msgp); };
  while (!urosTcpRosStatusCheckExit(tcpstp)) {
    urosMutexLock(&benchmark.lock);
    msgp->data = benchmark.payload;
    rate = benchmark.rate;
    urosMutexUnlock(&benchmark.lock);
    { size_t start = (tcpstp)->csp->sentlen; msglen = (uint32_t)length_msg__std_msgs__String(msgp); while (urosTcpRosSend((tcpstp), &(msglen), sizeof(msglen)) != UROS_OK) { if ((tcpstp)->err != UROS_ERR_TIMEOUT || (tcpstp)->csp->sentlen != start || urosTcpRosStatusCheckExit(tcpstp)) { goto _finally; } } };
    { send_msg__std_msgs__String(tcpstp, msgp); if ((tcpstp)->err != UROS_OK) { goto _finally; } };
    urosMutexLock(&benchmark.lock);
    ++benchmark.outCount.numMsgs;
    benchmark.outCount.numBytes += 2 * sizeof(uint32_t) + msgp->data.length;
    ++benchmark.outCount.deltaMsgs;
    benchmark.outCount.deltaBytes += 2 * sizeof(uint32_t) + msgp->data.length;
    urosMutexUnlock(&benchmark.lock);
    if (rate > 0) {
      urosThreadSleepUsec(1000000ul / rate);
    }
  }
  tcpstp->err = UROS_OK;
_finally:
  { clean_msg__std_msgs__String(msgp); urosFree(msgp); };;
  return tcpstp->err;
}

canonical_original_code:
int pub_tpc__benchmark__output(struct UrosTcpRosStatus *tcpstp) {
  unsigned int rate;
  struct msg__std_msgs__String *msgp = ((void *)0); unsigned int msglen; (void)(0); (void)(0); (void)(0); (void)(0); { msgp = ((struct msg__std_msgs__String *)urosAlloc(((void *)0), sizeof(struct msg__std_msgs__String))); if (msgp == ((void *)0)) { (tcpstp)->err = UROS_ERR_NOMEM; goto _finally; } init_msg__std_msgs__String(msgp); };
  while (!urosTcpRosStatusCheckExit(tcpstp)) {
    urosMutexLock(&benchmark.lock);
    msgp->data = benchmark.payload;
    rate = benchmark.rate;
    urosMutexUnlock(&benchmark.lock);
    { unsigned long start = (tcpstp)->csp->sentlen; msglen = (unsigned int)length_msg__std_msgs__String(msgp); while (urosTcpRosSend((tcpstp), &(msglen), sizeof(msglen)) != UROS_OK) { if ((tcpstp)->err != UROS_ERR_TIMEOUT || (tcpstp)->csp->sentlen != start || urosTcpRosStatusCheckExit(tcpstp)) { goto _finally; } } };
    { send_msg__std_msgs__String(tcpstp, msgp); if ((tcpstp)->err != UROS_OK) { goto _finally; } };
    urosMutexLock(&benchmark.lock);
    ++benchmark.outCount.numMsgs;
    benchmark.outCount.numBytes += 2 * sizeof(unsigned int) + msgp->data.length;
    ++benchmark.outCount.deltaMsgs;
    benchmark.outCount.deltaBytes += 2 * sizeof(unsigned int) + msgp->data.length;
    urosMutexUnlock(&benchmark.lock);
    if (rate > 0) {
      urosThreadSleepUsec(1000000ul / rate);
    }
  }
  tcpstp->err = UROS_OK;
_finally:
  { clean_msg__std_msgs__String(msgp); urosFree(msgp); };;
  return tcpstp->err;
}

variable_types: struct UrosTcpRosStatus { int err; struct UrosConn { struct UrosAddr { union UrosIp { unsigned int dword; struct { unsigned char field4; unsigned char field3; unsigned char field2; unsigned char field1; } fields; unsigned char bytes[4]; } ip; unsigned short port; } locaddr; struct UrosAddr remaddr; enum uros_connproto_t { UROS_PROTO_TCP=0, UROS_PROTO_UDP=1, UROS_PROTO__LENGTH=2 } protocol; unsigned long recvlen; unsigned long sentlen; int socket; unsigned int recvtimeout; unsigned int sendtimeout; void *recvbufp; unsigned long recvbuflen; } *csp; struct UrosString { unsigned long length; char *datap; } callerId; struct UrosTopic { struct UrosString name; struct UrosMsgType { struct UrosString name; struct UrosString desc; struct UrosString md5str; } *typep; int (*procf)(void *data); struct uros_topicflags_t { unsigned int service; unsigned int probe; unsigned int persistent; unsigned int latching; unsigned int noDelay; unsigned int deleted; } flags; unsigned int refcnt; } *topicp; struct uros_topicflags_t remoteFlags; unsigned char threadExit; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } threadExitMtx; struct UrosString errstr; } *

variable_types:
rate
unsigned int

variable_types: struct msg__std_msgs__String { struct UrosString { unsigned long length; char *datap; } data; } *

variable_types:
msglen
unsigned int

variable_types:
start
unsigned long

user_defined_types: struct msg__std_msgs__String { struct UrosString data; }

user_defined_types: struct UrosTcpRosStatus { int err; struct UrosConn *csp; struct UrosString callerId; struct UrosTopic *topicp; struct uros_topicflags_t remoteFlags; unsigned char threadExit; union pthread_mutex_t threadExitMtx; struct UrosString errstr; }

user_defined_types: struct UrosConn { struct UrosAddr locaddr; struct UrosAddr remaddr; enum uros_connproto_t protocol; unsigned long recvlen; unsigned long sentlen; int socket; unsigned int recvtimeout; unsigned int sendtimeout; void *recvbufp; unsigned long recvbuflen; }

user_defined_types: struct UrosTopic { struct UrosString name; struct UrosMsgType *typep; int (*procf)(void *data); struct uros_topicflags_t flags; unsigned int refcnt; }

user_defined_types: struct UrosAddr { union UrosIp ip; unsigned short port; }


decompiled_code:
__int64 __fastcall sub_tpc__benchmark__input(_QWORD *a1)
{
__int64 v1; // rax
__int64 *v2; // r12
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rdx
unsigned int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = urosAlloc(0LL, 16LL);
v2 = (__int64 *)v1;
if ( v1 )
{
init_msg__std_msgs__String(v1);
while ( !(unsigned __int8)urosTcpRosStatusCheckExit(a1) )
{
v3 = *(_QWORD *)(a1[1] + 24LL);
while ( (unsigned int)urosTcpRosRecv(a1, v7, 4LL) )
{
if ( *(_DWORD *)a1 != -100 || *(_QWORD *)(a1[1] + 24LL) != v3 || (unsigned __int8)urosTcpRosStatusCheckExit(a1) )
goto LABEL_12;
}
*v2 = v7[0] - 4LL;
if ( (unsigned int)urosTcpRosSkip(a1) )
goto LABEL_12;
urosMutexLock(benchmark);
v4 = *v2;
v5 = benchmark[26];
++benchmark[25];
++benchmark[27];
benchmark[26] = v4 + v5 + 8;
benchmark[28] += v4 + 8;
urosMutexUnlock(benchmark);
clean_msg__std_msgs__String(v2);
}
*(_DWORD *)a1 = 0;
}
else
{
*(_DWORD *)a1 = -101;
}
LABEL_12:
clean_msg__std_msgs__String(v2);
urosFree(v2);
return *(unsigned int *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
__int64 v1; // rax
__int64 *v2; // r12
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rdx
unsigned int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = urosAlloc(0LL, 16LL);
v2 = (__int64 *)v1;
if ( v1 )
{
init_msg__std_msgs__String(v1);
while ( !(unsigned __int8)urosTcpRosStatusCheckExit(a1) )
{
v3 = *(_QWORD *)(a1[1] + 24LL);
while ( (unsigned int)urosTcpRosRecv(a1, v7, 4LL) )
{
if ( *(_DWORD *)a1 != -100 || *(_QWORD *)(a1[1] + 24LL) != v3 || (unsigned __int8)urosTcpRosStatusCheckExit(a1) )
goto LABEL_12;
}
*v2 = v7[0] - 4LL;
if ( (unsigned int)urosTcpRosSkip(a1) )
goto LABEL_12;
urosMutexLock(benchmark);
v4 = *v2;
v5 = benchmark[26];
++benchmark[25];
++benchmark[27];
benchmark[26] = v4 + v5 + 8;
benchmark[28] += v4 + 8;
urosMutexUnlock(benchmark);
clean_msg__std_msgs__String(v2);
}
*(_DWORD *)a1 = 0;
}
else
{
*(_DWORD *)a1 = -101;
}
LABEL_12:
clean_msg__std_msgs__String(v2);
urosFree(v2);
return *(unsigned int *)a1;
}

original_code:
uros_err_t sub_tpc__benchmark__input(UrosTcpRosStatus *tcpstp) {
  struct msg__std_msgs__String *msgp = ((void *)0); uint32_t msglen; (void)(0); (void)(0); (void)(0); (void)(0); { msgp = ((struct msg__std_msgs__String *)urosAlloc(((void *)0), sizeof(struct msg__std_msgs__String))); if (msgp == ((void *)0)) { (tcpstp)->err = UROS_ERR_NOMEM; goto _finally; } init_msg__std_msgs__String(msgp); };
  while (!urosTcpRosStatusCheckExit(tcpstp)) {
    { size_t start = (tcpstp)->csp->recvlen; while (urosTcpRosRecv((tcpstp), &(msglen), sizeof(msglen)) != UROS_OK) { if ((tcpstp)->err != UROS_ERR_TIMEOUT || start != (tcpstp)->csp->recvlen || urosTcpRosStatusCheckExit(tcpstp)) { goto _finally; } } };
    msgp->data.length = msglen - sizeof(uint32_t);
    if (urosTcpRosSkip(tcpstp, msglen) != UROS_OK) { goto _finally; }
    urosMutexLock(&benchmark.lock);
    ++benchmark.inCount.numMsgs;
    benchmark.inCount.numBytes += 2 * sizeof(uint32_t) + msgp->data.length;
    ++benchmark.inCount.deltaMsgs;
    benchmark.inCount.deltaBytes += 2 * sizeof(uint32_t) + msgp->data.length;
    urosMutexUnlock(&benchmark.lock);
    clean_msg__std_msgs__String(msgp);
  }
  tcpstp->err = UROS_OK;
_finally:
  { clean_msg__std_msgs__String(msgp); urosFree(msgp); };;
  return tcpstp->err;
}

canonical_original_code:
int sub_tpc__benchmark__input(struct UrosTcpRosStatus *tcpstp) {
  struct msg__std_msgs__String *msgp = ((void *)0); unsigned int msglen; (void)(0); (void)(0); (void)(0); (void)(0); { msgp = ((struct msg__std_msgs__String *)urosAlloc(((void *)0), sizeof(struct msg__std_msgs__String))); if (msgp == ((void *)0)) { (tcpstp)->err = UROS_ERR_NOMEM; goto _finally; } init_msg__std_msgs__String(msgp); };
  while (!urosTcpRosStatusCheckExit(tcpstp)) {
    { unsigned long start = (tcpstp)->csp->recvlen; while (urosTcpRosRecv((tcpstp), &(msglen), sizeof(msglen)) != UROS_OK) { if ((tcpstp)->err != UROS_ERR_TIMEOUT || start != (tcpstp)->csp->recvlen || urosTcpRosStatusCheckExit(tcpstp)) { goto _finally; } } };
    msgp->data.length = msglen - sizeof(unsigned int);
    if (urosTcpRosSkip(tcpstp, msglen) != UROS_OK) { goto _finally; }
    urosMutexLock(&benchmark.lock);
    ++benchmark.inCount.numMsgs;
    benchmark.inCount.numBytes += 2 * sizeof(unsigned int) + msgp->data.length;
    ++benchmark.inCount.deltaMsgs;
    benchmark.inCount.deltaBytes += 2 * sizeof(unsigned int) + msgp->data.length;
    urosMutexUnlock(&benchmark.lock);
    clean_msg__std_msgs__String(msgp);
  }
  tcpstp->err = UROS_OK;
_finally:
  { clean_msg__std_msgs__String(msgp); urosFree(msgp); };;
  return tcpstp->err;
}

user_defined_types: struct UrosString { unsigned long length; char *datap; }

user_defined_types: enum uros_connproto_t { UROS_PROTO_TCP=0, UROS_PROTO_UDP=1, UROS_PROTO__LENGTH=2 }

user_defined_types: struct uros_topicflags_t { unsigned int service; unsigned int probe; unsigned int persistent; unsigned int latching; unsigned int noDelay; unsigned int deleted; }

user_defined_types: union UrosIp { unsigned int dword; struct { unsigned char field4; unsigned char field3; unsigned char field2; unsigned char field1; } fields; unsigned char bytes[4]; }

user_defined_types: struct UrosMsgType { struct UrosString name; struct UrosString desc; struct UrosString md5str; }


decompiled_code:
__int64 __fastcall sub_tpc__benchmark__output(_QWORD *a1)
{
__int64 v1; // rax
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // rbp
__int64 v6; // rax
unsigned int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = urosAlloc(0LL, 16LL);
v2 = v1;
if ( v1 )
{
init_msg__std_msgs__String(v1);
while ( 1 )
{
if ( (unsigned __int8)urosTcpRosStatusCheckExit(a1) )
{
*(_DWORD *)a1 = 0;
goto LABEL_13;
}
v3 = *(_QWORD *)(a1[1] + 24LL);
while ( (unsigned int)urosTcpRosRecv(a1, v7, 4LL) )
{
if ( *(_DWORD *)a1 != -100 || *(_QWORD *)(a1[1] + 24LL) != v3 || (unsigned __int8)urosTcpRosStatusCheckExit(a1) )
goto LABEL_13;
}
recv_msg__std_msgs__String(a1, v2);
if ( *(_DWORD *)a1 )
goto LABEL_13;
v4 = v7[0];
if ( v4 != length_msg__std_msgs__String(v2) )
break;
clean_msg__std_msgs__String(v2);
}
printf(
"Error at %s:%d\n function: %s\n reason: %s\n message: ",
"./src/urosHandlers.c",
190LL,
"sub_tpc__benchmark__output",
"(size_t)UROS_HND_LENVAR != length_msg__std_msgs__String(msgp)");
v6 = length_msg__std_msgs__String(v2);
printf("Wrong message length %u, expected %u\n", v7[0], v6);
*(_DWORD *)a1 = -104;
}
else
{
*(_DWORD *)a1 = -101;
}
LABEL_13:
clean_msg__std_msgs__String(v2);
urosFree(v2);
return *(unsigned int *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
__int64 v1; // rax
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // rbp
__int64 v6; // rax
unsigned int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = urosAlloc(0LL, 16LL);
v2 = v1;
if ( v1 )
{
init_msg__std_msgs__String(v1);
while ( 1 )
{
if ( (unsigned __int8)urosTcpRosStatusCheckExit(a1) )
{
*(_DWORD *)a1 = 0;
goto LABEL_13;
}
v3 = *(_QWORD *)(a1[1] + 24LL);
while ( (unsigned int)urosTcpRosRecv(a1, v7, 4LL) )
{
if ( *(_DWORD *)a1 != -100 || *(_QWORD *)(a1[1] + 24LL) != v3 || (unsigned __int8)urosTcpRosStatusCheckExit(a1) )
goto LABEL_13;
}
recv_msg__std_msgs__String(a1, v2);
if ( *(_DWORD *)a1 )
goto LABEL_13;
v4 = v7[0];
if ( v4 != length_msg__std_msgs__String(v2) )
break;
clean_msg__std_msgs__String(v2);
}
printf(
"Error at %s:%d\n function: %s\n reason: %s\n message: ",
"./src/urosHandlers.c",
190LL,
"sub_tpc__benchmark__output",
"(size_t)UROS_HND_LENVAR != length_msg__std_msgs__String(msgp)");
v6 = length_msg__std_msgs__String(v2);
printf("Wrong message length %u, expected %u\n", v7[0], v6);
*(_DWORD *)a1 = -104;
}
else
{
*(_DWORD *)a1 = -101;
}
LABEL_13:
clean_msg__std_msgs__String(v2);
urosFree(v2);
return *(unsigned int *)a1;
}

original_code:
uros_err_t sub_tpc__benchmark__output(UrosTcpRosStatus *tcpstp) {
  struct msg__std_msgs__String *msgp = ((void *)0); uint32_t msglen; (void)(0); (void)(0); (void)(0); (void)(0); { msgp = ((struct msg__std_msgs__String *)urosAlloc(((void *)0), sizeof(struct msg__std_msgs__String))); if (msgp == ((void *)0)) { (tcpstp)->err = UROS_ERR_NOMEM; goto _finally; } init_msg__std_msgs__String(msgp); };
  while (!urosTcpRosStatusCheckExit(tcpstp)) {
    { size_t start = (tcpstp)->csp->recvlen; while (urosTcpRosRecv((tcpstp), &(msglen), sizeof(msglen)) != UROS_OK) { if ((tcpstp)->err != UROS_ERR_TIMEOUT || start != (tcpstp)->csp->recvlen || urosTcpRosStatusCheckExit(tcpstp)) { goto _finally; } } };
    { recv_msg__std_msgs__String(tcpstp, msgp); if ((tcpstp)->err != UROS_OK) { goto _finally; } { if ((size_t)msglen != length_msg__std_msgs__String(msgp)) { printf("Error at %s:%d\n" "  function: %s\n" "  reason:   %s\n" "  message:  ", "./src/urosHandlers.c", 190, __PRETTY_FUNCTION__, "(size_t)UROS_HND_LENVAR != length_msg__std_msgs__String(msgp)"); printf ("Wrong message length %u, expected %u\n", (unsigned)msglen, (unsigned)length_msg__std_msgs__String(msgp)) ; { { (tcpstp)->err = UROS_ERR_BADPARAM; goto _finally; }; } } }; };
    clean_msg__std_msgs__String(msgp);
  }
  tcpstp->err = UROS_OK;
_finally:
  { clean_msg__std_msgs__String(msgp); urosFree(msgp); };;
  return tcpstp->err;
}

canonical_original_code:
int sub_tpc__benchmark__output(struct UrosTcpRosStatus *tcpstp) {
  struct msg__std_msgs__String *msgp = ((void *)0); unsigned int msglen; (void)(0); (void)(0); (void)(0); (void)(0); { msgp = ((struct msg__std_msgs__String *)urosAlloc(((void *)0), sizeof(struct msg__std_msgs__String))); if (msgp == ((void *)0)) { (tcpstp)->err = UROS_ERR_NOMEM; goto _finally; } init_msg__std_msgs__String(msgp); };
  while (!urosTcpRosStatusCheckExit(tcpstp)) {
    { unsigned long start = (tcpstp)->csp->recvlen; while (urosTcpRosRecv((tcpstp), &(msglen), sizeof(msglen)) != UROS_OK) { if ((tcpstp)->err != UROS_ERR_TIMEOUT || start != (tcpstp)->csp->recvlen || urosTcpRosStatusCheckExit(tcpstp)) { goto _finally; } } };
    { recv_msg__std_msgs__String(tcpstp, msgp); if ((tcpstp)->err != UROS_OK) { goto _finally; } { if ((unsigned long)msglen != length_msg__std_msgs__String(msgp)) { printf("Error at %s:%d\n" "  function: %s\n" "  reason:   %s\n" "  message:  ", "./src/urosHandlers.c", 190, __PRETTY_FUNCTION__, "(size_t)UROS_HND_LENVAR != length_msg__std_msgs__String(msgp)"); printf ("Wrong message length %u, expected %u\n", (unsigned int)msglen, (unsigned int)length_msg__std_msgs__String(msgp)) ; { { (tcpstp)->err = UROS_ERR_BADPARAM; goto _finally; }; } } }; };
    clean_msg__std_msgs__String(msgp);
  }
  tcpstp->err = UROS_OK;
_finally:
  { clean_msg__std_msgs__String(msgp); urosFree(msgp); };;
  return tcpstp->err;
}

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


urosHandlersPublishTopics

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

if ( LOBYTE(benchmark[8]) )
result = urosNodePublishTopicSZ(
"/benchmark/output",
"std_msgs/String",
pub_tpc__benchmark__output,
uros_nulltopicflags);
return result;
}

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

if ( LOBYTE(benchmark[8]) )
result = urosNodePublishTopicSZ(
"/benchmark/output",
"std_msgs/String",
pub_tpc__benchmark__output,
uros_nulltopicflags);
return result;
}

original_code:
void urosHandlersPublishTopics(void) {
  if (benchmark.hasOutPub) {
    urosNodePublishTopicSZ(
      "/benchmark/output",
      "std_msgs/String",
      (uros_proc_f)pub_tpc__benchmark__output,
      uros_nulltopicflags
    );
  }
}

canonical_original_code:
void urosHandlersPublishTopics() {
  if (benchmark.hasOutPub) {
    urosNodePublishTopicSZ(
      "/benchmark/output",
      "std_msgs/String",
      (int (*)(void *data))pub_tpc__benchmark__output,
      uros_nulltopicflags
    );
  }
}


urosHandlersUnpublishTopics

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

if ( LOBYTE(benchmark[8]) )
result = urosNodeUnpublishTopicSZ("/benchmark/output");
return result;
}

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

if ( LOBYTE(benchmark[8]) )
result = urosNodeUnpublishTopicSZ("/benchmark/output");
return result;
}

original_code:
void urosHandlersUnpublishTopics(void) {
  if (benchmark.hasOutPub) {
    urosNodeUnpublishTopicSZ(
      "/benchmark/output"
    );
  }
}

canonical_original_code:
void urosHandlersUnpublishTopics() {
  if (benchmark.hasOutPub) {
    urosNodeUnpublishTopicSZ(
      "/benchmark/output"
    );
  }
}


urosHandlersSubscribeTopics

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

if ( !BYTE1(benchmark[8]) )
{
if ( !BYTE2(benchmark[8]) )
return result;
return urosNodeSubscribeTopicSZ(
"/benchmark/output",
"std_msgs/String",
sub_tpc__benchmark__output,
uros_nulltopicflags);
}
result = urosNodeSubscribeTopicSZ(
"/benchmark/input",
"std_msgs/String",
sub_tpc__benchmark__input,
uros_nulltopicflags);
if ( BYTE2(benchmark[8]) )
return urosNodeSubscribeTopicSZ(
"/benchmark/output",
"std_msgs/String",
sub_tpc__benchmark__output,
uros_nulltopicflags);
return result;
}

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

if ( !BYTE1(benchmark[8]) )
{
if ( !BYTE2(benchmark[8]) )
return result;
return urosNodeSubscribeTopicSZ(
"/benchmark/output",
"std_msgs/String",
sub_tpc__benchmark__output,
uros_nulltopicflags);
}
result = urosNodeSubscribeTopicSZ(
"/benchmark/input",
"std_msgs/String",
sub_tpc__benchmark__input,
uros_nulltopicflags);
if ( BYTE2(benchmark[8]) )
return urosNodeSubscribeTopicSZ(
"/benchmark/output",
"std_msgs/String",
sub_tpc__benchmark__output,
uros_nulltopicflags);
return result;
}

original_code:
void urosHandlersSubscribeTopics(void) {
  if (benchmark.hasInSub) {
    urosNodeSubscribeTopicSZ(
      "/benchmark/input",
      "std_msgs/String",
      (uros_proc_f)sub_tpc__benchmark__input,
      uros_nulltopicflags
    );
  }
  if (benchmark.hasOutSub) {
    urosNodeSubscribeTopicSZ(
      "/benchmark/output",
      "std_msgs/String",
      (uros_proc_f)sub_tpc__benchmark__output,
      uros_nulltopicflags
    );
  }
}

canonical_original_code:
void urosHandlersSubscribeTopics() {
  if (benchmark.hasInSub) {
    urosNodeSubscribeTopicSZ(
      "/benchmark/input",
      "std_msgs/String",
      (int (*)(void *data))sub_tpc__benchmark__input,
      uros_nulltopicflags
    );
  }
  if (benchmark.hasOutSub) {
    urosNodeSubscribeTopicSZ(
      "/benchmark/output",
      "std_msgs/String",
      (int (*)(void *data))sub_tpc__benchmark__output,
      uros_nulltopicflags
    );
  }
}


urosHandlersUnsubscribeTopics

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

if ( !BYTE1(benchmark[8]) )
{
if ( !BYTE2(benchmark[8]) )
return result;
return urosNodeSubscribeTopicSZ(
"/benchmark/output",
"std_msgs/String",
sub_tpc__benchmark__output,
uros_nulltopicflags);
}
result = urosNodeUnsubscribeTopicSZ("/benchmark/input");
if ( BYTE2(benchmark[8]) )
return urosNodeSubscribeTopicSZ(
"/benchmark/output",
"std_msgs/String",
sub_tpc__benchmark__output,
uros_nulltopicflags);
return result;
}

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

if ( !BYTE1(benchmark[8]) )
{
if ( !BYTE2(benchmark[8]) )
return result;
return urosNodeSubscribeTopicSZ(
"/benchmark/output",
"std_msgs/String",
sub_tpc__benchmark__output,
uros_nulltopicflags);
}
result = urosNodeUnsubscribeTopicSZ("/benchmark/input");
if ( BYTE2(benchmark[8]) )
return urosNodeSubscribeTopicSZ(
"/benchmark/output",
"std_msgs/String",
sub_tpc__benchmark__output,
uros_nulltopicflags);
return result;
}

original_code:
void urosHandlersUnsubscribeTopics(void) {
  if (benchmark.hasInSub) {
    urosNodeUnsubscribeTopicSZ(
      "/benchmark/input"
    );
  }
  if (benchmark.hasOutSub) {
    urosNodeSubscribeTopicSZ(
      "/benchmark/output",
      "std_msgs/String",
      (uros_proc_f)sub_tpc__benchmark__output,
      uros_nulltopicflags
    );
  }
}

canonical_original_code:
void urosHandlersUnsubscribeTopics() {
  if (benchmark.hasInSub) {
    urosNodeUnsubscribeTopicSZ(
      "/benchmark/input"
    );
  }
  if (benchmark.hasOutSub) {
    urosNodeSubscribeTopicSZ(
      "/benchmark/output",
      "std_msgs/String",
      (int (*)(void *data))sub_tpc__benchmark__output,
      uros_nulltopicflags
    );
  }
}


urosHandlersPublishServices

decompiled_code:
void urosHandlersPublishServices()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void urosHandlersPublishServices(void) {
}

canonical_original_code:
void urosHandlersPublishServices() {
}


urosHandlersUnpublishServices

decompiled_code:
void urosHandlersUnpublishServices()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void urosHandlersUnpublishServices(void) {
}

canonical_original_code:
void urosHandlersUnpublishServices() {
}


urosHostnameToIp

decompiled_code:
// attributes: thunk
__int64 urosHostnameToIp()
{
return uros_lld_hostnametoip();
}

canonical_decompiled_code:
__int64 func0()
{
return uros_lld_hostnametoip();
}

original_code:
uros_err_t urosHostnameToIp(const UrosString *hostnamep, UrosIp *ipp) {
  return uros_lld_hostnametoip(hostnamep, ipp);
}

canonical_original_code:
int urosHostnameToIp(struct UrosString *hostnamep, union UrosIp *ipp) {
  return uros_lld_hostnametoip(hostnamep, ipp);
}

variable_types: struct UrosString { unsigned long length; char *datap; } *

variable_types: union UrosIp { unsigned int dword; struct { unsigned char field4; unsigned char field3; unsigned char field2; unsigned char field1; } fields; unsigned char bytes[4]; } *


urosConnIsValid

decompiled_code:
// attributes: thunk
__int64 urosConnIsValid()
{
return uros_lld_conn_isvalid();
}

canonical_decompiled_code:
__int64 func3()
{
return uros_lld_conn_isvalid();
}

original_code:
uros_bool_t urosConnIsValid(UrosConn *cp) {
  return uros_lld_conn_isvalid(cp);
}

canonical_original_code:
unsigned char urosConnIsValid(struct UrosConn *cp) {
  return uros_lld_conn_isvalid(cp);
}

variable_types: struct UrosConn { struct UrosAddr { union UrosIp { unsigned int dword; struct { unsigned char field4; unsigned char field3; unsigned char field2; unsigned char field1; } fields; unsigned char bytes[4]; } ip; unsigned short port; } locaddr; struct UrosAddr remaddr; enum uros_connproto_t { UROS_PROTO_TCP=0, UROS_PROTO_UDP=1, UROS_PROTO__LENGTH=2 } protocol; unsigned long recvlen; unsigned long sentlen; int socket; unsigned int recvtimeout; unsigned int sendtimeout; void *recvbufp; unsigned long recvbuflen; } *

return_type: unsigned char


urosConnCreate

decompiled_code:
// attributes: thunk
__int64 urosConnCreate()
{
return uros_lld_conn_create();
}

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

original_code:
uros_err_t urosConnCreate(UrosConn *cp, uros_connproto_t protocol) {
  return uros_lld_conn_create(cp, protocol);
}

canonical_original_code:
int urosConnCreate(struct UrosConn *cp, enum uros_connproto_t protocol) {
  return uros_lld_conn_create(cp, protocol);
}

variable_types: enum uros_connproto_t { UROS_PROTO_TCP=0, UROS_PROTO_UDP=1, UROS_PROTO__LENGTH=2 }


urosConnBind

decompiled_code:
// attributes: thunk
__int64 urosConnBind()
{
return uros_lld_conn_bind();
}

canonical_decompiled_code:
__int64 func5()
{
return uros_lld_conn_bind();
}

original_code:
uros_err_t urosConnBind(UrosConn *cp, const UrosAddr *locaddrp) {
  return uros_lld_conn_bind(cp, locaddrp);
}

canonical_original_code:
int urosConnBind(struct UrosConn *cp, struct UrosAddr *locaddrp) {
  return uros_lld_conn_bind(cp, locaddrp);
}

variable_types:
locaddrp
struct UrosAddr *


urosConnAccept

decompiled_code:
// attributes: thunk
__int64 urosConnAccept()
{
return uros_lld_conn_accept();
}

canonical_decompiled_code:
__int64 func6()
{
return uros_lld_conn_accept();
}

original_code:
uros_err_t urosConnAccept(UrosConn *cp, UrosConn *spawnedp) {
  return uros_lld_conn_accept(cp, spawnedp);
}

canonical_original_code:
int urosConnAccept(struct UrosConn *cp, struct UrosConn *spawnedp) {
  return uros_lld_conn_accept(cp, spawnedp);
}

variable_types:
spawnedp
struct UrosConn *


urosConnListen

decompiled_code:
// attributes: thunk
__int64 urosConnListen()
{
return uros_lld_conn_listen();
}

canonical_decompiled_code:
__int64 func7()
{
return uros_lld_conn_listen();
}

original_code:
uros_err_t urosConnListen(UrosConn *cp, uros_cnt_t backlog) {
  return uros_lld_conn_listen(cp, backlog);
}

canonical_original_code:
int urosConnListen(struct UrosConn *cp, unsigned int backlog) {
  return uros_lld_conn_listen(cp, backlog);
}

variable_types:
backlog
unsigned int


urosConnConnect

decompiled_code:
// attributes: thunk
__int64 urosConnConnect()
{
return uros_lld_conn_connect();
}

canonical_decompiled_code:
__int64 func8()
{
return uros_lld_conn_connect();
}

original_code:
uros_err_t urosConnConnect(UrosConn *cp, const UrosAddr *remaddrp) {
  return uros_lld_conn_connect(cp, remaddrp);
}

canonical_original_code:
int urosConnConnect(struct UrosConn *cp, struct UrosAddr *remaddrp) {
  return uros_lld_conn_connect(cp, remaddrp);
}

variable_types:
remaddrp
struct UrosAddr *


urosConnRecv

decompiled_code:
// attributes: thunk
__int64 urosConnRecv()
{
return uros_lld_conn_recv();
}

canonical_decompiled_code:
__int64 func9()
{
return uros_lld_conn_recv();
}

original_code:
uros_err_t urosConnRecv(UrosConn *cp,
                         void **bufpp, size_t *buflenp) {
  return uros_lld_conn_recv(cp, bufpp, buflenp);
}

canonical_original_code:
int urosConnRecv(struct UrosConn *cp, void **bufpp, unsigned long *buflenp) {
  return uros_lld_conn_recv(cp, bufpp, buflenp);
}

variable_types:
bufpp
void **

variable_types:
buflenp
unsigned long *


urosConnRecvFrom

decompiled_code:
// attributes: thunk
__int64 urosConnRecvFrom()
{
return uros_lld_conn_recvfrom();
}

canonical_decompiled_code:
__int64 func10()
{
return uros_lld_conn_recvfrom();
}

original_code:
uros_err_t urosConnRecvFrom(UrosConn *cp,
                             void **bufpp, size_t *buflenp,
                             const UrosAddr *remaddrp) {
  return uros_lld_conn_recvfrom(cp, bufpp, buflenp, remaddrp);
}

canonical_original_code:
int urosConnRecvFrom(struct UrosConn *cp, void **bufpp, unsigned long *buflenp, struct UrosAddr *remaddrp) {
  return uros_lld_conn_recvfrom(cp, bufpp, buflenp, remaddrp);
}


urosConnSend

decompiled_code:
// attributes: thunk
__int64 urosConnSend()
{
return uros_lld_conn_send();
}

canonical_decompiled_code:
__int64 func11()
{
return uros_lld_conn_send();
}

original_code:
uros_err_t urosConnSend(UrosConn *cp,
                         const void *bufp, size_t buflen) {
  return uros_lld_conn_send(cp, bufp, buflen);
}

canonical_original_code:
int urosConnSend(struct UrosConn *cp, void *bufp, unsigned long buflen) {
  return uros_lld_conn_send(cp, bufp, buflen);
}

variable_types:
bufp
void *

variable_types:
buflen
unsigned long


urosConnSendConst

decompiled_code:
// attributes: thunk
__int64 urosConnSendConst()
{
return uros_lld_conn_sendconst();
}

canonical_decompiled_code:
__int64 func12()
{
return uros_lld_conn_sendconst();
}

original_code:
uros_err_t urosConnSendConst(UrosConn *cp,
                              const void *bufp, size_t buflen) {
  return uros_lld_conn_sendconst(cp, bufp, buflen);
}

canonical_original_code:
int urosConnSendConst(struct UrosConn *cp, void *bufp, unsigned long buflen) {
  return uros_lld_conn_sendconst(cp, bufp, buflen);
}


urosConnSendTo

decompiled_code:
// attributes: thunk
__int64 urosConnSendTo()
{
return uros_lld_conn_sendto();
}

canonical_decompiled_code:
__int64 func13()
{
return uros_lld_conn_sendto();
}

original_code:
uros_err_t urosConnSendTo(UrosConn *cp,
                           const void *bufp, size_t buflen,
                           const UrosAddr *remaddrp) {
  return uros_lld_conn_sendto(cp, bufp, buflen, remaddrp);
}

canonical_original_code:
int urosConnSendTo(struct UrosConn *cp, void *bufp, unsigned long buflen, struct UrosAddr *remaddrp) {
  return uros_lld_conn_sendto(cp, bufp, buflen, remaddrp);
}


urosConnSendToConst

decompiled_code:
// attributes: thunk
__int64 urosConnSendToConst()
{
return uros_lld_conn_sendtoconst();
}

canonical_decompiled_code:
__int64 func14()
{
return uros_lld_conn_sendtoconst();
}

original_code:
uros_err_t urosConnSendToConst(UrosConn *cp,
                                const void *bufp, size_t buflen,
                                const UrosAddr *remaddrp) {
  return uros_lld_conn_sendtoconst(cp, bufp, buflen, remaddrp);
}

canonical_original_code:
int urosConnSendToConst(struct UrosConn *cp, void *bufp, unsigned long buflen, struct UrosAddr *remaddrp) {
  return uros_lld_conn_sendtoconst(cp, bufp, buflen, remaddrp);
}


urosConnShutdown

decompiled_code:
__int64 __fastcall urosConnShutdown(__int64 a1, unsigned __int8 a2, unsigned __int8 a3)
{
return uros_lld_conn_shutdown(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, unsigned __int8 a2, unsigned __int8 a3)
{
return uros_lld_conn_shutdown(a1, a2, a3);
}

original_code:
uros_err_t urosConnShutdown(UrosConn *cp,
                            uros_bool_t rx, uros_bool_t tx) {
  return uros_lld_conn_shutdown(cp, rx, tx);
}

canonical_original_code:
int urosConnShutdown(struct UrosConn *cp, unsigned char rx, unsigned char tx) {
  return uros_lld_conn_shutdown(cp, rx, tx);
}

variable_types:
rx
unsigned char

variable_types:
tx
unsigned char


urosConnClose

decompiled_code:
// attributes: thunk
__int64 urosConnClose()
{
return uros_lld_conn_close();
}

canonical_decompiled_code:
__int64 func16()
{
return uros_lld_conn_close();
}

original_code:
uros_err_t urosConnClose(UrosConn *cp) {
  return uros_lld_conn_close(cp);
}

canonical_original_code:
int urosConnClose(struct UrosConn *cp) {
  return uros_lld_conn_close(cp);
}


urosConnGetTcpNoDelay

decompiled_code:
// attributes: thunk
__int64 urosConnGetTcpNoDelay()
{
return uros_lld_conn_gettcpnodelay();
}

canonical_decompiled_code:
__int64 func17()
{
return uros_lld_conn_gettcpnodelay();
}

original_code:
uros_err_t urosConnGetTcpNoDelay(UrosConn *cp, uros_bool_t *enablep) {
  return uros_lld_conn_gettcpnodelay(cp, enablep);
}

canonical_original_code:
int urosConnGetTcpNoDelay(struct UrosConn *cp, unsigned char *enablep) {
  return uros_lld_conn_gettcpnodelay(cp, enablep);
}

variable_types:
enablep
unsigned char *


urosConnSetTcpNoDelay

decompiled_code:
__int64 __fastcall urosConnSetTcpNoDelay(__int64 a1, unsigned __int8 a2)
{
return uros_lld_conn_settcpnodelay(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, unsigned __int8 a2)
{
return uros_lld_conn_settcpnodelay(a1, a2);
}

original_code:
uros_err_t urosConnSetTcpNoDelay(UrosConn *cp, uros_bool_t enable) {
  return uros_lld_conn_settcpnodelay(cp, enable);
}

canonical_original_code:
int urosConnSetTcpNoDelay(struct UrosConn *cp, unsigned char enable) {
  return uros_lld_conn_settcpnodelay(cp, enable);
}

variable_types:
enable
unsigned char


urosConnGetRecvTimeout

decompiled_code:
// attributes: thunk
__int64 urosConnGetRecvTimeout()
{
return uros_lld_conn_getrecvtimeout();
}

canonical_decompiled_code:
__int64 func19()
{
return uros_lld_conn_getrecvtimeout();
}

original_code:
uros_err_t urosConnGetRecvTimeout(UrosConn *cp, uint32_t *msp) {
  return uros_lld_conn_getrecvtimeout(cp, msp);
}

canonical_original_code:
int urosConnGetRecvTimeout(struct UrosConn *cp, unsigned int *msp) {
  return uros_lld_conn_getrecvtimeout(cp, msp);
}

variable_types:
msp
unsigned int *


urosConnSetRecvTimeout

decompiled_code:
// attributes: thunk
__int64 urosConnSetRecvTimeout()
{
return uros_lld_conn_setrecvtimeout();
}

canonical_decompiled_code:
__int64 func20()
{
return uros_lld_conn_setrecvtimeout();
}

original_code:
uros_err_t urosConnSetRecvTimeout(UrosConn *cp, uint32_t ms) {
  return uros_lld_conn_setrecvtimeout(cp, ms);
}

canonical_original_code:
int urosConnSetRecvTimeout(struct UrosConn *cp, unsigned int ms) {
  return uros_lld_conn_setrecvtimeout(cp, ms);
}

variable_types:
ms
unsigned int


urosConnGetSendTimeout

decompiled_code:
// attributes: thunk
__int64 urosConnGetSendTimeout()
{
return uros_lld_conn_getsendtimeout();
}

canonical_decompiled_code:
__int64 func21()
{
return uros_lld_conn_getsendtimeout();
}

original_code:
uros_err_t urosConnGetSendTimeout(UrosConn *cp, uint32_t *msp) {
  return uros_lld_conn_getsendtimeout(cp, msp);
}

canonical_original_code:
int urosConnGetSendTimeout(struct UrosConn *cp, unsigned int *msp) {
  return uros_lld_conn_getsendtimeout(cp, msp);
}


urosConnSetSendTimeout

decompiled_code:
// attributes: thunk
__int64 urosConnSetSendTimeout()
{
return uros_lld_conn_setsendtimeout();
}

canonical_decompiled_code:
__int64 func22()
{
return uros_lld_conn_setsendtimeout();
}

original_code:
uros_err_t urosConnSetSendTimeout(UrosConn *cp, uint32_t ms) {
  return uros_lld_conn_setsendtimeout(cp, ms);
}

canonical_original_code:
int urosConnSetSendTimeout(struct UrosConn *cp, unsigned int ms) {
  return uros_lld_conn_setsendtimeout(cp, ms);
}


urosConnLastErrorText

decompiled_code:
// attributes: thunk
__int64 urosConnLastErrorText()
{
return uros_lld_conn_lasterrortext();
}

canonical_decompiled_code:
__int64 func23()
{
return uros_lld_conn_lasterrortext();
}

original_code:
const char *urosConnLastErrorText(const UrosConn *cp) {
  return uros_lld_conn_lasterrortext(cp);
}

canonical_original_code:
char *urosConnLastErrorText(struct UrosConn *cp) {
  return uros_lld_conn_lasterrortext(cp);
}

return_type: char *


decompiled_code:
int app_print_cpu_usage()
{
struct timespec v1; // [rsp+0h] [rbp-18h] BYREF

clock_gettime(2, &v1);
return printf("USER: %lu.%9.9lu\n", v1.tv_sec, v1.tv_nsec);
}

canonical_decompiled_code:
int func1()
{
struct timespec v1; // [rsp+0h] [rbp-18h] BYREF

clock_gettime(2, &v1);
return printf("USER: %lu.%9.9lu\n", v1.tv_sec, v1.tv_nsec);
}

original_code:
void app_print_cpu_usage(void) {
  struct timespec time;
  int err; (void)err;
  err = clock_gettime(2, &time);
  (void)(0);
  printf("USER: %lu.%9.9lu\n",
         (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec);
}

canonical_original_code:
void app_print_cpu_usage() {
  struct timespec time;
  int err; (void)err;
  err = clock_gettime(2, &time);
  (void)(0);
  printf("USER: %lu.%9.9lu\n",
         (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec);
}

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types: err int


decompiled_code:
int __fastcall app_print_thread_state(pthread_t target_thread)
{
__clockid_t clock_id; // [rsp+Ch] [rbp-3Ch] BYREF
struct timespec tp; // [rsp+10h] [rbp-38h] BYREF
char buf[16]; // [rsp+20h] [rbp-28h] BYREF
__int128 v5; // [rsp+30h] [rbp-18h]

pthread_getcpuclockid(target_thread, &clock_id);
clock_gettime(clock_id, &tp);
*(_OWORD *)buf = 0LL;
v5 = 0LL;
pthread_getname_np(target_thread, buf, 0x1FuLL);
HIBYTE(v5) = 0;
return printf("%lu %lu.%9.9lu %s\n", target_thread, tp.tv_sec, tp.tv_nsec, buf);
}

canonical_decompiled_code:
int __fastcall func2(pthread_t target_thread)
{
__clockid_t clock_id; // [rsp+Ch] [rbp-3Ch] BYREF
struct timespec tp; // [rsp+10h] [rbp-38h] BYREF
char buf[16]; // [rsp+20h] [rbp-28h] BYREF
__int128 v5; // [rsp+30h] [rbp-18h]

pthread_getcpuclockid(target_thread, &clock_id);
clock_gettime(clock_id, &tp);
*(_OWORD *)buf = 0LL;
v5 = 0LL;
pthread_getname_np(target_thread, buf, 0x1FuLL);
HIBYTE(v5) = 0;
return printf("%lu %lu.%9.9lu %s\n", target_thread, tp.tv_sec, tp.tv_nsec, buf);
}

original_code:
void app_print_thread_state(pthread_t threadId) {
  char namebuf[32];
  clockid_t clockId;
  struct timespec time;
  int err; (void)err;
  err = pthread_getcpuclockid(threadId, &clockId);
  (void)(0);
  err = clock_gettime(clockId, &time);
  (void)(0);
  memset(namebuf, 0, sizeof(namebuf));
  err = pthread_getname_np(threadId, namebuf, 31);
  (void)(0);
  namebuf[31] = 0;
  printf("%lu %lu.%9.9lu %s\n",
         (unsigned long)threadId,
         (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec,
         namebuf);
}

canonical_original_code:
void app_print_thread_state(unsigned long threadId) {
  char namebuf[32];
  int clockId;
  struct timespec time;
  int err; (void)err;
  err = pthread_getcpuclockid(threadId, &clockId);
  (void)(0);
  err = clock_gettime(clockId, &time);
  (void)(0);
  memset(namebuf, 0, sizeof(namebuf));
  err = pthread_getname_np(threadId, namebuf, 31);
  (void)(0);
  namebuf[31] = 0;
  printf("%lu %lu.%9.9lu %s\n",
         (unsigned long)threadId,
         (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec,
         namebuf);
}

variable_types:
threadId
unsigned long

variable_types:
namebuf
char [32]

variable_types: clockId int

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


decompiled_code:
__int64 app_printer_thread()
{
__int64 v0; // rdi
__int64 v2; // r14
unsigned __int64 v3; // r13
__int64 v4; // rdi
__int64 v5; // r9
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // rbp
__int64 v9; // r12
unsigned int v10; // eax
unsigned __int64 v11; // rdx
unsigned int v12; // er15
__int64 v13; // rax
unsigned __int64 v14; // rbx
unsigned __int64 v15; // r8
unsigned __int64 v16; // rcx
unsigned __int64 v17; // rax
unsigned __int64 v18; // rdx
unsigned int v19; // ebx
__int64 v20; // rdx
unsigned int v21; // ebx
__int64 v22; // rdx
unsigned int v23; // ebx
__int64 v24; // rdx
int v25; // eax
__int64 v26; // [rsp+8h] [rbp-A0h]
__int64 v27; // [rsp+10h] [rbp-98h]
__int64 v28; // [rsp+20h] [rbp-88h]
__int64 v29; // [rsp+28h] [rbp-80h]
__int64 v30; // [rsp+30h] [rbp-78h]
pthread_t target_thread; // [rsp+38h] [rbp-70h]
__int64 v32[2]; // [rsp+40h] [rbp-68h] BYREF
char v33[88]; // [rsp+50h] [rbp-58h] BYREF

while ( 1 )
{
urosMutexLock((unsigned int)((_DWORD)&urosNode + 192));
if ( *((_BYTE *)&urosNode + 1520) )
break;
v0 = (unsigned int)((_DWORD)&urosNode + 192);
if ( *((_DWORD *)&urosNode + 22) == 3 )
{
urosMutexUnlock(v0);
v2 = (unsigned int)urosGetTimestampMsec() - 1;
urosMutexLock((unsigned int)((_DWORD)&urosNode + 192));
if ( !*((_BYTE *)&urosNode + 1520) )
{
v3 = 0LL;
target_thread = pthread_self();
do
{
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 192));
urosMutexLock(benchmark);
v4 = benchmark[31];
v5 = benchmark[32];
benchmark[31] = 0LL;
v6 = benchmark[26];
v7 = benchmark[29];
benchmark[32] = 0LL;
v29 = v5;
v8 = benchmark[27];
v30 = v6;
v9 = benchmark[28];
v27 = v7;
v28 = benchmark[25];
v26 = benchmark[30];
benchmark[27] = 0LL;
benchmark[28] = 0LL;
urosMutexUnlock(benchmark);
v10 = urosGetTimestampMsec();
v11 = v3++;
v12 = v10;
v13 = v2;
v2 = v12;
v14 = v12 - v13;
printf("@ %lu %lu\n", v14, v11);
printf(
"IN: %lu msg %lu B %lu msg/s %lu B/s\n",
(1000 * v28 + 499) / v14,
(1000 * v30 + 499) / v14,
(1000 * v8 + 499) / v14,
(1000 * v9 + 499) / v14);
v15 = (1000 * v29 + 499) / v14;
v16 = (1000 * v4 + 499) / v14;
v17 = (1000 * v27 + 499) / v14;
v18 = (1000 * v26 + 499) / v14;
v19 = 0;
printf("OUT: %lu msg %lu B %lu msg/s %lu B/s\n", v17, v18, v16, v15);
app_print_cpu_state();
app_print_cpu_usage();
app_print_thread_state(target_thread);
urosMutexLock((unsigned int)((_DWORD)&urosNode + 192));
app_print_thread_state(*((_QWORD *)&urosNode + 189));
app_print_thread_state(*((_QWORD *)&urosNode + 187));
app_print_thread_state(*((_QWORD *)&urosNode + 188));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 1304));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 1400));
if ( *((_DWORD *)&urosNode + 312) )
{
do
{
v20 = v19++;
app_print_thread_state(*(_QWORD *)(*((_QWORD *)&urosNode + 160) + 8 * v20));
}
while ( *((_DWORD *)&urosNode + 312) > v19 );
}
v21 = 0;
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 1400));
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 1304));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 1048));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 1144));
if ( *((_DWORD *)&urosNode + 248) )
{
do
{
v22 = v21++;
app_print_thread_state(*(_QWORD *)(*((_QWORD *)&urosNode + 128) + 8 * v22));
}
while ( *((_DWORD *)&urosNode + 248) > v21 );
}
v23 = 0;
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 1144));
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 1048));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 792));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 888));
if ( *((_DWORD *)&urosNode + 184) )
{
do
{
v24 = v23++;
app_print_thread_state(*(_QWORD *)(*((_QWORD *)&urosNode + 96) + 8 * v24));
}
while ( *((_DWORD *)&urosNode + 184) > v23 );
}
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 888));
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 792));
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 192));
putchar(10);
if ( v3 > 0x78 )
{
v32[0] = 3LL;
v32[1] = (__int64)"end";
urosRpcResponseObjectInit(v33);
urosRpcCallShutdown((unsigned int)((_DWORD)&urosNode + 16), &urosNode, v32, v33);
urosRpcResponseClean(v33);
}
v25 = urosGetTimestampMsec();
urosThreadSleepMsec(v25 - v12 + 1000);
}
while ( !*((_BYTE *)&urosNode + 1520) );
}
break;
}
urosMutexUnlock(v0);
urosThreadSleepMsec(20LL);
}
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 192));
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rdi
__int64 v2; // r14
unsigned __int64 v3; // r13
__int64 v4; // rdi
__int64 v5; // r9
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // rbp
__int64 v9; // r12
unsigned int v10; // eax
unsigned __int64 v11; // rdx
unsigned int v12; // er15
__int64 v13; // rax
unsigned __int64 v14; // rbx
unsigned __int64 v15; // r8
unsigned __int64 v16; // rcx
unsigned __int64 v17; // rax
unsigned __int64 v18; // rdx
unsigned int v19; // ebx
__int64 v20; // rdx
unsigned int v21; // ebx
__int64 v22; // rdx
unsigned int v23; // ebx
__int64 v24; // rdx
int v25; // eax
__int64 v26; // [rsp+8h] [rbp-A0h]
__int64 v27; // [rsp+10h] [rbp-98h]
__int64 v28; // [rsp+20h] [rbp-88h]
__int64 v29; // [rsp+28h] [rbp-80h]
__int64 v30; // [rsp+30h] [rbp-78h]
pthread_t target_thread; // [rsp+38h] [rbp-70h]
__int64 v32[2]; // [rsp+40h] [rbp-68h] BYREF
char v33[88]; // [rsp+50h] [rbp-58h] BYREF

while ( 1 )
{
urosMutexLock((unsigned int)((_DWORD)&urosNode + 192));
if ( *((_BYTE *)&urosNode + 1520) )
break;
v0 = (unsigned int)((_DWORD)&urosNode + 192);
if ( *((_DWORD *)&urosNode + 22) == 3 )
{
urosMutexUnlock(v0);
v2 = (unsigned int)urosGetTimestampMsec() - 1;
urosMutexLock((unsigned int)((_DWORD)&urosNode + 192));
if ( !*((_BYTE *)&urosNode + 1520) )
{
v3 = 0LL;
target_thread = pthread_self();
do
{
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 192));
urosMutexLock(benchmark);
v4 = benchmark[31];
v5 = benchmark[32];
benchmark[31] = 0LL;
v6 = benchmark[26];
v7 = benchmark[29];
benchmark[32] = 0LL;
v29 = v5;
v8 = benchmark[27];
v30 = v6;
v9 = benchmark[28];
v27 = v7;
v28 = benchmark[25];
v26 = benchmark[30];
benchmark[27] = 0LL;
benchmark[28] = 0LL;
urosMutexUnlock(benchmark);
v10 = urosGetTimestampMsec();
v11 = v3++;
v12 = v10;
v13 = v2;
v2 = v12;
v14 = v12 - v13;
printf("@ %lu %lu\n", v14, v11);
printf(
"IN: %lu msg %lu B %lu msg/s %lu B/s\n",
(1000 * v28 + 499) / v14,
(1000 * v30 + 499) / v14,
(1000 * v8 + 499) / v14,
(1000 * v9 + 499) / v14);
v15 = (1000 * v29 + 499) / v14;
v16 = (1000 * v4 + 499) / v14;
v17 = (1000 * v27 + 499) / v14;
v18 = (1000 * v26 + 499) / v14;
v19 = 0;
printf("OUT: %lu msg %lu B %lu msg/s %lu B/s\n", v17, v18, v16, v15);
func0();
func1();
func2(target_thread);
urosMutexLock((unsigned int)((_DWORD)&urosNode + 192));
func2(*((_QWORD *)&urosNode + 189));
func2(*((_QWORD *)&urosNode + 187));
func2(*((_QWORD *)&urosNode + 188));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 1304));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 1400));
if ( *((_DWORD *)&urosNode + 312) )
{
do
{
v20 = v19++;
func2(*(_QWORD *)(*((_QWORD *)&urosNode + 160) + 8 * v20));
}
while ( *((_DWORD *)&urosNode + 312) > v19 );
}
v21 = 0;
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 1400));
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 1304));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 1048));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 1144));
if ( *((_DWORD *)&urosNode + 248) )
{
do
{
v22 = v21++;
func2(*(_QWORD *)(*((_QWORD *)&urosNode + 128) + 8 * v22));
}
while ( *((_DWORD *)&urosNode + 248) > v21 );
}
v23 = 0;
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 1144));
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 1048));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 792));
urosMutexLock((unsigned int)((_DWORD)&urosNode + 888));
if ( *((_DWORD *)&urosNode + 184) )
{
do
{
v24 = v23++;
func2(*(_QWORD *)(*((_QWORD *)&urosNode + 96) + 8 * v24));
}
while ( *((_DWORD *)&urosNode + 184) > v23 );
}
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 888));
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 792));
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 192));
putchar(10);
if ( v3 > 0x78 )
{
v32[0] = 3LL;
v32[1] = (__int64)"end";
urosRpcResponseObjectInit(v33);
urosRpcCallShutdown((unsigned int)((_DWORD)&urosNode + 16), &urosNode, v32, v33);
urosRpcResponseClean(v33);
}
v25 = urosGetTimestampMsec();
urosThreadSleepMsec(v25 - v12 + 1000);
}
while ( !*((_BYTE *)&urosNode + 1520) );
}
break;
}
urosMutexUnlock(v0);
urosThreadSleepMsec(20LL);
}
urosMutexUnlock((unsigned int)((_DWORD)&urosNode + 192));
return 0LL;
}

original_code:
uros_err_t app_printer_thread(void* argp) {
  static UrosNodeStatus *const stp = &urosNode.status;
  unsigned long oldTime, curTime, winTime, logentry = 0;
  streamcnt_t inCount, outCount;
  uros_cnt_t i;
  int err; (void)err;
  (void)argp;
  do {
    urosMutexLock(&stp->stateLock);
    if (stp->exitFlag) {
      urosMutexUnlock(&stp->stateLock);
      return UROS_OK;
    }
    if (stp->state == UROS_NODE_RUNNING) {
      urosMutexUnlock(&stp->stateLock);
      break;
    }
    urosMutexUnlock(&stp->stateLock);
    urosThreadSleepMsec(20);
  } while ((!(0)));
  oldTime = urosGetTimestampMsec() - 1;
  urosMutexLock(&stp->stateLock);
  while (!stp->exitFlag) {
    urosMutexUnlock(&stp->stateLock);
    urosMutexLock(&benchmark.lock);
    inCount = benchmark.inCount;
    outCount = benchmark.outCount;
    benchmark.inCount.deltaMsgs = 0;
    benchmark.inCount.deltaBytes = 0;
    benchmark.outCount.deltaMsgs = 0;
    benchmark.outCount.deltaBytes = 0;
    urosMutexUnlock(&benchmark.lock);
    curTime = urosGetTimestampMsec();
    winTime = curTime - oldTime;
    printf("@ %lu %lu\n", (curTime - oldTime), logentry++);
    printf(
      "IN: %lu msg %lu B %lu msg/s %lu B/s\n",
      (unsigned long)((1000 * (uint64_t)inCount.numMsgs + 499) / winTime),
      (unsigned long)((1000 * (uint64_t)inCount.numBytes + 499) / winTime),
      (unsigned long)((1000 * (uint64_t)inCount.deltaMsgs + 499) / winTime),
      (unsigned long)((1000 * (uint64_t)inCount.deltaBytes + 499) / winTime)
    );
    printf(
      "OUT: %lu msg %lu B %lu msg/s %lu B/s\n",
      (unsigned long)((1000 * (uint64_t)outCount.numMsgs + 499) / winTime),
      (unsigned long)((1000 * (uint64_t)outCount.numBytes + 499) / winTime),
      (unsigned long)((1000 * (uint64_t)outCount.deltaMsgs + 499) / winTime),
      (unsigned long)((1000 * (uint64_t)outCount.deltaBytes + 499) / winTime)
    );
    app_print_cpu_state();
    app_print_cpu_usage();
    app_print_thread_state(pthread_self());
    urosMutexLock(&stp->stateLock);
    app_print_thread_state(stp->nodeThreadId);
    app_print_thread_state(stp->xmlrpcListenerId);
    app_print_thread_state(stp->tcprosListenerId);
    urosMutexLock(&stp->slaveThdPool.readyMtx);
    urosMutexLock(&stp->slaveThdPool.busyMtx);
    for (i = 0; i < stp->slaveThdPool.size; ++i) {
      app_print_thread_state(stp->slaveThdPool.threadsp[i]);
    }
    urosMutexUnlock(&stp->slaveThdPool.busyMtx);
    urosMutexUnlock(&stp->slaveThdPool.readyMtx);
    urosMutexLock(&stp->tcpsvrThdPool.readyMtx);
    urosMutexLock(&stp->tcpsvrThdPool.busyMtx);
    for (i = 0; i < stp->tcpsvrThdPool.size; ++i) {
      app_print_thread_state(stp->tcpsvrThdPool.threadsp[i]);
    }
    urosMutexUnlock(&stp->tcpsvrThdPool.busyMtx);
    urosMutexUnlock(&stp->tcpsvrThdPool.readyMtx);
    urosMutexLock(&stp->tcpcliThdPool.readyMtx);
    urosMutexLock(&stp->tcpcliThdPool.busyMtx);
    for (i = 0; i < stp->tcpcliThdPool.size; ++i) {
      app_print_thread_state(stp->tcpcliThdPool.threadsp[i]);
    }
    urosMutexUnlock(&stp->tcpcliThdPool.busyMtx);
    urosMutexUnlock(&stp->tcpcliThdPool.readyMtx);
    urosMutexUnlock(&stp->stateLock);
    printf("\n");
    if (logentry > 120) {
      UrosRpcResponse res;
      const UrosString msgstr = { 3, "end" };
      urosRpcResponseObjectInit(&res);
      urosRpcCallShutdown(
        &urosNode.config.xmlrpcAddr,
        &urosNode.config.nodeName,
        &msgstr,
        &res
      );
      urosRpcResponseClean(&res);
    }
    urosThreadSleepMsec(urosGetTimestampMsec() - curTime + 1000);
    oldTime = curTime;
  }
  urosMutexUnlock(&stp->stateLock);
  return UROS_OK;
}

canonical_original_code:
int app_printer_thread(void *argp) {
  static struct UrosNodeStatus *stp = &urosNode.status;
  unsigned long oldTime; unsigned long curTime; unsigned long winTime; unsigned long logentry = 0;
  struct streamcnt_t inCount; struct streamcnt_t outCount;
  unsigned int i;
  int err; (void)err;
  (void)argp;
  do {
    urosMutexLock(&stp->stateLock);
    if (stp->exitFlag) {
      urosMutexUnlock(&stp->stateLock);
      return UROS_OK;
    }
    if (stp->state == UROS_NODE_RUNNING) {
      urosMutexUnlock(&stp->stateLock);
      break;
    }
    urosMutexUnlock(&stp->stateLock);
    urosThreadSleepMsec(20);
  } while ((!(0)));
  oldTime = urosGetTimestampMsec() - 1;
  urosMutexLock(&stp->stateLock);
  while (!stp->exitFlag) {
    urosMutexUnlock(&stp->stateLock);
    urosMutexLock(&benchmark.lock);
    inCount = benchmark.inCount;
    outCount = benchmark.outCount;
    benchmark.inCount.deltaMsgs = 0;
    benchmark.inCount.deltaBytes = 0;
    benchmark.outCount.deltaMsgs = 0;
    benchmark.outCount.deltaBytes = 0;
    urosMutexUnlock(&benchmark.lock);
    curTime = urosGetTimestampMsec();
    winTime = curTime - oldTime;
    printf("@ %lu %lu\n", (curTime - oldTime), logentry++);
    printf(
      "IN: %lu msg %lu B %lu msg/s %lu B/s\n",
      (unsigned long)((1000 * (unsigned long)inCount.numMsgs + 499) / winTime),
      (unsigned long)((1000 * (unsigned long)inCount.numBytes + 499) / winTime),
      (unsigned long)((1000 * (unsigned long)inCount.deltaMsgs + 499) / winTime),
      (unsigned long)((1000 * (unsigned long)inCount.deltaBytes + 499) / winTime)
    );
    printf(
      "OUT: %lu msg %lu B %lu msg/s %lu B/s\n",
      (unsigned long)((1000 * (unsigned long)outCount.numMsgs + 499) / winTime),
      (unsigned long)((1000 * (unsigned long)outCount.numBytes + 499) / winTime),
      (unsigned long)((1000 * (unsigned long)outCount.deltaMsgs + 499) / winTime),
      (unsigned long)((1000 * (unsigned long)outCount.deltaBytes + 499) / winTime)
    );
    app_print_cpu_state();
    app_print_cpu_usage();
    app_print_thread_state(pthread_self());
    urosMutexLock(&stp->stateLock);
    app_print_thread_state(stp->nodeThreadId);
    app_print_thread_state(stp->xmlrpcListenerId);
    app_print_thread_state(stp->tcprosListenerId);
    urosMutexLock(&stp->slaveThdPool.readyMtx);
    urosMutexLock(&stp->slaveThdPool.busyMtx);
    for (i = 0; i < stp->slaveThdPool.size; ++i) {
      app_print_thread_state(stp->slaveThdPool.threadsp[i]);
    }
    urosMutexUnlock(&stp->slaveThdPool.busyMtx);
    urosMutexUnlock(&stp->slaveThdPool.readyMtx);
    urosMutexLock(&stp->tcpsvrThdPool.readyMtx);
    urosMutexLock(&stp->tcpsvrThdPool.busyMtx);
    for (i = 0; i < stp->tcpsvrThdPool.size; ++i) {
      app_print_thread_state(stp->tcpsvrThdPool.threadsp[i]);
    }
    urosMutexUnlock(&stp->tcpsvrThdPool.busyMtx);
    urosMutexUnlock(&stp->tcpsvrThdPool.readyMtx);
    urosMutexLock(&stp->tcpcliThdPool.readyMtx);
    urosMutexLock(&stp->tcpcliThdPool.busyMtx);
    for (i = 0; i < stp->tcpcliThdPool.size; ++i) {
      app_print_thread_state(stp->tcpcliThdPool.threadsp[i]);
    }
    urosMutexUnlock(&stp->tcpcliThdPool.busyMtx);
    urosMutexUnlock(&stp->tcpcliThdPool.readyMtx);
    urosMutexUnlock(&stp->stateLock);
    printf("\n");
    if (logentry > 120) {
      struct UrosRpcResponse res;
      struct UrosString msgstr = { 3, "end" };
      urosRpcResponseObjectInit(&res);
      urosRpcCallShutdown(
        &urosNode.config.xmlrpcAddr,
        &urosNode.config.nodeName,
        &msgstr,
        &res
      );
      urosRpcResponseClean(&res);
    }
    urosThreadSleepMsec(urosGetTimestampMsec() - curTime + 1000);
    oldTime = curTime;
  }
  urosMutexUnlock(&stp->stateLock);
  return UROS_OK;
}

variable_types:
argp
void *

variable_types: struct UrosNodeStatus { enum uros_nodestate_t { UROS_NODE_UNINIT=0, UROS_NODE_IDLE=1, UROS_NODE_STARTUP=2, UROS_NODE_RUNNING=3, UROS_NODE_SHUTDOWN=4 } state; int xmlrpcPid; struct UrosList { struct UrosListNode { void *datap; struct UrosListNode *nextp; } *headp; unsigned int length; } subTopicList; struct UrosList pubTopicList; struct UrosList pubServiceList; struct UrosList subParamList; struct UrosList subTcpList; struct UrosList pubTcpList; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } stateLock; union pthread_mutex_t xmlrpcPidLock; union pthread_mutex_t subTopicListLock; union pthread_mutex_t pubTopicListLock; union pthread_mutex_t pubServiceListLock; union pthread_mutex_t subParamListLock; union pthread_mutex_t subTcpListLock; union pthread_mutex_t pubTcpListLock; struct UrosMemPool { void *headp; unsigned long blockSize; void *(*allocator)(unsigned long size); unsigned int free; union pthread_mutex_t lock; } tcpcliMemPool; struct UrosMemPool tcpsvrMemPool; struct UrosMemPool slaveMemPool; struct UrosThreadPool { struct UrosMemPool *stackPoolp; unsigned int size; int (*routine)(void *data); char *namep; int priority; unsigned long *threadsp; void *argp; unsigned int readyCnt; union pthread_mutex_t readyMtx; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } readyCond; unsigned int busyCnt; union pthread_mutex_t busyMtx; union pthread_cond_t busyCond; unsigned char exitFlag; } tcpcliThdPool; struct UrosThreadPool tcpsvrThdPool; struct UrosThreadPool slaveThdPool; unsigned long xmlrpcListenerId; unsigned long tcprosListenerId; unsigned long nodeThreadId; unsigned char exitFlag; struct UrosString { unsigned long length; char *datap; } exitMsg; } *

variable_types:
oldTime
unsigned long

variable_types:
curTime
unsigned long

variable_types:
winTime
unsigned long

variable_types:
logentry
unsigned long

variable_types: struct streamcnt_t { unsigned long numMsgs; unsigned long numBytes; unsigned long deltaMsgs; unsigned long deltaBytes; }

variable_types:
i
unsigned int

variable_types: struct UrosRpcResponse { unsigned int httpcode; int code; struct UrosString { unsigned long length; char *datap; } *statusMsgp; struct UrosRpcParam { enum uros_rpcparamclass_t { UROS_RPCP_INT=0, UROS_RPCP_BOOLEAN=1, UROS_RPCP_STRING=2, UROS_RPCP_DOUBLE=3, UROS_RPCP_BASE64=4, UROS_RPCP_STRUCT=5, UROS_RPCP_ARRAY=6, UROS_RPCP__LENGTH=7 } pclass; union { struct UrosString string; int int32; unsigned char boolean; double real; struct UrosString base64; void *mapp; struct UrosRpcParamList { struct UrosRpcParamNode { struct UrosRpcParam param; struct UrosRpcParamNode *nextp; } *headp; struct UrosRpcParamNode *tailp; unsigned int length; } *listp; } value; } *valuep; }

user_defined_types: struct UrosRpcResponse { unsigned int httpcode; int code; struct UrosString *statusMsgp; struct UrosRpcParam *valuep; }

user_defined_types: struct UrosNodeStatus { enum uros_nodestate_t state; int xmlrpcPid; struct UrosList subTopicList; struct UrosList pubTopicList; struct UrosList pubServiceList; struct UrosList subParamList; struct UrosList subTcpList; struct UrosList pubTcpList; union pthread_mutex_t stateLock; union pthread_mutex_t xmlrpcPidLock; union pthread_mutex_t subTopicListLock; union pthread_mutex_t pubTopicListLock; union pthread_mutex_t pubServiceListLock; union pthread_mutex_t subParamListLock; union pthread_mutex_t subTcpListLock; union pthread_mutex_t pubTcpListLock; struct UrosMemPool tcpcliMemPool; struct UrosMemPool tcpsvrMemPool; struct UrosMemPool slaveMemPool; struct UrosThreadPool tcpcliThdPool; struct UrosThreadPool tcpsvrThdPool; struct UrosThreadPool slaveThdPool; unsigned long xmlrpcListenerId; unsigned long tcprosListenerId; unsigned long nodeThreadId; unsigned char exitFlag; struct UrosString exitMsg; }

user_defined_types: struct UrosList { struct UrosListNode *headp; unsigned int length; }

user_defined_types: struct UrosThreadPool { struct UrosMemPool *stackPoolp; unsigned int size; int (*routine)(void *data); char *namep; int priority; unsigned long *threadsp; void *argp; unsigned int readyCnt; union pthread_mutex_t readyMtx; union pthread_cond_t readyCond; unsigned int busyCnt; union pthread_mutex_t busyMtx; union pthread_cond_t busyCond; unsigned char exitFlag; }

user_defined_types: struct UrosRpcParam { enum uros_rpcparamclass_t pclass; union { struct UrosString string; int int32; unsigned char boolean; double real; struct UrosString base64; void *mapp; struct UrosRpcParamList *listp; } value; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct UrosRpcParamList { struct UrosRpcParamNode *headp; struct UrosRpcParamNode *tailp; unsigned int length; }


decompiled_code:
int app_printusage()
{
puts("Usage:");
puts(" benchmark <[o][p][s]>");
puts(&byte_8A26);
puts("Options:");
puts(" o Creates the /benchmark/output subscriber (default off)");
puts(" p Creates the /benchmark/output publisher (default on)");
puts(" s Creates the /benchmark/input subscriber (default on)");
return puts(&byte_8A26);
}

canonical_decompiled_code:
int func4()
{
puts("Usage:");
puts(" benchmark <[o][p][s]>");
puts(&byte_8A26);
puts("Options:");
puts(" o Creates the /benchmark/output subscriber (default off)");
puts(" p Creates the /benchmark/output publisher (default on)");
puts(" s Creates the /benchmark/input subscriber (default on)");
return puts(&byte_8A26);
}

original_code:
void app_printusage(void) {
  puts("Usage:");
  puts("  benchmark <[o][p][s]>");
  puts("");
  puts("Options:");
  puts("  o   Creates the /benchmark/output subscriber (default off)");
  puts("  p   Creates the /benchmark/output publisher (default on)");
  puts("  s   Creates the /benchmark/input subscriber (default on)");
  puts("");
}

canonical_original_code:
void app_printusage() {
  puts("Usage:");
  puts("  benchmark <[o][p][s]>");
  puts("");
  puts("Options:");
  puts("  o   Creates the /benchmark/output subscriber (default off)");
  puts("  p   Creates the /benchmark/output publisher (default on)");
  puts("  s   Creates the /benchmark/input subscriber (default on)");
  puts("");
}


decompiled_code:
__int64 __fastcall app_parseargs(int a1, __int64 a2)
{
__int64 result; // rax
size_t v3; // rbx
const char *v4; // rbp

result = 0LL;
if ( a1 <= 2 )
{
if ( a1 == 2 )
{
v3 = 0LL;
LOWORD(benchmark[8]) = 0;
BYTE2(benchmark[8]) = 0;
v4 = *(const char **)(a2 + 8);
while ( strlen(v4) > v3 )
{
switch ( v4[v3] )
{
case 'p':
LOBYTE(benchmark[8]) = 1;
break;
case 's':
BYTE1(benchmark[8]) = 1;
break;
case 'o':
BYTE2(benchmark[8]) = 1;
break;
default:
printf("Invalid option: %c\n\n", (unsigned int)v4[v3]);
return 0LL;
}
++v3;
}
result = 1LL;
}
else
{
BYTE2(benchmark[8]) = 0;
LOWORD(benchmark[8]) = 257;
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, __int64 a2)
{
__int64 result; // rax
size_t v3; // rbx
const char *v4; // rbp

result = 0LL;
if ( a1 <= 2 )
{
if ( a1 == 2 )
{
v3 = 0LL;
LOWORD(benchmark[8]) = 0;
BYTE2(benchmark[8]) = 0;
v4 = *(const char **)(a2 + 8);
while ( strlen(v4) > v3 )
{
switch ( v4[v3] )
{
case 'p':
LOBYTE(benchmark[8]) = 1;
break;
case 's':
BYTE1(benchmark[8]) = 1;
break;
case 'o':
BYTE2(benchmark[8]) = 1;
break;
default:
printf("Invalid option: %c\n\n", (unsigned int)v4[v3]);
return 0LL;
}
++v3;
}
result = 1LL;
}
else
{
BYTE2(benchmark[8]) = 0;
LOWORD(benchmark[8]) = 257;
result = 1LL;
}
}
return result;
}

original_code:
uros_bool_t app_parseargs(int argc, char *argv[]) {
  if (argc > 2) {
    return (0);
  }
  if (argc == 2) {
    size_t i;
    benchmark.hasOutPub = (0);
    benchmark.hasInSub = (0);
    benchmark.hasOutSub = (0);
    for (i = 0; i < strlen(argv[1]); ++i) {
      switch (argv[1][i]) {
      case 'p': benchmark.hasOutPub = (!(0)); break;
      case 's': benchmark.hasInSub = (!(0)); break;
      case 'o': benchmark.hasOutSub = (!(0)); break;
      default:
        printf("Invalid option: %c\n\n", argv[1][i]);
        return (0);
      }
    }
  } else {
    benchmark.hasOutPub = (!(0));
    benchmark.hasInSub = (!(0));
    benchmark.hasOutSub = (0);
  }
  return (!(0));
}

canonical_original_code:
unsigned char app_parseargs(int argc, char *argv[]) {
  if (argc > 2) {
    return (0);
  }
  if (argc == 2) {
    unsigned long i;
    benchmark.hasOutPub = (0);
    benchmark.hasInSub = (0);
    benchmark.hasOutSub = (0);
    for (i = 0; i < strlen(argv[1]); ++i) {
      switch (argv[1][i]) {
      case 'p': benchmark.hasOutPub = (!(0)); break;
      case 's': benchmark.hasInSub = (!(0)); break;
      case 'o': benchmark.hasOutSub = (!(0)); break;
      default:
        printf("Invalid option: %c\n\n", argv[1][i]);
        return (0);
      }
    }
  } else {
    benchmark.hasOutPub = (!(0));
    benchmark.hasInSub = (!(0));
    benchmark.hasOutSub = (0);
  }
  return (!(0));
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
i
unsigned long


decompiled_code:
__int64 app_wait_exit()
{
urosThreadJoin(benchmark[33]);
return urosThreadJoin(urosNode[189]);
}

canonical_decompiled_code:
__int64 func7()
{
urosThreadJoin(benchmark[33]);
return urosThreadJoin(urosNode[189]);
}

original_code:
void app_wait_exit(void) {
  urosThreadJoin(benchmark.printerId);
  urosThreadJoin(urosNode.status.nodeThreadId);
}

canonical_original_code:
void app_wait_exit() {
  urosThreadJoin(benchmark.printerId);
  urosThreadJoin(urosNode.status.nodeThreadId);
}


decompiled_code:
__int64 app_initialize()
{
urosMutexObjectInit(benchmark);
LODWORD(benchmark[5]) = 1;
urosStringObjectInit((unsigned int)((_DWORD)benchmark + 48));
*(_OWORD *)&benchmark[25] = 0LL;
*(_OWORD *)&benchmark[27] = 0LL;
*(_OWORD *)&benchmark[29] = 0LL;
*(_OWORD *)&benchmark[31] = 0LL;
*(_OWORD *)&benchmark[9] = 0LL;
*(_OWORD *)&benchmark[11] = 0LL;
*(_OWORD *)&benchmark[13] = 0LL;
*(_OWORD *)&benchmark[15] = 0LL;
*(_OWORD *)&benchmark[17] = 0LL;
*(_OWORD *)&benchmark[19] = 0LL;
*(_OWORD *)&benchmark[21] = 0LL;
*(_OWORD *)&benchmark[23] = 0LL;
urosInit();
urosNodeCreateThread();
return urosThreadCreateStatic(
(unsigned int)((_DWORD)benchmark + 264),
"printer",
50LL,
app_printer_thread,
0LL,
&printerstack,
0x8000LL);
}

canonical_decompiled_code:
__int64 func6()
{
urosMutexObjectInit(benchmark);
LODWORD(benchmark[5]) = 1;
urosStringObjectInit((unsigned int)((_DWORD)benchmark + 48));
*(_OWORD *)&benchmark[25] = 0LL;
*(_OWORD *)&benchmark[27] = 0LL;
*(_OWORD *)&benchmark[29] = 0LL;
*(_OWORD *)&benchmark[31] = 0LL;
*(_OWORD *)&benchmark[9] = 0LL;
*(_OWORD *)&benchmark[11] = 0LL;
*(_OWORD *)&benchmark[13] = 0LL;
*(_OWORD *)&benchmark[15] = 0LL;
*(_OWORD *)&benchmark[17] = 0LL;
*(_OWORD *)&benchmark[19] = 0LL;
*(_OWORD *)&benchmark[21] = 0LL;
*(_OWORD *)&benchmark[23] = 0LL;
urosInit();
urosNodeCreateThread();
return urosThreadCreateStatic(
(unsigned int)((_DWORD)benchmark + 264),
"printer",
50LL,
app_printer_thread,
0LL,
&printerstack,
0x8000LL);
}

original_code:
void app_initialize(void) {
  uros_err_t err;
  (void)err;
  urosMutexObjectInit(&benchmark.lock);
  benchmark.rate = 1;
  urosStringObjectInit(&benchmark.payload);
  memset(&benchmark.inCount, 0, sizeof(streamcnt_t));
  memset(&benchmark.outCount, 0, sizeof(streamcnt_t));
  memset(&benchmark.curCpu, 0, sizeof(cpucnt_t));
  memset(&benchmark.oldCpu, 0, sizeof(cpucnt_t));
  urosInit();
  urosNodeCreateThread();
  err = urosThreadCreateStatic(&benchmark.printerId, "printer", 50,
                               app_printer_thread, ((void *)0), printerstack,
                               (16384 << 1));
  (void)(0);
}

canonical_original_code:
void app_initialize() {
  int err;
  (void)err;
  urosMutexObjectInit(&benchmark.lock);
  benchmark.rate = 1;
  urosStringObjectInit(&benchmark.payload);
  memset(&benchmark.inCount, 0, sizeof(streamcnt_t));
  memset(&benchmark.outCount, 0, sizeof(streamcnt_t));
  memset(&benchmark.curCpu, 0, sizeof(cpucnt_t));
  memset(&benchmark.oldCpu, 0, sizeof(cpucnt_t));
  urosInit();
  urosNodeCreateThread();
  err = urosThreadCreateStatic(&benchmark.printerId, "printer", 50,
                               app_printer_thread, ((void *)0), printerstack,
                               (16384 << 1));
  (void)(0);
}


decompiled_code:
void uros_lld_init()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void uros_lld_init(void) {
}

canonical_original_code:
void uros_lld_init() {
}


decompiled_code:
void __fastcall uros_lld_free(void *a1)
{
if ( a1 )
free(a1);
}

canonical_decompiled_code:
void __fastcall func2(void *a1)
{
if ( a1 )
free(a1);
}

original_code:
void uros_lld_free(void *chunkp) {
  if (chunkp != ((void *)0)) {
    free(chunkp);
  }
}

variable_types:
chunkp
void *


urosUserRegisterStaticTypes

decompiled_code:
// attributes: thunk
__int64 urosUserRegisterStaticTypes()
{
return urosMsgTypesRegStaticTypes();
}

canonical_decompiled_code:
__int64 func7()
{
return urosMsgTypesRegStaticTypes();
}

original_code:
void urosUserRegisterStaticTypes(void) {
  urosMsgTypesRegStaticTypes();
}

canonical_original_code:
void urosUserRegisterStaticTypes() {
  urosMsgTypesRegStaticTypes();
}


urosUserPublishTopics

decompiled_code:
__int64 urosUserPublishTopics()
{
urosHandlersPublishTopics();
return 0LL;
}

canonical_decompiled_code:
__int64 func8()
{
urosHandlersPublishTopics();
return 0LL;
}

original_code:
uros_err_t urosUserPublishTopics(void) {
  urosHandlersPublishTopics();
  return UROS_OK;
}

canonical_original_code:
int urosUserPublishTopics() {
  urosHandlersPublishTopics();
  return UROS_OK;
}