decompiled_code:
_BOOL8 __fastcall signal_go(__int64 a1, unsigned int *a2)
{
__int64 v2; // rdi

if ( !a2 )
_assert_fail("data != NULL", "remote.c", 0x163u, "signal_go");
v2 = *a2;
if ( (_DWORD)v2 == -1 )
_assert_fail("s != INVALID_SOCKET", "remote.c", 0x165u, "signal_go");
return signal_remote(v2, 3);
}

canonical_decompiled_code:
_BOOL8 __fastcall func15(__int64 a1, unsigned int *a2)
{
__int64 v2; // rdi

if ( !a2 )
_assert_fail("data != NULL", "remote.c", 0x163u, "signal_go");
v2 = *a2;
if ( (_DWORD)v2 == -1 )
_assert_fail("s != INVALID_SOCKET", "remote.c", 0x165u, "signal_go");
return func12(v2, 3);
}

original_code:
int signal_go( const struct settings *settings, void *data ) {
 int s;
 ((void) sizeof ((data != ((void *)0)) ? 1 : 0), __extension__ ({ if (data != ((void *)0)) ; else __assert_fail ("data != NULL", "remote.c", 355, __extension__ __PRETTY_FUNCTION__); }));
 s = ((struct remote_data*)data)->control_socket;
 ((void) sizeof ((s != (-1)) ? 1 : 0), __extension__ ({ if (s != (-1)) ; else __assert_fail ("s != INVALID_SOCKET", "remote.c", 357, __extension__ __PRETTY_FUNCTION__); }));
 return signal_remote( s, 3 );
}

canonical_original_code:
int signal_go(struct settings *settings, void *data) {
 int s;
 ((void) sizeof ((data != ((void *)0)) ? 1 : 0), __extension__ ({ if (data != ((void *)0)) ; else __assert_fail ("data != NULL", "remote.c", 355, __extension__ __PRETTY_FUNCTION__); }));
 s = ((struct remote_data *)data)->control_socket;
 ((void) sizeof ((s != (-1)) ? 1 : 0), __extension__ ({ if (s != (-1)) ; else __assert_fail ("s != INVALID_SOCKET", "remote.c", 357, __extension__ __PRETTY_FUNCTION__); }));
 return signal_remote( s, 3 );
}


repo: bramp/threadnetperf

decompiled_code:
__int64 __fastcall wait_ready(__int64 a1, unsigned int *a2)
{
__int64 v2; // rdi

if ( !a2 )
_assert_fail("data != NULL", "remote.c", 0x16Cu, "wait_ready");
v2 = *a2;
if ( (_DWORD)v2 == -1 )
_assert_fail("s != INVALID_SOCKET", "remote.c", 0x16Eu, "wait_ready");
return wait_remote(v2, 2u);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, unsigned int *a2)
{
__int64 v2; // rdi

if ( !a2 )
_assert_fail("data != NULL", "remote.c", 0x16Cu, "wait_ready");
v2 = *a2;
if ( (_DWORD)v2 == -1 )
_assert_fail("s != INVALID_SOCKET", "remote.c", 0x16Eu, "wait_ready");
return func13(v2, 2u);
}

original_code:
int wait_ready( const struct settings *settings, void *data ) {
 int s;
 ((void) sizeof ((data != ((void *)0)) ? 1 : 0), __extension__ ({ if (data != ((void *)0)) ; else __assert_fail ("data != NULL", "remote.c", 364, __extension__ __PRETTY_FUNCTION__); }));
 s = ((struct remote_data*)data)->control_socket;
 ((void) sizeof ((s != (-1)) ? 1 : 0), __extension__ ({ if (s != (-1)) ; else __assert_fail ("s != INVALID_SOCKET", "remote.c", 366, __extension__ __PRETTY_FUNCTION__); }));
 return wait_remote( s, 2 );
}

canonical_original_code:
int wait_ready(struct settings *settings, void *data) {
 int s;
 ((void) sizeof ((data != ((void *)0)) ? 1 : 0), __extension__ ({ if (data != ((void *)0)) ; else __assert_fail ("data != NULL", "remote.c", 364, __extension__ __PRETTY_FUNCTION__); }));
 s = ((struct remote_data *)data)->control_socket;
 ((void) sizeof ((s != (-1)) ? 1 : 0), __extension__ ({ if (s != (-1)) ; else __assert_fail ("s != INVALID_SOCKET", "remote.c", 366, __extension__ __PRETTY_FUNCTION__); }));
 return wait_remote( s, 2 );
}

variable_types: struct settings { unsigned int duration; int type; int protocol; unsigned int daemon; unsigned int verbose; unsigned int dirty; unsigned int timestamp; unsigned int disable_nagles; unsigned int reverse; unsigned int quiet; double confidence_lvl; double confidence_int; unsigned int min_iterations; unsigned int max_iterations; unsigned int message_size; unsigned int socket_size; unsigned int rate; char *server_host; unsigned short port; unsigned int tests; struct test { unsigned int clientcores; unsigned int servercores; unsigned int connections; struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; } addr; unsigned int addr_len; } *test; unsigned int clientcores; unsigned int servercores; unsigned int threaded_model; } *

variable_types:
data
void *

variable_types: s int

return_type: int

user_defined_types: struct settings { unsigned int duration; int type; int protocol; unsigned int daemon; unsigned int verbose; unsigned int dirty; unsigned int timestamp; unsigned int disable_nagles; unsigned int reverse; unsigned int quiet; double confidence_lvl; double confidence_int; unsigned int min_iterations; unsigned int max_iterations; unsigned int message_size; unsigned int socket_size; unsigned int rate; char *server_host; unsigned short port; unsigned int tests; struct test *test; unsigned int clientcores; unsigned int servercores; unsigned int threaded_model; }

user_defined_types: struct remote_data { int control_socket; int stats_socket; }

user_defined_types: struct test { unsigned int clientcores; unsigned int servercores; unsigned int connections; struct sockaddr_storage addr; unsigned int addr_len; }


decompiled_code:
__int64 __fastcall wait_go(__int64 a1, unsigned int *a2)
{
__int64 v2; // rdi

if ( !a2 )
_assert_fail("data != NULL", "remote.c", 0x175u, "wait_go");
v2 = *a2;
if ( (_DWORD)v2 == -1 )
_assert_fail("s != INVALID_SOCKET", "remote.c", 0x177u, "wait_go");
return wait_remote(v2, 3u);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, unsigned int *a2)
{
__int64 v2; // rdi

if ( !a2 )
_assert_fail("data != NULL", "remote.c", 0x175u, "wait_go");
v2 = *a2;
if ( (_DWORD)v2 == -1 )
_assert_fail("s != INVALID_SOCKET", "remote.c", 0x177u, "wait_go");
return func13(v2, 3u);
}

original_code:
int wait_go ( const struct settings *settings, void *data ) {
 int s;
 ((void) sizeof ((data != ((void *)0)) ? 1 : 0), __extension__ ({ if (data != ((void *)0)) ; else __assert_fail ("data != NULL", "remote.c", 373, __extension__ __PRETTY_FUNCTION__); }));
 s = ((struct remote_data*)data)->control_socket;
 ((void) sizeof ((s != (-1)) ? 1 : 0), __extension__ ({ if (s != (-1)) ; else __assert_fail ("s != INVALID_SOCKET", "remote.c", 375, __extension__ __PRETTY_FUNCTION__); }));
 return wait_remote( s, 3 );
}

canonical_original_code:
int wait_go(struct settings *settings, void *data) {
 int s;
 ((void) sizeof ((data != ((void *)0)) ? 1 : 0), __extension__ ({ if (data != ((void *)0)) ; else __assert_fail ("data != NULL", "remote.c", 373, __extension__ __PRETTY_FUNCTION__); }));
 s = ((struct remote_data *)data)->control_socket;
 ((void) sizeof ((s != (-1)) ? 1 : 0), __extension__ ({ if (s != (-1)) ; else __assert_fail ("s != INVALID_SOCKET", "remote.c", 375, __extension__ __PRETTY_FUNCTION__); }));
 return wait_remote( s, 3 );
}

user_defined_types: struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; }


decompiled_code:
unsigned __int64 __fastcall cpu_setup(_QWORD *a1, unsigned int a2)
{
unsigned __int64 v3; // rdi
unsigned __int64 result; // rax
unsigned int i; // ecx

*a1 = 0LL;
v3 = (unsigned __int64)(a1 + 1);
result = 0LL;
*(_QWORD *)(v3 + 112) = 0LL;
memset((void *)(v3 & 0xFFFFFFFFFFFFFFF8LL), 0, 8 * (((unsigned int)a1 - (v3 & 0xFFFFFFF8) + 128) >> 3));
for ( i = 0; a2; a2 >>= 1 )
{
if ( (a2 & 1) != 0 )
{
result = i;
if ( i <= 0x3FF )
{
result = (unsigned __int64)i >> 6;
a1[result] |= 1LL << i;
}
}
++i;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(_QWORD *a1, unsigned int a2)
{
unsigned __int64 v3; // rdi
unsigned __int64 result; // rax
unsigned int i; // ecx

*a1 = 0LL;
v3 = (unsigned __int64)(a1 + 1);
result = 0LL;
*(_QWORD *)(v3 + 112) = 0LL;
memset((void *)(v3 & 0xFFFFFFFFFFFFFFF8LL), 0, 8 * (((unsigned int)a1 - (v3 & 0xFFFFFFF8) + 128) >> 3));
for ( i = 0; a2; a2 >>= 1 )
{
if ( (a2 & 1) != 0 )
{
result = i;
if ( i <= 0x3FF )
{
result = (unsigned __int64)i >> 6;
a1[result] |= 1LL << i;
}
}
++i;
}
return result;
}

original_code:
void cpu_setup( cpu_set_t *cpu, unsigned int cores ) {
 unsigned int core = 0;
 do __builtin_memset (cpu, '\0', sizeof (cpu_set_t)); while (0);
 while ( cores > 0 ) {
  if ( cores & 1 )
   (__extension__ ({ size_t __cpu = (core); __cpu / 8 < (sizeof (cpu_set_t)) ? (((__cpu_mask *) ((cpu)->__bits))[((__cpu) / (8 * sizeof (__cpu_mask)))] |= ((__cpu_mask) 1 << ((__cpu) % (8 * sizeof (__cpu_mask))))) : 0; }));
  cores = cores >> 1;
  core++;
 }
}

canonical_original_code:
void cpu_setup(struct cpu_set_t *cpu, unsigned int cores) {
 unsigned int core = 0;
 do __builtin_memset (cpu, '\0', sizeof (cpu_set_t)); while (0);
 while ( cores > 0 ) {
  if ( cores & 1 )
   (__extension__ ({ unsigned long __cpu = (core); __cpu / 8 < (sizeof (cpu_set_t)) ? (((unsigned long *) ((cpu)->__bits))[((__cpu) / (8 * sizeof (__cpu_mask)))] |= ((unsigned long) 1 << ((__cpu) % (8 * sizeof (__cpu_mask))))) : 0; }));
  cores = cores >> 1;
  core++;
 }
}

variable_types: struct cpu_set_t { unsigned long __bits[-1]; } *

variable_types:
cores
unsigned int

variable_types:
core
unsigned int

return_type: void


decompiled_code:
__int64 __fastcall process_create_on(__pid_t *a1, void (__fastcall *a2)(__int64), __int64 a3, size_t a4, const cpu_set_t *a5)
{
__pid_t v8; // eax
unsigned int v9; // er12
__pid_t v11; // eax
int *v12; // rbx
char *v13; // rax

v8 = fork();
*a1 = v8;
if ( !v8 )
{
v11 = getpid();
*a1 = v11;
sched_setaffinity(v11, a4, a5);
a2(a3);
exit(0);
}
v9 = v8;
if ( v8 != -1 )
return 0;
v12 = _errno_location();
v13 = strerror(*v12);
fprintf(stderr, "%s:%d process_create_on() error (%d) %s\n", "threads.c", 88LL, (unsigned int)*v12, v13);
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func1(__pid_t *a1, void (__fastcall *a2)(__int64), __int64 a3, size_t a4, const cpu_set_t *a5)
{
__pid_t v8; // eax
unsigned int v9; // er12
__pid_t v11; // eax
int *v12; // rbx
char *v13; // rax

v8 = fork();
*a1 = v8;
if ( !v8 )
{
v11 = getpid();
*a1 = v11;
sched_setaffinity(v11, a4, a5);
a2(a3);
exit(0);
}
v9 = v8;
if ( v8 != -1 )
return 0;
v12 = _errno_location();
v13 = strerror(*v12);
fprintf(stderr, "%s:%d process_create_on() error (%d) %s\n", "threads.c", 88LL, (unsigned int)*v12, v13);
return v9;
}

original_code:
int process_create_on(pid_t *pid, void *(*start_routine)(void*), void *arg, size_t cpusetsize, const cpu_set_t *cpuset) {
 *pid = fork();
 if( *pid == 0) {
  *pid = getpid();
  sched_setaffinity(*pid, cpusetsize, cpuset);
  (*start_routine)(arg);
  _exit(0);
 }
 else if (*pid == -1 ) {
  fprintf(stderr, "%s:%d process_create_on() error (%d) %s\n", "threads.c", 88, (*__errno_location ()), strerror((*__errno_location ())));
  return -1;
 }
 return 0;
}

canonical_original_code:
int process_create_on(int *pid, void *(*start_routine)(void *), void *arg, unsigned long cpusetsize, struct cpu_set_t *cpuset) {
 *pid = fork();
 if( *pid == 0) {
  *pid = getpid();
  sched_setaffinity(*pid, cpusetsize, cpuset);
  (*start_routine)(arg);
  _exit(0);
 }
 else if (*pid == -1 ) {
  fprintf(stderr, "%s:%d process_create_on() error (%d) %s\n", "threads.c", 88, (*__errno_location ()), strerror((*__errno_location ())));
  return -1;
 }
 return 0;
}

variable_types:
pid
int *

variable_types:
arg
void *

variable_types:
cpusetsize
unsigned long

user_defined_types: struct cpu_set_t { unsigned long __bits[-1]; }


decompiled_code:
__int64 __fastcall pthread_create_on(pthread_t *newthread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg, size_t cpusetsize, cpu_set_t *cpuset)
{
size_t v7; // rsi
cpu_set_t *v10; // rdx
unsigned int v11; // er12
pthread_attr_t attra; // [rsp+10h] [rbp-78h] BYREF

v7 = cpusetsize;
v10 = cpuset;
if ( !attr )
{
attr = &attra;
pthread_attr_init(&attra);
v10 = cpuset;
v7 = cpusetsize;
}
if ( !v10 || (v11 = pthread_attr_setaffinity_np(attr, v7, v10)) == 0 )
{
v11 = pthread_attr_setdetachstate(attr, 0);
if ( !v11 )
{
v11 = pthread_create(newthread, attr, start_routine, arg);
if ( attr != &attra )
return v11;
LABEL_9:
pthread_attr_destroy(attr);
return v11;
}
}
if ( attr == &attra )
goto LABEL_9;
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func2(pthread_t *newthread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg, size_t cpusetsize, cpu_set_t *cpuset)
{
size_t v7; // rsi
cpu_set_t *v10; // rdx
unsigned int v11; // er12
pthread_attr_t attra; // [rsp+10h] [rbp-78h] BYREF

v7 = cpusetsize;
v10 = cpuset;
if ( !attr )
{
attr = &attra;
pthread_attr_init(&attra);
v10 = cpuset;
v7 = cpusetsize;
}
if ( !v10 || (v11 = pthread_attr_setaffinity_np(attr, v7, v10)) == 0 )
{
v11 = pthread_attr_setdetachstate(attr, 0);
if ( !v11 )
{
v11 = pthread_create(newthread, attr, start_routine, arg);
if ( attr != &attra )
return v11;
LABEL_9:
pthread_attr_destroy(attr);
return v11;
}
}
if ( attr == &attra )
goto LABEL_9;
return v11;
}

original_code:
int pthread_create_on( pthread_t *t, pthread_attr_t *attr, void *(*start_routine)(void*), void *arg, size_t cpusetsize, const cpu_set_t *cpuset) {
 pthread_attr_t thread_attr;
 int ret;
 if (attr == ((void *)0)) {
  pthread_attr_init ( &thread_attr );
  attr = &thread_attr;
 }
 if ( cpuset != ((void *)0) ) {
  ret = pthread_attr_setaffinity_np( attr, cpusetsize, cpuset );
  if (ret)
   goto cleanup;
 }
 ret = pthread_attr_setdetachstate( attr, PTHREAD_CREATE_JOINABLE);
 if (ret)
  goto cleanup;
 ret = pthread_create(t, attr, start_routine, arg);
cleanup:
 if ( attr == &thread_attr )
  pthread_attr_destroy ( &thread_attr );
 return ret;
}

canonical_original_code:
int pthread_create_on(unsigned long *t, union pthread_attr_t *attr, void *(*start_routine)(void *), void *arg, unsigned long cpusetsize, struct cpu_set_t *cpuset) {
 union pthread_attr_t thread_attr;
 int ret;
 if (attr == ((void *)0)) {
  pthread_attr_init ( &thread_attr );
  attr = &thread_attr;
 }
 if ( cpuset != ((void *)0) ) {
  ret = pthread_attr_setaffinity_np( attr, cpusetsize, cpuset );
  if (ret)
   goto cleanup;
 }
 ret = pthread_attr_setdetachstate( attr, PTHREAD_CREATE_JOINABLE);
 if (ret)
  goto cleanup;
 ret = pthread_create(t, attr, start_routine, arg);
cleanup:
 if ( attr == &thread_attr )
  pthread_attr_destroy ( &thread_attr );
 return ret;
}

variable_types:
t
unsigned long *

variable_types: union pthread_attr_t { char __size[56]; long __align; } *

variable_types: ret int


decompiled_code:
__int64 __fastcall create_thread(void *(*start_routine)(void *), void *arg, size_t cpusetsize, cpu_set_t *cpuset, int a5)
{
__int64 result; // rax

if ( !start_routine )
_assert_fail("start_routine != NULL", "threads.c", 0x87u, "create_thread");
if ( thread_count >= (unsigned __int64)thread_max_count )
{
fprintf(
stderr,
"%s:%d create_thread() can only create %ud threads\n",
"threads.c",
138LL,
(unsigned int)thread_max_count);
result = 0xFFFFFFFFLL;
}
else
{
if ( a5 )
{
if ( a5 != 1 )
_assert_fail("0", "threads.c", 0x96u, "create_thread");
result = process_create_on(
(__pid_t *)thread + 2 * thread_count,
(void (__fastcall *)(__int64))start_routine,
(__int64)arg,
cpusetsize,
cpuset);
}
else
{
result = pthread_create_on((pthread_t *)thread + thread_count, 0LL, start_routine, arg, cpusetsize, cpuset);
}
if ( !(_DWORD)result )
++thread_count;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *(*start_routine)(void *), void *arg, size_t cpusetsize, cpu_set_t *cpuset, int a5)
{
__int64 result; // rax

if ( !start_routine )
_assert_fail("start_routine != NULL", "threads.c", 0x87u, "create_thread");
if ( thread_count >= (unsigned __int64)thread_max_count )
{
fprintf(
stderr,
"%s:%d create_thread() can only create %ud threads\n",
"threads.c",
138LL,
(unsigned int)thread_max_count);
result = 0xFFFFFFFFLL;
}
else
{
if ( a5 )
{
if ( a5 != 1 )
_assert_fail("0", "threads.c", 0x96u, "create_thread");
result = func1(
(__pid_t *)thread + 2 * thread_count,
(void (__fastcall *)(__int64))start_routine,
(__int64)arg,
cpusetsize,
cpuset);
}
else
{
result = func2((pthread_t *)thread + thread_count, 0LL, start_routine, arg, cpusetsize, cpuset);
}
if ( !(_DWORD)result )
++thread_count;
}
return result;
}

original_code:
int create_thread( void *(*start_routine)(void*), void *arg, size_t cpusetsize, const cpu_set_t *cpuset, unsigned int threaded_model ) {
 int ret = -1;
 ((void) sizeof ((start_routine != ((void *)0)) ? 1 : 0), __extension__ ({ if (start_routine != ((void *)0)) ; else __assert_fail ("start_routine != NULL", "threads.c", 135, __extension__ __PRETTY_FUNCTION__); }));
 if ( thread_count >= thread_max_count ) {
  fprintf(stderr, "%s:%d create_thread() can only create %ud threads\n", "threads.c", 138, (unsigned int) thread_max_count );
  return -1;
 }
 switch ( threaded_model ) {
  case 0 :
   ret = pthread_create_on( &thread[thread_count].tid, ((void *)0), start_routine, arg , cpusetsize, cpuset);
   break;
  case 1 :
   ret = process_create_on( &thread[thread_count].pid, start_routine, arg, cpusetsize, cpuset);
   break;
  default:
   ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "threads.c", 150, __extension__ __PRETTY_FUNCTION__); }));
 }
 if ( !ret )
  thread_count++;
 return ret;
}

canonical_original_code:
int create_thread(void *(*start_routine)(void *), void *arg, unsigned long cpusetsize, struct cpu_set_t *cpuset, unsigned int threaded_model) {
 int ret = -1;
 ((void) sizeof ((start_routine != ((void *)0)) ? 1 : 0), __extension__ ({ if (start_routine != ((void *)0)) ; else __assert_fail ("start_routine != NULL", "threads.c", 135, __extension__ __PRETTY_FUNCTION__); }));
 if ( thread_count >= thread_max_count ) {
  fprintf(stderr, "%s:%d create_thread() can only create %ud threads\n", "threads.c", 138, (unsigned int) thread_max_count );
  return -1;
 }
 switch ( threaded_model ) {
  case 0 :
   ret = pthread_create_on( &thread[thread_count].tid, ((void *)0), start_routine, arg , cpusetsize, cpuset);
   break;
  case 1 :
   ret = process_create_on( &thread[thread_count].pid, start_routine, arg, cpusetsize, cpuset);
   break;
  default:
   ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "threads.c", 150, __extension__ __PRETTY_FUNCTION__); }));
 }
 if ( !ret )
  thread_count++;
 return ret;
}


decompiled_code:
int __fastcall send_stats_from_thread(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
unsigned int v7; // eax
unsigned int v8; // ebp
int v9; // eax
int result; // eax
int *v11; // rbx
char *v12; // rax
int *v13; // rbx
char *v14; // rax
int *v15; // rbx
char *v16; // rax
int *v17; // rbx
char *v18; // rax
struct sockaddr v19[8]; // [rsp+0h] [rbp-88h] BYREF

v7 = socket(1, 2, 0);
if ( v7 == -1 )
{
v13 = _errno_location();
v14 = strerror(*v13);
result = fprintf(stderr, "%s:%d socket() error (%d) %s\n", "threads.c", 168LL, (unsigned int)*v13, v14);
}
else
{
v8 = v7;
if ( (unsigned int)set_socket_timeout(v7, 5000LL) )
{
v11 = _errno_location();
v12 = strerror(*v11);
fprintf(stderr, "%s:%d set_socket_timeout() error (%d) %s\n", "threads.c", 173LL, (unsigned int)*v11, v12);
}
else
{
v19[0].sa_family = 1;
strcpy(v19[0].sa_data, ipc_sock_name);
v9 = strlen(v19[0].sa_data);
if ( connect(v8, v19, v9 + 2) == -1 )
{
v15 = _errno_location();
v16 = strerror(*v15);
fprintf(stderr, "%s:%d connect() error (%d) %s\n", "threads.c", 186LL, (unsigned int)*v15, v16);
}
else if ( (unsigned int)send_results(v8, &a7) )
{
v17 = _errno_location();
v18 = strerror(*v17);
fprintf(stderr, "%s:%d send_results() error (%d) %s\n", "threads.c", 191LL, (unsigned int)*v17, v18);
}
}
result = close(v8);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
unsigned int v7; // eax
unsigned int v8; // ebp
int v9; // eax
int result; // eax
int *v11; // rbx
char *v12; // rax
int *v13; // rbx
char *v14; // rax
int *v15; // rbx
char *v16; // rax
int *v17; // rbx
char *v18; // rax
struct sockaddr v19[8]; // [rsp+0h] [rbp-88h] BYREF

v7 = socket(1, 2, 0);
if ( v7 == -1 )
{
v13 = _errno_location();
v14 = strerror(*v13);
result = fprintf(stderr, "%s:%d socket() error (%d) %s\n", "threads.c", 168LL, (unsigned int)*v13, v14);
}
else
{
v8 = v7;
if ( (unsigned int)set_socket_timeout(v7, 5000LL) )
{
v11 = _errno_location();
v12 = strerror(*v11);
fprintf(stderr, "%s:%d set_socket_timeout() error (%d) %s\n", "threads.c", 173LL, (unsigned int)*v11, v12);
}
else
{
v19[0].sa_family = 1;
strcpy(v19[0].sa_data, ipc_sock_name);
v9 = strlen(v19[0].sa_data);
if ( connect(v8, v19, v9 + 2) == -1 )
{
v15 = _errno_location();
v16 = strerror(*v15);
fprintf(stderr, "%s:%d connect() error (%d) %s\n", "threads.c", 186LL, (unsigned int)*v15, v16);
}
else if ( (unsigned int)send_results(v8, &a7) )
{
v17 = _errno_location();
v18 = strerror(*v17);
fprintf(stderr, "%s:%d send_results() error (%d) %s\n", "threads.c", 191LL, (unsigned int)*v17, v18);
}
}
result = close(v8);
}
return result;
}

original_code:
void send_stats_from_thread(struct stats stats) {
 unsigned int sock_len;
 struct sockaddr_un ipc_socket;
 int s;
 s = socket( 1, SOCK_DGRAM, 0);
 if ( s == (-1) ) {
  fprintf(stderr, "%s:%d socket() error (%d) %s\n", "threads.c", 168, (*__errno_location ()), strerror((*__errno_location ())) );
  return;
 }
 if ( set_socket_timeout(s, 5000) ) {
  fprintf(stderr, "%s:%d set_socket_timeout() error (%d) %s\n", "threads.c", 173, (*__errno_location ()), strerror((*__errno_location ())) );
  goto cleanup;
 }
 ipc_socket.sun_family = 1;
 sprintf(ipc_socket.sun_path , "%s", ipc_sock_name);
 sock_len = strlen(ipc_socket.sun_path) + sizeof(ipc_socket.sun_family);
 if ( connect( s,(struct sockaddr *) &ipc_socket, sock_len) == (-1)) {
  fprintf(stderr, "%s:%d connect() error (%d) %s\n", "threads.c", 186, (*__errno_location ()), strerror((*__errno_location ())));
  goto cleanup;
 }
 if ( send_results(s, &stats) ) {
  fprintf(stderr, "%s:%d send_results() error (%d) %s\n", "threads.c", 191, (*__errno_location ()), strerror((*__errno_location ())) );
  goto cleanup;
 }
cleanup:
 close(s);
}

variable_types: struct stats { unsigned int cores; unsigned long long bytes_received; unsigned long long pkts_received; unsigned long long pkts_time; unsigned long long timestamps; unsigned long long duration; }

variable_types: struct sockaddr_un { unsigned short sun_family; char sun_path[108]; }

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


decompiled_code:
__int64 create_stats_socket()
{
unsigned int v0; // eax
unsigned int v1; // er12
int v2; // ebx
int *v4; // rbx
char *v5; // rax
int v6; // edi
int *v7; // rbx
char *v8; // rax
int *v9; // rbx
char *v10; // rax
struct sockaddr v11[8]; // [rsp+0h] [rbp-88h] BYREF

v0 = socket(1, 2, 0);
v1 = v0;
if ( v0 == -1 )
{
v7 = _errno_location();
v8 = strerror(*v7);
fprintf(stderr, "%s:%d socket() error (%d) %s\n", "threads.c", 206LL, (unsigned int)*v7, v8);
return v1;
}
if ( (unsigned int)set_socket_timeout(v0, 5000LL) )
{
v4 = _errno_location();
v5 = strerror(*v4);
fprintf(stderr, "%s:%d set_socket_timeout() error (%d) %s\n", "threads.c", 211LL, (unsigned int)*v4, v5);
LABEL_6:
unlink(ipc_sock_name);
v6 = v1;
v1 = -1;
close(v6);
return v1;
}
v11[0].sa_family = 1;
ipc_sock_name = tempnam(0LL, "threadnetperf");
strcpy(v11[0].sa_data, ipc_sock_name);
v2 = strlen(v11[0].sa_data);
unlink(v11[0].sa_data);
if ( bind(v1, v11, v2 + 2) == -1 )
{
v9 = _errno_location();
v10 = strerror(*v9);
fprintf(stderr, "%s:%d bind() error (%d) %s\n", "threads.c", 224LL, (unsigned int)*v9, v10);
goto LABEL_6;
}
return v1;
}

canonical_decompiled_code:
__int64 func5()
{
unsigned int v0; // eax
unsigned int v1; // er12
int v2; // ebx
int *v4; // rbx
char *v5; // rax
int v6; // edi
int *v7; // rbx
char *v8; // rax
int *v9; // rbx
char *v10; // rax
struct sockaddr v11[8]; // [rsp+0h] [rbp-88h] BYREF

v0 = socket(1, 2, 0);
v1 = v0;
if ( v0 == -1 )
{
v7 = _errno_location();
v8 = strerror(*v7);
fprintf(stderr, "%s:%d socket() error (%d) %s\n", "threads.c", 206LL, (unsigned int)*v7, v8);
return v1;
}
if ( (unsigned int)set_socket_timeout(v0, 5000LL) )
{
v4 = _errno_location();
v5 = strerror(*v4);
fprintf(stderr, "%s:%d set_socket_timeout() error (%d) %s\n", "threads.c", 211LL, (unsigned int)*v4, v5);
LABEL_6:
unlink(ipc_sock_name);
v6 = v1;
v1 = -1;
close(v6);
return v1;
}
v11[0].sa_family = 1;
ipc_sock_name = tempnam(0LL, "threadnetperf");
strcpy(v11[0].sa_data, ipc_sock_name);
v2 = strlen(v11[0].sa_data);
unlink(v11[0].sa_data);
if ( bind(v1, v11, v2 + 2) == -1 )
{
v9 = _errno_location();
v10 = strerror(*v9);
fprintf(stderr, "%s:%d bind() error (%d) %s\n", "threads.c", 224LL, (unsigned int)*v9, v10);
goto LABEL_6;
}
return v1;
}

original_code:
int create_stats_socket() {
 struct sockaddr_un ipc_socket;
 int sock_len;
 int s = socket( 1, SOCK_DGRAM, 0);
 if ( s == (-1) ) {
  fprintf(stderr, "%s:%d socket() error (%d) %s\n", "threads.c", 206, (*__errno_location ()), strerror((*__errno_location ())) );
  return (-1);
 }
 if ( set_socket_timeout(s, 5000) ) {
  fprintf(stderr, "%s:%d set_socket_timeout() error (%d) %s\n", "threads.c", 211, (*__errno_location ()), strerror((*__errno_location ())) );
  goto cleanup;
 }
 ipc_socket.sun_family = 1;
 ipc_sock_name = tempnam(((void *)0), "threadnetperf");
 sprintf(ipc_socket.sun_path, "%s", ipc_sock_name);
 sock_len = strlen(ipc_socket.sun_path) + sizeof(ipc_socket.sun_family);
 unlink(ipc_socket.sun_path);
 if ( bind( s, &ipc_socket, sock_len) == (-1)) {
  fprintf(stderr, "%s:%d bind() error (%d) %s\n", "threads.c", 224, (*__errno_location ()), strerror((*__errno_location ())) );
  goto cleanup;
 }
 return s;
cleanup:
 unlink(ipc_sock_name);
 close(s);
 return (-1);
}

user_defined_types: struct sockaddr_un { unsigned short sun_family; char sun_path[108]; }


decompiled_code:
__int64 __fastcall thread_join_all(int a1)
{
__int64 v1; // rax
pthread_t *v2; // rax
int stat_loc[3]; // [rsp+0h] [rbp-Ch] BYREF

v1 = thread_count;
if ( !thread_count )
return 0LL;
do
{
while ( 1 )
{
thread_count = v1 - 1;
v2 = (pthread_t *)((char *)thread + 8 * v1 - 8);
if ( a1 )
break;
pthread_join(*v2, 0LL);
v1 = thread_count;
if ( !thread_count )
return 0LL;
}
waitpid(*(_DWORD *)v2, stat_loc, 0);
v1 = thread_count;
}
while ( thread_count );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
__int64 v1; // rax
pthread_t *v2; // rax
int stat_loc[3]; // [rsp+0h] [rbp-Ch] BYREF

v1 = thread_count;
if ( !thread_count )
return 0LL;
do
{
while ( 1 )
{
thread_count = v1 - 1;
v2 = (pthread_t *)((char *)thread + 8 * v1 - 8);
if ( a1 )
break;
pthread_join(*v2, 0LL);
v1 = thread_count;
if ( !thread_count )
return 0LL;
}
waitpid(*(_DWORD *)v2, stat_loc, 0);
v1 = thread_count;
}
while ( thread_count );
return 0LL;
}

original_code:
int thread_join_all(int threaded_model) {
 while (thread_count > 0) {
  thread_count--;
  if( threaded_model == 0 ) {
   pthread_join( thread[thread_count].tid, ((void *)0) );
  } else {
   int status;
   waitpid(thread[thread_count].pid, &status, 0);
  }
 }
 ((void) sizeof ((thread_count == 0) ? 1 : 0), __extension__ ({ if (thread_count == 0) ; else __assert_fail ("thread_count == 0", "threads.c", 250, __extension__ __PRETTY_FUNCTION__); }));
 return 0;
}

variable_types: status int


decompiled_code:
__int64 __fastcall thread_collect_results(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64, char *, __int64), __int64 a4)
{
unsigned int v4; // er15
unsigned int v6; // ebx
unsigned int v7; // er14
unsigned int v8; // eax
char v11[104]; // [rsp+10h] [rbp-68h] BYREF

if ( !a1 )
_assert_fail("settings != NULL", "threads.c", 0x102u, "thread_collect_results");
if ( !a2 )
_assert_fail("total_stats != NULL", "threads.c", 0x103u, "thread_collect_results");
v4 = *(_DWORD *)(a4 + 4);
if ( v4 == -1 )
_assert_fail("s != INVALID_SOCKET", "threads.c", 0x106u, "thread_collect_results");
if ( (*(_BYTE *)(a1 + 12) & 2) != 0 )
printf("Collecting %u results\n", *(unsigned int *)(a1 + 84));
v6 = 0;
if ( !*(_DWORD *)(a1 + 84) )
return 0;
do
{
if ( (unsigned int)read_results(v4, v11) )
{
fprintf(stderr, "%s:%d read_results() error\n", "threads.c", 271LL);
return (unsigned int)-1;
}
v7 = a3(a1, v11, a4);
if ( v7 )
{
fprintf(stderr, "%s:%d print_results() error\n", "threads.c", 276LL);
return (unsigned int)-1;
}
++v6;
stats_add(a2, v11);
v8 = *(_DWORD *)(a1 + 84);
}
while ( v8 > v6 );
if ( v8 <= 1 )
return 0;
*(_QWORD *)(a2 + 40) /= (unsigned __int64)v8;
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64, char *, __int64), __int64 a4)
{
unsigned int v4; // er15
unsigned int v6; // ebx
unsigned int v7; // er14
unsigned int v8; // eax
char v11[104]; // [rsp+10h] [rbp-68h] BYREF

if ( !a1 )
_assert_fail("settings != NULL", "threads.c", 0x102u, "thread_collect_results");
if ( !a2 )
_assert_fail("total_stats != NULL", "threads.c", 0x103u, "thread_collect_results");
v4 = *(_DWORD *)(a4 + 4);
if ( v4 == -1 )
_assert_fail("s != INVALID_SOCKET", "threads.c", 0x106u, "thread_collect_results");
if ( (*(_BYTE *)(a1 + 12) & 2) != 0 )
printf("Collecting %u results\n", *(unsigned int *)(a1 + 84));
v6 = 0;
if ( !*(_DWORD *)(a1 + 84) )
return 0;
do
{
if ( (unsigned int)read_results(v4, v11) )
{
fprintf(stderr, "%s:%d read_results() error\n", "threads.c", 271LL);
return (unsigned int)-1;
}
v7 = a3(a1, v11, a4);
if ( v7 )
{
fprintf(stderr, "%s:%d print_results() error\n", "threads.c", 276LL);
return (unsigned int)-1;
}
++v6;
stats_add(a2, v11);
v8 = *(_DWORD *)(a1 + 84);
}
while ( v8 > v6 );
if ( v8 <= 1 )
return 0;
*(_QWORD *)(a2 + 40) /= (unsigned __int64)v8;
return v7;
}

original_code:
int thread_collect_results(const struct settings *settings, struct stats *total_stats, int (*print_results)(const struct settings *, const struct stats *, void *), void *data) {
 unsigned int i = 0;
 int s;
 ((void) sizeof ((settings != ((void *)0)) ? 1 : 0), __extension__ ({ if (settings != ((void *)0)) ; else __assert_fail ("settings != NULL", "threads.c", 258, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((total_stats != ((void *)0)) ? 1 : 0), __extension__ ({ if (total_stats != ((void *)0)) ; else __assert_fail ("total_stats != NULL", "threads.c", 259, __extension__ __PRETTY_FUNCTION__); }));
 s = ((struct remote_data*)data)->stats_socket;
 ((void) sizeof ((s != (-1)) ? 1 : 0), __extension__ ({ if (s != (-1)) ; else __assert_fail ("s != INVALID_SOCKET", "threads.c", 262, __extension__ __PRETTY_FUNCTION__); }));
 if ( settings->verbose )
  printf("Collecting %u results\n", settings->servercores);
 for ( ; i < settings->servercores; i++ ) {
  struct stats stats;
  if ( read_results(s, &stats) != 0 ) {
   fprintf(stderr, "%s:%d read_results() error\n", "threads.c", 271 );
   return -1;
  }
  if ( print_results(settings, &stats, data) ) {
   fprintf(stderr, "%s:%d print_results() error\n", "threads.c", 276 );
   return -1;
  }
  stats_add( total_stats, &stats );
 }
 if ( settings->servercores > 1 )
  total_stats->duration /= settings->servercores;
 return 0;
}

canonical_original_code:
int thread_collect_results(struct settings *settings, struct stats *total_stats, int (*print_results)(struct settings *, struct stats *, void *), void *data) {
 unsigned int i = 0;
 int s;
 ((void) sizeof ((settings != ((void *)0)) ? 1 : 0), __extension__ ({ if (settings != ((void *)0)) ; else __assert_fail ("settings != NULL", "threads.c", 258, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((total_stats != ((void *)0)) ? 1 : 0), __extension__ ({ if (total_stats != ((void *)0)) ; else __assert_fail ("total_stats != NULL", "threads.c", 259, __extension__ __PRETTY_FUNCTION__); }));
 s = ((struct remote_data *)data)->stats_socket;
 ((void) sizeof ((s != (-1)) ? 1 : 0), __extension__ ({ if (s != (-1)) ; else __assert_fail ("s != INVALID_SOCKET", "threads.c", 262, __extension__ __PRETTY_FUNCTION__); }));
 if ( settings->verbose )
  printf("Collecting %u results\n", settings->servercores);
 for ( ; i < settings->servercores; i++ ) {
  struct stats stats;
  if ( read_results(s, &stats) != 0 ) {
   fprintf(stderr, "%s:%d read_results() error\n", "threads.c", 271 );
   return -1;
  }
  if ( print_results(settings, &stats, data) ) {
   fprintf(stderr, "%s:%d print_results() error\n", "threads.c", 276 );
   return -1;
  }
  stats_add( total_stats, &stats );
 }
 if ( settings->servercores > 1 )
  total_stats->duration /= settings->servercores;
 return 0;
}

variable_types: struct stats { unsigned int cores; unsigned long long bytes_received; unsigned long long pkts_received; unsigned long long pkts_time; unsigned long long timestamps; unsigned long long duration; } *

variable_types: int (*)(struct settings *, struct stats *, void *)

variable_types:
i
unsigned int


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

if ( thread )
_assert_fail("thread == NULL", "threads.c", 0x124u, "thread_alloc");
if ( thread_count )
_assert_fail("thread_count == 0", "threads.c", 0x125u, "thread_alloc");
thread = calloc(a1, 8uLL);
if ( !thread )
return 0xFFFFFFFFLL;
thread_max_count = a1;
result = 0LL;
thread_count = 0LL;
return result;
}

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

if ( thread )
_assert_fail("thread == NULL", "threads.c", 0x124u, "thread_alloc");
if ( thread_count )
_assert_fail("thread_count == 0", "threads.c", 0x125u, "thread_alloc");
thread = calloc(a1, 8uLL);
if ( !thread )
return 0xFFFFFFFFLL;
thread_max_count = a1;
result = 0LL;
thread_count = 0LL;
return result;
}

original_code:
int thread_alloc(size_t count) {
 ((void) sizeof ((thread == ((void *)0)) ? 1 : 0), __extension__ ({ if (thread == ((void *)0)) ; else __assert_fail ("thread == NULL", "threads.c", 292, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((thread_count == 0) ? 1 : 0), __extension__ ({ if (thread_count == 0) ; else __assert_fail ("thread_count == 0", "threads.c", 293, __extension__ __PRETTY_FUNCTION__); }));
 thread = calloc(count, sizeof(*thread));
 if ( !thread )
  return -1;
 thread_max_count = count;
 thread_count = 0;
 return 0;
}

canonical_original_code:
int thread_alloc(unsigned long count) {
 ((void) sizeof ((thread == ((void *)0)) ? 1 : 0), __extension__ ({ if (thread == ((void *)0)) ; else __assert_fail ("thread == NULL", "threads.c", 292, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((thread_count == 0) ? 1 : 0), __extension__ ({ if (thread_count == 0) ; else __assert_fail ("thread_count == 0", "threads.c", 293, __extension__ __PRETTY_FUNCTION__); }));
 thread = calloc(count, sizeof(*thread));
 if ( !thread )
  return -1;
 thread_max_count = count;
 thread_count = 0;
 return 0;
}

variable_types:
count
unsigned long


decompiled_code:
void threads_clear()
{
free(thread);
thread = 0LL;
thread_count = 0LL;
thread_max_count = 0LL;
}

canonical_decompiled_code:
void func9()
{
free(thread);
thread = 0LL;
thread_count = 0LL;
thread_max_count = 0LL;
}

original_code:
void threads_clear() {
 free ( thread );
 thread = ((void *)0);
 thread_count = 0;
 thread_max_count = 0;
}


decompiled_code:
int __fastcall threads_signal_parent(unsigned int a1, int a2)
{
__pid_t v2; // eax
int result; // eax
__pid_t v4; // eax

if ( a2 == 1 )
{
v4 = getppid();
result = threads_signal(v4, a1);
}
else
{
if ( a2 )
_assert_fail("0", "threads.c", 0x14Au, "threads_signal_parent");
v2 = getpid();
result = threads_signal(v2, a1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func11(unsigned int a1, int a2)
{
__pid_t v2; // eax
int result; // eax
__pid_t v4; // eax

if ( a2 == 1 )
{
v4 = getppid();
result = func10(v4, a1);
}
else
{
if ( a2 )
_assert_fail("0", "threads.c", 0x14Au, "threads_signal_parent");
v2 = getpid();
result = func10(v2, a1);
}
return result;
}

original_code:
void threads_signal_parent(int type, int threaded_model) {
 if ( threaded_model == 1 )
  threads_signal(getppid(), type);
 else if ( threaded_model == 0 )
  threads_signal(getpid(), type);
 else
  ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "threads.c", 330, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: type int


decompiled_code:
void __fastcall threads_signal_all(unsigned int a1, int a2)
{
__pid_t v3; // eax
unsigned __int64 v4; // rbx
__pid_t v5; // edi

if ( a2 == 1 )
{
if ( thread_count )
{
v4 = 0LL;
do
{
v5 = *((_DWORD *)thread + 2 * v4++);
threads_signal(v5, a1);
}
while ( thread_count > v4 );
}
}
else
{
if ( a2 )
_assert_fail("0", "threads.c", 0x156u, "threads_signal_all");
v3 = getpid();
threads_signal(v3, a1);
}
}

canonical_decompiled_code:
void __fastcall func12(unsigned int a1, int a2)
{
__pid_t v3; // eax
unsigned __int64 v4; // rbx
__pid_t v5; // edi

if ( a2 == 1 )
{
if ( thread_count )
{
v4 = 0LL;
do
{
v5 = *((_DWORD *)thread + 2 * v4++);
func10(v5, a1);
}
while ( thread_count > v4 );
}
}
else
{
if ( a2 )
_assert_fail("0", "threads.c", 0x156u, "threads_signal_all");
v3 = getpid();
func10(v3, a1);
}
}

original_code:
void threads_signal_all(int type, int threaded_model) {
 if( threaded_model == 1 ) {
  int i;
  for(i=0; i<thread_count; i++) {
   threads_signal(thread[i].pid, type);
  }
 } else if ( threaded_model == 0 ) {
  threads_signal(getpid(), type);
 } else
  ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "threads.c", 342, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: i int


decompiled_code:
__int64 __fastcall pthread_mutex_lock_block_signal(pthread_mutex_t *mutex, int signo)
{
unsigned int v2; // er12
int *v4; // rbp
char *v5; // rax
__int64 v6; // r8
__int64 v7; // rcx
const char *v8; // r9
int *v9; // rbp
char *v10; // rax
sigset_t v11; // [rsp+0h] [rbp-98h] BYREF

sigemptyset(&v11);
if ( sigaddset(&v11, signo) )
{
v2 = -1;
fprintf(stderr, "%s:%d sigaddset() error\n", "threads.c", 356LL);
return v2;
}
if ( pthread_sigmask(0, &v11, 0LL) )
{
v9 = _errno_location();
v10 = strerror(*v9);
v6 = (unsigned int)*v9;
v7 = 360LL;
v8 = v10;
goto LABEL_7;
}
v2 = pthread_mutex_lock(mutex);
if ( v2 && pthread_sigmask(1, &v11, 0LL) )
{
v4 = _errno_location();
v5 = strerror(*v4);
v6 = (unsigned int)*v4;
v7 = 367LL;
v8 = v5;
LABEL_7:
v2 = -1;
fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", v7, v6, v8);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func13(pthread_mutex_t *mutex, int signo)
{
unsigned int v2; // er12
int *v4; // rbp
char *v5; // rax
__int64 v6; // r8
__int64 v7; // rcx
const char *v8; // r9
int *v9; // rbp
char *v10; // rax
sigset_t v11; // [rsp+0h] [rbp-98h] BYREF

sigemptyset(&v11);
if ( sigaddset(&v11, signo) )
{
v2 = -1;
fprintf(stderr, "%s:%d sigaddset() error\n", "threads.c", 356LL);
return v2;
}
if ( pthread_sigmask(0, &v11, 0LL) )
{
v9 = _errno_location();
v10 = strerror(*v9);
v6 = (unsigned int)*v9;
v7 = 360LL;
v8 = v10;
goto LABEL_7;
}
v2 = pthread_mutex_lock(mutex);
if ( v2 && pthread_sigmask(1, &v11, 0LL) )
{
v4 = _errno_location();
v5 = strerror(*v4);
v6 = (unsigned int)*v4;
v7 = 367LL;
v8 = v5;
LABEL_7:
v2 = -1;
fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", v7, v6, v8);
}
return v2;
}

original_code:
int pthread_mutex_lock_block_signal (pthread_mutex_t *mutex, int signum) {
 int ret;
 sigset_t set;
 sigemptyset(&set);
 if ( sigaddset(&set, signum) ) {
  fprintf(stderr, "%s:%d sigaddset() error\n", "threads.c", 356 );
  return -1;
 }
 if ( pthread_sigmask( 0, &set, ((void *)0)) ) {
  fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", 360, (*__errno_location ()), strerror((*__errno_location ())) );
  return -1;
 }
 ret = pthread_mutex_lock(mutex);
 if ( ret ) {
  if ( pthread_sigmask( 1, &set, ((void *)0)) ) {
   fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", 367, (*__errno_location ()), strerror((*__errno_location ())) );
   return -1;
  }
 }
 return ret;
}

canonical_original_code:
int pthread_mutex_lock_block_signal(union pthread_mutex_t *mutex, int signum) {
 int ret;
 struct __sigset_t set;
 sigemptyset(&set);
 if ( sigaddset(&set, signum) ) {
  fprintf(stderr, "%s:%d sigaddset() error\n", "threads.c", 356 );
  return -1;
 }
 if ( pthread_sigmask( 0, &set, ((void *)0)) ) {
  fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", 360, (*__errno_location ()), strerror((*__errno_location ())) );
  return -1;
 }
 ret = pthread_mutex_lock(mutex);
 if ( ret ) {
  if ( pthread_sigmask( 1, &set, ((void *)0)) ) {
   fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", 367, (*__errno_location ()), strerror((*__errno_location ())) );
   return -1;
  }
 }
 return ret;
}

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: signum int

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

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:
int __fastcall pthread_mutex_unlock_block_signal(pthread_mutex_t *mutex, int signo)
{
int result; // eax
int *v3; // rbp
char *v4; // rax
sigset_t v5; // [rsp+0h] [rbp-98h] BYREF

sigemptyset(&v5);
if ( sigaddset(&v5, signo) )
{
fprintf(stderr, "%s:%d sigaddset() error\n", "threads.c", 385LL);
result = -1;
}
else
{
result = pthread_mutex_unlock(mutex);
if ( !result )
{
result = pthread_sigmask(1, &v5, 0LL);
if ( result )
{
v3 = _errno_location();
v4 = strerror(*v3);
fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", 392LL, (unsigned int)*v3, v4);
result = -1;
}
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func14(pthread_mutex_t *mutex, int signo)
{
int result; // eax
int *v3; // rbp
char *v4; // rax
sigset_t v5; // [rsp+0h] [rbp-98h] BYREF

sigemptyset(&v5);
if ( sigaddset(&v5, signo) )
{
fprintf(stderr, "%s:%d sigaddset() error\n", "threads.c", 385LL);
result = -1;
}
else
{
result = pthread_mutex_unlock(mutex);
if ( !result )
{
result = pthread_sigmask(1, &v5, 0LL);
if ( result )
{
v3 = _errno_location();
v4 = strerror(*v3);
fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", 392LL, (unsigned int)*v3, v4);
result = -1;
}
}
}
return result;
}

original_code:
int pthread_mutex_unlock_block_signal (pthread_mutex_t *mutex, int signum) {
 int ret;
 sigset_t set;
 sigemptyset(&set);
 if ( sigaddset(&set, signum) ) {
  fprintf(stderr, "%s:%d sigaddset() error\n", "threads.c", 385 );
  return -1;
 }
 ret = pthread_mutex_unlock(mutex);
 if ( !ret ) {
  if ( pthread_sigmask( 1, &set, ((void *)0)) ) {
   fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", 392, (*__errno_location ()), strerror((*__errno_location ())) );
   return -1;
  }
 }
 return ret;
}

canonical_original_code:
int pthread_mutex_unlock_block_signal(union pthread_mutex_t *mutex, int signum) {
 int ret;
 struct __sigset_t set;
 sigemptyset(&set);
 if ( sigaddset(&set, signum) ) {
  fprintf(stderr, "%s:%d sigaddset() error\n", "threads.c", 385 );
  return -1;
 }
 ret = pthread_mutex_unlock(mutex);
 if ( !ret ) {
  if ( pthread_sigmask( 1, &set, ((void *)0)) ) {
   fprintf(stderr, "%s:%d pthread_sigmask() error (%d) %s\n", "threads.c", 392, (*__errno_location ()), strerror((*__errno_location ())) );
   return -1;
  }
 }
 return ret;
}

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

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


decompiled_code:
__int64 __fastcall count_client_cores(int *a1, unsigned int a2)
{
_DWORD *v3; // rdi
int *v4; // r8
__int64 v5; // rdx
int v6; // ecx
unsigned int v7; // er12
__int64 v8; // rax

if ( !a2 )
return 0LL;
if ( !a1 )
_assert_fail("test != NULL", "common.c", 0x1Cu, "count_client_cores");
v3 = calloc(a2, 4uLL);
if ( !v3 )
return (unsigned int)-1;
v4 = a1;
v5 = 0LL;
do
{
v6 = *v4;
v7 = v5;
v8 = 0LL;
if ( v5 )
{
while ( v3[v8] != v6 )
{
if ( ++v8 == v5 )
goto LABEL_10;
}
if ( (unsigned int)v8 < (unsigned int)v5 )
break;
}
LABEL_10:
v3[v5++] = v6;
++v7;
v4 += 38;
}
while ( v5 != a2 );
free(v3);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, unsigned int a2)
{
_DWORD *v3; // rdi
int *v4; // r8
__int64 v5; // rdx
int v6; // ecx
unsigned int v7; // er12
__int64 v8; // rax

if ( !a2 )
return 0LL;
if ( !a1 )
_assert_fail("test != NULL", "common.c", 0x1Cu, "count_client_cores");
v3 = calloc(a2, 4uLL);
if ( !v3 )
return (unsigned int)-1;
v4 = a1;
v5 = 0LL;
do
{
v6 = *v4;
v7 = v5;
v8 = 0LL;
if ( v5 )
{
while ( v3[v8] != v6 )
{
if ( ++v8 == v5 )
goto LABEL_10;
}
if ( (unsigned int)v8 < (unsigned int)v5 )
break;
}
LABEL_10:
v3[v5++] = v6;
++v7;
v4 += 38;
}
while ( v5 != a2 );
free(v3);
return v7;
}

original_code:
unsigned int count_client_cores( const struct test *test, const unsigned int tests ){
 unsigned int bins = 0;
 unsigned int *bin;
 unsigned int i = 0;
 if ( tests == 0 )
  return 0;
 ((void) sizeof ((test != ((void *)0)) ? 1 : 0), __extension__ ({ if (test != ((void *)0)) ; else __assert_fail ("test != NULL", "common.c", 28, __extension__ __PRETTY_FUNCTION__); }));
 bin = calloc(tests, sizeof(*bin));
 if ( bin == ((void *)0) )
  return -1;
 for ( i = 0; i < tests; i++ ) {
  unsigned int b = 0;
  for ( ; b < bins; b++) {
   if ( bin[ b ] == test[i].clientcores )
    break;
  }
  if ( b < bins )
   break;
  bin[bins] = test[i].clientcores;
  bins++;
 }
 free(bin);
 return bins;
}

canonical_original_code:
unsigned int count_client_cores(struct test *test, unsigned int tests){
 unsigned int bins = 0;
 unsigned int *bin;
 unsigned int i = 0;
 if ( tests == 0 )
  return 0;
 ((void) sizeof ((test != ((void *)0)) ? 1 : 0), __extension__ ({ if (test != ((void *)0)) ; else __assert_fail ("test != NULL", "common.c", 28, __extension__ __PRETTY_FUNCTION__); }));
 bin = calloc(tests, sizeof(*bin));
 if ( bin == ((void *)0) )
  return -1;
 for ( i = 0; i < tests; i++ ) {
  unsigned int b = 0;
  for ( ; b < bins; b++) {
   if ( bin[ b ] == test[i].clientcores )
    break;
  }
  if ( b < bins )
   break;
  bin[bins] = test[i].clientcores;
  bins++;
 }
 free(bin);
 return bins;
}

variable_types: struct test { unsigned int clientcores; unsigned int servercores; unsigned int connections; struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; } addr; unsigned int addr_len; } *

variable_types:
tests
unsigned int

variable_types:
bins
unsigned int

variable_types:
bin
unsigned int *

variable_types:
b
unsigned int

return_type: unsigned int


decompiled_code:
__int64 __fastcall count_server_cores(__int64 a1, unsigned int a2)
{
_DWORD *v3; // rdi
int *v4; // r8
__int64 v5; // rdx
int v6; // ecx
unsigned int v7; // er12
__int64 v8; // rax

if ( !a2 )
return 0LL;
if ( !a1 )
_assert_fail("test != NULL", "common.c", 0x43u, "count_server_cores");
v3 = calloc(a2, 4uLL);
if ( !v3 )
return (unsigned int)-1;
v4 = (int *)(a1 + 4);
v5 = 0LL;
do
{
v6 = *v4;
v7 = v5;
v8 = 0LL;
if ( v5 )
{
while ( v3[v8] != v6 )
{
if ( ++v8 == v5 )
goto LABEL_10;
}
if ( (unsigned int)v8 < (unsigned int)v5 )
break;
}
LABEL_10:
v3[v5++] = v6;
++v7;
v4 += 38;
}
while ( v5 != a2 );
free(v3);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2)
{
_DWORD *v3; // rdi
int *v4; // r8
__int64 v5; // rdx
int v6; // ecx
unsigned int v7; // er12
__int64 v8; // rax

if ( !a2 )
return 0LL;
if ( !a1 )
_assert_fail("test != NULL", "common.c", 0x43u, "count_server_cores");
v3 = calloc(a2, 4uLL);
if ( !v3 )
return (unsigned int)-1;
v4 = (int *)(a1 + 4);
v5 = 0LL;
do
{
v6 = *v4;
v7 = v5;
v8 = 0LL;
if ( v5 )
{
while ( v3[v8] != v6 )
{
if ( ++v8 == v5 )
goto LABEL_10;
}
if ( (unsigned int)v8 < (unsigned int)v5 )
break;
}
LABEL_10:
v3[v5++] = v6;
++v7;
v4 += 38;
}
while ( v5 != a2 );
free(v3);
return v7;
}

original_code:
unsigned int count_server_cores( const struct test *test, const unsigned int tests ) {
 unsigned int bins = 0;
 unsigned int *bin;
 unsigned int i = 0;
 if ( tests == 0 )
  return 0;
 ((void) sizeof ((test != ((void *)0)) ? 1 : 0), __extension__ ({ if (test != ((void *)0)) ; else __assert_fail ("test != NULL", "common.c", 67, __extension__ __PRETTY_FUNCTION__); }));
 bin = calloc(tests, sizeof(*bin));
 if ( bin == ((void *)0) )
  return -1;
 for ( i = 0; i < tests; i++ ) {
  unsigned int b = 0;
  for ( ; b < bins; b++) {
   if ( bin[ b ] == test[i].servercores )
    break;
  }
  if ( b < bins )
   break;
  bin[bins] = test[i].servercores;
  bins++;
 }
 free(bin);
 return bins;
}

canonical_original_code:
unsigned int count_server_cores(struct test *test, unsigned int tests) {
 unsigned int bins = 0;
 unsigned int *bin;
 unsigned int i = 0;
 if ( tests == 0 )
  return 0;
 ((void) sizeof ((test != ((void *)0)) ? 1 : 0), __extension__ ({ if (test != ((void *)0)) ; else __assert_fail ("test != NULL", "common.c", 67, __extension__ __PRETTY_FUNCTION__); }));
 bin = calloc(tests, sizeof(*bin));
 if ( bin == ((void *)0) )
  return -1;
 for ( i = 0; i < tests; i++ ) {
  unsigned int b = 0;
  for ( ; b < bins; b++) {
   if ( bin[ b ] == test[i].servercores )
    break;
  }
  if ( b < bins )
   break;
  bin[bins] = test[i].servercores;
  bins++;
 }
 free(bin);
 return bins;
}


decompiled_code:
__suseconds_t get_microseconds()
{
int *v1; // rbx
char *v2; // rax
struct timeval v3; // [rsp+0h] [rbp-18h] BYREF

if ( !gettimeofday(&v3, 0LL) )
return v3.tv_usec + 1000000 * v3.tv_sec;
v1 = _errno_location();
v2 = strerror(*v1);
fprintf(stderr, "%s:%d gettimeofday() error (%d) %s\n", "common.c", 152LL, (unsigned int)*v1, v2);
return 0LL;
}

canonical_decompiled_code:
__suseconds_t func4()
{
int *v1; // rbx
char *v2; // rax
struct timeval v3; // [rsp+0h] [rbp-18h] BYREF

if ( !gettimeofday(&v3, 0LL) )
return v3.tv_usec + 1000000 * v3.tv_sec;
v1 = _errno_location();
v2 = strerror(*v1);
fprintf(stderr, "%s:%d gettimeofday() error (%d) %s\n", "common.c", 152LL, (unsigned int)*v1, v2);
return 0LL;
}

original_code:
unsigned long long get_microseconds() {
 unsigned long long microseconds = 0;
 struct timeval tv;
 if (gettimeofday(&tv, ((void *)0)) != 0) {
  fprintf(stderr, "%s:%d gettimeofday() error (%d) %s\n", "common.c", 152, (*__errno_location ()), strerror((*__errno_location ())));
  microseconds = 0;
 } else {
  microseconds = (unsigned long long)tv.tv_sec * 1000000 + (unsigned long long)tv.tv_usec;
 }
 return microseconds;
}

variable_types:
microseconds
unsigned long long

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

return_type: unsigned long long


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

clock_gettime(0, &v1);
return v1.tv_nsec + 1000000000 * v1.tv_sec;
}

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

clock_gettime(0, &v1);
return v1.tv_nsec + 1000000000 * v1.tv_sec;
}

original_code:
unsigned long long get_nanoseconds() {
 unsigned long long nanoseconds = 0;
 struct timespec ts;
 clock_gettime(0, &ts);
 nanoseconds = (unsigned long long)ts.tv_sec * 1000000000 + (unsigned long long)ts.tv_nsec;
 return nanoseconds;
}

variable_types:
nanoseconds
unsigned long long

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


decompiled_code:
int __fastcall get_timespec_now(struct timespec *tp)
{
return clock_gettime(0, tp);
}

canonical_decompiled_code:
int __fastcall func6(struct timespec *tp)
{
return clock_gettime(0, tp);
}

original_code:
void get_timespec_now(struct timespec *ts) {
 clock_gettime(0, ts);
}

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


decompiled_code:
void __fastcall free_2D(void *ptr, __int64 a2)
{
void *v2; // r12
void **v3; // rbx
void **v4; // rbp
void *v5; // rdi

if ( ptr )
{
v2 = ptr;
if ( a2 )
{
v3 = (void **)ptr;
v4 = (void **)((char *)ptr + 8 * a2);
do
{
v5 = *v3++;
free(v5);
}
while ( v3 != v4 );
}
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func8(void *ptr, __int64 a2)
{
void *v2; // r12
void **v3; // rbx
void **v4; // rbp
void *v5; // rdi

if ( ptr )
{
v2 = ptr;
if ( a2 )
{
v3 = (void **)ptr;
v4 = (void **)((char *)ptr + 8 * a2);
do
{
v5 = *v3++;
free(v5);
}
while ( v3 != v4 );
}
free(v2);
}
}

original_code:
void free_2D(void **data, size_t x) {
 if ( data ) {
  size_t i = 0;
  for (; i < x; ++i)
   free ( data[i] );
  free( data );
 }
}

canonical_original_code:
void free_2D(void **data, unsigned long x) {
 if ( data ) {
  unsigned long i = 0;
  for (; i < x; ++i)
   free ( data[i] );
  free( data );
 }
}

variable_types:
data
void **

variable_types:
x
unsigned long

variable_types:
i
unsigned long


tinv

variable_types: p double

variable_types:
dof
unsigned int

variable_types: dofindex int

variable_types: pindex int

return_type: double


decompiled_code:
double __fastcall calc_confidence(unsigned int a1, int a2, double a3, double a4, double a5)
{
__int64 v5; // r8
double v6; // xmm0_8
double v7; // xmm4_8
double v8; // xmm3_8
double v9; // xmm2_8
double v10; // xmm2_8
double v11; // xmm3_8
double result; // xmm0_8

if ( a5 == 0.0 )
return 0.0;
v6 = tinv(a1, a3);
v8 = v6;
if ( v6 == 0.0 )
{
fprintf(stderr, "%s:%d tinv(%f, %d) error\n", "common.c", 373LL, v7, v5);
result = 0.0;
}
else
{
v9 = a5 / (double)(int)v5;
if ( v9 < 0.0 )
{
v8 = v6;
v10 = sqrt(v9);
}
else
{
v10 = sqrt(v9);
}
v11 = v8 * v10;
if ( a2 )
printf("min: %.f, max: %.f, cl: %f\n", a4 - v11, a4 + v11, (1.0 - v11 / a4) * 100.0);
result = v11;
}
return result;
}

canonical_decompiled_code:
double __fastcall func10(unsigned int a1, int a2, double a3, double a4, double a5)
{
__int64 v5; // r8
double v6; // xmm0_8
double v7; // xmm4_8
double v8; // xmm3_8
double v9; // xmm2_8
double v10; // xmm2_8
double v11; // xmm3_8
double result; // xmm0_8

if ( a5 == 0.0 )
return 0.0;
v6 = func9(a1, a3);
v8 = v6;
if ( v6 == 0.0 )
{
fprintf(stderr, "%s:%d tinv(%f, %d) error\n", "common.c", 373LL, v7, v5);
result = 0.0;
}
else
{
v9 = a5 / (double)(int)v5;
if ( v9 < 0.0 )
{
v8 = v6;
v10 = sqrt(v9);
}
else
{
v10 = sqrt(v9);
}
v11 = v8 * v10;
if ( a2 )
printf("min: %.f, max: %.f, cl: %f\n", a4 - v11, a4 + v11, (1.0 - v11 / a4) * 100.0);
result = v11;
}
return result;
}

original_code:
double calc_confidence(double confidence_lvl, double mean, double variance, unsigned int n, int verbose) {
 double bigZ;
 double sd_div_samples;
 double CI;
 if(variance == 0.0)
  return 0;
 bigZ = tinv(confidence_lvl, n);
 if(bigZ == 0.0) {
  fprintf(stderr, "%s:%d tinv(%f, %d) error\n", "common.c", 373, confidence_lvl, n );
  return 0;
 }
 sd_div_samples = sqrt(variance / n);
 CI = bigZ * sd_div_samples;
 if(verbose) {
  double min, max;
  double confidence;
  min = mean - CI;
  max = mean + CI;
  confidence = (1 - ( CI / mean))*100;
  printf("min: %.f, max: %.f, cl: %f\n", min, max, confidence);
 }
 return CI;
}

canonical_original_code:
double calc_confidence(double confidence_lvl, double mean, double variance, unsigned int n, int verbose) {
 double bigZ;
 double sd_div_samples;
 double CI;
 if(variance == 0.0)
  return 0;
 bigZ = tinv(confidence_lvl, n);
 if(bigZ == 0.0) {
  fprintf(stderr, "%s:%d tinv(%f, %d) error\n", "common.c", 373, confidence_lvl, n );
  return 0;
 }
 sd_div_samples = sqrt(variance / n);
 CI = bigZ * sd_div_samples;
 if(verbose) {
  double min; double max;
  double confidence;
  min = mean - CI;
  max = mean + CI;
  confidence = (1 - ( CI / mean))*100;
  printf("min: %.f, max: %.f, cl: %f\n", min, max, confidence);
 }
 return CI;
}

variable_types: mean double

variable_types: variance double

variable_types:
n
unsigned int

variable_types: verbose int

variable_types: bigZ double

variable_types: CI double

variable_types: min double

variable_types: max double

variable_types: confidence double


decompiled_code:
int __fastcall set_opt(int a1, int a2, int a3, int a4)
{
int result; // eax
int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optval[0] = a4;
if ( a1 == -1 )
result = -1;
else
result = setsockopt(a1, a2, a3, optval, 4u);
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1, int a2, int a3, int a4)
{
int result; // eax
int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optval[0] = a4;
if ( a1 == -1 )
result = -1;
else
result = setsockopt(a1, a2, a3, optval, 4u);
return result;
}

original_code:
int set_opt(int s, int level, int optname, int one) {
 if ( s == (-1) )
  return (-1);
 return setsockopt(s, level, optname, (char *)&one, sizeof(one));
}

variable_types: s int

variable_types: level int

variable_types: optname int

variable_types: one int


decompiled_code:
int __fastcall enable_nagle(int a1)
{
return set_opt(a1, 6, 1, 1);
}

canonical_decompiled_code:
int __fastcall func1(int a1)
{
return func0(a1, 6, 1, 1);
}

original_code:
int enable_nagle(int s) {
 return set_opt(s, IPPROTO_TCP, 1, 1);
}


decompiled_code:
int __fastcall disable_nagle(int a1)
{
return set_opt(a1, 6, 1, 0);
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
return func0(a1, 6, 1, 0);
}

original_code:
int disable_nagle(int s) {
 return set_opt(s, IPPROTO_TCP, 1, 0);
}


decompiled_code:
int __fastcall enable_maxseq(int a1, int a2)
{
return set_opt(a1, 6, 2, a2 + 52);
}

canonical_decompiled_code:
int __fastcall func3(int a1, int a2)
{
return func0(a1, 6, 2, a2 + 52);
}

original_code:
int enable_maxseq(int s, int size) {
 return set_opt(s, IPPROTO_TCP, 2, size + 52);
}

variable_types: size int


decompiled_code:
int __fastcall disable_maxseq(int a1)
{
return set_opt(a1, 6, 2, 0);
}

canonical_decompiled_code:
int __fastcall func4(int a1)
{
return func0(a1, 6, 2, 0);
}

original_code:
int disable_maxseq(int s) {
 return set_opt(s, IPPROTO_TCP, 2, 0);
}


decompiled_code:
int __fastcall enable_timestamp(int a1)
{
return set_opt(a1, 1, 35, 1);
}

canonical_decompiled_code:
int __fastcall func5(int a1)
{
return func0(a1, 1, 35, 1);
}

original_code:
int enable_timestamp(int s) {
 return set_opt(s, 1, 35, 1);
}


decompiled_code:
int __fastcall disable_timestamp(int a1)
{
return set_opt(a1, 1, 35, 0);
}

canonical_decompiled_code:
int __fastcall func6(int a1)
{
return func0(a1, 1, 35, 0);
}

original_code:
int disable_timestamp(int s) {
 return set_opt(s, 1, 35, 0);
}


decompiled_code:
__int64 __fastcall get_packet_timestamp(int a1)
{
int v1; // er8
__int64 result; // rax
__int64 v3; // [rsp+0h] [rbp-18h] BYREF
__int64 v4; // [rsp+8h] [rbp-10h]

v3 = 0LL;
v4 = 0LL;
v1 = ioctl(a1, 0x8907uLL, &v3);
result = 0LL;
if ( !v1 && v3 >= 0 )
result = v4 + 1000000000 * v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
int v1; // er8
__int64 result; // rax
__int64 v3; // [rsp+0h] [rbp-18h] BYREF
__int64 v4; // [rsp+8h] [rbp-10h]

v3 = 0LL;
v4 = 0LL;
v1 = ioctl(a1, 0x8907uLL, &v3);
result = 0LL;
if ( !v1 && v3 >= 0 )
result = v4 + 1000000000 * v3;
return result;
}

original_code:
unsigned long long get_packet_timestamp(int s) {
 struct timespec ts = {0,0};
 if ( ioctl(s, 0x8907, &ts) )
  return 0;
 if ( ts.tv_sec < 0 ) {
  return 0;
 }
 return (unsigned long long)ts.tv_sec * 1000000000 + (unsigned long long)ts.tv_nsec;
}

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


decompiled_code:
int __fastcall enable_blocking(int a1)
{
return fcntl(a1, 4, 2048LL);
}

canonical_decompiled_code:
int __fastcall func8(int a1)
{
return fcntl(a1, 4, 2048LL);
}

original_code:
int enable_blocking(int s) {
 return fcntl(s, 4, 04000);
}


decompiled_code:
// attributes: thunk
int __fastcall disable_blocking(int a1)
{
return enable_blocking(a1);
}

canonical_decompiled_code:
int __fastcall func9(int a1)
{
return func8(a1);
}

original_code:
int disable_blocking(int s) {
 return fcntl(s, 4, 04000);
}


decompiled_code:
__int64 __fastcall set_socket_buffer(int fd, int optname, int a3)
{
__int64 result; // rax
int optval[3]; // [rsp+Ch] [rbp-2Ch] BYREF
unsigned int v5; // [rsp+18h] [rbp-20h] BYREF
socklen_t optlen[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

optval[0] = a3;
v5 = -1;
optlen[0] = 4;
if ( fd == -1
|| optval[0] > 0 && setsockopt(fd, 1, optname, optval, 4u) < 0
|| getsockopt(fd, 1, optname, &v5, optlen) < 0 )
{
result = 0xFFFFFFFFLL;
}
else
{
result = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int fd, int optname, int a3)
{
__int64 result; // rax
int optval[3]; // [rsp+Ch] [rbp-2Ch] BYREF
unsigned int v5; // [rsp+18h] [rbp-20h] BYREF
socklen_t optlen[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

optval[0] = a3;
v5 = -1;
optlen[0] = 4;
if ( fd == -1
|| optval[0] > 0 && setsockopt(fd, 1, optname, optval, 4u) < 0
|| getsockopt(fd, 1, optname, &v5, optlen) < 0 )
{
result = 0xFFFFFFFFLL;
}
else
{
result = v5;
}
return result;
}

original_code:
int set_socket_buffer( int s, int opt, int size ) {
 int new_size = (-1);
 socklen_t new_size_len = sizeof(new_size);
 if ( s == (-1) )
  return (-1);
 if (size > 0 && setsockopt(s, 1, opt, (char *)&size, sizeof(size)) < 0)
  return (-1);
 if (getsockopt(s, 1, opt, (char *)&new_size, &new_size_len) < 0)
  return (-1);
  return new_size;
}

canonical_original_code:
int set_socket_buffer(int s, int opt, int size) {
 int new_size = (-1);
 unsigned int new_size_len = sizeof(new_size);
 if ( s == (-1) )
  return (-1);
 if (size > 0 && setsockopt(s, 1, opt, (char *)&size, sizeof(size)) < 0)
  return (-1);
 if (getsockopt(s, 1, opt, (char *)&new_size, &new_size_len) < 0)
  return (-1);
  return new_size;
}

variable_types: opt int


decompiled_code:
__int64 __fastcall set_socket_send_buffer(int a1, int a2)
{
return set_socket_buffer(a1, 7, a2);
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int a2)
{
return func10(a1, 7, a2);
}

original_code:
int set_socket_send_buffer(int s, unsigned int socket_size) {
 return set_socket_buffer(s, 7, socket_size);
}


decompiled_code:
__int64 __fastcall set_socket_recv_buffer(int a1, int a2)
{
return set_socket_buffer(a1, 8, a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2)
{
return func10(a1, 8, a2);
}

original_code:
int set_socket_recv_buffer(int s, unsigned int socket_size) {
 return set_socket_buffer(s, 8, socket_size);
}


decompiled_code:
__int64 __fastcall set_socket_timeout(int fd, unsigned int a2)
{
__int64 result; // rax
__int64 v3[3]; // [rsp+0h] [rbp-18h] BYREF

if ( fd == -1 )
return 0xFFFFFFFFLL;
v3[0] = a2 / 0x3E8;
v3[1] = 1000 * (a2 % 0x3E8);
if ( setsockopt(fd, 1, 20, v3, 0x10u) )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)-(setsockopt(fd, 1, 21, v3, 0x10u) != 0);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(int fd, unsigned int a2)
{
__int64 result; // rax
__int64 v3[3]; // [rsp+0h] [rbp-18h] BYREF

if ( fd == -1 )
return 0xFFFFFFFFLL;
v3[0] = a2 / 0x3E8;
v3[1] = 1000 * (a2 % 0x3E8);
if ( setsockopt(fd, 1, 20, v3, 0x10u) )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)-(setsockopt(fd, 1, 21, v3, 0x10u) != 0);
return result;
}

original_code:
int set_socket_timeout(int s, unsigned int milliseconds) {
 struct timeval tv;
 if ( s == (-1) )
  return (-1);
 tv.tv_sec = milliseconds / 1000;
 tv.tv_usec = milliseconds % 1000 * 1000;
 if (setsockopt(s, 1, 20, (const char*)&tv, sizeof(tv)))
  return (-1);
 if (setsockopt(s, 1, 21, (const char*)&tv, sizeof(tv)))
  return (-1);
 return 0;
}

canonical_original_code:
int set_socket_timeout(int s, unsigned int milliseconds) {
 struct timeval tv;
 if ( s == (-1) )
  return (-1);
 tv.tv_sec = milliseconds / 1000;
 tv.tv_usec = milliseconds % 1000 * 1000;
 if (setsockopt(s, 1, 20, (char *)&tv, sizeof(tv)))
  return (-1);
 if (setsockopt(s, 1, 21, (char *)&tv, sizeof(tv)))
  return (-1);
 return 0;
}

variable_types:
milliseconds
unsigned int

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


decompiled_code:
__int64 __fastcall highest_socket(int *a1, __int64 a2)
{
int *v2; // rcx
int *v3; // rax
int i; // er8

v2 = &a1[a2];
if ( !a1 )
_assert_fail("s != NULL", "netlib.c", 0xA6u, "highest_socket");
if ( a2 )
{
v3 = a1 + 1;
for ( i = *a1; v2 > v3; ++v3 )
{
if ( *v3 == -1 )
_assert_fail("*s != INVALID_SOCKET", "netlib.c", 0xB0u, "highest_socket");
if ( i < *v3 )
i = *v3;
}
}
else
{
i = -1;
}
return (unsigned int)i;
}

canonical_decompiled_code:
__int64 __fastcall func14(int *a1, __int64 a2)
{
int *v2; // rcx
int *v3; // rax
int i; // er8

v2 = &a1[a2];
if ( !a1 )
_assert_fail("s != NULL", "netlib.c", 0xA6u, "highest_socket");
if ( a2 )
{
v3 = a1 + 1;
for ( i = *a1; v2 > v3; ++v3 )
{
if ( *v3 == -1 )
_assert_fail("*s != INVALID_SOCKET", "netlib.c", 0xB0u, "highest_socket");
if ( i < *v3 )
i = *v3;
}
}
else
{
i = -1;
}
return (unsigned int)i;
}

original_code:
int highest_socket(int *s, size_t len) {
 const int *s_max = s + len;
 int max;
 ((void) sizeof ((s != ((void *)0)) ? 1 : 0), __extension__ ({ if (s != ((void *)0)) ; else __assert_fail ("s != NULL", "netlib.c", 166, __extension__ __PRETTY_FUNCTION__); }));
 if ( len == 0 )
  return (-1);
 max = *s++;
 for ( ; s < s_max ; s++) {
  ((void) sizeof ((*s != (-1)) ? 1 : 0), __extension__ ({ if (*s != (-1)) ; else __assert_fail ("*s != INVALID_SOCKET", "netlib.c", 176, __extension__ __PRETTY_FUNCTION__); }));
  if ( *s > max )
   max = *s;
 }
 return max;
}

canonical_original_code:
int highest_socket(int *s, unsigned long len) {
 int *s_max = s + len;
 int max;
 ((void) sizeof ((s != ((void *)0)) ? 1 : 0), __extension__ ({ if (s != ((void *)0)) ; else __assert_fail ("s != NULL", "netlib.c", 166, __extension__ __PRETTY_FUNCTION__); }));
 if ( len == 0 )
  return (-1);
 max = *s++;
 for ( ; s < s_max ; s++) {
  ((void) sizeof ((*s != (-1)) ? 1 : 0), __extension__ ({ if (*s != (-1)) ; else __assert_fail ("*s != INVALID_SOCKET", "netlib.c", 176, __extension__ __PRETTY_FUNCTION__); }));
  if ( *s > max )
   max = *s;
 }
 return max;
}

variable_types:
s
int *

variable_types:
len
unsigned long

variable_types: max int


decompiled_code:
char *__fastcall addr_to_ipstr(const struct sockaddr *a1, socklen_t a2, char *a3, size_t a4)
{
char *result; // rax
char serv[56]; // [rsp+0h] [rbp-38h] BYREF

if ( !a1 )
_assert_fail("addr != NULL", "netlib.c", 0xC1u, "addr_to_ipstr");
if ( !a2 )
_assert_fail("addlen > 0", "netlib.c", 0xC2u, "addr_to_ipstr");
if ( !a3 )
_assert_fail("host != NULL", "netlib.c", 0xC4u, "addr_to_ipstr");
if ( !a4 )
_assert_fail("maxhostlen > 0", "netlib.c", 0xC5u, "addr_to_ipstr");
if ( getnameinfo(a1, a2, a3, a4, serv, 0x20u, 3) )
{
*a3 = 0;
result = 0LL;
}
else if ( serv[0] != 48 && serv[1] )
{
strncat(a3, ":", a4);
strncat(a3, serv, a4);
result = a3;
}
else
{
result = a3;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func15(const struct sockaddr *a1, socklen_t a2, char *a3, size_t a4)
{
char *result; // rax
char serv[56]; // [rsp+0h] [rbp-38h] BYREF

if ( !a1 )
_assert_fail("addr != NULL", "netlib.c", 0xC1u, "addr_to_ipstr");
if ( !a2 )
_assert_fail("addlen > 0", "netlib.c", 0xC2u, "addr_to_ipstr");
if ( !a3 )
_assert_fail("host != NULL", "netlib.c", 0xC4u, "addr_to_ipstr");
if ( !a4 )
_assert_fail("maxhostlen > 0", "netlib.c", 0xC5u, "addr_to_ipstr");
if ( getnameinfo(a1, a2, a3, a4, serv, 0x20u, 3) )
{
*a3 = 0;
result = 0LL;
}
else if ( serv[0] != 48 && serv[1] )
{
strncat(a3, ":", a4);
strncat(a3, serv, a4);
result = a3;
}
else
{
result = a3;
}
return result;
}

original_code:
char * addr_to_ipstr(const struct sockaddr *addr, socklen_t addlen, char *host, size_t maxhostlen) {
 char port [ 32 ];
 ((void) sizeof ((addr != ((void *)0)) ? 1 : 0), __extension__ ({ if (addr != ((void *)0)) ; else __assert_fail ("addr != NULL", "netlib.c", 193, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((addlen > 0) ? 1 : 0), __extension__ ({ if (addlen > 0) ; else __assert_fail ("addlen > 0", "netlib.c", 194, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((host != ((void *)0)) ? 1 : 0), __extension__ ({ if (host != ((void *)0)) ; else __assert_fail ("host != NULL", "netlib.c", 196, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((maxhostlen > 0) ? 1 : 0), __extension__ ({ if (maxhostlen > 0) ; else __assert_fail ("maxhostlen > 0", "netlib.c", 197, __extension__ __PRETTY_FUNCTION__); }));
 if ( getnameinfo (addr, addlen, host, maxhostlen, port, sizeof(port), 1 | 2 ) ) {
  *host = '\0';
  return ((void *)0);
 }
 if (port[0] != '0' && port[1] != '\0') {
  strncat(host, ":", maxhostlen);
  strncat(host, port, maxhostlen);
 }
 return host;
}

canonical_original_code:
char *addr_to_ipstr(struct sockaddr *addr, unsigned int addlen, char *host, unsigned long maxhostlen) {
 char port[32];
 ((void) sizeof ((addr != ((void *)0)) ? 1 : 0), __extension__ ({ if (addr != ((void *)0)) ; else __assert_fail ("addr != NULL", "netlib.c", 193, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((addlen > 0) ? 1 : 0), __extension__ ({ if (addlen > 0) ; else __assert_fail ("addlen > 0", "netlib.c", 194, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((host != ((void *)0)) ? 1 : 0), __extension__ ({ if (host != ((void *)0)) ; else __assert_fail ("host != NULL", "netlib.c", 196, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((maxhostlen > 0) ? 1 : 0), __extension__ ({ if (maxhostlen > 0) ; else __assert_fail ("maxhostlen > 0", "netlib.c", 197, __extension__ __PRETTY_FUNCTION__); }));
 if ( getnameinfo (addr, addlen, host, maxhostlen, port, sizeof(port), 1 | 2 ) ) {
  *host = '\0';
  return ((void *)0);
 }
 if (port[0] != '0' && port[1] != '\0') {
  strncat(host, ":", maxhostlen);
  strncat(host, port, maxhostlen);
 }
 return host;
}

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

variable_types:
addlen
unsigned int

variable_types:
host
char *

variable_types:
maxhostlen
unsigned long

variable_types:
port
char [32]

return_type: char *


decompiled_code:
__int64 __fastcall str_to_addr(const char *a1, __m128i *a2, socklen_t *a3)
{
unsigned int v4; // er12
struct addrinfo *v5; // rdi
socklen_t v6; // eax
struct addrinfo *pai; // [rsp+8h] [rbp-20h] BYREF

pai = 0LL;
if ( !a1 )
_assert_fail("host != NULL", "netlib.c", 0xDBu, "str_to_addr");
if ( !a2 )
_assert_fail("addr != NULL", "netlib.c", 0xDCu, "str_to_addr");
if ( !a3 )
_assert_fail("addlen != NULL", "netlib.c", 0xDDu, "str_to_addr");
v4 = getaddrinfo(a1, 0LL, 0LL, &pai);
if ( v4 )
return (unsigned int)-1;
v5 = pai;
v6 = pai->ai_addrlen;
*a2 = _mm_loadu_si128((const __m128i *)pai->ai_addr);
*a3 = v6;
freeaddrinfo(v5);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func16(const char *a1, __m128i *a2, socklen_t *a3)
{
unsigned int v4; // er12
struct addrinfo *v5; // rdi
socklen_t v6; // eax
struct addrinfo *pai; // [rsp+8h] [rbp-20h] BYREF

pai = 0LL;
if ( !a1 )
_assert_fail("host != NULL", "netlib.c", 0xDBu, "str_to_addr");
if ( !a2 )
_assert_fail("addr != NULL", "netlib.c", 0xDCu, "str_to_addr");
if ( !a3 )
_assert_fail("addlen != NULL", "netlib.c", 0xDDu, "str_to_addr");
v4 = getaddrinfo(a1, 0LL, 0LL, &pai);
if ( v4 )
return (unsigned int)-1;
v5 = pai;
v6 = pai->ai_addrlen;
*a2 = _mm_loadu_si128((const __m128i *)pai->ai_addr);
*a3 = v6;
freeaddrinfo(v5);
return v4;
}

original_code:
int str_to_addr(const char *host, struct sockaddr *addr, socklen_t *addlen) {
 struct addrinfo *aiList = ((void *)0);
 ((void) sizeof ((host != ((void *)0)) ? 1 : 0), __extension__ ({ if (host != ((void *)0)) ; else __assert_fail ("host != NULL", "netlib.c", 219, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((addr != ((void *)0)) ? 1 : 0), __extension__ ({ if (addr != ((void *)0)) ; else __assert_fail ("addr != NULL", "netlib.c", 220, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((addlen != ((void *)0)) ? 1 : 0), __extension__ ({ if (addlen != ((void *)0)) ; else __assert_fail ("addlen != NULL", "netlib.c", 221, __extension__ __PRETTY_FUNCTION__); }));
 if ( getaddrinfo(host, ((void *)0), ((void *)0), &aiList) ) {
  return -1;
 }
 *addr = *(aiList->ai_addr);
 *addlen = (socklen_t) aiList->ai_addrlen;
 freeaddrinfo( aiList );
 return 0;
}

canonical_original_code:
int str_to_addr(char *host, struct sockaddr *addr, unsigned int *addlen) {
 struct addrinfo *aiList = ((void *)0);
 ((void) sizeof ((host != ((void *)0)) ? 1 : 0), __extension__ ({ if (host != ((void *)0)) ; else __assert_fail ("host != NULL", "netlib.c", 219, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((addr != ((void *)0)) ? 1 : 0), __extension__ ({ if (addr != ((void *)0)) ; else __assert_fail ("addr != NULL", "netlib.c", 220, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((addlen != ((void *)0)) ? 1 : 0), __extension__ ({ if (addlen != ((void *)0)) ; else __assert_fail ("addlen != NULL", "netlib.c", 221, __extension__ __PRETTY_FUNCTION__); }));
 if ( getaddrinfo(host, ((void *)0), ((void *)0), &aiList) ) {
  return -1;
 }
 *addr = *(aiList->ai_addr);
 *addlen = (unsigned int) aiList->ai_addrlen;
 freeaddrinfo( aiList );
 return 0;
}

variable_types:
addlen
unsigned int *

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *

user_defined_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }


decompiled_code:
__int64 __fastcall connect_ign_signal(int fd, struct sockaddr *addr, socklen_t len)
{
unsigned int v4; // er12

do
v4 = connect(fd, addr, len);
while ( v4 == -1 && *_errno_location() == 4 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func17(int fd, struct sockaddr *addr, socklen_t len)
{
unsigned int v4; // er12

do
v4 = connect(fd, addr, len);
while ( v4 == -1 && *_errno_location() == 4 );
return v4;
}

original_code:
int connect_ign_signal(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) {
 int len;
 while ( 1 ) {
  len = connect( sockfd, serv_addr, addrlen);
  if ( len == (-1) && (*__errno_location ()) == 4 )
   continue;
  return len;
 }
}

canonical_original_code:
int connect_ign_signal(int sockfd, struct sockaddr *serv_addr, unsigned int addrlen) {
 int len;
 while ( 1 ) {
  len = connect( sockfd, serv_addr, addrlen);
  if ( len == (-1) && (*__errno_location ()) == 4 )
   continue;
  return len;
 }
}

variable_types: sockfd int

variable_types:
addrlen
unsigned int

variable_types: len int


decompiled_code:
__int64 __fastcall accept_ign_signal(int fd, struct sockaddr *addr, socklen_t *addr_len)
{
unsigned int v4; // er12

do
v4 = accept(fd, addr, addr_len);
while ( v4 == -1 && *_errno_location() == 4 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func18(int fd, struct sockaddr *addr, socklen_t *addr_len)
{
unsigned int v4; // er12

do
v4 = accept(fd, addr, addr_len);
while ( v4 == -1 && *_errno_location() == 4 );
return v4;
}

original_code:
int accept_ign_signal(int sockfd, struct sockaddr *addr, socklen_t *addrlen) {
 int len;
 while ( 1 ) {
  len = accept( sockfd, addr, addrlen);
  if ( len == (-1) && (*__errno_location ()) == 4 )
   continue;
  return len;
 }
}

canonical_original_code:
int accept_ign_signal(int sockfd, struct sockaddr *addr, unsigned int *addrlen) {
 int len;
 while ( 1 ) {
  len = accept( sockfd, addr, addrlen);
  if ( len == (-1) && (*__errno_location ()) == 4 )
   continue;
  return len;
 }
}

variable_types:
addrlen
unsigned int *


decompiled_code:
__int64 __fastcall recv_ign_signal(int fd, void *buf, size_t n, int flags)
{
__int64 result; // rax

while ( 1 )
{
LODWORD(result) = recv(fd, buf, n, flags);
if ( (_DWORD)result != -1 )
break;
if ( *_errno_location() != 4 )
return -1LL;
}
return (int)result;
}

canonical_decompiled_code:
__int64 __fastcall func19(int fd, void *buf, size_t n, int flags)
{
__int64 result; // rax

while ( 1 )
{
LODWORD(result) = recv(fd, buf, n, flags);
if ( (_DWORD)result != -1 )
break;
if ( *_errno_location() != 4 )
return -1LL;
}
return (int)result;
}

original_code:
ssize_t recv_ign_signal(int s, void *buf, size_t len, int flags) {
 int ret;
 while ( 1 ) {
  ret = recv( s, buf, len, flags);
  if ( ret == (-1) && (*__errno_location ()) == 4 )
   continue;
  return ret;
 }
}

canonical_original_code:
long recv_ign_signal(int s, void *buf, unsigned long len, int flags) {
 int ret;
 while ( 1 ) {
  ret = recv( s, buf, len, flags);
  if ( ret == (-1) && (*__errno_location ()) == 4 )
   continue;
  return ret;
 }
}

variable_types: s int

variable_types:
buf
void *

variable_types: flags int

variable_types: ret int

return_type: long


decompiled_code:
__int64 __fastcall recvmsg_ign_signal(int fd, struct msghdr *message, int flags)
{
__int64 result; // rax

while ( 1 )
{
LODWORD(result) = recvmsg(fd, message, flags);
if ( (_DWORD)result != -1 )
break;
if ( *_errno_location() != 4 )
return -1LL;
}
return (int)result;
}

canonical_decompiled_code:
__int64 __fastcall func20(int fd, struct msghdr *message, int flags)
{
__int64 result; // rax

while ( 1 )
{
LODWORD(result) = recvmsg(fd, message, flags);
if ( (_DWORD)result != -1 )
break;
if ( *_errno_location() != 4 )
return -1LL;
}
return (int)result;
}

original_code:
ssize_t recvmsg_ign_signal(int s, struct msghdr *msg, int flags) {
 int len;
 while ( 1 ) {
  len = recvmsg(s, msg, flags);
  if ( len == (-1) && (*__errno_location ()) == 4 )
   continue;
  return len;
 }
}

canonical_original_code:
long recvmsg_ign_signal(int s, struct msghdr *msg, int flags) {
 int len;
 while ( 1 ) {
  len = recvmsg(s, msg, flags);
  if ( len == (-1) && (*__errno_location ()) == 4 )
   continue;
  return len;
 }
}

variable_types: struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec { void *iov_base; unsigned long iov_len; } *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; } *

user_defined_types: struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; }


decompiled_code:
__int64 __fastcall send_ign_signal(int fd, void *buf, size_t n, int flags)
{
__int64 result; // rax

while ( 1 )
{
LODWORD(result) = send(fd, buf, n, flags);
if ( (_DWORD)result != -1 )
break;
if ( *_errno_location() != 4 )
return -1LL;
}
return (int)result;
}

canonical_decompiled_code:
__int64 __fastcall func21(int fd, void *buf, size_t n, int flags)
{
__int64 result; // rax

while ( 1 )
{
LODWORD(result) = send(fd, buf, n, flags);
if ( (_DWORD)result != -1 )
break;
if ( *_errno_location() != 4 )
return -1LL;
}
return (int)result;
}

original_code:
ssize_t send_ign_signal(int s, const void *buf, size_t len, int flags) {
 int ret;
 while ( 1 ) {
  ret = send( s, buf, len, flags);
  if ( ret == (-1) && (*__errno_location ()) == 4 )
   continue;
  return ret;
 }
}

canonical_original_code:
long send_ign_signal(int s, void *buf, unsigned long len, int flags) {
 int ret;
 while ( 1 ) {
  ret = send( s, buf, len, flags);
  if ( ret == (-1) && (*__errno_location ()) == 4 )
   continue;
  return ret;
 }
}

variable_types:
len
unsigned long


decompiled_code:
__int64 __fastcall select_ign_signal(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
{
unsigned int v8; // er12

do
v8 = select(nfds, readfds, writefds, exceptfds, timeout);
while ( v8 == -1 && *_errno_location() == 4 );
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func22(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
{
unsigned int v8; // er12

do
v8 = select(nfds, readfds, writefds, exceptfds, timeout);
while ( v8 == -1 && *_errno_location() == 4 );
return v8;
}

original_code:
int select_ign_signal(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) {
 int num_fd;
 while ( 1 ) {
  num_fd = select(nfds, readfds, writefds, exceptfds, timeout);
  if ( num_fd == (-1) && (*__errno_location ()) == 4 )
   continue;
  return num_fd;
 }
}

canonical_original_code:
int select_ign_signal(int nfds, struct fd_set *readfds, struct fd_set *writefds, struct fd_set *exceptfds, struct timeval *timeout) {
 int num_fd;
 while ( 1 ) {
  num_fd = select(nfds, readfds, writefds, exceptfds, timeout);
  if ( num_fd == (-1) && (*__errno_location ()) == 4 )
   continue;
  return num_fd;
 }
}

variable_types: nfds int

variable_types: struct fd_set { long __fds_bits[-1]; } *

variable_types:
writefds
struct fd_set *

variable_types:
exceptfds
struct fd_set *

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


decompiled_code:
__int64 __fastcall close_ign_signal(int fd)
{
unsigned int v1; // er12

do
v1 = close(fd);
while ( v1 == -1 && *_errno_location() == 4 );
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func23(int fd)
{
unsigned int v1; // er12

do
v1 = close(fd);
while ( v1 == -1 && *_errno_location() == 4 );
return v1;
}

original_code:
int close_ign_signal(int fildes) {
 int err;
 while ( 1 ) {
  err = close(fildes);
  if ( err == (-1) && (*__errno_location ()) == 4 )
   continue;
  return err;
 }
}

variable_types: fildes int

variable_types: err int


decompiled_code:
__int64 __fastcall epoll_wait_ign_signal(int epfd, struct epoll_event *events, int maxevents, int timeout)
{
unsigned int v6; // er12

do
v6 = epoll_wait(epfd, events, maxevents, timeout);
while ( v6 == -1 && *_errno_location() == 4 );
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func24(int epfd, struct epoll_event *events, int maxevents, int timeout)
{
unsigned int v6; // er12

do
v6 = epoll_wait(epfd, events, maxevents, timeout);
while ( v6 == -1 && *_errno_location() == 4 );
return v6;
}

original_code:
int epoll_wait_ign_signal(int epfd, struct epoll_event * events, int maxevents, int timeout) {
 int num_fd;
 while ( 1 ) {
  num_fd = epoll_wait(epfd, events, maxevents, timeout);
  if ( num_fd == (-1) && (*__errno_location ()) == 4 )
   continue;
  return num_fd;
 }
}

canonical_original_code:
int epoll_wait_ign_signal(int epfd, struct epoll_event *events, int maxevents, int timeout) {
 int num_fd;
 while ( 1 ) {
  num_fd = epoll_wait(epfd, events, maxevents, timeout);
  if ( num_fd == (-1) && (*__errno_location ()) == 4 )
   continue;
  return num_fd;
 }
}

variable_types: epfd int

variable_types: struct epoll_event { unsigned int events; union epoll_data { void *ptr; int fd; unsigned int u32; unsigned long u64; } data; } *

variable_types: maxevents int

variable_types: timeout int

user_defined_types: struct epoll_event { unsigned int events; union epoll_data data; }


decompiled_code:
__int64 __fastcall print_headers(__int64 a1)
{
const char *v1; // rsi
const char *v2; // rsi

if ( !a1 )
_assert_fail("settings != NULL", "print.c", 0x13u, "print_headers");
pthread_mutex_lock(&printf_mutex);
v1 = "\t packet\t";
if ( (*(_BYTE *)(a1 + 12) & 8) == 0 )
v1 = (const char *)&unk_454;
printf("Core\tsend\treceived\tnum\ttime\tgoodput%s\n", v1);
v2 = "latency (ns)\ttimestamps";
if ( (*(_BYTE *)(a1 + 12) & 8) == 0 )
v2 = (const char *)&unk_454;
printf("\tmsg\tbytes\t\trecv()s\t\t(MB/s)\t%s\n", v2);
puts("\tsize\t\t\t\t\t\t\t");
pthread_mutex_unlock(&printf_mutex);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
const char *v1; // rsi
const char *v2; // rsi

if ( !a1 )
_assert_fail("settings != NULL", "print.c", 0x13u, "print_headers");
pthread_mutex_lock(&printf_mutex);
v1 = "\t packet\t";
if ( (*(_BYTE *)(a1 + 12) & 8) == 0 )
v1 = (const char *)&unk_454;
printf("Core\tsend\treceived\tnum\ttime\tgoodput%s\n", v1);
v2 = "latency (ns)\ttimestamps";
if ( (*(_BYTE *)(a1 + 12) & 8) == 0 )
v2 = (const char *)&unk_454;
printf("\tmsg\tbytes\t\trecv()s\t\t(MB/s)\t%s\n", v2);
puts("\tsize\t\t\t\t\t\t\t");
pthread_mutex_unlock(&printf_mutex);
return 0LL;
}

original_code:
int print_headers(const struct settings* settings, void*data) {
 ((void) sizeof ((settings != ((void *)0)) ? 1 : 0), __extension__ ({ if (settings != ((void *)0)) ; else __assert_fail ("settings != NULL", "print.c", 19, __extension__ __PRETTY_FUNCTION__); }));
 pthread_mutex_lock( &printf_mutex );
 printf("Core\tsend\treceived\tnum\ttime\tgoodput%s\n",
  settings->timestamp ? "\t   packet\t" : "");
 printf("\tmsg\tbytes\t\trecv()s\t\t(MB/s)\t%s\n",
  settings->timestamp ? "latency (ns)\ttimestamps" : "");
 printf("\tsize\t\t\t\t\t\t\t\n");
 pthread_mutex_unlock( &printf_mutex );
 return 0;
}

canonical_original_code:
int print_headers(struct settings *settings, void *data) {
 ((void) sizeof ((settings != ((void *)0)) ? 1 : 0), __extension__ ({ if (settings != ((void *)0)) ; else __assert_fail ("settings != NULL", "print.c", 19, __extension__ __PRETTY_FUNCTION__); }));
 pthread_mutex_lock( &printf_mutex );
 printf("Core\tsend\treceived\tnum\ttime\tgoodput%s\n",
  settings->timestamp ? "\t   packet\t" : "");
 printf("\tmsg\tbytes\t\trecv()s\t\t(MB/s)\t%s\n",
  settings->timestamp ? "latency (ns)\ttimestamps" : "");
 printf("\tsize\t\t\t\t\t\t\t\n");
 pthread_mutex_unlock( &printf_mutex );
 return 0;
}

variable_types: struct settings { unsigned int duration; int type; int protocol; unsigned int daemon; unsigned int verbose; unsigned int dirty; unsigned int timestamp; unsigned int disable_nagles; unsigned int reverse; unsigned int quiet; double confidence_lvl; double confidence_int; unsigned int min_iterations; unsigned int max_iterations; unsigned int message_size; unsigned int socket_size; unsigned int rate; char *server_host; unsigned short port; unsigned int tests; struct test { unsigned int clientcores; unsigned int servercores; unsigned int connections; struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; } addr; unsigned int addr_len; } *test; unsigned int clientcores; unsigned int servercores; unsigned int threaded_model; } *

variable_types:
data
void *


decompiled_code:
__int64 __fastcall print_results(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax
__int64 v3; // rdx
float v4; // xmm0_4
float v5; // xmm1_4
float v6; // xmm1_4
float v7; // xmm0_4
__int64 v9; // rax
__int64 v10; // rcx

v2 = *((_QWORD *)a2 + 5);
v3 = *((_QWORD *)a2 + 1);
if ( v2 < 0 )
{
v10 = *((_QWORD *)a2 + 5) & 1LL | (*((_QWORD *)a2 + 5) >> 1);
v4 = (float)(int)v10 + (float)(int)v10;
}
else
{
v4 = (float)(int)v2;
}
v5 = 0.0;
if ( v3 )
{
if ( v3 < 0 )
{
v9 = *((_QWORD *)a2 + 1) & 1LL | (*((_QWORD *)a2 + 1) >> 1);
v6 = (float)(int)v9 + (float)(int)v9;
}
else
{
v6 = (float)(int)v3;
}
v5 = v6 / v4;
}
v7 = v4 / 1000000.0;
if ( !a1 )
_assert_fail("settings != NULL", "print.c", 0x29u, "print_results");
pthread_mutex_lock(&printf_mutex);
printf(
"%i\t%u\t%llu\t%llu\t%.2fs\t%.2f",
*a2,
*(unsigned int *)(a1 + 40),
*((_QWORD *)a2 + 1),
*((_QWORD *)a2 + 2),
v7,
v5);
if ( (*(_BYTE *)(a1 + 12) & 8) != 0 )
printf("\t%llu\t%llu", *((_QWORD *)a2 + 3), *((_QWORD *)a2 + 4));
putchar(10);
pthread_mutex_unlock(&printf_mutex);
return 0LL;
}

original_code:
int print_results( const struct settings *settings, const struct stats *stats, void *data ) {
 float thruput = stats->bytes_received > 0 ? (float)stats->bytes_received / (float)stats->duration : 0;
 float duration = (float)stats->duration / (float)1000000;
 ((void) sizeof ((settings != ((void *)0)) ? 1 : 0), __extension__ ({ if (settings != ((void *)0)) ; else __assert_fail ("settings != NULL", "print.c", 41, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((stats != ((void *)0)) ? 1 : 0), __extension__ ({ if (stats != ((void *)0)) ; else __assert_fail ("stats != NULL", "print.c", 42, __extension__ __PRETTY_FUNCTION__); }));
 pthread_mutex_lock( &printf_mutex );
 printf( "%i\t%u\t%llu\t%llu\t%.2fs\t%.2f",
  stats->cores, settings->message_size, stats->bytes_received, stats->pkts_received, duration, thruput );
 if ( settings->timestamp )
  printf( "\t%llu\t%llu",stats->pkts_time, stats->timestamps );
 printf("\n");
 pthread_mutex_unlock( &printf_mutex );
 return 0;
}

canonical_original_code:
int print_results(struct settings *settings, struct stats *stats, void *data) {
 float thruput = stats->bytes_received > 0 ? (float)stats->bytes_received / (float)stats->duration : 0;
 float duration = (float)stats->duration / (float)1000000;
 ((void) sizeof ((settings != ((void *)0)) ? 1 : 0), __extension__ ({ if (settings != ((void *)0)) ; else __assert_fail ("settings != NULL", "print.c", 41, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((stats != ((void *)0)) ? 1 : 0), __extension__ ({ if (stats != ((void *)0)) ; else __assert_fail ("stats != NULL", "print.c", 42, __extension__ __PRETTY_FUNCTION__); }));
 pthread_mutex_lock( &printf_mutex );
 printf( "%i\t%u\t%llu\t%llu\t%.2fs\t%.2f",
  stats->cores, settings->message_size, stats->bytes_received, stats->pkts_received, duration, thruput );
 if ( settings->timestamp )
  printf( "\t%llu\t%llu",stats->pkts_time, stats->timestamps );
 printf("\n");
 pthread_mutex_unlock( &printf_mutex );
 return 0;
}

variable_types: struct stats { unsigned int cores; unsigned long long bytes_received; unsigned long long pkts_received; unsigned long long pkts_time; unsigned long long timestamps; unsigned long long duration; } *

variable_types: thruput float

variable_types: duration float


decompiled_code:
int __fastcall print_stats(double a1, double a2, double a3, double a4)
{
return printf("sum %f sumsquare %f mean %f variance %.f\n", a1, a2, a3, a4);
}

canonical_decompiled_code:
int __fastcall func2(double a1, double a2, double a3, double a4)
{
return printf("sum %f sumsquare %f mean %f variance %.f\n", a1, a2, a3, a4);
}

original_code:
void print_stats(double sum, double sumsquare, double mean, double variance) {
 printf("sum %f sumsquare %f mean %f variance %.f\n",sum, sumsquare, mean, variance);
}

variable_types: sum double

variable_types: sumsquare double

variable_types: mean double

variable_types: variance double


decompiled_code:
int __fastcall print_hex(unsigned __int8 *a1, int a2)
{
int result; // eax
int v3; // ebx
unsigned __int8 *v4; // r13
const unsigned __int16 **v5; // r12
unsigned int v6; // er14
size_t v7; // rax
size_t v8; // rax
size_t v9; // rax
size_t v10; // rax
char s[4]; // [rsp+Ah] [rbp-A6h] BYREF
char v12[8]; // [rsp+Eh] [rbp-A2h] BYREF
__int16 v13; // [rsp+16h] [rbp-9Ah]
char v14[16]; // [rsp+18h] [rbp-98h] BYREF
int v15; // [rsp+28h] [rbp-88h]
char v16; // [rsp+2Ch] [rbp-84h]
char dest[16]; // [rsp+38h] [rbp-78h] BYREF
__int128 v18; // [rsp+48h] [rbp-68h]
__int128 v19; // [rsp+58h] [rbp-58h]
int v20; // [rsp+68h] [rbp-48h]
char v21; // [rsp+6Ch] [rbp-44h]

result = 0;
*(_DWORD *)s = 0;
*(_QWORD *)v12 = 0LL;
v13 = 0;
v20 = 0;
v21 = 0;
v15 = 0;
v16 = 0;
*(_OWORD *)dest = 0LL;
v18 = 0LL;
v19 = 0LL;
*(_OWORD *)v14 = 0LL;
if ( !a1 )
_assert_fail("data != NULL", "print.c", 0x5Cu, "print_hex");
if ( a2 > 0 )
{
v3 = 1;
v4 = a1;
v5 = _ctype_b_loc();
do
{
while ( 1 )
{
if ( (v3 & 0xF) == 1 )
snprintf(v12, 0xAuLL, "%.4x", v4 - a1);
v6 = 46;
if ( ((*v5)[*v4] & 8) != 0 )
v6 = *v4;
snprintf(s, 4uLL, "%02X ");
v7 = strlen(dest);
strncat(dest, s, 52 - v7);
snprintf(s, 4uLL, "%c", v6);
v8 = strlen(v14);
result = (unsigned int)strncat(v14, s, 20 - v8);
if ( (v3 & 0xF) != 0 )
break;
++v3;
++v4;
result = printf("[%4.4s] %-50.50s %s\n", v12, dest, v14);
dest[0] = 0;
v14[0] = 0;
if ( a2 < v3 )
goto LABEL_13;
}
if ( (v3 & 7) == 0 )
{
v9 = strlen(dest);
strncat(dest, " ", 52 - v9);
v10 = strlen(v14);
result = (unsigned int)strncat(v14, " ", 20 - v10);
}
++v3;
++v4;
}
while ( a2 >= v3 );
LABEL_13:
if ( dest[0] )
result = printf("[%4.4s] %-50.50s %s\n", v12, dest, v14);
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(unsigned __int8 *a1, int a2)
{
int result; // eax
int v3; // ebx
unsigned __int8 *v4; // r13
const unsigned __int16 **v5; // r12
unsigned int v6; // er14
size_t v7; // rax
size_t v8; // rax
size_t v9; // rax
size_t v10; // rax
char s[4]; // [rsp+Ah] [rbp-A6h] BYREF
char v12[8]; // [rsp+Eh] [rbp-A2h] BYREF
__int16 v13; // [rsp+16h] [rbp-9Ah]
char v14[16]; // [rsp+18h] [rbp-98h] BYREF
int v15; // [rsp+28h] [rbp-88h]
char v16; // [rsp+2Ch] [rbp-84h]
char dest[16]; // [rsp+38h] [rbp-78h] BYREF
__int128 v18; // [rsp+48h] [rbp-68h]
__int128 v19; // [rsp+58h] [rbp-58h]
int v20; // [rsp+68h] [rbp-48h]
char v21; // [rsp+6Ch] [rbp-44h]

result = 0;
*(_DWORD *)s = 0;
*(_QWORD *)v12 = 0LL;
v13 = 0;
v20 = 0;
v21 = 0;
v15 = 0;
v16 = 0;
*(_OWORD *)dest = 0LL;
v18 = 0LL;
v19 = 0LL;
*(_OWORD *)v14 = 0LL;
if ( !a1 )
_assert_fail("data != NULL", "print.c", 0x5Cu, "print_hex");
if ( a2 > 0 )
{
v3 = 1;
v4 = a1;
v5 = _ctype_b_loc();
do
{
while ( 1 )
{
if ( (v3 & 0xF) == 1 )
snprintf(v12, 0xAuLL, "%.4x", v4 - a1);
v6 = 46;
if ( ((*v5)[*v4] & 8) != 0 )
v6 = *v4;
snprintf(s, 4uLL, "%02X ");
v7 = strlen(dest);
strncat(dest, s, 52 - v7);
snprintf(s, 4uLL, "%c", v6);
v8 = strlen(v14);
result = (unsigned int)strncat(v14, s, 20 - v8);
if ( (v3 & 0xF) != 0 )
break;
++v3;
++v4;
result = printf("[%4.4s] %-50.50s %s\n", v12, dest, v14);
dest[0] = 0;
v14[0] = 0;
if ( a2 < v3 )
goto LABEL_13;
}
if ( (v3 & 7) == 0 )
{
v9 = strlen(dest);
strncat(dest, " ", 52 - v9);
v10 = strlen(v14);
result = (unsigned int)strncat(v14, " ", 20 - v10);
}
++v3;
++v4;
}
while ( a2 >= v3 );
LABEL_13:
if ( dest[0] )
result = printf("[%4.4s] %-50.50s %s\n", v12, dest, v14);
}
return result;
}

original_code:
void print_hex(void *data, int size){
    unsigned char *p = data;
    unsigned char c;
    int n;
    char bytestr[4] = {0};
    char addrstr[10] = {0};
    char hexstr[ 16*3 + 5] = {0};
    char charstr[16*1 + 5] = {0};
 ((void) sizeof ((data != ((void *)0)) ? 1 : 0), __extension__ ({ if (data != ((void *)0)) ; else __assert_fail ("data != NULL", "print.c", 92, __extension__ __PRETTY_FUNCTION__); }));
    for(n=1;n<=size;n++) {
        if (n%16 == 1) {
            snprintf(addrstr, sizeof(addrstr), "%.4x",
               (unsigned int)(p- (unsigned char*) data) );
        }
        c = *p;
        if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISalnum) == 0) {
            c = '.';
        }
        snprintf(bytestr, sizeof(bytestr), "%02X ", *p);
        strncat(hexstr, bytestr, sizeof(hexstr)-strlen(hexstr)-1);
        snprintf(bytestr, sizeof(bytestr), "%c", c);
        strncat(charstr, bytestr, sizeof(charstr)-strlen(charstr)-1);
        if(n%16 == 0) {
            printf("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
            hexstr[0] = 0;
            charstr[0] = 0;
        } else if(n%8 == 0) {
            strncat(hexstr, "  ", sizeof(hexstr)-strlen(hexstr)-1);
            strncat(charstr, " ", sizeof(charstr)-strlen(charstr)-1);
        }
        p++;
    }
    if (strlen(hexstr) > 0) {
        printf("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
    }
}

canonical_original_code:
void print_hex(void *data, int size){
    unsigned char *p = data;
    unsigned char c;
    int n;
    char bytestr[4] = {0};
    char addrstr[10] = {0};
    char hexstr[-1] = {0};
    char charstr[-1] = {0};
 ((void) sizeof ((data != ((void *)0)) ? 1 : 0), __extension__ ({ if (data != ((void *)0)) ; else __assert_fail ("data != NULL", "print.c", 92, __extension__ __PRETTY_FUNCTION__); }));
    for(n=1;n<=size;n++) {
        if (n%16 == 1) {
            snprintf(addrstr, sizeof(addrstr), "%.4x",
               (unsigned int)(p- (unsigned char *) data) );
        }
        c = *p;
        if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISalnum) == 0) {
            c = '.';
        }
        snprintf(bytestr, sizeof(bytestr), "%02X ", *p);
        strncat(hexstr, bytestr, sizeof(hexstr)-strlen(hexstr)-1);
        snprintf(bytestr, sizeof(bytestr), "%c", c);
        strncat(charstr, bytestr, sizeof(charstr)-strlen(charstr)-1);
        if(n%16 == 0) {
            printf("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
            hexstr[0] = 0;
            charstr[0] = 0;
        } else if(n%8 == 0) {
            strncat(hexstr, "  ", sizeof(hexstr)-strlen(hexstr)-1);
            strncat(charstr, " ", sizeof(charstr)-strlen(charstr)-1);
        }
        p++;
    }
    if (strlen(hexstr) > 0) {
        printf("[%4.4s]   %-50.50s  %s\n", addrstr, hexstr, charstr);
    }
}

variable_types: size int

variable_types:
p
unsigned char *

variable_types:
c
unsigned char

variable_types: n int

variable_types:
bytestr
char [4]

variable_types:
addrstr
char [10]

variable_types:
hexstr
char [-1]

variable_types:
charstr
char [-1]