original_code:
struct iovec * alloc_iovec(unsigned int num)
{
 struct iovec *iov;
 unsigned int i;
 iov = __zmalloc(num * sizeof(struct iovec), __func__);
 for (i = 0; i < num; i++) {
  struct map *map = get_map();
  iov[i].iov_base = map->ptr;
  if ((rnd() & 1))
   iov[i].iov_len = 20;
  else
   iov[i].iov_len = rnd() % map->size;
 }
 return iov;
}

canonical_original_code:
struct iovec *alloc_iovec(unsigned int num)
{
 struct iovec *iov;
 unsigned int i;
 iov = __zmalloc(num * sizeof(struct iovec), __func__);
 for (i = 0; i < num; i++) {
  struct map *map = get_map();
  iov[i].iov_base = map->ptr;
  if ((rnd() & 1))
   iov[i].iov_len = 20;
  else
   iov[i].iov_len = rnd() % map->size;
 }
 return iov;
}

variable_types:
num
unsigned int

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

variable_types:
i
unsigned int

variable_types: struct map { void *ptr; char *name; unsigned long size; int prot; unsigned char type; } *


repo: kernelslacker/trinity

decompiled_code:
__int64 register_mce_grp()
{
return register_ioctl_group(&mce_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&mce_grp);
}

original_code: static void __attribute__((constructor)) register_mce_grp(void) { register_ioctl_group(&mce_grp); }

canonical_original_code: static void register_mce_grp() { register_ioctl_group(&mce_grp); }

return_type: void


decompiled_code:
__int64 get_fanotify_init_flags()
{
int v0; // eax
__int64 v1; // rdx

v0 = rnd();
v1 = (0x2492492492492493LL * (unsigned __int128)(unsigned __int64)v0) >> 64;
return fanotify_init_flags[v0 - 7 * ((((unsigned __int64)(v0 - v1) >> 1) + v1) >> 2)];
}

original_code:
unsigned long get_fanotify_init_flags(void)
{
 return fanotify_init_flags[rnd() % (sizeof(fanotify_init_flags) / sizeof((fanotify_init_flags)[0]))];
}

canonical_original_code:
unsigned long get_fanotify_init_flags()
{
 return fanotify_init_flags[rnd() % (sizeof(fanotify_init_flags) / sizeof((fanotify_init_flags)[0]))];
}

return_type: unsigned long


decompiled_code:
__int64 get_fanotify_init_event_flags()
{
int v0; // eax
__int64 v1; // rbx

v0 = rnd();
v1 = fanotify_event_flags_base[v0
- (v0 / 3uLL
+ (((0xAAAAAAAAAAAAAAABLL * (unsigned __int128)(unsigned __int64)v0) >> 64) & 0xFFFFFFFFFFFFFFFELL))];
return v1 | set_rand_bitmask(7LL, &fanotify_event_flags_extra);
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // eax
__int64 v1; // rbx

v0 = rnd();
v1 = fanotify_event_flags_base[v0
- (v0 / 3uLL
+ (((0xAAAAAAAAAAAAAAABLL * (unsigned __int128)(unsigned __int64)v0) >> 64) & 0xFFFFFFFFFFFFFFFELL))];
return v1 | set_rand_bitmask(7LL, &fanotify_event_flags_extra);
}

original_code:
unsigned long get_fanotify_init_event_flags(void)
{
 unsigned long flags;
 flags = fanotify_event_flags_base[rnd() % (sizeof(fanotify_event_flags_base) / sizeof((fanotify_event_flags_base)[0]))];
 flags |= set_rand_bitmask((sizeof(fanotify_event_flags_extra) / sizeof((fanotify_event_flags_extra)[0])), fanotify_event_flags_extra);
 return flags;
}

canonical_original_code:
unsigned long get_fanotify_init_event_flags()
{
 unsigned long flags;
 flags = fanotify_event_flags_base[rnd() % (sizeof(fanotify_event_flags_base) / sizeof((fanotify_event_flags_base)[0]))];
 flags |= set_rand_bitmask((sizeof(fanotify_event_flags_extra) / sizeof((fanotify_event_flags_extra)[0])), fanotify_event_flags_extra);
 return flags;
}

variable_types:
flags
unsigned long


decompiled_code:
int init_kcov()
{
void *v0; // rax
int v1; // ebx
int *v2; // rax
char *v3; // rax
int *v4; // rax
char *v5; // rax

LODWORD(v0) = open("/sys/kernel/debug/kcov", 2);
kcovfd = (int)v0;
if ( (_DWORD)v0 != -1 )
{
v1 = (int)v0;
if ( ioctl((int)v0, 0x80086301uLL, 0x10000LL) )
{
v2 = _errno_location();
v3 = strerror(*v2);
_printf_chk(1LL, "Failed to init kcov: %s\n", v3);
}
else
{
v0 = mmap(0LL, 0x80000uLL, 3, 1, v1, 0LL);
cover = v0;
if ( v0 != (void *)-1LL )
return (int)v0;
v4 = _errno_location();
v5 = strerror(*v4);
_printf_chk(1LL, "Failed to mmap kcov buffer: %s\n", v5);
}
LODWORD(v0) = close(kcovfd);
kcovfd = -1;
}
return (int)v0;
}

canonical_decompiled_code:
int func0()
{
void *v0; // rax
int v1; // ebx
int *v2; // rax
char *v3; // rax
int *v4; // rax
char *v5; // rax

LODWORD(v0) = open("/sys/kernel/debug/kcov", 2);
kcovfd = (int)v0;
if ( (_DWORD)v0 != -1 )
{
v1 = (int)v0;
if ( ioctl((int)v0, 0x80086301uLL, 0x10000LL) )
{
v2 = _errno_location();
v3 = strerror(*v2);
_printf_chk(1LL, "Failed to init kcov: %s\n", v3);
}
else
{
v0 = mmap(0LL, 0x80000uLL, 3, 1, v1, 0LL);
cover = v0;
if ( v0 != (void *)-1LL )
return (int)v0;
v4 = _errno_location();
v5 = strerror(*v4);
_printf_chk(1LL, "Failed to mmap kcov buffer: %s\n", v5);
}
LODWORD(v0) = close(kcovfd);
kcovfd = -1;
}
return (int)v0;
}

original_code:
void init_kcov(void)
{
 kcovfd = open("/sys/kernel/debug/kcov", 02);
 if (kcovfd == -1)
  return;
 if (ioctl(kcovfd, (((2U) << (((0 +8)+8)+14)) | ((('c')) << (0 +8)) | (((1)) << 0) | ((((sizeof(unsigned long)))) << ((0 +8)+8))), (64<<10))) {
  printf("Failed to init kcov: %s\n", strerror((*__errno_location ())));
  goto fail;
 }
 cover = (unsigned long*)mmap(((void *)0), (64<<10) * sizeof(unsigned long),
         0x1 | 0x2, 0x01, kcovfd, 0);
 if ((void*)cover == ((void *) -1)) {
  printf("Failed to mmap kcov buffer: %s\n", strerror((*__errno_location ())));
  goto fail;
 }
 return;
fail:
 close(kcovfd);
 kcovfd = -1;
 return;
}

canonical_original_code:
void init_kcov()
{
 kcovfd = open("/sys/kernel/debug/kcov", 02);
 if (kcovfd == -1)
  return;
 if (ioctl(kcovfd, (((2U) << (((0 +8)+8)+14)) | ((('c')) << (0 +8)) | (((1)) << 0) | ((((sizeof(unsigned long)))) << ((0 +8)+8))), (64<<10))) {
  printf("Failed to init kcov: %s\n", strerror((*__errno_location ())));
  goto fail;
 }
 cover = (unsigned long *)mmap(((void *)0), (64<<10) * sizeof(unsigned long),
         0x1 | 0x2, 0x01, kcovfd, 0);
 if ((void *)cover == ((void *) -1)) {
  printf("Failed to mmap kcov buffer: %s\n", strerror((*__errno_location ())));
  goto fail;
 }
 return;
fail:
 close(kcovfd);
 kcovfd = -1;
 return;
}


decompiled_code:
void *enable_kcov()
{
void *result; // rax
int *v1; // rax
char *v2; // rax

if ( ioctl(kcovfd, 0x6364uLL, 0LL) )
{
v1 = _errno_location();
v2 = strerror(*v1);
_printf_chk(1LL, "Error enabling kcov: %s\n", v2);
}
result = cover;
*(_QWORD *)cover = 0LL;
return result;
}

canonical_decompiled_code:
void *func1()
{
void *result; // rax
int *v1; // rax
char *v2; // rax

if ( ioctl(kcovfd, 0x6364uLL, 0LL) )
{
v1 = _errno_location();
v2 = strerror(*v1);
_printf_chk(1LL, "Error enabling kcov: %s\n", v2);
}
result = cover;
*(_QWORD *)cover = 0LL;
return result;
}


decompiled_code:
_QWORD *dump_kcov_buffer()
{
_QWORD *result; // rax
__int64 v1; // rbp
__int64 v2; // rbx

result = cover;
v1 = *(_QWORD *)cover;
if ( *(_QWORD *)cover )
{
v2 = 0LL;
while ( 1 )
{
result = (_QWORD *)_printf_chk(1LL, "0x%lx\n", result[++v2]);
if ( v2 == v1 )
break;
result = cover;
}
}
return result;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *result; // rax
__int64 v1; // rbp
__int64 v2; // rbx

result = cover;
v1 = *(_QWORD *)cover;
if ( *(_QWORD *)cover )
{
v2 = 0LL;
while ( 1 )
{
result = (_QWORD *)_printf_chk(1LL, "0x%lx\n", result[++v2]);
if ( v2 == v1 )
break;
result = cover;
}
}
return result;
}

original_code:
void dump_kcov_buffer(void)
{
 unsigned long n, i;
 n = __atomic_load_n(&cover[0], 0);
 for (i = 0; i < n; i++)
  printf("0x%lx\n", cover[i + 1]);
}

canonical_original_code:
void dump_kcov_buffer()
{
 unsigned long n; unsigned long i;
 n = __atomic_load_n(&cover[0], 0);
 for (i = 0; i < n; i++)
  printf("0x%lx\n", cover[i + 1]);
}

variable_types:
n
unsigned long

variable_types:
i
unsigned long


decompiled_code:
int disable_kcov()
{
int result; // eax
int *v1; // rax
char *v2; // rax

result = ioctl(kcovfd, 0x6365uLL, 0LL);
if ( result )
{
v1 = _errno_location();
v2 = strerror(*v1);
result = _printf_chk(1LL, "Failed to disable kcov: %s\n", v2);
}
return result;
}

canonical_decompiled_code:
int func3()
{
int result; // eax
int *v1; // rax
char *v2; // rax

result = ioctl(kcovfd, 0x6365uLL, 0LL);
if ( result )
{
v1 = _errno_location();
v2 = strerror(*v1);
result = _printf_chk(1LL, "Failed to disable kcov: %s\n", v2);
}
return result;
}


decompiled_code:
void shutdown_kcov()
{
int v0; // ebp
int *v1; // rax
char *v2; // rax
int *v3; // rax
char *v4; // rax

v0 = kcovfd;
if ( kcovfd != -1 )
{
if ( !munmap(cover, 0x80000uLL) )
{
if ( !close(v0) )
return;
LABEL_5:
v1 = _errno_location();
v2 = strerror(*v1);
_printf_chk(1LL, "Couldn't close kcov fd (%d) : %s\n", (unsigned int)kcovfd, v2);
return;
}
v3 = _errno_location();
v4 = strerror(*v3);
_printf_chk(1LL, "Couldn't munmap kcov buffer : %s\n", v4);
if ( close(kcovfd) )
goto LABEL_5;
}
}

canonical_decompiled_code:
void func4()
{
int v0; // ebp
int *v1; // rax
char *v2; // rax
int *v3; // rax
char *v4; // rax

v0 = kcovfd;
if ( kcovfd != -1 )
{
if ( !munmap(cover, 0x80000uLL) )
{
if ( !close(v0) )
return;
LABEL_5:
v1 = _errno_location();
v2 = strerror(*v1);
_printf_chk(1LL, "Couldn't close kcov fd (%d) : %s\n", (unsigned int)kcovfd, v2);
return;
}
v3 = _errno_location();
v4 = strerror(*v3);
_printf_chk(1LL, "Couldn't munmap kcov buffer : %s\n", v4);
if ( close(kcovfd) )
goto LABEL_5;
}
}

original_code:
void shutdown_kcov(void)
{
 if (kcovfd == -1)
  return;
 if (munmap(cover, (64<<10) * sizeof(unsigned long)))
  printf("Couldn't munmap kcov buffer : %s\n", strerror((*__errno_location ())));
 if (close(kcovfd))
  printf("Couldn't close kcov fd (%d) : %s\n", kcovfd, strerror((*__errno_location ())));
}

canonical_original_code:
void shutdown_kcov()
{
 if (kcovfd == -1)
  return;
 if (munmap(cover, (64<<10) * sizeof(unsigned long)))
  printf("Couldn't munmap kcov buffer : %s\n", strerror((*__errno_location ())));
 if (close(kcovfd))
  printf("Couldn't close kcov fd (%d) : %s\n", kcovfd, strerror((*__errno_location ())));
}


decompiled_code:
__int64 register_autofs_grp()
{
return register_ioctl_group(&autofs_grp);
}

canonical_decompiled_code:
__int64 func2()
{
return register_ioctl_group(&autofs_grp);
}

original_code: static void __attribute__((constructor)) register_autofs_grp(void) { register_ioctl_group(&autofs_grp); }

canonical_original_code: static void register_autofs_grp() { register_ioctl_group(&autofs_grp); }


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

if ( (unsigned int)_open_timerfd_fds(0) )
result = _open_timerfd_fds(1);
else
result = 0LL;
return result;
}

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

if ( (unsigned int)func1(0) )
result = func1(1);
else
result = 0LL;
return result;
}

original_code:
static int open_timerfd_fds(void)
{
 int ret;
 ret = __open_timerfd_fds(0);
 if (ret != FALSE)
  ret = __open_timerfd_fds(1);
 return ret;
}

canonical_original_code:
static int open_timerfd_fds()
{
 int ret;
 ret = __open_timerfd_fds(0);
 if (ret != FALSE)
  ret = __open_timerfd_fds(1);
 return ret;
}

variable_types: ret int

return_type: int


decompiled_code:
__int64 register_timerfd_fd_provider()
{
return register_fd_provider(&timerfd_fd_provider);
}

canonical_decompiled_code:
__int64 func5()
{
return register_fd_provider(&timerfd_fd_provider);
}

original_code: static void __attribute__((constructor)) register_timerfd_fd_provider(void) { register_fd_provider(&timerfd_fd_provider); }

canonical_original_code: static void register_timerfd_fd_provider() { register_fd_provider(&timerfd_fd_provider); }


decompiled_code:
__int64 register_input_grp()
{
return register_ioctl_group(&input_grp);
}

canonical_decompiled_code:
__int64 func1()
{
return register_ioctl_group(&input_grp);
}

original_code: static void __attribute__((constructor)) register_input_grp(void) { register_ioctl_group(&input_grp); }

canonical_original_code: static void register_input_grp() { register_ioctl_group(&input_grp); }


decompiled_code:
void __fastcall list_del(__int64 a1)
{
_QWORD *v1; // rax

_list_del(*(_QWORD **)(a1 + 8), *(_QWORD *)a1);
v1[1] = 0LL;
*v1 = 0LL;
}

original_code:
static inline void list_del(struct list_head *entry)
{
        __list_del(entry->prev, entry->next);
        entry->next = entry->prev = ((void *)0);
}

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


decompiled_code:
void destroy_global_objects()
{
unsigned int i; // ebx
unsigned int v1; // edi

for ( i = 0; i != 20; ++i )
{
v1 = i;
destroy_objects_constprop_0(v1);
}
}

canonical_decompiled_code:
void func12()
{
unsigned int i; // ebx
unsigned int v1; // edi

for ( i = 0; i != 20; ++i )
{
v1 = i;
func10(v1);
}
}

original_code:
void destroy_global_objects(void)
{
 unsigned int i;
 for (i = 0; i < MAX_OBJECT_TYPES; i++)
  destroy_objects(i, 1);
}

canonical_original_code:
void destroy_global_objects()
{
 unsigned int i;
 for (i = 0; i < MAX_OBJECT_TYPES; i++)
  destroy_objects(i, 1);
}


decompiled_code:
__int64 prune_objects()
{
__int64 result; // rax
unsigned int i; // ebx
unsigned int v2; // edi

result = (unsigned int)__ROR4__(-858993459 * rnd() + 429496728, 1);
if ( (unsigned int)result <= 0x19999998 )
{
for ( i = 0; i != 20; ++i )
{
v2 = i;
result = _prune_objects_constprop_0(v2);
}
}
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 result; // rax
unsigned int i; // ebx
unsigned int v2; // edi

result = (unsigned int)__ROR4__(-858993459 * rnd() + 429496728, 1);
if ( (unsigned int)result <= 0x19999998 )
{
for ( i = 0; i != 20; ++i )
{
v2 = i;
result = func11(v2);
}
}
return result;
}

original_code:
void prune_objects(void)
{
 unsigned int i;
 if (!(((rnd() % 10) == 0)))
  return;
 for (i = 0; i < MAX_OBJECT_TYPES; i++) {
  __prune_objects(i, 0);
 }
}

canonical_original_code:
void prune_objects()
{
 unsigned int i;
 if (!(((rnd() % 10) == 0)))
  return;
 for (i = 0; i < MAX_OBJECT_TYPES; i++) {
  __prune_objects(i, 0);
 }
}


decompiled_code:
__int64 register_loop_ctrl_grp()
{
return register_ioctl_group(&loop_ctrl_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&loop_ctrl_grp);
}

original_code: static void __attribute__((constructor)) register_loop_ctrl_grp(void) { register_ioctl_group(&loop_ctrl_grp); }

canonical_original_code: static void register_loop_ctrl_grp() { register_ioctl_group(&loop_ctrl_grp); }


decompiled_code:
__int64 register_loop_grp()
{
return register_ioctl_group(&loop_grp);
}

canonical_decompiled_code:
__int64 func1()
{
return register_ioctl_group(&loop_grp);
}

original_code: static void __attribute__((constructor)) register_loop_grp(void) { register_ioctl_group(&loop_grp); }

canonical_original_code: static void register_loop_grp() { register_ioctl_group(&loop_grp); }


decompiled_code:
__int64 register_sgx_grp()
{
return register_ioctl_group(&sgx_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&sgx_grp);
}

original_code: static void __attribute__((constructor)) register_sgx_grp(void) { register_ioctl_group(&sgx_grp); }

canonical_original_code: static void register_sgx_grp() { register_ioctl_group(&sgx_grp); }


decompiled_code:
__int64 register_file_fd_provider()
{
return register_fd_provider(&file_fd_provider);
}

canonical_decompiled_code:
__int64 func6()
{
return register_fd_provider(&file_fd_provider);
}

original_code: static void __attribute__((constructor)) register_file_fd_provider(void) { register_fd_provider(&file_fd_provider); }

canonical_original_code: static void register_file_fd_provider() { register_fd_provider(&file_fd_provider); }


original_code:
static unsigned long handle_arg_mode_t(void)
{
 unsigned int i, count;
 mode_t mode = 0, op = 0;
 count = rnd() % 9;
 for (i = 0; i < count; i++) {
  unsigned int j;
  j = rnd() % 16;
  switch (j) {
  case 0: op = (0400|0200|0100); break;
  case 1: op = 0400; break;
  case 2: op = 0200; break;
  case 3: op = 0100; break;
  case 4: op = ((0400|0200|0100) >> 3); break;
  case 5: op = (0400 >> 3); break;
  case 6: op = (0200 >> 3); break;
  case 7: op = (0100 >> 3); break;
  case 8: op = (((0400|0200|0100) >> 3) >> 3); break;
  case 9: op = ((0400 >> 3) >> 3); break;
  case 10: op = ((0200 >> 3) >> 3); break;
  case 11: op = ((0100 >> 3) >> 3); break;
  case 12: op = 04000; break;
  case 13: op = 02000; break;
  case 14: op = 01000; break;
  }
  if ((rnd() & 1))
   mode |= op;
  else
   mode &= ~op;
 }
 return mode;
}

canonical_original_code:
static unsigned long handle_arg_mode_t()
{
 unsigned int i; unsigned int count;
 unsigned int mode = 0; unsigned int op = 0;
 count = rnd() % 9;
 for (i = 0; i < count; i++) {
  unsigned int j;
  j = rnd() % 16;
  switch (j) {
  case 0: op = (0400|0200|0100); break;
  case 1: op = 0400; break;
  case 2: op = 0200; break;
  case 3: op = 0100; break;
  case 4: op = ((0400|0200|0100) >> 3); break;
  case 5: op = (0400 >> 3); break;
  case 6: op = (0200 >> 3); break;
  case 7: op = (0100 >> 3); break;
  case 8: op = (((0400|0200|0100) >> 3) >> 3); break;
  case 9: op = ((0400 >> 3) >> 3); break;
  case 10: op = ((0200 >> 3) >> 3); break;
  case 11: op = ((0100 >> 3) >> 3); break;
  case 12: op = 04000; break;
  case 13: op = 02000; break;
  case 14: op = 01000; break;
  }
  if ((rnd() & 1))
   mode |= op;
  else
   mode &= ~op;
 }
 return mode;
}

variable_types:
count
unsigned int

variable_types:
mode
unsigned int

variable_types:
op
unsigned int

variable_types:
j
unsigned int


decompiled_code:
__int64 __fastcall init_seed(unsigned int a1)
{
int v1; // eax
int v2; // er12
unsigned int v3; // er12
int *v5; // rax
char *v6; // rax
int *v7; // rax
char *v8; // rax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( user_set_seed == 1 )
{
v3 = a1;
output(0LL, "Using user passed random seed: %u.\n", a1);
if ( do_syslog != 1 )
return v3;
goto LABEL_8;
}
v1 = open("/dev/urandom", 0);
v2 = v1;
if ( v1 != -1 )
{
if ( read(v1, buf, 4uLL) != 4 )
{
v5 = _errno_location();
v6 = strerror(*v5);
_printf_chk(1LL, "urandom: %s\n", v6);
}
close(v2);
v3 = buf[0];
srand(buf[0]);
output(0LL, "Initial random seed: %u\n", v3);
if ( do_syslog != 1 )
return v3;
LABEL_8:
openlog("trinity", 34, 8);
_syslog_chk(2LL, 1LL, "Initial random seed: %u\n", v3);
closelog();
return v3;
}
v7 = _errno_location();
v8 = strerror(*v7);
_printf_chk(1LL, "urandom: %s\n", v8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
int v1; // eax
int v2; // er12
unsigned int v3; // er12
int *v5; // rax
char *v6; // rax
int *v7; // rax
char *v8; // rax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( user_set_seed == 1 )
{
v3 = a1;
output(0LL, "Using user passed random seed: %u.\n", a1);
if ( do_syslog != 1 )
return v3;
goto LABEL_8;
}
v1 = open("/dev/urandom", 0);
v2 = v1;
if ( v1 != -1 )
{
if ( read(v1, buf, 4uLL) != 4 )
{
v5 = _errno_location();
v6 = strerror(*v5);
_printf_chk(1LL, "urandom: %s\n", v6);
}
close(v2);
v3 = buf[0];
srand(buf[0]);
output(0LL, "Initial random seed: %u\n", v3);
if ( do_syslog != 1 )
return v3;
LABEL_8:
openlog("trinity", 34, 8);
_syslog_chk(2LL, 1LL, "Initial random seed: %u\n", v3);
closelog();
return v3;
}
v7 = _errno_location();
v8 = strerror(*v7);
_printf_chk(1LL, "urandom: %s\n", v8);
return 0LL;
}

original_code:
unsigned int init_seed(unsigned int seedparam)
{
 if (user_set_seed == TRUE)
  output(0, "Using user passed random seed: %u.\n", seedparam);
 else {
  int urandomfd;
  unsigned int r;
  urandomfd = open("/dev/urandom", 00);
  if (urandomfd == -1) {
   printf("urandom: %s\n", strerror((*__errno_location ())));
   return FALSE;
  }
  if (read(urandomfd, &r, sizeof(r)) != sizeof(r))
   printf("urandom: %s\n", strerror((*__errno_location ())));
  close(urandomfd);
  seedparam = r;
  srand(r);
  output(0, "Initial random seed: %u\n", seedparam);
 }
 if (do_syslog == TRUE) {
  openlog("trinity", 0x02|0x20, (1<<3));
  syslog(2, "Initial random seed: %u\n", seedparam);
  closelog();
 }
 return seedparam;
}

variable_types:
seedparam
unsigned int

variable_types: urandomfd int

variable_types:
r
unsigned int

return_type: unsigned int


reseed

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

if ( getpid() != mainpid )
{
outputerr("Reseeding should only happen from parent!\n");
exit(1);
}
result = shm;
*(_DWORD *)(shm + 44LL) += max_children;
return result;
}

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

if ( getpid() != mainpid )
{
outputerr("Reseeding should only happen from parent!\n");
exit(1);
}
result = shm;
*(_DWORD *)(shm + 44LL) += max_children;
return result;
}

original_code:
void reseed(void)
{
 if (getpid() != mainpid) {
  outputerr("Reseeding should only happen from parent!\n");
  exit(1);
 }
 shm->seed += max_children;
}

canonical_original_code:
void reseed()
{
 if (getpid() != mainpid) {
  outputerr("Reseeding should only happen from parent!\n");
  exit(1);
 }
 shm->seed += max_children;
}


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

*(_DWORD *)a1 = 270;
result = (unsigned int)netlink_opts[(int)rnd() % 0xAuLL];
*(_QWORD *)(a1 + 8) = result;
return result;
}

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

*(_DWORD *)a1 = 270;
result = (unsigned int)netlink_opts[(int)rnd() % 0xAuLL];
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
static void netlink_setsockopt(struct sockopt *so, __attribute((unused)) struct socket_triplet *triplet)
{
 so->level = 270;
 so->optname = netlink_opts[rnd() % (sizeof(netlink_opts) / sizeof((netlink_opts)[0]))];
}

canonical_original_code:
static void netlink_setsockopt(struct sockopt *so, struct socket_triplet *triplet)
{
 so->level = 270;
 so->optname = netlink_opts[rnd() % (sizeof(netlink_opts) / sizeof((netlink_opts)[0]))];
}

variable_types: struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; } *

variable_types: struct socket_triplet { unsigned int family; unsigned int type; unsigned int protocol; } *


original_code:
unsigned long get_rand_mmap_flags(void)
{
 unsigned long flags;
 const unsigned long mmap_flags[] = {
  0x10, 0x20, 0x00100, 0x00800,
  0x01000, 0x02000, 0x04000, 0x08000,
  0x10000, 0x20000, 0x40000, 0x4000000,
  0x40,
 };
 flags = mmap_excl_flags[rnd() % (sizeof(mmap_excl_flags) / sizeof((mmap_excl_flags)[0]))];
 if ((rnd() & 1))
  flags |= set_rand_bitmask((sizeof(mmap_flags) / sizeof((mmap_flags)[0])), mmap_flags);
 return flags;
}

canonical_original_code:
unsigned long get_rand_mmap_flags()
{
 unsigned long flags;
 unsigned long mmap_flags[] = {
  0x10, 0x20, 0x00100, 0x00800,
  0x01000, 0x02000, 0x04000, 0x08000,
  0x10000, 0x20000, 0x40000, 0x4000000,
  0x40,
 };
 flags = mmap_excl_flags[rnd() % (sizeof(mmap_excl_flags) / sizeof((mmap_excl_flags)[0]))];
 if ((rnd() & 1))
  flags |= set_rand_bitmask((sizeof(mmap_flags) / sizeof((mmap_flags)[0])), mmap_flags);
 return flags;
}


decompiled_code:
__int64 register_epoll_fd_provider()
{
return register_fd_provider(&epoll_fd_provider);
}

canonical_decompiled_code:
__int64 func4()
{
return register_fd_provider(&epoll_fd_provider);
}

original_code: static void __attribute__((constructor)) register_epoll_fd_provider(void) { register_fd_provider(&epoll_fd_provider); }

canonical_original_code: static void register_epoll_fd_provider() { register_fd_provider(&epoll_fd_provider); }


decompiled_code:
__int64 dump_uids()
{
__uid_t ruid; // [rsp+8h] [rbp-20h] BYREF
__uid_t euid; // [rsp+Ch] [rbp-1Ch] BYREF
__uid_t suid; // [rsp+10h] [rbp-18h] BYREF
__gid_t rgid; // [rsp+14h] [rbp-14h] BYREF
__gid_t egid; // [rsp+18h] [rbp-10h] BYREF
__gid_t sgid[3]; // [rsp+1Ch] [rbp-Ch] BYREF

getresuid(&ruid, &euid, &suid);
getresgid(&rgid, &egid, sgid);
return outputstd("initial uid:%u gid:%u euid:%u egid:%u suid:%u sgid:%u\n", ruid, rgid, euid, egid, suid, sgid[0]);
}

canonical_decompiled_code:
__int64 func0()
{
__uid_t ruid; // [rsp+8h] [rbp-20h] BYREF
__uid_t euid; // [rsp+Ch] [rbp-1Ch] BYREF
__uid_t suid; // [rsp+10h] [rbp-18h] BYREF
__gid_t rgid; // [rsp+14h] [rbp-14h] BYREF
__gid_t egid; // [rsp+18h] [rbp-10h] BYREF
__gid_t sgid[3]; // [rsp+1Ch] [rbp-Ch] BYREF

getresuid(&ruid, &euid, &suid);
getresgid(&rgid, &egid, sgid);
return outputstd("initial uid:%u gid:%u euid:%u egid:%u suid:%u sgid:%u\n", ruid, rgid, euid, egid, suid, sgid[0]);
}

original_code:
void dump_uids(void)
{
 uid_t uid, euid, suid;
 gid_t gid, egid, sgid;
 getresuid(&uid, &euid, &suid);
 getresgid(&gid, &egid, &sgid);
 outputstd("initial uid:%u gid:%u euid:%u egid:%u suid:%u sgid:%u\n",
  uid, gid, euid, egid, suid, sgid);
}

canonical_original_code:
void dump_uids()
{
 unsigned int uid; unsigned int euid; unsigned int suid;
 unsigned int gid; unsigned int egid; unsigned int sgid;
 getresuid(&uid, &euid, &suid);
 getresgid(&gid, &egid, &sgid);
 outputstd("initial uid:%u gid:%u euid:%u egid:%u suid:%u sgid:%u\n",
  uid, gid, euid, egid, suid, sgid);
}

variable_types:
uid
unsigned int

variable_types:
euid
unsigned int

variable_types:
suid
unsigned int

variable_types:
gid
unsigned int

variable_types:
egid
unsigned int

variable_types:
sgid
unsigned int


decompiled_code:
__int64 init_uids()
{
__int64 result; // rax
struct passwd *v1; // rax
__uid_t v2; // edx
int *v3; // rax
char *v4; // rax

orig_uid = getuid();
orig_gid = getgid();
result = dropprivs;
if ( dropprivs )
{
v1 = getpwnam("nobody");
if ( !v1 )
{
v3 = _errno_location();
v4 = strerror(*v3);
outputerr("Error getting nobody pwent (%s)\n", v4);
exit(1);
}
v2 = v1->pw_uid;
result = v1->pw_gid;
nobody_uid = v2;
nobody_gid = result;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
struct passwd *v1; // rax
__uid_t v2; // edx
int *v3; // rax
char *v4; // rax

orig_uid = getuid();
orig_gid = getgid();
result = dropprivs;
if ( dropprivs )
{
v1 = getpwnam("nobody");
if ( !v1 )
{
v3 = _errno_location();
v4 = strerror(*v3);
outputerr("Error getting nobody pwent (%s)\n", v4);
exit(1);
}
v2 = v1->pw_uid;
result = v1->pw_gid;
nobody_uid = v2;
nobody_gid = result;
}
return result;
}

original_code:
void init_uids(void)
{
 struct passwd *passwd;
 orig_uid = getuid();
 orig_gid = getgid();
 if (dropprivs == FALSE)
  return;
 passwd = getpwnam("nobody");
 if (passwd == ((void *)0)) {
  outputerr("Error getting nobody pwent (%s)\n", strerror((*__errno_location ())));
  exit(1);
 }
 nobody_uid = passwd->pw_uid;
 nobody_gid = passwd->pw_gid;
}

canonical_original_code:
void init_uids()
{
 struct passwd *passwd;
 orig_uid = getuid();
 orig_gid = getgid();
 if (dropprivs == FALSE)
  return;
 passwd = getpwnam("nobody");
 if (passwd == ((void *)0)) {
  outputerr("Error getting nobody pwent (%s)\n", strerror((*__errno_location ())));
  exit(1);
 }
 nobody_uid = passwd->pw_uid;
 nobody_gid = passwd->pw_gid;
}

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *


decompiled_code:
unsigned int do_uid0_check()
{
unsigned int v0; // ebx
unsigned int result; // eax

if ( !orig_uid )
{
if ( dangerous == 1 )
{
outputstd("DANGER: RUNNING AS ROOT.\n");
outputstd("Unless you are running in a virtual machine, this could cause serious problems such as overwriting CMOS\n");
outputstd("or similar which could potentially make this machine unbootable without a firmware reset.\n");
outputstd("You might want to check out running with --dropprivs (currently experimental).\n\n");
}
else
{
if ( !dropprivs )
{
outputstd("Don't run as root (or pass --dangerous, or --dropprivs if you know what you are doing).\n");
exit(1);
}
outputstd(
"--dropprivs is still in development, and really shouldn't be used unless you're helping development. Expect crashes.\n");
outputstd("Going to run as user nobody (uid:%d gid:%d)\n", nobody_uid, nobody_gid);
}
if ( clowntown == 1 )
{
result = puts("THIS CLOWN GOES TO 11.");
}
else
{
v0 = 10;
outputstd("ctrl-c now unless you really know what you are doing.\n");
do
{
outputstd("Continuing in %u seconds.\r", v0);
fflush(stdout);
result = sleep(1u);
--v0;
}
while ( v0 );
}
}
return result;
}

canonical_decompiled_code:
unsigned int func3()
{
unsigned int v0; // ebx
unsigned int result; // eax

if ( !orig_uid )
{
if ( dangerous == 1 )
{
outputstd("DANGER: RUNNING AS ROOT.\n");
outputstd("Unless you are running in a virtual machine, this could cause serious problems such as overwriting CMOS\n");
outputstd("or similar which could potentially make this machine unbootable without a firmware reset.\n");
outputstd("You might want to check out running with --dropprivs (currently experimental).\n\n");
}
else
{
if ( !dropprivs )
{
outputstd("Don't run as root (or pass --dangerous, or --dropprivs if you know what you are doing).\n");
exit(1);
}
outputstd(
"--dropprivs is still in development, and really shouldn't be used unless you're helping development. Expect crashes.\n");
outputstd("Going to run as user nobody (uid:%d gid:%d)\n", nobody_uid, nobody_gid);
}
if ( clowntown == 1 )
{
result = puts("THIS CLOWN GOES TO 11.");
}
else
{
v0 = 10;
outputstd("ctrl-c now unless you really know what you are doing.\n");
do
{
outputstd("Continuing in %u seconds.\r", v0);
fflush(stdout);
result = sleep(1u);
--v0;
}
while ( v0 );
}
}
return result;
}

original_code:
void do_uid0_check(void)
{
 unsigned int i;
 if (orig_uid != 0)
  return;
 if (dangerous == TRUE) {
  outputstd("DANGER: RUNNING AS ROOT.\n");
  outputstd("Unless you are running in a virtual machine, this could cause serious problems such as overwriting CMOS\n");
  outputstd("or similar which could potentially make this machine unbootable without a firmware reset.\n");
  outputstd("You might want to check out running with --dropprivs (currently experimental).\n\n");
 } else {
  if (dropprivs == FALSE) {
   outputstd("Don't run as root (or pass --dangerous, or --dropprivs if you know what you are doing).\n");
   exit(1);
  } else {
   outputstd("--dropprivs is still in development, and really shouldn't be used unless you're helping development. Expect crashes.\n");
   outputstd("Going to run as user nobody (uid:%d gid:%d)\n", nobody_uid, nobody_gid);
  }
 }
 if (clowntown == TRUE) {
  printf("THIS CLOWN GOES TO 11.\n");
  return;
 }
 outputstd("ctrl-c now unless you really know what you are doing.\n");
 for (i = 10; i > 0; i--) {
  outputstd("Continuing in %u seconds.\r", i);
  (void)fflush(stdout);
  sleep(1);
 }
}

canonical_original_code:
void do_uid0_check()
{
 unsigned int i;
 if (orig_uid != 0)
  return;
 if (dangerous == TRUE) {
  outputstd("DANGER: RUNNING AS ROOT.\n");
  outputstd("Unless you are running in a virtual machine, this could cause serious problems such as overwriting CMOS\n");
  outputstd("or similar which could potentially make this machine unbootable without a firmware reset.\n");
  outputstd("You might want to check out running with --dropprivs (currently experimental).\n\n");
 } else {
  if (dropprivs == FALSE) {
   outputstd("Don't run as root (or pass --dangerous, or --dropprivs if you know what you are doing).\n");
   exit(1);
  } else {
   outputstd("--dropprivs is still in development, and really shouldn't be used unless you're helping development. Expect crashes.\n");
   outputstd("Going to run as user nobody (uid:%d gid:%d)\n", nobody_uid, nobody_gid);
  }
 }
 if (clowntown == TRUE) {
  printf("THIS CLOWN GOES TO 11.\n");
  return;
 }
 outputstd("ctrl-c now unless you really know what you are doing.\n");
 for (i = 10; i > 0; i--) {
  outputstd("Continuing in %u seconds.\r", i);
  (void)fflush(stdout);
  sleep(1);
 }
}

variable_types:
i
unsigned int


decompiled_code:
__uid_t check_uid()
{
__uid_t result; // eax

result = orig_uid;
if ( orig_uid )
{
result = getuid();
if ( dropprivs == 1 )
{
if ( nobody_uid == result )
return result;
}
else if ( orig_uid == result )
{
return result;
}
if ( result != 65534 )
{
output(0LL, "uid changed! Was: %u, now %u\n", (unsigned int)orig_uid);
panic(12LL);
exit(1);
}
}
return result;
}

canonical_decompiled_code:
__uid_t func4()
{
__uid_t result; // eax

result = orig_uid;
if ( orig_uid )
{
result = getuid();
if ( dropprivs == 1 )
{
if ( nobody_uid == result )
return result;
}
else if ( orig_uid == result )
{
return result;
}
if ( result != 65534 )
{
output(0LL, "uid changed! Was: %u, now %u\n", (unsigned int)orig_uid);
panic(12LL);
exit(1);
}
}
return result;
}

original_code:
void check_uid(void)
{
 uid_t myuid;
 if (orig_uid == 0)
  return;
 myuid = getuid();
 if (dropprivs == TRUE) {
  if (myuid == nobody_uid)
   return;
  else
   goto changed;
 }
 if (myuid != orig_uid) {
changed:
  if (myuid == 65534)
   return;
  output(0, "uid changed! Was: %u, now %u\n", orig_uid, myuid);
  panic(EXIT_UID_CHANGED);
  _exit(1);
 }
}

canonical_original_code:
void check_uid()
{
 unsigned int myuid;
 if (orig_uid == 0)
  return;
 myuid = getuid();
 if (dropprivs == TRUE) {
  if (myuid == nobody_uid)
   return;
  else
   goto changed;
 }
 if (myuid != orig_uid) {
changed:
  if (myuid == 65534)
   return;
  output(0, "uid changed! Was: %u, now %u\n", orig_uid, myuid);
  panic(EXIT_UID_CHANGED);
  _exit(1);
 }
}

variable_types:
myuid
unsigned int


decompiled_code:
__int64 __fastcall dirty_mapping(__int64 a1)
{
int v1; // eax
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 24);
if ( v1 == 1 )
return random_map_readfn();
result = (unsigned int)(v1 - 2);
if ( (unsigned int)result <= 1 )
result = random_map_writefn();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v1; // eax
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 24);
if ( v1 == 1 )
return random_map_readfn();
result = (unsigned int)(v1 - 2);
if ( (unsigned int)result <= 1 )
result = random_map_writefn();
return result;
}

original_code:
void dirty_mapping(struct map *map)
{
 switch (map->prot) {
 case 0x2:
 case 0x2|0x1:
  random_map_writefn(map);
  break;
 case 0x1:
  random_map_readfn(map);
  break;
 case 0x8:
 case 0x0:
 default:
  break;
 }
}

variable_types: struct map { void *ptr; char *name; unsigned long size; int prot; unsigned char type; } *


decompiled_code:
__int64 dirty_random_mapping()
{
__int64 v0; // rax

v0 = get_map();
return dirty_mapping(v0);
}

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

v0 = func2();
return func5(v0);
}

original_code:
void dirty_random_mapping(void)
{
 struct map *map;
 map = get_map();
 dirty_mapping(map);
}

canonical_original_code:
void dirty_random_mapping()
{
 struct map *map;
 map = get_map();
 dirty_mapping(map);
}

user_defined_types: struct map { void *ptr; char *name; unsigned long size; int prot; unsigned char type; }


outputerr

decompiled_code:
__int64 outputerr(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return _vfprintf_chk(stderr, 1LL, a1, va);
}

canonical_decompiled_code:
__int64 func0(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return _vfprintf_chk(stderr, 1LL, a1, va);
}

original_code:
void outputerr(const char *fmt, ...)
{
 va_list args;
 __builtin_va_start(args,fmt);
 vfprintf(stderr, fmt, args);
 __builtin_va_end(args);
}

canonical_original_code:
void outputerr(char *fmt, ...)
{
 __builtin_va_list args;
 __builtin_va_start(args,fmt);
 vfprintf(stderr, fmt, args);
 __builtin_va_end(args);
}

variable_types:
fmt
char *


outputstd

decompiled_code:
__int64 outputstd(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return _vfprintf_chk(stdout, 1LL, a1, va);
}

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

va_start(va, a1);
return _vfprintf_chk(stdout, 1LL, a1, va);
}

original_code:
void outputstd(const char *fmt, ...)
{
 va_list args;
 __builtin_va_start(args,fmt);
 vfprintf(stdout, fmt, args);
 __builtin_va_end(args);
}

canonical_original_code:
void outputstd(char *fmt, ...)
{
 __builtin_va_list args;
 __builtin_va_start(args,fmt);
 vfprintf(stdout, fmt, args);
 __builtin_va_end(args);
}


original_code:
static inline int random_futex_wake_op(void)
{
 const unsigned int op_flags[] = {
  0, 1, 2,
  3, 4,
 };
 const unsigned int cmp_flags[] = {
  0, 1, 2,
  3, 4, 5,
 };
 return op_flags[rnd() % (sizeof(op_flags) / sizeof((op_flags)[0]))] | cmp_flags[rnd() % (sizeof(cmp_flags) / sizeof((cmp_flags)[0]))];
}

canonical_original_code:
static inline int random_futex_wake_op()
{
 unsigned int op_flags[] = {
  0, 1, 2,
  3, 4,
 };
 unsigned int cmp_flags[] = {
  0, 1, 2,
  3, 4, 5,
 };
 return op_flags[rnd() % (sizeof(op_flags) / sizeof((op_flags)[0]))] | cmp_flags[rnd() % (sizeof(cmp_flags) / sizeof((cmp_flags)[0]))];
}


decompiled_code:
__int64 __fastcall futex_unlock(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+0h] [rbp-18h]

if ( *(_DWORD *)a1 == 1 )
{
*(_DWORD *)(a1 + 4) = 0;
_cmpxchg((volatile signed __int32 *)a1, 1, 0);
syscall(202LL, a1, 1LL);
syscall(202LL, a1, 7LL, 1LL, 0LL, 0LL, 0LL);
result = v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+0h] [rbp-18h]

if ( *(_DWORD *)a1 == 1 )
{
*(_DWORD *)(a1 + 4) = 0;
func6((volatile signed __int32 *)a1, 1, 0);
syscall(202LL, a1, 1LL);
syscall(202LL, a1, 7LL, 1LL, 0LL, 0LL, 0LL);
result = v2;
}
return result;
}

original_code:
static inline void futex_unlock(struct __lock *thislock)
{
 int status = thislock->futex;
 if (status == (!(0))) {
  thislock->owner_pid = 0;
  __cmpxchg(&thislock->futex, (!(0)), (0));
  syscall(202, &thislock->futex, 1, 1, ((void *)0), 0, 0);
  syscall(202, &thislock->futex, 7, 1, ((void *)0), 0, 0);
 }
}

variable_types: struct __lock { unsigned int futex; int owner_pid; } *

variable_types: status int


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

result = (unsigned int)(1 << a1);
kernel_taint_mask |= result;
return result;
}

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

result = (unsigned int)(1 << a1);
kernel_taint_mask |= result;
return result;
}

original_code:
static void toggle_taint_flag(int bit)
{
 kernel_taint_mask |= (1 << bit);
}

variable_types: bit int


decompiled_code:
__int64 __fastcall toggle_taint_flag_by_name(const char *a1, __int64 a2)
{
const char *v2; // r8
int v3; // esi
char v5[40]; // [rsp+0h] [rbp-28h] BYREF

v2 = a1;
if ( a2 )
{
v3 = a2 - (_DWORD)a1;
if ( v3 > 31 )
v3 = 31;
_strncpy_chk(v5, a1, v3, 32LL, a1);
v5[v3] = 0;
v2 = v5;
}
if ( !strcmp(v2, "PROPRIETARY_MODULE") )
return toggle_taint_flag(0);
if ( !strcmp(v2, "FORCED_MODULE") )
return toggle_taint_flag(1);
if ( !strcmp(v2, "UNSAFE_SMP") )
return toggle_taint_flag(2);
if ( !strcmp(v2, "FORCED_RMMOD") )
return toggle_taint_flag(3);
if ( !strcmp(v2, "MACHINE_CHECK") )
return toggle_taint_flag(4);
if ( !strcmp(v2, "BAD_PAGE") )
return toggle_taint_flag(5);
if ( !strcmp(v2, "USER") )
return toggle_taint_flag(6);
if ( !strcmp(v2, "DIE") )
return toggle_taint_flag(7);
if ( !strcmp(v2, "OVERRIDDEN_ACPI_TABLE") )
return toggle_taint_flag(8);
if ( !strcmp(v2, "WARN") )
return toggle_taint_flag(9);
if ( !strcmp(v2, "CRAP") )
return toggle_taint_flag(10);
if ( !strcmp(v2, "FIRMWARE_WORKAROUND") )
return toggle_taint_flag(11);
if ( strcmp(v2, "OOT_MODULE") )
{
outputerr("Unrecognizable kernel taint flag \"%s\".\n", v2);
exit(1);
}
return toggle_taint_flag(12);
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, __int64 a2)
{
const char *v2; // r8
int v3; // esi
char v5[40]; // [rsp+0h] [rbp-28h] BYREF

v2 = a1;
if ( a2 )
{
v3 = a2 - (_DWORD)a1;
if ( v3 > 31 )
v3 = 31;
_strncpy_chk(v5, a1, v3, 32LL, a1);
v5[v3] = 0;
v2 = v5;
}
if ( !strcmp(v2, "PROPRIETARY_MODULE") )
return func0(0);
if ( !strcmp(v2, "FORCED_MODULE") )
return func0(1);
if ( !strcmp(v2, "UNSAFE_SMP") )
return func0(2);
if ( !strcmp(v2, "FORCED_RMMOD") )
return func0(3);
if ( !strcmp(v2, "MACHINE_CHECK") )
return func0(4);
if ( !strcmp(v2, "BAD_PAGE") )
return func0(5);
if ( !strcmp(v2, "USER") )
return func0(6);
if ( !strcmp(v2, "DIE") )
return func0(7);
if ( !strcmp(v2, "OVERRIDDEN_ACPI_TABLE") )
return func0(8);
if ( !strcmp(v2, "WARN") )
return func0(9);
if ( !strcmp(v2, "CRAP") )
return func0(10);
if ( !strcmp(v2, "FIRMWARE_WORKAROUND") )
return func0(11);
if ( strcmp(v2, "OOT_MODULE") )
{
outputerr("Unrecognizable kernel taint flag \"%s\".\n", v2);
exit(1);
}
return func0(12);
}

original_code:
static void toggle_taint_flag_by_name(char *beg, char *end)
{
 char flagname[32];
 char *name;
 if (end == ((void *)0)) {
  name = beg;
 } else {
  int maxlen;
  name = flagname;
  maxlen = end - beg;
  if (maxlen > (32 - 1))
   maxlen = 32 - 1;
  strncpy(flagname, beg, maxlen);
  flagname[maxlen] = 0;
 }
 if (strcmp(name,"PROPRIETARY_MODULE") == 0)
  toggle_taint_flag(0);
 else if (strcmp(name,"FORCED_MODULE") == 0)
  toggle_taint_flag(1);
 else if (strcmp(name,"UNSAFE_SMP") == 0)
  toggle_taint_flag(2);
 else if (strcmp(name,"FORCED_RMMOD") == 0)
  toggle_taint_flag(3);
 else if (strcmp(name,"MACHINE_CHECK") == 0)
  toggle_taint_flag(4);
 else if (strcmp(name,"BAD_PAGE") == 0)
  toggle_taint_flag(5);
 else if (strcmp(name,"USER") == 0)
  toggle_taint_flag(6);
 else if (strcmp(name,"DIE") == 0)
  toggle_taint_flag(7);
 else if (strcmp(name,"OVERRIDDEN_ACPI_TABLE") == 0)
  toggle_taint_flag(8);
 else if (strcmp(name,"WARN") == 0)
  toggle_taint_flag(9);
 else if (strcmp(name,"CRAP") == 0)
  toggle_taint_flag(10);
 else if (strcmp(name,"FIRMWARE_WORKAROUND") == 0)
  toggle_taint_flag(11);
 else if (strcmp(name,"OOT_MODULE") == 0)
  toggle_taint_flag(12);
 else {
  outputerr("Unrecognizable kernel taint flag \"%s\".\n", name);
  exit(1);
 }
}

variable_types:
beg
char *

variable_types:
end
char *

variable_types:
flagname
char [32]

variable_types:
name
char *

variable_types: maxlen int


decompiled_code:
__int64 get_taint()
{
unsigned int v0; // er12
int v1; // ebp
char buf[35]; // [rsp+5h] [rbp-23h] BYREF

v0 = 0;
v1 = taint_fd;
if ( taint_fd != -1 )
{
buf[10] = 0;
lseek(taint_fd, 0LL, 0);
if ( (unsigned int)read(v1, buf, 0xAuLL) )
v0 = atoi(buf);
}
return v0;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // er12
int v1; // ebp
char buf[35]; // [rsp+5h] [rbp-23h] BYREF

v0 = 0;
v1 = taint_fd;
if ( taint_fd != -1 )
{
buf[10] = 0;
lseek(taint_fd, 0LL, 0);
if ( (unsigned int)read(v1, buf, 0xAuLL) )
v0 = atoi(buf);
}
return v0;
}

original_code:
int get_taint(void)
{
 unsigned int ret = 0;
 char buffer[11];
 if (taint_fd == -1)
  return 0;
 buffer[10] = 0;
 lseek(taint_fd, 0, 0);
 ret = read(taint_fd, buffer, 10);
 if (ret > 0)
  ret = atoi(buffer);
 else {
  ret = 0;
 }
 return ret;
}

canonical_original_code:
int get_taint()
{
 unsigned int ret = 0;
 char buffer[11];
 if (taint_fd == -1)
  return 0;
 buffer[10] = 0;
 lseek(taint_fd, 0, 0);
 ret = read(taint_fd, buffer, 10);
 if (ret > 0)
  ret = atoi(buffer);
 else {
  ret = 0;
 }
 return ret;
}

variable_types:
ret
unsigned int

variable_types:
buffer
char [11]


decompiled_code:
__int64 __fastcall process_taint_arg(char *s)
{
char *v2; // rdi
char *v3; // rax

if ( !kernel_taint_param_occured )
{
kernel_taint_param_occured = 1;
kernel_taint_mask = 0;
}
while ( 1 )
{
v3 = strchr(s, 44);
if ( !v3 )
break;
v2 = s;
s = v3 + 1;
toggle_taint_flag_by_name(v2, (__int64)v3);
}
return toggle_taint_flag_by_name(s, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s)
{
char *v2; // rdi
char *v3; // rax

if ( !kernel_taint_param_occured )
{
kernel_taint_param_occured = 1;
kernel_taint_mask = 0;
}
while ( 1 )
{
v3 = strchr(s, 44);
if ( !v3 )
break;
v2 = s;
s = v3 + 1;
func1(v2, (__int64)v3);
}
return func1(s, 0LL);
}

original_code:
void process_taint_arg(char *taintarg)
{
 char *beg, *end;
 if (kernel_taint_param_occured == FALSE) {
  kernel_taint_param_occured = TRUE;
  kernel_taint_mask = 0;
 }
 beg = taintarg;
 end = strchr(beg, ',');
 while(end != ((void *)0)) {
  toggle_taint_flag_by_name(beg,end);
  beg = end + 1;
  end = strchr(beg, ',');
 }
 toggle_taint_flag_by_name(beg,end);
}

canonical_original_code:
void process_taint_arg(char *taintarg)
{
 char *beg; char *end;
 if (kernel_taint_param_occured == FALSE) {
  kernel_taint_param_occured = TRUE;
  kernel_taint_mask = 0;
 }
 beg = taintarg;
 end = strchr(beg, ',');
 while(end != ((void *)0)) {
  toggle_taint_flag_by_name(beg,end);
  beg = end + 1;
  end = strchr(beg, ',');
 }
 toggle_taint_flag_by_name(beg,end);
}

variable_types:
taintarg
char *


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

taint_fd = open("/proc/sys/kernel/tainted", 0);
result = get_taint();
kernel_taint_initial = result;
if ( (_DWORD)result )
result = output(0LL, "Kernel was tainted on startup. Will ignore flags that are already set.\n");
return result;
}

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

taint_fd = open("/proc/sys/kernel/tainted", 0);
result = func2();
kernel_taint_initial = result;
if ( (_DWORD)result )
result = output(0LL, "Kernel was tainted on startup. Will ignore flags that are already set.\n");
return result;
}

original_code:
void init_taint_checking(void)
{
 taint_fd = open("/proc/sys/kernel/tainted", 00);
 kernel_taint_initial = get_taint();
 if (kernel_taint_initial != 0)
  output(0, "Kernel was tainted on startup. Will ignore flags that are already set.\n");
}

canonical_original_code:
void init_taint_checking()
{
 taint_fd = open("/proc/sys/kernel/tainted", 00);
 kernel_taint_initial = get_taint();
 if (kernel_taint_initial != 0)
  output(0, "Kernel was tainted on startup. Will ignore flags that are already set.\n");
}


decompiled_code:
__int64 open_drm_fds()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 1LL;
}

original_code: static int open_drm_fds(void) { return TRUE; }

canonical_original_code: static int open_drm_fds() { return TRUE; }


decompiled_code:
__int64 register_drm_fd_provider()
{
return register_fd_provider(&drm_fd_provider);
}

canonical_decompiled_code:
__int64 func2()
{
return register_fd_provider(&drm_fd_provider);
}

original_code: static void __attribute__((constructor)) register_drm_fd_provider(void) { register_fd_provider(&drm_fd_provider); }

canonical_original_code: static void register_drm_fd_provider() { register_fd_provider(&drm_fd_provider); }


decompiled_code:
__int64 register_mtd_grp()
{
return register_ioctl_group(&mtd_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&mtd_grp);
}

original_code: static void __attribute__((constructor)) register_mtd_grp(void) { register_ioctl_group(&mtd_grp); }

canonical_original_code: static void register_mtd_grp() { register_ioctl_group(&mtd_grp); }


decompiled_code:
__int64 __fastcall userfaultfd_create(unsigned int a1, __int64 a2, __int64 a3, __int64 a4)
{
return syscall(323LL, a1, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, __int64 a2, __int64 a3, __int64 a4)
{
return syscall(323LL, a1, a3, a4);
}

original_code:
static int userfaultfd_create(__attribute((unused)) unsigned int flag)
{
 return syscall(323, flag);
}

canonical_original_code:
static int userfaultfd_create(unsigned int flag)
{
 return syscall(323, flag);
}

variable_types:
flag
unsigned int


decompiled_code:
__int64 register_userfaultfd_provider()
{
return register_fd_provider(&userfaultfd_provider);
}

canonical_decompiled_code:
__int64 func5()
{
return register_fd_provider(&userfaultfd_provider);
}

original_code: static void __attribute__((constructor)) register_userfaultfd_provider(void) { register_fd_provider(&userfaultfd_provider); }

canonical_original_code: static void register_userfaultfd_provider() { register_fd_provider(&userfaultfd_provider); }


decompiled_code:
__int64 __fastcall generate_sockaddr(__int64 *a1, int *a2, int a3)
{
__int64 v4; // rax
__int64 (__fastcall *v5)(__int64 *, int *); // rax
__int64 result; // rax
unsigned int v7; // eax
int v8; // edx

if ( (rnd() & 1) != 0 )
{
result = *a1;
if ( !*a1 )
result = _zmalloc(110LL, "generate_sockaddr");
*(_WORD *)result = 0;
*a1 = result;
*a2 = 110;
}
else
{
if ( do_specific_domain == 1 )
a3 = specific_domain;
if ( a3 == -1 )
a3 = (int)rnd() % 45;
v4 = *((_QWORD *)&net_protocols + a3);
if ( v4 && (v5 = *(__int64 (__fastcall **)(__int64 *, int *))(v4 + 40)) != 0LL )
{
result = v5(a1, a2);
}
else
{
*a1 = _zmalloc(page_size, "generate_sockaddr");
v7 = rnd();
v8 = v7 % page_size;
result = v7 / page_size;
*a2 = v8;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, int *a2, int a3)
{
__int64 v4; // rax
__int64 (__fastcall *v5)(__int64 *, int *); // rax
__int64 result; // rax
unsigned int v7; // eax
int v8; // edx

if ( (rnd() & 1) != 0 )
{
result = *a1;
if ( !*a1 )
result = _zmalloc(110LL, "generate_sockaddr");
*(_WORD *)result = 0;
*a1 = result;
*a2 = 110;
}
else
{
if ( do_specific_domain == 1 )
a3 = specific_domain;
if ( a3 == -1 )
a3 = (int)rnd() % 45;
v4 = *((_QWORD *)&net_protocols + a3);
if ( v4 && (v5 = *(__int64 (__fastcall **)(__int64 *, int *))(v4 + 40)) != 0LL )
{
result = v5(a1, a2);
}
else
{
*a1 = _zmalloc(page_size, "generate_sockaddr");
v7 = rnd();
v8 = v7 % page_size;
result = v7 / page_size;
*a2 = v8;
}
}
return result;
}

original_code:
void generate_sockaddr(struct sockaddr **addr, socklen_t *addrlen, int pf)
{
 const struct netproto *proto;
 if ((rnd() & 1)) {
  struct sockaddr_un *un;
  un = (struct sockaddr_un *) *addr;
  if (un == ((void *)0))
   un = __zmalloc(sizeof(struct sockaddr_un), __func__);
  un->sun_family = 0;
  *addr = (struct sockaddr *) un;
  *addrlen = sizeof(struct sockaddr_un);
  return;
 }
 if (do_specific_domain == TRUE)
  pf = specific_domain;
 if (pf == -1)
  pf = rnd() % 45;
 proto = net_protocols[pf].proto;
 if (proto != ((void *)0)) {
  if (proto->gen_sockaddr != ((void *)0)) {
   proto->gen_sockaddr(addr, addrlen);
   return;
  }
 }
 *addr = (struct sockaddr *) __zmalloc(page_size, __func__);
 *addrlen = rnd() % page_size;
}

canonical_original_code:
void generate_sockaddr(struct sockaddr **addr, unsigned int *addrlen, int pf)
{
 struct netproto *proto;
 if ((rnd() & 1)) {
  struct sockaddr_un *un;
  un = (struct sockaddr_un *) *addr;
  if (un == ((void *)0))
   un = __zmalloc(sizeof(struct sockaddr_un), __func__);
  un->sun_family = 0;
  *addr = (struct sockaddr *) un;
  *addrlen = sizeof(struct sockaddr_un);
  return;
 }
 if (do_specific_domain == TRUE)
  pf = specific_domain;
 if (pf == -1)
  pf = rnd() % 45;
 proto = net_protocols[pf].proto;
 if (proto != ((void *)0)) {
  if (proto->gen_sockaddr != ((void *)0)) {
   proto->gen_sockaddr(addr, addrlen);
   return;
  }
 }
 *addr = (struct sockaddr *) __zmalloc(page_size, __func__);
 *addrlen = rnd() % page_size;
}

variable_types:
addrlen
unsigned int *

variable_types: pf int

variable_types: struct netproto { char *name; struct socket_triplet { unsigned int family; unsigned int type; unsigned int protocol; } *valid_triplets; struct socket_triplet *valid_privileged_triplets; void (*socket_setup)(int fd); void (*setsockopt)(struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; } *so, struct socket_triplet *triplet); void (*gen_sockaddr)(struct sockaddr { unsigned short sa_family; char sa_data[14]; } **addr, unsigned int *addrlen); void (*gen_packet)(struct socket_triplet *st, void **ptr, unsigned long *len); unsigned int nr_triplets; unsigned int nr_privileged_triplets; } *

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

user_defined_types: struct netproto { char *name; struct socket_triplet *valid_triplets; struct socket_triplet *valid_privileged_triplets; void (*socket_setup)(int fd); void (*setsockopt)(struct sockopt *so, struct socket_triplet *triplet); void (*gen_sockaddr)(struct sockaddr **addr, unsigned int *addrlen); void (*gen_packet)(struct socket_triplet *st, void **ptr, unsigned long *len); unsigned int nr_triplets; unsigned int nr_privileged_triplets; }


decompiled_code:
unsigned __int64 __fastcall packet_setsockopt(__int64 a1)
{
__int64 v1; // rbp
unsigned __int64 v2; // rcx
unsigned __int64 result; // rax
__int64 v4; // rsi

*(_DWORD *)a1 = 263;
v1 = *(_QWORD *)(a1 + 16);
v2 = (int)rnd();
result = 18 * (v2 / 0x12);
v4 = (unsigned int)packet_opts[v2 % 0x12];
*(_QWORD *)(a1 + 8) = v4;
if ( (_DWORD)v4 == 5 )
{
result = setup_tpacket_req3(v1);
*(_QWORD *)(a1 + 24) = 28LL;
}
else if ( (_DWORD)v4 == 10 )
{
result = (unsigned __int64)set_tpacket_version3(a1);
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rbp
unsigned __int64 v2; // rcx
unsigned __int64 result; // rax
__int64 v4; // rsi

*(_DWORD *)a1 = 263;
v1 = *(_QWORD *)(a1 + 16);
v2 = (int)rnd();
result = 18 * (v2 / 0x12);
v4 = (unsigned int)packet_opts[v2 % 0x12];
*(_QWORD *)(a1 + 8) = v4;
if ( (_DWORD)v4 == 5 )
{
result = func1(v1);
*(_QWORD *)(a1 + 24) = 28LL;
}
else if ( (_DWORD)v4 == 10 )
{
result = (unsigned __int64)set_tpacket_version3(a1);
}
return result;
}

original_code:
static void packet_setsockopt(struct sockopt *so, __attribute((unused)) struct socket_triplet *triplet)
{
 struct tpacket_req3 *req = (struct tpacket_req3 *) so->optval;
 so->level = 263;
 so->optname = packet_opts[rnd() % (sizeof(packet_opts) / sizeof((packet_opts)[0]))];
 switch (so->optname) {
 case 10:
  set_tpacket_version3(so);
  break;
 case 5:
  setup_tpacket_req3(req);
  so->optlen = sizeof(struct tpacket_req3);
  break;
 default:
  break;
 }
}

canonical_original_code:
static void packet_setsockopt(struct sockopt *so, struct socket_triplet *triplet)
{
 struct tpacket_req3 *req = (struct tpacket_req3 *) so->optval;
 so->level = 263;
 so->optname = packet_opts[rnd() % (sizeof(packet_opts) / sizeof((packet_opts)[0]))];
 switch (so->optname) {
 case 10:
  set_tpacket_version3(so);
  break;
 case 5:
  setup_tpacket_req3(req);
  so->optlen = sizeof(struct tpacket_req3);
  break;
 default:
  break;
 }
}

variable_types: struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; } *

variable_types: struct socket_triplet { unsigned int family; unsigned int type; unsigned int protocol; } *

variable_types: struct tpacket_req3 { unsigned int tp_block_size; unsigned int tp_block_nr; unsigned int tp_frame_size; unsigned int tp_frame_nr; unsigned int tp_retire_blk_tov; unsigned int tp_sizeof_priv; unsigned int tp_feature_req_word; } *


decompiled_code:
int __fastcall packet_socket_setup(int a1)
{
int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optval[0] = 2;
return setsockopt(a1, 263, 10, optval, 4u);
}

canonical_decompiled_code:
int __fastcall func3(int a1)
{
int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optval[0] = 2;
return setsockopt(a1, 263, 10, optval, 4u);
}

original_code:
static void packet_socket_setup(int fd)
{
 int v3 = TPACKET_V3;
 (void) setsockopt(fd, 263, 10, &v3, sizeof(v3));
}

variable_types: fd int


original_code:
void rand_proto_type(struct socket_triplet *st)
{
 int types[] = { SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET, SOCK_DCCP, SOCK_PACKET };
 st->protocol = types[rnd() % (sizeof(types) / sizeof((types)[0]))];
}

variable_types:
types
int []

user_defined_types: struct socket_triplet { unsigned int family; unsigned int type; unsigned int protocol; }


decompiled_code:
__int64 __fastcall sanitise_socket_triplet(unsigned int *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // rbp
__int64 v5; // rdx
__int64 v6; // rax
unsigned int v7; // edx

v4 = *((_QWORD *)&net_protocols + *a1);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = orig_uid;
if ( !orig_uid && (rnd(a1, a2, orig_uid, a4) & 1) == 0 )
{
a2 = v4;
if ( (unsigned int)do_priv((__int64)a1, v4) )
return 0xFFFFFFFFLL;
}
if ( !*(_DWORD *)(v4 + 56) )
return 0xFFFFFFFFLL;
v6 = *(_QWORD *)(v4 + 8) + 12LL * (int)((unsigned int)rnd(a1, a2, v5, a4) % *(_DWORD *)(v4 + 56));
v7 = *(_DWORD *)(v6 + 8);
LODWORD(v6) = *(_DWORD *)(v6 + 4);
a1[2] = v7;
a1[1] = v6;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // rbp
__int64 v5; // rdx
__int64 v6; // rax
unsigned int v7; // edx

v4 = *((_QWORD *)&net_protocols + *a1);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = orig_uid;
if ( !orig_uid && (rnd(a1, a2, orig_uid, a4) & 1) == 0 )
{
a2 = v4;
if ( (unsigned int)func1((__int64)a1, v4) )
return 0xFFFFFFFFLL;
}
if ( !*(_DWORD *)(v4 + 56) )
return 0xFFFFFFFFLL;
v6 = *(_QWORD *)(v4 + 8) + 12LL * (int)((unsigned int)rnd(a1, a2, v5, a4) % *(_DWORD *)(v4 + 56));
v7 = *(_DWORD *)(v6 + 8);
LODWORD(v6) = *(_DWORD *)(v6 + 4);
a1[2] = v7;
a1[1] = v6;
return 0LL;
}

original_code:
int sanitise_socket_triplet(struct socket_triplet *st)
{
 const struct netproto *proto;
 proto = net_protocols[st->family].proto;
 if (proto != ((void *)0)) {
  if (orig_uid != 0)
   goto do_unpriv;
  if ((rnd() & 1)) {
do_unpriv:
   if (proto->nr_triplets != 0) {
    int r;
    r = rnd() % proto->nr_triplets;
    st->protocol = proto->valid_triplets[r].protocol;
    st->type = proto->valid_triplets[r].type;
    return 0;
   }
  } else {
   if (do_priv(st, proto) == FALSE)
    goto do_unpriv;
  }
 }
 return -1;
}

canonical_original_code:
int sanitise_socket_triplet(struct socket_triplet *st)
{
 struct netproto *proto;
 proto = net_protocols[st->family].proto;
 if (proto != ((void *)0)) {
  if (orig_uid != 0)
   goto do_unpriv;
  if ((rnd() & 1)) {
do_unpriv:
   if (proto->nr_triplets != 0) {
    int r;
    r = rnd() % proto->nr_triplets;
    st->protocol = proto->valid_triplets[r].protocol;
    st->type = proto->valid_triplets[r].type;
    return 0;
   }
  } else {
   if (do_priv(st, proto) == FALSE)
    goto do_unpriv;
  }
 }
 return -1;
}

variable_types: r int

user_defined_types: struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; }

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


decompiled_code:
__int64 __fastcall gen_socket_args(unsigned int *a1, __int64 a2, __int64 a3, __int64 a4)
{
unsigned int *v4; // rbx
__int64 v5; // rdx
__int64 v6; // rcx
unsigned int *v7; // rdi
__int64 v8; // rdx
__int64 v9; // rcx
__int64 result; // rax
__int64 v11; // rdx
__int64 v12; // rcx
int v13; // eax
unsigned int v14; // eax
unsigned int v15; // eax

v4 = a1;
if ( do_specific_domain == 1 )
{
*a1 = specific_domain;
}
else
{
v13 = rnd(a1, a2, a3, a4);
a3 = (unsigned int)(45 * (v13 / 45));
v14 = v13 % 45;
*a1 = v14;
a1 = (unsigned int *)v14;
if ( v14 > 0x2C )
{
_BUG("st->family >= (sizeof(no_domains) / sizeof((no_domains)[0]))", "syscalls/socket.c", "gen_socket_args", 82LL);
while ( 1 )
;
}
if ( *((_DWORD *)&no_domains + v14) )
{
v15 = find_next_enabled_domain(v14);
*v4 = v15;
if ( v15 == -1 )
{
outputerr("No available socket family found\n");
exit(1);
}
}
}
if ( __ROR4__(-1030792151 * rnd(a1, a2, a3, a4) + 85899344, 2) > 0x28F5C28u )
{
v7 = v4;
if ( (int)sanitise_socket_triplet(v4, a2, v5, v6) >= 0 )
{
if ( (rnd(v4, a2, v5, v6) & 3) != 0 )
goto LABEL_7;
goto LABEL_6;
}
}
v7 = v4;
rand_proto_type((__int64)v4, a2, v5, v6);
if ( (rnd(v4, a2, v11, v12) & 3) == 0 )
LABEL_6:
v4[1] |= 0x80000u;
LABEL_7:
result = rnd(v7, a2, v8, v9);
if ( (result & 3) == 0 )
v4[1] |= 0x800u;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int *a1, __int64 a2, __int64 a3, __int64 a4)
{
unsigned int *v4; // rbx
__int64 v5; // rdx
__int64 v6; // rcx
unsigned int *v7; // rdi
__int64 v8; // rdx
__int64 v9; // rcx
__int64 result; // rax
__int64 v11; // rdx
__int64 v12; // rcx
int v13; // eax
unsigned int v14; // eax
unsigned int v15; // eax

v4 = a1;
if ( do_specific_domain == 1 )
{
*a1 = specific_domain;
}
else
{
v13 = rnd(a1, a2, a3, a4);
a3 = (unsigned int)(45 * (v13 / 45));
v14 = v13 % 45;
*a1 = v14;
a1 = (unsigned int *)v14;
if ( v14 > 0x2C )
{
_BUG("st->family >= (sizeof(no_domains) / sizeof((no_domains)[0]))", "syscalls/socket.c", "gen_socket_args", 82LL);
while ( 1 )
;
}
if ( *((_DWORD *)&no_domains + v14) )
{
v15 = find_next_enabled_domain(v14);
*v4 = v15;
if ( v15 == -1 )
{
outputerr("No available socket family found\n");
exit(1);
}
}
}
if ( __ROR4__(-1030792151 * rnd(a1, a2, a3, a4) + 85899344, 2) > 0x28F5C28u )
{
v7 = v4;
if ( (int)func3(v4, a2, v5, v6) >= 0 )
{
if ( (rnd(v4, a2, v5, v6) & 3) != 0 )
goto LABEL_7;
goto LABEL_6;
}
}
v7 = v4;
func2((__int64)v4, a2, v5, v6);
if ( (rnd(v4, a2, v11, v12) & 3) == 0 )
LABEL_6:
v4[1] |= 0x80000u;
LABEL_7:
result = rnd(v7, a2, v8, v9);
if ( (result & 3) == 0 )
v4[1] |= 0x800u;
return result;
}

original_code:
void gen_socket_args(struct socket_triplet *st)
{
 if (do_specific_domain == TRUE)
  st->family = specific_domain;
 else {
  st->family = rnd() % 45;
  do { if ((st->family >= (sizeof(no_domains) / sizeof((no_domains)[0])))) { __BUG("st->family >= (sizeof(no_domains) / sizeof((no_domains)[0]))", "syscalls/socket.c", __func__, 82); do { } while (1); }; } while (0);
  if (no_domains[st->family]) {
   st->family = find_next_enabled_domain(st->family);
   if (st->family == -1u) {
    outputerr("No available socket family found\n");
    exit(1);
   }
  }
 }
 if (((rnd() % 100) == 0)) {
  rand_proto_type(st);
  goto done;
 }
 if (sanitise_socket_triplet(st) < 0)
  rand_proto_type(st);
done:
 if (((rnd() % 4) == 0))
  st->type |= SOCK_CLOEXEC;
 if (((rnd() % 4) == 0))
  st->type |= SOCK_NONBLOCK;
}


decompiled_code:
__int64 register_binder_grp()
{
return register_ioctl_group(&binder_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&binder_grp);
}

original_code: static void __attribute__((constructor)) register_binder_grp(void) { register_ioctl_group(&binder_grp); }

canonical_original_code: static void register_binder_grp() { register_ioctl_group(&binder_grp); }


decompiled_code:
void __fastcall ipx_setsockopt(__int64 a1)
{
*(_DWORD *)a1 = 256;
*(_QWORD *)(a1 + 8) = 1LL;
}

original_code:
static void ipx_setsockopt(struct sockopt *so, __attribute((unused)) struct socket_triplet *triplet)
{
 so->level = 256;
 so->optname = 1;
}

canonical_original_code:
static void ipx_setsockopt(struct sockopt *so, struct socket_triplet *triplet)
{
 so->level = 256;
 so->optname = 1;
}


decompiled_code:
__int64 parse_devices()
{
parse_proc_devices();
parse_proc_misc();
return output(2LL, "Parsed %zu char devices, %zu block devices, %zu misc devices.\n", chrdevs, bldevs, miscdevs);
}

canonical_decompiled_code:
__int64 func2()
{
func0();
func1();
return output(2LL, "Parsed %zu char devices, %zu block devices, %zu misc devices.\n", chrdevs, bldevs, miscdevs);
}

original_code:
void parse_devices(void)
{
 parse_proc_devices();
 parse_proc_misc();
 output(2, "Parsed %zu char devices, %zu block devices, %zu misc devices.\n",
   chrdevs, bldevs, miscdevs);
}

canonical_original_code:
void parse_devices()
{
 parse_proc_devices();
 parse_proc_misc();
 output(2, "Parsed %zu char devices, %zu block devices, %zu misc devices.\n",
   chrdevs, bldevs, miscdevs);
}


decompiled_code:
const char *__fastcall map_dev(unsigned __int64 a1, __int16 a2)
{
int v2; // esi
unsigned __int64 v3; // r8
const char *result; // rax
_QWORD *v5; // rax
__int64 v6; // rdx
__int64 v7; // r11
char *v8; // r9
char *v9; // rax
__int64 v10; // rdx

v2 = a2 & 0xF000;
v3 = a1 >> 8;
if ( v2 == 0x2000 )
{
if ( chrdevs )
{
v7 = 0LL;
v8 = (char *)char_devs;
while ( 1 )
{
if ( *(_DWORD *)v8 == (_DWORD)v3 )
{
result = (const char *)*((_QWORD *)v8 + 1);
if ( strcmp(result, "misc") )
return result;
if ( miscdevs )
break;
}
LABEL_11:
++v7;
v8 += 16;
if ( chrdevs == v7 )
goto LABEL_21;
}
v9 = (char *)misc_devs;
v10 = 0LL;
while ( *((_DWORD *)v9 + 1) != (unsigned __int8)a1 )
{
++v10;
v9 += 16;
if ( v10 == miscdevs )
goto LABEL_11;
}
result = (const char *)*((_QWORD *)v9 + 1);
}
else
{
LABEL_21:
result = 0LL;
}
}
else
{
result = 0LL;
if ( v2 == 24576 && bldevs )
{
v5 = block_devs;
v6 = 0LL;
do
{
if ( *(_DWORD *)v5 == (_DWORD)v3 )
return (const char *)v5[1];
++v6;
v5 += 2;
}
while ( v6 != bldevs );
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func3(unsigned __int64 a1, __int16 a2)
{
int v2; // esi
unsigned __int64 v3; // r8
const char *result; // rax
_QWORD *v5; // rax
__int64 v6; // rdx
__int64 v7; // r11
char *v8; // r9
char *v9; // rax
__int64 v10; // rdx

v2 = a2 & 0xF000;
v3 = a1 >> 8;
if ( v2 == 0x2000 )
{
if ( chrdevs )
{
v7 = 0LL;
v8 = (char *)char_devs;
while ( 1 )
{
if ( *(_DWORD *)v8 == (_DWORD)v3 )
{
result = (const char *)*((_QWORD *)v8 + 1);
if ( strcmp(result, "misc") )
return result;
if ( miscdevs )
break;
}
LABEL_11:
++v7;
v8 += 16;
if ( chrdevs == v7 )
goto LABEL_21;
}
v9 = (char *)misc_devs;
v10 = 0LL;
while ( *((_DWORD *)v9 + 1) != (unsigned __int8)a1 )
{
++v10;
v9 += 16;
if ( v10 == miscdevs )
goto LABEL_11;
}
result = (const char *)*((_QWORD *)v9 + 1);
}
else
{
LABEL_21:
result = 0LL;
}
}
else
{
result = 0LL;
if ( v2 == 24576 && bldevs )
{
v5 = block_devs;
v6 = 0LL;
do
{
if ( *(_DWORD *)v5 == (_DWORD)v3 )
return (const char *)v5[1];
++v6;
v5 += 2;
}
while ( v6 != bldevs );
result = 0LL;
}
}
return result;
}

original_code:
const char *map_dev(dev_t st_rdev, mode_t st_mode)
{
 int major, minor;
 size_t i;
 major = ((st_rdev)>>8);
 minor = ((st_rdev) & 0xff);
 if (((((st_mode)) & 0170000) == (0020000))) {
  for (i = 0; i < chrdevs; ++i) {
   if (char_devs[i].major == major) {
    if (strcmp(char_devs[i].name, "misc") == 0) {
     size_t j;
     for (j = 0; j < miscdevs; ++j)
      if (misc_devs[j].minor == minor)
       return misc_devs[j].name;
    } else
     return char_devs[i].name;
   }
  }
 } else if (((((st_mode)) & 0170000) == (0060000))) {
  for (i = 0; i < bldevs; ++i) {
   if (block_devs[i].major == major)
    return block_devs[i].name;
  }
 }
 return ((void *)0);
}

canonical_original_code:
char *map_dev(unsigned long st_rdev, unsigned int st_mode)
{
 int major; int minor;
 unsigned long i;
 major = ((st_rdev)>>8);
 minor = ((st_rdev) & 0xff);
 if (((((st_mode)) & 0170000) == (0020000))) {
  for (i = 0; i < chrdevs; ++i) {
   if (char_devs[i].major == major) {
    if (strcmp(char_devs[i].name, "misc") == 0) {
     unsigned long j;
     for (j = 0; j < miscdevs; ++j)
      if (misc_devs[j].minor == minor)
       return misc_devs[j].name;
    } else
     return char_devs[i].name;
   }
  }
 } else if (((((st_mode)) & 0170000) == (0060000))) {
  for (i = 0; i < bldevs; ++i) {
   if (block_devs[i].major == major)
    return block_devs[i].name;
  }
 }
 return ((void *)0);
}

variable_types: major int

variable_types: minor int

variable_types:
i
unsigned long

variable_types:
j
unsigned long

return_type: char *


decompiled_code:
void __fastcall raw_setsockopt(__int64 a1)
{
*(_QWORD *)(a1 + 8) = 1LL;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
*(_QWORD *)(a1 + 8) = 1LL;
}

original_code:
void raw_setsockopt(struct sockopt *so, __attribute((unused)) struct socket_triplet *triplet)
{
 so->optname = 1;
}

canonical_original_code:
void raw_setsockopt(struct sockopt *so, struct socket_triplet *triplet)
{
 so->optname = 1;
}


decompiled_code:
char parse_logging()
{
bool v0; // zf
int v1; // eax
struct stat v3; // [rsp-18h] [rbp-98h] BYREF

v0 = strcmp(optarg, "off") == 0;
LOBYTE(v1) = !v0;
if ( v0 )
{
logging = 0;
}
else
{
logging_args = (__int64)strdup(optarg);
v1 = stat((const char *)logging_args, &v3);
if ( !v1 )
{
v1 = v3.st_mode & 0xF000;
if ( v1 == 0x4000 )
logging = 1;
}
}
return v1;
}

canonical_decompiled_code:
char func0()
{
bool v0; // zf
int v1; // eax
struct stat v3; // [rsp-18h] [rbp-98h] BYREF

v0 = strcmp(optarg, "off") == 0;
LOBYTE(v1) = !v0;
if ( v0 )
{
logging = 0;
}
else
{
logging_args = (__int64)strdup(optarg);
v1 = stat((const char *)logging_args, &v3);
if ( !v1 )
{
v1 = v3.st_mode & 0xF000;
if ( v1 == 0x4000 )
logging = 1;
}
}
return v1;
}

original_code:
static void parse_logging(void)
{
 struct stat sb;
 int ret;
 if (!strcmp(optarg, "off")) {
  logging = LOGGING_DISABLED;
  return;
 }
 logging_args = strdup(optarg);
 ret = stat(logging_args, &sb);
 if (ret == 0) {
  if (((((sb.st_mode)) & 0170000) == (0040000))) {
   logging = LOGGING_FILES;
   return;
  }
 }
}

canonical_original_code:
static void parse_logging()
{
 struct stat sb;
 int ret;
 if (!strcmp(optarg, "off")) {
  logging = LOGGING_DISABLED;
  return;
 }
 logging_args = strdup(optarg);
 ret = stat(logging_args, &sb);
 if (ret == 0) {
  if (((((sb.st_mode)) & 0170000) == (0040000))) {
   logging = LOGGING_FILES;
   return;
  }
 }
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: ret int

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
__int64 enable_disable_fd_usage()
{
return outputerr(" --enable-fds/--disable-fds= {sockets,pipes,perf,epoll,eventfd,pseudo,timerfd,testfile,memfd,drm}\n");
}

canonical_decompiled_code:
__int64 func1()
{
return outputerr(" --enable-fds/--disable-fds= {sockets,pipes,perf,epoll,eventfd,pseudo,timerfd,testfile,memfd,drm}\n");
}

original_code:
void enable_disable_fd_usage(void)
{
 outputerr(" --enable-fds/--disable-fds= {sockets,pipes,perf,epoll,eventfd,pseudo,timerfd,testfile,memfd,drm}\n");
}

canonical_original_code:
void enable_disable_fd_usage()
{
 outputerr(" --enable-fds/--disable-fds= {sockets,pipes,perf,epoll,eventfd,pseudo,timerfd,testfile,memfd,drm}\n");
}


usage

decompiled_code:
void __noreturn usage()
{
__int64 v0; // rsi

v0 = progname;
outputerr(&unk_8D0);
outputerr(" --arch, -a: selects syscalls for the specified architecture (32 or 64). Both by default.\n");
outputerr(" --bdev, -b <node>: Add /dev node to list of block devices to use for destructive tests..\n");
outputerr(" --children,-C: specify number of child processes\n");
outputerr(" --debug,-D: enable debug\n");
outputerr(" --dropprivs, -X: if run as root, switch to nobody [EXPERIMENTAL]\n");
outputerr(" --exclude,-x: don't call a specific syscall\n");
enable_disable_fd_usage(" --exclude,-x: don't call a specific syscall\n", v0);
outputerr(" --ftrace-dump-file: specify file that ftrace buffer gets dumped to if kernel becomes tainted.\n");
outputerr(" --group,-g = {vfs,vm}: only run syscalls from a certain group.\n");
outputerr(" --ioctls,-I: list all ioctls.\n");
outputerr(
" --kernel_taint, -T: controls which kernel taint flags should be considered, for more details refer to README file. \n");
outputerr(" --list,-L: list all syscalls known on this architecture.\n");
outputerr(
" --logging,-l [off, <dir>, <hostname>] : disable logging to files, log to a directory, or log over udp to a remote t"
"rinity server.\n");
outputerr(" --domain,-P: specify specific network domain for sockets.\n");
outputerr(" --no_domain,-E: specify network domains to be excluded from testing.\n");
outputerr(" --quiet,-q: less output.\n");
outputerr(" --random,-r#: pick N syscalls at random and just fuzz those\n");
outputerr(" --stats: show errno distribution per syscall before exiting\n");
outputerr(" --syslog,-S: log important info to syslog. (useful if syslog is remote)\n");
outputerr(" --verbose,-v: increase output verbosity.\n");
outputerr(" --victims,-V: path to victim files.\n");
outputerr("\n");
outputerr(
" -c#,@: target specific syscall (takes syscall name as parameter and optionally 32 or 64 as bit-width. Default:both).\n");
outputerr(" -N#: do # syscalls then exit.\n");
outputerr(" -s#: use # as random seed.\n");
exit(0);
}

canonical_decompiled_code:
void __noreturn func2()
{
__int64 v0; // rsi

v0 = progname;
outputerr(&unk_8D0);
outputerr(" --arch, -a: selects syscalls for the specified architecture (32 or 64). Both by default.\n");
outputerr(" --bdev, -b <node>: Add /dev node to list of block devices to use for destructive tests..\n");
outputerr(" --children,-C: specify number of child processes\n");
outputerr(" --debug,-D: enable debug\n");
outputerr(" --dropprivs, -X: if run as root, switch to nobody [EXPERIMENTAL]\n");
outputerr(" --exclude,-x: don't call a specific syscall\n");
func1(" --exclude,-x: don't call a specific syscall\n", v0);
outputerr(" --ftrace-dump-file: specify file that ftrace buffer gets dumped to if kernel becomes tainted.\n");
outputerr(" --group,-g = {vfs,vm}: only run syscalls from a certain group.\n");
outputerr(" --ioctls,-I: list all ioctls.\n");
outputerr(
" --kernel_taint, -T: controls which kernel taint flags should be considered, for more details refer to README file. \n");
outputerr(" --list,-L: list all syscalls known on this architecture.\n");
outputerr(
" --logging,-l [off, <dir>, <hostname>] : disable logging to files, log to a directory, or log over udp to a remote t"
"rinity server.\n");
outputerr(" --domain,-P: specify specific network domain for sockets.\n");
outputerr(" --no_domain,-E: specify network domains to be excluded from testing.\n");
outputerr(" --quiet,-q: less output.\n");
outputerr(" --random,-r#: pick N syscalls at random and just fuzz those\n");
outputerr(" --stats: show errno distribution per syscall before exiting\n");
outputerr(" --syslog,-S: log important info to syslog. (useful if syslog is remote)\n");
outputerr(" --verbose,-v: increase output verbosity.\n");
outputerr(" --victims,-V: path to victim files.\n");
outputerr("\n");
outputerr(
" -c#,@: target specific syscall (takes syscall name as parameter and optionally 32 or 64 as bit-width. Default:both).\n");
outputerr(" -N#: do # syscalls then exit.\n");
outputerr(" -s#: use # as random seed.\n");
exit(0);
}

original_code:
static void usage(void)
{
 outputerr("%s\n", progname);
 outputerr(" --arch, -a: selects syscalls for the specified architecture (32 or 64). Both by default.\n");
 outputerr(" --bdev, -b <node>:  Add /dev node to list of block devices to use for destructive tests..\n");
 outputerr(" --children,-C: specify number of child processes\n");
 outputerr(" --debug,-D: enable debug\n");
 outputerr(" --dropprivs, -X: if run as root, switch to nobody [EXPERIMENTAL]\n");
 outputerr(" --exclude,-x: don't call a specific syscall\n");
 enable_disable_fd_usage();
 outputerr(" --ftrace-dump-file: specify file that ftrace buffer gets dumped to if kernel becomes tainted.\n");
 outputerr(" --group,-g = {vfs,vm}: only run syscalls from a certain group.\n");
 outputerr(" --ioctls,-I: list all ioctls.\n");
 outputerr(" --kernel_taint, -T: controls which kernel taint flags should be considered, for more details refer to README file. \n");
 outputerr(" --list,-L: list all syscalls known on this architecture.\n");
 outputerr(" --logging,-l [off, <dir>, <hostname>] : disable logging to files, log to a directory, or log over udp to a remote trinity server.\n");
 outputerr(" --domain,-P: specify specific network domain for sockets.\n");
 outputerr(" --no_domain,-E: specify network domains to be excluded from testing.\n");
 outputerr(" --quiet,-q: less output.\n");
 outputerr(" --random,-r#: pick N syscalls at random and just fuzz those\n");
 outputerr(" --stats: show errno distribution per syscall before exiting\n");
 outputerr(" --syslog,-S: log important info to syslog. (useful if syslog is remote)\n");
 outputerr(" --verbose,-v: increase output verbosity.\n");
 outputerr(" --victims,-V: path to victim files.\n");
 outputerr("\n");
 outputerr(" -c#,@: target specific syscall (takes syscall name as parameter and optionally 32 or 64 as bit-width. Default:both).\n");
 outputerr(" -N#: do # syscalls then exit.\n");
 outputerr(" -s#: use # as random seed.\n");
 exit(0);
}

canonical_original_code:
static void usage()
{
 outputerr("%s\n", progname);
 outputerr(" --arch, -a: selects syscalls for the specified architecture (32 or 64). Both by default.\n");
 outputerr(" --bdev, -b <node>:  Add /dev node to list of block devices to use for destructive tests..\n");
 outputerr(" --children,-C: specify number of child processes\n");
 outputerr(" --debug,-D: enable debug\n");
 outputerr(" --dropprivs, -X: if run as root, switch to nobody [EXPERIMENTAL]\n");
 outputerr(" --exclude,-x: don't call a specific syscall\n");
 enable_disable_fd_usage();
 outputerr(" --ftrace-dump-file: specify file that ftrace buffer gets dumped to if kernel becomes tainted.\n");
 outputerr(" --group,-g = {vfs,vm}: only run syscalls from a certain group.\n");
 outputerr(" --ioctls,-I: list all ioctls.\n");
 outputerr(" --kernel_taint, -T: controls which kernel taint flags should be considered, for more details refer to README file. \n");
 outputerr(" --list,-L: list all syscalls known on this architecture.\n");
 outputerr(" --logging,-l [off, <dir>, <hostname>] : disable logging to files, log to a directory, or log over udp to a remote trinity server.\n");
 outputerr(" --domain,-P: specify specific network domain for sockets.\n");
 outputerr(" --no_domain,-E: specify network domains to be excluded from testing.\n");
 outputerr(" --quiet,-q: less output.\n");
 outputerr(" --random,-r#: pick N syscalls at random and just fuzz those\n");
 outputerr(" --stats: show errno distribution per syscall before exiting\n");
 outputerr(" --syslog,-S: log important info to syslog. (useful if syslog is remote)\n");
 outputerr(" --verbose,-v: increase output verbosity.\n");
 outputerr(" --victims,-V: path to victim files.\n");
 outputerr("\n");
 outputerr(" -c#,@: target specific syscall (takes syscall name as parameter and optionally 32 or 64 as bit-width. Default:both).\n");
 outputerr(" -N#: do # syscalls then exit.\n");
 outputerr(" -s#: use # as random seed.\n");
 exit(0);
}


decompiled_code:
__int64 __fastcall parse_args(int argc, char **argv)
{
unsigned int v2; // eax
__int64 result; // rax
int v4; // eax
int v5; // eax
const char *v6; // r12
char v7; // al
int longind[7]; // [rsp+Ch] [rbp-1Ch] BYREF

longind[0] = 0;
while ( 2 )
{
v2 = getopt_long(argc, argv, "a:b:c:C:dDE:g:hIl:LN:P:qr:s:ST:V:vx:X", &longopts, longind);
if ( v2 != -1 )
{
switch ( v2 )
{
case 0u:
v6 = (const char *)*((_QWORD *)&longopts.name + 4 * longind[0]);
if ( !strcmp("clowntown", v6) )
clowntown = 1;
if ( !strcmp("disable-fds", v6) )
{
process_fds_param(optarg, 0LL);
v6 = (const char *)*((_QWORD *)&longopts.name + 4 * longind[0]);
}
if ( !strcmp("dry-run", v6) )
dry_run = 1;
if ( !strcmp("enable-fds", v6) )
{
process_fds_param(optarg, 1LL);
v6 = (const char *)*((_QWORD *)&longopts.name + 4 * longind[0]);
}
if ( !strcmp("ftrace-dump-file", v6) )
ftracedumpname = strdup(optarg);
if ( !strcmp("show-unannotated", v6) )
show_unannotated = 1;
if ( !strcmp("stats", v6) )
show_stats = 1;
continue;
case 0x43u:
user_specified_children = strtoll(optarg, 0LL, 10);
max_children = user_specified_children;
if ( !user_specified_children )
{
outputerr("zero children ? WAT?\n");
exit(1);
}
continue;
case 0x44u:
set_debug = 1;
continue;
case 0x45u:
parse_exclude_domains(optarg);
continue;
case 0x49u:
show_ioctl_list = 1;
continue;
case 0x4Cu:
show_syscall_list = 1;
continue;
case 0x4Eu:
syscalls_todo = strtoll(optarg, 0LL, 10);
continue;
case 0x50u:
do_specific_domain = 1;
specific_domain = strtol(optarg, 0LL, 10);
specific_domain_optarg = (__int64)optarg;
continue;
case 0x53u:
do_syslog = 1;
continue;
case 0x54u:
process_taint_arg(optarg);
if ( kernel_taint_mask != -1 )
outputstd(
"Custom kernel taint mask has been specified: 0x%08x (%d).\n",
(unsigned int)kernel_taint_mask,
(unsigned int)kernel_taint_mask);
continue;
case 0x56u:
if ( victim_path )
{
outputstd("Sorry, only one victim path right now.\n");
exit(1);
}
victim_path = (__int64)strdup(optarg);
continue;
case 0x58u:
if ( getuid() )
outputstd("Already running unprivileged, can't drop privs\n");
else
dropprivs = 1;
continue;
case 0x61u:
do_32_arch = 0;
do_64_arch = 0;
v5 = (unsigned __int8)*optarg;
if ( v5 == 54 && optarg[1] == 52 && !optarg[2] )
{
do_64_arch = 1;
}
else
{
if ( v5 != 51 || optarg[1] != 50 || optarg[2] )
{
outputstd("can't parse %s\n", optarg);
LABEL_25:
exit(1);
}
do_32_arch = 1;
}
continue;
case 0x62u:
init_bdev_list();
process_bdev_param(optarg);
dump_bdev_list();
outputstd("--bdev doesn't do anything useful yet.\n");
exit(0);
case 0x63u:
do_specific_syscall = 1;
toggle_syscall(optarg, 1LL);
continue;
case 0x64u:
dangerous = 1;
continue;
case 0x67u:
if ( *optarg == 118 && optarg[1] == 109 && !optarg[2] )
desired_group = 1;
if ( !strcmp(optarg, "vfs") )
desired_group = 2;
continue;
case 0x68u:
usage();
return result;
case 0x6Cu:
parse_logging();
continue;
case 0x71u:
++quiet_level;
continue;
case 0x72u:
if ( do_exclude_syscall == 1 )
{
outputerr("-r needs to be before any -x options.\n");
exit(1);
}
random_selection = 1;
random_selection_num = strtol(optarg, 0LL, 10);
continue;
case 0x73u:
v4 = strtol(optarg, 0LL, 10);
user_set_seed = 1;
seed = v4;
continue;
case 0x76u:
verbose = 1;
continue;
case 0x78u:
do_exclude_syscall = 1;
toggle_syscall(optarg, 0LL);
continue;
default:
if ( v2 == 63 )
goto LABEL_25;
return outputstd("opt:%c\n", v2);
}
}
break;
}
v7 = 3 - quiet_level;
if ( (unsigned __int8)quiet_level >= 4u )
v7 = 0;
quiet_level = v7;
return output(1LL, "Done parsing arguments.\n");
}

canonical_decompiled_code:
__int64 __fastcall func3(int argc, char **argv)
{
unsigned int v2; // eax
__int64 result; // rax
int v4; // eax
int v5; // eax
const char *v6; // r12
char v7; // al
int longind[7]; // [rsp+Ch] [rbp-1Ch] BYREF

longind[0] = 0;
while ( 2 )
{
v2 = getopt_long(argc, argv, "a:b:c:C:dDE:g:hIl:LN:P:qr:s:ST:V:vx:X", &longopts, longind);
if ( v2 != -1 )
{
switch ( v2 )
{
case 0u:
v6 = (const char *)*((_QWORD *)&longopts.name + 4 * longind[0]);
if ( !strcmp("clowntown", v6) )
clowntown = 1;
if ( !strcmp("disable-fds", v6) )
{
process_fds_param(optarg, 0LL);
v6 = (const char *)*((_QWORD *)&longopts.name + 4 * longind[0]);
}
if ( !strcmp("dry-run", v6) )
dry_run = 1;
if ( !strcmp("enable-fds", v6) )
{
process_fds_param(optarg, 1LL);
v6 = (const char *)*((_QWORD *)&longopts.name + 4 * longind[0]);
}
if ( !strcmp("ftrace-dump-file", v6) )
ftracedumpname = strdup(optarg);
if ( !strcmp("show-unannotated", v6) )
show_unannotated = 1;
if ( !strcmp("stats", v6) )
show_stats = 1;
continue;
case 0x43u:
user_specified_children = strtoll(optarg, 0LL, 10);
max_children = user_specified_children;
if ( !user_specified_children )
{
outputerr("zero children ? WAT?\n");
exit(1);
}
continue;
case 0x44u:
set_debug = 1;
continue;
case 0x45u:
parse_exclude_domains(optarg);
continue;
case 0x49u:
show_ioctl_list = 1;
continue;
case 0x4Cu:
show_syscall_list = 1;
continue;
case 0x4Eu:
syscalls_todo = strtoll(optarg, 0LL, 10);
continue;
case 0x50u:
do_specific_domain = 1;
specific_domain = strtol(optarg, 0LL, 10);
specific_domain_optarg = (__int64)optarg;
continue;
case 0x53u:
do_syslog = 1;
continue;
case 0x54u:
process_taint_arg(optarg);
if ( kernel_taint_mask != -1 )
outputstd(
"Custom kernel taint mask has been specified: 0x%08x (%d).\n",
(unsigned int)kernel_taint_mask,
(unsigned int)kernel_taint_mask);
continue;
case 0x56u:
if ( victim_path )
{
outputstd("Sorry, only one victim path right now.\n");
exit(1);
}
victim_path = (__int64)strdup(optarg);
continue;
case 0x58u:
if ( getuid() )
outputstd("Already running unprivileged, can't drop privs\n");
else
dropprivs = 1;
continue;
case 0x61u:
do_32_arch = 0;
do_64_arch = 0;
v5 = (unsigned __int8)*optarg;
if ( v5 == 54 && optarg[1] == 52 && !optarg[2] )
{
do_64_arch = 1;
}
else
{
if ( v5 != 51 || optarg[1] != 50 || optarg[2] )
{
outputstd("can't parse %s\n", optarg);
LABEL_25:
exit(1);
}
do_32_arch = 1;
}
continue;
case 0x62u:
init_bdev_list();
process_bdev_param(optarg);
dump_bdev_list();
outputstd("--bdev doesn't do anything useful yet.\n");
exit(0);
case 0x63u:
do_specific_syscall = 1;
toggle_syscall(optarg, 1LL);
continue;
case 0x64u:
dangerous = 1;
continue;
case 0x67u:
if ( *optarg == 118 && optarg[1] == 109 && !optarg[2] )
desired_group = 1;
if ( !strcmp(optarg, "vfs") )
desired_group = 2;
continue;
case 0x68u:
func2();
return result;
case 0x6Cu:
func0();
continue;
case 0x71u:
++quiet_level;
continue;
case 0x72u:
if ( do_exclude_syscall == 1 )
{
outputerr("-r needs to be before any -x options.\n");
exit(1);
}
random_selection = 1;
random_selection_num = strtol(optarg, 0LL, 10);
continue;
case 0x73u:
v4 = strtol(optarg, 0LL, 10);
user_set_seed = 1;
seed = v4;
continue;
case 0x76u:
verbose = 1;
continue;
case 0x78u:
do_exclude_syscall = 1;
toggle_syscall(optarg, 0LL);
continue;
default:
if ( v2 == 63 )
goto LABEL_25;
return outputstd("opt:%c\n", v2);
}
}
break;
}
v7 = 3 - quiet_level;
if ( (unsigned __int8)quiet_level >= 4u )
v7 = 0;
quiet_level = v7;
return output(1LL, "Done parsing arguments.\n");
}

original_code:
void parse_args(int argc, char *argv[])
{
 int opt;
 int opt_index = 0;
 while ((opt = getopt_long(argc, argv, paramstr, longopts, &opt_index)) != -1) {
  switch (opt) {
  default:
   if (opt == '?')
    exit(1);
   else
    outputstd("opt:%c\n", opt);
   return;
  case 'a':
   do_32_arch = FALSE;
   do_64_arch = FALSE;
   if (strcmp(optarg, "64") == 0) {
    do_32_arch = FALSE;
    do_64_arch = TRUE;
   } else if (strcmp(optarg, "32") == 0) {
    do_32_arch = TRUE;
    do_64_arch = FALSE;
   } else {
    outputstd("can't parse %s\n", optarg);
    exit(1);
   }
   break;
  case 'b':
   init_bdev_list();
   process_bdev_param(optarg);
   dump_bdev_list();
   outputstd("--bdev doesn't do anything useful yet.\n");
   exit(0);
  case 'c':
   do_specific_syscall = TRUE;
   toggle_syscall(optarg, TRUE);
   break;
  case 'C':
   user_specified_children = strtoll(optarg, ((void *)0), 10);
   max_children = user_specified_children;
   if (max_children == 0) {
    outputerr("zero children ? WAT?\n");
    exit(1);
   }
   break;
  case 'd':
   dangerous = TRUE;
   break;
  case 'D':
   set_debug = TRUE;
   break;
  case 'E':
   parse_exclude_domains(optarg);
   break;
  case 'g':
   if (!strcmp(optarg, "vm"))
    desired_group = 1;
   if (!strcmp(optarg, "vfs"))
    desired_group = 2;
   break;
  case 'h':
   usage();
   exit(0);
  case 'I':
   show_ioctl_list = TRUE;
   break;
  case 'l':
   parse_logging();
   break;
  case 'L':
   show_syscall_list = TRUE;
   break;
  case 'N':
   syscalls_todo = strtoll(optarg, ((void *)0), 10);
   break;
  case 'P':
   do_specific_domain = TRUE;
   specific_domain = strtol(optarg, ((void *)0), 10);
   specific_domain_optarg = optarg;
   break;
  case 'q':
   quiet_level++;
   break;
  case 'r':
   if (do_exclude_syscall == TRUE) {
    outputerr("-r needs to be before any -x options.\n");
    exit(1);
   }
   random_selection = TRUE;
   random_selection_num = strtol(optarg, ((void *)0), 10);
   break;
  case 's':
   seed = strtol(optarg, ((void *)0), 10);
   user_set_seed = TRUE;
   break;
  case 'S':
   do_syslog = TRUE;
   break;
  case 'T':
   process_taint_arg(optarg);
   if (kernel_taint_mask != 0xFFFFFFFF)
    outputstd("Custom kernel taint mask has been specified: 0x%08x (%d).\n",
     kernel_taint_mask, kernel_taint_mask);
   break;
  case 'v':
   verbose = TRUE;
   break;
  case 'V':
   if (victim_path == ((void *)0)) {
    victim_path = strdup(optarg);
    break;
   } else {
    outputstd("Sorry, only one victim path right now.\n");
    exit(1);
   }
   break;
  case 'x':
   do_exclude_syscall = TRUE;
   toggle_syscall(optarg, FALSE);
   break;
  case 'X':
   if (getuid() == 0)
    dropprivs = TRUE;
   else
    outputstd("Already running unprivileged, can't drop privs\n");
   break;
  case 0:
   if (strcmp("clowntown", longopts[opt_index].name) == 0)
    clowntown = TRUE;
   if (strcmp("disable-fds", longopts[opt_index].name) == 0)
    process_fds_param(optarg, FALSE);
   if (strcmp("dry-run", longopts[opt_index].name) == 0)
    dry_run = TRUE;
   if (strcmp("enable-fds", longopts[opt_index].name) == 0)
    process_fds_param(optarg, TRUE);
   if (strcmp("ftrace-dump-file", longopts[opt_index].name) == 0)
    ftracedumpname = strdup(optarg);
   if (strcmp("show-unannotated", longopts[opt_index].name) == 0)
    show_unannotated = TRUE;
   if (strcmp("stats", longopts[opt_index].name) == 0)
    show_stats = TRUE;
   break;
  }
 }
 if (quiet_level > 3)
  quiet_level = 3;
 quiet_level = 3 - quiet_level;
 output(1, "Done parsing arguments.\n");
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: opt int


decompiled_code:
__int64 register_scsi_grp()
{
return register_ioctl_group(&scsi_grp);
}

canonical_decompiled_code:
__int64 func2()
{
return register_ioctl_group(&scsi_grp);
}

original_code: static void __attribute__((constructor)) register_scsi_grp(void) { register_ioctl_group(&scsi_grp); }

canonical_original_code: static void register_scsi_grp() { register_ioctl_group(&scsi_grp); }


decompiled_code:
__int64 register_msr_grp()
{
return register_ioctl_group(&msr_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&msr_grp);
}

original_code: static void __attribute__((constructor)) register_msr_grp(void) { register_ioctl_group(&msr_grp); }

canonical_original_code: static void register_msr_grp() { register_ioctl_group(&msr_grp); }


decompiled_code:
void __fastcall store_successful_fd(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4LL * a2) = 1;
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4LL * a2) = 1;
}

original_code:
static void store_successful_fd(struct results *results, unsigned long value)
{
 int fd = (int) value;
 results->fdmap[fd] = TRUE;
}

variable_types: struct results { union { int fdmap[1024]; unsigned int min; }; } *

variable_types:
value
unsigned long


decompiled_code:
unsigned __int64 __fastcall store_successful_len(_DWORD *a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

result = (unsigned int)*a1;
if ( result > a2 )
{
*a1 = a2;
result = (unsigned int)a2;
}
if ( a2 > result )
*a1 = a2;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(_DWORD *a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

result = (unsigned int)*a1;
if ( result > a2 )
{
*a1 = a2;
result = (unsigned int)a2;
}
if ( a2 > result )
*a1 = a2;
return result;
}

original_code:
static void store_successful_len(struct results *results, unsigned long value)
{
 if (value < results->min)
  results->min = value;
 if (value > results->max)
  results->max = value;
}

user_defined_types: struct results { union { int fdmap[1024]; unsigned int min; }; }


decompiled_code:
__int64 register_cdrom_grp()
{
return register_ioctl_group(&cdrom_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&cdrom_grp);
}

original_code: static void __attribute__((constructor)) register_cdrom_grp(void) { register_ioctl_group(&cdrom_grp); }

canonical_original_code: static void register_cdrom_grp() { register_ioctl_group(&cdrom_grp); }


decompiled_code:
__int64 register_socket_grp()
{
return register_ioctl_group(&socket_grp);
}

canonical_decompiled_code:
__int64 func1()
{
return register_ioctl_group(&socket_grp);
}

original_code: static void __attribute__((constructor)) register_socket_grp(void) { register_ioctl_group(&socket_grp); }

canonical_original_code: static void register_socket_grp() { register_ioctl_group(&socket_grp); }


decompiled_code:
__int64 random_fcntl_setfl_flags()
{
return set_rand_bitmask(5LL, &fcntl_o_flags);
}

canonical_decompiled_code:
__int64 func0()
{
return set_rand_bitmask(5LL, &fcntl_o_flags);
}

original_code:
unsigned int random_fcntl_setfl_flags(void)
{
 return set_rand_bitmask((sizeof(fcntl_o_flags) / sizeof((fcntl_o_flags)[0])), fcntl_o_flags);
}

canonical_original_code:
unsigned int random_fcntl_setfl_flags()
{
 return set_rand_bitmask((sizeof(fcntl_o_flags) / sizeof((fcntl_o_flags)[0])), fcntl_o_flags);
}


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

result = (unsigned int)dccp_opts[rnd() & 0xF];
*(_QWORD *)(a1 + 8) = result;
return result;
}

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

result = (unsigned int)dccp_opts[rnd() & 0xF];
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
void dccp_setsockopt(struct sockopt *so, __attribute((unused)) struct socket_triplet *triplet)
{
 so->optname = dccp_opts[rnd() % (sizeof(dccp_opts) / sizeof((dccp_opts)[0]))];
}

canonical_original_code:
void dccp_setsockopt(struct sockopt *so, struct socket_triplet *triplet)
{
 so->optname = dccp_opts[rnd() % (sizeof(dccp_opts) / sizeof((dccp_opts)[0]))];
}

variable_types: struct sockopt { unsigned int level; unsigned long optname; unsigned long optval; unsigned long optlen; } *


decompiled_code:
__int64 get_len()
{
int v0; // eax
char v1; // cl
int v2; // edx
__int64 result; // rax
int v4; // ebx
int v5; // eax

if ( (rnd() & 1) == 0 )
goto LABEL_8;
v0 = rnd();
v1 = v0;
v2 = v0 % 4;
if ( v0 % 4 == 2 )
return 8LL;
result = page_size;
if ( v2 != 3 )
{
result = 1LL;
if ( (v1 & 3) != 0 )
{
if ( v2 == 1 )
return 4LL;
LABEL_8:
v4 = rand32();
if ( !v4 )
return 0LL;
v5 = (int)rnd() % 6;
if ( v5 == 2 )
{
v4 = (unsigned __int16)v4;
}
else if ( v5 > 2 )
{
if ( v5 != 3 )
goto LABEL_18;
v4 &= 0xFFFFFFu;
}
else
{
if ( v5 )
{
if ( v5 == 1 )
{
v4 &= page_size - 1;
goto LABEL_17;
}
LABEL_18:
if ( (rnd() & 3) == 0 )
v4 /= 1 << ((int)rnd() / 0x20000000 + 1);
return v4;
}
v4 = (unsigned __int8)v4;
}
LABEL_17:
if ( !v4 )
return 0LL;
goto LABEL_18;
}
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // eax
char v1; // cl
int v2; // edx
__int64 result; // rax
int v4; // ebx
int v5; // eax

if ( (rnd() & 1) == 0 )
goto LABEL_8;
v0 = rnd();
v1 = v0;
v2 = v0 % 4;
if ( v0 % 4 == 2 )
return 8LL;
result = page_size;
if ( v2 != 3 )
{
result = 1LL;
if ( (v1 & 3) != 0 )
{
if ( v2 == 1 )
return 4LL;
LABEL_8:
v4 = rand32();
if ( !v4 )
return 0LL;
v5 = (int)rnd() % 6;
if ( v5 == 2 )
{
v4 = (unsigned __int16)v4;
}
else if ( v5 > 2 )
{
if ( v5 != 3 )
goto LABEL_18;
v4 &= 0xFFFFFFu;
}
else
{
if ( v5 )
{
if ( v5 == 1 )
{
v4 &= page_size - 1;
goto LABEL_17;
}
LABEL_18:
if ( (rnd() & 3) == 0 )
v4 /= 1 << ((int)rnd() / 0x20000000 + 1);
return v4;
}
v4 = (unsigned __int8)v4;
}
LABEL_17:
if ( !v4 )
return 0LL;
goto LABEL_18;
}
}
return result;
}

original_code:
unsigned long get_len(void)
{
 int i = 0;
 if ((rnd() & 1)) {
  switch (rnd() % 4) {
  case 0: return sizeof(char);
  case 1: return sizeof(int);
  case 2: return sizeof(long);
  case 3: return page_size;
  }
 }
 i = rand32();
 if (i == 0)
  return 0;
 switch (rnd() % 6) {
 case 0: i &= 0xff;
  break;
 case 1: i &= page_size - 1;
  break;
 case 2: i &= 0xffff;
  break;
 case 3: i &= 0xffffff;
  break;
 case 4: i &= 0xffffffff;
  break;
 case 5:
  break;
 }
 if (i == 0)
  return 0;
 if (((rnd() % 4) == 0)) {
  int _div = 1 << (1 + rnd() / (2147483647 / (4 - 1 + 1) + 1));
  i /= _div;
 }
 return i;
}

canonical_original_code:
unsigned long get_len()
{
 int i = 0;
 if ((rnd() & 1)) {
  switch (rnd() % 4) {
  case 0: return sizeof(char);
  case 1: return sizeof(int);
  case 2: return sizeof(long);
  case 3: return page_size;
  }
 }
 i = rand32();
 if (i == 0)
  return 0;
 switch (rnd() % 6) {
 case 0: i &= 0xff;
  break;
 case 1: i &= page_size - 1;
  break;
 case 2: i &= 0xffff;
  break;
 case 3: i &= 0xffffff;
  break;
 case 4: i &= 0xffffffff;
  break;
 case 5:
  break;
 }
 if (i == 0)
  return 0;
 if (((rnd() % 4) == 0)) {
  int _div = 1 << (1 + rnd() / (2147483647 / (4 - 1 + 1) + 1));
  i /= _div;
 }
 return i;
}

variable_types: i int


decompiled_code:
__int64 register_sound_grp()
{
return register_ioctl_group(&sound_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&sound_grp);
}

original_code: static void __attribute__((constructor)) register_sound_grp(void) { register_ioctl_group(&sound_grp); }

canonical_original_code: static void register_sound_grp() { register_ioctl_group(&sound_grp); }


decompiled_code:
__int64 register_vmci_grp()
{
return register_ioctl_group(&vmci_grp);
}

canonical_decompiled_code:
__int64 func0()
{
return register_ioctl_group(&vmci_grp);
}

original_code: static void __attribute__((constructor)) register_vmci_grp(void) { register_ioctl_group(&vmci_grp); }

canonical_original_code: static void register_vmci_grp() { register_ioctl_group(&vmci_grp); }


decompiled_code:
__int64 __fastcall activate_syscall(__int64 a1)
{
return activate_syscall_in_table(a1, shm + 12336LL, syscalls, shm + 8240LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return activate_syscall_in_table(a1, shm + 12336LL, syscalls, shm + 8240LL);
}

original_code:
void activate_syscall(unsigned int calln)
{
 activate_syscall_in_table(calln, &shm->nr_active_syscalls, syscalls, shm->active_syscalls);
}

variable_types:
calln
unsigned int


decompiled_code:
__int64 __fastcall deactivate_syscall_uniarch(__int64 a1)
{
return deactivate_syscall_in_table(a1, shm + 12336LL, syscalls, shm + 8240LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return deactivate_syscall_in_table(a1, shm + 12336LL, syscalls, shm + 8240LL);
}

original_code:
void deactivate_syscall_uniarch(unsigned int calln)
{
 deactivate_syscall_in_table(calln, &shm->nr_active_syscalls, syscalls, shm->active_syscalls);
}


decompiled_code:
__int64 __fastcall setup_syscall_group_uniarch(int a1)
{
unsigned int v2; // ebx
__int64 v3; // rdi
__int64 v4; // rsi
__int64 result; // rax

if ( max_nr_syscalls )
{
v2 = 0;
do
{
while ( *(_DWORD *)(*(_QWORD *)(syscalls + 8LL * v2) + 25464LL) != a1 )
{
if ( max_nr_syscalls <= ++v2 )
goto LABEL_6;
}
v3 = v2++;
activate_syscall(v3);
}
while ( max_nr_syscalls > v2 );
}
LABEL_6:
v4 = *(unsigned int *)(shm + 12336LL);
if ( (_DWORD)v4 )
{
outputstd("Found %d syscalls in group\n", v4);
result = 1LL;
}
else
{
outputstd("No syscalls found in group\n");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
unsigned int v2; // ebx
__int64 v3; // rdi
__int64 v4; // rsi
__int64 result; // rax

if ( max_nr_syscalls )
{
v2 = 0;
do
{
while ( *(_DWORD *)(*(_QWORD *)(syscalls + 8LL * v2) + 25464LL) != a1 )
{
if ( max_nr_syscalls <= ++v2 )
goto LABEL_6;
}
v3 = v2++;
func0(v3);
}
while ( max_nr_syscalls > v2 );
}
LABEL_6:
v4 = *(unsigned int *)(shm + 12336LL);
if ( (_DWORD)v4 )
{
outputstd("Found %d syscalls in group\n", v4);
result = 1LL;
}
else
{
outputstd("No syscalls found in group\n");
result = 0LL;
}
return result;
}

original_code:
int setup_syscall_group_uniarch(unsigned int group)
{
 unsigned int i;
 for (i = 0; i < max_nr_syscalls; i++) {
  if (syscalls[i].entry->group == group)
   activate_syscall(i);
 }
 if (shm->nr_active_syscalls == 0) {
  outputstd("No syscalls found in group\n");
  return FALSE;
 } else {
  outputstd("Found %d syscalls in group\n", shm->nr_active_syscalls);
 }
 return TRUE;
}

variable_types:
group
unsigned int

variable_types:
i
unsigned int