decompiled_code:
void __noreturn handle_sigint()
{
unsigned int v0; // eax
unsigned int v1; // ebx

v0 = syscall(186LL);
v1 = v0;
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36mctrl-C press handled by thread %u\n", v0);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
}
log_msg("DBG", "ctrl-C press handled by thread %u\n", v1);
fwrite("\x1B[01m\x1B[31mctrl-C pressed, aborting...\n", 1uLL, 0x26uLL, stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("ERR", "ctrl-C pressed, aborting...\n");
try_print_live_data_race_pps();
fwrite("\x1B[01m\x1B[33m\n", 1uLL, 0xBuLL, stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("WARN", "\n");
fwrite(
"\x1B[01m\x1B[33msome landslide processes may be left hanging; please 'killall bochs'.\n",
1uLL,
0x50uLL,
stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("WARN", "some landslide processes may be left hanging; please 'killall bochs'.\n");
exit(3);
}

canonical_decompiled_code:
void __noreturn func0()
{
unsigned int v0; // eax
unsigned int v1; // ebx

v0 = syscall(186LL);
v1 = v0;
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36mctrl-C press handled by thread %u\n", v0);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
}
log_msg("DBG", "ctrl-C press handled by thread %u\n", v1);
fwrite("\x1B[01m\x1B[31mctrl-C pressed, aborting...\n", 1uLL, 0x26uLL, stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("ERR", "ctrl-C pressed, aborting...\n");
try_print_live_data_race_pps();
fwrite("\x1B[01m\x1B[33m\n", 1uLL, 0xBuLL, stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("WARN", "\n");
fwrite(
"\x1B[01m\x1B[33msome landslide processes may be left hanging; please 'killall bochs'.\n",
1uLL,
0x50uLL,
stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("WARN", "some landslide processes may be left hanging; please 'killall bochs'.\n");
exit(3);
}

original_code:
static void handle_sigint(int __attribute__((unused)) signum)
{
 pid_t me = syscall(186);
 do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "ctrl-C press handled by thread %u\n", me); fprintf(stderr, "\033[00m"); } log_msg("DBG", "ctrl-C press handled by thread %u\n", me); } while (0);
 do { fprintf(stderr, "\033[01m" "\033[31m" "ctrl-C pressed, aborting...\n"); fprintf(stderr, "\033[00m"); log_msg("ERR", "ctrl-C pressed, aborting...\n"); } while (0);
 try_print_live_data_race_pps();
 do { fprintf(stderr, "\033[01m" "\033[33m" "\n"); fprintf(stderr, "\033[00m"); log_msg("WARN", "\n"); } while (0);
 do { fprintf(stderr, "\033[01m" "\033[33m" "some landslide processes may be left hanging; please 'killall bochs'.\n"); fprintf(stderr, "\033[00m"); log_msg("WARN", "some landslide processes may be left hanging; please 'killall bochs'.\n"); } while (0);
 exit(3);
}

canonical_original_code:
static void handle_sigint(int signum)
{
 int me = syscall(186);
 do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "ctrl-C press handled by thread %u\n", me); fprintf(stderr, "\033[00m"); } log_msg("DBG", "ctrl-C press handled by thread %u\n", me); } while (0);
 do { fprintf(stderr, "\033[01m" "\033[31m" "ctrl-C pressed, aborting...\n"); fprintf(stderr, "\033[00m"); log_msg("ERR", "ctrl-C pressed, aborting...\n"); } while (0);
 try_print_live_data_race_pps();
 do { fprintf(stderr, "\033[01m" "\033[33m" "\n"); fprintf(stderr, "\033[00m"); log_msg("WARN", "\n"); } while (0);
 do { fprintf(stderr, "\033[01m" "\033[33m" "some landslide processes may be left hanging; please 'killall bochs'.\n"); fprintf(stderr, "\033[00m"); log_msg("WARN", "some landslide processes may be left hanging; please 'killall bochs'.\n"); } while (0);
 exit(3);
}

variable_types: signum int

variable_types: me int


repo: bblum/landslide

decompiled_code:
__int64 init_signal_handling()
{
unsigned int v0; // eax
unsigned int v1; // ebx
struct sigaction v3; // [rsp+0h] [rbp-A8h] BYREF

v3.sa_handler = (__sighandler_t)handle_sigint;
sigemptyset(&v3.sa_mask);
if ( sigaction(2, &v3, 0LL) )
_assert_fail("ret == 0 && \"failed init signal handling\"", "signals.c", 0x3Eu, "init_signal_handling");
v0 = syscall(186LL);
v1 = v0;
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36msignal handling inited by thread %u\n", v0);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
}
return log_msg("DBG", "signal handling inited by thread %u\n", v1);
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // eax
unsigned int v1; // ebx
struct sigaction v3; // [rsp+0h] [rbp-A8h] BYREF

v3.sa_handler = (__sighandler_t)handle_sigint;
sigemptyset(&v3.sa_mask);
if ( sigaction(2, &v3, 0LL) )
_assert_fail("ret == 0 && \"failed init signal handling\"", "signals.c", 0x3Eu, "init_signal_handling");
v0 = syscall(186LL);
v1 = v0;
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36msignal handling inited by thread %u\n", v0);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
}
return log_msg("DBG", "signal handling inited by thread %u\n", v1);
}

original_code:
void init_signal_handling()
{
 struct sigaction act;
 act.__sigaction_handler.sa_handler = handle_sigint;
 sigemptyset(&act.sa_mask);
 int ret = sigaction(2, &act, ((void *)0));
 ((ret == 0 && "failed init signal handling") ? (void) (0) : __assert_fail ("ret == 0 && \"failed init signal handling\"", "signals.c", 62, __extension__ __PRETTY_FUNCTION__));
 pid_t me = syscall(186);
 do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "signal handling inited by thread %u\n", me); fprintf(stderr, "\033[00m"); } log_msg("DBG", "signal handling inited by thread %u\n", me); } while (0);
}

canonical_original_code:
void init_signal_handling()
{
 struct sigaction act;
 act.__sigaction_handler.sa_handler = handle_sigint;
 sigemptyset(&act.sa_mask);
 int ret = sigaction(2, &act, ((void *)0));
 ((ret == 0 && "failed init signal handling") ? (void) (0) : __assert_fail ("ret == 0 && \"failed init signal handling\"", "signals.c", 62, __extension__ __PRETTY_FUNCTION__));
 int me = syscall(186);
 do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "signal handling inited by thread %u\n", me); fprintf(stderr, "\033[00m"); } log_msg("DBG", "signal handling inited by thread %u\n", me); } while (0);
}

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

variable_types: ret int

return_type: void

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


timestamp

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

if ( gettimeofday(&v4, 0LL) )
{
v1 = *_errno_location();
fprintf(stderr, "\x1B[01m\x1B[31mAssertion failed: '%s'\n", "__ret == 0");
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("ERR", "Assertion failed: '%s'\n", "__ret == 0");
fwrite("\x1B[01m\x1B[31mfailed gettimeofday", 1uLL, 0x1DuLL, stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("ERR", "failed gettimeofday");
v2 = strerror(v1);
fprintf(stderr, "\x1B[01m\x1B[31mError: %s\n", v2);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v3 = strerror(v1);
log_msg("ERR", "Error: %s\n", v3);
}
return v4.tv_usec + 1000000 * v4.tv_sec;
}

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

if ( gettimeofday(&v4, 0LL) )
{
v1 = *_errno_location();
fprintf(stderr, "\x1B[01m\x1B[31mAssertion failed: '%s'\n", "__ret == 0");
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("ERR", "Assertion failed: '%s'\n", "__ret == 0");
fwrite("\x1B[01m\x1B[31mfailed gettimeofday", 1uLL, 0x1DuLL, stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
log_msg("ERR", "failed gettimeofday");
v2 = strerror(v1);
fprintf(stderr, "\x1B[01m\x1B[31mError: %s\n", v2);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v3 = strerror(v1);
log_msg("ERR", "Error: %s\n", v3);
}
return v4.tv_usec + 1000000 * v4.tv_sec;
}

original_code:
unsigned long timestamp()
{
 struct timeval tv;
 do { int __ret = gettimeofday((&tv), ((void *)0)); do { int __last_errno = (*__errno_location ()); if (!(__ret == 0)) { do { fprintf(stderr, "\033[01m" "\033[31m" "Assertion failed: '%s'\n", "__ret == 0"); fprintf(stderr, "\033[00m"); log_msg("ERR", "Assertion failed: '%s'\n", "__ret == 0"); } while (0); do { fprintf(stderr, "\033[01m" "\033[31m" "failed gettimeofday"); fprintf(stderr, "\033[00m"); log_msg("ERR", "failed gettimeofday"); } while (0); do { fprintf(stderr, "\033[01m" "\033[31m" "Error: %s\n", strerror(__last_errno)); fprintf(stderr, "\033[00m"); log_msg("ERR", "Error: %s\n", strerror(__last_errno)); } while (0); } } while (0); } while (0);
 return (unsigned long)((tv.tv_sec * 1000000) + tv.tv_usec);
}

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

return_type: unsigned long


decompiled_code:
unsigned __int64 time_elapsed()
{
unsigned __int64 v0; // rax

if ( !start_timestamp )
_assert_fail("start_timestamp != 0", "time.c", 0x4Eu, "time_elapsed");
v0 = timestamp();
if ( start_timestamp > v0 )
_assert_fail("now >= start_timestamp && \"travelled back in time??\"", "time.c", 0x50u, "time_elapsed");
return v0 - start_timestamp;
}

canonical_decompiled_code:
unsigned __int64 func1()
{
unsigned __int64 v0; // rax

if ( !start_timestamp )
_assert_fail("start_timestamp != 0", "time.c", 0x4Eu, "time_elapsed");
v0 = func0();
if ( start_timestamp > v0 )
_assert_fail("now >= start_timestamp && \"travelled back in time??\"", "time.c", 0x50u, "time_elapsed");
return v0 - start_timestamp;
}

original_code:
unsigned long time_elapsed()
{
 ((start_timestamp != 0) ? (void) (0) : __assert_fail ("start_timestamp != 0", "time.c", 78, __extension__ __PRETTY_FUNCTION__));
 unsigned long now = timestamp();
 ((now >= start_timestamp && "travelled back in time??") ? (void) (0) : __assert_fail ("now >= start_timestamp && \"travelled back in time??\"", "time.c", 80, __extension__ __PRETTY_FUNCTION__));
 return now - start_timestamp;
}

variable_types:
now
unsigned long


decompiled_code:
unsigned __int64 time_remaining()
{
unsigned __int64 v0; // rdx
unsigned __int64 result; // rax

if ( !start_timestamp )
_assert_fail("start_timestamp != 0", "time.c", 0x56u, "time_remaining");
v0 = timestamp();
result = 0LL;
if ( v0 <= start_timestamp + budget )
result = start_timestamp + budget - v0;
return result;
}

canonical_decompiled_code:
unsigned __int64 func2()
{
unsigned __int64 v0; // rdx
unsigned __int64 result; // rax

if ( !start_timestamp )
_assert_fail("start_timestamp != 0", "time.c", 0x56u, "time_remaining");
v0 = func0();
result = 0LL;
if ( v0 <= start_timestamp + budget )
result = start_timestamp + budget - v0;
return result;
}

original_code:
unsigned long time_remaining()
{
 ((start_timestamp != 0) ? (void) (0) : __assert_fail ("start_timestamp != 0", "time.c", 86, __extension__ __PRETTY_FUNCTION__));
 unsigned long now = timestamp();
 unsigned long end_time = start_timestamp + budget;
 return end_time < now ? 0 : end_time - now;
}


decompiled_code:
int __fastcall start_using_cpu(unsigned int a1)
{
__int64 v1; // rbx
int result; // eax

if ( pthread_mutex_lock(&cpu_time_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "time.c", 0x5Eu, "start_using_cpu");
if ( !cpu_times )
_assert_fail("cpu_times != NULL", "time.c", 0x5Fu, "start_using_cpu");
if ( num_cpus <= a1 )
_assert_fail("which < num_cpus", "time.c", 0x60u, "start_using_cpu");
v1 = cpu_times + 24LL * a1;
if ( *(_BYTE *)(v1 + 8) )
_assert_fail("!cpu_times[which].running_now", "time.c", 0x61u, "start_using_cpu");
*(_QWORD *)(v1 + 16) = timestamp();
*(_BYTE *)(cpu_times + 24LL * a1 + 8) = 1;
result = pthread_mutex_unlock(&cpu_time_lock);
if ( result )
_assert_fail("__ret == 0 && \"failed mx unlock\"", "time.c", 0x64u, "start_using_cpu");
return result;
}

canonical_decompiled_code:
int __fastcall func3(unsigned int a1)
{
__int64 v1; // rbx
int result; // eax

if ( pthread_mutex_lock(&cpu_time_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "time.c", 0x5Eu, "start_using_cpu");
if ( !cpu_times )
_assert_fail("cpu_times != NULL", "time.c", 0x5Fu, "start_using_cpu");
if ( num_cpus <= a1 )
_assert_fail("which < num_cpus", "time.c", 0x60u, "start_using_cpu");
v1 = cpu_times + 24LL * a1;
if ( *(_BYTE *)(v1 + 8) )
_assert_fail("!cpu_times[which].running_now", "time.c", 0x61u, "start_using_cpu");
*(_QWORD *)(v1 + 16) = func0();
*(_BYTE *)(cpu_times + 24LL * a1 + 8) = 1;
result = pthread_mutex_unlock(&cpu_time_lock);
if ( result )
_assert_fail("__ret == 0 && \"failed mx unlock\"", "time.c", 0x64u, "start_using_cpu");
return result;
}

original_code:
void start_using_cpu(unsigned int which)
{
 do { int __ret = pthread_mutex_lock(&cpu_time_lock); ((__ret == 0 && "failed mx lock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx lock\"", "time.c", 94, __extension__ __PRETTY_FUNCTION__)); } while (0);
 ((cpu_times != ((void *)0)) ? (void) (0) : __assert_fail ("cpu_times != NULL", "time.c", 95, __extension__ __PRETTY_FUNCTION__));
 ((which < num_cpus) ? (void) (0) : __assert_fail ("which < num_cpus", "time.c", 96, __extension__ __PRETTY_FUNCTION__));
 ((!cpu_times[which].running_now) ? (void) (0) : __assert_fail ("!cpu_times[which].running_now", "time.c", 97, __extension__ __PRETTY_FUNCTION__));
 cpu_times[which].running_since = timestamp();
 cpu_times[which].running_now = 1;
 do { int __ret = pthread_mutex_unlock(&cpu_time_lock); ((__ret == 0 && "failed mx unlock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx unlock\"", "time.c", 100, __extension__ __PRETTY_FUNCTION__)); } while (0);
}

variable_types:
which
unsigned int


decompiled_code:
int __fastcall stop_using_cpu(unsigned int a1)
{
__int64 v1; // rbx
__suseconds_t v2; // rdx
__int64 v3; // rax
__suseconds_t v4; // rdx
int result; // eax

if ( pthread_mutex_lock(&cpu_time_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "time.c", 0x69u, "stop_using_cpu");
if ( !cpu_times )
_assert_fail("cpu_times != NULL", "time.c", 0x6Au, "stop_using_cpu");
if ( num_cpus <= a1 )
_assert_fail("which < num_cpus", "time.c", 0x6Bu, "stop_using_cpu");
v1 = 24LL * a1;
if ( !*(_BYTE *)(cpu_times + v1 + 8) )
_assert_fail("cpu_times[which].running_now", "time.c", 0x6Cu, "stop_using_cpu");
v2 = timestamp();
v3 = v1 + cpu_times;
v4 = *(_QWORD *)(v1 + cpu_times) + v2 - *(_QWORD *)(v1 + cpu_times + 16);
*(_BYTE *)(v3 + 8) = 0;
*(_QWORD *)v3 = v4;
result = pthread_mutex_unlock(&cpu_time_lock);
if ( result )
_assert_fail("__ret == 0 && \"failed mx unlock\"", "time.c", 0x70u, "stop_using_cpu");
return result;
}

canonical_decompiled_code:
int __fastcall func4(unsigned int a1)
{
__int64 v1; // rbx
__suseconds_t v2; // rdx
__int64 v3; // rax
__suseconds_t v4; // rdx
int result; // eax

if ( pthread_mutex_lock(&cpu_time_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "time.c", 0x69u, "stop_using_cpu");
if ( !cpu_times )
_assert_fail("cpu_times != NULL", "time.c", 0x6Au, "stop_using_cpu");
if ( num_cpus <= a1 )
_assert_fail("which < num_cpus", "time.c", 0x6Bu, "stop_using_cpu");
v1 = 24LL * a1;
if ( !*(_BYTE *)(cpu_times + v1 + 8) )
_assert_fail("cpu_times[which].running_now", "time.c", 0x6Cu, "stop_using_cpu");
v2 = func0();
v3 = v1 + cpu_times;
v4 = *(_QWORD *)(v1 + cpu_times) + v2 - *(_QWORD *)(v1 + cpu_times + 16);
*(_BYTE *)(v3 + 8) = 0;
*(_QWORD *)v3 = v4;
result = pthread_mutex_unlock(&cpu_time_lock);
if ( result )
_assert_fail("__ret == 0 && \"failed mx unlock\"", "time.c", 0x70u, "stop_using_cpu");
return result;
}

original_code:
void stop_using_cpu(unsigned int which)
{
 do { int __ret = pthread_mutex_lock(&cpu_time_lock); ((__ret == 0 && "failed mx lock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx lock\"", "time.c", 105, __extension__ __PRETTY_FUNCTION__)); } while (0);
 ((cpu_times != ((void *)0)) ? (void) (0) : __assert_fail ("cpu_times != NULL", "time.c", 106, __extension__ __PRETTY_FUNCTION__));
 ((which < num_cpus) ? (void) (0) : __assert_fail ("which < num_cpus", "time.c", 107, __extension__ __PRETTY_FUNCTION__));
 ((cpu_times[which].running_now) ? (void) (0) : __assert_fail ("cpu_times[which].running_now", "time.c", 108, __extension__ __PRETTY_FUNCTION__));
 cpu_times[which].previous_total +=
  timestamp() - cpu_times[which].running_since;
 cpu_times[which].running_now = 0;
 do { int __ret = pthread_mutex_unlock(&cpu_time_lock); ((__ret == 0 && "failed mx unlock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx unlock\"", "time.c", 112, __extension__ __PRETTY_FUNCTION__)); } while (0);
}


decompiled_code:
__suseconds_t total_cpu_time()
{
__suseconds_t v0; // rsi
__int64 v1; // rdx
__suseconds_t v2; // r12
__int64 i; // rax

if ( pthread_mutex_lock(&cpu_time_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "time.c", 0x75u, "total_cpu_time");
if ( !cpu_times )
_assert_fail("cpu_times != NULL", "time.c", 0x76u, "total_cpu_time");
v0 = timestamp();
if ( num_cpus )
{
v1 = cpu_times;
v2 = 0LL;
for ( i = cpu_times + 24; ; i += 24LL )
{
v2 += *(_QWORD *)v1;
if ( *(_BYTE *)(v1 + 8) )
v2 = v0 + v2 - *(_QWORD *)(v1 + 16);
v1 = i;
if ( i == cpu_times + 24 + 24LL * (unsigned int)(num_cpus - 1) )
break;
}
}
else
{
v2 = 0LL;
}
if ( pthread_mutex_unlock(&cpu_time_lock) )
_assert_fail("__ret == 0 && \"failed mx unlock\"", "time.c", 0x7Fu, "total_cpu_time");
return v2;
}

canonical_decompiled_code:
__suseconds_t func5()
{
__suseconds_t v0; // rsi
__int64 v1; // rdx
__suseconds_t v2; // r12
__int64 i; // rax

if ( pthread_mutex_lock(&cpu_time_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "time.c", 0x75u, "total_cpu_time");
if ( !cpu_times )
_assert_fail("cpu_times != NULL", "time.c", 0x76u, "total_cpu_time");
v0 = func0();
if ( num_cpus )
{
v1 = cpu_times;
v2 = 0LL;
for ( i = cpu_times + 24; ; i += 24LL )
{
v2 += *(_QWORD *)v1;
if ( *(_BYTE *)(v1 + 8) )
v2 = v0 + v2 - *(_QWORD *)(v1 + 16);
v1 = i;
if ( i == cpu_times + 24 + 24LL * (unsigned int)(num_cpus - 1) )
break;
}
}
else
{
v2 = 0LL;
}
if ( pthread_mutex_unlock(&cpu_time_lock) )
_assert_fail("__ret == 0 && \"failed mx unlock\"", "time.c", 0x7Fu, "total_cpu_time");
return v2;
}

original_code:
unsigned long total_cpu_time()
{
 do { int __ret = pthread_mutex_lock(&cpu_time_lock); ((__ret == 0 && "failed mx lock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx lock\"", "time.c", 117, __extension__ __PRETTY_FUNCTION__)); } while (0);
 ((cpu_times != ((void *)0)) ? (void) (0) : __assert_fail ("cpu_times != NULL", "time.c", 118, __extension__ __PRETTY_FUNCTION__));
 unsigned long now = timestamp();
 unsigned long total = 0;
 for (unsigned int i = 0; i < num_cpus; i++) {
  total += cpu_times[i].previous_total;
  if (cpu_times[i].running_now) {
   total += now - cpu_times[i].running_since;
  }
 }
 do { int __ret = pthread_mutex_unlock(&cpu_time_lock); ((__ret == 0 && "failed mx unlock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx unlock\"", "time.c", 127, __extension__ __PRETTY_FUNCTION__)); } while (0);
 return total;
}

variable_types:
total
unsigned long

variable_types:
i
unsigned int


original_code:
void human_friendly_time(long double usecs, struct human_friendly_time *hft)
{
 long double secs = usecs / 1000000;
 if ((hft->inf = (secs > (long double)(18446744073709551615UL)))) {
  return;
 }
 hft->years = 0;
 hft->days = 0;
 hft->hours = 0;
 hft->mins = 0;
 hft->secs = (uint64_t)secs;
 if (hft->secs >= 60) {
  hft->mins = hft->secs / 60;
  hft->secs = hft->secs % 60;
 }
 if (hft->mins >= 60) {
  hft->hours = hft->mins / 60;
  hft->mins = hft->mins % 60;
 }
 if (hft->hours >= 24) {
  hft->days = hft->hours / 24;
  hft->hours = hft->hours % 24;
 }
 if (hft->days >= 365) {
  hft->years = hft->days / 365;
  hft->days = hft->days % 365;
 }
}

canonical_original_code:
void human_friendly_time(long double usecs, struct human_friendly_time *hft)
{
 long double secs = usecs / 1000000;
 if ((hft->inf = (secs > (long double)(18446744073709551615UL)))) {
  return;
 }
 hft->years = 0;
 hft->days = 0;
 hft->hours = 0;
 hft->mins = 0;
 hft->secs = (unsigned long)secs;
 if (hft->secs >= 60) {
  hft->mins = hft->secs / 60;
  hft->secs = hft->secs % 60;
 }
 if (hft->mins >= 60) {
  hft->hours = hft->mins / 60;
  hft->mins = hft->mins % 60;
 }
 if (hft->hours >= 24) {
  hft->days = hft->hours / 24;
  hft->hours = hft->hours % 24;
 }
 if (hft->days >= 365) {
  hft->years = hft->days / 365;
  hft->days = hft->days % 365;
 }
}

variable_types:
usecs
long double

variable_types: struct human_friendly_time { unsigned long secs; _Bool inf; } *

variable_types:
secs
long double


user_defined_types: struct human_friendly_time { unsigned long secs; _Bool inf; }


decompiled_code:
__int64 __fastcall dbg_human_friendly_time(_QWORD *a1)
{
__int64 v1; // rdx
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 result; // rax

if ( *((_BYTE *)a1 + 40) )
{
if ( verbose )
{
fwrite("\x1B[00m\x1B[36mINF", 1uLL, 0xDuLL, stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
}
result = log_msg("DBG", "INF");
}
else
{
v1 = a1[4];
if ( v1 )
{
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%luy ", v1);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v1 = a1[4];
}
log_msg("DBG", "%luy ", v1);
}
v2 = a1[3];
if ( v2 )
{
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%lud ", v2);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v2 = a1[3];
}
log_msg("DBG", "%lud ", v2);
}
v3 = a1[2];
if ( v3 )
{
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%luh ", v3);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v3 = a1[2];
}
log_msg("DBG", "%luh ", v3);
}
v4 = a1[1];
if ( v4 )
{
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%lum ", v4);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v4 = a1[1];
}
log_msg("DBG", "%lum ", v4);
}
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%lus", *a1);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
}
result = log_msg("DBG", "%lus", *a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1)
{
__int64 v1; // rdx
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 result; // rax

if ( *((_BYTE *)a1 + 40) )
{
if ( verbose )
{
fwrite("\x1B[00m\x1B[36mINF", 1uLL, 0xDuLL, stderr);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
}
result = log_msg("DBG", "INF");
}
else
{
v1 = a1[4];
if ( v1 )
{
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%luy ", v1);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v1 = a1[4];
}
log_msg("DBG", "%luy ", v1);
}
v2 = a1[3];
if ( v2 )
{
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%lud ", v2);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v2 = a1[3];
}
log_msg("DBG", "%lud ", v2);
}
v3 = a1[2];
if ( v3 )
{
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%luh ", v3);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v3 = a1[2];
}
log_msg("DBG", "%luh ", v3);
}
v4 = a1[1];
if ( v4 )
{
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%lum ", v4);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
v4 = a1[1];
}
log_msg("DBG", "%lum ", v4);
}
if ( verbose )
{
fprintf(stderr, "\x1B[00m\x1B[36m%lus", *a1);
fwrite("\x1B[00m", 1uLL, 5uLL, stderr);
}
result = log_msg("DBG", "%lus", *a1);
}
return result;
}

original_code:
void dbg_human_friendly_time(struct human_friendly_time *hft)
{
 if (hft->inf) {
  do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "INF"); fprintf(stderr, "\033[00m"); } log_msg("DBG", "INF"); } while (0);
  return;
 }
 if (hft->years != 0)
  do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "%luy ", hft->years); fprintf(stderr, "\033[00m"); } log_msg("DBG", "%luy ", hft->years); } while (0);
 if (hft->days != 0)
  do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "%lud ", hft->days); fprintf(stderr, "\033[00m"); } log_msg("DBG", "%lud ", hft->days); } while (0);
 if (hft->hours != 0)
  do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "%luh ", hft->hours); fprintf(stderr, "\033[00m"); } log_msg("DBG", "%luh ", hft->hours); } while (0);
 if (hft->mins != 0)
  do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "%lum ", hft->mins); fprintf(stderr, "\033[00m"); } log_msg("DBG", "%lum ", hft->mins); } while (0);
 do { if (verbose) { fprintf(stderr, "\033[00m" "\033[36m" "%lus", hft->secs); fprintf(stderr, "\033[00m"); } log_msg("DBG", "%lus", hft->secs); } while (0);
}


decompiled_code:
__int64 __fastcall bug_already_found(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
unsigned int v3; // er12

check_init();
if ( pthread_mutex_lock(&fab_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "bug.c", 0x58u, "bug_already_found");
v1 = qword_AB8;
if ( (_DWORD)fab_list )
{
LODWORD(v2) = 0;
while ( 1 )
{
v3 = pp_subset(*(_QWORD *)(v1 + 8), a1);
if ( (_BYTE)v3 )
break;
v2 = (unsigned int)(v2 + 1);
v1 = qword_AB8 + 24 * v2;
if ( (unsigned int)fab_list <= (unsigned int)v2 )
goto LABEL_8;
}
}
else
{
LABEL_8:
v3 = 0;
}
if ( pthread_mutex_unlock(&fab_lock) )
_assert_fail("__ret == 0 && \"failed mx unlock\"", "bug.c", 0x5Fu, "bug_already_found");
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
unsigned int v3; // er12

func0();
if ( pthread_mutex_lock(&fab_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "bug.c", 0x58u, "bug_already_found");
v1 = qword_AB8;
if ( (_DWORD)fab_list )
{
LODWORD(v2) = 0;
while ( 1 )
{
v3 = pp_subset(*(_QWORD *)(v1 + 8), a1);
if ( (_BYTE)v3 )
break;
v2 = (unsigned int)(v2 + 1);
v1 = qword_AB8 + 24 * v2;
if ( (unsigned int)fab_list <= (unsigned int)v2 )
goto LABEL_8;
}
}
else
{
LABEL_8:
v3 = 0;
}
if ( pthread_mutex_unlock(&fab_lock) )
_assert_fail("__ret == 0 && \"failed mx unlock\"", "bug.c", 0x5Fu, "bug_already_found");
return v3;
}

original_code:
_Bool bug_already_found(struct pp_set *config)
{
 unsigned int i;
 struct bug_info *b;
 _Bool result = 0;
 check_init();
 do { int __ret = pthread_mutex_lock(&fab_lock); ((__ret == 0 && "failed mx lock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx lock\"", "bug.c", 88, __extension__ __PRETTY_FUNCTION__)); } while (0);
 for(i = 0, b = &(&fab_list)->array[i]; i < (&fab_list)->size; i++, b = &(&fab_list)->array[i]) {
  if (pp_subset(b->config, config)) {
   result = 1;
   break;
  }
 }
 do { int __ret = pthread_mutex_unlock(&fab_lock); ((__ret == 0 && "failed mx unlock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx unlock\"", "bug.c", 95, __extension__ __PRETTY_FUNCTION__)); } while (0);
 return result;
}

variable_types: struct bug_info { char *trace_filename; struct pp_set { unsigned int size; unsigned int capacity; _Bool array[]; } *config; char *log_filename; } *

user_defined_types: struct bug_info { char *trace_filename; struct pp_set *config; char *log_filename; }


decompiled_code:
__int64 found_any_bugs()
{
__int64 v0; // rbx
__int64 v1; // rbp

check_init();
if ( pthread_mutex_lock(&fab_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "bug.c", 0x6Bu, "found_any_bugs");
v0 = qword_AB8;
if ( (_DWORD)fab_list )
{
LODWORD(v1) = 0;
do
{
printf("\x1B[01m\x1B[31mFound a bug - %s - with PPs: ", *(const char **)v0);
print_pp_set(*(_QWORD *)(v0 + 8), 1LL);
printf(" (log file: id/%s)\n\x1B[00m", *(const char **)(v0 + 16));
v1 = (unsigned int)(v1 + 1);
v0 = qword_AB8 + 24 * v1;
}
while ( (unsigned int)fab_list > (unsigned int)v1 );
if ( !pthread_mutex_unlock(&fab_lock) )
return 1LL;
LABEL_9:
_assert_fail("__ret == 0 && \"failed mx unlock\"", "bug.c", 0x74u, "found_any_bugs");
}
if ( pthread_mutex_unlock(&fab_lock) )
goto LABEL_9;
printf("\x1B[01m\x1B[32mNo bugs were found -- you survived!\n\x1B[00m");
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx
__int64 v1; // rbp

func0();
if ( pthread_mutex_lock(&fab_lock) )
_assert_fail("__ret == 0 && \"failed mx lock\"", "bug.c", 0x6Bu, "found_any_bugs");
v0 = qword_AB8;
if ( (_DWORD)fab_list )
{
LODWORD(v1) = 0;
do
{
printf("\x1B[01m\x1B[31mFound a bug - %s - with PPs: ", *(const char **)v0);
print_pp_set(*(_QWORD *)(v0 + 8), 1LL);
printf(" (log file: id/%s)\n\x1B[00m", *(const char **)(v0 + 16));
v1 = (unsigned int)(v1 + 1);
v0 = qword_AB8 + 24 * v1;
}
while ( (unsigned int)fab_list > (unsigned int)v1 );
if ( !pthread_mutex_unlock(&fab_lock) )
return 1LL;
LABEL_9:
_assert_fail("__ret == 0 && \"failed mx unlock\"", "bug.c", 0x74u, "found_any_bugs");
}
if ( pthread_mutex_unlock(&fab_lock) )
goto LABEL_9;
printf("\x1B[01m\x1B[32mNo bugs were found -- you survived!\n\x1B[00m");
return 0LL;
}

original_code:
_Bool found_any_bugs()
{
 unsigned int i;
 struct bug_info *b;
 _Bool any = 0;
 check_init();
 do { int __ret = pthread_mutex_lock(&fab_lock); ((__ret == 0 && "failed mx lock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx lock\"", "bug.c", 107, __extension__ __PRETTY_FUNCTION__)); } while (0);
 for(i = 0, b = &(&fab_list)->array[i]; i < (&fab_list)->size; i++, b = &(&fab_list)->array[i]) {
  printf("\033[01m" "\033[31m"
         "Found a bug - %s - with PPs: ", b->trace_filename);
  print_pp_set(b->config, 1);
  printf(" (log file: id/%s)\n" "\033[00m", b->log_filename);
  any = 1;
 }
 do { int __ret = pthread_mutex_unlock(&fab_lock); ((__ret == 0 && "failed mx unlock") ? (void) (0) : __assert_fail ("__ret == 0 && \"failed mx unlock\"", "bug.c", 116, __extension__ __PRETTY_FUNCTION__)); } while (0);
 if (!any) {
  printf("\033[01m" "\033[32m"
         "No bugs were found -- you survived!\n" "\033[00m");
 }
 return any;
}

user_defined_types: struct pp_set { unsigned int size; unsigned int capacity; _Bool array[]; }


decompiled_code:
unsigned __int64 __fastcall persistent_write(int fd, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // r13
unsigned __int64 v5; // rsi
ssize_t v7; // rax
int v8; // eax

v3 = 0LL;
v5 = 0LL;
while ( 1 )
{
v7 = write(fd, (const void *)(a2 + v5), a3 - v5);
if ( v7 == -1 )
break;
v3 += v7;
LABEL_3:
v5 = v3;
if ( v3 >= a3 )
return v3;
}
v8 = *__errno_location();
if ( v8 == 11 || v8 == 4 )
goto LABEL_3;
return -1LL;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(int fd, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // r13
unsigned __int64 v5; // rsi
ssize_t v7; // rax
int v8; // eax

v3 = 0LL;
v5 = 0LL;
while ( 1 )
{
v7 = write(fd, (const void *)(a2 + v5), a3 - v5);
if ( v7 == -1 )
break;
v3 += v7;
LABEL_3:
v5 = v3;
if ( v3 >= a3 )
return v3;
}
v8 = *__errno_location();
if ( v8 == 11 || v8 == 4 )
goto LABEL_3;
return -1LL;
}

original_code:
static ssize_t persistent_write(int fd, const void *data, size_t size) {
    ssize_t res, written;
    written = 0;
    while (written < size) {
        res = write(fd, ((char*)data) + written, size - written);
        if (res == -1) {
            if ((*__errno_location ()) == 11 || (*__errno_location ()) == 4) continue;
            else return -1;
        }
        written += res;
    }
    return written;
}

canonical_original_code:
static long persistent_write(int fd, void *data, unsigned long size) {
    long res; long written;
    written = 0;
    while (written < size) {
        res = write(fd, ((char *)data) + written, size - written);
        if (res == -1) {
            if ((*__errno_location ()) == 11 || (*__errno_location ()) == 4) continue;
            else return -1;
        }
        written += res;
    }
    return written;
}

variable_types: fd int

variable_types:
data
void *

variable_types:
size
unsigned long

variable_types: res long

variable_types: written long

return_type: long


decompiled_code:
__int64 lb_connect()
{
int v0; // eax
unsigned int v1; // er12
char buf; // [rsp+Fh] [rbp-49h] BYREF
struct termios termios_p; // [rsp+10h] [rbp-48h] BYREF

v0 = open("/dev/ttyACM0", 258);
if ( v0 == -1 )
__assert_fail("ret != -1", "light_bar.c", 0x17u, "lb_connect");
v1 = v0;
if ( tcgetattr(v0, &termios_p) )
__assert_fail("res == 0", "light_bar.c", 0x1Bu, "lb_connect");
if ( cfsetspeed(&termios_p, 0x1002u) )
__assert_fail("res == 0", "light_bar.c", 0x1Fu, "lb_connect");
cfmakeraw(&termios_p);
if ( tcsetattr(v1, 0, &termios_p) )
__assert_fail("res == 0", "light_bar.c", 0x24u, "lb_connect");
buf = 0;
while ( (unsigned int)read(v1, &buf, 1uLL) != 1 )
;
return v1;
}

canonical_decompiled_code:
__int64 func9()
{
int v0; // eax
unsigned int v1; // er12
char buf; // [rsp+Fh] [rbp-49h] BYREF
struct termios termios_p; // [rsp+10h] [rbp-48h] BYREF

v0 = open("/dev/ttyACM0", 258);
if ( v0 == -1 )
__assert_fail("ret != -1", "light_bar.c", 0x17u, "lb_connect");
v1 = v0;
if ( tcgetattr(v0, &termios_p) )
__assert_fail("res == 0", "light_bar.c", 0x1Bu, "lb_connect");
if ( cfsetspeed(&termios_p, 0x1002u) )
__assert_fail("res == 0", "light_bar.c", 0x1Fu, "lb_connect");
cfmakeraw(&termios_p);
if ( tcsetattr(v1, 0, &termios_p) )
__assert_fail("res == 0", "light_bar.c", 0x24u, "lb_connect");
buf = 0;
while ( (unsigned int)read(v1, &buf, 1uLL) != 1 )
;
return v1;
}

original_code:
light_bar lb_connect() {
    int res;
    light_bar ret = open("/dev/ttyACM0", 02 | 0400);
    ((void) sizeof ((ret != -1) ? 1 : 0), __extension__ ({ if (ret != -1) ; else __assert_fail ("ret != -1", "light_bar.c", 23, __extension__ __PRETTY_FUNCTION__); }));
    struct termios opts;
    res = tcgetattr(ret, &opts);
    ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "light_bar.c", 27, __extension__ __PRETTY_FUNCTION__); }));
    res = cfsetspeed(&opts, 0010002);
    ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "light_bar.c", 31, __extension__ __PRETTY_FUNCTION__); }));
    cfmakeraw(&opts);
    res = tcsetattr(ret, 0, &opts);
    ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "light_bar.c", 36, __extension__ __PRETTY_FUNCTION__); }));
    char ready = 0;
    while (res != 1) {
        res = read(ret, &ready, 1);
    }
    return ret;
}

canonical_original_code:
int lb_connect() {
    int res;
    int ret = open("/dev/ttyACM0", 02 | 0400);
    ((void) sizeof ((ret != -1) ? 1 : 0), __extension__ ({ if (ret != -1) ; else __assert_fail ("ret != -1", "light_bar.c", 23, __extension__ __PRETTY_FUNCTION__); }));
    struct termios opts;
    res = tcgetattr(ret, &opts);
    ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "light_bar.c", 27, __extension__ __PRETTY_FUNCTION__); }));
    res = cfsetspeed(&opts, 0010002);
    ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "light_bar.c", 31, __extension__ __PRETTY_FUNCTION__); }));
    cfmakeraw(&opts);
    res = tcsetattr(ret, 0, &opts);
    ((void) sizeof ((res == 0) ? 1 : 0), __extension__ ({ if (res == 0) ; else __assert_fail ("res == 0", "light_bar.c", 36, __extension__ __PRETTY_FUNCTION__); }));
    char ready = 0;
    while (res != 1) {
        res = read(ret, &ready, 1);
    }
    return ret;
}

variable_types: res int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

variable_types: ready char

return_type: int


decompiled_code:
// attributes: thunk
int lb_close(int fd)
{
return close(fd);
}

canonical_decompiled_code:
int func10(int fd)
{
return close(fd);
}

original_code:
int lb_close(light_bar fd) {
    return close(fd);
}


decompiled_code:
__int64 __fastcall lb_reset(unsigned int a1)
{
lb_write_isra_0(a1, (__int64)&RESET, 4uLL);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1)
{
func8(a1, (__int64)&RESET, 4uLL);
return a1;
}

original_code:
light_bar lb_reset(light_bar fd) {
    lb_write(fd, &RESET, 4);
    return fd;
}

canonical_original_code:
int lb_reset(int fd) {
    lb_write(fd, &RESET, 4);
    return fd;
}


decompiled_code:
__int64 __fastcall set_progress(unsigned int a1, int a2, int a3)
{
int v4; // [rsp+8h] [rbp-10h] BYREF
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = a2;
v4 = a3;
lb_write_isra_0(a1, (__int64)&PROGRESS, 4uLL);
lb_write_isra_0(a1, (__int64)v5, 4uLL);
lb_write_isra_0(a1, (__int64)&v4, 4uLL);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1, int a2, int a3)
{
int v4; // [rsp+8h] [rbp-10h] BYREF
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = a2;
v4 = a3;
func8(a1, (__int64)&PROGRESS, 4uLL);
func8(a1, (__int64)v5, 4uLL);
func8(a1, (__int64)&v4, 4uLL);
return a1;
}

original_code:
light_bar set_progress(light_bar fd, uint32_t numerator, uint32_t denominator) {
    lb_write(fd, &PROGRESS, 4);
    lb_write(fd, &numerator, 4);
    lb_write(fd, &denominator, 4);
    return fd;
}

canonical_original_code:
int set_progress(int fd, unsigned int numerator, unsigned int denominator) {
    lb_write(fd, &PROGRESS, 4);
    lb_write(fd, &numerator, 4);
    lb_write(fd, &denominator, 4);
    return fd;
}

variable_types:
numerator
unsigned int

variable_types:
denominator
unsigned int


decompiled_code:
__int64 __fastcall set_random(unsigned int a1)
{
lb_write_isra_0(a1, (__int64)&RANDOM, 4uLL);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned int a1)
{
func8(a1, (__int64)&RANDOM, 4uLL);
return a1;
}

original_code:
light_bar set_random(light_bar fd) {
    lb_write(fd, &RANDOM, 4);
    return fd;
}

canonical_original_code:
int set_random(int fd) {
    lb_write(fd, &RANDOM, 4);
    return fd;
}


decompiled_code:
__int64 __fastcall set_solid(unsigned int a1, int a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
lb_write_isra_0(a1, (__int64)&SOLID, 4uLL);
lb_write_isra_0(a1, (__int64)v3, 4uLL);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int a1, int a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
func8(a1, (__int64)&SOLID, 4uLL);
func8(a1, (__int64)v3, 4uLL);
return a1;
}

original_code:
light_bar set_solid(light_bar fd, uint32_t color) {
    lb_write(fd, &SOLID, 4);
    lb_write(fd, &color, 4);
    return fd;
}

canonical_original_code:
int set_solid(int fd, unsigned int color) {
    lb_write(fd, &SOLID, 4);
    lb_write(fd, &color, 4);
    return fd;
}

variable_types:
color
unsigned int


decompiled_code:
__int64 __fastcall set_custom(unsigned int a1, __int64 a2, __int64 a3)
{
__int64 v5; // rbp

lb_write_isra_0(a1, (__int64)&CUSTOM, 4uLL);
if ( a3 )
{
v5 = 0LL;
do
{
++v5;
lb_write_isra_0(a1, a2, 4uLL);
a2 += 4LL;
}
while ( a3 != v5 );
}
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1, __int64 a2, __int64 a3)
{
__int64 v5; // rbp

func8(a1, (__int64)&CUSTOM, 4uLL);
if ( a3 )
{
v5 = 0LL;
do
{
++v5;
func8(a1, a2, 4uLL);
a2 += 4LL;
}
while ( a3 != v5 );
}
return a1;
}

original_code:
light_bar set_custom(light_bar fd, uint32_t *colors, size_t size) {
    lb_write(fd, &CUSTOM, 4);
    for (size_t i = 0; i < size; ++i) {
        lb_write(fd, colors + i, 4);
    }
    return fd;
}

canonical_original_code:
int set_custom(int fd, unsigned int *colors, unsigned long size) {
    lb_write(fd, &CUSTOM, 4);
    for (unsigned long i = 0; i < size; ++i) {
        lb_write(fd, colors + i, 4);
    }
    return fd;
}

variable_types:
colors
unsigned int *

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall set_pixel(unsigned int a1, char a2, char a3)
{
char v4[4]; // [rsp+8h] [rbp-10h] BYREF
char v5[12]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = a2;
v4[0] = a3;
lb_write_isra_0(a1, (__int64)v5, 1uLL);
lb_write_isra_0(a1, (__int64)v4, 1uLL);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1, char a2, char a3)
{
char v4[4]; // [rsp+8h] [rbp-10h] BYREF
char v5[12]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = a2;
v4[0] = a3;
func8(a1, (__int64)v5, 1uLL);
func8(a1, (__int64)v4, 1uLL);
return a1;
}

original_code:
light_bar set_pixel(light_bar fd, uint8_t pixel, uint8_t brightness) {
    lb_write(fd, &pixel, 1);
    lb_write(fd, &brightness, 1);
    return fd;
}

canonical_original_code:
int set_pixel(int fd, unsigned char pixel, unsigned char brightness) {
    lb_write(fd, &pixel, 1);
    lb_write(fd, &brightness, 1);
    return fd;
}

variable_types:
pixel
unsigned char

variable_types:
brightness
unsigned char


repo: bdauvergne/c-json-parser

decompiled_code:
__int64 __fastcall test_json_content(char *s, int a2, int a3)
{
size_t v4; // rax
__int64 result; // rax
__int16 v6[84]; // [rsp+0h] [rbp-A8h] BYREF

json_parser_init(v6);
v4 = strlen(s);
if ( a2 != (unsigned int)json_parser_execute(v6, s, v4, 100LL) )
_assert_fail("len_consumed == consumed", "test.c", 0x12u, "test_json_content");
result = (unsigned __int16)v6[0];
if ( (unsigned __int16)v6[0] != a3 )
_assert_fail("parser.state == state", "test.c", 0x13u, "test_json_content");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s, int a2, int a3)
{
size_t v4; // rax
__int64 result; // rax
__int16 v6[84]; // [rsp+0h] [rbp-A8h] BYREF

json_parser_init(v6);
v4 = strlen(s);
if ( a2 != (unsigned int)json_parser_execute(v6, s, v4, 100LL) )
_assert_fail("len_consumed == consumed", "test.c", 0x12u, "test_json_content");
result = (unsigned __int16)v6[0];
if ( (unsigned __int16)v6[0] != a3 )
_assert_fail("parser.state == state", "test.c", 0x13u, "test_json_content");
return result;
}

original_code:
void test_json_content (const char *data, int len_consumed, int state) {
  json_parser parser;
  int consumed = 0;
  json_parser_init(&parser);
  consumed = json_parser_execute(&parser, data, strlen(data), 100);
  ((void) sizeof ((len_consumed == consumed) ? 1 : 0), __extension__ ({ if (len_consumed == consumed) ; else __assert_fail ("len_consumed == consumed", "test.c", 18, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((parser.state == state) ? 1 : 0), __extension__ ({ if (parser.state == state) ; else __assert_fail ("parser.state == state", "test.c", 19, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
void test_json_content(char *data, int len_consumed, int state) {
  struct json_parser parser;
  int consumed = 0;
  json_parser_init(&parser);
  consumed = json_parser_execute(&parser, data, strlen(data), 100);
  ((void) sizeof ((len_consumed == consumed) ? 1 : 0), __extension__ ({ if (len_consumed == consumed) ; else __assert_fail ("len_consumed == consumed", "test.c", 18, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((parser.state == state) ? 1 : 0), __extension__ ({ if (parser.state == state) ; else __assert_fail ("parser.state == state", "test.c", 19, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types:
data
char *

variable_types: state int

variable_types: struct json_parser { unsigned short state; unsigned long stack_size; unsigned long nread; unsigned short stop_on_callback; unsigned short error; void *data; char *data_mark; unsigned long data_size; int (*on_array_begin)(struct json_parser *); int (*on_object_begin)(struct json_parser *); int (*on_string)(struct json_parser *, char *at, unsigned long length); int (*on_end)(struct json_parser *); int (*on_separator)(struct json_parser *); int (*on_minus)(struct json_parser *); int (*on_int)(struct json_parser *, char *at, unsigned long length); int (*on_frac)(struct json_parser *, char *at, unsigned long length); int (*on_exp)(struct json_parser *, char *at, unsigned long length); unsigned char stack[-1]; }

variable_types: consumed int


main

canonical_name: main

original_code:
int main (int argc, char **argv) {
  json_parser p;
  test_json_content(json1, strlen(json1), 0);
  test_json_content(json2, strlen(json2), 0);
  test_json_content(json3, strlen(json3), 0);
  test_json_content(json4, 99, 1);
  printf ("Size of json_parser: %u\n", sizeof(json_parser));
}

canonical_original_code:
int main(int argc, char **argv) {
  struct json_parser p;
  test_json_content(json1, strlen(json1), 0);
  test_json_content(json2, strlen(json2), 0);
  test_json_content(json3, strlen(json3), 0);
  test_json_content(json4, 99, 1);
  printf ("Size of json_parser: %u\n", sizeof(json_parser));
}

variable_types: argc int

variable_types:
argv
char **

user_defined_types: struct json_parser { unsigned short state; unsigned long stack_size; unsigned long nread; unsigned short stop_on_callback; unsigned short error; void *data; char *data_mark; unsigned long data_size; int (*on_array_begin)(struct json_parser *); int (*on_object_begin)(struct json_parser *); int (*on_string)(struct json_parser *, char *at, unsigned long length); int (*on_end)(struct json_parser *); int (*on_separator)(struct json_parser *); int (*on_minus)(struct json_parser *); int (*on_int)(struct json_parser *, char *at, unsigned long length); int (*on_frac)(struct json_parser *, char *at, unsigned long length); int (*on_exp)(struct json_parser *, char *at, unsigned long length); unsigned char stack[-1]; }


die

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

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

original_code:
_Bool die ()
{
    return 0;
}

canonical_original_code:
_Bool die()
{
    return 0;
}


live

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

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

original_code:
_Bool live ()
{
    return 1;
}

canonical_original_code:
_Bool live()
{
    return 1;
}


four

decompiled_code:
__int64 four()
{
return live();
}

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

original_code:
_Bool four ()
{
    domorestuff();
    return live();
}

canonical_original_code:
_Bool four()
{
    domorestuff();
    return live();
}


three

decompiled_code:
__int64 three()
{
return four();
}

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

original_code:
_Bool three ()
{
    domorestuff();
    return four();
}

canonical_original_code:
_Bool three()
{
    domorestuff();
    return four();
}


two

decompiled_code:
__int64 __fastcall two(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // eax
int v4; // edx

v2 = three();
v3 = four(a1, a2, v2);
return v4 | v3;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // eax
int v4; // edx

v2 = func9();
v3 = func8(a1, a2, v2);
return v4 | v3;
}

original_code:
_Bool two ()
{
    domorestuff();
    return three() | four();
}

canonical_original_code:
_Bool two()
{
    domorestuff();
    return three() | four();
}


one

decompiled_code:
__int64 __fastcall one(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
int v3; // eax
unsigned int v4; // edx
unsigned int v5; // eax
int v6; // edx

v2 = two(a1, a2);
v3 = three(a1, a2, v2);
v5 = four(a1, a2, v3 | v4);
return v6 | v5;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
int v3; // eax
unsigned int v4; // edx
unsigned int v5; // eax
int v6; // edx

v2 = func10(a1, a2);
v3 = func9(a1, a2, v2);
v5 = func8(a1, a2, v3 | v4);
return v6 | v5;
}

original_code:
_Bool one ()
{
    domorestuff();
    return two() | three() | four();
}

canonical_original_code:
_Bool one()
{
    domorestuff();
    return two() | three() | four();
}


domorestuff

decompiled_code:
void domorestuff()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code:
void domorestuff() {
    strcmp("", "");
    strcoll("","");
    strncmp("", "", 0);
}


dostuff

decompiled_code:
void dostuff()
{
;
}

canonical_decompiled_code:
void func13()
{
;
}

original_code:
void dostuff ()
{
    if(one() | two() | three() | four())
        domorestuff();
}

canonical_original_code:
void dostuff()
{
    if(one() | two() | three() | four())
        domorestuff();
}


main

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

original_code:
int main ()
{
   dostuff();
   return 0;
}

canonical_original_code:
int main()
{
   dostuff();
   return 0;
}


decompiled_code:
__int64 __fastcall function10(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter10;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter10 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function1(a1, a2, a3);
result = (unsigned int)counter10;
if ( counter10 != 2 )
goto LABEL_3;
LABEL_13:
function2();
result = (unsigned int)counter10;
if ( counter10 != 3 )
goto LABEL_4;
LABEL_14:
function3();
result = (unsigned int)counter10;
if ( counter10 != 4 )
goto LABEL_5;
LABEL_15:
function4();
result = (unsigned int)counter10;
if ( counter10 != 5 )
goto LABEL_6;
LABEL_16:
function5();
result = (unsigned int)counter10;
if ( counter10 != 6 )
goto LABEL_7;
LABEL_17:
function6();
result = (unsigned int)counter10;
if ( counter10 != 7 )
goto LABEL_8;
LABEL_18:
function7();
result = (unsigned int)counter10;
if ( counter10 != 8 )
goto LABEL_9;
LABEL_19:
function8();
result = (unsigned int)counter10;
if ( counter10 != 9 )
goto LABEL_10;
LABEL_20:
function9();
result = (unsigned int)counter10;
}
while ( counter10 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter10;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter10 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func15(a1, a2, a3);
result = (unsigned int)counter10;
if ( counter10 != 2 )
goto LABEL_3;
LABEL_13:
func14();
result = (unsigned int)counter10;
if ( counter10 != 3 )
goto LABEL_4;
LABEL_14:
func13();
result = (unsigned int)counter10;
if ( counter10 != 4 )
goto LABEL_5;
LABEL_15:
func12();
result = (unsigned int)counter10;
if ( counter10 != 5 )
goto LABEL_6;
LABEL_16:
func11();
result = (unsigned int)counter10;
if ( counter10 != 6 )
goto LABEL_7;
LABEL_17:
func10();
result = (unsigned int)counter10;
if ( counter10 != 7 )
goto LABEL_8;
LABEL_18:
func9();
result = (unsigned int)counter10;
if ( counter10 != 8 )
goto LABEL_9;
LABEL_19:
func7();
result = (unsigned int)counter10;
if ( counter10 != 9 )
goto LABEL_10;
LABEL_20:
func8();
result = (unsigned int)counter10;
}
while ( counter10 == 10 );
return result;
}

original_code:
void function10()
{
    counter10++;
    if(counter10 == 1)
        function1();
    if(counter10 == 2)
        function2();
    if(counter10 == 3)
        function3();
    if(counter10 == 4)
        function4();
    if(counter10 == 5)
        function5();
    if(counter10 == 6)
        function6();
    if(counter10 == 7)
        function7();
    if(counter10 == 8)
        function8();
    if(counter10 == 9)
        function9();
    if(counter10 == 10)
        function10();
}


decompiled_code:
__int64 __fastcall function8(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter8;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter8 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function9();
result = (unsigned int)counter8;
if ( counter8 != 2 )
goto LABEL_3;
LABEL_13:
function10(a1, a2, a3);
result = (unsigned int)counter8;
if ( counter8 != 3 )
goto LABEL_4;
LABEL_14:
function1(a1, a2, a3);
result = (unsigned int)counter8;
if ( counter8 != 4 )
goto LABEL_5;
LABEL_15:
function2();
result = (unsigned int)counter8;
if ( counter8 != 5 )
goto LABEL_6;
LABEL_16:
function3();
result = (unsigned int)counter8;
if ( counter8 != 6 )
goto LABEL_7;
LABEL_17:
function4();
result = (unsigned int)counter8;
if ( counter8 != 7 )
goto LABEL_8;
LABEL_18:
function5();
result = (unsigned int)counter8;
if ( counter8 != 8 )
goto LABEL_9;
LABEL_19:
function6();
result = (unsigned int)counter8;
if ( counter8 != 9 )
goto LABEL_10;
LABEL_20:
function7();
result = (unsigned int)counter8;
}
while ( counter8 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter8;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter8 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func8();
result = (unsigned int)counter8;
if ( counter8 != 2 )
goto LABEL_3;
LABEL_13:
func6(a1, a2, a3);
result = (unsigned int)counter8;
if ( counter8 != 3 )
goto LABEL_4;
LABEL_14:
func15(a1, a2, a3);
result = (unsigned int)counter8;
if ( counter8 != 4 )
goto LABEL_5;
LABEL_15:
func14();
result = (unsigned int)counter8;
if ( counter8 != 5 )
goto LABEL_6;
LABEL_16:
func13();
result = (unsigned int)counter8;
if ( counter8 != 6 )
goto LABEL_7;
LABEL_17:
func12();
result = (unsigned int)counter8;
if ( counter8 != 7 )
goto LABEL_8;
LABEL_18:
func11();
result = (unsigned int)counter8;
if ( counter8 != 8 )
goto LABEL_9;
LABEL_19:
func10();
result = (unsigned int)counter8;
if ( counter8 != 9 )
goto LABEL_10;
LABEL_20:
func9();
result = (unsigned int)counter8;
}
while ( counter8 == 10 );
return result;
}

original_code:
void function8()
{
    counter8++;
    if(counter8 == 1)
        function9();
    if(counter8 == 2)
        function10();
    if(counter8 == 3)
        function1();
    if(counter8 == 4)
        function2();
    if(counter8 == 5)
        function3();
    if(counter8 == 6)
        function4();
    if(counter8 == 7)
        function5();
    if(counter8 == 8)
        function6();
    if(counter8 == 9)
        function7();
    if(counter8 == 10)
        function8();
}


decompiled_code:
__int64 __fastcall function9(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter9;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter9 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_12;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_13;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_14;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_15;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_16;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_17;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_18;
LABEL_9:
if ( (_DWORD)result != 9 )
return result;
}
function1(a1, a2, a3);
result = (unsigned int)counter9;
if ( counter9 != 2 )
goto LABEL_3;
LABEL_12:
function2();
result = (unsigned int)counter9;
if ( counter9 != 3 )
goto LABEL_4;
LABEL_13:
function3();
result = (unsigned int)counter9;
if ( counter9 != 4 )
goto LABEL_5;
LABEL_14:
function4();
result = (unsigned int)counter9;
if ( counter9 != 5 )
goto LABEL_6;
LABEL_15:
function5();
result = (unsigned int)counter9;
if ( counter9 != 6 )
goto LABEL_7;
LABEL_16:
function6();
result = (unsigned int)counter9;
if ( counter9 != 7 )
goto LABEL_8;
LABEL_17:
function7();
result = (unsigned int)counter9;
if ( counter9 != 8 )
goto LABEL_9;
LABEL_18:
function8(a1, a2, a3);
result = (unsigned int)counter9;
}
while ( counter9 == 9 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter9;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter9 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_12;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_13;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_14;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_15;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_16;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_17;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_18;
LABEL_9:
if ( (_DWORD)result != 9 )
return result;
}
func15(a1, a2, a3);
result = (unsigned int)counter9;
if ( counter9 != 2 )
goto LABEL_3;
LABEL_12:
func14();
result = (unsigned int)counter9;
if ( counter9 != 3 )
goto LABEL_4;
LABEL_13:
func13();
result = (unsigned int)counter9;
if ( counter9 != 4 )
goto LABEL_5;
LABEL_14:
func12();
result = (unsigned int)counter9;
if ( counter9 != 5 )
goto LABEL_6;
LABEL_15:
func11();
result = (unsigned int)counter9;
if ( counter9 != 6 )
goto LABEL_7;
LABEL_16:
func10();
result = (unsigned int)counter9;
if ( counter9 != 7 )
goto LABEL_8;
LABEL_17:
func9();
result = (unsigned int)counter9;
if ( counter9 != 8 )
goto LABEL_9;
LABEL_18:
func7(a1, a2, a3);
result = (unsigned int)counter9;
}
while ( counter9 == 9 );
return result;
}

original_code:
void function9()
{
    counter9++;
    if(counter9 == 1)
        function1();
    if(counter9 == 2)
        function2();
    if(counter9 == 3)
        function3();
    if(counter9 == 4)
        function4();
    if(counter9 == 5)
        function5();
    if(counter9 == 6)
        function6();
    if(counter9 == 7)
        function7();
    if(counter9 == 8)
        function8();
    if(counter9 == 9)
        function9();
}


decompiled_code:
__int64 __fastcall function7(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter7;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter7 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function8(a1, a2, a3);
result = (unsigned int)counter7;
if ( counter7 != 2 )
goto LABEL_3;
LABEL_13:
function9(a1, a2, a3);
result = (unsigned int)counter7;
if ( counter7 != 3 )
goto LABEL_4;
LABEL_14:
function10(a1, a2, a3);
result = (unsigned int)counter7;
if ( counter7 != 4 )
goto LABEL_5;
LABEL_15:
function1(a1, a2, a3);
result = (unsigned int)counter7;
if ( counter7 != 5 )
goto LABEL_6;
LABEL_16:
function2();
result = (unsigned int)counter7;
if ( counter7 != 6 )
goto LABEL_7;
LABEL_17:
function3();
result = (unsigned int)counter7;
if ( counter7 != 7 )
goto LABEL_8;
LABEL_18:
function4();
result = (unsigned int)counter7;
if ( counter7 != 8 )
goto LABEL_9;
LABEL_19:
function5();
result = (unsigned int)counter7;
if ( counter7 != 9 )
goto LABEL_10;
LABEL_20:
function6();
result = (unsigned int)counter7;
}
while ( counter7 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter7;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter7 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func7(a1, a2, a3);
result = (unsigned int)counter7;
if ( counter7 != 2 )
goto LABEL_3;
LABEL_13:
func8(a1, a2, a3);
result = (unsigned int)counter7;
if ( counter7 != 3 )
goto LABEL_4;
LABEL_14:
func6(a1, a2, a3);
result = (unsigned int)counter7;
if ( counter7 != 4 )
goto LABEL_5;
LABEL_15:
func15(a1, a2, a3);
result = (unsigned int)counter7;
if ( counter7 != 5 )
goto LABEL_6;
LABEL_16:
func14();
result = (unsigned int)counter7;
if ( counter7 != 6 )
goto LABEL_7;
LABEL_17:
func13();
result = (unsigned int)counter7;
if ( counter7 != 7 )
goto LABEL_8;
LABEL_18:
func12();
result = (unsigned int)counter7;
if ( counter7 != 8 )
goto LABEL_9;
LABEL_19:
func11();
result = (unsigned int)counter7;
if ( counter7 != 9 )
goto LABEL_10;
LABEL_20:
func10();
result = (unsigned int)counter7;
}
while ( counter7 == 10 );
return result;
}

original_code:
void function7()
{
    counter7++;
    if(counter7 == 1)
        function8();
    if(counter7 == 2)
        function9();
    if(counter7 == 3)
        function10();
    if(counter7 == 4)
        function1();
    if(counter7 == 5)
        function2();
    if(counter7 == 6)
        function3();
    if(counter7 == 7)
        function4();
    if(counter7 == 8)
        function5();
    if(counter7 == 9)
        function6();
    if(counter7 == 10)
        function7();
}


decompiled_code:
__int64 __fastcall function6(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter6;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter6 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function7(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 2 )
goto LABEL_3;
LABEL_13:
function8(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 3 )
goto LABEL_4;
LABEL_14:
function9(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 4 )
goto LABEL_5;
LABEL_15:
function10(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 5 )
goto LABEL_6;
LABEL_16:
function1(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 6 )
goto LABEL_7;
LABEL_17:
function2();
result = (unsigned int)counter6;
if ( counter6 != 7 )
goto LABEL_8;
LABEL_18:
function3();
result = (unsigned int)counter6;
if ( counter6 != 8 )
goto LABEL_9;
LABEL_19:
function4();
result = (unsigned int)counter6;
if ( counter6 != 9 )
goto LABEL_10;
LABEL_20:
function5();
result = (unsigned int)counter6;
}
while ( counter6 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter6;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter6 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func9(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 2 )
goto LABEL_3;
LABEL_13:
func7(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 3 )
goto LABEL_4;
LABEL_14:
func8(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 4 )
goto LABEL_5;
LABEL_15:
func6(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 5 )
goto LABEL_6;
LABEL_16:
func15(a1, a2, a3);
result = (unsigned int)counter6;
if ( counter6 != 6 )
goto LABEL_7;
LABEL_17:
func14();
result = (unsigned int)counter6;
if ( counter6 != 7 )
goto LABEL_8;
LABEL_18:
func13();
result = (unsigned int)counter6;
if ( counter6 != 8 )
goto LABEL_9;
LABEL_19:
func12();
result = (unsigned int)counter6;
if ( counter6 != 9 )
goto LABEL_10;
LABEL_20:
func11();
result = (unsigned int)counter6;
}
while ( counter6 == 10 );
return result;
}

original_code:
void function6()
{
    counter6++;
    if(counter6 == 1)
        function7();
    if(counter6 == 2)
        function8();
    if(counter6 == 3)
        function9();
    if(counter6 == 4)
        function10();
    if(counter6 == 5)
        function1();
    if(counter6 == 6)
        function2();
    if(counter6 == 7)
        function3();
    if(counter6 == 8)
        function4();
    if(counter6 == 9)
        function5();
    if(counter6 == 10)
        function6();
}


decompiled_code:
__int64 __fastcall function5(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter5;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter5 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function6(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 2 )
goto LABEL_3;
LABEL_13:
function7(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 3 )
goto LABEL_4;
LABEL_14:
function8(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 4 )
goto LABEL_5;
LABEL_15:
function9(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 5 )
goto LABEL_6;
LABEL_16:
function10(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 6 )
goto LABEL_7;
LABEL_17:
function1(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 7 )
goto LABEL_8;
LABEL_18:
function2();
result = (unsigned int)counter5;
if ( counter5 != 8 )
goto LABEL_9;
LABEL_19:
function3();
result = (unsigned int)counter5;
if ( counter5 != 9 )
goto LABEL_10;
LABEL_20:
function4();
result = (unsigned int)counter5;
}
while ( counter5 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter5;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter5 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func10(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 2 )
goto LABEL_3;
LABEL_13:
func9(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 3 )
goto LABEL_4;
LABEL_14:
func7(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 4 )
goto LABEL_5;
LABEL_15:
func8(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 5 )
goto LABEL_6;
LABEL_16:
func6(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 6 )
goto LABEL_7;
LABEL_17:
func15(a1, a2, a3);
result = (unsigned int)counter5;
if ( counter5 != 7 )
goto LABEL_8;
LABEL_18:
func14();
result = (unsigned int)counter5;
if ( counter5 != 8 )
goto LABEL_9;
LABEL_19:
func13();
result = (unsigned int)counter5;
if ( counter5 != 9 )
goto LABEL_10;
LABEL_20:
func12();
result = (unsigned int)counter5;
}
while ( counter5 == 10 );
return result;
}

original_code:
void function5()
{
    counter5++;
    if(counter5 == 1)
        function6();
    if(counter5 == 2)
        function7();
    if(counter5 == 3)
        function8();
    if(counter5 == 4)
        function9();
    if(counter5 == 5)
        function10();
    if(counter5 == 6)
        function1();
    if(counter5 == 7)
        function2();
    if(counter5 == 8)
        function3();
    if(counter5 == 9)
        function4();
    if(counter5 == 10)
        function5();
}


decompiled_code:
__int64 __fastcall function4(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter4;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter4 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function5(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 2 )
goto LABEL_3;
LABEL_13:
function6(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 3 )
goto LABEL_4;
LABEL_14:
function7(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 4 )
goto LABEL_5;
LABEL_15:
function8(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 5 )
goto LABEL_6;
LABEL_16:
function9(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 6 )
goto LABEL_7;
LABEL_17:
function10(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 7 )
goto LABEL_8;
LABEL_18:
function1(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 8 )
goto LABEL_9;
LABEL_19:
function2();
result = (unsigned int)counter4;
if ( counter4 != 9 )
goto LABEL_10;
LABEL_20:
function3();
result = (unsigned int)counter4;
}
while ( counter4 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter4;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter4 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func11(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 2 )
goto LABEL_3;
LABEL_13:
func10(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 3 )
goto LABEL_4;
LABEL_14:
func9(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 4 )
goto LABEL_5;
LABEL_15:
func7(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 5 )
goto LABEL_6;
LABEL_16:
func8(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 6 )
goto LABEL_7;
LABEL_17:
func6(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 7 )
goto LABEL_8;
LABEL_18:
func15(a1, a2, a3);
result = (unsigned int)counter4;
if ( counter4 != 8 )
goto LABEL_9;
LABEL_19:
func14();
result = (unsigned int)counter4;
if ( counter4 != 9 )
goto LABEL_10;
LABEL_20:
func13();
result = (unsigned int)counter4;
}
while ( counter4 == 10 );
return result;
}

original_code:
void function4()
{
    counter4++;
    if(counter4 == 1)
        function5();
    if(counter4 == 2)
        function6();
    if(counter4 == 3)
        function7();
    if(counter4 == 4)
        function8();
    if(counter4 == 5)
        function9();
    if(counter4 == 6)
        function10();
    if(counter4 == 7)
        function1();
    if(counter4 == 8)
        function2();
    if(counter4 == 9)
        function3();
    if(counter4 == 10)
        function4();
}


decompiled_code:
__int64 __fastcall function3(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter3;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter3 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function4(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 2 )
goto LABEL_3;
LABEL_13:
function5(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 3 )
goto LABEL_4;
LABEL_14:
function6(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 4 )
goto LABEL_5;
LABEL_15:
function7(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 5 )
goto LABEL_6;
LABEL_16:
function8(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 6 )
goto LABEL_7;
LABEL_17:
function9(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 7 )
goto LABEL_8;
LABEL_18:
function10(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 8 )
goto LABEL_9;
LABEL_19:
function1(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 9 )
goto LABEL_10;
LABEL_20:
function2();
result = (unsigned int)counter3;
}
while ( counter3 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter3;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter3 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func12(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 2 )
goto LABEL_3;
LABEL_13:
func11(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 3 )
goto LABEL_4;
LABEL_14:
func10(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 4 )
goto LABEL_5;
LABEL_15:
func9(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 5 )
goto LABEL_6;
LABEL_16:
func7(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 6 )
goto LABEL_7;
LABEL_17:
func8(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 7 )
goto LABEL_8;
LABEL_18:
func6(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 8 )
goto LABEL_9;
LABEL_19:
func15(a1, a2, a3);
result = (unsigned int)counter3;
if ( counter3 != 9 )
goto LABEL_10;
LABEL_20:
func14();
result = (unsigned int)counter3;
}
while ( counter3 == 10 );
return result;
}

original_code:
void function3()
{
    counter3++;
    if(counter3 == 1)
        function4();
    if(counter3 == 2)
        function5();
    if(counter3 == 3)
        function6();
    if(counter3 == 4)
        function7();
    if(counter3 == 5)
        function8();
    if(counter3 == 6)
        function9();
    if(counter3 == 7)
        function10();
    if(counter3 == 8)
        function1();
    if(counter3 == 9)
        function2();
    if(counter3 == 10)
        function3();
}


decompiled_code:
__int64 __fastcall function2(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter2;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter2 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function3(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 2 )
goto LABEL_3;
LABEL_13:
function4(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 3 )
goto LABEL_4;
LABEL_14:
function5(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 4 )
goto LABEL_5;
LABEL_15:
function6(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 5 )
goto LABEL_6;
LABEL_16:
function7(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 6 )
goto LABEL_7;
LABEL_17:
function8(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 7 )
goto LABEL_8;
LABEL_18:
function9(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 8 )
goto LABEL_9;
LABEL_19:
function10(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 9 )
goto LABEL_10;
LABEL_20:
function1(a1, a2, a3);
result = (unsigned int)counter2;
}
while ( counter2 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter2;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter2 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func13(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 2 )
goto LABEL_3;
LABEL_13:
func12(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 3 )
goto LABEL_4;
LABEL_14:
func11(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 4 )
goto LABEL_5;
LABEL_15:
func10(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 5 )
goto LABEL_6;
LABEL_16:
func9(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 6 )
goto LABEL_7;
LABEL_17:
func7(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 7 )
goto LABEL_8;
LABEL_18:
func8(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 8 )
goto LABEL_9;
LABEL_19:
func6(a1, a2, a3);
result = (unsigned int)counter2;
if ( counter2 != 9 )
goto LABEL_10;
LABEL_20:
func15(a1, a2, a3);
result = (unsigned int)counter2;
}
while ( counter2 == 10 );
return result;
}

original_code:
void function2()
{
    counter2++;
    if(counter2 == 1)
        function3();
    if(counter2 == 2)
        function4();
    if(counter2 == 3)
        function5();
    if(counter2 == 4)
        function6();
    if(counter2 == 5)
        function7();
    if(counter2 == 6)
        function8();
    if(counter2 == 7)
        function9();
    if(counter2 == 8)
        function10();
    if(counter2 == 9)
        function1();
    if(counter2 == 10)
        function2();
}


decompiled_code:
__int64 __fastcall function1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter1;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter1 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
function2(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 2 )
goto LABEL_3;
LABEL_13:
function3(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 3 )
goto LABEL_4;
LABEL_14:
function4(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 4 )
goto LABEL_5;
LABEL_15:
function5(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 5 )
goto LABEL_6;
LABEL_16:
function6(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 6 )
goto LABEL_7;
LABEL_17:
function7(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 7 )
goto LABEL_8;
LABEL_18:
function8(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 8 )
goto LABEL_9;
LABEL_19:
function9(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 9 )
goto LABEL_10;
LABEL_20:
function10(a1, a2, a3);
result = (unsigned int)counter1;
}
while ( counter1 == 10 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

LODWORD(result) = counter1;
do
{
while ( 1 )
{
result = (unsigned int)(result + 1);
counter1 = result;
if ( (_DWORD)result == 1 )
break;
if ( (_DWORD)result == 2 )
goto LABEL_13;
LABEL_3:
if ( (_DWORD)result == 3 )
goto LABEL_14;
LABEL_4:
if ( (_DWORD)result == 4 )
goto LABEL_15;
LABEL_5:
if ( (_DWORD)result == 5 )
goto LABEL_16;
LABEL_6:
if ( (_DWORD)result == 6 )
goto LABEL_17;
LABEL_7:
if ( (_DWORD)result == 7 )
goto LABEL_18;
LABEL_8:
if ( (_DWORD)result == 8 )
goto LABEL_19;
LABEL_9:
if ( (_DWORD)result == 9 )
goto LABEL_20;
LABEL_10:
if ( (_DWORD)result != 10 )
return result;
}
func14(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 2 )
goto LABEL_3;
LABEL_13:
func13(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 3 )
goto LABEL_4;
LABEL_14:
func12(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 4 )
goto LABEL_5;
LABEL_15:
func11(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 5 )
goto LABEL_6;
LABEL_16:
func10(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 6 )
goto LABEL_7;
LABEL_17:
func9(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 7 )
goto LABEL_8;
LABEL_18:
func7(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 8 )
goto LABEL_9;
LABEL_19:
func8(a1, a2, a3);
result = (unsigned int)counter1;
if ( counter1 != 9 )
goto LABEL_10;
LABEL_20:
func6(a1, a2, a3);
result = (unsigned int)counter1;
}
while ( counter1 == 10 );
return result;
}

original_code:
void function1()
{
    counter1++;
    if(counter1 == 1)
        function2();
    if(counter1 == 2)
        function3();
    if(counter1 == 3)
        function4();
    if(counter1 == 4)
        function5();
    if(counter1 == 5)
        function6();
    if(counter1 == 6)
        function7();
    if(counter1 == 7)
        function8();
    if(counter1 == 8)
        function9();
    if(counter1 == 9)
        function10();
    if(counter1 == 10)
        function1();
}


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

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

original_code:
int main ()
{
    function1();
    return 0;
}

canonical_original_code:
int main()
{
    function1();
    return 0;
}


decompiled_code:
_QWORD *make_string_array()
{
_QWORD *v0; // r12
_QWORD *v1; // rbp
_BYTE *v2; // rax
_BYTE *v3; // rcx
_BYTE *v4; // rdx

v0 = malloc(0x50uLL);
v1 = v0;
do
{
v2 = malloc(0xAuLL);
v3 = v2;
v4 = v2 + 10;
do
*v2++ = 88;
while ( v4 != v2 );
*v1++ = v3;
}
while ( v1 != v0 + 10 );
return v0;
}

canonical_decompiled_code:
_QWORD *func7()
{
_QWORD *v0; // r12
_QWORD *v1; // rbp
_BYTE *v2; // rax
_BYTE *v3; // rcx
_BYTE *v4; // rdx

v0 = malloc(0x50uLL);
v1 = v0;
do
{
v2 = malloc(0xAuLL);
v3 = v2;
v4 = v2 + 10;
do
*v2++ = 88;
while ( v4 != v2 );
*v1++ = v3;
}
while ( v1 != v0 + 10 );
return v0;
}

original_code:
char** make_string_array ()
{
    char ** string_array = malloc(sizeof(char*)*10);
    int i = 0;
    for(;i < 10;i++) {
        char* str = (char*) malloc(10);
        int j = 0;
        for(;j < 10;j++) {
            *(str+j) = 'X';
        }
        *(string_array+i) = str;
    }
    return string_array;
}

canonical_original_code:
char **make_string_array()
{
    char **string_array = malloc(sizeof(char*)*10);
    int i = 0;
    for(;i < 10;i++) {
        char *str = (char*) malloc(10);
        int j = 0;
        for(;j < 10;j++) {
            *(str+j) = 'X';
        }
        *(string_array+i) = str;
    }
    return string_array;
}

variable_types: i int

variable_types:
str
char *

variable_types: j int

return_type: char **


decompiled_code:
int __fastcall print_string_array(const char **a1)
{
const char **v1; // rbx
const char *v2; // rsi
int result; // eax

v1 = a1;
puts("Strings:");
do
{
v2 = *v1++;
result = printf("\t\"%s\"\n", v2);
}
while ( v1 != a1 + 10 );
return result;
}

canonical_decompiled_code:
int __fastcall func8(const char **a1)
{
const char **v1; // rbx
const char *v2; // rsi
int result; // eax

v1 = a1;
puts("Strings:");
do
{
v2 = *v1++;
result = printf("\t\"%s\"\n", v2);
}
while ( v1 != a1 + 10 );
return result;
}

original_code:
void print_string_array (char **arr)
{
    printf("Strings:\n");
    int i = 0;
    for(; i < 10; i++) {
        printf("\t\"%s\"\n", *(arr+i));
    }
}

canonical_original_code:
void print_string_array(char **arr)
{
    printf("Strings:\n");
    int i = 0;
    for(; i < 10; i++) {
        printf("\t\"%s\"\n", *(arr+i));
    }
}

variable_types:
arr
char **


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

v3 = make_string_array(argc, argv, envp);
print_string_array(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax

v3 = func7(argc, argv, envp);
func8(v3);
return 0;
}

original_code:
int main (int argc, char **argv)
{
    char **res = make_string_array();
    print_string_array(res);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    char **res = make_string_array();
    print_string_array(res);
    return 0;
}

variable_types:
res
char **


decompiled_code:
void __fastcall __noreturn thread_1(void *a1)
{
int v1; // ebx
unsigned int v2; // eax
struct timeval v3; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v3, 0LL);
time_list[2 * (int)a1] = v3.tv_usec + 1000000 * v3.tv_sec;
v1 = 1000000;
v2 = getpid();
printf("Before Context Switch Time %llu, pid %d\n", v3.tv_usec + 1000000 * v3.tv_sec, v2);
do
{
sched_yield();
--v1;
}
while ( v1 );
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(void *a1)
{
int v1; // ebx
unsigned int v2; // eax
struct timeval v3; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v3, 0LL);
time_list[2 * (int)a1] = v3.tv_usec + 1000000 * v3.tv_sec;
v1 = 1000000;
v2 = getpid();
printf("Before Context Switch Time %llu, pid %d\n", v3.tv_usec + 1000000 * v3.tv_sec, v2);
do
{
sched_yield();
--v1;
}
while ( v1 );
pthread_exit(0LL);
}

original_code:
void *thread_1(void *arg)
{
 int i, th_num = (int)arg;
 struct timeval tv;
 gettimeofday(&tv, ((void *)0));
 time_list[th_num][0] = tv.tv_usec+tv.tv_sec*1000000;
 printf("Before Context Switch Time %llu, pid %d\n", (tv.tv_usec+tv.tv_sec*1000000), getpid());
 for (i = 0; i < 1000000; i++) {
  sched_yield();
 }
 pthread_exit(0);
}

canonical_original_code:
void *thread_1(void *arg)
{
 int i; int th_num = (int)arg;
 struct timeval tv;
 gettimeofday(&tv, ((void *)0));
 time_list[th_num][0] = tv.tv_usec+tv.tv_sec*1000000;
 printf("Before Context Switch Time %llu, pid %d\n", (tv.tv_usec+tv.tv_sec*1000000), getpid());
 for (i = 0; i < 1000000; i++) {
  sched_yield();
 }
 pthread_exit(0);
}

variable_types:
arg
void *

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

return_type: void *


decompiled_code:
void __fastcall __noreturn thread_2(void *a1)
{
int v1; // ebx
unsigned int v2; // eax
struct timeval v3; // [rsp+0h] [rbp-28h] BYREF

v1 = 1000000;
do
{
sched_yield();
--v1;
}
while ( v1 );
gettimeofday(&v3, 0LL);
qword_4040A8[2 * (int)a1] = v3.tv_usec + 1000000 * v3.tv_sec;
v2 = getpid();
printf("After Context Switch Time %llu, pid %d\n", v3.tv_usec + 1000000 * v3.tv_sec, v2);
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(void *a1)
{
int v1; // ebx
unsigned int v2; // eax
struct timeval v3; // [rsp+0h] [rbp-28h] BYREF

v1 = 1000000;
do
{
sched_yield();
--v1;
}
while ( v1 );
gettimeofday(&v3, 0LL);
qword_4040A8[2 * (int)a1] = v3.tv_usec + 1000000 * v3.tv_sec;
v2 = getpid();
printf("After Context Switch Time %llu, pid %d\n", v3.tv_usec + 1000000 * v3.tv_sec, v2);
pthread_exit(0LL);
}

original_code:
void *thread_2(void *arg)
{
 int i, th_num = (int)arg;
 struct timeval tv;
 for (i = 0; i < 1000000; i++) {
  sched_yield();
 }
 gettimeofday(&tv, ((void *)0));
 time_list[th_num][1] = tv.tv_usec+tv.tv_sec*1000000;
 printf("After Context Switch Time %llu, pid %d\n", (tv.tv_usec+tv.tv_sec*1000000), getpid());
 pthread_exit(0);
}

canonical_original_code:
void *thread_2(void *arg)
{
 int i; int th_num = (int)arg;
 struct timeval tv;
 for (i = 0; i < 1000000; i++) {
  sched_yield();
 }
 gettimeofday(&tv, ((void *)0));
 time_list[th_num][1] = tv.tv_usec+tv.tv_sec*1000000;
 printf("After Context Switch Time %llu, pid %d\n", (tv.tv_usec+tv.tv_sec*1000000), getpid());
 pthread_exit(0);
}

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


rdtsc

decompiled_code:
__int64 rdtsc()
{
return (unsigned int)__rdtsc();
}

canonical_decompiled_code:
__int64 func9()
{
return (unsigned int)__rdtsc();
}

original_code:
long long rdtsc()
{
    __asm("rdtsc");
}

canonical_original_code:
long long rdtsc()
{
    __asm("rdtsc");
}

return_type: long long


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int *v3; // rbx
__pid_t v4; // eax
int *v5; // rbp
int *v6; // rdi
int *v7; // rdi
int *v8; // rbp
char *v9; // rbx
pthread_t *v10; // r12
pthread_t *v11; // rdi
char *v12; // rcx
pthread_t v13; // rdi
unsigned __int64 v14; // rbx
struct sched_param param; // [rsp+Ch] [rbp-3Ch] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF
struct timeval v18; // [rsp+20h] [rbp-28h] BYREF

v3 = fd_list;
param.__sched_priority = 0;
v4 = getpid();
sched_setscheduler(v4, 1, &param);
memset(fd_list, 0, 0x640uLL);
v5 = p_list;
memset(p_list, 0, 0x640uLL);
do
{
v6 = v3;
v3 += 2;
pipe(v6);
v7 = v5;
v5 += 2;
pipe(v7);
}
while ( v3 != (int *)&end );
v8 = (int *)&th_list;
v9 = 0LL;
gettimeofday(&tv, 0LL);
v10 = &th_list;
do
{
pthread_create(v10, 0LL, thread_1, v9);
v11 = v10 + 1;
v12 = v9++;
v10 += 2;
pthread_create(v11, 0LL, thread_2, v12);
}
while ( v9 != (char *)200 );
do
{
v13 = *(_QWORD *)v8;
v8 += 4;
pthread_join(v13, 0LL);
pthread_join(*((_QWORD *)v8 - 1), 0LL);
}
while ( v8 != p_list );
gettimeofday(&v18, 0LL);
v14 = v18.tv_usec + 1000000 * v18.tv_sec - (tv.tv_usec + 1000000 * tv.tv_sec);
printf("total time %llu\n", v14);
printf("switch count:%llu\n", 400000000LL);
printf("thread switch time %llu\n", v14 / 0x17D78400);
return 0;
}

original_code:
int main()
{
 int i;
 unsigned long time_total;
 struct timeval tv_begin, tv_end;
 struct sched_param param;
 param.sched_priority = 0;
 sched_setscheduler(getpid(), 1, &param);
 memset(fd_list, '\0', 200*sizeof(int)*2);
 memset(p_list, '\0', 200*sizeof(int)*2);
 for (i=0; i<200; i++) {
  pipe(fd_list[i]);
  pipe(p_list[i]);
 }
 gettimeofday(&tv_begin, ((void *)0));
 for (i=0; i<200; i++) {
  pthread_create(&th_list[i][0], ((void *)0), thread_1, (void *)i);
  pthread_create(&th_list[i][1], ((void *)0), thread_2, (void *)i);
 }
 for (i=0; i<200; i++) {
  pthread_join(th_list[i][0], ((void *)0));
  pthread_join(th_list[i][1], ((void *)0));
 }
 gettimeofday(&tv_end, ((void *)0));
 time_total = (tv_end.tv_usec+tv_end.tv_sec*1000000) - (tv_begin.tv_usec+tv_begin.tv_sec*1000000);
 printf("total time %llu\n", time_total);
 printf("switch count:%llu\n", 200*1000000*2);
 printf("thread switch time %llu\n", time_total/(200*1000000*2));
 return 0;
}

canonical_original_code:
int main()
{
 int i;
 unsigned long time_total;
 struct timeval tv_begin; struct timeval tv_end;
 struct sched_param param;
 param.sched_priority = 0;
 sched_setscheduler(getpid(), 1, &param);
 memset(fd_list, '\0', 200*sizeof(int)*2);
 memset(p_list, '\0', 200*sizeof(int)*2);
 for (i=0; i<200; i++) {
  pipe(fd_list[i]);
  pipe(p_list[i]);
 }
 gettimeofday(&tv_begin, ((void *)0));
 for (i=0; i<200; i++) {
  pthread_create(&th_list[i][0], ((void *)0), thread_1, (void *)i);
  pthread_create(&th_list[i][1], ((void *)0), thread_2, (void *)i);
 }
 for (i=0; i<200; i++) {
  pthread_join(th_list[i][0], ((void *)0));
  pthread_join(th_list[i][1], ((void *)0));
 }
 gettimeofday(&tv_end, ((void *)0));
 time_total = (tv_end.tv_usec+tv_end.tv_sec*1000000) - (tv_begin.tv_usec+tv_begin.tv_sec*1000000);
 printf("total time %llu\n", time_total);
 printf("switch count:%llu\n", 200*1000000*2);
 printf("thread switch time %llu\n", time_total/(200*1000000*2));
 return 0;
}

variable_types: struct sched_param { int sched_priority; }


decompiled_code:
int test_mremap()
{
unsigned int v0; // eax
void *v1; // rax
__int64 v2; // rbx
int result; // eax
int *v4; // rbx
char *v5; // rax

v0 = getpagesize();
printf("Page size:%d.\n", v0);
v1 = valloc(0x1000uLL);
if ( v1 )
{
v2 = (__int64)v1;
result = printf("valloc memory address:\t\t%p\n", v1);
valoc_mem = v2;
}
else
{
printf("Can not alloc memory from valloc.");
v4 = __errno_location();
v5 = strerror(*v4);
result = printf(" (%d:%s)\n", (unsigned int)*v4, v5);
}
return result;
}

canonical_decompiled_code:
int func7()
{
unsigned int v0; // eax
void *v1; // rax
__int64 v2; // rbx
int result; // eax
int *v4; // rbx
char *v5; // rax

v0 = getpagesize();
printf("Page size:%d.\n", v0);
v1 = valloc(0x1000uLL);
if ( v1 )
{
v2 = (__int64)v1;
result = printf("valloc memory address:\t\t%p\n", v1);
valoc_mem = v2;
}
else
{
printf("Can not alloc memory from valloc.");
v4 = __errno_location();
v5 = strerror(*v4);
result = printf(" (%d:%s)\n", (unsigned int)*v4, v5);
}
return result;
}

original_code:
void
test_mremap(void)
{
 int page_size;
 void *buf;
 void *buf_new;
 char *p;
 int i;
 page_size = getpagesize();
 printf("Page size:%d.\n", page_size);
 buf = valloc(4096);
 if(!buf) {
  do { printf("Can not alloc memory from valloc."); printf(" (%d:%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  goto failed;
 }
 printf("valloc memory address:\t\t%p\n", buf);
 valoc_mem = buf;
failed:
 return;
}

canonical_original_code:
void test_mremap()
{
 int page_size;
 void *buf;
 void *buf_new;
 char *p;
 int i;
 page_size = getpagesize();
 printf("Page size:%d.\n", page_size);
 buf = valloc(4096);
 if(!buf) {
  do { printf("Can not alloc memory from valloc."); printf(" (%d:%s)\n", (*__errno_location ()), strerror((*__errno_location ()))); } while(0);
  goto failed;
 }
 printf("valloc memory address:\t\t%p\n", buf);
 valoc_mem = buf;
failed:
 return;
}

variable_types:
buf
void *

variable_types:
p
char *