decompiled_code:
char *__fastcall l2tp_code(unsigned int a1)
{
char *result; // rax

if ( a1 > 0x10 || (result = (char *)l2tp_codes[a1]) == 0LL )
{
snprintf(n_11, 0x10uLL, "%d", a1);
result = n_11;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(unsigned int a1)
{
char *result; // rax

if ( a1 > 0x10 || (result = (char *)l2tp_codes[a1]) == 0LL )
{
snprintf(n_11, 0x10uLL, "%d", a1);
result = n_11;
}
return result;
}

original_code: char const *l2tp_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_codes) / sizeof(l2tp_codes[0]) && l2tp_codes[index]) return l2tp_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *l2tp_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_codes) / sizeof(l2tp_codes[0]) && l2tp_codes[index]) return l2tp_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }

variable_types: index int

variable_types:
n
char [16]


decompiled_code:
char *__fastcall l2tp_avp_name(unsigned int a1)
{
char *result; // rax

if ( a1 > 0x27 || (result = l2tp_avp_names[a1]) == 0LL )
{
snprintf(n_10, 0x10uLL, "%d", a1);
result = n_10;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func1(unsigned int a1)
{
char *result; // rax

if ( a1 > 0x27 || (result = l2tp_avp_names[a1]) == 0LL )
{
snprintf(n_10, 0x10uLL, "%d", a1);
result = n_10;
}
return result;
}

original_code: char const *l2tp_avp_name(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_avp_names) / sizeof(l2tp_avp_names[0]) && l2tp_avp_names[index]) return l2tp_avp_names[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *l2tp_avp_name(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_avp_names) / sizeof(l2tp_avp_names[0]) && l2tp_avp_names[index]) return l2tp_avp_names[index]; snprintf(n, sizeof(n), "%d", index); return n; }

return_type: char *


decompiled_code:
char *__fastcall l2tp_stopccn_result_code(unsigned int a1)
{
char *result; // rax

if ( a1 > 7 || (result = (char *)l2tp_stopccn_result_codes[a1]) == 0LL )
{
snprintf(n_9, 0x10uLL, "%d", a1);
result = n_9;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func2(unsigned int a1)
{
char *result; // rax

if ( a1 > 7 || (result = (char *)l2tp_stopccn_result_codes[a1]) == 0LL )
{
snprintf(n_9, 0x10uLL, "%d", a1);
result = n_9;
}
return result;
}

original_code: char const *l2tp_stopccn_result_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_stopccn_result_codes) / sizeof(l2tp_stopccn_result_codes[0]) && l2tp_stopccn_result_codes[index]) return l2tp_stopccn_result_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *l2tp_stopccn_result_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_stopccn_result_codes) / sizeof(l2tp_stopccn_result_codes[0]) && l2tp_stopccn_result_codes[index]) return l2tp_stopccn_result_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall l2tp_cdn_result_code(unsigned int a1)
{
char *result; // rax

if ( a1 > 0xB || (result = (char *)l2tp_cdn_result_codes[a1]) == 0LL )
{
snprintf(n_8, 0x10uLL, "%d", a1);
result = n_8;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func3(unsigned int a1)
{
char *result; // rax

if ( a1 > 0xB || (result = (char *)l2tp_cdn_result_codes[a1]) == 0LL )
{
snprintf(n_8, 0x10uLL, "%d", a1);
result = n_8;
}
return result;
}

original_code: char const *l2tp_cdn_result_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_cdn_result_codes) / sizeof(l2tp_cdn_result_codes[0]) && l2tp_cdn_result_codes[index]) return l2tp_cdn_result_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *l2tp_cdn_result_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_cdn_result_codes) / sizeof(l2tp_cdn_result_codes[0]) && l2tp_cdn_result_codes[index]) return l2tp_cdn_result_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall l2tp_error_code(unsigned int a1)
{
char *result; // rax

if ( a1 > 8 || (result = l2tp_error_codes[a1]) == 0LL )
{
snprintf(n_7, 0x10uLL, "%d", a1);
result = n_7;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func4(unsigned int a1)
{
char *result; // rax

if ( a1 > 8 || (result = l2tp_error_codes[a1]) == 0LL )
{
snprintf(n_7, 0x10uLL, "%d", a1);
result = n_7;
}
return result;
}

original_code: char const *l2tp_error_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_error_codes) / sizeof(l2tp_error_codes[0]) && l2tp_error_codes[index]) return l2tp_error_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *l2tp_error_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(l2tp_error_codes) / sizeof(l2tp_error_codes[0]) && l2tp_error_codes[index]) return l2tp_error_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall ppp_phase(unsigned int a1)
{
char *result; // rax

if ( a1 > 4 || (result = ppp_phases[a1]) == 0LL )
{
snprintf(n_6, 0x10uLL, "%d", a1);
result = n_6;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func5(unsigned int a1)
{
char *result; // rax

if ( a1 > 4 || (result = ppp_phases[a1]) == 0LL )
{
snprintf(n_6, 0x10uLL, "%d", a1);
result = n_6;
}
return result;
}

original_code: char const *ppp_phase(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_phases) / sizeof(ppp_phases[0]) && ppp_phases[index]) return ppp_phases[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *ppp_phase(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_phases) / sizeof(ppp_phases[0]) && ppp_phases[index]) return ppp_phases[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall ppp_state(unsigned int a1)
{
char *result; // rax

if ( a1 > 9 || (result = ppp_states[a1]) == 0LL )
{
snprintf(n_5, 0x10uLL, "%d", a1);
result = n_5;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func6(unsigned int a1)
{
char *result; // rax

if ( a1 > 9 || (result = ppp_states[a1]) == 0LL )
{
snprintf(n_5, 0x10uLL, "%d", a1);
result = n_5;
}
return result;
}

original_code: char const *ppp_state(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_states) / sizeof(ppp_states[0]) && ppp_states[index]) return ppp_states[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *ppp_state(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_states) / sizeof(ppp_states[0]) && ppp_states[index]) return ppp_states[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall ppp_auth_type(unsigned int a1)
{
char *result; // rax

if ( a1 > 5 || (result = (char *)ppp_auth_types[a1]) == 0LL )
{
snprintf(n_4, 0x10uLL, "%d", a1);
result = n_4;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func7(unsigned int a1)
{
char *result; // rax

if ( a1 > 5 || (result = (char *)ppp_auth_types[a1]) == 0LL )
{
snprintf(n_4, 0x10uLL, "%d", a1);
result = n_4;
}
return result;
}

original_code: char const *ppp_auth_type(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_auth_types) / sizeof(ppp_auth_types[0]) && ppp_auth_types[index]) return ppp_auth_types[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *ppp_auth_type(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_auth_types) / sizeof(ppp_auth_types[0]) && ppp_auth_types[index]) return ppp_auth_types[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall ppp_code(unsigned int a1)
{
char *result; // rax

if ( a1 > 0xC || (result = (char *)ppp_codes[a1]) == 0LL )
{
snprintf(n_3, 0x10uLL, "%d", a1);
result = n_3;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func8(unsigned int a1)
{
char *result; // rax

if ( a1 > 0xC || (result = (char *)ppp_codes[a1]) == 0LL )
{
snprintf(n_3, 0x10uLL, "%d", a1);
result = n_3;
}
return result;
}

original_code: char const *ppp_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_codes) / sizeof(ppp_codes[0]) && ppp_codes[index]) return ppp_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *ppp_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_codes) / sizeof(ppp_codes[0]) && ppp_codes[index]) return ppp_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall ppp_lcp_option(unsigned int a1)
{
char *result; // rax

if ( a1 > 8 || (result = (char *)ppp_lcp_options[a1]) == 0LL )
{
snprintf(n_2, 0x10uLL, "%d", a1);
result = n_2;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func9(unsigned int a1)
{
char *result; // rax

if ( a1 > 8 || (result = (char *)ppp_lcp_options[a1]) == 0LL )
{
snprintf(n_2, 0x10uLL, "%d", a1);
result = n_2;
}
return result;
}

original_code: char const *ppp_lcp_option(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_lcp_options) / sizeof(ppp_lcp_options[0]) && ppp_lcp_options[index]) return ppp_lcp_options[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *ppp_lcp_option(int index) { static char n[16]; if (index >= 0 && index < sizeof(ppp_lcp_options) / sizeof(ppp_lcp_options[0]) && ppp_lcp_options[index]) return ppp_lcp_options[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall radius_state(unsigned int a1)
{
char *result; // rax

if ( a1 > 7 || (result = radius_states[a1]) == 0LL )
{
snprintf(n_1, 0x10uLL, "%d", a1);
result = n_1;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func10(unsigned int a1)
{
char *result; // rax

if ( a1 > 7 || (result = radius_states[a1]) == 0LL )
{
snprintf(n_1, 0x10uLL, "%d", a1);
result = n_1;
}
return result;
}

original_code: char const *radius_state(int index) { static char n[16]; if (index >= 0 && index < sizeof(radius_states) / sizeof(radius_states[0]) && radius_states[index]) return radius_states[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *radius_state(int index) { static char n[16]; if (index >= 0 && index < sizeof(radius_states) / sizeof(radius_states[0]) && radius_states[index]) return radius_states[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
char *__fastcall radius_code(unsigned int a1)
{
char *result; // rax

if ( a1 > 0x2D || (result = (char *)radius_codes[a1]) == 0LL )
{
snprintf(n_0, 0x10uLL, "%d", a1);
result = n_0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func11(unsigned int a1)
{
char *result; // rax

if ( a1 > 0x2D || (result = (char *)radius_codes[a1]) == 0LL )
{
snprintf(n_0, 0x10uLL, "%d", a1);
result = n_0;
}
return result;
}

original_code: char const *radius_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(radius_codes) / sizeof(radius_codes[0]) && radius_codes[index]) return radius_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }

canonical_original_code: char *radius_code(int index) { static char n[16]; if (index >= 0 && index < sizeof(radius_codes) / sizeof(radius_codes[0]) && radius_codes[index]) return radius_codes[index]; snprintf(n, sizeof(n), "%d", index); return n; }


decompiled_code:
void *ll_init()
{
return calloc(0x18uLL, 1uLL);
}

canonical_decompiled_code:
void *func0()
{
return calloc(0x18uLL, 1uLL);
}

original_code:
linked_list *ll_init()
{
 return (linked_list *)calloc(sizeof(linked_list), 1);
}

canonical_original_code:
struct s_ll *ll_init()
{
 return (struct s_ll *)calloc(sizeof(linked_list), 1);
}

return_type: struct s_ll { struct s_li { void *data; struct s_li *next; } *head; struct s_li *end; struct s_li *current; } *

user_defined_types: struct s_ll { struct s_li *head; struct s_li *end; struct s_li *current; }


decompiled_code:
void __fastcall ll_done(void *ptr)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[1];
free(v3);
}
while ( v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[1];
free(v3);
}
while ( v2 );
}
free(ptr);
}

original_code:
void ll_done(linked_list *l)
{
 li *i = l->head, *n;
 while (i)
 {
  n = i->next;
  free(i);
  i = n;
 }
 free(l);
}

canonical_original_code:
void ll_done(struct s_ll *l)
{
 struct s_li *i = l->head; struct s_li *n;
 while (i)
 {
  n = i->next;
  free(i);
  i = n;
 }
 free(l);
}

variable_types: struct s_ll { struct s_li { void *data; struct s_li *next; } *head; struct s_li *end; struct s_li *current; } *

return_type: void


original_code:
void *ll_pop(linked_list *l)
{
 li *i;
 void *data;
 if (!l) return ((void *)0);
 if (!l->head)
  return ((void *)0);
 data = l->head->data;
 i = l->head->next;
 free(l->head);
 l->head = i;
 return data;
}

canonical_original_code:
void *ll_pop(struct s_ll *l)
{
 struct s_li *i;
 void *data;
 if (!l) return ((void *)0);
 if (!l->head)
  return ((void *)0);
 data = l->head->data;
 i = l->head->next;
 free(l->head);
 l->head = i;
 return data;
}

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

variable_types:
data
void *

return_type: void *


decompiled_code:
void __fastcall ll_iterate(_QWORD **a1, unsigned int (*a2)(void))
{
_QWORD *i; // rbx

if ( a1 )
{
if ( a2 )
{
for ( i = *a1; i; i = (_QWORD *)i[1] )
{
if ( *i && !a2() )
break;
}
}
}
}

canonical_decompiled_code:
void __fastcall func3(_QWORD **a1, unsigned int (*a2)(void))
{
_QWORD *i; // rbx

if ( a1 )
{
if ( a2 )
{
for ( i = *a1; i; i = (_QWORD *)i[1] )
{
if ( *i && !a2() )
break;
}
}
}
}

original_code:
void ll_iterate(linked_list *l, int(*func)(void *))
{
 li *i;
 if (!l || !func) return;
 for (i = l->head; i; i = i->next)
 {
  if (i->data && !func(i->data))
   break;
 }
}

canonical_original_code:
void ll_iterate(struct s_ll *l, int (*func)(void *))
{
 struct s_li *i;
 if (!l || !func) return;
 for (i = l->head; i; i = i->next)
 {
  if (i->data && !func(i->data))
   break;
 }
}

variable_types:
func
int (*)(void *)

user_defined_types: struct s_li { void *data; struct s_li *next; }


decompiled_code:
void __fastcall ll_reset(__int64 a1)
{
if ( a1 )
*(_QWORD *)(a1 + 16) = 0LL;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
if ( a1 )
*(_QWORD *)(a1 + 16) = 0LL;
}

original_code:
void ll_reset(linked_list *l)
{
 if (!l) return;
 l->current = ((void *)0);
}

canonical_original_code:
void ll_reset(struct s_ll *l)
{
 if (!l) return;
 l->current = ((void *)0);
}


decompiled_code:
__int64 __fastcall ll_size(_QWORD **a1)
{
_QWORD *v1; // rax
unsigned int i; // er8
bool v3; // cf

if ( !a1 )
return 0LL;
v1 = *a1;
for ( i = 0; v1; i -= v3 - 1 )
{
v3 = *v1 == 0LL;
v1 = (_QWORD *)v1[1];
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD **a1)
{
_QWORD *v1; // rax
unsigned int i; // er8
bool v3; // cf

if ( !a1 )
return 0LL;
v1 = *a1;
for ( i = 0; v1; i -= v3 - 1 )
{
v3 = *v1 == 0LL;
v1 = (_QWORD *)v1[1];
}
return i;
}

original_code:
int ll_size(linked_list *l)
{
 int count = 0;
 li *i;
 if (!l) return 0;
 for (i = l->head; i; i = i->next)
  if (i->data) count++;
 return count;
}

canonical_original_code:
int ll_size(struct s_ll *l)
{
 int count = 0;
 struct s_li *i;
 if (!l) return 0;
 for (i = l->head; i; i = i->next)
  if (i->data) count++;
 return count;
}

variable_types: count int

return_type: int


repo: bodokaiser/libuv-snippets

decompiled_code:
__int64 wait_for_a_while()
{
__int64 result; // rax
double v1; // xmm0_8

result = counter + 1;
v1 = (double)((int)counter++ + 1);
if ( v1 >= 10000000.0 )
result = uv_idle_stop();
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
double v1; // xmm0_8

result = counter + 1;
v1 = (double)((int)counter++ + 1);
if ( v1 >= 10000000.0 )
result = uv_idle_stop();
return result;
}

original_code:
void wait_for_a_while(uv_idle_t* handle, int status) {
    counter++;
    if (counter >= 10e6)
        uv_idle_stop(handle);
}

canonical_original_code:
void wait_for_a_while(struct uv_idle_s *handle, int status) {
    counter++;
    if (counter >= 10e6)
        uv_idle_stop(handle);
}

variable_types: struct uv_idle_s { void *data; struct uv_loop_s { void *data; unsigned int active_handles; void *handle_queue[2]; union { void *unused[2]; unsigned int count; } active_reqs; unsigned int stop_flag; unsigned long flags; int backend_fd; void *pending_queue[2]; void *watcher_queue[2]; struct uv__io_s { void (*cb)(struct uv_loop_s *loop, struct uv__io_s *w, unsigned int events); void *pending_queue[2]; void *watcher_queue[2]; unsigned int pevents; unsigned int events; int fd; } **watchers; unsigned int nwatchers; unsigned int nfds; void *wq[2]; 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; } wq_mutex; struct uv_async_s { void *data; struct uv_loop_s *loop; enum uv_handle_type { UV_UNKNOWN_HANDLE=0, UV_ASYNC=1, UV_CHECK=2, UV_FS_EVENT=3, UV_FS_POLL=4, UV_HANDLE=5, UV_IDLE=6, UV_NAMED_PIPE=7, UV_POLL=8, UV_PREPARE=9, UV_PROCESS=10, UV_STREAM=11, UV_TCP=12, UV_TIMER=13, UV_TTY=14, UV_UDP=15, UV_SIGNAL=16, UV_FILE=17, UV_HANDLE_TYPE_MAX=18 } type; void (*close_cb)(struct uv_handle_s { void *data; struct uv_loop_s *loop; enum uv_handle_type { UV_UNKNOWN_HANDLE=0, UV_ASYNC=1, UV_CHECK=2, UV_FS_EVENT=3, UV_FS_POLL=4, UV_HANDLE=5, UV_IDLE=6, UV_NAMED_PIPE=7, UV_POLL=8, UV_PREPARE=9, UV_PROCESS=10, UV_STREAM=11, UV_TCP=12, UV_TIMER=13, UV_TTY=14, UV_UDP=15, UV_SIGNAL=16, UV_FILE=17, UV_HANDLE_TYPE_MAX=18 } type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; } *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*async_cb)(struct uv_async_s *handle); void *queue[2]; int pending; } wq_async; union pthread_rwlock_t { struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; char __rwelision; unsigned char __pad1[7]; unsigned long __pad2; unsigned int __flags; } __data; char __size[56]; long __align; } cloexec_lock; struct uv_handle_s *closing_handles; void *process_handles[2]; void *prepare_handles[2]; void *check_handles[2]; void *idle_handles[2]; void *async_handles[2]; void (*async_unused)(); struct uv__io_s async_io_watcher; int async_wfd; struct { void *min; unsigned int nelts; } timer_heap; unsigned long timer_counter; unsigned long time; int signal_pipefd[2]; struct uv__io_s signal_io_watcher; struct uv_signal_s { void *data; struct uv_loop_s *loop; enum uv_handle_type { UV_UNKNOWN_HANDLE=0, UV_ASYNC=1, UV_CHECK=2, UV_FS_EVENT=3, UV_FS_POLL=4, UV_HANDLE=5, UV_IDLE=6, UV_NAMED_PIPE=7, UV_POLL=8, UV_PREPARE=9, UV_PROCESS=10, UV_STREAM=11, UV_TCP=12, UV_TIMER=13, UV_TTY=14, UV_UDP=15, UV_SIGNAL=16, UV_FILE=17, UV_HANDLE_TYPE_MAX=18 } type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*signal_cb)(struct uv_signal_s *handle, int signum); int signum; struct { struct uv_signal_s *rbe_left; struct uv_signal_s *rbe_right; struct uv_signal_s *rbe_parent; int rbe_color; } tree_entry; unsigned int caught_signals; unsigned int dispatched_signals; } child_watcher; int emfile_fd; struct uv__io_s inotify_read_watcher; void *inotify_watchers; int inotify_fd; } *loop; enum uv_handle_type { UV_UNKNOWN_HANDLE=0, UV_ASYNC=1, UV_CHECK=2, UV_FS_EVENT=3, UV_FS_POLL=4, UV_HANDLE=5, UV_IDLE=6, UV_NAMED_PIPE=7, UV_POLL=8, UV_PREPARE=9, UV_PROCESS=10, UV_STREAM=11, UV_TCP=12, UV_TIMER=13, UV_TTY=14, UV_UDP=15, UV_SIGNAL=16, UV_FILE=17, UV_HANDLE_TYPE_MAX=18 } type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*idle_cb)(struct uv_idle_s *handle); void *queue[2]; } *

variable_types: status int

user_defined_types: struct uv_idle_s { void *data; struct uv_loop_s *loop; enum uv_handle_type type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*idle_cb)(struct uv_idle_s *handle); void *queue[2]; }

user_defined_types: struct uv_loop_s { void *data; unsigned int active_handles; void *handle_queue[2]; union { void *unused[2]; unsigned int count; } active_reqs; unsigned int stop_flag; unsigned long flags; int backend_fd; void *pending_queue[2]; void *watcher_queue[2]; struct uv__io_s **watchers; unsigned int nwatchers; unsigned int nfds; void *wq[2]; union pthread_mutex_t wq_mutex; struct uv_async_s wq_async; union pthread_rwlock_t cloexec_lock; struct uv_handle_s *closing_handles; void *process_handles[2]; void *prepare_handles[2]; void *check_handles[2]; void *idle_handles[2]; void *async_handles[2]; void (*async_unused)(); struct uv__io_s async_io_watcher; int async_wfd; struct { void *min; unsigned int nelts; } timer_heap; unsigned long timer_counter; unsigned long time; int signal_pipefd[2]; struct uv__io_s signal_io_watcher; struct uv_signal_s child_watcher; int emfile_fd; struct uv__io_s inotify_read_watcher; void *inotify_watchers; int inotify_fd; }

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

user_defined_types: struct uv_async_s { void *data; struct uv_loop_s *loop; enum uv_handle_type type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*async_cb)(struct uv_async_s *handle); void *queue[2]; int pending; }

user_defined_types: union pthread_rwlock_t { struct __pthread_rwlock_arch_t __data; char __size[56]; long __align; }

user_defined_types: struct uv_signal_s { void *data; struct uv_loop_s *loop; enum uv_handle_type type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*signal_cb)(struct uv_signal_s *handle, int signum); int signum; struct { struct uv_signal_s *rbe_left; struct uv_signal_s *rbe_right; struct uv_signal_s *rbe_parent; int rbe_color; } tree_entry; unsigned int caught_signals; unsigned int dispatched_signals; }

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 uv_handle_s { void *data; struct uv_loop_s *loop; enum uv_handle_type type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
uv_default_loop();
uv_idle_init();
uv_idle_start();
puts("Idling ...");
uv_run();
return 0;
}

original_code:
int main() {
    uv_loop_t *loop;
    uv_idle_t idler;
    loop = uv_default_loop();
    uv_idle_init(loop, &idler);
    uv_idle_start(&idler, wait_for_a_while);
    printf("Idling ...\n");
    uv_run(loop, UV_RUN_DEFAULT);
}

canonical_original_code:
int main() {
    struct uv_loop_s *loop;
    struct uv_idle_s idler;
    loop = uv_default_loop();
    uv_idle_init(loop, &idler);
    uv_idle_start(&idler, wait_for_a_while);
    printf("Idling ...\n");
    uv_run(loop, UV_RUN_DEFAULT);
}

variable_types: struct uv_idle_s { void *data; struct uv_loop_s { void *data; unsigned int active_handles; void *handle_queue[2]; union { void *unused[2]; unsigned int count; } active_reqs; unsigned int stop_flag; unsigned long flags; int backend_fd; void *pending_queue[2]; void *watcher_queue[2]; struct uv__io_s { void (*cb)(struct uv_loop_s *loop, struct uv__io_s *w, unsigned int events); void *pending_queue[2]; void *watcher_queue[2]; unsigned int pevents; unsigned int events; int fd; } **watchers; unsigned int nwatchers; unsigned int nfds; void *wq[2]; 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; } wq_mutex; struct uv_async_s { void *data; struct uv_loop_s *loop; enum uv_handle_type { UV_UNKNOWN_HANDLE=0, UV_ASYNC=1, UV_CHECK=2, UV_FS_EVENT=3, UV_FS_POLL=4, UV_HANDLE=5, UV_IDLE=6, UV_NAMED_PIPE=7, UV_POLL=8, UV_PREPARE=9, UV_PROCESS=10, UV_STREAM=11, UV_TCP=12, UV_TIMER=13, UV_TTY=14, UV_UDP=15, UV_SIGNAL=16, UV_FILE=17, UV_HANDLE_TYPE_MAX=18 } type; void (*close_cb)(struct uv_handle_s { void *data; struct uv_loop_s *loop; enum uv_handle_type { UV_UNKNOWN_HANDLE=0, UV_ASYNC=1, UV_CHECK=2, UV_FS_EVENT=3, UV_FS_POLL=4, UV_HANDLE=5, UV_IDLE=6, UV_NAMED_PIPE=7, UV_POLL=8, UV_PREPARE=9, UV_PROCESS=10, UV_STREAM=11, UV_TCP=12, UV_TIMER=13, UV_TTY=14, UV_UDP=15, UV_SIGNAL=16, UV_FILE=17, UV_HANDLE_TYPE_MAX=18 } type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; } *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*async_cb)(struct uv_async_s *handle); void *queue[2]; int pending; } wq_async; union pthread_rwlock_t { struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; char __rwelision; unsigned char __pad1[7]; unsigned long __pad2; unsigned int __flags; } __data; char __size[56]; long __align; } cloexec_lock; struct uv_handle_s *closing_handles; void *process_handles[2]; void *prepare_handles[2]; void *check_handles[2]; void *idle_handles[2]; void *async_handles[2]; void (*async_unused)(); struct uv__io_s async_io_watcher; int async_wfd; struct { void *min; unsigned int nelts; } timer_heap; unsigned long timer_counter; unsigned long time; int signal_pipefd[2]; struct uv__io_s signal_io_watcher; struct uv_signal_s { void *data; struct uv_loop_s *loop; enum uv_handle_type { UV_UNKNOWN_HANDLE=0, UV_ASYNC=1, UV_CHECK=2, UV_FS_EVENT=3, UV_FS_POLL=4, UV_HANDLE=5, UV_IDLE=6, UV_NAMED_PIPE=7, UV_POLL=8, UV_PREPARE=9, UV_PROCESS=10, UV_STREAM=11, UV_TCP=12, UV_TIMER=13, UV_TTY=14, UV_UDP=15, UV_SIGNAL=16, UV_FILE=17, UV_HANDLE_TYPE_MAX=18 } type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*signal_cb)(struct uv_signal_s *handle, int signum); int signum; struct { struct uv_signal_s *rbe_left; struct uv_signal_s *rbe_right; struct uv_signal_s *rbe_parent; int rbe_color; } tree_entry; unsigned int caught_signals; unsigned int dispatched_signals; } child_watcher; int emfile_fd; struct uv__io_s inotify_read_watcher; void *inotify_watchers; int inotify_fd; } *loop; enum uv_handle_type { UV_UNKNOWN_HANDLE=0, UV_ASYNC=1, UV_CHECK=2, UV_FS_EVENT=3, UV_FS_POLL=4, UV_HANDLE=5, UV_IDLE=6, UV_NAMED_PIPE=7, UV_POLL=8, UV_PREPARE=9, UV_PROCESS=10, UV_STREAM=11, UV_TCP=12, UV_TIMER=13, UV_TTY=14, UV_UDP=15, UV_SIGNAL=16, UV_FILE=17, UV_HANDLE_TYPE_MAX=18 } type; void (*close_cb)(struct uv_handle_s *handle); void *handle_queue[2]; union { int fd; void *reserved[4]; } u; struct uv_handle_s *next_closing; unsigned int flags; void (*idle_cb)(struct uv_idle_s *handle); void *queue[2]; }


decompiled_code:
int new_localSocket()
{
int result; // eax

result = socket(2, 2, 0);
if ( result < 0 )
{
perror("socket");
result = -1;
}
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax

result = socket(2, 2, 0);
if ( result < 0 )
{
perror("socket");
result = -1;
}
return result;
}

original_code:
int new_localSocket(void)
{
    int socket_local;
    socket_local = socket(2, SOCK_DGRAM, 0);
    if(socket_local < 0)
    {
 perror("socket");
 return -1;
    }
    return socket_local;
}

canonical_original_code:
int new_localSocket()
{
    int socket_local;
    socket_local = socket(2, SOCK_DGRAM, 0);
    if(socket_local < 0)
    {
 perror("socket");
 return -1;
    }
    return socket_local;
}


decompiled_code:
__int64 __fastcall new_destAddr(char *name, __int16 a2)
{
struct hostent *v2; // rbp
char *v3; // rax
__m128i v4; // xmm0
__int16 v5; // ax
__int64 v6; // r8
struct in_addr inp; // [rsp+Ch] [rbp-1Ch] BYREF

if ( inet_aton(name, &inp) )
v2 = gethostbyaddr(&inp, 4u, 2);
else
v2 = gethostbyname(name);
if ( !v2 )
{
printf("Endereco de rede invalido");
exit(1);
}
v3 = (char *)calloc(0x10uLL, 1uLL);
v4 = _mm_loadu_si128((const __m128i *)*v2->h_addr_list);
*(_WORD *)v3 = 2;
*(__m128i *)(v3 + 4) = v4;
v5 = _bswap_16(a2);
*(_WORD *)(v6 + 2) = v5;
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *name, __int16 a2)
{
struct hostent *v2; // rbp
char *v3; // rax
__m128i v4; // xmm0
__int16 v5; // ax
__int64 v6; // r8
struct in_addr inp; // [rsp+Ch] [rbp-1Ch] BYREF

if ( inet_aton(name, &inp) )
v2 = gethostbyaddr(&inp, 4u, 2);
else
v2 = gethostbyname(name);
if ( !v2 )
{
printf("Endereco de rede invalido");
exit(1);
}
v3 = (char *)calloc(0x10uLL, 1uLL);
v4 = _mm_loadu_si128((const __m128i *)*v2->h_addr_list);
*(_WORD *)v3 = 2;
*(__m128i *)(v3 + 4) = v4;
v5 = func0(a2);
*(_WORD *)(v6 + 2) = v5;
return v6;
}

original_code:
Sockaddr_in* new_destAddr(char* dest, int destPort)
{
    Sockaddr_in *sockaddr_serv;
    Hostent *addr_dest;
    In_addr ip_dest;
    if (inet_aton(dest, &ip_dest))
 addr_dest = gethostbyaddr((char* )&ip_dest, sizeof(ip_dest), 2);
    else
 addr_dest = gethostbyname(dest);
    if(addr_dest == ((void *)0))
    {
 printf("Endereco de rede invalido");
 exit(1);
    }
    sockaddr_serv = (Sockaddr_in*)malloc(sizeof(Sockaddr_in));
    memset((char *)sockaddr_serv, 0, sizeof(*sockaddr_serv));
    memcpy(&sockaddr_serv->sin_addr, addr_dest->h_addr_list[0], sizeof(*sockaddr_serv));
    sockaddr_serv->sin_family = 2;
    sockaddr_serv->sin_port = htons(destPort);
    return sockaddr_serv;
}

canonical_original_code:
struct sockaddr_in *new_destAddr(char *dest, int destPort)
{
    struct sockaddr_in *sockaddr_serv;
    struct hostent *addr_dest;
    struct in_addr ip_dest;
    if (inet_aton(dest, &ip_dest))
 addr_dest = gethostbyaddr((char * )&ip_dest, sizeof(ip_dest), 2);
    else
 addr_dest = gethostbyname(dest);
    if(addr_dest == ((void *)0))
    {
 printf("Endereco de rede invalido");
 exit(1);
    }
    sockaddr_serv = (struct sockaddr_in *)malloc(sizeof(Sockaddr_in));
    memset((char *)sockaddr_serv, 0, sizeof(*sockaddr_serv));
    memcpy(&sockaddr_serv->sin_addr, addr_dest->h_addr_list[0], sizeof(*sockaddr_serv));
    sockaddr_serv->sin_family = 2;
    sockaddr_serv->sin_port = htons(destPort);
    return sockaddr_serv;
}

variable_types:
dest
char *

variable_types: destPort int

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }


decompiled_code:
__int64 __fastcall send_msg(__int64 a1, const char *a2)
{
size_t v2; // rax
ssize_t v3; // r8
__int64 result; // rax

v2 = strlen(a2);
v3 = sendto(*(_DWORD *)a1, a2, v2 + 1, 0, *(const struct sockaddr **)(a1 + 8), 0x10u);
result = 1LL;
if ( v3 < 0 )
{
perror("sendto");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2)
{
size_t v2; // rax
ssize_t v3; // r8
__int64 result; // rax

v2 = strlen(a2);
v3 = sendto(*(_DWORD *)a1, a2, v2 + 1, 0, *(const struct sockaddr **)(a1 + 8), 0x10u);
result = 1LL;
if ( v3 < 0 )
{
perror("sendto");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int send_msg(UdpCom* udpcom, char *msg)
{
    if (sendto(udpcom->localSocket, msg, strlen(msg)+1, 0, (Sockaddr *)udpcom->destAddr, sizeof(*udpcom->destAddr)) < 0)
    {
 perror("sendto");
 return -1;
    }
    return 1;
}

canonical_original_code:
int send_msg(struct udpCom *udpcom, char *msg)
{
    if (sendto(udpcom->localSocket, msg, strlen(msg)+1, 0, (struct sockaddr *)udpcom->destAddr, sizeof(*udpcom->destAddr)) < 0)
    {
 perror("sendto");
 return -1;
    }
    return 1;
}

variable_types: struct udpCom { int localSocket; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *destAddr; } *

variable_types:
msg
char *

user_defined_types: struct udpCom { int localSocket; struct sockaddr_in *destAddr; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


decompiled_code:
ssize_t __fastcall recv_msg(int *a1, void *a2, int a3)
{
ssize_t result; // rax
ssize_t v4; // [rsp+8h] [rbp-10h]

result = recvfrom(*a1, a2, a3, 0, 0LL, 0LL);
if ( (int)result < 0 )
{
v4 = result;
perror("recvfrom");
result = v4;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func4(int *a1, void *a2, int a3)
{
ssize_t result; // rax
ssize_t v4; // [rsp+8h] [rbp-10h]

result = recvfrom(*a1, a2, a3, 0, 0LL, 0LL);
if ( (int)result < 0 )
{
v4 = result;
perror("recvfrom");
result = v4;
}
return result;
}

original_code:
int recv_msg(UdpCom* udpcom, char *buffer, int bufferSize)
{
    int bytes_recv;
    bytes_recv = recvfrom(udpcom->localSocket, buffer, bufferSize, 0, ((void *)0), 0);
    if (bytes_recv < 0)
    {
 perror("recvfrom");
    }
    return bytes_recv;
}

canonical_original_code:
int recv_msg(struct udpCom *udpcom, char *buffer, int bufferSize)
{
    int bytes_recv;
    bytes_recv = recvfrom(udpcom->localSocket, buffer, bufferSize, 0, ((void *)0), 0);
    if (bytes_recv < 0)
    {
 perror("recvfrom");
    }
    return bytes_recv;
}

variable_types:
buffer
char *

variable_types: bufferSize int


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

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

original_code:
void delete_udpCom(UdpCom* udpcom)
{
    free(udpcom->destAddr);
    free(udpcom);
}

canonical_original_code:
void delete_udpCom(struct udpCom *udpcom)
{
    free(udpcom->destAddr);
    free(udpcom);
}


decompiled_code:
int __fastcall init_monitor(__int64 a1, __int64 a2, __int64 a3)
{
*(_QWORD *)a2 = 0LL;
*(_QWORD *)(a2 + 8) = 0LL;
*(_QWORD *)(a2 + 16) = 0LL;
*(_QWORD *)(a2 + 24) = 0LL;
*(_QWORD *)(a2 + 32) = 0LL;
*(_QWORD *)(a2 + 40) = 0LL;
*(_QWORD *)(a2 + 48) = 0LL;
*(_QWORD *)(a2 + 56) = 0LL;
*(_QWORD *)(a2 + 64) = 0LL;
*(_WORD *)(a2 + 72) = 28160;
*(_QWORD *)(a3 + 160) = 0LL;
*(_DWORD *)(a3 + 168) = 0;
pthread_mutex_init((pthread_mutex_t *)a1, 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 40), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 80), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 120), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 160), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 200), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 240), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 280), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 320), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 360), 0LL);
pthread_cond_init((pthread_cond_t *)(a1 + 400), 0LL);
return pthread_cond_init((pthread_cond_t *)(a1 + 448), 0LL);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
*(_QWORD *)a2 = 0LL;
*(_QWORD *)(a2 + 8) = 0LL;
*(_QWORD *)(a2 + 16) = 0LL;
*(_QWORD *)(a2 + 24) = 0LL;
*(_QWORD *)(a2 + 32) = 0LL;
*(_QWORD *)(a2 + 40) = 0LL;
*(_QWORD *)(a2 + 48) = 0LL;
*(_QWORD *)(a2 + 56) = 0LL;
*(_QWORD *)(a2 + 64) = 0LL;
*(_WORD *)(a2 + 72) = 28160;
*(_QWORD *)(a3 + 160) = 0LL;
*(_DWORD *)(a3 + 168) = 0;
pthread_mutex_init((pthread_mutex_t *)a1, 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 40), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 80), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 120), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 160), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 200), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 240), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 280), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 320), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 360), 0LL);
pthread_cond_init((pthread_cond_t *)(a1 + 400), 0LL);
return pthread_cond_init((pthread_cond_t *)(a1 + 448), 0LL);
}

original_code:
void init_monitor(PthreadAcess* pth, SharedVars* vars, BufferControl* buffer)
{
    vars->H = 0;
    vars->Href = 0;
    vars->Ni = 0;
    vars->No = 0;
    vars->Q = 0;
    vars->T = 0;
    vars->Tref = 0;
    vars->Ta = 0;
    vars->Ti = 0;
    vars->stop_threads = 'n';
    vars->screen = 0;
    buffer->bufferRec = 0;
    buffer->bufferRead = 0;
    buffer->ndata = 0;
    pthread_mutex_init(&pth->mQ, ((void *)0));
    pthread_mutex_init(&pth->mNi, ((void *)0));
    pthread_mutex_init(&pth->mT, ((void *)0));
    pthread_mutex_init(&pth->mTref, ((void *)0));
    pthread_mutex_init(&pth->mPert, ((void *)0));
    pthread_mutex_init(&pth->mH, ((void *)0));
    pthread_mutex_init(&pth->mHref, ((void *)0));
    pthread_mutex_init(&pth->mstop_threads, ((void *)0));
    pthread_mutex_init(&pth->mscreen, ((void *)0));
    pthread_mutex_init(&pth->mbuffer, ((void *)0));
    pthread_cond_init(&pth->writeBuffer, ((void *)0));
    pthread_cond_init(&pth->levAlarm, ((void *)0));
}

canonical_original_code:
void init_monitor(struct pthreadAcess *pth, struct sharedVars *vars, struct bufferControl *buffer)
{
    vars->H = 0;
    vars->Href = 0;
    vars->Ni = 0;
    vars->No = 0;
    vars->Q = 0;
    vars->T = 0;
    vars->Tref = 0;
    vars->Ta = 0;
    vars->Ti = 0;
    vars->stop_threads = 'n';
    vars->screen = 0;
    buffer->bufferRec = 0;
    buffer->bufferRead = 0;
    buffer->ndata = 0;
    pthread_mutex_init(&pth->mQ, ((void *)0));
    pthread_mutex_init(&pth->mNi, ((void *)0));
    pthread_mutex_init(&pth->mT, ((void *)0));
    pthread_mutex_init(&pth->mTref, ((void *)0));
    pthread_mutex_init(&pth->mPert, ((void *)0));
    pthread_mutex_init(&pth->mH, ((void *)0));
    pthread_mutex_init(&pth->mHref, ((void *)0));
    pthread_mutex_init(&pth->mstop_threads, ((void *)0));
    pthread_mutex_init(&pth->mscreen, ((void *)0));
    pthread_mutex_init(&pth->mbuffer, ((void *)0));
    pthread_cond_init(&pth->writeBuffer, ((void *)0));
    pthread_cond_init(&pth->levAlarm, ((void *)0));
}

variable_types: struct pthreadAcess { 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; } mQ; union pthread_mutex_t mNi; union pthread_mutex_t mT; union pthread_mutex_t mTref; union pthread_mutex_t mPert; union pthread_mutex_t mH; union pthread_mutex_t mHref; union pthread_mutex_t mstop_threads; union pthread_mutex_t mscreen; union pthread_mutex_t mbuffer; 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; } writeBuffer; union pthread_cond_t levAlarm; union pthread_mutex_t mexc; union pthread_cond_t ok2writers; union pthread_cond_t ok2readers; short rcount; short pendingw; char busy; } *

variable_types: struct sharedVars { double Ni; double No; double Q; double T; double Tref; double Ta; double Ti; double H; double Href; char screen; char stop_threads; } *

variable_types: struct bufferControl { struct sharedVars array[2]; int bufferRec; int bufferRead; int ndata; } *

user_defined_types: struct pthreadAcess { union pthread_mutex_t mQ; union pthread_mutex_t mNi; union pthread_mutex_t mT; union pthread_mutex_t mTref; union pthread_mutex_t mPert; union pthread_mutex_t mH; union pthread_mutex_t mHref; union pthread_mutex_t mstop_threads; union pthread_mutex_t mscreen; union pthread_mutex_t mbuffer; union pthread_cond_t writeBuffer; union pthread_cond_t levAlarm; union pthread_mutex_t mexc; union pthread_cond_t ok2writers; union pthread_cond_t ok2readers; short rcount; short pendingw; char busy; }

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


readGen

decompiled_code:
int __fastcall readGen(_QWORD *a1, pthread_mutex_t *a2, _QWORD *a3)
{
pthread_mutex_lock(a2);
*a3 = *a1;
return pthread_mutex_unlock(a2);
}

canonical_decompiled_code:
int __fastcall func1(_QWORD *a1, pthread_mutex_t *a2, _QWORD *a3)
{
pthread_mutex_lock(a2);
*a3 = *a1;
return pthread_mutex_unlock(a2);
}

original_code:
void readGen(double* sv, pthread_mutex_t* m, double* res)
{
    pthread_mutex_lock(m);
    *res = *sv;
    pthread_mutex_unlock(m);
}

canonical_original_code:
void readGen(double *sv, union pthread_mutex_t *m, double *res)
{
    pthread_mutex_lock(m);
    *res = *sv;
    pthread_mutex_unlock(m);
}

variable_types:
sv
double *

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

variable_types:
res
double *


setGen

decompiled_code:
int __fastcall setGen(_QWORD *a1, pthread_mutex_t *a2, _QWORD *a3)
{
pthread_mutex_lock(a2);
*a1 = *a3;
return pthread_mutex_unlock(a2);
}

canonical_decompiled_code:
int __fastcall func2(_QWORD *a1, pthread_mutex_t *a2, _QWORD *a3)
{
pthread_mutex_lock(a2);
*a1 = *a3;
return pthread_mutex_unlock(a2);
}

original_code:
void setGen(double* sv, pthread_mutex_t* m, double* value)
{
    pthread_mutex_lock(m);
    *sv = *value;
    pthread_mutex_unlock(m);
}

canonical_original_code:
void setGen(double *sv, union pthread_mutex_t *m, double *value)
{
    pthread_mutex_lock(m);
    *sv = *value;
    pthread_mutex_unlock(m);
}

variable_types:
value
double *

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


readQ

decompiled_code:
int __fastcall readQ(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen((_QWORD *)(a1 + 16), a2, a3);
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1((_QWORD *)(a1 + 16), a2, a3);
}

original_code:
void readQ(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->Q, &p->mQ, res);
}

canonical_original_code:
void readQ(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->Q, &p->mQ, res);
}

user_defined_types: struct sharedVars { double Ni; double No; double Q; double T; double Tref; double Ta; double Ti; double H; double Href; char screen; char stop_threads; }

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]; }


setQ

decompiled_code:
int __fastcall setQ(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return setGen((_QWORD *)(a1 + 16), a2, v4);
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return func2((_QWORD *)(a1 + 16), a2, v4);
}

original_code:
void setQ(SharedVars* v, PthreadAcess* p, double value)
{
    setGen(&v->Q, &p->mQ, &value);
}

canonical_original_code:
void setQ(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    setGen(&v->Q, &p->mQ, &value);
}

variable_types: value double


readNi

decompiled_code:
int __fastcall readNi(_QWORD *a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen(a1, a2 + 1, a3);
}

canonical_decompiled_code:
int __fastcall func5(_QWORD *a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1(a1, a2 + 1, a3);
}

original_code:
void readNi(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->Ni, &p->mNi, res);
}

canonical_original_code:
void readNi(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->Ni, &p->mNi, res);
}


setNi

decompiled_code:
int __fastcall setNi(double *a1, pthread_mutex_t *a2, double a3)
{
pthread_mutex_lock(a2 + 1);
*a1 = a3;
return pthread_mutex_unlock(a2 + 1);
}

canonical_decompiled_code:
int __fastcall func6(double *a1, pthread_mutex_t *a2, double a3)
{
pthread_mutex_lock(a2 + 1);
*a1 = a3;
return pthread_mutex_unlock(a2 + 1);
}

original_code:
void setNi(SharedVars* v, PthreadAcess* p, double value)
{
    pthread_mutex_lock(&p->mNi);
    v->Ni = value;
    pthread_mutex_unlock(&p->mNi);
}

canonical_original_code:
void setNi(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    pthread_mutex_lock(&p->mNi);
    v->Ni = value;
    pthread_mutex_unlock(&p->mNi);
}


readNo

decompiled_code:
int __fastcall readNo(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen((_QWORD *)(a1 + 8), a2 + 4, a3);
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1((_QWORD *)(a1 + 8), a2 + 4, a3);
}

original_code:
void readNo(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->No, &p->mPert, res);
}

canonical_original_code:
void readNo(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->No, &p->mPert, res);
}


setNo

decompiled_code:
int __fastcall setNo(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return setGen((_QWORD *)(a1 + 8), a2 + 4, v4);
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return func2((_QWORD *)(a1 + 8), a2 + 4, v4);
}

original_code:
void setNo(SharedVars* v, PthreadAcess* p, double value)
{
    setGen(&v->No, &p->mPert, &value);
}

canonical_original_code:
void setNo(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    setGen(&v->No, &p->mPert, &value);
}


readT

decompiled_code:
int __fastcall readT(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen((_QWORD *)(a1 + 24), a2 + 2, a3);
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1((_QWORD *)(a1 + 24), a2 + 2, a3);
}

original_code:
void readT(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->T, &p->mT, res);
}

canonical_original_code:
void readT(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->T, &p->mT, res);
}


setT

decompiled_code:
int __fastcall setT(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return setGen((_QWORD *)(a1 + 24), a2 + 2, v4);
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return func2((_QWORD *)(a1 + 24), a2 + 2, v4);
}

original_code:
void setT(SharedVars* v, PthreadAcess* p, double value)
{
    setGen(&v->T, &p->mT, &value);
}

canonical_original_code:
void setT(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    setGen(&v->T, &p->mT, &value);
}


readTref

decompiled_code:
int __fastcall readTref(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen((_QWORD *)(a1 + 32), a2 + 3, a3);
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1((_QWORD *)(a1 + 32), a2 + 3, a3);
}

original_code:
void readTref(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->Tref, &p->mTref, res);
}

canonical_original_code:
void readTref(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->Tref, &p->mTref, res);
}


setTref

decompiled_code:
int __fastcall setTref(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return setGen((_QWORD *)(a1 + 32), a2 + 3, v4);
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return func2((_QWORD *)(a1 + 32), a2 + 3, v4);
}

original_code:
void setTref(SharedVars* v, PthreadAcess* p, double value)
{
    setGen(&v->Tref, &p->mTref, &value);
}

canonical_original_code:
void setTref(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    setGen(&v->Tref, &p->mTref, &value);
}


readTa

decompiled_code:
int __fastcall readTa(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen((_QWORD *)(a1 + 40), a2 + 4, a3);
}

canonical_decompiled_code:
int __fastcall func13(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1((_QWORD *)(a1 + 40), a2 + 4, a3);
}

original_code:
void readTa(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->Ta, &p->mPert, res);
}

canonical_original_code:
void readTa(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->Ta, &p->mPert, res);
}


setTa

decompiled_code:
int __fastcall setTa(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return setGen((_QWORD *)(a1 + 40), a2 + 4, v4);
}

canonical_decompiled_code:
int __fastcall func14(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return func2((_QWORD *)(a1 + 40), a2 + 4, v4);
}

original_code:
void setTa(SharedVars* v, PthreadAcess* p, double value)
{
    setGen(&v->Ta, &p->mPert, &value);
}

canonical_original_code:
void setTa(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    setGen(&v->Ta, &p->mPert, &value);
}


readTi

decompiled_code:
int __fastcall readTi(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen((_QWORD *)(a1 + 48), a2 + 4, a3);
}

canonical_decompiled_code:
int __fastcall func15(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1((_QWORD *)(a1 + 48), a2 + 4, a3);
}

original_code:
void readTi(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->Ti, &p->mPert, res);
}

canonical_original_code:
void readTi(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->Ti, &p->mPert, res);
}


setTi

decompiled_code:
int __fastcall setTi(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return setGen((_QWORD *)(a1 + 48), a2 + 4, v4);
}

canonical_decompiled_code:
int __fastcall func16(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return func2((_QWORD *)(a1 + 48), a2 + 4, v4);
}

original_code:
void setTi(SharedVars* v, PthreadAcess* p, double value)
{
    setGen(&v->Ti, &p->mPert, &value);
}

canonical_original_code:
void setTi(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    setGen(&v->Ti, &p->mPert, &value);
}


readH

decompiled_code:
int __fastcall readH(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen((_QWORD *)(a1 + 56), a2 + 5, a3);
}

canonical_decompiled_code:
int __fastcall func17(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1((_QWORD *)(a1 + 56), a2 + 5, a3);
}

original_code:
void readH(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->H, &p->mH, res);
}

canonical_original_code:
void readH(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->H, &p->mH, res);
}


setH

decompiled_code:
int __fastcall setH(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return setGen((_QWORD *)(a1 + 56), a2 + 5, v4);
}

canonical_decompiled_code:
int __fastcall func18(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return func2((_QWORD *)(a1 + 56), a2 + 5, v4);
}

original_code:
void setH(SharedVars* v, PthreadAcess* p, double value)
{
    setGen(&v->H, &p->mH, &value);
}

canonical_original_code:
void setH(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    setGen(&v->H, &p->mH, &value);
}


readHref

decompiled_code:
int __fastcall readHref(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return readGen((_QWORD *)(a1 + 64), a2 + 6, a3);
}

canonical_decompiled_code:
int __fastcall func19(__int64 a1, pthread_mutex_t *a2, _QWORD *a3)
{
return func1((_QWORD *)(a1 + 64), a2 + 6, a3);
}

original_code:
void readHref(SharedVars* v, PthreadAcess* p, double* res)
{
    readGen(&v->Href, &p->mHref, res);
}

canonical_original_code:
void readHref(struct sharedVars *v, struct pthreadAcess *p, double *res)
{
    readGen(&v->Href, &p->mHref, res);
}


setHref

decompiled_code:
int __fastcall setHref(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return setGen((_QWORD *)(a1 + 64), a2 + 6, v4);
}

canonical_decompiled_code:
int __fastcall func20(__int64 a1, pthread_mutex_t *a2, double a3)
{
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = a3;
return func2((_QWORD *)(a1 + 64), a2 + 6, v4);
}

original_code:
void setHref(SharedVars* v, PthreadAcess* p, double value)
{
    setGen(&v->Href, &p->mHref, &value);
}

canonical_original_code:
void setHref(struct sharedVars *v, struct pthreadAcess *p, double value)
{
    setGen(&v->Href, &p->mHref, &value);
}


decompiled_code:
int __fastcall readstop_threads(__int64 a1, pthread_mutex_t *a2, _BYTE *a3)
{
pthread_mutex_lock(a2 + 7);
*a3 = *(_BYTE *)(a1 + 73);
return pthread_mutex_unlock(a2 + 7);
}

canonical_decompiled_code:
int __fastcall func21(__int64 a1, pthread_mutex_t *a2, _BYTE *a3)
{
pthread_mutex_lock(a2 + 7);
*a3 = *(_BYTE *)(a1 + 73);
return pthread_mutex_unlock(a2 + 7);
}

original_code:
void readstop_threads(SharedVars* v, PthreadAcess* p, char* res)
{
    pthread_mutex_lock(&p->mstop_threads);
    *res = v->stop_threads;
    pthread_mutex_unlock(&p->mstop_threads);
}

canonical_original_code:
void readstop_threads(struct sharedVars *v, struct pthreadAcess *p, char *res)
{
    pthread_mutex_lock(&p->mstop_threads);
    *res = v->stop_threads;
    pthread_mutex_unlock(&p->mstop_threads);
}

variable_types:
res
char *


decompiled_code:
int __fastcall setstop_threads(__int64 a1, pthread_mutex_t *a2, char a3)
{
pthread_mutex_lock(a2 + 7);
*(_BYTE *)(a1 + 73) = a3;
return pthread_mutex_unlock(a2 + 7);
}

canonical_decompiled_code:
int __fastcall func22(__int64 a1, pthread_mutex_t *a2, char a3)
{
pthread_mutex_lock(a2 + 7);
*(_BYTE *)(a1 + 73) = a3;
return pthread_mutex_unlock(a2 + 7);
}

original_code:
void setstop_threads(SharedVars* v, PthreadAcess* p, char value)
{
    pthread_mutex_lock(&p->mstop_threads);
    v->stop_threads = value;
    pthread_mutex_unlock(&p->mstop_threads);
}

canonical_original_code:
void setstop_threads(struct sharedVars *v, struct pthreadAcess *p, char value)
{
    pthread_mutex_lock(&p->mstop_threads);
    v->stop_threads = value;
    pthread_mutex_unlock(&p->mstop_threads);
}

variable_types: value char


readscreen

decompiled_code:
int __fastcall readscreen(__int64 a1, pthread_mutex_t *a2, _BYTE *a3)
{
pthread_mutex_lock(a2 + 8);
*a3 = *(_BYTE *)(a1 + 72);
return pthread_mutex_unlock(a2 + 8);
}

canonical_decompiled_code:
int __fastcall func23(__int64 a1, pthread_mutex_t *a2, _BYTE *a3)
{
pthread_mutex_lock(a2 + 8);
*a3 = *(_BYTE *)(a1 + 72);
return pthread_mutex_unlock(a2 + 8);
}

original_code:
void readscreen(SharedVars* v, PthreadAcess* p, char* res)
{
    pthread_mutex_lock(&p->mscreen);
    *res = v->screen;
    pthread_mutex_unlock(&p->mscreen);
}

canonical_original_code:
void readscreen(struct sharedVars *v, struct pthreadAcess *p, char *res)
{
    pthread_mutex_lock(&p->mscreen);
    *res = v->screen;
    pthread_mutex_unlock(&p->mscreen);
}


setscreen

decompiled_code:
int __fastcall setscreen(__int64 a1, pthread_mutex_t *a2, char a3)
{
pthread_mutex_lock(a2 + 8);
*(_BYTE *)(a1 + 72) = a3;
return pthread_mutex_unlock(a2 + 8);
}

canonical_decompiled_code:
int __fastcall func24(__int64 a1, pthread_mutex_t *a2, char a3)
{
pthread_mutex_lock(a2 + 8);
*(_BYTE *)(a1 + 72) = a3;
return pthread_mutex_unlock(a2 + 8);
}

original_code:
void setscreen(SharedVars* v, PthreadAcess* p, char value)
{
    pthread_mutex_lock(&p->mscreen);
    v->screen = value;
    pthread_mutex_unlock(&p->mscreen);
}

canonical_original_code:
void setscreen(struct sharedVars *v, struct pthreadAcess *p, char value)
{
    pthread_mutex_lock(&p->mscreen);
    v->screen = value;
    pthread_mutex_unlock(&p->mscreen);
}


writeBuffer

original_code:
void writeBuffer(SharedVars* vars, BufferControl* buffer, PthreadAcess* p)
{
    pthread_mutex_lock(&p->mbuffer);
    if (buffer->ndata != 2)
    {
 buffer->array[buffer->bufferRec] = *vars;
 buffer->bufferRec = (buffer->bufferRec + 1) % 2;
 buffer->ndata ++;
 pthread_cond_signal(&p->writeBuffer);
    }
    pthread_mutex_unlock(&p->mbuffer);
}

canonical_original_code:
void writeBuffer(struct sharedVars *vars, struct bufferControl *buffer, struct pthreadAcess *p)
{
    pthread_mutex_lock(&p->mbuffer);
    if (buffer->ndata != 2)
    {
 buffer->array[buffer->bufferRec] = *vars;
 buffer->bufferRec = (buffer->bufferRec + 1) % 2;
 buffer->ndata ++;
 pthread_cond_signal(&p->writeBuffer);
    }
    pthread_mutex_unlock(&p->mbuffer);
}

user_defined_types: struct bufferControl { struct sharedVars array[2]; int bufferRec; int bufferRead; int ndata; }


wakeupThreads

decompiled_code:
int __fastcall wakeupThreads(__int64 a1)
{
pthread_cond_signal((pthread_cond_t *)(a1 + 400));
return pthread_cond_signal((pthread_cond_t *)(a1 + 448));
}

canonical_decompiled_code:
int __fastcall func27(__int64 a1)
{
pthread_cond_signal((pthread_cond_t *)(a1 + 400));
return pthread_cond_signal((pthread_cond_t *)(a1 + 448));
}

original_code:
void wakeupThreads(PthreadAcess* p)
{
    pthread_cond_signal(&p->writeBuffer);
    pthread_cond_signal(&p->levAlarm);
}

canonical_original_code:
void wakeupThreads(struct pthreadAcess *p)
{
    pthread_cond_signal(&p->writeBuffer);
    pthread_cond_signal(&p->levAlarm);
}


wakeuplevAlarm

decompiled_code:
int __fastcall wakeuplevAlarm(__int64 a1)
{
return pthread_cond_signal((pthread_cond_t *)(a1 + 448));
}

canonical_decompiled_code:
int __fastcall func28(__int64 a1)
{
return pthread_cond_signal((pthread_cond_t *)(a1 + 448));
}

original_code:
void wakeuplevAlarm(PthreadAcess* p)
{
    pthread_cond_signal(&p->levAlarm);
}

canonical_original_code:
void wakeuplevAlarm(struct pthreadAcess *p)
{
    pthread_cond_signal(&p->levAlarm);
}


decompiled_code:
int __fastcall data4levAlarm(__int64 a1, __int64 a2, _QWORD *a3)
{
pthread_mutex_lock((pthread_mutex_t *)(a2 + 200));
pthread_cond_wait((pthread_cond_t *)(a2 + 448), (pthread_mutex_t *)(a2 + 200));
*a3 = *(_QWORD *)(a1 + 56);
return pthread_mutex_unlock((pthread_mutex_t *)(a2 + 200));
}

canonical_decompiled_code:
int __fastcall func29(__int64 a1, __int64 a2, _QWORD *a3)
{
pthread_mutex_lock((pthread_mutex_t *)(a2 + 200));
pthread_cond_wait((pthread_cond_t *)(a2 + 448), (pthread_mutex_t *)(a2 + 200));
*a3 = *(_QWORD *)(a1 + 56);
return pthread_mutex_unlock((pthread_mutex_t *)(a2 + 200));
}

original_code:
void data4levAlarm(SharedVars* v, PthreadAcess* p, double* aH)
{
    pthread_mutex_lock(&p->mH);
    pthread_cond_wait(&p->levAlarm, &p->mH);
    *aH = v->H;
    pthread_mutex_unlock(&p->mH);
}

canonical_original_code:
void data4levAlarm(struct sharedVars *v, struct pthreadAcess *p, double *aH)
{
    pthread_mutex_lock(&p->mH);
    pthread_cond_wait(&p->levAlarm, &p->mH);
    *aH = v->H;
    pthread_mutex_unlock(&p->mH);
}

variable_types:
aH
double *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
if ( argc != 3 )
{
puts("\n\tSao necessarios dois argumentos para execucao: endereco do servidor e porta de comunicacao.\n");
exit(1);
}
start_tasks(argv[1], argv[2], envp);
return 0;
}

original_code:
int main(int argc, char* argv[])
{
    if (argc != 3)
    {
 puts("\n\tSao necessarios dois argumentos para execucao: endereco do servidor e porta de comunicacao.\n");
 exit(1);
    }
    start_tasks(argv[1], argv[2]);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    if (argc != 3)
    {
 puts("\n\tSao necessarios dois argumentos para execucao: endereco do servidor e porta de comunicacao.\n");
 exit(1);
    }
    start_tasks(argv[1], argv[2]);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


repo: bofhbug/gpsdate

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbp
unsigned int v4; // ebx
int *v5; // rbx
const char *v6; // rax

v3 = "localhost";
openlog("gpsdate", 32, 72);
if ( argc > 1 )
v3 = argv[1];
v4 = 1;
while ( 1 )
{
printf("Attempt #%d to connect to gpsd at %s...\n", v4, v3);
if ( !(unsigned int)gps_open() )
break;
++v4;
sleep(1u);
if ( v4 == 61 )
{
v5 = __errno_location();
v6 = (const char *)gps_errstr();
syslog(3, "no gpsd running or network error: %d, %s\n", (unsigned int)*v5, v6);
closelog();
exit(1);
}
}
osmo_daemonize_isra_0(v3, "2947");
gps_stream();
while ( 1 )
gps_mainloop();
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbp
unsigned int v4; // ebx
int *v5; // rbx
const char *v6; // rax

v3 = "localhost";
openlog("gpsdate", 32, 72);
if ( argc > 1 )
v3 = argv[1];
v4 = 1;
while ( 1 )
{
printf("Attempt #%d to connect to gpsd at %s...\n", v4, v3);
if ( !(unsigned int)gps_open() )
break;
++v4;
sleep(1u);
if ( v4 == 61 )
{
v5 = __errno_location();
v6 = (const char *)gps_errstr();
syslog(3, "no gpsd running or network error: %d, %s\n", (unsigned int)*v5, v6);
closelog();
exit(1);
}
}
func8(v3, "2947");
gps_stream();
while ( 1 )
gps_mainloop();
}

original_code:
int main(int argc, char **argv)
{
 char *host = "localhost";
 int i, rc;
 openlog("gpsdate", 0x20, (9<<3));
 if (argc > 1)
  host = argv[1];
 for (i = 1; i <= 60; i++) {
  printf("Attempt #%d to connect to gpsd at %s...\n", i, host);
  rc = gps_open(host, "2947", &gpsdata);
  if (!rc)
   break;
  sleep(1);
 }
 if (rc) {
  syslog(3, "no gpsd running or network error: %d, %s\n",
   (*__errno_location ()), gps_errstr((*__errno_location ())));
  closelog();
  exit(1);
 }
 osmo_daemonize();
 gps_stream(&gpsdata, 0x000001u|0x000010u, ((void *)0));
 while (1)
  gps_mainloop(&gpsdata, 0x7fffffff, callback);
 gps_close(&gpsdata);
 closelog();
 exit(0);
}

canonical_original_code:
int main(int argc, char **argv)
{
 char *host = "localhost";
 int i; int rc;
 openlog("gpsdate", 0x20, (9<<3));
 if (argc > 1)
  host = argv[1];
 for (i = 1; i <= 60; i++) {
  printf("Attempt #%d to connect to gpsd at %s...\n", i, host);
  rc = gps_open(host, "2947", &gpsdata);
  if (!rc)
   break;
  sleep(1);
 }
 if (rc) {
  syslog(3, "no gpsd running or network error: %d, %s\n",
   (*__errno_location ()), gps_errstr((*__errno_location ())));
  closelog();
  exit(1);
 }
 osmo_daemonize();
 gps_stream(&gpsdata, 0x000001u|0x000010u, ((void *)0));
 while (1)
  gps_mainloop(&gpsdata, 0x7fffffff, callback);
 gps_close(&gpsdata);
 closelog();
 exit(0);
}

variable_types:
argv
char **

variable_types:
host
char *

variable_types: i int

variable_types: rc int