triadd

decompiled_code:
__int64 __fastcall triadd(unsigned int a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // eax
void *v5; // rbx
unsigned int v6; // eax
__int64 result; // rax
void **v8; // [rsp+8h] [rbp-30h] BYREF

v4 = init_lib(&v8);
if ( v4 )
{
printf("!! load symbol add failed: %d\n", v4);
result = 0LL;
}
else
{
v5 = v8[1];
v6 = ((__int64 (__fastcall *)(_QWORD, _QWORD))v5)(a1, a2);
result = ((__int64 (__fastcall *)(_QWORD, _QWORD))v5)(v6, a3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // eax
void *v5; // rbx
unsigned int v6; // eax
__int64 result; // rax
void **v8; // [rsp+8h] [rbp-30h] BYREF

v4 = func6(&v8);
if ( v4 )
{
printf("!! load symbol add failed: %d\n", v4);
result = 0LL;
}
else
{
v5 = v8[1];
v6 = ((__int64 (__fastcall *)(_QWORD, _QWORD))v5)(a1, a2);
result = ((__int64 (__fastcall *)(_QWORD, _QWORD))v5)(v6, a3);
}
return result;
}

original_code:
int triadd(int x, int y, int z)
{
 VendorFuncs *vFuncs;
 int ret = init_lib(&vFuncs);
 if (ret != 0) {
  printf("!! load symbol add failed: %d\n", ret);
  return 0;
 }
 return vFuncs->add(vFuncs->add(x, y), z);
}

canonical_original_code:
int triadd(int x, int y, int z)
{
 struct VendorFuncs *vFuncs;
 int ret = init_lib(&vFuncs);
 if (ret != 0) {
  printf("!! load symbol add failed: %d\n", ret);
  return 0;
 }
 return vFuncs->add(vFuncs->add(x, y), z);
}

variable_types: x int

variable_types: y int

variable_types: z int

variable_types: struct VendorFuncs { void *lib; int (*add)(int x, int y); } *


repo: choueric/tools

decompiled_code:
const char *__fastcall bool_str(int a1)
{
const char *result; // rax

result = "enabled";
if ( !a1 )
result = "disabled";
return result;
}

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

result = "enabled";
if ( !a1 )
result = "disabled";
return result;
}

original_code:
static const char *bool_str(bool val)
{
 return val ? "enabled": "disabled";
}

canonical_original_code:
static char *bool_str(int val)
{
 return val ? "enabled": "disabled";
}

variable_types: val int

return_type: char *


decompiled_code:
void __fastcall opts_def(__int64 a1)
{
*(_QWORD *)a1 = "/dev/ttyS0";
*(_DWORD *)(a1 + 8) = 0;
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1)
{
*(_QWORD *)a1 = "/dev/ttyS0";
*(_DWORD *)(a1 + 8) = 0;
}

original_code:
void opts_def(struct options_t *opts)
{
 opts->device = "/dev/ttyS0";
 opts->loop = 0;
}

variable_types: struct options_t { char *device; int loop; } *

return_type: void


decompiled_code:
int __fastcall opts_usage(__int64 a1, const char *a2)
{
const char *v2; // rax

fprintf(stderr, "Usage: %s [-d device] [-l]\n", a2);
fprintf(stderr, " -d: tty device. Default is [%s]\n", *(const char **)a1);
v2 = bool_str(*(_DWORD *)(a1 + 8));
return fprintf(stderr, " -l: loop test. Default is [%s]\n", v2);
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1, const char *a2)
{
const char *v2; // rax

fprintf(stderr, "Usage: %s [-d device] [-l]\n", a2);
fprintf(stderr, " -d: tty device. Default is [%s]\n", *(const char **)a1);
v2 = func7(*(_DWORD *)(a1 + 8));
return fprintf(stderr, " -l: loop test. Default is [%s]\n", v2);
}

original_code:
void opts_usage(struct options_t *opts, char *p)
{
 fprintf(stderr, "Usage: %s [-d device] [-l]\n", p);
 fprintf(stderr, "  -d: tty device. Default is [%s]\n", opts->device);
 fprintf(stderr, "  -l: loop test. Default is [%s]\n", bool_str(opts->loop));
}

variable_types:
p
char *

user_defined_types: struct options_t { char *device; int loop; }


decompiled_code:
int __fastcall opts_parse(__int64 a1, int a2, char *const *a3)
{
int result; // eax

while ( 1 )
{
result = getopt(a2, a3, "d:l");
if ( result == -1 )
break;
if ( result == 100 )
{
*(_QWORD *)a1 = optarg;
}
else
{
if ( result != 108 )
{
opts_usage(a1, *(const char **)a3);
exit(0);
}
*(_DWORD *)(a1 + 8) = 1;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, int a2, char *const *a3)
{
int result; // eax

while ( 1 )
{
result = getopt(a2, a3, "d:l");
if ( result == -1 )
break;
if ( result == 100 )
{
*(_QWORD *)a1 = optarg;
}
else
{
if ( result != 108 )
{
func9(a1, *(const char **)a3);
exit(0);
}
*(_DWORD *)(a1 + 8) = 1;
}
}
return result;
}

original_code:
void opts_parse(struct options_t *opts, int argc, char **argv)
{
 int opt;
 while ( (opt = getopt(argc, argv, "d:l")) != -1) {
  switch (opt) {
   case 'd': opts->device = optarg; break;
   case 'l': opts->loop = 1; break;
   default:
    opts_usage(opts, argv[0]);
    exit(0);
  }
 }
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int


decompiled_code:
__pid_t fork_child()
{
__pid_t result; // eax

result = fork();
if ( result == -1 )
{
perror("fork");
exit(1);
}
if ( !result )
{
puts("child: sleeping...");
sleep(0xAu);
puts("child: exiting");
exit(0);
}
return result;
}

canonical_decompiled_code:
__pid_t func7()
{
__pid_t result; // eax

result = fork();
if ( result == -1 )
{
perror("fork");
exit(1);
}
if ( !result )
{
puts("child: sleeping...");
sleep(0xAu);
puts("child: exiting");
exit(0);
}
return result;
}

original_code:
static pid_t fork_child(void)
{
    int p = fork ();
    if (p == -1) {
        perror ("fork");
        exit (1);
    }
    if (p == 0) {
        puts ("child: sleeping...");
        sleep (10);
        puts ("child: exiting");
        exit (0);
    }
    return p;
}

canonical_original_code:
static int fork_child()
{
    int p = fork ();
    if (p == -1) {
        perror ("fork");
        exit (1);
    }
    if (p == 0) {
        puts ("child: sleeping...");
        sleep (10);
        puts ("child: exiting");
        exit (0);
    }
    return p;
}

variable_types: p int

return_type: int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__pid_t v3; // ebp
__int64 v4; // rbx
int v5; // eax
int result; // eax
struct timespec v7; // [rsp+0h] [rbp-128h] BYREF
sigset_t set; // [rsp+10h] [rbp-118h] BYREF
sigset_t oset; // [rsp+90h] [rbp-98h] BYREF

sigemptyset(&set);
sigaddset(&set, 17);
if ( sigprocmask(0, &set, &oset) < 0 )
{
perror("sigprocmask");
result = 1;
}
else
{
v3 = fork_child();
fork_test_isra_0();
v7.tv_sec = 5LL;
v7.tv_nsec = 0LL;
while ( 1 )
{
v4 = (unsigned int)sigtimedwait(&set, 0LL, &v7);
printf(" ret = %d\n", v4);
if ( (int)v4 >= 0 )
break;
puts("--> after sigtimedwait");
v5 = *__errno_location();
if ( v5 != 4 )
{
if ( v5 != 11 )
{
perror("sigtimedwait");
return 1;
}
puts("Timeout, killing child");
kill(v3, 9);
break;
}
puts("got EINTR");
}
puts("wait pid...");
if ( waitpid(v3, 0LL, 0) < 0 )
{
perror("waitpid");
result = 1;
}
else
{
puts("ok child pid exit");
result = 0;
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__pid_t v3; // ebp
__int64 v4; // rbx
int v5; // eax
int result; // eax
struct timespec v7; // [rsp+0h] [rbp-128h] BYREF
sigset_t set; // [rsp+10h] [rbp-118h] BYREF
sigset_t oset; // [rsp+90h] [rbp-98h] BYREF

sigemptyset(&set);
sigaddset(&set, 17);
if ( sigprocmask(0, &set, &oset) < 0 )
{
perror("sigprocmask");
result = 1;
}
else
{
v3 = func7();
func8();
v7.tv_sec = 5LL;
v7.tv_nsec = 0LL;
while ( 1 )
{
v4 = (unsigned int)sigtimedwait(&set, 0LL, &v7);
printf(" ret = %d\n", v4);
if ( (int)v4 >= 0 )
break;
puts("--> after sigtimedwait");
v5 = *__errno_location();
if ( v5 != 4 )
{
if ( v5 != 11 )
{
perror("sigtimedwait");
return 1;
}
puts("Timeout, killing child");
kill(v3, 9);
break;
}
puts("got EINTR");
}
puts("wait pid...");
if ( waitpid(v3, 0LL, 0) < 0 )
{
perror("waitpid");
result = 1;
}
else
{
puts("ok child pid exit");
result = 0;
}
}
return result;
}

original_code:
int main(int argc, char *argv[])
{
    sigset_t mask;
    sigset_t orig_mask;
    struct timespec timeout;
    pid_t pid;
    sigemptyset (&mask);
    sigaddset (&mask, 17);
    if (sigprocmask(0, &mask, &orig_mask) < 0) {
        perror ("sigprocmask");
        return 1;
    }
    pid = fork_child ();
    fork_test();
    timeout.tv_sec = 5;
    timeout.tv_nsec = 0;
    do {
        int ret = sigtimedwait(&mask, ((void *)0), &timeout);
        printf(" ret = %d\n", ret);
        if (ret < 0) {
            printf("--> after sigtimedwait\n");
            if ((*__errno_location ()) == 4) {
                printf("got EINTR\n");
                continue;
            }
            else if ((*__errno_location ()) == 11) {
                printf ("Timeout, killing child\n");
                kill (pid, 9);
            }
            else {
                perror ("sigtimedwait");
                return 1;
            }
        }
        break;
    } while (1);
    printf("wait pid...\n");
    if (waitpid(pid, ((void *)0), 0) < 0) {
        perror ("waitpid");
        return 1;
    }
    printf("ok child pid exit\n");
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    struct __sigset_t mask;
    struct __sigset_t orig_mask;
    struct timespec timeout;
    int pid;
    sigemptyset (&mask);
    sigaddset (&mask, 17);
    if (sigprocmask(0, &mask, &orig_mask) < 0) {
        perror ("sigprocmask");
        return 1;
    }
    pid = fork_child ();
    fork_test();
    timeout.tv_sec = 5;
    timeout.tv_nsec = 0;
    do {
        int ret = sigtimedwait(&mask, ((void *)0), &timeout);
        printf(" ret = %d\n", ret);
        if (ret < 0) {
            printf("--> after sigtimedwait\n");
            if ((*__errno_location ()) == 4) {
                printf("got EINTR\n");
                continue;
            }
            else if ((*__errno_location ()) == 11) {
                printf ("Timeout, killing child\n");
                kill (pid, 9);
            }
            else {
                perror ("sigtimedwait");
                return 1;
            }
        }
        break;
    } while (1);
    printf("wait pid...\n");
    if (waitpid(pid, ((void *)0), 0) < 0) {
        perror ("waitpid");
        return 1;
    }
    printf("ok child pid exit\n");
    return 0;
}

variable_types:
argv
char *[]

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

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

variable_types: pid int

variable_types: ret int


worker

decompiled_code:
void *__fastcall worker(void *a1)
{
int v1; // ebp

v1 = 10000;
if ( (*((_BYTE *)a1 + 16) & 1) != 0 )
{
do
{
usleep(0x64u);
_InterlockedSub(*(volatile signed __int32 **)a1, 1u);
--**((_DWORD **)a1 + 1);
--v1;
}
while ( v1 );
}
else
{
do
{
usleep(0x64u);
_InterlockedAdd(*(volatile signed __int32 **)a1, 1u);
++**((_DWORD **)a1 + 1);
--v1;
}
while ( v1 );
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func7(void *a1)
{
int v1; // ebp

v1 = 10000;
if ( (*((_BYTE *)a1 + 16) & 1) != 0 )
{
do
{
usleep(0x64u);
_InterlockedSub(*(volatile signed __int32 **)a1, 1u);
--**((_DWORD **)a1 + 1);
--v1;
}
while ( v1 );
}
else
{
do
{
usleep(0x64u);
_InterlockedAdd(*(volatile signed __int32 **)a1, 1u);
++**((_DWORD **)a1 + 1);
--v1;
}
while ( v1 );
}
return 0LL;
}

original_code:
static void *worker(void *arg)
{
 job *p_job = arg;
 if (p_job->id & 0x1) {
  for (int i = 0; i < 10000; i++) {
   usleep(100);
   __atomic_fetch_sub ((p_job->pval), (1), 5);
   *(p_job->p_normal) = *(p_job->p_normal) - 1;
  }
 } else {
  for (int i = 0; i < 10000; i++) {
   usleep(100);
   __atomic_fetch_add ((p_job->pval), (1), 5);
   *(p_job->p_normal) = *(p_job->p_normal) + 1;
  }
 }
    return ((void *)0);
}

canonical_original_code:
static void *worker(void *arg)
{
 struct _job *p_job = arg;
 if (p_job->id & 0x1) {
  for (int i = 0; i < 10000; i++) {
   usleep(100);
   __atomic_fetch_sub ((p_job->pval), (1), 5);
   *(p_job->p_normal) = *(p_job->p_normal) - 1;
  }
 } else {
  for (int i = 0; i < 10000; i++) {
   usleep(100);
   __atomic_fetch_add ((p_job->pval), (1), 5);
   *(p_job->p_normal) = *(p_job->p_normal) + 1;
  }
 }
    return ((void *)0);
}

variable_types:
arg
void *

variable_types: struct _job { int *pval; int *p_normal; int id; } *

variable_types: i int

return_type: void *


decompiled_code:
int print_arch()
{
printf("sizeof(int)=%d\n", 32LL);
printf("sizeof(int*)=%d\n", 64LL);
puts("__GNUC__ is defined");
puts("__x86_64__ is defined");
puts("__linux__ is defined");
puts("__LP64__ is defined");
return puts("__amd64 is defined");
}

canonical_decompiled_code:
int func7()
{
printf("sizeof(int)=%d\n", 32LL);
printf("sizeof(int*)=%d\n", 64LL);
puts("__GNUC__ is defined");
puts("__x86_64__ is defined");
puts("__linux__ is defined");
puts("__LP64__ is defined");
return puts("__amd64 is defined");
}

original_code:
void print_arch()
{
    int len=sizeof(int)*8;
    printf("sizeof(int)=%d\n",len);
    len=sizeof(int *)*8;
    printf("sizeof(int*)=%d\n",len);
    printf("__GNUC__ is defined\n");
    printf("__x86_64__  is defined\n");
    printf("__linux__ is defined\n");
    printf("__LP64__ is defined\n");
    printf("__amd64 is defined\n");
}

canonical_original_code:
void print_arch()
{
    int len = sizeof(int)*8;
    printf("sizeof(int)=%d\n",len);
    len=sizeof(int *)*8;
    printf("sizeof(int*)=%d\n",len);
    printf("__GNUC__ is defined\n");
    printf("__x86_64__  is defined\n");
    printf("__linux__ is defined\n");
    printf("__LP64__ is defined\n");
    printf("__amd64 is defined\n");
}

variable_types: len int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
print_arch(argc, argv, envp);
printf("unsigned long long size = %zd\n", 8uLL);
printf("long long size = %zd\n", 8uLL);
printf(" short int: %zd\n", 2uLL);
printf(" int: %zd\n", 4uLL);
printf(" long int: %zd\n", 8uLL);
printf("long long int: %zd\n", 8uLL);
printf(" size_t: %zd\n", 8uLL);
printf(" void*: %zd\n\n", 8uLL);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7(argc, argv, envp);
printf("unsigned long long size = %zd\n", 8uLL);
printf("long long size = %zd\n", 8uLL);
printf(" short int: %zd\n", 2uLL);
printf(" int: %zd\n", 4uLL);
printf(" long int: %zd\n", 8uLL);
printf("long long int: %zd\n", 8uLL);
printf(" size_t: %zd\n", 8uLL);
printf(" void*: %zd\n\n", 8uLL);
return 0;
}

original_code:
int main()
{
 print_arch();
 printf("unsigned long long size = %zd\n", sizeof(unsigned long long));
 printf("long long size = %zd\n", sizeof(long long));
 printf( "    short int: %zd\n" , sizeof(short int) ) ;
 printf( "          int: %zd\n" , sizeof(int) ) ;
 printf( "     long int: %zd\n", sizeof(long int) ) ;
 printf( "long long int: %zd\n", sizeof(long long int) ) ;
 printf( "       size_t: %zd\n", sizeof(size_t) ) ;
 printf( "        void*: %zd\n\n", sizeof(void *) ) ;
 return 0;
}

canonical_original_code:
int main()
{
 print_arch();
 printf("unsigned long long size = %zd\n", sizeof(unsigned long long));
 printf("long long size = %zd\n", sizeof(long long));
 printf( "    short int: %zd\n" , sizeof(short) ) ;
 printf( "          int: %zd\n" , sizeof(int) ) ;
 printf( "     long int: %zd\n", sizeof(long) ) ;
 printf( "long long int: %zd\n", sizeof(long long) ) ;
 printf( "       size_t: %zd\n", sizeof(unsigned long) ) ;
 printf( "        void*: %zd\n\n", sizeof(void *) ) ;
 return 0;
}


decompiled_code:
void __fastcall clog_set_level(int a1)
{
clog_level = a1;
}

canonical_decompiled_code:
void __fastcall func7(int a1)
{
clog_level = a1;
}

original_code:
void clog_set_level(int level)
{
 clog_level = level;
}

variable_types: level int


test

decompiled_code:
int test()
{
if ( clog_level > 0 )
printf("\x1B[31m!!! %s %d %s()\x1B[0m: error msg.\n", "main.c", 5LL, "test");
if ( clog_level > 1 )
printf("\x1B[33m>>> %s %d %s()\x1B[0m: warn msg.\n", "main.c", 6LL, "test");
if ( clog_level > 2 )
{
printf("\x1B[34m>>> %s %d %s()\x1B[0m: info msg.\n", "main.c", 7LL, "test");
if ( clog_level > 3 )
{
printf("\x1B[32m>>> %s %d %s()\x1B[0m: debug msg.\n", "main.c", 8LL, "test");
if ( clog_level > 4 )
puts("\x1B[35m>>>\x1B[0m trace msg.");
}
}
return putchar(10);
}

canonical_decompiled_code:
int func8()
{
if ( clog_level > 0 )
printf("\x1B[31m!!! %s %d %s()\x1B[0m: error msg.\n", "main.c", 5LL, "test");
if ( clog_level > 1 )
printf("\x1B[33m>>> %s %d %s()\x1B[0m: warn msg.\n", "main.c", 6LL, "test");
if ( clog_level > 2 )
{
printf("\x1B[34m>>> %s %d %s()\x1B[0m: info msg.\n", "main.c", 7LL, "test");
if ( clog_level > 3 )
{
printf("\x1B[32m>>> %s %d %s()\x1B[0m: debug msg.\n", "main.c", 8LL, "test");
if ( clog_level > 4 )
puts("\x1B[35m>>>\x1B[0m trace msg.");
}
}
return putchar(10);
}

original_code:
static void test()
{
 do { if (clog_level >= CLOG_ERROR) printf("\033[31m!!! %s %d %s()\033[0m: " "error msg." "\n", "main.c", 5, __func__); } while (0);
 do { if (clog_level >= CLOG_WARNING) printf("\033[33m>>> %s %d %s()\033[0m: " "warn msg." "\n", "main.c", 6, __func__); } while (0);
 do { if (clog_level >= CLOG_INFO) printf("\033[34m>>> %s %d %s()\033[0m: " "info msg." "\n", "main.c", 7, __func__); } while (0);
 do { if (clog_level >= CLOG_DEBUG) printf("\033[32m>>> %s %d %s()\033[0m: " "debug msg." "\n", "main.c", 8, __func__); } while (0);
 do { if (clog_level >= CLOG_TRACE) printf("\033[35m>>>\033[0m " "trace msg." "\n");} while (0);
 printf("\n");
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx

clog_set_level(0LL, argv, envp);
test();
clog_set_level(1LL, argv, v3);
test();
clog_set_level(2LL, argv, v4);
test();
clog_set_level(3LL, argv, v5);
test();
clog_set_level(4LL, argv, v6);
test();
clog_set_level(5LL, argv, v7);
test();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx

func7(0LL, argv, envp);
func8();
func7(1LL, argv, v3);
func8();
func7(2LL, argv, v4);
func8();
func7(3LL, argv, v5);
func8();
func7(4LL, argv, v6);
func8();
func7(5LL, argv, v7);
func8();
return 0;
}

original_code:
int main(int argc, char **argv)
{
 clog_set_level(CLOG_NONE);
 test();
 clog_set_level(CLOG_ERROR);
 test();
 clog_set_level(CLOG_WARNING);
 test();
 clog_set_level(CLOG_INFO);
 test();
 clog_set_level(CLOG_DEBUG);
 test();
 clog_set_level(CLOG_TRACE);
 test();
    return 0;
}


test

decompiled_code:
__int64 test()
{
char v1[32]; // [rsp+0h] [rbp-68h] BYREF
struct tm tp; // [rsp+20h] [rbp-48h] BYREF

puts("---- time date ----");
fetch_time(&tp);
time2str(&tp, v1, 20LL);
printf("[%s]\n", v1);
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
char v1[32]; // [rsp+0h] [rbp-68h] BYREF
struct tm tp; // [rsp+20h] [rbp-48h] BYREF

puts("---- time date ----");
func8(&tp);
func9(&tp, v1, 20LL);
printf("[%s]\n", v1);
return 0LL;
}

canonical_original_code:
static void test()
{
 do { if (clog_level >= CLOG_ERROR) printf("\033[31m!!! %s %d %s()\033[0m: " "error msg." "\n", "main.c", 5, __func__); } while (0);
 do { if (clog_level >= CLOG_WARNING) printf("\033[33m>>> %s %d %s()\033[0m: " "warn msg." "\n", "main.c", 6, __func__); } while (0);
 do { if (clog_level >= CLOG_INFO) printf("\033[34m>>> %s %d %s()\033[0m: " "info msg." "\n", "main.c", 7, __func__); } while (0);
 do { if (clog_level >= CLOG_DEBUG) printf("\033[32m>>> %s %d %s()\033[0m: " "debug msg." "\n", "main.c", 8, __func__); } while (0);
 do { if (clog_level >= CLOG_TRACE) printf("\033[35m>>>\033[0m " "trace msg." "\n");} while (0);
 printf("\n");
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
test(argc, argv, envp);
puts("--- print timeofday ----");
print_timeofday();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7(argc, argv, envp);
puts("--- print timeofday ----");
func10();
return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 clog_set_level(CLOG_NONE);
 test();
 clog_set_level(CLOG_ERROR);
 test();
 clog_set_level(CLOG_WARNING);
 test();
 clog_set_level(CLOG_INFO);
 test();
 clog_set_level(CLOG_DEBUG);
 test();
 clog_set_level(CLOG_TRACE);
 test();
    return 0;
}


test

decompiled_code:
int __fastcall test(__int64 a1)
{
__int64 v1; // rsi

v1 = (unsigned int)count++;
printf("-------------- test %d --------------------\n", v1);
debugoutput(a1, 1LL);
return puts("\n");
}


main

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

do_edvlog(" do test %d\n", v4);
gettimeofday(&tv2, 0LL);
printf("--> %s [%ld]\n", "1", tv2.tv_usec + 1000000 * (tv2.tv_sec - (_QWORD)tv1) - *((_QWORD *)&tv1 + 1));
tv1 = (__int128)_mm_load_si128((const __m128i *)&tv2);
test("/home/zhs/test\n", 16LL);
do_edvlog(" do test %d\n", v5);
gettimeofday(&tv2, 0LL);
printf("--> %s [%ld]\n", "2", tv2.tv_usec + 1000000 * (tv2.tv_sec - (_QWORD)tv1) - *((_QWORD *)&tv1 + 1));
tv1 = (__int128)_mm_load_si128((const __m128i *)&tv2);
test("/home/zhs/test/main.c/", 23LL);
do_edvlog(" do test %d\n", v6);
gettimeofday(&tv2, 0LL);
printf("--> %s [%ld]\n", "3", tv2.tv_usec + 1000000 * (tv2.tv_sec - (_QWORD)tv1) - *((_QWORD *)&tv1 + 1));
tv1 = (__int128)_mm_load_si128((const __m128i *)&tv2);
test("/home/zhs/test/main.c", 22LL);
return 0;
}

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

func9(" do test %d\n", v4);
gettimeofday(&tv2, 0LL);
printf("--> %s [%ld]\n", "1", tv2.tv_usec + 1000000 * (tv2.tv_sec - (_QWORD)tv1) - *((_QWORD *)&tv1 + 1));
tv1 = (__int128)_mm_load_si128((const __m128i *)&tv2);
func7("/home/zhs/test\n", 16LL);
func9(" do test %d\n", v5);
gettimeofday(&tv2, 0LL);
printf("--> %s [%ld]\n", "2", tv2.tv_usec + 1000000 * (tv2.tv_sec - (_QWORD)tv1) - *((_QWORD *)&tv1 + 1));
tv1 = (__int128)_mm_load_si128((const __m128i *)&tv2);
func7("/home/zhs/test/main.c/", 23LL);
func9(" do test %d\n", v6);
gettimeofday(&tv2, 0LL);
printf("--> %s [%ld]\n", "3", tv2.tv_usec + 1000000 * (tv2.tv_sec - (_QWORD)tv1) - *((_QWORD *)&tv1 + 1));
tv1 = (__int128)_mm_load_si128((const __m128i *)&tv2);
func7("/home/zhs/test/main.c", 22LL);
return 0;
}


decompiled_code:
_BOOL8 __fastcall is_special_dir(unsigned __int8 *a1)
{
_BOOL8 result; // rax
int v2; // eax

if ( *a1 != 46 || (result = 1LL, a1[1]) )
{
v2 = *a1 - 46;
if ( *a1 == 46 && (v2 = a1[1] - 46, a1[1] == 46) )
result = a1[2] == 0;
else
result = v2 == 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(unsigned __int8 *a1)
{
_BOOL8 result; // rax
int v2; // eax

if ( *a1 != 46 || (result = 1LL, a1[1]) )
{
v2 = *a1 - 46;
if ( *a1 == 46 && (v2 = a1[1] - 46, a1[1] == 46) )
result = a1[2] == 0;
else
result = v2 == 0;
}
return result;
}

original_code:
static int is_special_dir(const char *path)
{
 return strcmp(path, ".") == 0 || strcmp(path, "..") == 0;
}

canonical_original_code:
static int is_special_dir(char *path)
{
 return strcmp(path, ".") == 0 || strcmp(path, "..") == 0;
}

variable_types:
path
char *


decompiled_code:
char *__fastcall get_file_path(char *s, char *src, char *dest)
{
strcpy(dest, s);
if ( dest[strlen(s) - 1] != 47 )
*(_WORD *)&dest[strlen(dest)] = 47;
return strcat(dest, src);
}

canonical_decompiled_code:
char *__fastcall func10(char *s, char *src, char *dest)
{
strcpy(dest, s);
if ( dest[strlen(s) - 1] != 47 )
*(_WORD *)&dest[strlen(dest)] = 47;
return strcat(dest, src);
}

original_code:
void get_file_path(const char *path, const char *filename, char *file_path)
{
 strcpy(file_path, path);
 if (file_path[strlen(path) - 1] != '/')
  strcat(file_path, "/");
 strcat(file_path, filename);
}

canonical_original_code:
void get_file_path(char *path, char *filename, char *file_path)
{
 strcpy(file_path, path);
 if (file_path[strlen(path) - 1] != '/')
  strcat(file_path, "/");
 strcat(file_path, filename);
}

variable_types:
filename
char *


decompiled_code:
char *__fastcall get_file_path(char *s, char *src, char *dest)
{
char *v4; // rbx

v4 = stpcpy(dest, s);
if ( dest[strlen(s) - 1] != 47 )
*(_WORD *)v4 = 47;
return strcat(dest, src);
}

canonical_decompiled_code:
char *__fastcall func10(char *s, char *src, char *dest)
{
char *v4; // rbx

v4 = stpcpy(dest, s);
if ( dest[strlen(s) - 1] != 47 )
*(_WORD *)v4 = 47;
return strcat(dest, src);
}


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

test("/home/zhs/test", 15LL, envp);
test("/home/zhs/test/main.c/", 23LL, v3);
test("/home/zhs/test/main.c", 22LL, v4);
return 0;
}

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

func7("/home/zhs/test", 15LL, envp);
func7("/home/zhs/test/main.c/", 23LL, v3);
func7("/home/zhs/test/main.c", 22LL, v4);
return 0;
}


repo: choupi/MLFounds

variable_types: j int

variable_types: k int

variable_types: n int

variable_types: flag int

variable_types:
w
float [5]

variable_types: s float

variable_types: delta float


repo: chouqin/simpleFs

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // ebx
int v5; // edi
socklen_t v6; // edx
int v7; // er12
int v8; // eax
int v9; // ebp
unsigned int v10; // er12
char *v11; // rax
unsigned int v12; // er12
char *v13; // rax
unsigned int v14; // er12
char *v15; // rax
unsigned int v16; // er12
char *v17; // rax
unsigned int v18; // er13
char *v19; // rax
unsigned int v20; // er12
char *v21; // rax
unsigned int v22; // er12
char *v23; // rax
unsigned int v24; // er12
char *v25; // rax
unsigned int v26; // er12
char *v27; // rax
unsigned int buf; // [rsp+4h] [rbp-1244h] BYREF
unsigned int v29; // [rsp+8h] [rbp-1240h] BYREF
int v30; // [rsp+Ch] [rbp-123Ch] BYREF
struct sockaddr v31; // [rsp+10h] [rbp-1238h] BYREF
char v32[512]; // [rsp+20h] [rbp-1228h] BYREF
char v33[4136]; // [rsp+220h] [rbp-1028h] BYREF

v3 = socket(2, 1, 0);
if ( v3 == -1 )
{
v12 = *__errno_location();
v13 = strerror(v12);
printf("create socket error: %s(errno: %d)\n", v13, v12);
exit(0);
}
v4 = v3;
*(_QWORD *)&v31.sa_data[6] = 0LL;
v31.sa_family = 2;
v5 = v3;
*(_QWORD *)&v31.sa_data[2] = (unsigned int)_bswap_32_constprop_0(v3, &v31, 16LL);
*(_WORD *)v31.sa_data = _bswap_16_constprop_0();
if ( bind(v5, &v31, v6) == -1 )
{
v10 = *__errno_location();
v11 = strerror(v10);
printf("bind socket error: %s(errno: %d)\n", v11, v10);
exit(0);
}
if ( listen(v4, 10) == -1 )
{
v16 = *__errno_location();
v17 = strerror(v16);
printf("listen socket error: %s(errno: %d)\n", v17, v16);
exit(0);
}
puts("======waiting for client's request======");
v7 = open("bigfile", 2);
while ( 1 )
{
while ( 1 )
{
v8 = accept(v4, 0LL, 0LL);
v9 = v8;
if ( v8 != -1 )
break;
v18 = *__errno_location();
v19 = strerror(v18);
printf("accept socket error: %s(errno: %d)", v19, v18);
}
recv(v8, &buf, 4uLL, 0);
if ( buf == 2 )
{
v30 = 0;
if ( send(v9, &v30, 4uLL, 0) < 0 )
goto LABEL_24;
recv(v9, &v29, 4uLL, 0);
printf("write block: block_num is %d\n", v29);
v30 = 0;
if ( send(v9, &v30, 4uLL, 0) < 0 )
goto LABEL_24;
recv(v9, v33, 0x200uLL, 0);
if ( (unsigned int)lseek(v7, v29 << 9, 0) == -1 )
goto LABEL_27;
if ( (int)write(v7, v33, 0x200uLL) < 0 )
{
v26 = *__errno_location();
v27 = strerror(v26);
printf("write block to file error: %s(errno: %d)\n", v27, v26);
exit(0);
}
if ( send(v9, &v30, 4uLL, 0) < 0 )
goto LABEL_24;
}
else if ( buf != 3 )
{
if ( buf != 1 )
{
printf("accept bad request_number: %d\n", buf);
v30 = 1;
if ( send(v9, &v30, 0x1000uLL, 0) >= 0 )
exit(0);
LABEL_24:
v14 = *__errno_location();
v15 = strerror(v14);
printf("send msg error: %s(errno: %d)\n", v15, v14);
exit(0);
}
v30 = 0;
if ( send(v9, &v30, 4uLL, 0) < 0 )
goto LABEL_24;
if ( recv(v9, &v29, 4uLL, 0) < 0 )
{
v22 = *__errno_location();
v23 = strerror(v22);
printf("receive block number from client error: %s(errno: %d)\n", v23, v22);
exit(0);
}
printf("read block: block_num is %d\n", v29);
if ( (unsigned int)lseek(v7, v29 << 9, 0) == -1 )
{
LABEL_27:
v20 = *__errno_location();
v21 = strerror(v20);
printf("lseek error: %s(errno: %d)\n", v21, v20);
exit(0);
}
if ( (int)read(v7, v32, 0x200uLL) < 0 )
{
v24 = *__errno_location();
v25 = strerror(v24);
printf("read block from file error: %s(errno: %d)\n", v25, v24);
exit(0);
}
if ( send(v9, v32, 0x200uLL, 0) < 0 )
goto LABEL_24;
}
close(v9);
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // ebx
int v5; // edi
socklen_t v6; // edx
int v7; // er12
int v8; // eax
int v9; // ebp
unsigned int v10; // er12
char *v11; // rax
unsigned int v12; // er12
char *v13; // rax
unsigned int v14; // er12
char *v15; // rax
unsigned int v16; // er12
char *v17; // rax
unsigned int v18; // er13
char *v19; // rax
unsigned int v20; // er12
char *v21; // rax
unsigned int v22; // er12
char *v23; // rax
unsigned int v24; // er12
char *v25; // rax
unsigned int v26; // er12
char *v27; // rax
unsigned int buf; // [rsp+4h] [rbp-1244h] BYREF
unsigned int v29; // [rsp+8h] [rbp-1240h] BYREF
int v30; // [rsp+Ch] [rbp-123Ch] BYREF
struct sockaddr v31; // [rsp+10h] [rbp-1238h] BYREF
char v32[512]; // [rsp+20h] [rbp-1228h] BYREF
char v33[4136]; // [rsp+220h] [rbp-1028h] BYREF

v3 = socket(2, 1, 0);
if ( v3 == -1 )
{
v12 = *__errno_location();
v13 = strerror(v12);
printf("create socket error: %s(errno: %d)\n", v13, v12);
exit(0);
}
v4 = v3;
*(_QWORD *)&v31.sa_data[6] = 0LL;
v31.sa_family = 2;
v5 = v3;
*(_QWORD *)&v31.sa_data[2] = (unsigned int)func7(v3, &v31, 16LL);
*(_WORD *)v31.sa_data = func8();
if ( bind(v5, &v31, v6) == -1 )
{
v10 = *__errno_location();
v11 = strerror(v10);
printf("bind socket error: %s(errno: %d)\n", v11, v10);
exit(0);
}
if ( listen(v4, 10) == -1 )
{
v16 = *__errno_location();
v17 = strerror(v16);
printf("listen socket error: %s(errno: %d)\n", v17, v16);
exit(0);
}
puts("======waiting for client's request======");
v7 = open("bigfile", 2);
while ( 1 )
{
while ( 1 )
{
v8 = accept(v4, 0LL, 0LL);
v9 = v8;
if ( v8 != -1 )
break;
v18 = *__errno_location();
v19 = strerror(v18);
printf("accept socket error: %s(errno: %d)", v19, v18);
}
recv(v8, &buf, 4uLL, 0);
if ( buf == 2 )
{
v30 = 0;
if ( send(v9, &v30, 4uLL, 0) < 0 )
goto LABEL_24;
recv(v9, &v29, 4uLL, 0);
printf("write block: block_num is %d\n", v29);
v30 = 0;
if ( send(v9, &v30, 4uLL, 0) < 0 )
goto LABEL_24;
recv(v9, v33, 0x200uLL, 0);
if ( (unsigned int)lseek(v7, v29 << 9, 0) == -1 )
goto LABEL_27;
if ( (int)write(v7, v33, 0x200uLL) < 0 )
{
v26 = *__errno_location();
v27 = strerror(v26);
printf("write block to file error: %s(errno: %d)\n", v27, v26);
exit(0);
}
if ( send(v9, &v30, 4uLL, 0) < 0 )
goto LABEL_24;
}
else if ( buf != 3 )
{
if ( buf != 1 )
{
printf("accept bad request_number: %d\n", buf);
v30 = 1;
if ( send(v9, &v30, 0x1000uLL, 0) >= 0 )
exit(0);
LABEL_24:
v14 = *__errno_location();
v15 = strerror(v14);
printf("send msg error: %s(errno: %d)\n", v15, v14);
exit(0);
}
v30 = 0;
if ( send(v9, &v30, 4uLL, 0) < 0 )
goto LABEL_24;
if ( recv(v9, &v29, 4uLL, 0) < 0 )
{
v22 = *__errno_location();
v23 = strerror(v22);
printf("receive block number from client error: %s(errno: %d)\n", v23, v22);
exit(0);
}
printf("read block: block_num is %d\n", v29);
if ( (unsigned int)lseek(v7, v29 << 9, 0) == -1 )
{
LABEL_27:
v20 = *__errno_location();
v21 = strerror(v20);
printf("lseek error: %s(errno: %d)\n", v21, v20);
exit(0);
}
if ( (int)read(v7, v32, 0x200uLL) < 0 )
{
v24 = *__errno_location();
v25 = strerror(v24);
printf("read block from file error: %s(errno: %d)\n", v25, v24);
exit(0);
}
if ( send(v9, v32, 0x200uLL, 0) < 0 )
goto LABEL_24;
}
close(v9);
}
}

original_code:
int main(int argc, char** argv)
{
    int listenfd, connfd;
    struct sockaddr_in servaddr;
    char buff[4096];
    char tmp[512];
    int n;
    int request_number, block_num;
    int return_msg;
    int fd;
    int position;
    if( (listenfd = socket(2, SOCK_STREAM, 0)) == -1 ){
        printf("create socket error: %s(errno: %d)\n",strerror((*__errno_location ())),(*__errno_location ()));
        exit(0);
    }
    memset(&servaddr, 0, sizeof(servaddr));
    servaddr.sin_family = 2;
    servaddr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
    servaddr.sin_port = htons(6666);
    if( bind(listenfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) == -1){
        printf("bind socket error: %s(errno: %d)\n",strerror((*__errno_location ())),(*__errno_location ()));
        exit(0);
    }
    if( listen(listenfd, 10) == -1){
        printf("listen socket error: %s(errno: %d)\n",strerror((*__errno_location ())),(*__errno_location ()));
        exit(0);
    }
    printf("======waiting for client's request======\n");
    fd = open("bigfile", 02);
    while(1){
        if( (connfd = accept(listenfd, (struct sockaddr*)((void *)0), ((void *)0))) == -1){
            printf("accept socket error: %s(errno: %d)",strerror((*__errno_location ())),(*__errno_location ()));
            continue;
        }
        recv(connfd, &request_number, sizeof(int), 0);
        switch(request_number){
            case 1:
                return_msg = 0;
                if( send(connfd, &return_msg, sizeof(int), 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if(recv(connfd, &block_num, sizeof(int), 0) < 0){
                    printf("receive block number from client error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                printf("read block: block_num is %d\n", block_num);
                position = block_num * 512;
                if(lseek(fd, position, 0) == -1){
                    printf("lseek error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if (read(fd, tmp, 512) < 0)
                {
                    printf("read block from file error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if( send(connfd, tmp, 512, 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                break;
            case 2:
                return_msg = 0;
                if( send(connfd, &return_msg, sizeof(int), 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                recv(connfd, &block_num, sizeof(int), 0);
                printf("write block: block_num is %d\n", block_num);
                return_msg = 0;
                if( send(connfd, &return_msg, sizeof(int), 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                recv(connfd, buff, 512, 0);
                position = block_num * 512;
                if(lseek(fd, position, 0) == -1){
                    printf("lseek error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if (write(fd, buff, 512) < 0)
                {
                    printf("write block to file error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if( send(connfd, &return_msg, sizeof(int), 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                break;
            case 3:
                break;
            default:
                printf("accept bad request_number: %d\n", request_number);
                return_msg = 1;
                if( send(connfd, &return_msg, 4096, 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                exit(0);
        }
        close(connfd);
    }
    close(listenfd);
}

canonical_original_code:
int main(int argc, char **argv)
{
    int listenfd; int connfd;
    struct sockaddr_in servaddr;
    char buff[4096];
    char tmp[512];
    int n;
    int request_number; int block_num;
    int return_msg;
    int fd;
    int position;
    if( (listenfd = socket(2, SOCK_STREAM, 0)) == -1 ){
        printf("create socket error: %s(errno: %d)\n",strerror((*__errno_location ())),(*__errno_location ()));
        exit(0);
    }
    memset(&servaddr, 0, sizeof(servaddr));
    servaddr.sin_family = 2;
    servaddr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
    servaddr.sin_port = htons(6666);
    if( bind(listenfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == -1){
        printf("bind socket error: %s(errno: %d)\n",strerror((*__errno_location ())),(*__errno_location ()));
        exit(0);
    }
    if( listen(listenfd, 10) == -1){
        printf("listen socket error: %s(errno: %d)\n",strerror((*__errno_location ())),(*__errno_location ()));
        exit(0);
    }
    printf("======waiting for client's request======\n");
    fd = open("bigfile", 02);
    while(1){
        if( (connfd = accept(listenfd, (struct sockaddr *)((void *)0), ((void *)0))) == -1){
            printf("accept socket error: %s(errno: %d)",strerror((*__errno_location ())),(*__errno_location ()));
            continue;
        }
        recv(connfd, &request_number, sizeof(int), 0);
        switch(request_number){
            case 1:
                return_msg = 0;
                if( send(connfd, &return_msg, sizeof(int), 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if(recv(connfd, &block_num, sizeof(int), 0) < 0){
                    printf("receive block number from client error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                printf("read block: block_num is %d\n", block_num);
                position = block_num * 512;
                if(lseek(fd, position, 0) == -1){
                    printf("lseek error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if (read(fd, tmp, 512) < 0)
                {
                    printf("read block from file error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if( send(connfd, tmp, 512, 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                break;
            case 2:
                return_msg = 0;
                if( send(connfd, &return_msg, sizeof(int), 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                recv(connfd, &block_num, sizeof(int), 0);
                printf("write block: block_num is %d\n", block_num);
                return_msg = 0;
                if( send(connfd, &return_msg, sizeof(int), 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                recv(connfd, buff, 512, 0);
                position = block_num * 512;
                if(lseek(fd, position, 0) == -1){
                    printf("lseek error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if (write(fd, buff, 512) < 0)
                {
                    printf("write block to file error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                if( send(connfd, &return_msg, sizeof(int), 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                break;
            case 3:
                break;
            default:
                printf("accept bad request_number: %d\n", request_number);
                return_msg = 1;
                if( send(connfd, &return_msg, 4096, 0) < 0)
                {
                    printf("send msg error: %s(errno: %d)\n", strerror((*__errno_location ())), (*__errno_location ()));
                    exit(0);
                }
                exit(0);
        }
        close(connfd);
    }
    close(listenfd);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: listenfd int

variable_types: connfd int

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

variable_types:
buff
char [4096]

variable_types:
tmp
char [512]

variable_types: fd int

variable_types: position int

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

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


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
int v4; // eax
int v5; // ebp
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF

addr_len = 16;
v3 = create_listening_socket("127.0.0.1");
addr = 0LL;
v4 = accept(v3, &addr, &addr_len);
if ( v4 < 0 )
{
perror("accept");
exit(1);
}
v5 = v4;
play_stream((unsigned int)v4);
close(v5);
shutdown(v3, 2);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
int v4; // eax
int v5; // ebp
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF

addr_len = 16;
v3 = func15("127.0.0.1");
addr = 0LL;
v4 = accept(v3, &addr, &addr_len);
if ( v4 < 0 )
{
perror("accept");
exit(1);
}
v5 = v4;
func14((unsigned int)v4);
close(v5);
shutdown(v3, 2);
return 0;
}

original_code:
int main(void) {
  int sock = create_listening_socket("127.0.0.1", 13107);
  struct sockaddr_in remote_addr;
  memset(&remote_addr, 0, sizeof remote_addr);
  socklen_t size = sizeof remote_addr;
  int fd = accept(sock, (struct sockaddr *) &remote_addr, &size);
  if (fd < 0) {
    perror("accept");
    exit(1);
  }
  play_stream(fd);
  close(fd);
  shutdown(sock, SHUT_RDWR);
  return 0;
}

canonical_original_code:
int main() {
  int sock = create_listening_socket("127.0.0.1", 13107);
  struct sockaddr_in remote_addr;
  memset(&remote_addr, 0, sizeof remote_addr);
  unsigned int size = sizeof remote_addr;
  int fd = accept(sock, (struct sockaddr *) &remote_addr, &size);
  if (fd < 0) {
    perror("accept");
    exit(1);
  }
  play_stream(fd);
  close(fd);
  shutdown(sock, SHUT_RDWR);
  return 0;
}

variable_types: sock int

variable_types:
size
unsigned int


decompiled_code:
_BOOL8 __fastcall eq_sample_format(__int64 a1, __int64 a2)
{
_BOOL8 result; // rax

result = 0LL;
if ( *(_QWORD *)a1 == *(_QWORD *)a2 && *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8) )
result = strcmp(*(const char **)(a1 + 16), *(const char **)(a2 + 16)) == 0;
return result;
}

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

result = 0LL;
if ( *(_QWORD *)a1 == *(_QWORD *)a2 && *(_QWORD *)(a1 + 8) == *(_QWORD *)(a2 + 8) )
result = strcmp(*(const char **)(a1 + 16), *(const char **)(a2 + 16)) == 0;
return result;
}

original_code:
int eq_sample_format(ao_sample_format *f1, ao_sample_format *f2) {
  return (f1->bits == f2->bits &&
          f1->rate == f2->rate &&
          f1->channels == f2->channels &&
          f1->byte_format == f2->byte_format &&
          strcmp(f1->matrix, f2->matrix) == 0);
}

canonical_original_code:
int eq_sample_format(struct ao_sample_format *f1, struct ao_sample_format *f2) {
  return (f1->bits == f2->bits &&
          f1->rate == f2->rate &&
          f1->channels == f2->channels &&
          f1->byte_format == f2->byte_format &&
          strcmp(f1->matrix, f2->matrix) == 0);
}

variable_types: struct ao_sample_format { int bits; int rate; int channels; int byte_format; char *matrix; } *


scale

decompiled_code:
__int64 __fastcall scale(int a1)
{
int v1; // eax

v1 = -268435455;
if ( a1 >= -268435455 )
v1 = a1;
if ( v1 > 0xFFFFFFF )
v1 = 0xFFFFFFF;
return (unsigned int)(8 * v1);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1)
{
int v1; // eax

v1 = -268435455;
if ( a1 >= -268435455 )
v1 = a1;
if ( v1 > 0xFFFFFFF )
v1 = 0xFFFFFFF;
return (unsigned int)(8 * v1);
}

variable_types: sample int


decompiled_code:
__int64 __fastcall create_listening_socket(char *cp, __int16 a2)
{
int v2; // eax
unsigned int v3; // er12
socklen_t v4; // edx
int optval; // [rsp+8h] [rbp-30h] BYREF
struct in_addr inp; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr v8; // [rsp+10h] [rbp-28h] BYREF

optval = 1;
v2 = socket(2, 1, 0);
if ( v2 == -1 )
{
perror("socket");
exit(1);
}
v3 = v2;
if ( setsockopt(v2, 1, 2, &optval, 4u) )
{
perror("setsockopt");
exit(1);
}
inp.s_addr = 0;
if ( inet_aton(cp, &inp) != 1 )
{
perror("inet_aton");
exit(1);
}
*(_QWORD *)&v8.sa_data[6] = 0LL;
v8.sa_family = 2;
*(_WORD *)v8.sa_data = _bswap_16(a2);
*(struct in_addr *)&v8.sa_data[2] = inp;
if ( bind(v3, &v8, v4) )
{
perror("bind");
exit(1);
}
if ( listen(v3, 5) )
{
perror("listen");
exit(1);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func15(char *cp, __int16 a2)
{
int v2; // eax
unsigned int v3; // er12
socklen_t v4; // edx
int optval; // [rsp+8h] [rbp-30h] BYREF
struct in_addr inp; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr v8; // [rsp+10h] [rbp-28h] BYREF

optval = 1;
v2 = socket(2, 1, 0);
if ( v2 == -1 )
{
perror("socket");
exit(1);
}
v3 = v2;
if ( setsockopt(v2, 1, 2, &optval, 4u) )
{
perror("setsockopt");
exit(1);
}
inp.s_addr = 0;
if ( inet_aton(cp, &inp) != 1 )
{
perror("inet_aton");
exit(1);
}
*(_QWORD *)&v8.sa_data[6] = 0LL;
v8.sa_family = 2;
*(_WORD *)v8.sa_data = func9(a2);
*(struct in_addr *)&v8.sa_data[2] = inp;
if ( bind(v3, &v8, v4) )
{
perror("bind");
exit(1);
}
if ( listen(v3, 5) )
{
perror("listen");
exit(1);
}
return v3;
}

original_code:
int create_listening_socket(const char *host_quad, in_port_t port) {
  int e = 1;
  int sock = socket(2, SOCK_STREAM, 0);
  if (sock == -1) {
    perror("socket");
    exit(1);
  }
  if (setsockopt(sock, 1, 2, (void *)&e, sizeof e) != 0) {
    perror("setsockopt");
    exit(1);
  }
  struct in_addr addr;
  memset(&addr, 0, sizeof addr);
  if (inet_aton(host_quad, &addr) != 1) {
    perror("inet_aton");
    exit(1);
  }
  struct sockaddr_in saddr;
  memset(&saddr, 0, sizeof saddr);
  saddr.sin_family = 2;
  saddr.sin_port = htons(port);
  saddr.sin_addr = addr;
  if (bind(sock, (struct sockaddr *) &saddr, sizeof saddr) != 0) {
    perror("bind");
    exit(1);
  }
  if (listen(sock, 5) != 0) {
    perror("listen");
    exit(1);
  }
  return sock;
}

canonical_original_code:
int create_listening_socket(char *host_quad, unsigned short port) {
  int e = 1;
  int sock = socket(2, SOCK_STREAM, 0);
  if (sock == -1) {
    perror("socket");
    exit(1);
  }
  if (setsockopt(sock, 1, 2, (void *)&e, sizeof e) != 0) {
    perror("setsockopt");
    exit(1);
  }
  struct in_addr addr;
  memset(&addr, 0, sizeof addr);
  if (inet_aton(host_quad, &addr) != 1) {
    perror("inet_aton");
    exit(1);
  }
  struct sockaddr_in saddr;
  memset(&saddr, 0, sizeof saddr);
  saddr.sin_family = 2;
  saddr.sin_port = htons(port);
  saddr.sin_addr = addr;
  if (bind(sock, (struct sockaddr *) &saddr, sizeof saddr) != 0) {
    perror("bind");
    exit(1);
  }
  if (listen(sock, 5) != 0) {
    perror("listen");
    exit(1);
  }
  return sock;
}

variable_types:
port
unsigned short

variable_types: e int

variable_types:
addr
struct in_addr { unsigned int s_addr; }


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

if ( gps_available )
{
gps_stream(&gpsdata, 2LL, 0LL);
result = gps_close(&gpsdata);
gps_available = 0;
}
return result;
}

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

if ( gps_available )
{
gps_stream(&gpsdata, 2LL, 0LL);
result = gps_close(&gpsdata);
gps_available = 0;
}
return result;
}

original_code:
void
gps_stop(void) {
    if (!gps_available)
        return;
    gps_stream((struct gps_data_t *) &gpsdata, 0x000002u, ((void *)0));
    gps_close((struct gps_data_t *) &gpsdata);
    gps_available = 0;
}

canonical_original_code:
void gps_stop() {
    if (!gps_available)
        return;
    gps_stream((struct gps_data_t *) &gpsdata, 0x000002u, ((void *)0));
    gps_close((struct gps_data_t *) &gpsdata);
    gps_available = 0;
}

user_defined_types: struct gps_data_t { unsigned long set; double online; int gps_fd; struct gps_fix_t fix; double separation; int status; int satellites_used; struct dop_t dop; double epe; double skyview_time; int satellites_visible; struct satellite_t skyview[72]; struct devconfig_t dev; struct policy_t policy; struct { double time; int ndevices; struct devconfig_t list[4]; } devices; union { struct rtcm2_t rtcm2; struct rtcm3_t rtcm3; struct subframe_t subframe; struct ais_t ais; struct attitude_t attitude; struct navdata_t navdata; struct rawdata_t raw; struct gst_t gst; struct oscillator_t osc; struct version_t version; char error[256]; struct timedelta_t toff; struct timedelta_t pps; }; void *privdata; }

user_defined_types: struct gps_fix_t { double time; int mode; double ept; double latitude; double epy; double longitude; double epx; double altitude; double epv; double track; double epd; double speed; double eps; double climb; double epc; }

user_defined_types: struct devconfig_t { char path[128]; int flags; char driver[64]; char subtype[64]; double activated; unsigned int baudrate; char parity; double cycle; int driver_mode; }

user_defined_types: struct policy_t { _Bool watcher; _Bool json; _Bool nmea; int raw; _Bool scaled; _Bool timing; _Bool split24; _Bool pps; int loglevel; char devpath[128]; char remote[128]; }

user_defined_types: struct satellite_t { double ss; _Bool used; short PRN; short elevation; short azimuth; }

user_defined_types: struct rtcm2_t { unsigned int type; unsigned int length; double zcount; unsigned int refstaid; unsigned int seqnum; unsigned int stathlth; union { struct { unsigned int nentries; struct gps_rangesat_t sat[18]; } gps_ranges; struct { _Bool valid; double x; } ecef; struct { _Bool valid; int system; int sense; char datum[6]; double dx; } reference; struct { unsigned int nentries; struct consat_t sat[-1]; } conhealth; struct { unsigned int nentries; struct station_t station[10]; } almanac; struct { _Bool status; _Bool rangeflag; double lat; unsigned int range; } xmitter; struct { unsigned int week; unsigned int hour; unsigned int leapsecs; } gpstime; struct { unsigned int nentries; struct glonass_rangesat_t sat[18]; } glonass_ranges; char message[-1]; unsigned int words[-1]; }; }

user_defined_types: struct rtcm3_t { unsigned int type; unsigned int length; union { struct { struct rtcm3_rtk_hdr header; struct rtcm3_1001_t rtk_data[64]; } rtcm3_1001; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1002_t rtk_data[64]; } rtcm3_1002; struct rtcm3_1003_t rtcm3_1003; struct rtcm3_1004_t rtcm3_1004; struct rtcm3_1005_t rtcm3_1005; struct rtcm3_1006_t rtcm3_1006; struct { unsigned int station_id; char descriptor[-1]; unsigned int setup_id; } rtcm3_1007; struct { unsigned int station_id; char descriptor[-1]; unsigned int setup_id; char serial[-1]; } rtcm3_1008; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1009_t rtk_data[64]; } rtcm3_1009; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1010_t rtk_data[64]; } rtcm3_1010; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1011_t rtk_data[64]; } rtcm3_1011; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1012_t rtk_data[64]; } rtcm3_1012; struct { unsigned int station_id; unsigned short mjd; unsigned int sod; unsigned char leapsecs; unsigned char ncount; struct rtcm3_1013_t announcements[32]; } rtcm3_1013; struct rtcm3_1014_t rtcm3_1014; struct rtcm3_1015_t rtcm3_1015; struct rtcm3_1016_t rtcm3_1016; struct rtcm3_1017_t rtcm3_1017; struct rtcm3_1019_t rtcm3_1019; struct rtcm3_1020_t rtcm3_1020; struct rtcm3_1029_t rtcm3_1029; struct rtcm3_1033_t rtcm3_1033; unsigned char data[1024]; } rtcmtypes; }

user_defined_types: struct subframe_t { unsigned char subframe_num; unsigned char data_id; unsigned char pageid; unsigned char tSVID; unsigned int TOW17; long l_TOW17; _Bool integrity; _Bool alert; _Bool antispoof; int is_almanac; union { struct { unsigned short WN; unsigned short IODC; unsigned short toc; long l_toc; unsigned char l2; unsigned char l2p; unsigned int ura; unsigned int hlth; int af0; double d_af0; short af1; double d_af1; char af2; double d_af2; char Tgd; double d_Tgd; } sub1; struct { unsigned char IODE; unsigned char AODO; unsigned short u_AODO; unsigned char fit; unsigned short toe; long l_toe; short Crs; double d_Crs; short Cus; double d_Cus; short Cuc; double d_Cuc; short deltan; double d_deltan; int M0; double d_M0; unsigned int e; double d_eccentricity; unsigned int sqrtA; double d_sqrtA; } sub2; struct { unsigned char IODE; short IDOT; double d_IDOT; short Cic; double d_Cic; short Cis; double d_Cis; short Crc; double d_Crc; int i0; double d_i0; int Omega0; double d_Omega0; int omega; double d_omega; int Omegad; double d_Omegad; } sub3; struct { struct almanac_t almanac; } sub4; struct { char ERD[33]; unsigned char ai; } sub4_13; struct { char str[24]; } sub4_17; struct { int A0; double d_A0; int A1; double d_A1; char alpha0; double d_alpha0; char alpha1; double d_alpha1; char alpha2; double d_alpha2; char alpha3; double d_alpha3; char beta0; double d_beta0; char beta1; double d_beta1; char beta2; double d_beta2; char beta3; double d_beta3; char leap; char lsf; unsigned char tot; double d_tot; unsigned char WNt; unsigned char WNlsf; unsigned char DN; } sub4_18; struct { unsigned char svf[33]; unsigned char svhx[8]; } sub4_25; struct { struct almanac_t almanac; } sub5; struct { unsigned char toa; long l_toa; unsigned char WNa; unsigned char sv[25]; } sub5_25; }; }

user_defined_types: struct ais_t { unsigned int type; unsigned int repeat; unsigned int mmsi; union { struct { unsigned int status; int turn; unsigned int speed; _Bool accuracy; int lon; int lat; unsigned int course; unsigned int heading; unsigned int second; unsigned int maneuver; _Bool raim; unsigned int radio; } type1; struct { unsigned int year; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int second; _Bool accuracy; int lon; int lat; unsigned int epfd; _Bool raim; unsigned int radio; } type4; struct { unsigned int ais_version; unsigned int imo; char callsign[-1]; char shipname[-1]; unsigned int shiptype; unsigned int to_bow; unsigned int to_stern; unsigned int to_port; unsigned int to_starboard; unsigned int epfd; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int draught; char destination[-1]; unsigned int dte; } type5; struct { unsigned int seqno; unsigned int dest_mmsi; _Bool retransmit; unsigned int dac; unsigned int fid; _Bool structured; unsigned long bitcount; union { char bitdata[-1]; struct { char country[-1]; char locode[-1]; char section[-1]; char terminal[-1]; char hectometre[-1]; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int tugs; unsigned int airdraught; } dac200fid21; struct { char country[-1]; char locode[-1]; char section[-1]; char terminal[-1]; char hectometre[-1]; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int status; } dac200fid22; struct { unsigned int crew; unsigned int passengers; unsigned int personnel; } dac200fid55; struct { unsigned int ana_int; unsigned int ana_ext1; unsigned int ana_ext2; unsigned int racon; unsigned int light; _Bool alarm; unsigned int stat_ext; _Bool off_pos; } dac235fid10; struct { char lastport[-1]; unsigned int lmonth; unsigned int lday; unsigned int lhour; unsigned int lminute; char nextport[-1]; unsigned int nmonth; unsigned int nday; unsigned int nhour; unsigned int nminute; char dangerous[-1]; char imdcat[-1]; unsigned int unid; unsigned int amount; unsigned int unit; } dac1fid12; struct { unsigned int airdraught; } dac1fid15; struct { unsigned int persons; } dac1fid16; struct { unsigned int linkage; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; char portname[-1]; char destination[-1]; int lon; int lat; } dac1fid18; struct { unsigned int linkage; unsigned int berth_length; unsigned int berth_depth; unsigned int position; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int availability; unsigned int agent; unsigned int fuel; unsigned int chandler; unsigned int stevedore; unsigned int electrical; unsigned int water; unsigned int customs; unsigned int cartage; unsigned int crane; unsigned int lift; unsigned int medical; unsigned int navrepair; unsigned int provisions; unsigned int shiprepair; unsigned int surveyor; unsigned int steam; unsigned int tugs; unsigned int solidwaste; unsigned int liquidwaste; unsigned int hazardouswaste; unsigned int ballast; unsigned int additional; unsigned int regional1; unsigned int regional2; unsigned int future1; unsigned int future2; char berth_name[-1]; int berth_lon; int berth_lat; } dac1fid20; struct { _Bool wmo; union { struct { char location[-1]; int lon; int lat; unsigned int day; unsigned int hour; unsigned int minute; _Bool vislimit; unsigned int visibility; unsigned int humidity; unsigned int wspeed; unsigned int wgust; unsigned int wdir; unsigned int pressure; unsigned int pressuretend; int airtemp; unsigned int watertemp; unsigned int waveperiod; unsigned int wavedir; unsigned int swellheight; unsigned int swellperiod; unsigned int swelldir; } nonwmo_obs; struct { int lon; int lat; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int course; unsigned int speed; unsigned int heading; unsigned int pressure; unsigned int pdelta; unsigned int ptend; unsigned int twinddir; unsigned int twindspeed; unsigned int rwinddir; unsigned int rwindspeed; unsigned int mgustspeed; unsigned int mgustdir; unsigned int airtemp; unsigned int humidity; } wmo_obs; }; } dac1fid21; struct { unsigned int unit; unsigned int amount; int ncargos; struct cargo_t cargos[28]; } dac1fid25; struct route_info dac1fid28; struct { unsigned int linkage; char text[154]; } dac1fid30; struct { unsigned int month; unsigned int day; int ntidals; struct tidal_t tidals[3]; } dac1fid32; }; } type6; struct { unsigned int mmsi1; unsigned int mmsi2; unsigned int mmsi3; unsigned int mmsi4; } type7; struct { unsigned int dac; unsigned int fid; unsigned long bitcount; _Bool structured; union { char bitdata[-1]; struct { char vin[-1]; unsigned int length; unsigned int beam; unsigned int shiptype; unsigned int hazard; unsigned int draught; unsigned int loaded; _Bool speed_q; _Bool course_q; _Bool heading_q; } dac200fid10; struct { unsigned int start_year; unsigned int start_month; unsigned int start_day; unsigned int end_year; unsigned int end_month; unsigned int end_day; unsigned int start_hour; unsigned int start_minute; unsigned int end_hour; unsigned int end_minute; int start_lon; int start_lat; int end_lon; int end_lat; unsigned int type; int min; int max; unsigned int intensity; unsigned int wind; } dac200fid23; struct { char country[-1]; int ngauges; struct gauge_t gauges[4]; } dac200fid24; struct { int lon; int lat; unsigned int form; unsigned int facing; unsigned int direction; unsigned int status; } dac200fid40; struct { int lon; int lat; unsigned int day; unsigned int hour; unsigned int minute; unsigned int wspeed; unsigned int wgust; unsigned int wdir; unsigned int wgustdir; unsigned int airtemp; unsigned int humidity; unsigned int dewpoint; unsigned int pressure; unsigned int pressuretend; unsigned int visibility; int waterlevel; unsigned int leveltrend; unsigned int cspeed; unsigned int cdir; unsigned int cspeed2; unsigned int cdir2; unsigned int cdepth2; unsigned int cspeed3; unsigned int cdir3; unsigned int cdepth3; unsigned int waveheight; unsigned int waveperiod; unsigned int wavedir; unsigned int swellheight; unsigned int swellperiod; unsigned int swelldir; unsigned int seastate; unsigned int watertemp; unsigned int preciptype; unsigned int salinity; unsigned int ice; } dac1fid11; struct { char reason[-1]; char closefrom[-1]; char closeto[-1]; unsigned int radius; unsigned int extunit; unsigned int fday; unsigned int fmonth; unsigned int fhour; unsigned int fminute; unsigned int tday; unsigned int tmonth; unsigned int thour; unsigned int tminute; } dac1fid13; struct { unsigned int airdraught; } dac1fid15; struct { unsigned int persons; } dac1fid16; struct { int ntargets; struct target_t targets[4]; } dac1fid17; struct { unsigned int linkage; char station[-1]; int lon; int lat; unsigned int status; unsigned int signal; unsigned int hour; unsigned int minute; unsigned int nextsignal; } dac1fid19; struct route_info dac1fid27; struct { unsigned int linkage; char text[162]; } dac1fid29; struct { _Bool accuracy; int lon; int lat; unsigned int day; unsigned int hour; unsigned int minute; unsigned int wspeed; unsigned int wgust; unsigned int wdir; unsigned int wgustdir; int airtemp; unsigned int humidity; int dewpoint; unsigned int pressure; unsigned int pressuretend; _Bool visgreater; unsigned int visibility; int waterlevel; unsigned int leveltrend; unsigned int cspeed; unsigned int cdir; unsigned int cspeed2; unsigned int cdir2; unsigned int cdepth2; unsigned int cspeed3; unsigned int cdir3; unsigned int cdepth3; unsigned int waveheight; unsigned int waveperiod; unsigned int wavedir; unsigned int swellheight; unsigned int swellperiod; unsigned int swelldir; unsigned int seastate; int watertemp; unsigned int preciptype; unsigned int salinity; unsigned int ice; } dac1fid31; }; } type8; struct { unsigned int alt; unsigned int speed; _Bool accuracy; int lon; int lat; unsigned int course; unsigned int second; unsigned int regional; unsigned int dte; _Bool assigned; _Bool raim; unsigned int radio; } type9; struct { unsigned int dest_mmsi; } type10; struct { unsigned int seqno; unsigned int dest_mmsi; _Bool retransmit; char text[157]; } type12; struct { char text[161]; } type14; struct { unsigned int mmsi1; unsigned int type1_1; unsigned int offset1_1; unsigned int type1_2; unsigned int offset1_2; unsigned int mmsi2; unsigned int type2_1; unsigned int offset2_1; } type15; struct { unsigned int mmsi1; unsigned int offset1; unsigned int increment1; unsigned int mmsi2; unsigned int offset2; unsigned int increment2; } type16; struct { int lon; int lat; unsigned long bitcount; char bitdata[-1]; } type17; struct { unsigned int reserved; unsigned int speed; _Bool accuracy; int lon; int lat; unsigned int course; unsigned int heading; unsigned int second; unsigned int regional; _Bool cs; _Bool display; _Bool dsc; _Bool band; _Bool msg22; _Bool assigned; _Bool raim; unsigned int radio; } type18; struct { unsigned int reserved; unsigned int speed; _Bool accuracy; int lon; int lat; unsigned int course; unsigned int heading; unsigned int second; unsigned int regional; char shipname[-1]; unsigned int shiptype; unsigned int to_bow; unsigned int to_stern; unsigned int to_port; unsigned int to_starboard; unsigned int epfd; _Bool raim; unsigned int dte; _Bool assigned; } type19; struct { unsigned int offset1; unsigned int number1; unsigned int timeout1; unsigned int increment1; unsigned int offset2; unsigned int number2; unsigned int timeout2; unsigned int increment2; unsigned int offset3; unsigned int number3; unsigned int timeout3; unsigned int increment3; unsigned int offset4; unsigned int number4; unsigned int timeout4; unsigned int increment4; } type20; struct { unsigned int aid_type; char name[35]; _Bool accuracy; int lon; int lat; unsigned int to_bow; unsigned int to_stern; unsigned int to_port; unsigned int to_starboard; unsigned int epfd; unsigned int second; _Bool off_position; unsigned int regional; _Bool raim; _Bool virtual_aid; _Bool assigned; } type21; struct { unsigned int channel_a; unsigned int channel_b; unsigned int txrx; _Bool power; union { struct { int ne_lon; int ne_lat; int sw_lon; int sw_lat; } area; struct { unsigned int dest1; unsigned int dest2; } mmsi; }; _Bool addressed; _Bool band_a; _Bool band_b; unsigned int zonesize; } type22; struct { int ne_lon; int ne_lat; int sw_lon; int sw_lat; unsigned int stationtype; unsigned int shiptype; unsigned int txrx; unsigned int interval; unsigned int quiet; } type23; struct { char shipname[-1]; enum { both=0, part_a=1, part_b=2 } part; unsigned int shiptype; char vendorid[8]; unsigned int model; unsigned int serial; char callsign[8]; union { unsigned int mothership_mmsi; struct { unsigned int to_bow; unsigned int to_stern; unsigned int to_port; unsigned int to_starboard; } dim; }; } type24; struct { _Bool addressed; _Bool structured; unsigned int dest_mmsi; unsigned int app_id; unsigned long bitcount; char bitdata[-1]; } type25; struct { _Bool addressed; _Bool structured; unsigned int dest_mmsi; unsigned int app_id; unsigned long bitcount; char bitdata[-1]; unsigned int radio; } type26; struct { _Bool accuracy; _Bool raim; unsigned int status; int lon; int lat; unsigned int speed; unsigned int course; _Bool gnss; } type27; }; }

user_defined_types: struct attitude_t { double heading; double pitch; double roll; double yaw; double dip; double mag_len; double mag_x; double mag_y; double mag_z; double acc_len; double acc_x; double acc_y; double acc_z; double gyro_x; double gyro_y; double temp; double depth; char mag_st; char pitch_st; char roll_st; char yaw_st; }

user_defined_types: struct navdata_t { unsigned int version; double compass_heading; double compass_deviation; double compass_variation; double air_temp; double air_pressure; double water_temp; double depth; double depth_offset; double wind_speed; double wind_dir; double crosstrack_error; unsigned int compass_status; unsigned int log_cumulative; unsigned int log_trip; unsigned int crosstrack_status; }

user_defined_types: struct rawdata_t { double codephase[72]; double carrierphase[72]; double pseudorange[72]; double deltarange[72]; double doppler[72]; double mtime[72]; unsigned int satstat[72]; }

user_defined_types: struct gst_t { double utctime; double rms_deviation; double smajor_deviation; double sminor_deviation; double smajor_orientation; double lat_err_deviation; double lon_err_deviation; double alt_err_deviation; }

user_defined_types: struct oscillator_t { _Bool running; _Bool reference; _Bool disciplined; int delta; }

user_defined_types: struct version_t { char release[64]; char rev[64]; int proto_major; char remote[128]; }

user_defined_types: struct timedelta_t { struct timespec real; struct timespec clock; }

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

user_defined_types: struct rtcm3_1003_t { struct rtcm3_rtk_hdr header; struct { unsigned int ident; struct rtcm3_basic_rtk L1; struct rtcm3_basic_rtk L2; } rtk_data[64]; }

user_defined_types: struct rtcm3_1004_t { struct rtcm3_rtk_hdr header; struct { unsigned int ident; struct rtcm3_extended_rtk L1; struct rtcm3_extended_rtk L2; } rtk_data[64]; }

user_defined_types: struct rtcm3_1005_t { unsigned int station_id; int system; _Bool reference_station; _Bool single_receiver; double ecef_x; }

user_defined_types: struct rtcm3_1006_t { unsigned int station_id; int system; _Bool reference_station; _Bool single_receiver; double ecef_x; double height; }

user_defined_types: struct rtcm3_1014_t { unsigned int network_id; unsigned int subnetwork_id; unsigned int stationcount; unsigned int master_id; unsigned int aux_id; double d_lat; }

user_defined_types: struct rtcm3_1015_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[64]; }

user_defined_types: struct rtcm3_1016_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[64]; }

user_defined_types: struct rtcm3_1017_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[64]; }

user_defined_types: struct rtcm3_1019_t { unsigned int ident; unsigned int week; unsigned char sv_accuracy; enum { reserved_code=0, p=1, ca=2, l2c=3 } code; double idot; unsigned char iode; unsigned int t_sub_oc; int a_sub_f2; int a_sub_f1; int a_sub_f0; unsigned int iodc; int C_sub_rs; int delta_sub_n; int M_sub_0; int C_sub_uc; unsigned int e; int C_sub_us; unsigned int sqrt_sub_A; unsigned int t_sub_oe; int C_sub_ic; int OMEGA_sub_0; int C_sub_is; int i_sub_0; int C_sub_rc; int argument_of_perigee; int omegadot; int t_sub_GD; unsigned char sv_health; _Bool p_data; _Bool fit_interval; }

user_defined_types: struct rtcm3_1020_t { unsigned int ident; unsigned short channel; _Bool C_sub_n; _Bool health_avAilability_indicator; unsigned char P1; unsigned short t_sub_k; _Bool msb_of_B_sub_n; _Bool P2; _Bool t_sub_b; int x_sub_n_t_of_t_sub_b_prime; int x_sub_n_t_of_t_sub_b; int x_sub_n_t_of_t_sub_b_prime_prime; int y_sub_n_t_of_t_sub_b_prime; int y_sub_n_t_of_t_sub_b; int y_sub_n_t_of_t_sub_b_prime_prime; int z_sub_n_t_of_t_sub_b_prime; int z_sub_n_t_of_t_sub_b; int z_sub_n_t_of_t_sub_b_prime_prime; _Bool P3; int gamma_sub_n_of_t_sub_b; unsigned char MP; _Bool Ml_n; int tau_n_of_t_sub_b; int M_delta_tau_sub_n; unsigned int E_sub_n; _Bool MP4; unsigned char MF_sub_T; unsigned char MN_sub_T; unsigned char MM; _Bool additioinal_data_availability; unsigned int N_sup_A; unsigned int tau_sub_c; unsigned int M_N_sub_4; int M_tau_sub_GPS; _Bool M_l_sub_n; }

user_defined_types: struct rtcm3_1029_t { unsigned int station_id; unsigned short mjd; unsigned int sod; unsigned long len; unsigned long unicode_units; unsigned char text[128]; }

user_defined_types: struct rtcm3_1033_t { unsigned int station_id; char descriptor[-1]; unsigned int setup_id; char serial[-1]; char receiver[-1]; char firmware[-1]; }

user_defined_types: struct rtcm3_rtk_hdr { unsigned int station_id; long tow; _Bool sync; unsigned short satcount; _Bool smoothing; unsigned int interval; }

user_defined_types: struct rtcm3_network_rtk_header { unsigned int network_id; unsigned int subnetwork_id; long time; _Bool multimesg; unsigned int master_id; unsigned int aux_id; unsigned char satcount; }

user_defined_types: struct almanac_t { unsigned char sv; unsigned char toa; long l_toa; unsigned char svh; short deltai; double d_deltai; int M0; double d_M0; int Omega0; double d_Omega0; int omega; double d_omega; short af0; double d_af0; short af1; double d_af1; unsigned short e; double d_eccentricity; unsigned int sqrtA; double d_sqrtA; short Omegad; double d_Omegad; }

user_defined_types: struct gps_rangesat_t { unsigned int ident; unsigned int udre; unsigned int iod; double prc; double rrc; }

user_defined_types: struct consat_t { unsigned int ident; _Bool iodl; unsigned int health; int snr; _Bool health_en; _Bool new_data; _Bool los_warning; unsigned int tou; }

user_defined_types: struct station_t { double latitude; unsigned int range; double frequency; unsigned int health; unsigned int station_id; unsigned int bitrate; }

user_defined_types: struct glonass_rangesat_t { unsigned int ident; unsigned int udre; unsigned int tod; _Bool change; double prc; double rrc; }

user_defined_types: struct rtcm3_1001_t { unsigned int ident; struct rtcm3_basic_rtk L1; }

user_defined_types: struct rtcm3_1002_t { unsigned int ident; struct rtcm3_extended_rtk L1; }

user_defined_types: struct rtcm3_1009_t { unsigned int ident; struct rtcm3_basic_rtk L1; }

user_defined_types: struct rtcm3_1010_t { unsigned int ident; struct rtcm3_extended_rtk L1; }

user_defined_types: struct rtcm3_1011_t { unsigned int ident; struct rtcm3_extended_rtk L1; struct rtcm3_extended_rtk L2; }

user_defined_types: struct rtcm3_1012_t { unsigned int ident; struct rtcm3_extended_rtk L1; struct rtcm3_extended_rtk L2; }

user_defined_types: struct rtcm3_1013_t { unsigned short id; _Bool sync; unsigned short interval; }

user_defined_types: struct rtcm3_correction_diff { unsigned char ident; enum { reserved=0, correct=1, widelane=2, uncertain=3 } ambiguity; unsigned char nonsync; double geometric_diff; unsigned char iode; double ionospheric_diff; }

user_defined_types: struct route_info { unsigned int linkage; unsigned int sender; unsigned int rtype; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int duration; int waycount; struct waypoint_t waypoints[16]; }

user_defined_types: struct rtcm3_basic_rtk { unsigned char indicator; unsigned int channel; double pseudorange; double rangediff; unsigned char locktime; }

user_defined_types: struct rtcm3_extended_rtk { unsigned char indicator; unsigned int channel; double pseudorange; double rangediff; unsigned char locktime; unsigned char ambiguity; double CNR; }

user_defined_types: struct cargo_t { unsigned int code; unsigned int subtype; }

user_defined_types: struct tidal_t { int lon; int lat; unsigned int from_hour; unsigned int from_min; unsigned int to_hour; unsigned int to_min; unsigned int cdir; unsigned int cspeed; }

user_defined_types: struct gauge_t { unsigned int id; int level; }

user_defined_types: struct target_t { unsigned int idtype; union target_id id; int lat; int lon; unsigned int course; unsigned int second; unsigned int speed; }

user_defined_types: union target_id { unsigned int mmsi; unsigned int imo; char callsign[-1]; char other[-1]; }


decompiled_code:
__int64 gps_start()
{
unsigned int v0; // er12
int *v2; // rax
const char *v3; // rax

if ( (unsigned int)gps_open("shared memory", 0LL, &gpsdata) )
{
v2 = _errno_location();
v0 = -1;
v3 = (const char *)gps_errstr((unsigned int)*v2);
printf("couldn't connect to gpsd: %s\n", v3);
}
else
{
v0 = 0;
if ( (unsigned int)gps_stream(&gpsdata, 1LL, 0LL) == -1 )
perror("gps_stream()");
gps_available = 1;
}
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // er12
int *v2; // rax
const char *v3; // rax

if ( (unsigned int)gps_open("shared memory", 0LL, &gpsdata) )
{
v2 = _errno_location();
v0 = -1;
v3 = (const char *)gps_errstr((unsigned int)*v2);
printf("couldn't connect to gpsd: %s\n", v3);
}
else
{
v0 = 0;
if ( (unsigned int)gps_stream(&gpsdata, 1LL, 0LL) == -1 )
perror("gps_stream()");
gps_available = 1;
}
return v0;
}

original_code:
int
gps_start(void) {
    if (gps_open("shared memory", ((void *)0), &gpsdata) != 0) {
        printf("couldn't connect to gpsd: %s\n", gps_errstr((*__errno_location ())));
        return -1;
    }
    if (gps_stream((struct gps_data_t *) &gpsdata, 0x000001u, ((void *)0)) == -1)
        perror("gps_stream()");
    gps_available = 1;
    return 0;
}

canonical_original_code:
int gps_start() {
    if (gps_open("shared memory", ((void *)0), &gpsdata) != 0) {
        printf("couldn't connect to gpsd: %s\n", gps_errstr((*__errno_location ())));
        return -1;
    }
    if (gps_stream((struct gps_data_t *) &gpsdata, 0x000001u, ((void *)0)) == -1)
        perror("gps_stream()");
    gps_available = 1;
    return 0;
}

user_defined_types: struct gps_data_t { unsigned long set; double online; int gps_fd; struct gps_fix_t fix; double separation; int status; int satellites_used; struct dop_t dop; double epe; double skyview_time; int satellites_visible; struct satellite_t skyview[72]; struct devconfig_t dev; struct policy_t policy; struct { double time; int ndevices; struct devconfig_t list[4]; } devices; union { struct rtcm2_t rtcm2; struct rtcm3_t rtcm3; struct subframe_t subframe; struct ais_t ais; struct attitude_t attitude; struct navdata_t navdata; struct rawdata_t raw; struct gst_t gst; struct oscillator_t osc; struct version_t version; char error[256]; struct timedelta_t toff; struct timedelta_t pps; }; void *privdata; }

user_defined_types: struct gps_fix_t { double time; int mode; double ept; double latitude; double epy; double longitude; double epx; double altitude; double epv; double track; double epd; double speed; double eps; double climb; double epc; }

user_defined_types: struct devconfig_t { char path[128]; int flags; char driver[64]; char subtype[64]; double activated; unsigned int baudrate; char parity; double cycle; int driver_mode; }

user_defined_types: struct policy_t { _Bool watcher; _Bool json; _Bool nmea; int raw; _Bool scaled; _Bool timing; _Bool split24; _Bool pps; int loglevel; char devpath[128]; char remote[128]; }

user_defined_types: struct satellite_t { double ss; _Bool used; short PRN; short elevation; short azimuth; }

user_defined_types: struct rtcm2_t { unsigned int type; unsigned int length; double zcount; unsigned int refstaid; unsigned int seqnum; unsigned int stathlth; union { struct { unsigned int nentries; struct gps_rangesat_t sat[18]; } gps_ranges; struct { _Bool valid; double x; } ecef; struct { _Bool valid; int system; int sense; char datum[6]; double dx; } reference; struct { unsigned int nentries; struct consat_t sat[-1]; } conhealth; struct { unsigned int nentries; struct station_t station[10]; } almanac; struct { _Bool status; _Bool rangeflag; double lat; unsigned int range; } xmitter; struct { unsigned int week; unsigned int hour; unsigned int leapsecs; } gpstime; struct { unsigned int nentries; struct glonass_rangesat_t sat[18]; } glonass_ranges; char message[-1]; unsigned int words[-1]; }; }

user_defined_types: struct rtcm3_t { unsigned int type; unsigned int length; union { struct { struct rtcm3_rtk_hdr header; struct rtcm3_1001_t rtk_data[64]; } rtcm3_1001; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1002_t rtk_data[64]; } rtcm3_1002; struct rtcm3_1003_t rtcm3_1003; struct rtcm3_1004_t rtcm3_1004; struct rtcm3_1005_t rtcm3_1005; struct rtcm3_1006_t rtcm3_1006; struct { unsigned int station_id; char descriptor[-1]; unsigned int setup_id; } rtcm3_1007; struct { unsigned int station_id; char descriptor[-1]; unsigned int setup_id; char serial[-1]; } rtcm3_1008; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1009_t rtk_data[64]; } rtcm3_1009; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1010_t rtk_data[64]; } rtcm3_1010; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1011_t rtk_data[64]; } rtcm3_1011; struct { struct rtcm3_rtk_hdr header; struct rtcm3_1012_t rtk_data[64]; } rtcm3_1012; struct { unsigned int station_id; unsigned short mjd; unsigned int sod; unsigned char leapsecs; unsigned char ncount; struct rtcm3_1013_t announcements[32]; } rtcm3_1013; struct rtcm3_1014_t rtcm3_1014; struct rtcm3_1015_t rtcm3_1015; struct rtcm3_1016_t rtcm3_1016; struct rtcm3_1017_t rtcm3_1017; struct rtcm3_1019_t rtcm3_1019; struct rtcm3_1020_t rtcm3_1020; struct rtcm3_1029_t rtcm3_1029; struct rtcm3_1033_t rtcm3_1033; unsigned char data[1024]; } rtcmtypes; }

user_defined_types: struct subframe_t { unsigned char subframe_num; unsigned char data_id; unsigned char pageid; unsigned char tSVID; unsigned int TOW17; long l_TOW17; _Bool integrity; _Bool alert; _Bool antispoof; int is_almanac; union { struct { unsigned short WN; unsigned short IODC; unsigned short toc; long l_toc; unsigned char l2; unsigned char l2p; unsigned int ura; unsigned int hlth; int af0; double d_af0; short af1; double d_af1; char af2; double d_af2; char Tgd; double d_Tgd; } sub1; struct { unsigned char IODE; unsigned char AODO; unsigned short u_AODO; unsigned char fit; unsigned short toe; long l_toe; short Crs; double d_Crs; short Cus; double d_Cus; short Cuc; double d_Cuc; short deltan; double d_deltan; int M0; double d_M0; unsigned int e; double d_eccentricity; unsigned int sqrtA; double d_sqrtA; } sub2; struct { unsigned char IODE; short IDOT; double d_IDOT; short Cic; double d_Cic; short Cis; double d_Cis; short Crc; double d_Crc; int i0; double d_i0; int Omega0; double d_Omega0; int omega; double d_omega; int Omegad; double d_Omegad; } sub3; struct { struct almanac_t almanac; } sub4; struct { char ERD[33]; unsigned char ai; } sub4_13; struct { char str[24]; } sub4_17; struct { int A0; double d_A0; int A1; double d_A1; char alpha0; double d_alpha0; char alpha1; double d_alpha1; char alpha2; double d_alpha2; char alpha3; double d_alpha3; char beta0; double d_beta0; char beta1; double d_beta1; char beta2; double d_beta2; char beta3; double d_beta3; char leap; char lsf; unsigned char tot; double d_tot; unsigned char WNt; unsigned char WNlsf; unsigned char DN; } sub4_18; struct { unsigned char svf[33]; unsigned char svhx[8]; } sub4_25; struct { struct almanac_t almanac; } sub5; struct { unsigned char toa; long l_toa; unsigned char WNa; unsigned char sv[25]; } sub5_25; }; }

user_defined_types: struct ais_t { unsigned int type; unsigned int repeat; unsigned int mmsi; union { struct { unsigned int status; int turn; unsigned int speed; _Bool accuracy; int lon; int lat; unsigned int course; unsigned int heading; unsigned int second; unsigned int maneuver; _Bool raim; unsigned int radio; } type1; struct { unsigned int year; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int second; _Bool accuracy; int lon; int lat; unsigned int epfd; _Bool raim; unsigned int radio; } type4; struct { unsigned int ais_version; unsigned int imo; char callsign[-1]; char shipname[-1]; unsigned int shiptype; unsigned int to_bow; unsigned int to_stern; unsigned int to_port; unsigned int to_starboard; unsigned int epfd; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int draught; char destination[-1]; unsigned int dte; } type5; struct { unsigned int seqno; unsigned int dest_mmsi; _Bool retransmit; unsigned int dac; unsigned int fid; _Bool structured; unsigned long bitcount; union { char bitdata[-1]; struct { char country[-1]; char locode[-1]; char section[-1]; char terminal[-1]; char hectometre[-1]; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int tugs; unsigned int airdraught; } dac200fid21; struct { char country[-1]; char locode[-1]; char section[-1]; char terminal[-1]; char hectometre[-1]; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int status; } dac200fid22; struct { unsigned int crew; unsigned int passengers; unsigned int personnel; } dac200fid55; struct { unsigned int ana_int; unsigned int ana_ext1; unsigned int ana_ext2; unsigned int racon; unsigned int light; _Bool alarm; unsigned int stat_ext; _Bool off_pos; } dac235fid10; struct { char lastport[-1]; unsigned int lmonth; unsigned int lday; unsigned int lhour; unsigned int lminute; char nextport[-1]; unsigned int nmonth; unsigned int nday; unsigned int nhour; unsigned int nminute; char dangerous[-1]; char imdcat[-1]; unsigned int unid; unsigned int amount; unsigned int unit; } dac1fid12; struct { unsigned int airdraught; } dac1fid15; struct { unsigned int persons; } dac1fid16; struct { unsigned int linkage; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; char portname[-1]; char destination[-1]; int lon; int lat; } dac1fid18; struct { unsigned int linkage; unsigned int berth_length; unsigned int berth_depth; unsigned int position; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int availability; unsigned int agent; unsigned int fuel; unsigned int chandler; unsigned int stevedore; unsigned int electrical; unsigned int water; unsigned int customs; unsigned int cartage; unsigned int crane; unsigned int lift; unsigned int medical; unsigned int navrepair; unsigned int provisions; unsigned int shiprepair; unsigned int surveyor; unsigned int steam; unsigned int tugs; unsigned int solidwaste; unsigned int liquidwaste; unsigned int hazardouswaste; unsigned int ballast; unsigned int additional; unsigned int regional1; unsigned int regional2; unsigned int future1; unsigned int future2; char berth_name[-1]; int berth_lon; int berth_lat; } dac1fid20; struct { _Bool wmo; union { struct { char location[-1]; int lon; int lat; unsigned int day; unsigned int hour; unsigned int minute; _Bool vislimit; unsigned int visibility; unsigned int humidity; unsigned int wspeed; unsigned int wgust; unsigned int wdir; unsigned int pressure; unsigned int pressuretend; int airtemp; unsigned int watertemp; unsigned int waveperiod; unsigned int wavedir; unsigned int swellheight; unsigned int swellperiod; unsigned int swelldir; } nonwmo_obs; struct { int lon; int lat; unsigned int month; unsigned int day; unsigned int hour; unsigned int minute; unsigned int course; unsigned int speed; unsigned int heading; unsigned int pressure; unsigned int pdelta; unsigned int ptend; unsigned int twinddir; unsigned int twindspeed; unsigned int rwinddir; unsigned int rwindspeed; unsigned int mgustspeed; unsigned int mgustdir; unsigned int airtemp; unsigned int humidity; } wmo_obs; }; } dac1fid21; struct { unsigned int unit; unsigned int amount; int ncargos; struct cargo_t cargos[28]; } dac1fid25; struct route_info dac1fid28; struct { unsigned int linkage; char text[154]; } dac1fid30; struct { unsigned int month; unsigned int day; int ntidals; struct tidal_t tidals[3]; } dac1fid32; }; } type6; struct { unsigned int mmsi1; unsigned int mmsi2; unsigned int mmsi3; unsigned int mmsi4; } type7; struct { unsigned int dac; unsigned int fid; unsigned long bitcount; _Bool structured; union { char bitdata[-1]; struct { char vin[-1]; unsigned int length; unsigned int beam; unsigned int shiptype; unsigned int hazard; unsigned int draught; unsigned int loaded; _Bool speed_q; _Bool course_q; _Bool heading_q; } dac200fid10; struct { unsigned int start_year; unsigned int start_month; unsigned int start_day; unsigned int end_year; unsigned int end_month; unsigned int end_day; unsigned int start_hour; unsigned int start_minute; unsigned int end_hour; unsigned int end_minute; int start_lon; int start_lat; int end_lon; int end_lat; unsigned int type; int min; int max; unsigned int intensity; unsigned int wind; } dac200fid23; struct { char country[-1]; int ngauges; struct gauge_t gauges[4]; } dac200fid24; struct { int lon; int lat; unsigned int form; unsigned int facing; unsigned int direction; unsigned int status; } dac200fid40; struct { int lon; int lat; unsigned int day; unsigned int hour; unsigned int minute; unsigned int wspeed; unsigned int wgust; unsigned int wdir; unsigned int wgustdir; unsigned int airtemp; unsigned int humidity; unsigned int dewpoint; unsigned int pressure; unsigned int pressuretend; unsigned int visibility; int waterlevel; unsigned int leveltrend; unsigned int cspeed; unsigned int cdir; unsigned int cspeed2; unsigned int cdir2; unsigned int cdepth2; unsigned int cspeed3; unsigned int cdir3; unsigned int cdepth3; unsigned int waveheight; unsigned int waveperiod; unsigned int wavedir; unsigned int swellheight; unsigned int swellperiod; unsigned int swelldir; unsigned int seastate; unsigned int watertemp; unsigned int preciptype; unsigned int salinity; unsigned int ice; } dac1fid11; struct { char reason[-1]; char closefrom[-1]; char closeto[-1]; unsigned int radius; unsigned int extunit; unsigned int fday; unsigned int fmonth; unsigned int fhour; unsigned int fminute; unsigned int tday; unsigned int tmonth; unsigned int thour; unsigned int tminute; } dac1fid13; struct { unsigned int airdraught; } dac1fid15; struct { unsigned int persons; } dac1fid16; struct { int ntargets; struct target_t targets[4]; } dac1fid17; struct { unsigned int linkage; char station[-1]; int lon; int lat; unsigned int status; unsigned int signal; unsigned int hour; unsigned int minute; unsigned int nextsignal; } dac1fid19; struct route_info dac1fid27; struct { unsigned int linkage; char text[162]; } dac1fid29; struct { _Bool accuracy; int lon; int lat; unsigned int day; unsigned int hour; unsigned int minute; unsigned int wspeed; unsigned int wgust; unsigned int wdir; unsigned int wgustdir; int airtemp; unsigned int humidity; int dewpoint; unsigned int pressure; unsigned int pressuretend; _Bool visgreater; unsigned int visibility; int waterlevel; unsigned int leveltrend; unsigned int cspeed; unsigned int cdir; unsigned int cspeed2; unsigned int cdir2; unsigned int cdepth2; unsigned int cspeed3; unsigned int cdir3; unsigned int cdepth3; unsigned int waveheight; unsigned int waveperiod; unsigned int wavedir; unsigned int swellheight; unsigned int swellperiod; unsigned int swelldir; unsigned int seastate; int watertemp; unsigned int preciptype; unsigned int salinity; unsigned int ice; } dac1fid31; }; } type8; struct { unsigned int alt; unsigned int speed; _Bool accuracy; int lon; int lat; unsigned int course; unsigned int second; unsigned int regional; unsigned int dte; _Bool assigned; _Bool raim; unsigned int radio; } type9; struct { unsigned int dest_mmsi; } type10; struct { unsigned int seqno; unsigned int dest_mmsi; _Bool retransmit; char text[157]; } type12; struct { char text[161]; } type14; struct { unsigned int mmsi1; unsigned int type1_1; unsigned int offset1_1; unsigned int type1_2; unsigned int offset1_2; unsigned int mmsi2; unsigned int type2_1; unsigned int offset2_1; } type15; struct { unsigned int mmsi1; unsigned int offset1; unsigned int increment1; unsigned int mmsi2; unsigned int offset2; unsigned int increment2; } type16; struct { int lon; int lat; unsigned long bitcount; char bitdata[-1]; } type17; struct { unsigned int reserved; unsigned int speed; _Bool accuracy; int lon; int lat; unsigned int course; unsigned int heading; unsigned int second; unsigned int regional; _Bool cs; _Bool display; _Bool dsc; _Bool band; _Bool msg22; _Bool assigned; _Bool raim; unsigned int radio; } type18; struct { unsigned int reserved; unsigned int speed; _Bool accuracy; int lon; int lat; unsigned int course; unsigned int heading; unsigned int second; unsigned int regional; char shipname[-1]; unsigned int shiptype; unsigned int to_bow; unsigned int to_stern; unsigned int to_port; unsigned int to_starboard; unsigned int epfd; _Bool raim; unsigned int dte; _Bool assigned; } type19; struct { unsigned int offset1; unsigned int number1; unsigned int timeout1; unsigned int increment1; unsigned int offset2; unsigned int number2; unsigned int timeout2; unsigned int increment2; unsigned int offset3; unsigned int number3; unsigned int timeout3; unsigned int increment3; unsigned int offset4; unsigned int number4; unsigned int timeout4; unsigned int increment4; } type20; struct { unsigned int aid_type; char name[35]; _Bool accuracy; int lon; int lat; unsigned int to_bow; unsigned int to_stern; unsigned int to_port; unsigned int to_starboard; unsigned int epfd; unsigned int second; _Bool off_position; unsigned int regional; _Bool raim; _Bool virtual_aid; _Bool assigned; } type21; struct { unsigned int channel_a; unsigned int channel_b; unsigned int txrx; _Bool power; union { struct { int ne_lon; int ne_lat; int sw_lon; int sw_lat; } area; struct { unsigned int dest1; unsigned int dest2; } mmsi; }; _Bool addressed; _Bool band_a; _Bool band_b; unsigned int zonesize; } type22; struct { int ne_lon; int ne_lat; int sw_lon; int sw_lat; unsigned int stationtype; unsigned int shiptype; unsigned int txrx; unsigned int interval; unsigned int quiet; } type23; struct { char shipname[-1]; enum { both=0, part_a=1, part_b=2 } part; unsigned int shiptype; char vendorid[8]; unsigned int model; unsigned int serial; char callsign[8]; union { unsigned int mothership_mmsi; struct { unsigned int to_bow; unsigned int to_stern; unsigned int to_port; unsigned int to_starboard; } dim; }; } type24; struct { _Bool addressed; _Bool structured; unsigned int dest_mmsi; unsigned int app_id; unsigned long bitcount; char bitdata[-1]; } type25; struct { _Bool addressed; _Bool structured; unsigned int dest_mmsi; unsigned int app_id; unsigned long bitcount; char bitdata[-1]; unsigned int radio; } type26; struct { _Bool accuracy; _Bool raim; unsigned int status; int lon; int lat; unsigned int speed; unsigned int course; _Bool gnss; } type27; }; }

user_defined_types: struct attitude_t { double heading; double pitch; double roll; double yaw; double dip; double mag_len; double mag_x; double mag_y; double mag_z; double acc_len; double acc_x; double acc_y; double acc_z; double gyro_x; double gyro_y; double temp; double depth; char mag_st; char pitch_st; char roll_st; char yaw_st; }

user_defined_types: struct navdata_t { unsigned int version; double compass_heading; double compass_deviation; double compass_variation; double air_temp; double air_pressure; double water_temp; double depth; double depth_offset; double wind_speed; double wind_dir; double crosstrack_error; unsigned int compass_status; unsigned int log_cumulative; unsigned int log_trip; unsigned int crosstrack_status; }

user_defined_types: struct rawdata_t { double codephase[72]; double carrierphase[72]; double pseudorange[72]; double deltarange[72]; double doppler[72]; double mtime[72]; unsigned int satstat[72]; }

user_defined_types: struct gst_t { double utctime; double rms_deviation; double smajor_deviation; double sminor_deviation; double smajor_orientation; double lat_err_deviation; double lon_err_deviation; double alt_err_deviation; }

user_defined_types: struct oscillator_t { _Bool running; _Bool reference; _Bool disciplined; int delta; }

user_defined_types: struct version_t { char release[64]; char rev[64]; int proto_major; char remote[128]; }

user_defined_types: struct timedelta_t { struct timespec real; struct timespec clock; }

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

user_defined_types: struct rtcm3_1003_t { struct rtcm3_rtk_hdr header; struct { unsigned int ident; struct rtcm3_basic_rtk L1; struct rtcm3_basic_rtk L2; } rtk_data[64]; }

user_defined_types: struct rtcm3_1004_t { struct rtcm3_rtk_hdr header; struct { unsigned int ident; struct rtcm3_extended_rtk L1; struct rtcm3_extended_rtk L2; } rtk_data[64]; }

user_defined_types: struct rtcm3_1005_t { unsigned int station_id; int system; _Bool reference_station; _Bool single_receiver; double ecef_x; }

user_defined_types: struct rtcm3_1006_t { unsigned int station_id; int system; _Bool reference_station; _Bool single_receiver; double ecef_x; double height; }

user_defined_types: struct rtcm3_1014_t { unsigned int network_id; unsigned int subnetwork_id; unsigned int stationcount; unsigned int master_id; unsigned int aux_id; double d_lat; }

user_defined_types: struct rtcm3_1015_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[64]; }

user_defined_types: struct rtcm3_1016_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[64]; }

user_defined_types: struct rtcm3_1017_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[64]; }

user_defined_types: struct rtcm3_1019_t { unsigned int ident; unsigned int week; unsigned char sv_accuracy; enum { reserved_code=0, p=1, ca=2, l2c=3 } code; double idot; unsigned char iode; unsigned int t_sub_oc; int a_sub_f2; int a_sub_f1; int a_sub_f0; unsigned int iodc; int C_sub_rs; int delta_sub_n; int M_sub_0; int C_sub_uc; unsigned int e; int C_sub_us; unsigned int sqrt_sub_A; unsigned int t_sub_oe; int C_sub_ic; int OMEGA_sub_0; int C_sub_is; int i_sub_0; int C_sub_rc; int argument_of_perigee; int omegadot; int t_sub_GD; unsigned char sv_health; _Bool p_data; _Bool fit_interval; }

user_defined_types: struct rtcm3_1020_t { unsigned int ident; unsigned short channel; _Bool C_sub_n; _Bool health_avAilability_indicator; unsigned char P1; unsigned short t_sub_k; _Bool msb_of_B_sub_n; _Bool P2; _Bool t_sub_b; int x_sub_n_t_of_t_sub_b_prime; int x_sub_n_t_of_t_sub_b; int x_sub_n_t_of_t_sub_b_prime_prime; int y_sub_n_t_of_t_sub_b_prime; int y_sub_n_t_of_t_sub_b; int y_sub_n_t_of_t_sub_b_prime_prime; int z_sub_n_t_of_t_sub_b_prime; int z_sub_n_t_of_t_sub_b; int z_sub_n_t_of_t_sub_b_prime_prime; _Bool P3; int gamma_sub_n_of_t_sub_b; unsigned char MP; _Bool Ml_n; int tau_n_of_t_sub_b; int M_delta_tau_sub_n; unsigned int E_sub_n; _Bool MP4; unsigned char MF_sub_T; unsigned char MN_sub_T; unsigned char MM; _Bool additioinal_data_availability; unsigned int N_sup_A; unsigned int tau_sub_c; unsigned int M_N_sub_4; int M_tau_sub_GPS; _Bool M_l_sub_n; }

user_defined_types: struct rtcm3_1029_t { unsigned int station_id; unsigned short mjd; unsigned int sod; unsigned long len; unsigned long unicode_units; unsigned char text[128]; }

user_defined_types: struct rtcm3_1033_t { unsigned int station_id; char descriptor[-1]; unsigned int setup_id; char serial[-1]; char receiver[-1]; char firmware[-1]; }

user_defined_types: struct rtcm3_rtk_hdr { unsigned int station_id; long tow; _Bool sync; unsigned short satcount; _Bool smoothing; unsigned int interval; }

user_defined_types: struct rtcm3_network_rtk_header { unsigned int network_id; unsigned int subnetwork_id; long time; _Bool multimesg; unsigned int master_id; unsigned int aux_id; unsigned char satcount; }

user_defined_types: struct almanac_t { unsigned char sv; unsigned char toa; long l_toa; unsigned char svh; short deltai; double d_deltai; int M0; double d_M0; int Omega0; double d_Omega0; int omega; double d_omega; short af0; double d_af0; short af1; double d_af1; unsigned short e; double d_eccentricity; unsigned int sqrtA; double d_sqrtA; short Omegad; double d_Omegad; }

user_defined_types: struct gps_rangesat_t { unsigned int ident; unsigned int udre; unsigned int iod; double prc; double rrc; }

user_defined_types: struct consat_t { unsigned int ident; _Bool iodl; unsigned int health; int snr; _Bool health_en; _Bool new_data; _Bool los_warning; unsigned int tou; }

user_defined_types: struct station_t { double latitude; unsigned int range; double frequency; unsigned int health; unsigned int station_id; unsigned int bitrate; }

user_defined_types: struct glonass_rangesat_t { unsigned int ident; unsigned int udre; unsigned int tod; _Bool change; double prc; double rrc; }


decompiled_code:
__int64 gps_reconnect()
{
fwrite("reconnecting to gpsd...\n", 1uLL, 0x18uLL, stderr);
gps_stop();
return gps_start();
}

canonical_decompiled_code:
__int64 func2()
{
fwrite("reconnecting to gpsd...\n", 1uLL, 0x18uLL, stderr);
func0();
return func1();
}

original_code:
void
gps_reconnect(void) {
    fprintf(stderr, "reconnecting to gpsd...\n");
    gps_stop();
    gps_start();
}

canonical_original_code:
void gps_reconnect() {
    fprintf(stderr, "reconnecting to gpsd...\n");
    gps_stop();
    gps_start();
}