decompiled_code:
int test_brk()
{
char *v0; // rbx
char *v1; // rbx
int v2; // ebp
unsigned int v3; // esi
void *v4; // rax
int *v6; // rbx
char *v7; // rax

v0 = (char *)sbrk(0LL);
printf("Programe break address:\t\t%p\n", v0);
if ( valoc_mem >= (unsigned __int64)v0 )
printf("prot-break before valloc:%x\n", valoc_mem - (_QWORD)v0);
else
printf("prot-break after valloc:%x\n", &v0[-valoc_mem]);
v1 = v0 + 0x20000000;
v2 = 0x20000000;
while ( !brk(v1) )
{
v3 = v2;
v2 += 0x20000000;
v1 += 0x20000000;
printf("brked %dM memory.\n", v3 >> 20);
if ( v2 == -536870912 )
{
v4 = sbrk(0LL);
return printf("Programe break address after:\t%p\n", v4);
}
}
printf("Can not use brk to set programe break.");
v6 = __errno_location();
v7 = strerror(*v6);
return printf(" (%d:%s)\n", (unsigned int)*v6, v7);
}

canonical_decompiled_code:
int func8()
{
char *v0; // rbx
char *v1; // rbx
int v2; // ebp
unsigned int v3; // esi
void *v4; // rax
int *v6; // rbx
char *v7; // rax

v0 = (char *)sbrk(0LL);
printf("Programe break address:\t\t%p\n", v0);
if ( valoc_mem >= (unsigned __int64)v0 )
printf("prot-break before valloc:%x\n", valoc_mem - (_QWORD)v0);
else
printf("prot-break after valloc:%x\n", &v0[-valoc_mem]);
v1 = v0 + 0x20000000;
v2 = 0x20000000;
while ( !brk(v1) )
{
v3 = v2;
v2 += 0x20000000;
v1 += 0x20000000;
printf("brked %dM memory.\n", v3 >> 20);
if ( v2 == -536870912 )
{
v4 = sbrk(0LL);
return printf("Programe break address after:\t%p\n", v4);
}
}
printf("Can not use brk to set programe break.");
v6 = __errno_location();
v7 = strerror(*v6);
return printf(" (%d:%s)\n", (unsigned int)*v6, v7);
}

original_code:
void
test_brk(void)
{
 void *prog_break;
 unsigned int brk_len;
 int ret;
 int i;
 prog_break = sbrk(0);
 printf("Programe break address:\t\t%p\n", prog_break);
 if (prog_break > valoc_mem)
  printf("prot-break after valloc:%x\n", prog_break-valoc_mem);
 else
  printf("prot-break before valloc:%x\n", valoc_mem-prog_break);
 brk_len = 0x20000000;
 for (i=0; i<6; i++) {
  ret = brk(prog_break+brk_len);
  if(ret) {
   do { printf("Can not use brk to set programe break."); printf(" (%d:%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
   goto failed;
  }
  printf("brked %dM memory.\n", brk_len/1024/1024);
  brk_len += 0x20000000;
 }
 prog_break = sbrk(0);
 printf("Programe break address after:\t%p\n", prog_break);
failed:
 return;
}

canonical_original_code:
void test_brk()
{
 void *prog_break;
 unsigned int brk_len;
 int ret;
 int i;
 prog_break = sbrk(0);
 printf("Programe break address:\t\t%p\n", prog_break);
 if (prog_break > valoc_mem)
  printf("prot-break after valloc:%x\n", prog_break-valoc_mem);
 else
  printf("prot-break before valloc:%x\n", valoc_mem-prog_break);
 brk_len = 0x20000000;
 for (i=0; i<6; i++) {
  ret = brk(prog_break+brk_len);
  if(ret) {
   do { printf("Can not use brk to set programe break."); printf(" (%d:%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
   goto failed;
  }
  printf("brked %dM memory.\n", brk_len/1024/1024);
  brk_len += 0x20000000;
 }
 prog_break = sbrk(0);
 printf("Programe break address after:\t%p\n", prog_break);
failed:
 return;
}

variable_types: ret int


decompiled_code:
int test_malloc()
{
unsigned __int64 v0; // rbx
void *v1; // rax
int *v2; // rbx
char *v3; // rax

v0 = 0LL;
while ( 1 )
{
v1 = malloc(0x100000uLL);
if ( !v1 )
break;
v0 += 0x100000LL;
qmemcpy(v1, "hellohello", 10);
if ( v0 == 12582912 )
return (int)v1;
}
printf("Allocated %dM memory.", v0 >> 20);
printf("Can not malloc memory.");
v2 = __errno_location();
v3 = strerror(*v2);
LODWORD(v1) = printf(" (%d:%s)\n", (unsigned int)*v2, v3);
return (int)v1;
}

canonical_decompiled_code:
int func9()
{
unsigned __int64 v0; // rbx
void *v1; // rax
int *v2; // rbx
char *v3; // rax

v0 = 0LL;
while ( 1 )
{
v1 = malloc(0x100000uLL);
if ( !v1 )
break;
v0 += 0x100000LL;
qmemcpy(v1, "hellohello", 10);
if ( v0 == 12582912 )
return (int)v1;
}
printf("Allocated %dM memory.", v0 >> 20);
printf("Can not malloc memory.");
v2 = __errno_location();
v3 = strerror(*v2);
LODWORD(v1) = printf(" (%d:%s)\n", (unsigned int)*v2, v3);
return (int)v1;
}

original_code:
void
test_malloc(void)
{
 void *ptr;
 int i;
 size_t aloc_unit_size = 0x100000;
 size_t aloc_size = 0;
 for (i=0; i<12; i++) {
  ptr = malloc(aloc_unit_size);
  if (ptr == ((void *)0)) {
   printf("Allocated %dM memory.", aloc_size/1024/1024);
   do { printf("Can not malloc memory."); printf(" (%d:%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
   goto failed;
  }
  memcpy(ptr, "hellohello", 10);
  aloc_size += aloc_unit_size;
 }
failed:
 return;
}

canonical_original_code:
void test_malloc()
{
 void *ptr;
 int i;
 unsigned long aloc_unit_size = 0x100000;
 unsigned long aloc_size = 0;
 for (i=0; i<12; i++) {
  ptr = malloc(aloc_unit_size);
  if (ptr == ((void *)0)) {
   printf("Allocated %dM memory.", aloc_size/1024/1024);
   do { printf("Can not malloc memory."); printf(" (%d:%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
   goto failed;
  }
  memcpy(ptr, "hellohello", 10);
  aloc_size += aloc_unit_size;
 }
failed:
 return;
}

variable_types:
ptr
void *

variable_types: i int

return_type: void


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

if ( !getrlimit(RLIMIT_DATA, &v3) )
return printf("Data segment size limit cur:%d, max:%d\n", v3.rlim_cur, v3.rlim_max);
printf("Get data segment size error.");
v1 = __errno_location();
v2 = strerror(*v1);
return printf(" (%d:%s)\n", (unsigned int)*v1, v2);
}

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

if ( !getrlimit(RLIMIT_DATA, &v3) )
return printf("Data segment size limit cur:%d, max:%d\n", v3.rlim_cur, v3.rlim_max);
printf("Get data segment size error.");
v1 = __errno_location();
v2 = strerror(*v1);
return printf(" (%d:%s)\n", (unsigned int)*v1, v2);
}

original_code:
void
test_rlimit(void)
{
 struct rlimit lmt;
 if (getrlimit(RLIMIT_DATA, &lmt)) {
  do { printf("Get data segment size error."); printf(" (%d:%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  goto failed;
 }
 printf("Data segment size limit cur:%d, max:%d\n", lmt.rlim_cur, lmt.rlim_max);
failed:
 return;
}

canonical_original_code:
void test_rlimit()
{
 struct rlimit lmt;
 if (getrlimit(RLIMIT_DATA, &lmt)) {
  do { printf("Get data segment size error."); printf(" (%d:%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  goto failed;
 }
 printf("Data segment size limit cur:%d, max:%d\n", lmt.rlim_cur, lmt.rlim_max);
failed:
 return;
}

variable_types: struct rlimit { unsigned long rlim_cur; unsigned long rlim_max; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
test_brk(argc, argv, envp);
test_malloc();
test_rlimit();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func8(argc, argv, envp);
func9();
func10();
return 0;
}

original_code:
int
main(int argc, char *args[])
{
 char s[10];
 test_brk();
 test_malloc();
 test_rlimit();
 return 0;
}

variable_types: argc int

variable_types:
args
char *[]

variable_types:
s
char [10]

return_type: int


original_code:
static inline void bw_list_del(struct bw_list_head *entry)
{
 __bw_list_del(entry->prev, entry->next);
 entry->next = ((void *) 0x00100100);
 entry->prev = ((void *) 0x00200200);
}

variable_types: struct bw_list_head { struct bw_list_head *next; } *


decompiled_code:
_DWORD *bw_timer_create_queue()
{
char *v0; // rax
_DWORD *v1; // r12
int *v3; // rbx
char *v4; // rax

v0 = (char *)calloc(1uLL, 0x80uLL);
v1 = v0;
if ( !v0 )
{
puts("BWTIMER: Can not alloc mem for timer queue.");
return v1;
}
*(_QWORD *)v0 = v0;
*((_QWORD *)v0 + 1) = v0;
*((_QWORD *)v0 + 2) = v0;
*((_QWORD *)v0 + 3) = 0x20000000ELL;
*((_QWORD *)v0 + 4) = _bw_timer_routine;
*((_QWORD *)v0 + 5) = 0LL;
if ( !timer_create(0, (struct sigevent *)(v0 + 16), (timer_t *)v0 + 10) )
{
v1[30] = 0;
return v1;
}
v3 = _errno_location();
v4 = strerror(*v3);
printf("BWTIMER: timer_create failed. %d(%s)\n", (unsigned int)*v3, v4);
free(v1);
return 0LL;
}

canonical_decompiled_code:
_DWORD *func12()
{
char *v0; // rax
_DWORD *v1; // r12
int *v3; // rbx
char *v4; // rax

v0 = (char *)calloc(1uLL, 0x80uLL);
v1 = v0;
if ( !v0 )
{
puts("BWTIMER: Can not alloc mem for timer queue.");
return v1;
}
*(_QWORD *)v0 = v0;
*((_QWORD *)v0 + 1) = v0;
*((_QWORD *)v0 + 2) = v0;
*((_QWORD *)v0 + 3) = 0x20000000ELL;
*((_QWORD *)v0 + 4) = _bw_timer_routine;
*((_QWORD *)v0 + 5) = 0LL;
if ( !timer_create(0, (struct sigevent *)(v0 + 16), (timer_t *)v0 + 10) )
{
v1[30] = 0;
return v1;
}
v3 = _errno_location();
v4 = strerror(*v3);
printf("BWTIMER: timer_create failed. %d(%s)\n", (unsigned int)*v3, v4);
free(v1);
return 0LL;
}

original_code:
bw_timer_queue_t *bw_timer_create_queue(void)
{
 bw_timer_queue_t *queue = ((void *)0);
 int ret;
 queue = calloc(1, sizeof(bw_timer_queue_t));
 if (!queue) {
  printf("BWTIMER: Can not alloc mem for timer queue.\n");
  goto failed;
 }
 do { (&queue->tmq_list)->next = (&queue->tmq_list); (&queue->tmq_list)->prev = (&queue->tmq_list); } while (0);
 queue->tmq_sige.sigev_value.sival_ptr = queue;
 queue->tmq_sige.sigev_signo = 14;
 queue->tmq_sige.sigev_notify = SIGEV_THREAD;
 queue->tmq_sige._sigev_un._sigev_thread._function = __bw_timer_routine;
 queue->tmq_sige._sigev_un._sigev_thread._attribute = ((void *)0);
 ret = timer_create(0, &queue->tmq_sige, &queue->tmq_id);
 if (ret) {
  printf("BWTIMER: timer_create failed. %d(%s)\n", (*__errno_location ()), strerror((*__errno_location ())));
  goto failed;
 }
 queue->tmq_count = 0;
 return queue;
failed:
 if (queue)
  free(queue);
 return ((void *)0);
}

canonical_original_code:
struct _bw_timer_queue *bw_timer_create_queue()
{
 struct _bw_timer_queue *queue = ((void *)0);
 int ret;
 queue = calloc(1, sizeof(bw_timer_queue_t));
 if (!queue) {
  printf("BWTIMER: Can not alloc mem for timer queue.\n");
  goto failed;
 }
 do { (&queue->tmq_list)->next = (&queue->tmq_list); (&queue->tmq_list)->prev = (&queue->tmq_list); } while (0);
 queue->tmq_sige.sigev_value.sival_ptr = queue;
 queue->tmq_sige.sigev_signo = 14;
 queue->tmq_sige.sigev_notify = SIGEV_THREAD;
 queue->tmq_sige._sigev_un._sigev_thread._function = __bw_timer_routine;
 queue->tmq_sige._sigev_un._sigev_thread._attribute = ((void *)0);
 ret = timer_create(0, &queue->tmq_sige, &queue->tmq_id);
 if (ret) {
  printf("BWTIMER: timer_create failed. %d(%s)\n", (*__errno_location ()), strerror((*__errno_location ())));
  goto failed;
 }
 queue->tmq_count = 0;
 return queue;
failed:
 if (queue)
  free(queue);
 return ((void *)0);
}

variable_types: struct _bw_timer_queue { struct bw_list_head { struct bw_list_head *next; } tmq_list; struct sigevent { union sigval { int sival_int; void *sival_ptr; } sigev_value; int sigev_signo; int sigev_notify; union { int _pad[-1]; int _tid; struct { void (*_function)(union sigval); union pthread_attr_t { char __size[56]; long __align; } *_attribute; } _sigev_thread; } _sigev_un; } tmq_sige; void *tmq_id; struct itimerspec { struct timespec { long tv_sec; long tv_nsec; } it_interval; struct timespec it_value; } tmq_timeo; int tmq_count; } *

user_defined_types: struct _bw_timer_queue { struct bw_list_head tmq_list; struct sigevent tmq_sige; void *tmq_id; struct itimerspec tmq_timeo; int tmq_count; }

user_defined_types: struct sigevent { union sigval sigev_value; int sigev_signo; int sigev_notify; union { int _pad[-1]; int _tid; struct { void (*_function)(union sigval); union pthread_attr_t *_attribute; } _sigev_thread; } _sigev_un; }

user_defined_types: struct itimerspec { struct timespec it_interval; struct timespec it_value; }


decompiled_code:
__int64 __fastcall bw_timer_queue_timer(_QWORD **a1, __m128i *a2)
{
_bw_timer_timer_update_timeo(a2, 1);
_bw_timer_queue_insert(a1, a2);
if ( (unsigned int)_bw_timer_queue_update_timeo((__int64)a1) )
puts("BWTIMER: queue timer update timeo failed, ignore");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(_QWORD **a1, __m128i *a2)
{
func10(a2, 1);
func7(a1, a2);
if ( (unsigned int)func9((__int64)a1) )
puts("BWTIMER: queue timer update timeo failed, ignore");
return 0LL;
}

original_code:
int32_t bw_timer_queue_timer(bw_timer_queue_t *queue, bw_timer_timer_t *timer)
{
 int ret;
 __bw_timer_timer_update_timeo(timer, 1);
 __bw_timer_queue_insert(queue, timer);
 ret = __bw_timer_queue_update_timeo(queue);
 if (ret)
  printf("BWTIMER: queue timer update timeo failed, ignore\n");
 return 0;
}

canonical_original_code:
int bw_timer_queue_timer(struct _bw_timer_queue *queue, struct _bw_timer_timer *timer)
{
 int ret;
 __bw_timer_timer_update_timeo(timer, 1);
 __bw_timer_queue_insert(queue, timer);
 ret = __bw_timer_queue_update_timeo(queue);
 if (ret)
  printf("BWTIMER: queue timer update timeo failed, ignore\n");
 return 0;
}

variable_types: struct _bw_timer_timer { struct bw_list_head tm_node; int (*tm_handler)(void *); void *tm_args; struct timeval { long tv_sec; long tv_usec; } tm_begin; struct timeval tm_tick; struct timeval tm_timeo; } *

user_defined_types: struct _bw_timer_timer { struct bw_list_head tm_node; int (*tm_handler)(void *); void *tm_args; struct timeval tm_begin; struct timeval tm_tick; struct timeval tm_timeo; }

user_defined_types: struct bw_list_head { struct bw_list_head *next; }

user_defined_types: union sigval { int sival_int; void *sival_ptr; }

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

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


decompiled_code:
__int64 __fastcall bw_timer_unqueue_timer(__int64 a1, __int64 a2)
{
__int64 v2; // r8

_bw_timer_queue_delete(a1, a2);
if ( (unsigned int)_bw_timer_queue_update_timeo(v2) )
puts("BWTIMER: queue timer update timeo failed, ignore");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2)
{
__int64 v2; // r8

func8(a1, a2);
if ( (unsigned int)func9(v2) )
puts("BWTIMER: queue timer update timeo failed, ignore");
return 0LL;
}

original_code:
int32_t bw_timer_unqueue_timer(bw_timer_queue_t *queue, bw_timer_timer_t *timer)
{
 int ret;
 __bw_timer_queue_delete(queue, timer);
 ret = __bw_timer_queue_update_timeo(queue);
 if (ret)
  printf("BWTIMER: queue timer update timeo failed, ignore\n");
 return 0;
}

canonical_original_code:
int bw_timer_unqueue_timer(struct _bw_timer_queue *queue, struct _bw_timer_timer *timer)
{
 int ret;
 __bw_timer_queue_delete(queue, timer);
 ret = __bw_timer_queue_update_timeo(queue);
 if (ret)
  printf("BWTIMER: queue timer update timeo failed, ignore\n");
 return 0;
}

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


decompiled_code:
int __fastcall task_start(__int64 a1)
{
return pthread_create((pthread_t *)a1, 0LL, *(void *(**)(void *))(a1 + 8), *(void **)(a1 + 24));
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
return pthread_create((pthread_t *)a1, 0LL, *(void *(**)(void *))(a1 + 8), *(void **)(a1 + 24));
}

original_code:
int
task_start(struct task *t)
{
 return pthread_create(&t->tid, ((void *)0), t->rt, t->arg);
}

variable_types: struct task { unsigned long tid; void *(*rt)(void *t); int status; void *arg; void *ret; } *


decompiled_code:
int __fastcall task_stop(pthread_t *a1)
{
return pthread_kill(*a1, 15);
}

canonical_decompiled_code:
int __fastcall func1(pthread_t *a1)
{
return pthread_kill(*a1, 15);
}

original_code:
int
task_stop(struct task *t)
{
 return pthread_kill(t->tid, 15);
}

user_defined_types: struct task { unsigned long tid; void *(*rt)(void *t); int status; void *arg; void *ret; }


decompiled_code:
int __fastcall task_wait(pthread_t *a1)
{
return pthread_join(*a1, 0LL);
}

canonical_decompiled_code:
int __fastcall func2(pthread_t *a1)
{
return pthread_join(*a1, 0LL);
}

original_code:
int
task_wait(struct task *t)
{
 return pthread_join(t->tid, ((void *)0));
}


decompiled_code:
__int64 task_timewait()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func3()
{
return 0xFFFFFFFFLL;
}

original_code:
int
task_timewait(struct task *t)
{
 return -1;
}


original_code:
static inline int
uskb_header_cpy(struct usk_buff *uskb, void *buff)
{
 memcpy(buff, ((uskb)->direct ? ((uskb)->header)+(uskb)->header_max-(uskb)->header_len :(uskb)->header), uskb->header_len);
 return uskb->header_len;
}

variable_types: struct usk_buff { struct usk_buff *prev; struct usk_buff *next; unsigned char direct; void *header; void *payload; unsigned short header_len; void *network_header; void *transport_header; struct btqueue_node { struct btqueue_node *next; } q_send; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct uprotocol { void (*close)(struct usock { int usk_mode; struct usk_buff_head { struct usk_buff *prev; struct usk_buff *next; unsigned short qlen; 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; } loc; } *usk_write_queue; struct usk_buff_head *usk_receive_queue; } *sk, long timeout); int (*connect)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); int (*disconnect)(struct usock *sk, int flags); struct usock *(*accept)(struct usock *sk, int flags, int *err); int (*ioctl)(struct usock *sk, int cmd, unsigned long arg); int (*init)(struct usock *sk); void (*destroy)(struct usock *sk); void (*shutdown)(struct usock *sk, int how); int (*setsockopt)(struct usock *sk, int level, int optname, char *optval, int optlen); int (*getsockopt)(struct usock *sk, int level, int optname, char *optval, int *option); int (*bind)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); char name[32]; int proto_num; struct list_head { struct list_head *next; } node; int (*header_len)(struct usk_buff *uskb); int (*handler)(struct usk_buff *uskb); } *proto; } *

variable_types:
buff
void *

user_defined_types: struct usk_buff { struct usk_buff *prev; struct usk_buff *next; unsigned char direct; void *header; void *payload; unsigned short header_len; void *network_header; void *transport_header; struct btqueue_node q_send; struct sockaddr_in sin; struct uprotocol *proto; }

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

user_defined_types: struct uprotocol { void (*close)(struct usock *sk, long timeout); int (*connect)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); int (*disconnect)(struct usock *sk, int flags); struct usock *(*accept)(struct usock *sk, int flags, int *err); int (*ioctl)(struct usock *sk, int cmd, unsigned long arg); int (*init)(struct usock *sk); void (*destroy)(struct usock *sk); void (*shutdown)(struct usock *sk, int how); int (*setsockopt)(struct usock *sk, int level, int optname, char *optval, int optlen); int (*getsockopt)(struct usock *sk, int level, int optname, char *optval, int *option); int (*bind)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); char name[32]; int proto_num; struct list_head node; int (*header_len)(struct usk_buff *uskb); int (*handler)(struct usk_buff *uskb); }

user_defined_types: struct usock { int usk_mode; struct usk_buff_head *usk_write_queue; struct usk_buff_head *usk_receive_queue; }

user_defined_types: struct usk_buff_head { struct usk_buff *prev; struct usk_buff *next; unsigned short qlen; union pthread_mutex_t loc; }

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:
__int64 usender_start()
{
__int64 v0; // r12

v0 = task_create(usender);
task_start(v0);
return v0;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 v0; // r12

v0 = task_create(usender);
task_start(v0);
return v0;
}

original_code:
struct task *
usender_start(void)
{
 struct task *snd_task;
 snd_task = task_create(usender);
 task_start(snd_task);
 return snd_task;
}

canonical_original_code:
struct task *usender_start()
{
 struct task *snd_task;
 snd_task = task_create(usender);
 task_start(snd_task);
 return snd_task;
}

return_type: struct task { unsigned long tid; void *(*rt)(void *t); int status; void *arg; void *ret; } *


decompiled_code:
int usender_init()
{
atomic_init_constprop_0();
return pthread_mutex_init(&stru_2B0, 0LL);
}

canonical_decompiled_code:
int func9()
{
func2();
return pthread_mutex_init(&stru_2B0, 0LL);
}

original_code:
void
usender_init(void)
{
 do { atomic_init(&(&snd_queue)->len); pthread_mutex_init(&(&snd_queue)->loc, ((void *)0)); } while(0);
 snd_queue_max = 4096;
}

canonical_original_code:
void usender_init()
{
 do { atomic_init(&(&snd_queue)->len); pthread_mutex_init(&(&snd_queue)->loc, ((void *)0)); } while(0);
 snd_queue_max = 4096;
}


hello

decompiled_code:
void __fastcall __noreturn hello(void *a1)
{
int v1; // ebx
int i; // eax

v1 = 50000;
printf("Num:%d decrease thread start\n", a1);
while ( 1 )
{
pthread_mutex_lock(&data_loc);
for ( i = data; data <= 50; i = data )
pthread_cond_wait(&data_cond, &data_loc);
++op_count;
data = i - 1;
pthread_mutex_unlock(&data_loc);
if ( !--v1 )
pthread_exit(0LL);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func7(void *a1)
{
int v1; // ebx
int i; // eax

v1 = 50000;
printf("Num:%d decrease thread start\n", a1);
while ( 1 )
{
pthread_mutex_lock(&data_loc);
for ( i = data; data <= 50; i = data )
pthread_cond_wait(&data_cond, &data_loc);
++op_count;
data = i - 1;
pthread_mutex_unlock(&data_loc);
if ( !--v1 )
pthread_exit(0LL);
}
}

original_code:
void *hello(void *threadid)
{
 long tid;
 int tmp;
 int i;
 tid = (long)threadid;
 printf("Num:%d decrease thread start\n", tid);
 for (i = 0; i<50000; i++) {
  pthread_mutex_lock(&data_loc);
  while (data <= 50) {
   pthread_cond_wait(&data_cond, &data_loc);
  }
  tmp = data;
  tmp -= 1;
  data = tmp;
  op_count++;
  pthread_mutex_unlock(&data_loc);
 }
 pthread_exit(((void *)0));
}

variable_types:
threadid
void *

variable_types: tid long

variable_types: tmp int

return_type: void *


nihao

decompiled_code:
void __fastcall __noreturn nihao(void *a1)
{
int v1; // ebx

v1 = 50050;
printf("Num:%d increase thread start\n", a1);
while ( 1 )
{
pthread_mutex_lock(&data_loc);
++op_count;
if ( ++data <= 50 )
{
pthread_mutex_unlock(&data_loc);
if ( !--v1 )
goto LABEL_5;
}
else
{
pthread_cond_broadcast(&data_cond);
pthread_mutex_unlock(&data_loc);
if ( !--v1 )
LABEL_5:
pthread_exit(0LL);
}
}
}

canonical_decompiled_code:
void __fastcall __noreturn func8(void *a1)
{
int v1; // ebx

v1 = 50050;
printf("Num:%d increase thread start\n", a1);
while ( 1 )
{
pthread_mutex_lock(&data_loc);
++op_count;
if ( ++data <= 50 )
{
pthread_mutex_unlock(&data_loc);
if ( !--v1 )
goto LABEL_5;
}
else
{
pthread_cond_broadcast(&data_cond);
pthread_mutex_unlock(&data_loc);
if ( !--v1 )
LABEL_5:
pthread_exit(0LL);
}
}
}

original_code:
void *nihao(void *threadid)
{
 long tid;
 int tmp;
 int i;
 tid = (long)threadid;
 printf("Num:%d increase thread start\n", tid);
 for (i = 0; i<50050; i++) {
  pthread_mutex_lock(&data_loc);
  tmp = data;
  tmp += 1;
  data = tmp;
  op_count++;
  if (data > 50) {
   pthread_cond_broadcast(&data_cond);
  }
  pthread_mutex_unlock(&data_loc);
 }
 pthread_exit(((void *)0));
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbx
pthread_t *v4; // rbp
unsigned int v5; // eax
__int64 i; // rbx
pthread_t v7; // rdi
pthread_t th[103]; // [rsp+0h] [rbp-338h] BYREF

v3 = 0LL;
pthread_cond_init(&data_cond, 0LL);
v4 = th;
pthread_mutex_init(&data_loc, 0LL);
data = 0;
op_count = 0;
do
{
v5 = pthread_create(v4, 0LL, hello, v3);
if ( v5 || (v5 = pthread_create(&th[(_QWORD)v3 + 50], 0LL, nihao, v3)) != 0 )
{
printf("ERROR; return code from pthread_create() is %d\n", v5);
exit(-1);
}
v3 = (char *)v3 + 1;
++v4;
}
while ( v3 != (void *)50 );
for ( i = 0LL; i != 50; ++i )
{
pthread_join(th[i], 0LL);
v7 = th[i + 50];
pthread_join(v7, 0LL);
}
printf("data is %d\n", (unsigned int)data);
return -1;
}

original_code:
int main (int argc, char *argv[])
{
 pthread_t th_inc_id[50];
 pthread_t th_dec_id[50];
 int ret;
 long i;
 pthread_cond_init(&data_cond, ((void *)0));
 pthread_mutex_init(&data_loc, ((void *)0));
 data = 0;
 op_count = 0;
 for(i=0; i<50; i++){
  ret = pthread_create(&th_inc_id[i], ((void *)0), hello, (void *)i);
  if (ret){
   printf("ERROR; return code from pthread_create() is %d\n", ret);
   exit(-1);
  }
  ret = pthread_create(&th_dec_id[i], ((void *)0), nihao, (void *)i);
  if (ret){
   printf("ERROR; return code from pthread_create() is %d\n", ret);
   exit(-1);
  }
 }
 for(i=0; i<50; i++){
  pthread_join(th_inc_id[i], ((void *)0));
  pthread_join(th_dec_id[i], ((void *)0));
 }
 printf("data is %d\n", data);
 return -1;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 unsigned long th_inc_id[50];
 unsigned long th_dec_id[50];
 int ret;
 long i;
 pthread_cond_init(&data_cond, ((void *)0));
 pthread_mutex_init(&data_loc, ((void *)0));
 data = 0;
 op_count = 0;
 for(i=0; i<50; i++){
  ret = pthread_create(&th_inc_id[i], ((void *)0), hello, (void *)i);
  if (ret){
   printf("ERROR; return code from pthread_create() is %d\n", ret);
   exit(-1);
  }
  ret = pthread_create(&th_dec_id[i], ((void *)0), nihao, (void *)i);
  if (ret){
   printf("ERROR; return code from pthread_create() is %d\n", ret);
   exit(-1);
  }
 }
 for(i=0; i<50; i++){
  pthread_join(th_inc_id[i], ((void *)0));
  pthread_join(th_dec_id[i], ((void *)0));
 }
 printf("data is %d\n", data);
 return -1;
}

variable_types:
argv
char *[]

variable_types: i long


decompiled_code:
__int64 __fastcall lock_unlock(const char *a1)
{
int v1; // eax
int v2; // er13
unsigned int v3; // er12
int *v5; // r12
char *v6; // rax
__int64 v7; // rdx
int *v8; // rbx
char *v9; // rax
int *v10; // rbx
char *v11; // rax

v1 = open(a1, 66, 436LL);
if ( v1 < 0 )
{
v5 = __errno_location();
v6 = strerror(*v5);
v7 = (unsigned int)*v5;
v3 = -1;
printf("failed to open file %s, %d(%s)\n", a1, v7, v6);
}
else
{
v2 = v1;
printf("LOCK: begin. %s\n", a1);
v3 = flock(v2, 2);
if ( v3 == -1 )
{
v8 = __errno_location();
v9 = strerror(*v8);
printf("failed to lock file %s, %d(%s)\n", a1, (unsigned int)*v8, v9);
}
else
{
printf("LOCK: end. %s\n", a1);
printf("SEELP: 30 sec. %s\n", a1);
sleep(0x1Eu);
printf("UNLOCK: begin. %s\n", a1);
v3 = flock(v2, 8);
if ( v3 == -1 )
{
v10 = __errno_location();
v11 = strerror(*v10);
printf("failed to unlock file %s, %d(%s)\n", a1, (unsigned int)*v10, v11);
}
else
{
v3 = 0;
printf("UNLOCK: end. %s\n", a1);
}
}
close(v2);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
int v1; // eax
int v2; // er13
unsigned int v3; // er12
int *v5; // r12
char *v6; // rax
__int64 v7; // rdx
int *v8; // rbx
char *v9; // rax
int *v10; // rbx
char *v11; // rax

v1 = open(a1, 66, 436LL);
if ( v1 < 0 )
{
v5 = __errno_location();
v6 = strerror(*v5);
v7 = (unsigned int)*v5;
v3 = -1;
printf("failed to open file %s, %d(%s)\n", a1, v7, v6);
}
else
{
v2 = v1;
printf("LOCK: begin. %s\n", a1);
v3 = flock(v2, 2);
if ( v3 == -1 )
{
v8 = __errno_location();
v9 = strerror(*v8);
printf("failed to lock file %s, %d(%s)\n", a1, (unsigned int)*v8, v9);
}
else
{
printf("LOCK: end. %s\n", a1);
printf("SEELP: 30 sec. %s\n", a1);
sleep(0x1Eu);
printf("UNLOCK: begin. %s\n", a1);
v3 = flock(v2, 8);
if ( v3 == -1 )
{
v10 = __errno_location();
v11 = strerror(*v10);
printf("failed to unlock file %s, %d(%s)\n", a1, (unsigned int)*v10, v11);
}
else
{
v3 = 0;
printf("UNLOCK: end. %s\n", a1);
}
}
close(v2);
}
return v3;
}

original_code:
int lock_unlock(char *filepath)
{
 int fd = -1, ret = -1;
 fd = open(filepath, (02|0100), 0664);
 if (fd < 0) {
  printf("failed to open file %s, %d(%s)\n",
   filepath, (*__errno_location ()), strerror((*__errno_location ())));
  goto out;
 }
 printf("LOCK: begin.   %s\n", filepath);
 if (flock(fd, 2) == -1) {
  printf("failed to lock file %s, %d(%s)\n",
   filepath, (*__errno_location ()), strerror((*__errno_location ())));
  goto out;
 }
 printf("LOCK: end.     %s\n", filepath);
 printf("SEELP: 30 sec. %s\n", filepath);
 sleep(30);
 printf("UNLOCK: begin. %s\n", filepath);
 if (flock(fd, 8) == -1) {
  printf("failed to unlock file %s, %d(%s)\n",
   filepath, (*__errno_location ()), strerror((*__errno_location ())));
  goto out;
 }
 printf("UNLOCK: end.   %s\n", filepath);
 ret = 0;
out:
 if (fd >= 0)
  close(fd);
 return ret;
}

canonical_original_code:
int lock_unlock(char *filepath)
{
 int fd = -1; int ret = -1;
 fd = open(filepath, (02|0100), 0664);
 if (fd < 0) {
  printf("failed to open file %s, %d(%s)\n",
   filepath, (*__errno_location ()), strerror((*__errno_location ())));
  goto out;
 }
 printf("LOCK: begin.   %s\n", filepath);
 if (flock(fd, 2) == -1) {
  printf("failed to lock file %s, %d(%s)\n",
   filepath, (*__errno_location ()), strerror((*__errno_location ())));
  goto out;
 }
 printf("LOCK: end.     %s\n", filepath);
 printf("SEELP: 30 sec. %s\n", filepath);
 sleep(30);
 printf("UNLOCK: begin. %s\n", filepath);
 if (flock(fd, 8) == -1) {
  printf("failed to unlock file %s, %d(%s)\n",
   filepath, (*__errno_location ()), strerror((*__errno_location ())));
  goto out;
 }
 printf("UNLOCK: end.   %s\n", filepath);
 ret = 0;
out:
 if (fd >= 0)
  close(fd);
 return ret;
}

variable_types:
filepath
char *

variable_types: fd int

variable_types: ret int


worker

decompiled_code:
void *__fastcall worker(void *a1)
{
int v1; // eax
int v2; // ebp
__int64 v3; // rsi
__int64 v4; // rdx

v1 = *((_DWORD *)a1 + 3);
*((_DWORD *)a1 + 4) = 0;
if ( v1 <= 0 )
return 0LL;
v2 = 0;
while ( !(unsigned int)lock_unlock((const char *)a1 + 24) )
{
++*((_DWORD *)a1 + 5);
if ( *((_DWORD *)a1 + 3) <= ++v2 )
return 0LL;
}
v3 = *((unsigned int *)a1 + 2);
v4 = (unsigned int)(*((_DWORD *)a1 + 4) + 1);
*((_DWORD *)a1 + 4) = v4;
printf("worker %d failed %d times\n", v3, v4);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func8(void *a1)
{
int v1; // eax
int v2; // ebp
__int64 v3; // rsi
__int64 v4; // rdx

v1 = *((_DWORD *)a1 + 3);
*((_DWORD *)a1 + 4) = 0;
if ( v1 <= 0 )
return 0LL;
v2 = 0;
while ( !(unsigned int)func7((const char *)a1 + 24) )
{
++*((_DWORD *)a1 + 5);
if ( *((_DWORD *)a1 + 3) <= ++v2 )
return 0LL;
}
v3 = *((unsigned int *)a1 + 2);
v4 = (unsigned int)(*((_DWORD *)a1 + 4) + 1);
*((_DWORD *)a1 + 4) = v4;
printf("worker %d failed %d times\n", v3, v4);
return 0LL;
}

original_code:
void *worker(void *args)
{
 struct worker_spec *ws = args;
 int i;
 ws->ws_fail = 0;
 for (i=0; i<ws->ws_iter; i++) {
  if (lock_unlock(ws->ws_path)) {
   ws->ws_fail++;
   printf("worker %d failed %d times\n",
    ws->ws_id, ws->ws_fail);
   break;
  } else {
   ws->ws_succ++;
  }
 }
 return ((void *)0);
}

variable_types:
args
void *

variable_types: struct worker_spec { unsigned long ws_thid; int ws_id; int ws_iter; int ws_fail; int ws_succ; char ws_path[4096]; } *

variable_types: i int


generator

decompiled_code:
__int64 __fastcall generator(const char *a1, int a2, unsigned int a3)
{
char *v3; // rax
char *v4; // rbx
unsigned int v5; // ebp
unsigned int v6; // er14
int v7; // eax
unsigned int v8; // er14
char *v9; // rax
__int64 v10; // rdx
pthread_t *v11; // r15
__int64 i; // r12
int v13; // eax
unsigned int v14; // ebx
char *v15; // rax
unsigned int *v16; // rbx
__int64 v17; // rcx
__int64 v18; // rdx
__int64 v19; // rsi
char *v22; // [rsp+8h] [rbp-40h]

v3 = (char *)calloc(a2, 0x1018uLL);
v22 = v3;
if ( !v3 )
{
puts("can not alloc mem!!!");
return 0LL;
}
v4 = v3;
v5 = 0;
if ( a2 <= 0 )
{
printf("Result: dirpath=%s, th_count=%d, iter=%d\n", a1, (unsigned int)a2, a3);
return 0LL;
}
while ( 1 )
{
*((_DWORD *)v4 + 2) = v5;
*((_DWORD *)v4 + 3) = a3;
snprintf(v4 + 24, 0x1000uLL, "%s/worker-%d", a1, v5);
v7 = pthread_create((pthread_t *)v4, 0LL, worker, v4);
v8 = v7;
if ( v7 )
break;
v6 = v5 + 1;
v4 += 4120;
if ( a2 == v5 + 1 )
goto LABEL_8;
LABEL_5:
v5 = v6;
}
v4 += 4120;
v9 = strerror(v7);
v10 = v8;
v6 = v5 + 1;
printf("create %d thread failed, %d(%s)\n", v5, v10, v9);
if ( a2 != v5 + 1 )
goto LABEL_5;
LABEL_8:
v11 = (pthread_t *)v22;
for ( i = 0LL; ; i = (unsigned int)(i + 1) )
{
v13 = pthread_join(*v11, 0LL);
v14 = v13;
if ( v13 )
{
v15 = strerror(v13);
printf("wait %d thread failed, %d(%s)\n", (unsigned int)i, v14, v15);
}
v11 += 515;
if ( (_DWORD)i == v5 )
break;
}
printf("Result: dirpath=%s, th_count=%d, iter=%d\n", a1, v6, a3);
v16 = (unsigned int *)(v22 + 8);
do
{
v17 = v16[2];
v18 = v16[3];
v19 = *v16;
v16 += 1030;
printf("worker(%d), success(%d), fail(%d)\n", v19, v18, v17);
}
while ( v16 != (unsigned int *)&v22[4120 * i + 4128] );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1, int a2, unsigned int a3)
{
char *v3; // rax
char *v4; // rbx
unsigned int v5; // ebp
unsigned int v6; // er14
int v7; // eax
unsigned int v8; // er14
char *v9; // rax
__int64 v10; // rdx
pthread_t *v11; // r15
__int64 i; // r12
int v13; // eax
unsigned int v14; // ebx
char *v15; // rax
unsigned int *v16; // rbx
__int64 v17; // rcx
__int64 v18; // rdx
__int64 v19; // rsi
char *v22; // [rsp+8h] [rbp-40h]

v3 = (char *)calloc(a2, 0x1018uLL);
v22 = v3;
if ( !v3 )
{
puts("can not alloc mem!!!");
return 0LL;
}
v4 = v3;
v5 = 0;
if ( a2 <= 0 )
{
printf("Result: dirpath=%s, th_count=%d, iter=%d\n", a1, (unsigned int)a2, a3);
return 0LL;
}
while ( 1 )
{
*((_DWORD *)v4 + 2) = v5;
*((_DWORD *)v4 + 3) = a3;
snprintf(v4 + 24, 0x1000uLL, "%s/worker-%d", a1, v5);
v7 = pthread_create((pthread_t *)v4, 0LL, worker, v4);
v8 = v7;
if ( v7 )
break;
v6 = v5 + 1;
v4 += 4120;
if ( a2 == v5 + 1 )
goto LABEL_8;
LABEL_5:
v5 = v6;
}
v4 += 4120;
v9 = strerror(v7);
v10 = v8;
v6 = v5 + 1;
printf("create %d thread failed, %d(%s)\n", v5, v10, v9);
if ( a2 != v5 + 1 )
goto LABEL_5;
LABEL_8:
v11 = (pthread_t *)v22;
for ( i = 0LL; ; i = (unsigned int)(i + 1) )
{
v13 = pthread_join(*v11, 0LL);
v14 = v13;
if ( v13 )
{
v15 = strerror(v13);
printf("wait %d thread failed, %d(%s)\n", (unsigned int)i, v14, v15);
}
v11 += 515;
if ( (_DWORD)i == v5 )
break;
}
printf("Result: dirpath=%s, th_count=%d, iter=%d\n", a1, v6, a3);
v16 = (unsigned int *)(v22 + 8);
do
{
v17 = v16[2];
v18 = v16[3];
v19 = *v16;
v16 += 1030;
printf("worker(%d), success(%d), fail(%d)\n", v19, v18, v17);
}
while ( v16 != (unsigned int *)&v22[4120 * i + 4128] );
return 0LL;
}

original_code:
int generator(const char *dirpath, int count, int iter)
{
 struct worker_spec *ws = ((void *)0);
 int i, ret;
 ws = calloc(count, sizeof(struct worker_spec));
 if (!ws) {
  printf("can not alloc mem!!!\n");
  goto out;
 }
 for (i=0; i<count; i++) {
  ws[i].ws_id = i;
  ws[i].ws_iter = iter;
  snprintf(ws[i].ws_path, 4096, "%s/worker-%d", dirpath, i);
  ret = pthread_create(&ws[i].ws_thid, ((void *)0), &worker, &ws[i]);
  if (ret) {
   printf("create %d thread failed, %d(%s)\n",
    i, ret, strerror(ret));
  }
 }
 for (i=0; i<count; i++) {
  ret = pthread_join(ws[i].ws_thid, ((void *)0));
  if (ret) {
   printf("wait %d thread failed, %d(%s)\n",
    i, ret, strerror(ret));
  }
 }
 printf("Result: dirpath=%s, th_count=%d, iter=%d\n",
   dirpath, count, iter);
 for (i=0; i<count; i++) {
  printf("worker(%d), success(%d), fail(%d)\n",
   ws[i].ws_id, ws[i].ws_succ, ws[i].ws_fail);
 }
out:
 return 0;
}

canonical_original_code:
int generator(char *dirpath, int count, int iter)
{
 struct worker_spec *ws = ((void *)0);
 int i; int ret;
 ws = calloc(count, sizeof(struct worker_spec));
 if (!ws) {
  printf("can not alloc mem!!!\n");
  goto out;
 }
 for (i=0; i<count; i++) {
  ws[i].ws_id = i;
  ws[i].ws_iter = iter;
  snprintf(ws[i].ws_path, 4096, "%s/worker-%d", dirpath, i);
  ret = pthread_create(&ws[i].ws_thid, ((void *)0), &worker, &ws[i]);
  if (ret) {
   printf("create %d thread failed, %d(%s)\n",
    i, ret, strerror(ret));
  }
 }
 for (i=0; i<count; i++) {
  ret = pthread_join(ws[i].ws_thid, ((void *)0));
  if (ret) {
   printf("wait %d thread failed, %d(%s)\n",
    i, ret, strerror(ret));
  }
 }
 printf("Result: dirpath=%s, th_count=%d, iter=%d\n",
   dirpath, count, iter);
 for (i=0; i<count; i++) {
  printf("worker(%d), success(%d), fail(%d)\n",
   ws[i].ws_id, ws[i].ws_succ, ws[i].ws_fail);
 }
out:
 return 0;
}

variable_types:
dirpath
char *

variable_types: count int

variable_types: iter int

user_defined_types: struct worker_spec { unsigned long ws_thid; int ws_id; int ws_iter; int ws_fail; int ws_succ; char ws_path[4096]; }


main

original_code:
int main(int argc, char *argv[])
{
 char dirpath[4096] = "/mnt/";
 int count = 20;
 int iter = 100;
 int i;
 for (i = 0; i < argc - 1; i++) {
  if (strcmp(argv[i], "-i") == 0) {
   i++;
   iter = atoi(argv[i]);
  } else if (strcmp(argv[i], "-c") == 0) {
   i++;
   count = atoi(argv[i]);
  } else if (strcmp(argv[i], "-d") == 0) {
   i++;
   snprintf(dirpath, 4096, "%s", argv[i]);
  }
 }
 generator(dirpath, count, iter);
 return 0;
}

variable_types: argc int

variable_types:
dirpath
char [4096]


decompiled_code:
__int64 __fastcall ip_csum(unsigned __int16 *a1, int a2)
{
unsigned __int64 v2; // rax
unsigned __int16 *v3; // rcx
__int64 v4; // rdx

if ( a2 <= 0 )
return 0xFFFFFFFFLL;
v2 = 0LL;
v3 = &a1[a2];
do
{
v4 = *a1++;
v2 += v4;
}
while ( a1 != v3 );
return ~((unsigned __int16)v2 + (unsigned int)(v2 >> 16) + (unsigned int)(((unsigned __int16)v2 + (v2 >> 16)) >> 16));
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int16 *a1, int a2)
{
unsigned __int64 v2; // rax
unsigned __int16 *v3; // rcx
__int64 v4; // rdx

if ( a2 <= 0 )
return 0xFFFFFFFFLL;
v2 = 0LL;
v3 = &a1[a2];
do
{
v4 = *a1++;
v2 += v4;
}
while ( a1 != v3 );
return ~((unsigned __int16)v2 + (unsigned int)(v2 >> 16) + (unsigned int)(((unsigned __int16)v2 + (v2 >> 16)) >> 16));
}

original_code:
u16
ip_csum (u16 *buf, int nwords)
{
 unsigned long sum;
 for (sum = 0; nwords > 0; nwords--)
  sum += *buf++;
 sum = (sum >> 16) + (sum & 0xffff);
 sum += (sum >> 16);
 return ~sum;
}

canonical_original_code:
unsigned short ip_csum(unsigned short *buf, int nwords)
{
 unsigned long sum;
 for (sum = 0; nwords > 0; nwords--)
  sum += *buf++;
 sum = (sum >> 16) + (sum & 0xffff);
 sum += (sum >> 16);
 return ~sum;
}

variable_types:
buf
unsigned short *

variable_types: nwords int

variable_types:
sum
unsigned long

return_type: unsigned short


decompiled_code:
__int64 __fastcall uip_header_len(__int64 a1)
{
_BYTE *v1; // rax
__int64 result; // rax

v1 = *(_BYTE **)(a1 + 48);
if ( v1 )
result = 4 * (*v1 & 0xFu);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
_BYTE *v1; // rax
__int64 result; // rax

v1 = *(_BYTE **)(a1 + 48);
if ( v1 )
result = 4 * (*v1 & 0xFu);
else
result = 0LL;
return result;
}

original_code:
int
uip_header_len(struct usk_buff *uskb)
{
 struct iphdr *iph;
 iph = ((struct iphdr *)(((uskb))->network_header));
 if (!iph)
  return 0;
 return (iph->ihl * 4);
}

variable_types: struct usk_buff { struct usk_buff *prev; struct usk_buff *next; unsigned char direct; void *header; void *payload; unsigned short header_len; void *network_header; void *transport_header; struct btqueue_node { struct btqueue_node *next; } q_send; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct uprotocol { void (*close)(struct usock { int usk_mode; struct usk_buff_head { struct usk_buff *prev; struct usk_buff *next; unsigned short qlen; 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; } loc; } *usk_write_queue; struct usk_buff_head *usk_receive_queue; } *sk, long timeout); int (*connect)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); int (*disconnect)(struct usock *sk, int flags); struct usock *(*accept)(struct usock *sk, int flags, int *err); int (*ioctl)(struct usock *sk, int cmd, unsigned long arg); int (*init)(struct usock *sk); void (*destroy)(struct usock *sk); void (*shutdown)(struct usock *sk, int how); int (*setsockopt)(struct usock *sk, int level, int optname, char *optval, int optlen); int (*getsockopt)(struct usock *sk, int level, int optname, char *optval, int *option); int (*bind)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); char name[32]; int proto_num; struct list_head { struct list_head *next; } node; int (*header_len)(struct usk_buff *uskb); int (*handler)(struct usk_buff *uskb); } *proto; } *

variable_types: struct iphdr { unsigned int ihl; unsigned int version; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; } *


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

v1 = *(_QWORD *)(a1 + 48);
if ( v1 )
result = uprotocol_find(*(unsigned __int8 *)(v1 + 9));
else
result = 0LL;
return result;
}

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

v1 = *(_QWORD *)(a1 + 48);
if ( v1 )
result = uprotocol_find(*(unsigned __int8 *)(v1 + 9));
else
result = 0LL;
return result;
}

original_code:
struct uprotocol *
uip_find_proto(struct usk_buff *uskb)
{
 struct iphdr *iph;
 struct uprotocol *proto;
 iph = ((struct iphdr *)(((uskb))->network_header));
 if (!iph)
  return 0;
 proto = uprotocol_find(iph->protocol);
 return proto;
}

canonical_original_code:
struct uprotocol *uip_find_proto(struct usk_buff *uskb)
{
 struct iphdr *iph;
 struct uprotocol *proto;
 iph = ((struct iphdr *)(((uskb))->network_header));
 if (!iph)
  return 0;
 proto = uprotocol_find(iph->protocol);
 return proto;
}

variable_types:
uskb
struct usk_buff *

variable_types: struct uprotocol { void (*close)(struct usock { int usk_mode; struct usk_buff_head { struct usk_buff { struct usk_buff *prev; struct usk_buff *next; unsigned char direct; void *header; void *payload; unsigned short header_len; void *network_header; void *transport_header; struct btqueue_node { struct btqueue_node *next; } q_send; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct uprotocol *proto; } *prev; struct usk_buff *next; unsigned short qlen; 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; } loc; } *usk_write_queue; struct usk_buff_head *usk_receive_queue; } *sk, long timeout); int (*connect)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); int (*disconnect)(struct usock *sk, int flags); struct usock *(*accept)(struct usock *sk, int flags, int *err); int (*ioctl)(struct usock *sk, int cmd, unsigned long arg); int (*init)(struct usock *sk); void (*destroy)(struct usock *sk); void (*shutdown)(struct usock *sk, int how); int (*setsockopt)(struct usock *sk, int level, int optname, char *optval, int optlen); int (*getsockopt)(struct usock *sk, int level, int optname, char *optval, int *option); int (*bind)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); char name[32]; int proto_num; struct list_head { struct list_head *next; } node; int (*header_len)(struct usk_buff *uskb); int (*handler)(struct usk_buff *uskb); } *

user_defined_types: struct iphdr { unsigned int ihl; unsigned int version; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; }


decompiled_code:
__int64 uip_output()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 0LL;
}

original_code:
int
uip_output(struct usk_buff *uskb)
{
 return 0;
}

user_defined_types: struct btqueue_node { struct btqueue_node *next; }

user_defined_types: struct list_head { struct list_head *next; }

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


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

v1 = uprotocol_find(*(unsigned __int8 *)(*(_QWORD *)(a1 + 48) + 9LL));
if ( v1 )
result = (*(__int64 (__fastcall **)(__int64))(v1 + 152))(a1);
else
result = 0xFFFFFFFFLL;
return result;
}

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

v1 = uprotocol_find(*(unsigned __int8 *)(*(_QWORD *)(a1 + 48) + 9LL));
if ( v1 )
result = (*(__int64 (__fastcall **)(__int64))(v1 + 152))(a1);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int
uip_input(struct usk_buff *uskb)
{
 struct iphdr *iph;
 struct uprotocol *proto;
 int ret;
 iph = ((struct iphdr *)(((uskb))->network_header));
 proto = uprotocol_find(iph->protocol);
 if (!proto) {
  return -1;
 }
 ret = proto->handler(uskb);
 return ret;
}


decompiled_code:
int init_data_channel()
{
int v0; // edi
__int16 v1; // ax
socklen_t v2; // edx
int result; // eax
struct sockaddr v4; // [rsp+0h] [rbp-18h] BYREF

client_recv_fd = socket(2, 1, 0);
v0 = client_recv_fd;
v4.sa_family = 2;
v1 = _bswap_16_constprop_0((unsigned int)client_recv_fd, &v4, 16LL);
*(_DWORD *)&v4.sa_data[2] = 0;
*(_WORD *)v4.sa_data = v1;
if ( bind(v0, &v4, v2) == -1 )
{
puts("bind error! ");
exit(0);
}
result = listen(client_recv_fd, 5);
if ( result == -1 )
result = puts("listen error! ");
return result;
}

canonical_decompiled_code:
int func1()
{
int v0; // edi
__int16 v1; // ax
socklen_t v2; // edx
int result; // eax
struct sockaddr v4; // [rsp+0h] [rbp-18h] BYREF

client_recv_fd = socket(2, 1, 0);
v0 = client_recv_fd;
v4.sa_family = 2;
v1 = func0((unsigned int)client_recv_fd, &v4, 16LL);
*(_DWORD *)&v4.sa_data[2] = 0;
*(_WORD *)v4.sa_data = v1;
if ( bind(v0, &v4, v2) == -1 )
{
puts("bind error! ");
exit(0);
}
result = listen(client_recv_fd, 5);
if ( result == -1 )
result = puts("listen error! ");
return result;
}

original_code:
void init_data_channel()
{
 struct sockaddr_in client_addr;
 client_recv_fd = socket(2,SOCK_STREAM,0);
 client_addr.sin_family = 2;
 client_addr.sin_port = htons(30667);
 client_addr.sin_addr.s_addr = ((in_addr_t) 0x00000000);
 if(bind(client_recv_fd,(struct sockaddr*) &client_addr,sizeof(client_addr))==-1){
  printf("bind error! \n");
  exit(0);
 }
 if(listen(client_recv_fd,5)==-1)
  printf("listen error! \n");
}

canonical_original_code:
void init_data_channel()
{
 struct sockaddr_in client_addr;
 client_recv_fd = socket(2,SOCK_STREAM,0);
 client_addr.sin_family = 2;
 client_addr.sin_port = htons(30667);
 client_addr.sin_addr.s_addr = ((unsigned int) 0x00000000);
 if(bind(client_recv_fd,(struct sockaddr *) &client_addr,sizeof(client_addr))==-1){
  printf("bind error! \n");
  exit(0);
 }
 if(listen(client_recv_fd,5)==-1)
  printf("listen error! \n");
}

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

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


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

if ( close(client_recv_fd) )
result = puts("data chenal close failed ");
else
result = puts("data chenal close success ");
return result;
}

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

if ( close(client_recv_fd) )
result = puts("data chenal close failed ");
else
result = puts("data chenal close success ");
return result;
}

original_code:
void close_data_channel()
{
 if(close(client_recv_fd) == 0)
  printf("data chenal close success \n");
 else
  printf("data chenal close failed \n");
}


decompiled_code:
int get_data_connection()
{
socklen_t addr_len; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

addr_len = 16;
return accept(client_recv_fd, &addr, &addr_len);
}

canonical_decompiled_code:
int func3()
{
socklen_t addr_len; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

addr_len = 16;
return accept(client_recv_fd, &addr, &addr_len);
}

original_code:
int get_data_connection()
{
 int server_data_channel_fd,server_len;
 server_data_channel_fd = -1;
 struct sockaddr_in server_addr;
 server_len = sizeof(server_addr);
 server_data_channel_fd = accept(client_recv_fd,(struct sockaddr*) &server_addr,&server_len);
 return server_data_channel_fd;
}

canonical_original_code:
int get_data_connection()
{
 int server_data_channel_fd; int server_len;
 server_data_channel_fd = -1;
 struct sockaddr_in server_addr;
 server_len = sizeof(server_addr);
 server_data_channel_fd = accept(client_recv_fd,(struct sockaddr *) &server_addr,&server_len);
 return server_data_channel_fd;
}


decompiled_code:
int __fastcall close_data_connection(int a1)
{
int result; // eax

if ( close(a1) )
result = puts("data channel connection close failed ");
else
result = puts("data channel connection close success ");
return result;
}

canonical_decompiled_code:
int __fastcall func4(int a1)
{
int result; // eax

if ( close(a1) )
result = puts("data channel connection close failed ");
else
result = puts("data channel connection close success ");
return result;
}

original_code:
void close_data_connection(int server_data_channel_fd)
{
 if(close(server_data_channel_fd) != 0)
  printf("data channel connection close failed \n");
 else
  printf("data channel connection close success \n");
}


decompiled_code:
__int64 __fastcall scan_command(__int64 a1, const char *a2, __int64 a3)
{
int v4; // eax
__int64 result; // rax
bool v6; // zf

printf("command>");
_isoc99_scanf("%s", a2);
v4 = *(unsigned __int8 *)a2;
if ( v4 == 108 && a2[1] == 115 && !a2[2] || v4 == 99 && a2[1] == 100 && !a2[2] || v4 == 114 && a2[1] == 109 && !a2[2] )
{
_isoc99_scanf("%s", a3);
result = 1LL;
}
else if ( !strcmp(a2, "rename") )
{
_isoc99_scanf("%s", a3);
_isoc99_scanf("%s", a3 + 20);
result = 1LL;
}
else if ( !strcmp(a2, "upload") || !strcmp(a2, "download") )
{
_isoc99_scanf("%s,%s", a3, a3 + 20);
result = 1LL;
}
else
{
v6 = strcmp(a2, "exit") == 0;
result = !v6;
if ( !v6 )
result = 2LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char *a2, __int64 a3)
{
int v4; // eax
__int64 result; // rax
bool v6; // zf

printf("command>");
_isoc99_scanf("%s", a2);
v4 = *(unsigned __int8 *)a2;
if ( v4 == 108 && a2[1] == 115 && !a2[2] || v4 == 99 && a2[1] == 100 && !a2[2] || v4 == 114 && a2[1] == 109 && !a2[2] )
{
_isoc99_scanf("%s", a3);
result = 1LL;
}
else if ( !strcmp(a2, "rename") )
{
_isoc99_scanf("%s", a3);
_isoc99_scanf("%s", a3 + 20);
result = 1LL;
}
else if ( !strcmp(a2, "upload") || !strcmp(a2, "download") )
{
_isoc99_scanf("%s,%s", a3, a3 + 20);
result = 1LL;
}
else
{
v6 = strcmp(a2, "exit") == 0;
result = !v6;
if ( !v6 )
result = 2LL;
}
return result;
}

original_code:
int scan_command(char* username,char command[],char arguments[][20])
{
 printf("command>");
 scanf("%s",command);
 if(strcmp(command,"ls") == 0)
 {
  scanf("%s",arguments[0]);
  return 1;
 }
 else if(strcmp(command,"cd") == 0)
 {
  scanf("%s",arguments[0]);
  return 1;
 }
 else if(strcmp(command,"rm") == 0)
 {
  scanf("%s",arguments[0]);
  return 1;
 }
 else if(strcmp(command,"rename") == 0)
 {
  scanf("%s",arguments[0]);
  scanf("%s",arguments[1]);
  return 1;
 }
 else if(strcmp(command,"upload") == 0)
 {
  scanf("%s,%s",arguments[0],arguments[1]);
  return 1;
 }
 else if(strcmp(command,"download") == 0)
 {
  scanf("%s,%s",arguments[0],arguments[1]);
  return 1;
 }
 else if(strcmp(command,"exit") == 0)
 {
  return 0;
 }
 else
 {
  return 2;
 }
}

canonical_original_code:
int scan_command(char *username, char command[], char arguments[][20])
{
 printf("command>");
 scanf("%s",command);
 if(strcmp(command,"ls") == 0)
 {
  scanf("%s",arguments[0]);
  return 1;
 }
 else if(strcmp(command,"cd") == 0)
 {
  scanf("%s",arguments[0]);
  return 1;
 }
 else if(strcmp(command,"rm") == 0)
 {
  scanf("%s",arguments[0]);
  return 1;
 }
 else if(strcmp(command,"rename") == 0)
 {
  scanf("%s",arguments[0]);
  scanf("%s",arguments[1]);
  return 1;
 }
 else if(strcmp(command,"upload") == 0)
 {
  scanf("%s,%s",arguments[0],arguments[1]);
  return 1;
 }
 else if(strcmp(command,"download") == 0)
 {
  scanf("%s,%s",arguments[0],arguments[1]);
  return 1;
 }
 else if(strcmp(command,"exit") == 0)
 {
  return 0;
 }
 else
 {
  return 2;
 }
}

variable_types:
username
char *

variable_types:
command
char []

variable_types:
arguments
char [][20]


QueryDirContent

decompiled_code:
int __fastcall QueryDirContent(int fd, const char *a2)
{
size_t v2; // rax
unsigned int v3; // ebp
int v4; // er14
int v5; // eax
_QWORD *v6; // rax
__int64 v7; // rbx
void *i; // r13
const char *v9; // rsi
int v11; // [rsp+0h] [rbp-68h] BYREF
__int16 v12; // [rsp+4h] [rbp-64h]
char v13[72]; // [rsp+20h] [rbp-48h] BYREF

memset(buffer, 0, (size_t)&unk_100000);
sprintf(buffer, "request;querydircontent;%s%s|", &current_directory, a2);
v2 = strlen(buffer);
if ( send(fd, buffer, v2, 0) == -1 )
puts("send error");
memset(buffer, 0, (size_t)&unk_100000);
recv(fd, buffer, (size_t)&unk_100000, 0);
response_analysis(buffer, &v11, v13);
if ( v11 == 1869771365 && v12 == 114 )
return printf("%s:%s\n", (const char *)&v11, v13);
v3 = 0;
v4 = get_data_connection();
puts("type\tname\t\t\t\tsize");
while ( 1 )
{
v5 = recv(v4, buffer, (size_t)&unk_100000, 0);
if ( v5 <= 0 )
break;
buffer[v5] = 0;
v6 = get_files_information(buffer);
v7 = v6[14];
for ( i = v6; v7; v7 = *(_QWORD *)(v7 + 112) )
{
++v3;
v9 = "file";
if ( *(_DWORD *)v7 )
v9 = "dir";
printf("%s\t%-20s\t\t%-6d\n", v9, v7 + 4, *(unsigned int *)(v7 + 104));
}
free_file_list(i);
}
printf("total %d items\n", v3);
close_data_connection(v4);
return puts("end of query dir ");
}

canonical_decompiled_code:
int __fastcall func8(int fd, const char *a2)
{
size_t v2; // rax
unsigned int v3; // ebp
int v4; // er14
int v5; // eax
_QWORD *v6; // rax
__int64 v7; // rbx
void *i; // r13
const char *v9; // rsi
int v11; // [rsp+0h] [rbp-68h] BYREF
__int16 v12; // [rsp+4h] [rbp-64h]
char v13[72]; // [rsp+20h] [rbp-48h] BYREF

memset(buffer, 0, (size_t)&unk_100000);
sprintf(buffer, "request;querydircontent;%s%s|", &current_directory, a2);
v2 = strlen(buffer);
if ( send(fd, buffer, v2, 0) == -1 )
puts("send error");
memset(buffer, 0, (size_t)&unk_100000);
recv(fd, buffer, (size_t)&unk_100000, 0);
func6(buffer, &v11, v13);
if ( v11 == 1869771365 && v12 == 114 )
return printf("%s:%s\n", (const char *)&v11, v13);
v3 = 0;
v4 = func3();
puts("type\tname\t\t\t\tsize");
while ( 1 )
{
v5 = recv(v4, buffer, (size_t)&unk_100000, 0);
if ( v5 <= 0 )
break;
buffer[v5] = 0;
v6 = get_files_information(buffer);
v7 = v6[14];
for ( i = v6; v7; v7 = *(_QWORD *)(v7 + 112) )
{
++v3;
v9 = "file";
if ( *(_DWORD *)v7 )
v9 = "dir";
printf("%s\t%-20s\t\t%-6d\n", v9, v7 + 4, *(unsigned int *)(v7 + 104));
}
func7(i);
}
printf("total %d items\n", v3);
func4(v4);
return puts("end of query dir ");
}

original_code:
void QueryDirContent(int server_fd,char directory[])
{
 char response_type[20];
 char response_argu[20];
 int server_data_channel_fd;
 int nbytes;
 int item_count = 0;
 struct file_list * files_head = ((void *)0);
 struct file_list * pfile = ((void *)0);
 memset(buffer,'\0',1048576);
 sprintf(buffer,"request;querydircontent;%s%s|",current_directory,directory);
 if(send(server_fd,buffer,strlen(buffer),0)==-1)
 {
  printf("send error\n");
 }
 memset(buffer,'\0',1048576);
 recv(server_fd,buffer,1048576,0);
 response_analysis(buffer,response_type,response_argu);
 if(strcmp(response_type,"error") == 0)
 {
      printf("%s:%s\n",response_type,response_argu);
   return;
 }
 server_data_channel_fd = get_data_connection();
 memset(buffer,1048576,'\0');
 printf("type\tname\t\t\t\tsize\n");
  while((nbytes = recv(server_data_channel_fd,buffer,1048576,0)) > 0)
 {
  buffer[nbytes]='\0';
  files_head = get_files_information(buffer);
  pfile = files_head;
  while(pfile->next_file != ((void *)0)){
   item_count++;
   pfile = pfile->next_file;
   printf("%s\t%-20s\t\t%-6d\n",pfile->file_type?"dir":"file",pfile->file_name,pfile->file_size);
  }
  memset(buffer,1048576,'\0');
  free_file_list(files_head);
  }
 printf("total %d items\n",item_count);
 close_data_connection(server_data_channel_fd);
printf("end of query dir \n");
}

canonical_original_code:
void QueryDirContent(int server_fd, char directory[])
{
 char response_type[20];
 char response_argu[20];
 int server_data_channel_fd;
 int nbytes;
 int item_count = 0;
 struct file_list *files_head = ((void *)0);
 struct file_list *pfile = ((void *)0);
 memset(buffer,'\0',1048576);
 sprintf(buffer,"request;querydircontent;%s%s|",current_directory,directory);
 if(send(server_fd,buffer,strlen(buffer),0)==-1)
 {
  printf("send error\n");
 }
 memset(buffer,'\0',1048576);
 recv(server_fd,buffer,1048576,0);
 response_analysis(buffer,response_type,response_argu);
 if(strcmp(response_type,"error") == 0)
 {
      printf("%s:%s\n",response_type,response_argu);
   return;
 }
 server_data_channel_fd = get_data_connection();
 memset(buffer,1048576,'\0');
 printf("type\tname\t\t\t\tsize\n");
  while((nbytes = recv(server_data_channel_fd,buffer,1048576,0)) > 0)
 {
  buffer[nbytes]='\0';
  files_head = get_files_information(buffer);
  pfile = files_head;
  while(pfile->next_file != ((void *)0)){
   item_count++;
   pfile = pfile->next_file;
   printf("%s\t%-20s\t\t%-6d\n",pfile->file_type?"dir":"file",pfile->file_name,pfile->file_size);
  }
  memset(buffer,1048576,'\0');
  free_file_list(files_head);
  }
 printf("total %d items\n",item_count);
 close_data_connection(server_data_channel_fd);
printf("end of query dir \n");
}

variable_types:
directory
char []

variable_types: nbytes int

variable_types: struct file_list { int file_type; char file_name[100]; int file_size; struct file_list *next_file; } *


ChangeDirectory

decompiled_code:
__int64 __fastcall ChangeDirectory(int fd, char *src)
{
size_t v2; // rax
size_t v3; // rax
__int64 result; // rax
int v5; // [rsp+0h] [rbp-58h] BYREF
__int16 v6; // [rsp+4h] [rbp-54h]
char v7[56]; // [rsp+20h] [rbp-38h] BYREF

sprintf(buffer, "request;changedirectory;%s;%s|", current_directory, src);
v2 = strlen(buffer);
if ( send(fd, buffer, v2, 0) == -1 )
{
puts("send error");
result = 0xFFFFFFFFLL;
}
else
{
recv(fd, buffer, (size_t)&unk_100000, 0);
response_analysis(buffer, &v5, v7);
if ( v5 == 1869771365 && v6 == 114 )
{
puts("the directory don't exist");
result = 0xFFFFFFFFLL;
}
else
{
v3 = strlen(current_directory);
*stpcpy(&current_directory[v3], src) = 47;
current_directory[strlen(current_directory) + 1] = 0;
puts("directory changed");
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int fd, char *src)
{
size_t v2; // rax
size_t v3; // rax
__int64 result; // rax
int v5; // [rsp+0h] [rbp-58h] BYREF
__int16 v6; // [rsp+4h] [rbp-54h]
char v7[56]; // [rsp+20h] [rbp-38h] BYREF

sprintf(buffer, "request;changedirectory;%s;%s|", current_directory, src);
v2 = strlen(buffer);
if ( send(fd, buffer, v2, 0) == -1 )
{
puts("send error");
result = 0xFFFFFFFFLL;
}
else
{
recv(fd, buffer, (size_t)&unk_100000, 0);
func6(buffer, &v5, v7);
if ( v5 == 1869771365 && v6 == 114 )
{
puts("the directory don't exist");
result = 0xFFFFFFFFLL;
}
else
{
v3 = strlen(current_directory);
*stpcpy(&current_directory[v3], src) = 47;
current_directory[strlen(current_directory) + 1] = 0;
puts("directory changed");
result = 1LL;
}
}
return result;
}

original_code:
int ChangeDirectory(int server_fd,char new_dir[])
{
 char response_type[20];
 char response_argu[20];
 memset(buffer,1048576,'\0');
 sprintf(buffer,"request;changedirectory;%s;%s|",current_directory,new_dir);
 if(send(server_fd,buffer,strlen(buffer),0)==-1)
 {
  printf("send error\n");
  return -1;
 }
 memset(buffer,1048576,'\0');
 recv(server_fd,buffer,1048576,0);
 response_analysis(buffer,response_type,response_argu);
 if(strcmp(response_type,"error") == 0)
 {
  printf("the directory don't exist\n");
  return -1;
 }
 strcat(current_directory,new_dir);
 current_directory[strlen(current_directory)] = '/';
 current_directory[strlen(current_directory)+1] = '\0';
 printf("directory changed\n");
 return 1;
}

canonical_original_code:
int ChangeDirectory(int server_fd, char new_dir[])
{
 char response_type[20];
 char response_argu[20];
 memset(buffer,1048576,'\0');
 sprintf(buffer,"request;changedirectory;%s;%s|",current_directory,new_dir);
 if(send(server_fd,buffer,strlen(buffer),0)==-1)
 {
  printf("send error\n");
  return -1;
 }
 memset(buffer,1048576,'\0');
 recv(server_fd,buffer,1048576,0);
 response_analysis(buffer,response_type,response_argu);
 if(strcmp(response_type,"error") == 0)
 {
  printf("the directory don't exist\n");
  return -1;
 }
 strcat(current_directory,new_dir);
 current_directory[strlen(current_directory)] = '/';
 current_directory[strlen(current_directory)+1] = '\0';
 printf("directory changed\n");
 return 1;
}


decompiled_code:
void __fastcall free_file_list(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 14);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func7(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 14);
free(v2);
}
while ( v1 );
}
}

original_code:
void free_file_list(struct file_list * file_list_head)
{
 struct file_list * tem = ((void *)0);
 while(file_list_head != ((void *)0)){
  tem = file_list_head;
  file_list_head = file_list_head->next_file;
  free(tem);
 }
}

canonical_original_code:
void free_file_list(struct file_list *file_list_head)
{
 struct file_list *tem = ((void *)0);
 while(file_list_head != ((void *)0)){
  tem = file_list_head;
  file_list_head = file_list_head->next_file;
  free(tem);
 }
}

user_defined_types: struct file_list { int file_type; char file_name[100]; int file_size; struct file_list *next_file; }


decompiled_code:
__int64 __fastcall test_fuse_init(int fd, __int64 a2, __int64 *a3)
{
__int64 v4; // rax
__int64 v5; // rax
int v6; // eax
__int64 result; // rax
int *v8; // rax
__int64 v9[2]; // [rsp+0h] [rbp-68h] BYREF
__int64 v10[4]; // [rsp+10h] [rbp-58h] BYREF
struct iovec iovec; // [rsp+30h] [rbp-38h] BYREF
__int64 *v12; // [rsp+40h] [rbp-28h]
__int64 v13; // [rsp+48h] [rbp-20h]

printf("%s called\n", "test_fuse_init");
v4 = *a3;
iovec.iov_base = v9;
v10[0] = v4;
v10[1] = 0x300020000LL;
v10[2] = 0x2000000300040LL;
v12 = v10;
v5 = *(_QWORD *)(a2 + 8);
iovec.iov_len = 16LL;
v13 = 24LL;
v9[1] = v5;
v9[0] = 40LL;
v6 = writev(fd, &iovec, 2);
if ( v6 <= 0 )
{
v8 = __errno_location();
printf("write error.errno %d\n", (unsigned int)*v8);
result = 0xFFFFFFFFLL;
}
else
{
printf("write %d bytes\n", (unsigned int)v6);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int fd, __int64 a2, __int64 *a3)
{
__int64 v4; // rax
__int64 v5; // rax
int v6; // eax
__int64 result; // rax
int *v8; // rax
__int64 v9[2]; // [rsp+0h] [rbp-68h] BYREF
__int64 v10[4]; // [rsp+10h] [rbp-58h] BYREF
struct iovec iovec; // [rsp+30h] [rbp-38h] BYREF
__int64 *v12; // [rsp+40h] [rbp-28h]
__int64 v13; // [rsp+48h] [rbp-20h]

printf("%s called\n", "test_fuse_init");
v4 = *a3;
iovec.iov_base = v9;
v10[0] = v4;
v10[1] = 0x300020000LL;
v10[2] = 0x2000000300040LL;
v12 = v10;
v5 = *(_QWORD *)(a2 + 8);
iovec.iov_len = 16LL;
v13 = 24LL;
v9[1] = v5;
v9[0] = 40LL;
v6 = writev(fd, &iovec, 2);
if ( v6 <= 0 )
{
v8 = __errno_location();
printf("write error.errno %d\n", (unsigned int)*v8);
result = 0xFFFFFFFFLL;
}
else
{
printf("write %d bytes\n", (unsigned int)v6);
result = 0LL;
}
return result;
}

original_code:
int test_fuse_init (int fd, struct fuse_in_header *finh, void *msg)
{
 int ret;
 struct fuse_init_in *fini = msg;
 struct fuse_init_out fino;
 struct fuse_out_header fouh;
 struct iovec iov[2];
printf("%s called\n", __func__);
 fino.major = fini->major;
 fino.minor = fini->minor;
 fino.max_readahead = 1 << 17;
 fino.max_write = 1 << 17;
 fino.flags = (1 << 0) | (1 << 1);
 fino.max_background = 64;
 fino.congestion_threshold = 48;
 iov[0].iov_base = &fouh;
 iov[0].iov_len = sizeof(fouh);
 iov[1].iov_base = &fino;
 iov[1].iov_len = sizeof(fino);
 fouh.len = iov[0].iov_len + iov[1].iov_len;
 fouh.unique = finh->unique;
 fouh.error = 0;
 ret = writev(fd, iov, 2);
 if (ret <= 0) {
  printf("write error.errno %d\n", (*__errno_location ()));
  return -1;
 }
 printf("write %d bytes\n", ret);
 return 0;
}

canonical_original_code:
int test_fuse_init(int fd, struct fuse_in_header *finh, void *msg)
{
 int ret;
 struct fuse_init_in *fini = msg;
 struct fuse_init_out fino;
 struct fuse_out_header fouh;
 struct iovec iov[2];
printf("%s called\n", __func__);
 fino.major = fini->major;
 fino.minor = fini->minor;
 fino.max_readahead = 1 << 17;
 fino.max_write = 1 << 17;
 fino.flags = (1 << 0) | (1 << 1);
 fino.max_background = 64;
 fino.congestion_threshold = 48;
 iov[0].iov_base = &fouh;
 iov[0].iov_len = sizeof(fouh);
 iov[1].iov_base = &fino;
 iov[1].iov_len = sizeof(fino);
 fouh.len = iov[0].iov_len + iov[1].iov_len;
 fouh.unique = finh->unique;
 fouh.error = 0;
 ret = writev(fd, iov, 2);
 if (ret <= 0) {
  printf("write error.errno %d\n", (*__errno_location ()));
  return -1;
 }
 printf("write %d bytes\n", ret);
 return 0;
}

variable_types: fd int

variable_types: struct fuse_in_header { unsigned int len; unsigned int opcode; unsigned long unique; unsigned long nodeid; unsigned int uid; unsigned int gid; unsigned int pid; unsigned int padding; } *

variable_types:
msg
void *

variable_types: ret int

variable_types: struct fuse_init_in { unsigned int major; unsigned int minor; unsigned int max_readahead; unsigned int flags; } *

variable_types: struct fuse_init_out { unsigned int major; unsigned int minor; unsigned int max_readahead; unsigned int flags; unsigned short max_background; unsigned short congestion_threshold; unsigned int max_write; }

variable_types: struct fuse_out_header { unsigned int len; int error; unsigned long unique; }

variable_types: struct iovec { void *iov_base; unsigned long iov_len; } [2]


decompiled_code:
__int64 test_fuse_mount()
{
unsigned int v0; // er12
__gid_t v1; // ebx
__uid_t v2; // eax
int *v4; // rbx
char *v5; // rax
int *v6; // rbx
char *v7; // rax
int v8; // edi
__m128i v9; // [rsp+0h] [rbp-518h] BYREF
__int64 v10; // [rsp+10h] [rbp-508h]
int v11; // [rsp+18h] [rbp-500h]
__int16 v12; // [rsp+1Ch] [rbp-4FCh]
char special_file[16]; // [rsp+20h] [rbp-4F8h] BYREF
__int128 v14; // [rsp+30h] [rbp-4E8h]
__int128 v15; // [rsp+40h] [rbp-4D8h]
__int128 v16; // [rsp+50h] [rbp-4C8h]
__int128 v17; // [rsp+60h] [rbp-4B8h]
__int128 v18; // [rsp+70h] [rbp-4A8h]
int v19; // [rsp+80h] [rbp-498h]
char dir[16]; // [rsp+90h] [rbp-488h] BYREF
__int128 v21; // [rsp+A0h] [rbp-478h]
__int128 v22; // [rsp+B0h] [rbp-468h]
__int128 v23; // [rsp+C0h] [rbp-458h]
__int128 v24; // [rsp+D0h] [rbp-448h]
__int128 v25; // [rsp+E0h] [rbp-438h]
int v26; // [rsp+F0h] [rbp-428h]
char s[1048]; // [rsp+100h] [rbp-418h] BYREF

v12 = 0;
*(__m128i *)special_file = _mm_load_si128((const __m128i *)&xmmword_4021E0);
v14 = 0LL;
v15 = 0LL;
v16 = 0LL;
v17 = 0LL;
v18 = 0LL;
v21 = 0LL;
v22 = 0LL;
v23 = 0LL;
v24 = 0LL;
v25 = 0LL;
v19 = 0;
v26 = 0;
v10 = 0LL;
v11 = 0;
*(__m128i *)dir = _mm_load_si128((const __m128i *)&xmmword_4021F0);
v9 = _mm_load_si128((const __m128i *)&xmmword_402200);
v0 = open("/dev/fuse", 2);
if ( v0 == -1 )
{
v4 = __errno_location();
v5 = strerror(*v4);
printf("cannot open /dev/fuse errno:%d, errstr:%s\n", (unsigned int)*v4, v5);
}
else
{
v1 = getgid();
v2 = getuid();
sprintf(
s,
"allow_other,default_permissions,max_read=131072,fd=%i,rootmode=%o,user_id=%i,group_id=%i",
v0,
0x4000LL,
v2,
v1);
if ( mount(special_file, dir, v9.m128i_i8, 0LL, s) )
{
v6 = __errno_location();
v7 = strerror(*v6);
printf("cannot mount errno:%d, errstr:%s\n", (unsigned int)*v6, v7);
v8 = v0;
v0 = -1;
close(v8);
}
}
return v0;
}

canonical_decompiled_code:
__int64 func8()
{
unsigned int v0; // er12
__gid_t v1; // ebx
__uid_t v2; // eax
int *v4; // rbx
char *v5; // rax
int *v6; // rbx
char *v7; // rax
int v8; // edi
__m128i v9; // [rsp+0h] [rbp-518h] BYREF
__int64 v10; // [rsp+10h] [rbp-508h]
int v11; // [rsp+18h] [rbp-500h]
__int16 v12; // [rsp+1Ch] [rbp-4FCh]
char special_file[16]; // [rsp+20h] [rbp-4F8h] BYREF
__int128 v14; // [rsp+30h] [rbp-4E8h]
__int128 v15; // [rsp+40h] [rbp-4D8h]
__int128 v16; // [rsp+50h] [rbp-4C8h]
__int128 v17; // [rsp+60h] [rbp-4B8h]
__int128 v18; // [rsp+70h] [rbp-4A8h]
int v19; // [rsp+80h] [rbp-498h]
char dir[16]; // [rsp+90h] [rbp-488h] BYREF
__int128 v21; // [rsp+A0h] [rbp-478h]
__int128 v22; // [rsp+B0h] [rbp-468h]
__int128 v23; // [rsp+C0h] [rbp-458h]
__int128 v24; // [rsp+D0h] [rbp-448h]
__int128 v25; // [rsp+E0h] [rbp-438h]
int v26; // [rsp+F0h] [rbp-428h]
char s[1048]; // [rsp+100h] [rbp-418h] BYREF

v12 = 0;
*(__m128i *)special_file = _mm_load_si128((const __m128i *)&xmmword_4021E0);
v14 = 0LL;
v15 = 0LL;
v16 = 0LL;
v17 = 0LL;
v18 = 0LL;
v21 = 0LL;
v22 = 0LL;
v23 = 0LL;
v24 = 0LL;
v25 = 0LL;
v19 = 0;
v26 = 0;
v10 = 0LL;
v11 = 0;
*(__m128i *)dir = _mm_load_si128((const __m128i *)&xmmword_4021F0);
v9 = _mm_load_si128((const __m128i *)&xmmword_402200);
v0 = open("/dev/fuse", 2);
if ( v0 == -1 )
{
v4 = __errno_location();
v5 = strerror(*v4);
printf("cannot open /dev/fuse errno:%d, errstr:%s\n", (unsigned int)*v4, v5);
}
else
{
v1 = getgid();
v2 = getuid();
sprintf(
s,
"allow_other,default_permissions,max_read=131072,fd=%i,rootmode=%o,user_id=%i,group_id=%i",
v0,
0x4000LL,
v2,
v1);
if ( mount(special_file, dir, v9.m128i_i8, 0LL, s) )
{
v6 = __errno_location();
v7 = strerror(*v6);
printf("cannot mount errno:%d, errstr:%s\n", (unsigned int)*v6, v7);
v8 = v0;
v0 = -1;
close(v8);
}
}
return v0;
}

original_code:
int test_fuse_mount ()
{
 int fd, ret;
 char source[100] = "/tmp/image_mount";
 char mountpoint[100] = "/mnt/test2";
 char fstype[30] = "fuse.glusterfs";
 char mnt_param_mnt[1024];
 fd = open ("/dev/fuse", 02);
 if (fd == -1) {
  printf ("cannot open /dev/fuse errno:%d, errstr:%s\n", (*__errno_location ()), strerror ((*__errno_location ())));
  return -1;
 }
 sprintf (mnt_param_mnt,
   "allow_other,default_permissions,max_read=131072,fd=%i,rootmode=%o,user_id=%i,group_id=%i",
   fd, 0040000, getuid (), getgid ());
 ret = mount (source, mountpoint, fstype, 0, mnt_param_mnt);
 if (ret) {
  printf ("cannot mount errno:%d, errstr:%s\n", (*__errno_location ()), strerror ((*__errno_location ())));
  close (fd);
  return -1;
 }
 return fd;
}

canonical_original_code:
int test_fuse_mount()
{
 int fd; int ret;
 char source[100] = "/tmp/image_mount";
 char mountpoint[100] = "/mnt/test2";
 char fstype[30] = "fuse.glusterfs";
 char mnt_param_mnt[1024];
 fd = open ("/dev/fuse", 02);
 if (fd == -1) {
  printf ("cannot open /dev/fuse errno:%d, errstr:%s\n", (*__errno_location ()), strerror ((*__errno_location ())));
  return -1;
 }
 sprintf (mnt_param_mnt,
   "allow_other,default_permissions,max_read=131072,fd=%i,rootmode=%o,user_id=%i,group_id=%i",
   fd, 0040000, getuid (), getgid ());
 ret = mount (source, mountpoint, fstype, 0, mnt_param_mnt);
 if (ret) {
  printf ("cannot mount errno:%d, errstr:%s\n", (*__errno_location ()), strerror ((*__errno_location ())));
  close (fd);
  return -1;
 }
 return fd;
}

variable_types:
source
char [100]

variable_types:
mountpoint
char [100]

variable_types:
fstype
char [30]


decompiled_code:
__int64 __fastcall test_fuse_cntl(int fd)
{
int v1; // ebx
_DWORD *v2; // rbp
unsigned int *v3; // r12
int v4; // eax
struct iovec v6; // [rsp+0h] [rbp-48h] BYREF
unsigned int *v7; // [rsp+10h] [rbp-38h]
__int64 v8; // [rsp+18h] [rbp-30h]

v1 = 100;
v6.iov_len = 40LL;
v8 = 1024LL;
v6.iov_base = calloc(1uLL, 0x28uLL);
v7 = (unsigned int *)calloc(1uLL, 0x400uLL);
do
{
while ( 1 )
{
v4 = readv(fd, &v6, 2);
if ( v4 > 0 )
break;
puts("read nothing");
if ( !--v1 )
return 0LL;
}
printf("readv recieve %d bytes\n", (unsigned int)v4);
v2 = v6.iov_base;
v3 = v7;
printf(
"len:%d,opcode:%d,unique:%d,nodeid:%d,uid:%d,gid:%d,pid:%d,padding:%d\n",
*(unsigned int *)v6.iov_base,
*((unsigned int *)v6.iov_base + 1),
*((_QWORD *)v6.iov_base + 1),
*((_QWORD *)v6.iov_base + 2),
*((unsigned int *)v6.iov_base + 6),
*((unsigned int *)v6.iov_base + 7),
*((unsigned int *)v6.iov_base + 8),
*((unsigned int *)v6.iov_base + 9));
printf("major:%d,minor:%d,max_readahead:%d,flags:%d\n", *v3, v3[1], v3[2], v3[3]);
if ( v2[1] == 26 )
test_fuse_init(fd, (__int64)v2, (__int64 *)v3);
else
puts("can not recogonise thie op");
--v1;
}
while ( v1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(int fd)
{
int v1; // ebx
_DWORD *v2; // rbp
unsigned int *v3; // r12
int v4; // eax
struct iovec v6; // [rsp+0h] [rbp-48h] BYREF
unsigned int *v7; // [rsp+10h] [rbp-38h]
__int64 v8; // [rsp+18h] [rbp-30h]

v1 = 100;
v6.iov_len = 40LL;
v8 = 1024LL;
v6.iov_base = calloc(1uLL, 0x28uLL);
v7 = (unsigned int *)calloc(1uLL, 0x400uLL);
do
{
while ( 1 )
{
v4 = readv(fd, &v6, 2);
if ( v4 > 0 )
break;
puts("read nothing");
if ( !--v1 )
return 0LL;
}
printf("readv recieve %d bytes\n", (unsigned int)v4);
v2 = v6.iov_base;
v3 = v7;
printf(
"len:%d,opcode:%d,unique:%d,nodeid:%d,uid:%d,gid:%d,pid:%d,padding:%d\n",
*(unsigned int *)v6.iov_base,
*((unsigned int *)v6.iov_base + 1),
*((_QWORD *)v6.iov_base + 1),
*((_QWORD *)v6.iov_base + 2),
*((unsigned int *)v6.iov_base + 6),
*((unsigned int *)v6.iov_base + 7),
*((unsigned int *)v6.iov_base + 8),
*((unsigned int *)v6.iov_base + 9));
printf("major:%d,minor:%d,max_readahead:%d,flags:%d\n", *v3, v3[1], v3[2], v3[3]);
if ( v2[1] == 26 )
func7(fd, (__int64)v2, (__int64 *)v3);
else
puts("can not recogonise thie op");
--v1;
}
while ( v1 );
return 0LL;
}

original_code:
int test_fuse_cntl (int fd)
{
 int i, ret;
 struct iovec iov[2];
 struct fuse_in_header *finh;
 struct fuse_init_in *fini;
 iov[0].iov_len = sizeof(*finh);
 iov[0].iov_base = calloc(1, sizeof(*finh));
 iov[1].iov_len = 1024;
 iov[1].iov_base = calloc(1, 1024);
 i = 100;
 while (i) {
  ret = readv (fd, iov, 2);
  if (ret > 0) {
   printf("readv recieve %d bytes\n", ret);
   finh = (struct fuse_in_header *) iov[0].iov_base;
   fini = (struct fuse_init_in *) iov[1].iov_base;
   printf("len:%d,opcode:%d,unique:%d,nodeid:%d,uid:%d,gid:%d,pid:%d,padding:%d\n",
    finh->len,
    finh->opcode,
    finh->unique,
    finh->nodeid,
    finh->uid,
    finh->gid,
    finh->pid,
    finh->padding);
   printf("major:%d,minor:%d,max_readahead:%d,flags:%d\n",
    fini->major,
    fini->minor,
    fini->max_readahead,
    fini->flags);
   if (finh->opcode == 26)
    fuse_ops[0] (fd, finh, fini);
   else
    printf("can not recogonise thie op\n");
  }
  else
   printf("read nothing\n");
  i--;
 }
 return 0;
}

canonical_original_code:
int test_fuse_cntl(int fd)
{
 int i; int ret;
 struct iovec iov[2];
 struct fuse_in_header *finh;
 struct fuse_init_in *fini;
 iov[0].iov_len = sizeof(*finh);
 iov[0].iov_base = calloc(1, sizeof(*finh));
 iov[1].iov_len = 1024;
 iov[1].iov_base = calloc(1, 1024);
 i = 100;
 while (i) {
  ret = readv (fd, iov, 2);
  if (ret > 0) {
   printf("readv recieve %d bytes\n", ret);
   finh = (struct fuse_in_header *) iov[0].iov_base;
   fini = (struct fuse_init_in *) iov[1].iov_base;
   printf("len:%d,opcode:%d,unique:%d,nodeid:%d,uid:%d,gid:%d,pid:%d,padding:%d\n",
    finh->len,
    finh->opcode,
    finh->unique,
    finh->nodeid,
    finh->uid,
    finh->gid,
    finh->pid,
    finh->padding);
   printf("major:%d,minor:%d,max_readahead:%d,flags:%d\n",
    fini->major,
    fini->minor,
    fini->max_readahead,
    fini->flags);
   if (finh->opcode == 26)
    fuse_ops[0] (fd, finh, fini);
   else
    printf("can not recogonise thie op\n");
  }
  else
   printf("read nothing\n");
  i--;
 }
 return 0;
}

variable_types: i int

user_defined_types: struct iovec { void *iov_base; unsigned long iov_len; }

user_defined_types: struct fuse_in_header { unsigned int len; unsigned int opcode; unsigned long unique; unsigned long nodeid; unsigned int uid; unsigned int gid; unsigned int pid; unsigned int padding; }

user_defined_types: struct fuse_init_in { unsigned int major; unsigned int minor; unsigned int max_readahead; unsigned int flags; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
int result; // eax
int *v6; // rax

v3 = test_fuse_mount(argc, argv, envp);
if ( v3 < 0 )
{
v6 = __errno_location();
printf("error ocoured. %d\n", (unsigned int)*v6);
result = -1;
}
else
{
v4 = v3;
test_fuse_cntl(v3);
close(v4);
result = 0;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
int result; // eax
int *v6; // rax

v3 = func8(argc, argv, envp);
if ( v3 < 0 )
{
v6 = __errno_location();
printf("error ocoured. %d\n", (unsigned int)*v6);
result = -1;
}
else
{
v4 = v3;
func9(v3);
close(v4);
result = 0;
}
return result;
}

original_code:
int main (int argc, char *argv[])
{
 int fd;
 fd = test_fuse_mount ();
 if (fd < 0) {
  printf ("error ocoured. %d\n", (*__errno_location ()));
  return -1;
 }
 test_fuse_cntl (fd);
 close (fd);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int fd;
 fd = test_fuse_mount ();
 if (fd < 0) {
  printf ("error ocoured. %d\n", (*__errno_location ()));
  return -1;
 }
 test_fuse_cntl (fd);
 close (fd);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


original_code:
void *
mempool_alloc(struct mempool *pool)
{
 int i;
 while(1) {
  if ((((struct mem_status *)((pool->mempod[pool->cursor])-sizeof(struct mem_status)))->status) == MEM_IDLE) {
   i = pool->cursor;
   pool->cursor++;
   pool->cursor %= pool->count;
   break;
  }
  pool->cursor++;
  pool->cursor %= pool->count;
 }
 (((struct mem_status *)((pool->mempod[i])-sizeof(struct mem_status)))->status = MEM_USED);
 return pool->mempod[i];
}

canonical_original_code:
void *mempool_alloc(struct mempool *pool)
{
 int i;
 while(1) {
  if ((((struct mem_status *)((pool->mempod[pool->cursor])-sizeof(struct mem_status)))->status) == MEM_IDLE) {
   i = pool->cursor;
   pool->cursor++;
   pool->cursor %= pool->count;
   break;
  }
  pool->cursor++;
  pool->cursor %= pool->count;
 }
 (((struct mem_status *)((pool->mempod[i])-sizeof(struct mem_status)))->status = MEM_USED);
 return pool->mempod[i];
}

variable_types: struct mempool { char *name; int size; int count; int cursor; void **mempod; } *


decompiled_code:
void __fastcall mempool_free(__int64 a1)
{
*(_DWORD *)(a1 - 4) = 1;
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
*(_DWORD *)(a1 - 4) = 1;
}

original_code:
void
mempool_free(void *ptr)
{
 (((struct mem_status *)((ptr)-sizeof(struct mem_status)))->status = MEM_IDLE);
}

variable_types:
ptr
void *


decompiled_code:
int __fastcall show_parent(__int64 a1)
{
int result; // eax
__int64 v2; // rbx
__int64 v3; // rsi
__int64 v4; // rdx

result = *(_DWORD *)(a1 + 8);
if ( result > 0 )
{
v2 = 0LL;
do
{
v3 = (unsigned int)v2;
v4 = *(unsigned int *)(*(_QWORD *)a1 + 4 * v2++);
result = printf("son[%d] score=%d\n", v3, v4);
}
while ( *(_DWORD *)(a1 + 8) > (int)v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1)
{
int result; // eax
__int64 v2; // rbx
__int64 v3; // rsi
__int64 v4; // rdx

result = *(_DWORD *)(a1 + 8);
if ( result > 0 )
{
v2 = 0LL;
do
{
v3 = (unsigned int)v2;
v4 = *(unsigned int *)(*(_QWORD *)a1 + 4 * v2++);
result = printf("son[%d] score=%d\n", v3, v4);
}
while ( *(_DWORD *)(a1 + 8) > (int)v2 );
}
return result;
}

original_code:
void show_parent(struct parent *p)
{
 int i;
 for (i=0; i<p->count; i++) {
  printf("son[%d] score=%d\n", i, p->son[i].score);
 }
}

variable_types: struct parent { struct son { int score; } *son; int count; } *

user_defined_types: struct parent { struct son *son; int count; }


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int128 v4; // [rsp+0h] [rbp-18h] BYREF

v4 = 0LL;
DWORD2(v4) = 10;
init_parent(&v4, argv, envp);
show_parent(&v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int128 v4; // [rsp+0h] [rbp-18h] BYREF

v4 = 0LL;
DWORD2(v4) = 10;
init_parent(&v4, argv, envp);
func7(&v4);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 struct parent p = {.count=10};
 init_parent(&p);
 show_parent(&p);
 return 0;
}

variable_types: struct parent { struct son { int score; } *son; int count; }


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

result = *(_QWORD *)(a1 + 24) + *(unsigned __int16 *)(a1 + 40);
*(_QWORD *)(a1 + 48) = result;
return result;
}

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

result = *(_QWORD *)(a1 + 24) + *(unsigned __int16 *)(a1 + 40);
*(_QWORD *)(a1 + 48) = result;
return result;
}

original_code:
static inline void
uskb_set_network_header(struct usk_buff *uskb)
{
 uskb->network_header = uskb->header + uskb->header_len;
}

variable_types: struct usk_buff { struct usk_buff *prev; struct usk_buff *next; unsigned char direct; void *header; void *payload; unsigned short header_len; void *network_header; void *transport_header; struct btqueue_node { struct btqueue_node *next; } q_send; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct uprotocol { void (*close)(struct usock { int usk_mode; struct usk_buff_head { struct usk_buff *prev; struct usk_buff *next; unsigned short qlen; 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; } loc; } *usk_write_queue; struct usk_buff_head *usk_receive_queue; } *sk, long timeout); int (*connect)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); int (*disconnect)(struct usock *sk, int flags); struct usock *(*accept)(struct usock *sk, int flags, int *err); int (*ioctl)(struct usock *sk, int cmd, unsigned long arg); int (*init)(struct usock *sk); void (*destroy)(struct usock *sk); void (*shutdown)(struct usock *sk, int how); int (*setsockopt)(struct usock *sk, int level, int optname, char *optval, int optlen); int (*getsockopt)(struct usock *sk, int level, int optname, char *optval, int *option); int (*bind)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); char name[32]; int proto_num; struct list_head { struct list_head *next; } node; int (*header_len)(struct usk_buff *uskb); int (*handler)(struct usk_buff *uskb); } *proto; } *

user_defined_types: struct usk_buff { struct usk_buff *prev; struct usk_buff *next; unsigned char direct; void *header; void *payload; unsigned short header_len; void *network_header; void *transport_header; struct btqueue_node q_send; struct sockaddr_in sin; struct uprotocol *proto; }

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


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

result = *(_QWORD *)(a1 + 48) + *(unsigned __int16 *)(a1 + 40);
*(_QWORD *)(a1 + 56) = result;
return result;
}

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

result = *(_QWORD *)(a1 + 48) + *(unsigned __int16 *)(a1 + 40);
*(_QWORD *)(a1 + 56) = result;
return result;
}

original_code:
static inline void
uskb_set_transport_header(struct usk_buff *uskb)
{
 uskb->transport_header = uskb->network_header + uskb->header_len;
}

user_defined_types: struct uprotocol { void (*close)(struct usock *sk, long timeout); int (*connect)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); int (*disconnect)(struct usock *sk, int flags); struct usock *(*accept)(struct usock *sk, int flags, int *err); int (*ioctl)(struct usock *sk, int cmd, unsigned long arg); int (*init)(struct usock *sk); void (*destroy)(struct usock *sk); void (*shutdown)(struct usock *sk, int how); int (*setsockopt)(struct usock *sk, int level, int optname, char *optval, int optlen); int (*getsockopt)(struct usock *sk, int level, int optname, char *optval, int *option); int (*bind)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); char name[32]; int proto_num; struct list_head node; int (*header_len)(struct usk_buff *uskb); int (*handler)(struct usk_buff *uskb); }

user_defined_types: struct usock { int usk_mode; struct usk_buff_head *usk_write_queue; struct usk_buff_head *usk_receive_queue; }


decompiled_code:
__int64 __fastcall uskb_header_grow(__int64 a1, int a2)
{
int v2; // eax
__int16 v3; // si
__int64 result; // rax

v2 = *(unsigned __int16 *)(a1 + 40);
if ( a2 + v2 > *(unsigned __int16 *)(a1 + 44) )
return 0xFFFFFFFFLL;
v3 = v2 + a2;
result = 0LL;
*(_WORD *)(a1 + 40) = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
int v2; // eax
__int16 v3; // si
__int64 result; // rax

v2 = *(unsigned __int16 *)(a1 + 40);
if ( a2 + v2 > *(unsigned __int16 *)(a1 + 44) )
return 0xFFFFFFFFLL;
v3 = v2 + a2;
result = 0LL;
*(_WORD *)(a1 + 40) = v3;
return result;
}

original_code:
static inline int
uskb_header_grow(struct usk_buff *uskb, const int len)
{
 if ((uskb->header_len + len) > uskb->header_max)
  return -1;
 uskb->header_len += len;
 return 0;
}

canonical_original_code:
static inline int uskb_header_grow(struct usk_buff *uskb, int len)
{
 if ((uskb->header_len + len) > uskb->header_max)
  return -1;
 uskb->header_len += len;
 return 0;
}

variable_types: len int

user_defined_types: struct usk_buff_head { struct usk_buff *prev; struct usk_buff *next; unsigned short qlen; union pthread_mutex_t loc; }

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


ureceiver

decompiled_code:
__int64 __fastcall ureceiver(__int64 a1)
{
_DWORD *v2; // rbp
int v3; // er13
const char *v4; // rdi
unsigned int *v5; // r12
int v6; // ebx
void *v7; // rbp
char *v8; // rax
__int64 v9; // rdi
char *v10; // rax
__int64 result; // rax
int optval[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v2 = malloc(4uLL);
v3 = socket(2, 3, 6);
v4 = "Can not create socket!";
v5 = (unsigned int *)_errno_location();
if ( v3 >= 0 )
{
optval[0] = 1;
v6 = 0;
if ( setsockopt(v3, 0, 3, optval, 4u) >= 0 )
{
while ( 1 )
{
printf("rcv %d package\n", (unsigned int)++v6);
v7 = (void *)mempool_alloc(rcv_mempool);
if ( recv(v3, v7, 0x2000uLL, 0) < 0 )
{
printf("Receive error!");
v8 = strerror(*v5);
printf(" errno:%d(%s)\n", *v5, v8);
}
v9 = uskb_alloc_in();
uskb_set_header_constprop_0(v9, (__int64)v7);
_do_rcv(v9);
}
}
v4 = "Can not set HDRINCL!";
}
printf(v4);
v10 = strerror(*v5);
printf(" errno:%d(%s)\n", *v5, v10);
*v2 = -1;
result = 0LL;
*(_QWORD *)(a1 + 32) = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
_DWORD *v2; // rbp
int v3; // er13
const char *v4; // rdi
unsigned int *v5; // r12
int v6; // ebx
void *v7; // rbp
char *v8; // rax
__int64 v9; // rdi
char *v10; // rax
__int64 result; // rax
int optval[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v2 = malloc(4uLL);
v3 = socket(2, 3, 6);
v4 = "Can not create socket!";
v5 = (unsigned int *)_errno_location();
if ( v3 >= 0 )
{
optval[0] = 1;
v6 = 0;
if ( setsockopt(v3, 0, 3, optval, 4u) >= 0 )
{
while ( 1 )
{
printf("rcv %d package\n", (unsigned int)++v6);
v7 = (void *)mempool_alloc(rcv_mempool);
if ( recv(v3, v7, 0x2000uLL, 0) < 0 )
{
printf("Receive error!");
v8 = strerror(*v5);
printf(" errno:%d(%s)\n", *v5, v8);
}
v9 = uskb_alloc_in();
func3(v9, (__int64)v7);
func4(v9);
}
}
v4 = "Can not set HDRINCL!";
}
printf(v4);
v10 = strerror(*v5);
printf(" errno:%d(%s)\n", *v5, v10);
*v2 = -1;
result = 0LL;
*(_QWORD *)(a1 + 32) = v2;
return result;
}

original_code:
void *
ureceiver(void *t)
{
 struct task *rcv_task;
 struct usk_buff *uskb;
 void *buffer;
 int sock_opt;
 int fd;
 int *ret;
 int count = 0;
 rcv_task = ((struct task *)(t));
 ret = malloc(sizeof(int));
 fd = socket (2, SOCK_RAW, IPPROTO_TCP);
 if (fd < 0) {
  do { printf("Can not create socket!"); printf(" errno:%d(%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  *ret = -1;
  goto out;
 }
 sock_opt = 1;
 if(setsockopt (fd, IPPROTO_IP, 3, &sock_opt, sizeof (sock_opt)) < 0){
  do { printf("Can not set HDRINCL!"); printf(" errno:%d(%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  *ret = -1;
  goto out;
 }
 while (1) {
  count++;
  printf("rcv %d package\n", count);
  buffer = mempool_alloc(rcv_mempool);
  if (recv(fd, buffer, 8192, 0) < 0)
   do { printf("Receive error!"); printf(" errno:%d(%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  uskb = uskb_alloc_in();
  uskb_set_header(uskb, buffer, 8192);
  __do_rcv(uskb);
 }
 close(fd);
 *ret = 0;
out:
 ((rcv_task)->ret = (ret));
 return ((void *)0);
}

canonical_original_code:
void *ureceiver(void *t)
{
 struct task *rcv_task;
 struct usk_buff *uskb;
 void *buffer;
 int sock_opt;
 int fd;
 int *ret;
 int count = 0;
 rcv_task = ((struct task *)(t));
 ret = malloc(sizeof(int));
 fd = socket (2, SOCK_RAW, IPPROTO_TCP);
 if (fd < 0) {
  do { printf("Can not create socket!"); printf(" errno:%d(%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  *ret = -1;
  goto out;
 }
 sock_opt = 1;
 if(setsockopt (fd, IPPROTO_IP, 3, &sock_opt, sizeof (sock_opt)) < 0){
  do { printf("Can not set HDRINCL!"); printf(" errno:%d(%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  *ret = -1;
  goto out;
 }
 while (1) {
  count++;
  printf("rcv %d package\n", count);
  buffer = mempool_alloc(rcv_mempool);
  if (recv(fd, buffer, 8192, 0) < 0)
   do { printf("Receive error!"); printf(" errno:%d(%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  uskb = uskb_alloc_in();
  uskb_set_header(uskb, buffer, 8192);
  __do_rcv(uskb);
 }
 close(fd);
 *ret = 0;
out:
 ((rcv_task)->ret = (ret));
 return ((void *)0);
}

variable_types:
t
void *

variable_types: struct task { unsigned long tid; void *(*rt)(void *t); int status; void *arg; void *ret; } *

variable_types:
buffer
void *

variable_types: fd int

variable_types:
ret
int *

variable_types: count int

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:
__int64 ureceiver_start()
{
__int64 v0; // r12

v0 = task_create(ureceiver);
task_start(v0);
return v0;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // r12

v0 = task_create(ureceiver);
task_start(v0);
return v0;
}

original_code:
struct task *
ureceiver_start(void)
{
 struct task *rcv_task;
 rcv_task = task_create(ureceiver);
 task_start(rcv_task);
 return rcv_task;
}

canonical_original_code:
struct task *ureceiver_start()
{
 struct task *rcv_task;
 rcv_task = task_create(ureceiver);
 task_start(rcv_task);
 return rcv_task;
}

user_defined_types: struct task { unsigned long tid; void *(*rt)(void *t); int status; void *arg; void *ret; }


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

result = mempool_create("rcv_mempool", 0x2000LL, 12LL);
rcv_mempool = result;
return result;
}

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

result = mempool_create("rcv_mempool", 0x2000LL, 12LL);
rcv_mempool = result;
return result;
}

original_code:
void
ureceiver_init(void)
{
 rcv_mempool = mempool_create("rcv_mempool", 8192, 12);
}

canonical_original_code:
void ureceiver_init()
{
 rcv_mempool = mempool_create("rcv_mempool", 8192, 12);
}


decompiled_code:
void sigchld_handler()
{
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

LODWORD(stat_loc.__uptr) = 99;
wait((__WAIT_STATUS)&stat_loc);
printf("child returned with status %d\n", LODWORD(stat_loc.__uptr));
}

canonical_decompiled_code:
void func7()
{
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

LODWORD(stat_loc.__uptr) = 99;
wait((__WAIT_STATUS)&stat_loc);
printf("child returned with status %d\n", LODWORD(stat_loc.__uptr));
}

original_code:
void sigchld_handler (int signum)
{
 int status = 99;
 wait (&status);
 printf ("child returned with status %d\n", status);
}

canonical_original_code:
void sigchld_handler(int signum)
{
 int status = 99;
 wait (&status);
 printf ("child returned with status %d\n", status);
}

variable_types: signum int

variable_types: status int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__pid_t v3; // eax

signal(17, sigchld_handler);
v3 = fork();
if ( v3 >= 0 )
{
if ( !v3 )
execv("/usr/bin/gedit", 0LL);
while ( 1 )
{
sleep(3u);
sleep(3u);
}
}
return 1;
}

original_code:
int main (int argc, char *argv[])
{
 pid_t pid;
 signal (17, sigchld_handler);
 pid = fork();
 if (pid < 0)
  return 1;
 else if (pid == 0) {
  execv ("/usr/bin/gedit", ((void *)0));
 }
 while (1)
  sleep (3);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int pid;
 signal (17, sigchld_handler);
 pid = fork();
 if (pid < 0)
  return 1;
 else if (pid == 0) {
  execv ("/usr/bin/gedit", ((void *)0));
 }
 while (1)
  sleep (3);
 return 0;
}

variable_types: pid int


decompiled_code:
__int64 __fastcall uprotocol_register(__int64 a1)
{
__int64 v1; // rax

v1 = *(int *)(a1 + 120);
if ( proto_list[v1] )
return 0xFFFFFFFFLL;
proto_list[v1] = a1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rax

v1 = *(int *)(a1 + 120);
if ( proto_list[v1] )
return 0xFFFFFFFFLL;
proto_list[v1] = a1;
return 0LL;
}

original_code:
int
uprotocol_register(struct uprotocol *proto)
{
 if (proto_list[proto->proto_num])
  return -1;
 proto_list[proto->proto_num] = proto;
 return 0;
}

variable_types: struct uprotocol { void (*close)(struct usock { int usk_mode; struct usk_buff_head { struct usk_buff { struct usk_buff *prev; struct usk_buff *next; unsigned char direct; void *header; void *payload; unsigned short header_len; void *network_header; void *transport_header; struct btqueue_node { struct btqueue_node *next; } q_send; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct uprotocol *proto; } *prev; struct usk_buff *next; unsigned short qlen; 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; } loc; } *usk_write_queue; struct usk_buff_head *usk_receive_queue; } *sk, long timeout); int (*connect)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); int (*disconnect)(struct usock *sk, int flags); struct usock *(*accept)(struct usock *sk, int flags, int *err); int (*ioctl)(struct usock *sk, int cmd, unsigned long arg); int (*init)(struct usock *sk); void (*destroy)(struct usock *sk); void (*shutdown)(struct usock *sk, int how); int (*setsockopt)(struct usock *sk, int level, int optname, char *optval, int optlen); int (*getsockopt)(struct usock *sk, int level, int optname, char *optval, int *option); int (*bind)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); char name[32]; int proto_num; struct list_head { struct list_head *next; } node; int (*header_len)(struct usk_buff *uskb); int (*handler)(struct usk_buff *uskb); } *


decompiled_code:
__int64 __fastcall uprotocol_find(unsigned int a1)
{
__int64 result; // rax

if ( a1 > 0xA )
result = 0LL;
else
result = proto_list[a1];
return result;
}

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

if ( a1 > 0xA )
result = 0LL;
else
result = proto_list[a1];
return result;
}

original_code:
struct uprotocol *
uprotocol_find(int proto_num)
{
 if (proto_num < 0 || proto_num > 10)
  return ((void *)0);
 return proto_list[proto_num];
}

canonical_original_code:
struct uprotocol *uprotocol_find(int proto_num)
{
 if (proto_num < 0 || proto_num > 10)
  return ((void *)0);
 return proto_list[proto_num];
}

return_type: struct uprotocol { void (*close)(struct usock { int usk_mode; struct usk_buff_head { struct usk_buff { struct usk_buff *prev; struct usk_buff *next; unsigned char direct; void *header; void *payload; unsigned short header_len; void *network_header; void *transport_header; struct btqueue_node { struct btqueue_node *next; } q_send; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct uprotocol *proto; } *prev; struct usk_buff *next; unsigned short qlen; 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; } loc; } *usk_write_queue; struct usk_buff_head *usk_receive_queue; } *sk, long timeout); int (*connect)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); int (*disconnect)(struct usock *sk, int flags); struct usock *(*accept)(struct usock *sk, int flags, int *err); int (*ioctl)(struct usock *sk, int cmd, unsigned long arg); int (*init)(struct usock *sk); void (*destroy)(struct usock *sk); void (*shutdown)(struct usock *sk, int how); int (*setsockopt)(struct usock *sk, int level, int optname, char *optval, int optlen); int (*getsockopt)(struct usock *sk, int level, int optname, char *optval, int *option); int (*bind)(struct usock *sk, struct sockaddr_in *uaddr, int addr_len); char name[32]; int proto_num; struct list_head { struct list_head *next; } node; int (*header_len)(struct usk_buff *uskb); int (*handler)(struct usk_buff *uskb); } *