main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rdi
const char *v4; // rsi
int v5; // ebx
char *v6; // rax
int *v8; // rax
char v9; // al
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF
time_t buf[2]; // [rsp+28h] [rbp-10h] BYREF

switch ( argc )
{
case 2:
v3 = (char *)argv[1];
v4 = "10010";
break;
case 3:
v3 = (char *)argv[1];
v4 = argv[2];
break;
case 1:
v4 = "10010";
v3 = "127.0.0.1";
break;
default:
errexit("usage: UDPtime [host [port]]\n", (char)argv);
}
v5 = connectUDP(v3, (char)v4, &addr);
fwrite("[CLIENT] sending message to service..\n", 1uLL, 0x26uLL, stderr);
sendto(v5, "what time is it ?\n", 0x12uLL, 0, &addr, 0x10u);
fwrite("[CLIENT] message sent to service, waiting for respond..\n", 1uLL, 0x38uLL, stderr);
addr_len = 16;
if ( (int)recvfrom(v5, buf, 8uLL, 0, &addr, &addr_len) < 0 )
{
v8 = __errno_location();
v9 = (unsigned __int8)strerror(*v8);
errexit("read failed: %s\n", v9);
}
buf[0] = (unsigned int)_bswap_32(buf[0]) - 2208988800LL;
v6 = ctime(buf);
fprintf(stderr, "[CLIENT] now time is : %s\n", v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rdi
const char *v4; // rsi
int v5; // ebx
char *v6; // rax
int *v8; // rax
char v9; // al
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF
time_t buf[2]; // [rsp+28h] [rbp-10h] BYREF

switch ( argc )
{
case 2:
v3 = (char *)argv[1];
v4 = "10010";
break;
case 3:
v3 = (char *)argv[1];
v4 = argv[2];
break;
case 1:
v4 = "10010";
v3 = "127.0.0.1";
break;
default:
func11("usage: UDPtime [host [port]]\n", (char)argv);
}
v5 = func8(v3, (char)v4, &addr);
fwrite("[CLIENT] sending message to service..\n", 1uLL, 0x26uLL, stderr);
sendto(v5, "what time is it ?\n", 0x12uLL, 0, &addr, 0x10u);
fwrite("[CLIENT] message sent to service, waiting for respond..\n", 1uLL, 0x38uLL, stderr);
addr_len = 16;
if ( (int)recvfrom(v5, buf, 8uLL, 0, &addr, &addr_len) < 0 )
{
v8 = __errno_location();
v9 = (unsigned __int8)strerror(*v8);
func11("read failed: %s\n", v9);
}
buf[0] = (unsigned int)func7(buf[0]) - 2208988800LL;
v6 = ctime(buf);
fprintf(stderr, "[CLIENT] now time is : %s\n", v6);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    char *host = "127.0.0.1";
    char *service = "10010";
    time_t now;
    int s, n;
    switch(argc)
    {
        case 1:
            break;
        case 2:
            host = argv[1];
            break;
        case 3:
            host = argv[1];
            service = argv[2];
            break;
        default:
            errexit("usage: UDPtime [host [port]]\n");
    }
    struct sockaddr_in sin;
    s = connectUDP(host, service, &sin);
    fprintf(stderr, "[CLIENT] sending message to service..\n");
    (void) sendto(s, "what time is it ?\n", strlen("what time is it ?\n"), 0, (struct sockaddr*)&sin, sizeof(sin));
    fprintf(stderr, "[CLIENT] message sent to service, waiting for respond..\n");
    int recvlen = sizeof(sin);
    n = recvfrom(s, (char*)&now, sizeof(now), 0, (struct sockaddr*)&sin, &recvlen);
    if (n < 0)
        errexit("read failed: %s\n", strerror((*__errno_location ())));
    now = ntohl((unsigned long)now);
    now -= 2208988800UL;
    fprintf(stderr, "[CLIENT] now time is : %s\n", ctime(&now));
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    char *host = "127.0.0.1";
    char *service = "10010";
    long now;
    int s; int n;
    switch(argc)
    {
        case 1:
            break;
        case 2:
            host = argv[1];
            break;
        case 3:
            host = argv[1];
            service = argv[2];
            break;
        default:
            errexit("usage: UDPtime [host [port]]\n");
    }
    struct sockaddr_in sin;
    s = connectUDP(host, service, &sin);
    fprintf(stderr, "[CLIENT] sending message to service..\n");
    (void) sendto(s, "what time is it ?\n", strlen("what time is it ?\n"), 0, (struct sockaddr *)&sin, sizeof(sin));
    fprintf(stderr, "[CLIENT] message sent to service, waiting for respond..\n");
    int recvlen = sizeof(sin);
    n = recvfrom(s, (char *)&now, sizeof(now), 0, (struct sockaddr *)&sin, &recvlen);
    if (n < 0)
        errexit("read failed: %s\n", strerror((*__errno_location ())));
    now = ntohl((unsigned long)now);
    now -= 2208988800UL;
    fprintf(stderr, "[CLIENT] now time is : %s\n", ctime(&now));
    return 0;
}

variable_types:
argv
char *[]

variable_types: now long

variable_types: s int

variable_types: recvlen int


readtask

repo: linfan/TCP-IP-Network-basic-examples

decompiled_code:
void __fastcall __noreturn readtask(void *a1)
{
int *v1; // r12
int *i; // rdi
int v3; // ebp
_DWORD *v4; // rbx
int v5; // eax
int v6; // edx
__int64 v7; // rax
char v8; // [rsp+0h] [rbp-28h]
char v9; // [rsp+0h] [rbp-28h]

while ( 1 )
{
pthread_mutex_lock(&r_mutex);
for ( i = (int *)readhead; !readhead; i = (int *)readhead )
pthread_cond_wait(&r_condl, &r_mutex);
v3 = *i;
readhead = (void *)*((_QWORD *)i + 1);
free(i);
pthread_mutex_unlock(&r_mutex);
pthread_self();
echo("[SERVER] readtask %d handling %d\n", v8);
v4 = malloc(0x14uLL);
*v4 = v3;
v5 = recv(v3, v4 + 2, 0xAuLL, 0);
v6 = v5;
if ( v5 < 0 )
{
v1 = __errno_location();
if ( *v1 == 104 )
close(v3);
strerror(*v1);
echo("[SERVER] Error: readline failed: %s\n", v9);
free(v4);
}
else if ( v5 )
{
v4[1] = v5;
v7 = 0LL;
do
{
if ( *((_BYTE *)v4 + v7 + 8) == 10 )
{
*((_BYTE *)v4 + v7 + 8) = 0;
v4[1] = v7 + 1;
}
++v7;
}
while ( v6 > (int)v7 );
echo("[SERVER] readtask %d received %d : [%d] %s\n", v9);
if ( *((_BYTE *)v4 + 8) )
{
ev.data.u64 = (uint64_t)v4;
ev.events = -2147483644;
epoll_ctl(epfd, 3, v3, &ev);
}
}
else
{
close(v3);
echo("[SERVER] Error: client closed connection.\n", v9);
free(v4);
}
}
}

canonical_decompiled_code:
void __fastcall __noreturn func8(void *a1)
{
int *v1; // r12
int *i; // rdi
int v3; // ebp
_DWORD *v4; // rbx
int v5; // eax
int v6; // edx
__int64 v7; // rax
char v8; // [rsp+0h] [rbp-28h]
char v9; // [rsp+0h] [rbp-28h]

while ( 1 )
{
pthread_mutex_lock(&r_mutex);
for ( i = (int *)readhead; !readhead; i = (int *)readhead )
pthread_cond_wait(&r_condl, &r_mutex);
v3 = *i;
readhead = (void *)*((_QWORD *)i + 1);
free(i);
pthread_mutex_unlock(&r_mutex);
pthread_self();
func12("[SERVER] readtask %d handling %d\n", v8);
v4 = malloc(0x14uLL);
*v4 = v3;
v5 = recv(v3, v4 + 2, 0xAuLL, 0);
v6 = v5;
if ( v5 < 0 )
{
v1 = __errno_location();
if ( *v1 == 104 )
close(v3);
strerror(*v1);
func12("[SERVER] Error: readline failed: %s\n", v9);
free(v4);
}
else if ( v5 )
{
v4[1] = v5;
v7 = 0LL;
do
{
if ( *((_BYTE *)v4 + v7 + 8) == 10 )
{
*((_BYTE *)v4 + v7 + 8) = 0;
v4[1] = v7 + 1;
}
++v7;
}
while ( v6 > (int)v7 );
func12("[SERVER] readtask %d received %d : [%d] %s\n", v9);
if ( *((_BYTE *)v4 + 8) )
{
ev.data.u64 = (uint64_t)v4;
ev.events = -2147483644;
epoll_ctl(epfd, 3, v3, &ev);
}
}
else
{
close(v3);
func12("[SERVER] Error: client closed connection.\n", v9);
free(v4);
}
}
}

original_code:
void *readtask(void *args)
{
    int fd = -1;
    int n, i;
    struct user_data* data = ((void *)0);
    while(1)
    {
        pthread_mutex_lock(&r_mutex);
        while(readhead == ((void *)0))
            pthread_cond_wait(&r_condl, &r_mutex);
        fd = readhead->data.fd;
        struct task* tmp = readhead;
        readhead = readhead->next;
        free(tmp);
        pthread_mutex_unlock(&r_mutex);
        echo("[SERVER] readtask %d handling %d\n", pthread_self(), fd);
        data = malloc(sizeof(struct user_data));
        data->fd = fd;
        if ((n = recv(fd, data->line, 10, 0)) < 0)
        {
            if ((*__errno_location ()) == 104)
                close(fd);
            echo("[SERVER] Error: readline failed: %s\n", strerror((*__errno_location ())));
            if (data != ((void *)0))
                free(data);
        }
        else if (n == 0)
        {
            close(fd);
            echo("[SERVER] Error: client closed connection.\n");
            if (data != ((void *)0))
                free(data);
        }
        else
        {
            data->n_size = n;
            for (i = 0; i < n; ++i)
            {
                if (data->line[i] == '\n' || data->line[i] > 128)
                {
                    data->line[i] = '\0';
                    data->n_size = i + 1;
                }
            }
            echo("[SERVER] readtask %d received %d : [%d] %s\n", pthread_self(), fd, data->n_size, data->line);
            if (data->line[0] != '\0')
            {
                ev.data.ptr = data;
                ev.events = EPOLLOUT | EPOLLET;
                epoll_ctl(epfd, 3, fd, &ev);
            }
        }
    }
}

canonical_original_code:
void *readtask(void *args)
{
    int fd = -1;
    int n; int i;
    struct user_data *data = ((void *)0);
    while(1)
    {
        pthread_mutex_lock(&r_mutex);
        while(readhead == ((void *)0))
            pthread_cond_wait(&r_condl, &r_mutex);
        fd = readhead->data.fd;
        struct task *tmp = readhead;
        readhead = readhead->next;
        free(tmp);
        pthread_mutex_unlock(&r_mutex);
        echo("[SERVER] readtask %d handling %d\n", pthread_self(), fd);
        data = malloc(sizeof(struct user_data));
        data->fd = fd;
        if ((n = recv(fd, data->line, 10, 0)) < 0)
        {
            if ((*__errno_location ()) == 104)
                close(fd);
            echo("[SERVER] Error: readline failed: %s\n", strerror((*__errno_location ())));
            if (data != ((void *)0))
                free(data);
        }
        else if (n == 0)
        {
            close(fd);
            echo("[SERVER] Error: client closed connection.\n");
            if (data != ((void *)0))
                free(data);
        }
        else
        {
            data->n_size = n;
            for (i = 0; i < n; ++i)
            {
                if (data->line[i] == '\n' || data->line[i] > 128)
                {
                    data->line[i] = '\0';
                    data->n_size = i + 1;
                }
            }
            echo("[SERVER] readtask %d received %d : [%d] %s\n", pthread_self(), fd, data->n_size, data->line);
            if (data->line[0] != '\0')
            {
                ev.data.ptr = data;
                ev.events = EPOLLOUT | EPOLLET;
                epoll_ctl(epfd, 3, fd, &ev);
            }
        }
    }
}

variable_types:
args
void *

variable_types: fd int

variable_types: n int

variable_types: i int

variable_types: struct user_data { int fd; unsigned int n_size; char line[10]; } *

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

return_type: void *

user_defined_types: struct task { union epoll_data data; struct task *next; }


writetask

decompiled_code:
void __fastcall __noreturn writetask(void *a1)
{
__int64 *i; // rdi
__int64 v2; // rbx
char v3; // [rsp+0h] [rbp-18h]

while ( 1 )
{
pthread_mutex_lock(&w_mutex);
for ( i = (__int64 *)writehead; !writehead; i = (__int64 *)writehead )
pthread_cond_wait(&w_condl, &w_mutex);
v2 = *i;
writehead = (void *)i[1];
free(i);
pthread_mutex_unlock(&w_mutex);
pthread_self();
echo("[SERVER] writetask %d sending %d : [%d] %s\n", v3);
if ( (unsigned int)send(*(_DWORD *)v2, (const void *)(v2 + 8), *(unsigned int *)(v2 + 4), 0) )
{
ev.data.fd = *(_DWORD *)v2;
ev.events = -2147483647;
epoll_ctl(epfd, 3, *(_DWORD *)v2, &ev);
}
else
{
close(*(_DWORD *)v2);
echo("[SERVER] Error: client closed connection.", v3);
}
free((void *)v2);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func9(void *a1)
{
__int64 *i; // rdi
__int64 v2; // rbx
char v3; // [rsp+0h] [rbp-18h]

while ( 1 )
{
pthread_mutex_lock(&w_mutex);
for ( i = (__int64 *)writehead; !writehead; i = (__int64 *)writehead )
pthread_cond_wait(&w_condl, &w_mutex);
v2 = *i;
writehead = (void *)i[1];
free(i);
pthread_mutex_unlock(&w_mutex);
pthread_self();
func12("[SERVER] writetask %d sending %d : [%d] %s\n", v3);
if ( (unsigned int)send(*(_DWORD *)v2, (const void *)(v2 + 8), *(unsigned int *)(v2 + 4), 0) )
{
ev.data.fd = *(_DWORD *)v2;
ev.events = -2147483647;
epoll_ctl(epfd, 3, *(_DWORD *)v2, &ev);
}
else
{
close(*(_DWORD *)v2);
func12("[SERVER] Error: client closed connection.", v3);
}
free((void *)v2);
}
}

original_code:
void *writetask(void *args)
{
    unsigned int n;
    struct user_data *rdata = ((void *)0);
    while(1)
    {
        pthread_mutex_lock(&w_mutex);
        while(writehead == ((void *)0))
            pthread_cond_wait(&w_condl, &w_mutex);
        rdata = (struct user_data*)writehead->data.ptr;
        struct task* tmp = writehead;
        writehead = writehead->next;
        free(tmp);
        pthread_mutex_unlock(&w_mutex);
        echo("[SERVER] writetask %d sending %d : [%d] %s\n", pthread_self(), rdata->fd, rdata->n_size, rdata->line);
        if ((n = send(rdata->fd, rdata->line, rdata->n_size, 0)) < 0)
        {
            if ((*__errno_location ()) == 104)
                close(rdata->fd);
            echo("[SERVER] Error: send responce failed: %s\n", strerror((*__errno_location ())));
        }
        else if (n == 0)
        {
            close(rdata->fd);
            echo("[SERVER] Error: client closed connection.");
        }
        else
        {
            ev.data.fd = rdata->fd;
            ev.events = EPOLLIN | EPOLLET;
            epoll_ctl(epfd, 3, rdata->fd, &ev);
        }
        free(rdata);
    }
}

canonical_original_code:
void *writetask(void *args)
{
    unsigned int n;
    struct user_data *rdata = ((void *)0);
    while(1)
    {
        pthread_mutex_lock(&w_mutex);
        while(writehead == ((void *)0))
            pthread_cond_wait(&w_condl, &w_mutex);
        rdata = (struct user_data *)writehead->data.ptr;
        struct task *tmp = writehead;
        writehead = writehead->next;
        free(tmp);
        pthread_mutex_unlock(&w_mutex);
        echo("[SERVER] writetask %d sending %d : [%d] %s\n", pthread_self(), rdata->fd, rdata->n_size, rdata->line);
        if ((n = send(rdata->fd, rdata->line, rdata->n_size, 0)) < 0)
        {
            if ((*__errno_location ()) == 104)
                close(rdata->fd);
            echo("[SERVER] Error: send responce failed: %s\n", strerror((*__errno_location ())));
        }
        else if (n == 0)
        {
            close(rdata->fd);
            echo("[SERVER] Error: client closed connection.");
        }
        else
        {
            ev.data.fd = rdata->fd;
            ev.events = EPOLLIN | EPOLLET;
            epoll_ctl(epfd, 3, rdata->fd, &ev);
        }
        free(rdata);
    }
}

variable_types:
n
unsigned int

user_defined_types: struct user_data { int fd; unsigned int n_size; char line[10]; }

user_defined_types: union epoll_data { void *ptr; int fd; unsigned int u32; unsigned long u64; }


setnonblocking

decompiled_code:
int __fastcall setnonblocking(char a1)
{
int v1; // eax
__int64 v2; // rdx
int result; // eax

v1 = fcntl(a1, 3);
if ( v1 < 0 )
errexit("GETFL %d failed", a1);
v2 = (unsigned int)v1;
BYTE1(v2) = BYTE1(v1) | 8;
result = fcntl(a1, 4, v2);
if ( result < 0 )
errexit("SETFL %d failed", a1);
return result;
}

canonical_decompiled_code:
int __fastcall func10(char a1)
{
int v1; // eax
__int64 v2; // rdx
int result; // eax

v1 = fcntl(a1, 3);
if ( v1 < 0 )
func11("GETFL %d failed", a1);
v2 = (unsigned int)v1;
BYTE1(v2) = BYTE1(v1) | 8;
result = fcntl(a1, 4, v2);
if ( result < 0 )
func11("SETFL %d failed", a1);
return result;
}

original_code:
void setnonblocking(int sock)
{
    int opts;
    if ((opts = fcntl(sock, 3)) < 0)
        errexit("GETFL %d failed", sock);
    opts = opts | 04000;
    if (fcntl(sock, 4, opts) < 0)
        errexit("SETFL %d failed", sock);
}

variable_types: sock int

variable_types: opts int

return_type: void


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // eax
int v5; // er13
__int64 v6; // rbx
int v7; // eax
__int64 v8; // r12
int v9; // esi
int v10; // eax
_QWORD *v11; // r13
_QWORD *v12; // r13
struct sockaddr inp; // [rsp+0h] [rbp-78h] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-68h] BYREF
socklen_t addr_len; // [rsp+2Ch] [rbp-4Ch] BYREF
pthread_t v16; // [rsp+30h] [rbp-48h] BYREF
pthread_t v17; // [rsp+38h] [rbp-40h] BYREF
pthread_t v18; // [rsp+40h] [rbp-38h] BYREF
pthread_t newthread[6]; // [rsp+48h] [rbp-30h] BYREF

pthread_mutex_init(&r_mutex, 0LL);
pthread_cond_init(&r_condl, 0LL);
pthread_mutex_init(&w_mutex, 0LL);
pthread_cond_init(&w_condl, 0LL);
pthread_create(newthread, 0LL, (void *(*)(void *))readtask, 0LL);
pthread_create(&v18, 0LL, (void *(*)(void *))readtask, 0LL);
pthread_create(&v17, 0LL, (void *(*)(void *))writetask, 0LL);
pthread_create(&v16, 0LL, (void *(*)(void *))writetask, 0LL);
epfd = epoll_create(256);
v3 = socket(2, 1, 0);
setnonblocking(v3);
ev.data.fd = v3;
ev.events = -2147483647;
epoll_ctl(epfd, 1, v3, &ev);
*(_QWORD *)&inp.sa_family = 2LL;
*(_QWORD *)&inp.sa_data[6] = 0LL;
inet_aton("127.0.0.1", (struct in_addr *)&inp.sa_data[2]);
*(_WORD *)inp.sa_data = _bswap_16(10012);
bind(v3, &inp, 0x10u);
listen(v3, 20);
while ( 1 )
{
do
v7 = epoll_wait(epfd, &events, 20, 500);
while ( v7 <= 0 );
v8 = 12LL * (unsigned int)v7;
v6 = 0LL;
do
{
v9 = *(int *)((char *)&events.data.fd + v6);
if ( v9 == v3 )
{
v4 = accept(v3, &addr, &addr_len);
v5 = v4;
if ( v4 < 0 )
errexit("connfd < 0", (char)&addr);
setnonblocking(v4);
inet_ntoa(*(struct in_addr *)&addr.sa_data[2]);
echo("[SERVER] connect from %s \n", inp.sa_family);
ev.data.fd = v5;
ev.events = -2147483647;
epoll_ctl(epfd, 1, v5, &ev);
}
else
{
v10 = *(uint32_t *)((char *)&events.events + v6);
if ( (v10 & 1) != 0 )
{
if ( v9 >= 0 )
{
echo("[SERVER] put task %d to read queue\n", inp.sa_family);
v11 = malloc(0x10uLL);
*(_DWORD *)v11 = *(int *)((char *)&events.data.fd + v6);
v11[1] = 0LL;
pthread_mutex_lock(&r_mutex);
if ( readhead )
*(_QWORD *)(readtail + 8) = v11;
else
readhead = v11;
readtail = (__int64)v11;
pthread_cond_broadcast(&r_condl);
pthread_mutex_unlock(&r_mutex);
}
}
else if ( (v10 & 4) != 0 )
{
if ( *(uint64_t *)((char *)&events.data.u64 + v6) )
{
echo("[SERVER] put task %d to write queue\n", inp.sa_family);
v12 = malloc(0x10uLL);
*v12 = *(void **)((char *)&events.data.ptr + v6);
v12[1] = 0LL;
pthread_mutex_lock(&w_mutex);
if ( writehead )
*(_QWORD *)(writetail + 8) = v12;
else
writehead = v12;
writetail = (__int64)v12;
pthread_cond_broadcast(&w_condl);
pthread_mutex_unlock(&w_mutex);
}
}
else
{
echo("[SERVER] Error: unknown epoll event", inp.sa_family);
}
}
v6 += 12LL;
}
while ( v6 != v8 );
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // eax
int v5; // er13
__int64 v6; // rbx
int v7; // eax
__int64 v8; // r12
int v9; // esi
int v10; // eax
_QWORD *v11; // r13
_QWORD *v12; // r13
struct sockaddr inp; // [rsp+0h] [rbp-78h] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-68h] BYREF
socklen_t addr_len; // [rsp+2Ch] [rbp-4Ch] BYREF
pthread_t v16; // [rsp+30h] [rbp-48h] BYREF
pthread_t v17; // [rsp+38h] [rbp-40h] BYREF
pthread_t v18; // [rsp+40h] [rbp-38h] BYREF
pthread_t newthread[6]; // [rsp+48h] [rbp-30h] BYREF

pthread_mutex_init(&r_mutex, 0LL);
pthread_cond_init(&r_condl, 0LL);
pthread_mutex_init(&w_mutex, 0LL);
pthread_cond_init(&w_condl, 0LL);
pthread_create(newthread, 0LL, (void *(*)(void *))readtask, 0LL);
pthread_create(&v18, 0LL, (void *(*)(void *))readtask, 0LL);
pthread_create(&v17, 0LL, (void *(*)(void *))writetask, 0LL);
pthread_create(&v16, 0LL, (void *(*)(void *))writetask, 0LL);
epfd = epoll_create(256);
v3 = socket(2, 1, 0);
func10(v3);
ev.data.fd = v3;
ev.events = -2147483647;
epoll_ctl(epfd, 1, v3, &ev);
*(_QWORD *)&inp.sa_family = 2LL;
*(_QWORD *)&inp.sa_data[6] = 0LL;
inet_aton("127.0.0.1", (struct in_addr *)&inp.sa_data[2]);
*(_WORD *)inp.sa_data = func7(10012);
bind(v3, &inp, 0x10u);
listen(v3, 20);
while ( 1 )
{
do
v7 = epoll_wait(epfd, &events, 20, 500);
while ( v7 <= 0 );
v8 = 12LL * (unsigned int)v7;
v6 = 0LL;
do
{
v9 = *(int *)((char *)&events.data.fd + v6);
if ( v9 == v3 )
{
v4 = accept(v3, &addr, &addr_len);
v5 = v4;
if ( v4 < 0 )
func11("connfd < 0", (char)&addr);
func10(v4);
inet_ntoa(*(struct in_addr *)&addr.sa_data[2]);
func12("[SERVER] connect from %s \n", inp.sa_family);
ev.data.fd = v5;
ev.events = -2147483647;
epoll_ctl(epfd, 1, v5, &ev);
}
else
{
v10 = *(uint32_t *)((char *)&events.events + v6);
if ( (v10 & 1) != 0 )
{
if ( v9 >= 0 )
{
func12("[SERVER] put task %d to read queue\n", inp.sa_family);
v11 = malloc(0x10uLL);
*(_DWORD *)v11 = *(int *)((char *)&events.data.fd + v6);
v11[1] = 0LL;
pthread_mutex_lock(&r_mutex);
if ( readhead )
*(_QWORD *)(readtail + 8) = v11;
else
readhead = v11;
readtail = (__int64)v11;
pthread_cond_broadcast(&r_condl);
pthread_mutex_unlock(&r_mutex);
}
}
else if ( (v10 & 4) != 0 )
{
if ( *(uint64_t *)((char *)&events.data.u64 + v6) )
{
func12("[SERVER] put task %d to write queue\n", inp.sa_family);
v12 = malloc(0x10uLL);
*v12 = *(void **)((char *)&events.data.ptr + v6);
v12[1] = 0LL;
pthread_mutex_lock(&w_mutex);
if ( writehead )
*(_QWORD *)(writetail + 8) = v12;
else
writehead = v12;
writetail = (__int64)v12;
pthread_cond_broadcast(&w_condl);
pthread_mutex_unlock(&w_mutex);
}
}
else
{
func12("[SERVER] Error: unknown epoll event", inp.sa_family);
}
}
v6 += 12LL;
}
while ( v6 != v8 );
}
}

original_code:
int main(int argc,char* argv[])
{
    int i, maxi, nfds;
    int listenfd, connfd;
    pthread_t tid1, tid2;
    pthread_t tid3, tid4;
    struct task *new_task = ((void *)0);
    socklen_t clilen;
    struct sockaddr_in clientaddr;
    struct sockaddr_in serveraddr;
    pthread_mutex_init(&r_mutex, ((void *)0));
    pthread_cond_init(&r_condl, ((void *)0));
    pthread_mutex_init(&w_mutex, ((void *)0));
    pthread_cond_init(&w_condl, ((void *)0));
    pthread_create(&tid1, ((void *)0), readtask, ((void *)0));
    pthread_create(&tid2, ((void *)0), readtask, ((void *)0));
    pthread_create(&tid3, ((void *)0), writetask, ((void *)0));
    pthread_create(&tid4, ((void *)0), writetask, ((void *)0));
    epfd = epoll_create(256);
    listenfd = socket(2, SOCK_STREAM, 0);
    setnonblocking(listenfd);
    ev.data.fd = listenfd;
    ev.events = EPOLLIN | EPOLLET;
    epoll_ctl(epfd, 1, listenfd, &ev);
    bzero(&serveraddr, sizeof(serveraddr));
    serveraddr.sin_family = 2;
    char *local_addr = "127.0.0.1";
    inet_aton(local_addr, &(serveraddr.sin_addr));
    serveraddr.sin_port = htons(10012);
    bind(listenfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr));
    listen(listenfd, 20);
    maxi = 0;
    for(;;)
    {
        nfds = epoll_wait(epfd, events, 20, 500);
        for (i = 0; i < nfds; ++i)
        {
            if (events[i].data.fd == listenfd)
            {
                connfd = accept(listenfd, (struct sockaddr*)&clientaddr, &clilen);
                if (connfd < 0)
                    errexit("connfd < 0");
                setnonblocking(connfd);
                echo("[SERVER] connect from %s \n", inet_ntoa(clientaddr.sin_addr));
                ev.data.fd = connfd;
                ev.events = EPOLLIN | EPOLLET;
                epoll_ctl(epfd, 1, connfd, &ev);
            }
            else if (events[i].events & EPOLLIN)
            {
                if (events[i].data.fd < 0)
                    continue;
                echo("[SERVER] put task %d to read queue\n", events[i].data.fd);
                new_task = malloc(sizeof(struct task));
                new_task->data.fd = events[i].data.fd;
                new_task->next = ((void *)0);
                pthread_mutex_lock(&r_mutex);
                if (readhead == ((void *)0))
                {
                    readhead = new_task;
                    readtail = new_task;
                }
                else
                {
                    readtail->next = new_task;
                    readtail = new_task;
                }
                pthread_cond_broadcast(&r_condl);
                pthread_mutex_unlock(&r_mutex);
            }
            else if (events[i].events & EPOLLOUT)
            {
                if (events[i].data.ptr == ((void *)0))
                    continue;
                echo("[SERVER] put task %d to write queue\n", ((struct task*)events[i].data.ptr)->data.fd);
                new_task = malloc(sizeof(struct task));
                new_task->data.ptr = (struct user_data*)events[i].data.ptr;
                new_task->next = ((void *)0);
                pthread_mutex_lock(&w_mutex);
                if (writehead == ((void *)0))
                {
                    writehead = new_task;
                    writetail = new_task;
                }
                else
                {
                    writetail->next = new_task;
                    writetail = new_task;
                }
                pthread_cond_broadcast(&w_condl);
                pthread_mutex_unlock(&w_mutex);
            }
            else
            {
                echo("[SERVER] Error: unknown epoll event");
            }
        }
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int i; int maxi; int nfds;
    int listenfd; int connfd;
    unsigned long tid1; unsigned long tid2;
    unsigned long tid3; unsigned long tid4;
    struct task *new_task = ((void *)0);
    unsigned int clilen;
    struct sockaddr_in clientaddr;
    struct sockaddr_in serveraddr;
    pthread_mutex_init(&r_mutex, ((void *)0));
    pthread_cond_init(&r_condl, ((void *)0));
    pthread_mutex_init(&w_mutex, ((void *)0));
    pthread_cond_init(&w_condl, ((void *)0));
    pthread_create(&tid1, ((void *)0), readtask, ((void *)0));
    pthread_create(&tid2, ((void *)0), readtask, ((void *)0));
    pthread_create(&tid3, ((void *)0), writetask, ((void *)0));
    pthread_create(&tid4, ((void *)0), writetask, ((void *)0));
    epfd = epoll_create(256);
    listenfd = socket(2, SOCK_STREAM, 0);
    setnonblocking(listenfd);
    ev.data.fd = listenfd;
    ev.events = EPOLLIN | EPOLLET;
    epoll_ctl(epfd, 1, listenfd, &ev);
    bzero(&serveraddr, sizeof(serveraddr));
    serveraddr.sin_family = 2;
    char *local_addr = "127.0.0.1";
    inet_aton(local_addr, &(serveraddr.sin_addr));
    serveraddr.sin_port = htons(10012);
    bind(listenfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
    listen(listenfd, 20);
    maxi = 0;
    for(;;)
    {
        nfds = epoll_wait(epfd, events, 20, 500);
        for (i = 0; i < nfds; ++i)
        {
            if (events[i].data.fd == listenfd)
            {
                connfd = accept(listenfd, (struct sockaddr *)&clientaddr, &clilen);
                if (connfd < 0)
                    errexit("connfd < 0");
                setnonblocking(connfd);
                echo("[SERVER] connect from %s \n", inet_ntoa(clientaddr.sin_addr));
                ev.data.fd = connfd;
                ev.events = EPOLLIN | EPOLLET;
                epoll_ctl(epfd, 1, connfd, &ev);
            }
            else if (events[i].events & EPOLLIN)
            {
                if (events[i].data.fd < 0)
                    continue;
                echo("[SERVER] put task %d to read queue\n", events[i].data.fd);
                new_task = malloc(sizeof(struct task));
                new_task->data.fd = events[i].data.fd;
                new_task->next = ((void *)0);
                pthread_mutex_lock(&r_mutex);
                if (readhead == ((void *)0))
                {
                    readhead = new_task;
                    readtail = new_task;
                }
                else
                {
                    readtail->next = new_task;
                    readtail = new_task;
                }
                pthread_cond_broadcast(&r_condl);
                pthread_mutex_unlock(&r_mutex);
            }
            else if (events[i].events & EPOLLOUT)
            {
                if (events[i].data.ptr == ((void *)0))
                    continue;
                echo("[SERVER] put task %d to write queue\n", ((struct task *)events[i].data.ptr)->data.fd);
                new_task = malloc(sizeof(struct task));
                new_task->data.ptr = (struct user_data *)events[i].data.ptr;
                new_task->next = ((void *)0);
                pthread_mutex_lock(&w_mutex);
                if (writehead == ((void *)0))
                {
                    writehead = new_task;
                    writetail = new_task;
                }
                else
                {
                    writetail->next = new_task;
                    writetail = new_task;
                }
                pthread_cond_broadcast(&w_condl);
                pthread_mutex_unlock(&w_mutex);
            }
            else
            {
                echo("[SERVER] Error: unknown epoll event");
            }
        }
    }
    return 0;
}

variable_types: argc int

variable_types: maxi int

variable_types: nfds int

variable_types: listenfd int

variable_types: connfd int

variable_types:
clilen
unsigned 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]; }

return_type: 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]; }


passiveTCP

decompiled_code:
__int64 __fastcall passiveTCP(char a1)
{
return passivesock(a1, (char)&unk_402004, 1);
}

canonical_decompiled_code:
__int64 __fastcall func7(char a1)
{
return func10(a1, (char)&unk_402004, 1);
}

original_code:
int passiveTCP(const char* service)
{
    return passivesock(service, "TCP", 1);
}

canonical_original_code:
int passiveTCP(char *service)
{
    return passivesock(service, "TCP", 1);
}

variable_types:
service
char *


TCPdaytimed

decompiled_code:
ssize_t __fastcall TCPdaytimed(int fd)
{
char *v1; // rbx
size_t v2; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

time(&timer);
v1 = ctime(&timer);
v2 = strlen(v1);
return send(fd, v1, v2, 0);
}

canonical_decompiled_code:
ssize_t __fastcall func8(int fd)
{
char *v1; // rbx
size_t v2; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

time(&timer);
v1 = ctime(&timer);
v2 = strlen(v1);
return send(fd, v1, v2, 0);
}

original_code:
void TCPdaytimed(int fd)
{
    char *pts;
    time_t now;
    (void) time(&now);
    pts = ctime(&now);
    (void) send(fd, pts, strlen(pts), 0);
}

canonical_original_code:
void TCPdaytimed(int fd)
{
    char *pts;
    long now;
    (void) time(&now);
    pts = ctime(&now);
    (void) send(fd, pts, strlen(pts), 0);
}

variable_types:
pts
char *

variable_types: now long


errexit

decompiled_code:
void __noreturn errexit(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
exit(1);
}

canonical_decompiled_code:
void __noreturn func11(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
exit(1);
}

original_code:
int errexit(const char* format, ...)
{
    va_list args;
    __builtin_va_start(args,format);
    vfprintf(stderr, format, args);
    __builtin_va_end(args);
    exit(1);
}

canonical_original_code:
int errexit(char *format, ...)
{
    __builtin_va_list args;
    __builtin_va_start(args,format);
    vfprintf(stderr, format, args);
    __builtin_va_end(args);
    exit(1);
}

variable_types:
format
char *


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbx
__int64 v4; // rbp
int *v5; // rax
char v6; // al
int v7; // eax
int v8; // ebx
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF

v3 = "10086";
if ( argc != 1 )
{
if ( argc != 2 )
errexit("[SERVICE] usage: TCPdaytimed [port]\n", (char)argv);
v3 = argv[1];
}
fwrite("[SERVICE] creating passive socket..\n", 1uLL, 0x24uLL, stderr);
v4 = (unsigned int)passiveTCP((char)v3);
fprintf(stderr, "[SERVICE] passive socket %d created.\n", v4);
while ( 1 )
{
addr_len = 16;
fwrite("[SERVICE] waiting for client..\n", 1uLL, 0x1FuLL, stderr);
v7 = accept(v4, &addr, &addr_len);
v8 = v7;
if ( v7 < 0 )
break;
fprintf(stderr, "[SERVICE] temporary socket %d created.\n", (unsigned int)v7);
TCPdaytimed(v8);
close(v8);
}
v5 = __errno_location();
v6 = (unsigned __int8)strerror(*v5);
errexit("accept failed: %s\n", v6);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbx
__int64 v4; // rbp
int *v5; // rax
char v6; // al
int v7; // eax
int v8; // ebx
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF

v3 = "10086";
if ( argc != 1 )
{
if ( argc != 2 )
func11("[SERVICE] usage: TCPdaytimed [port]\n", (char)argv);
v3 = argv[1];
}
fwrite("[SERVICE] creating passive socket..\n", 1uLL, 0x24uLL, stderr);
v4 = (unsigned int)func7((char)v3);
fprintf(stderr, "[SERVICE] passive socket %d created.\n", v4);
while ( 1 )
{
addr_len = 16;
fwrite("[SERVICE] waiting for client..\n", 1uLL, 0x1FuLL, stderr);
v7 = accept(v4, &addr, &addr_len);
v8 = v7;
if ( v7 < 0 )
break;
fprintf(stderr, "[SERVICE] temporary socket %d created.\n", (unsigned int)v7);
func8(v8);
close(v8);
}
v5 = __errno_location();
v6 = (unsigned __int8)strerror(*v5);
func11("accept failed: %s\n", v6);
}

original_code:
int main(int argc,char* argv[])
{
    struct sockaddr_in fsin;
    char *service = "10086";
    int msock, ssock;
    unsigned int alen;
    switch (argc)
    {
        case 1:
            break;
        case 2:
            service = argv[1];
            break;
        default:
            errexit("[SERVICE] usage: TCPdaytimed [port]\n");
    }
    fprintf(stderr, "[SERVICE] creating passive socket..\n");
    msock = passiveTCP(service);
    fprintf(stderr, "[SERVICE] passive socket %d created.\n", msock);
    while(1)
    {
        alen = sizeof(fsin);
        fprintf(stderr, "[SERVICE] waiting for client..\n");
        ssock = accept(msock, (struct sockaddr*)&fsin, &alen);
        if (ssock < 0)
            errexit("accept failed: %s\n", strerror((*__errno_location ())));
        fprintf(stderr, "[SERVICE] temporary socket %d created.\n", ssock);
        TCPdaytimed(ssock);
        (void) close(ssock);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    struct sockaddr_in fsin;
    char *service = "10086";
    int msock; int ssock;
    unsigned int alen;
    switch (argc)
    {
        case 1:
            break;
        case 2:
            service = argv[1];
            break;
        default:
            errexit("[SERVICE] usage: TCPdaytimed [port]\n");
    }
    fprintf(stderr, "[SERVICE] creating passive socket..\n");
    msock = passiveTCP(service);
    fprintf(stderr, "[SERVICE] passive socket %d created.\n", msock);
    while(1)
    {
        alen = sizeof(fsin);
        fprintf(stderr, "[SERVICE] waiting for client..\n");
        ssock = accept(msock, (struct sockaddr *)&fsin, &alen);
        if (ssock < 0)
            errexit("accept failed: %s\n", strerror((*__errno_location ())));
        fprintf(stderr, "[SERVICE] temporary socket %d created.\n", ssock);
        TCPdaytimed(ssock);
        (void) close(ssock);
    }
    return 0;
}

variable_types:
argv
char *[]

variable_types: msock int

variable_types: ssock int

variable_types:
alen
unsigned int


passiveUDP

decompiled_code:
__int64 __fastcall passiveUDP(char a1)
{
return passivesock(a1, (char)&unk_402004, 0);
}

canonical_decompiled_code:
__int64 __fastcall func8(char a1)
{
return func10(a1, (char)&unk_402004, 0);
}

original_code:
int passiveUDP(const char *service)
{
    return passivesock(service, "UDP", 0);
}

canonical_original_code:
int passiveUDP(char *service)
{
    return passivesock(service, "UDP", 0);
}


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char *v3; // rax
int i; // ebx
int *v5; // rax
char v6; // al
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
time_t timer; // [rsp+10h] [rbp-28h] BYREF
char buf; // [rsp+1Fh] [rbp-19h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-18h] BYREF

v3 = "10010";
if ( argc != 1 )
{
if ( argc != 2 )
errexit("usage: UDPtimed [port]\n", (char)argv);
v3 = argv[1];
}
for ( i = passiveUDP((char)v3); ; sendto(i, &timer, 8uLL, 0, &addr, 0x10u) )
{
addr_len = 16;
if ( recvfrom(i, &buf, 1uLL, 0, &addr, &addr_len) < 0 )
break;
time(&timer);
timer = (unsigned int)_bswap_32((int)timer - 2085978496);
}
v5 = __errno_location();
v6 = (unsigned __int8)strerror(*v5);
errexit("recvfrom: %s \n", v6);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char *v3; // rax
int i; // ebx
int *v5; // rax
char v6; // al
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
time_t timer; // [rsp+10h] [rbp-28h] BYREF
char buf; // [rsp+1Fh] [rbp-19h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-18h] BYREF

v3 = "10010";
if ( argc != 1 )
{
if ( argc != 2 )
func11("usage: UDPtimed [port]\n", (char)argv);
v3 = argv[1];
}
for ( i = func8((char)v3); ; sendto(i, &timer, 8uLL, 0, &addr, 0x10u) )
{
addr_len = 16;
if ( recvfrom(i, &buf, 1uLL, 0, &addr, &addr_len) < 0 )
break;
time(&timer);
timer = (unsigned int)func7((int)timer - 2085978496);
}
v5 = __errno_location();
v6 = (unsigned __int8)strerror(*v5);
func11("recvfrom: %s \n", v6);
}

original_code:
int main(int argc, char *argv[])
{
    struct sockaddr_in fsin;
    char *service = "10010";
    char buf[1];
    int sock;
    time_t now;
    unsigned int alen;
    switch (argc)
    {
        case 1:
            break;
        case 2:
            service = argv[1];
            break;
        default:
            errexit("usage: UDPtimed [port]\n");
    }
    sock = passiveUDP(service);
    while(1)
    {
        alen = sizeof(fsin);
        if (recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr*)&fsin, &alen) < 0)
            errexit("recvfrom: %s \n", strerror((*__errno_location ())));
        (void) time(&now);
        now = htonl((unsigned long)(now + 2208988800UL));
        (void) sendto(sock, (char*)&now, sizeof(now), 0, (struct sockaddr*)&fsin, sizeof(fsin));
    }
}

canonical_original_code:
int main(int argc, char *argv[])
{
    struct sockaddr_in fsin;
    char *service = "10010";
    char buf[1];
    int sock;
    long now;
    unsigned int alen;
    switch (argc)
    {
        case 1:
            break;
        case 2:
            service = argv[1];
            break;
        default:
            errexit("usage: UDPtimed [port]\n");
    }
    sock = passiveUDP(service);
    while(1)
    {
        alen = sizeof(fsin);
        if (recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr *)&fsin, &alen) < 0)
            errexit("recvfrom: %s \n", strerror((*__errno_location ())));
        (void) time(&now);
        now = htonl((unsigned long)(now + 2208988800UL));
        (void) sendto(sock, (char *)&now, sizeof(now), 0, (struct sockaddr *)&fsin, sizeof(fsin));
    }
}

variable_types:
buf
char [1]

variable_types: sock int


TCPdaytime

decompiled_code:
size_t __fastcall TCPdaytime(char *a1, char a2)
{
__int64 v2; // rbp
int v3; // eax
int v4; // ebx
char v6[168]; // [rsp+0h] [rbp-A8h] BYREF

v2 = (unsigned int)clientsock(a1, a2, (char)&unk_402004, 0LL);
fprintf(stderr, "[CLIENT] socket %d created.\n", v2);
sleep(1u);
while ( 1 )
{
v3 = recv(v2, v6, 0x80uLL, 0);
v4 = v3;
if ( v3 <= 0 )
break;
fprintf(stderr, "[CLIENT] %d data read: \n", (unsigned int)v3);
v6[v4] = 0;
fputs(v6, stderr);
}
return fwrite("[CLIENT] data receive finish. \n", 1uLL, 0x1FuLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func7(char *a1, char a2)
{
__int64 v2; // rbp
int v3; // eax
int v4; // ebx
char v6[168]; // [rsp+0h] [rbp-A8h] BYREF

v2 = (unsigned int)func9(a1, a2, (char)&unk_402004, 0LL);
fprintf(stderr, "[CLIENT] socket %d created.\n", v2);
sleep(1u);
while ( 1 )
{
v3 = recv(v2, v6, 0x80uLL, 0);
v4 = v3;
if ( v3 <= 0 )
break;
fprintf(stderr, "[CLIENT] %d data read: \n", (unsigned int)v3);
v6[v4] = 0;
fputs(v6, stderr);
}
return fwrite("[CLIENT] data receive finish. \n", 1uLL, 0x1FuLL, stderr);
}

original_code:
void TCPdaytime(const char* host, const char* service)
{
    char buf[128 + 1];
    int s, n;
    s = clientsock(host, service, "TCP", ((void *)0));
    fprintf(stderr, "[CLIENT] socket %d created.\n", s);
    sleep(1);
    while((n = recv(s, buf, 128, 0)) > 0)
    {
        fprintf(stderr, "[CLIENT] %d data read: \n", n);
        buf[n] = '\0';
        (void) fputs(buf, stderr);
    }
    fprintf(stderr, "[CLIENT] data receive finish. \n");
}

canonical_original_code:
void TCPdaytime(char *host, char *service)
{
    char buf[-1];
    int s; int n;
    s = clientsock(host, service, "TCP", ((void *)0));
    fprintf(stderr, "[CLIENT] socket %d created.\n", s);
    sleep(1);
    while((n = recv(s, buf, 128, 0)) > 0)
    {
        fprintf(stderr, "[CLIENT] %d data read: \n", n);
        buf[n] = '\0';
        (void) fputs(buf, stderr);
    }
    fprintf(stderr, "[CLIENT] data receive finish. \n");
}

variable_types:
host
char *

variable_types:
buf
char [-1]

variable_types: s int

variable_types: n int


errexit

canonical_decompiled_code:
void __noreturn func10(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
exit(1);
}


main

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

switch ( argc )
{
case 2:
v3 = (char *)argv[1];
v4 = "10086";
break;
case 3:
v3 = (char *)argv[1];
v4 = argv[2];
break;
case 1:
v4 = "10086";
v3 = "127.0.0.1";
break;
default:
errexit("usage: TCPdaytime [host [port]]\n", (char)argv);
}
TCPdaytime(v3, (char)v4);
return 0;
}

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

switch ( argc )
{
case 2:
v3 = (char *)argv[1];
v4 = "10086";
break;
case 3:
v3 = (char *)argv[1];
v4 = argv[2];
break;
case 1:
v4 = "10086";
v3 = "127.0.0.1";
break;
default:
func10("usage: TCPdaytime [host [port]]\n", (char)argv);
}
func7(v3, (char)v4);
return 0;
}

original_code:
int main(int argc,char* argv[])
{
    char *host = "127.0.0.1";
    char *service = "10086";
    switch (argc)
    {
        case 1:
            break;
        case 2:
            host = argv[1];
            break;
        case 3:
            host = argv[1];
            service = argv[2];
            break;
        default:
            errexit("usage: TCPdaytime [host [port]]\n");
    }
    TCPdaytime(host, service);
}

canonical_original_code:
int main(int argc, char *argv[])
{
    char *host = "127.0.0.1";
    char *service = "10086";
    switch (argc)
    {
        case 1:
            break;
        case 2:
            host = argv[1];
            break;
        case 3:
            host = argv[1];
            service = argv[2];
            break;
        default:
            errexit("usage: TCPdaytime [host [port]]\n");
    }
    TCPdaytime(host, service);
}

variable_types: argc int


processClient

decompiled_code:
int __fastcall processClient(int fd, __int64 a2)
{
int v2; // eax
int result; // eax
int v4; // eax
int v5; // eax
int v6; // ebp
char *v7; // rax
char *v8; // rdx
char v9[1024]; // [rsp+0h] [rbp-C18h] BYREF
char s[1024]; // [rsp+400h] [rbp-818h] BYREF
char buf[1048]; // [rsp+800h] [rbp-418h] BYREF

inet_ntoa(*(struct in_addr *)((char *)&a2 + 4));
echo("[SERVICE] Accept a connect from %s.\n", v9[0]);
v2 = recv(fd, v9, 0x400uLL, 0);
if ( v2 )
{
v9[v2 - 1] = 0;
echo("[SERVICE] Client name is: %s.\n", v9[0]);
while ( 1 )
{
v5 = recv(fd, buf, 0x400uLL, 0);
v6 = v5;
if ( !v5 )
break;
buf[v5] = 0;
echo("[SERVICE] Received client (%s) message: %s", v9[0]);
if ( v6 - 1 > 0 )
{
v7 = &buf[v6];
v8 = s;
do
{
*v8 = *(v7 - 2);
--v7;
++v8;
}
while ( v7 != &s[v6 + 1023 - (v6 - 2)] );
}
s[v6 - 1] = 0;
v4 = strlen(s);
send(fd, s, v4, 0);
}
result = close(fd);
}
else
{
close(fd);
result = echo("[SERVICE] Client disconnected.\n", v9[0]);
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(int fd, __int64 a2)
{
int v2; // eax
int result; // eax
int v4; // eax
int v5; // eax
int v6; // ebp
char *v7; // rax
char *v8; // rdx
char v9[1024]; // [rsp+0h] [rbp-C18h] BYREF
char s[1024]; // [rsp+400h] [rbp-818h] BYREF
char buf[1048]; // [rsp+800h] [rbp-418h] BYREF

inet_ntoa(*(struct in_addr *)((char *)&a2 + 4));
func13("[SERVICE] Accept a connect from %s.\n", v9[0]);
v2 = recv(fd, v9, 0x400uLL, 0);
if ( v2 )
{
v9[v2 - 1] = 0;
func13("[SERVICE] Client name is: %s.\n", v9[0]);
while ( 1 )
{
v5 = recv(fd, buf, 0x400uLL, 0);
v6 = v5;
if ( !v5 )
break;
buf[v5] = 0;
func13("[SERVICE] Received client (%s) message: %s", v9[0]);
if ( v6 - 1 > 0 )
{
v7 = &buf[v6];
v8 = s;
do
{
*v8 = *(v7 - 2);
--v7;
++v8;
}
while ( v7 != &s[v6 + 1023 - (v6 - 2)] );
}
s[v6 - 1] = 0;
v4 = strlen(s);
send(fd, s, v4, 0);
}
result = close(fd);
}
else
{
close(fd);
result = func13("[SERVICE] Client disconnected.\n", v9[0]);
}
return result;
}

original_code:
void processClient(int connectfd, struct sockaddr_in client)
{
    int num, i;
    char recvbuf[1024], sendbuf[1024], clientName[1024];
    int len;
    echo("[SERVICE] Accept a connect from %s.\n", inet_ntoa(client.sin_addr));
    num = recv(connectfd, clientName, 1024, 0);
    if (num == 0)
    {
        close(connectfd);
        echo("[SERVICE] Client disconnected.\n");
        return;
    }
    clientName[num - 1] = '\0';
    echo("[SERVICE] Client name is: %s.\n", clientName);
    while (num = recv(connectfd, recvbuf, 1024, 0))
    {
        recvbuf[num] = '\0';
        echo("[SERVICE] Received client (%s) message: %s", clientName, recvbuf);
        for (i = 0; i < num - 1; i++)
        {
            sendbuf[i] = recvbuf[num - i - 2];
        }
        sendbuf[num - 1] = '\0';
        len = strlen(sendbuf);
        send(connectfd, sendbuf, len, 0);
    }
    close(connectfd);
}

canonical_original_code:
void processClient(int connectfd, struct sockaddr_in client)
{
    int num; int i;
    char recvbuf[1024]; char sendbuf[1024]; char clientName[1024];
    int len;
    echo("[SERVICE] Accept a connect from %s.\n", inet_ntoa(client.sin_addr));
    num = recv(connectfd, clientName, 1024, 0);
    if (num == 0)
    {
        close(connectfd);
        echo("[SERVICE] Client disconnected.\n");
        return;
    }
    clientName[num - 1] = '\0';
    echo("[SERVICE] Client name is: %s.\n", clientName);
    while (num = recv(connectfd, recvbuf, 1024, 0))
    {
        recvbuf[num] = '\0';
        echo("[SERVICE] Received client (%s) message: %s", clientName, recvbuf);
        for (i = 0; i < num - 1; i++)
        {
            sendbuf[i] = recvbuf[num - i - 2];
        }
        sendbuf[num - 1] = '\0';
        len = strlen(sendbuf);
        send(connectfd, sendbuf, len, 0);
    }
    close(connectfd);
}

variable_types: connectfd int

variable_types: num int

variable_types: i int

variable_types:
recvbuf
char [1024]

variable_types:
sendbuf
char [1024]

variable_types:
clientName
char [1024]

variable_types: len int


startRoutine

decompiled_code:
void __fastcall __noreturn startRoutine(void *a1)
{
char v1; // [rsp+0h] [rbp-8h]

processClient(*(_DWORD *)a1, *(_QWORD *)((char *)a1 + 4));
free(a1);
pthread_self();
echo("[SERVICE] thread %d terminated\n", v1);
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func10(void *a1)
{
char v1; // [rsp+0h] [rbp-8h]

func9(*(_DWORD *)a1, *(_QWORD *)((char *)a1 + 4));
free(a1);
pthread_self();
func13("[SERVICE] thread %d terminated\n", v1);
pthread_exit(0LL);
}

original_code:
void* startRoutine(void* arg)
{
    ARG* info = (ARG*)arg;
    processClient(info->connectfd, info->client);
    free(info);
    echo("[SERVICE] thread %d terminated\n", pthread_self());
    pthread_exit(((void *)0));
}

canonical_original_code:
void *startRoutine(void *arg)
{
    struct ARG *info = (ARG*)arg;
    processClient(info->connectfd, info->client);
    free(info);
    echo("[SERVICE] thread %d terminated\n", pthread_self());
    pthread_exit(((void *)0));
}

variable_types:
arg
void *

variable_types: struct ARG { int connectfd; 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]; } client; } *

user_defined_types: struct ARG { int connectfd; struct sockaddr_in client; }


errexit

decompiled_code:
void __noreturn errexit(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(_bss_start, format, arg);
exit(1);
}

canonical_decompiled_code:
void __noreturn func12(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(_bss_start, format, arg);
exit(1);
}

variable_types:
format
char *


echo

decompiled_code:
int echo(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(_bss_start, format, arg);
}

canonical_decompiled_code:
int func13(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(_bss_start, format, arg);
}

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

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


decompiled_code:
void sig_child()
{
char v0; // [rsp+0h] [rbp-18h]
int stat_loc[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( waitpid(-1, stat_loc, 1) > 0 )
echo("[SERVICE] Child %d terminated\n", v0);
}

canonical_decompiled_code:
void func7()
{
char v0; // [rsp+0h] [rbp-18h]
int stat_loc[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( waitpid(-1, stat_loc, 1) > 0 )
func13("[SERVICE] Child %d terminated\n", v0);
}

original_code:
void sig_child(int sig)
{
    pid_t pid;
    int stat;
    while ((pid = waitpid(-1, &stat, 1)) > 0)
        echo("[SERVICE] Child %d terminated\n", pid);
    return;
}

canonical_original_code:
void sig_child(int sig)
{
    int pid;
    int stat;
    while ((pid = waitpid(-1, &stat, 1)) > 0)
        echo("[SERVICE] Child %d terminated\n", pid);
    return;
}

variable_types: sig int

variable_types: pid int

variable_types: stat int


processClient

canonical_decompiled_code:
int __fastcall func10(int fd, __int64 a2)
{
int v2; // eax
int result; // eax
int v4; // eax
int v5; // eax
int v6; // ebp
char *v7; // rax
char *v8; // rdx
char v9[1024]; // [rsp+0h] [rbp-C18h] BYREF
char s[1024]; // [rsp+400h] [rbp-818h] BYREF
char buf[1048]; // [rsp+800h] [rbp-418h] BYREF

inet_ntoa(*(struct in_addr *)((char *)&a2 + 4));
func13("[SERVICE] Accept a connect from %s.\n", v9[0]);
v2 = recv(fd, v9, 0x400uLL, 0);
if ( v2 )
{
v9[v2 - 1] = 0;
func13("[SERVICE] Client name is: %s.\n", v9[0]);
while ( 1 )
{
v5 = recv(fd, buf, 0x400uLL, 0);
v6 = v5;
if ( !v5 )
break;
buf[v5] = 0;
func13("[SERVICE] Received client (%s) message: %s", v9[0]);
if ( v6 - 1 > 0 )
{
v7 = &buf[v6];
v8 = s;
do
{
*v8 = *(v7 - 2);
--v7;
++v8;
}
while ( v7 != &s[v6 + 1023 - (v6 - 2)] );
}
s[v6 - 1] = 0;
v4 = strlen(s);
send(fd, s, v4, 0);
}
result = close(fd);
}
else
{
close(fd);
result = func13("[SERVICE] Client disconnected.\n", v9[0]);
}
return result;
}

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]; }


errexit

canonical_decompiled_code:
void __noreturn func12(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
exit(1);
}


echo

decompiled_code:
int echo(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(stderr, format, arg);
}

canonical_decompiled_code:
int func13(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(stderr, format, arg);
}


repo: linkedin/datacl

original_code:
void
or2_I1(
       char *in1,
       char *in2,
       long long nR,
       char * restrict out
       )
{
  char inv1, inv2, outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 || inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

canonical_original_code:
void or2_I1(char *in1, char *in2, long long nR, char *out)
{
  char inv1; char inv2; char outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 || inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

variable_types:
nR
long long

variable_types:
out
char *

variable_types: outv char

variable_types:
i
long long


decompiled_code:
__int64 __fastcall sort_iL_aa_compare(int *a1, int *a2)
{
int v2; // ecx
__int64 v3; // rdi
int v4; // edx
__int64 v5; // rsi
__int64 result; // rax

v2 = *a1;
v3 = *(_QWORD *)(a1 + 1);
v4 = *a2;
v5 = *(_QWORD *)(a2 + 1);
result = 1LL;
if ( v2 <= v4 )
{
result = 0xFFFFFFFFLL;
if ( v2 >= v4 )
{
result = 1LL;
if ( v3 <= v5 )
result = (unsigned int)-(v3 < v5);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, int *a2)
{
int v2; // ecx
__int64 v3; // rdi
int v4; // edx
__int64 v5; // rsi
__int64 result; // rax

v2 = *a1;
v3 = *(_QWORD *)(a1 + 1);
v4 = *a2;
v5 = *(_QWORD *)(a2 + 1);
result = 1LL;
if ( v2 <= v4 )
{
result = 0xFFFFFFFFLL;
if ( v2 >= v4 )
{
result = 1LL;
if ( v3 <= v5 )
result = (unsigned int)-(v3 < v5);
}
}
return result;
}

original_code:
int sort_iL_aa_compare(
         const void *in1,
         const void *in2
         )
{
  char *cptr1, *cptr2;
  int *iptr; long long *llptr;
  int x1, x2; long long y1, y2;
  cptr1 = (char *)in1;
  cptr2 = (char *)in2;
  iptr = (int *)cptr1; x1 = *iptr; cptr1 += sizeof(int);
  llptr = (long long *)cptr1; y1 = *llptr; cptr1 += sizeof(long long);
  iptr = (int *)cptr2; x2 = *iptr; cptr2 += sizeof(int);
  llptr = (long long *)cptr2; y2 = *llptr; cptr2 += sizeof(long long);
  if ( x1 > x2 ) {
    return (1);
  }
  else if ( x1 < x2 ) {
    return (-1);
  }
  else {
    if ( y1 > y2 ) {
      return (1);
    }
    else if ( y1 < y2 ) {
      return (-1);
    }
    else {
      return(0);
    }
  }
}

canonical_original_code:
int sort_iL_aa_compare(void *in1, void *in2)
{
  char *cptr1; char *cptr2;
  int *iptr; long long *llptr;
  int x1; int x2; long long y1; long long y2;
  cptr1 = (char *)in1;
  cptr2 = (char *)in2;
  iptr = (int *)cptr1; x1 = *iptr; cptr1 += sizeof(int);
  llptr = (long long *)cptr1; y1 = *llptr; cptr1 += sizeof(long long);
  iptr = (int *)cptr2; x2 = *iptr; cptr2 += sizeof(int);
  llptr = (long long *)cptr2; y2 = *llptr; cptr2 += sizeof(long long);
  if ( x1 > x2 ) {
    return (1);
  }
  else if ( x1 < x2 ) {
    return (-1);
  }
  else {
    if ( y1 > y2 ) {
      return (1);
    }
    else if ( y1 < y2 ) {
      return (-1);
    }
    else {
      return(0);
    }
  }
}

variable_types:
iptr
int *

variable_types:
llptr
long long *


decompiled_code:
__int64 __fastcall sort_Li_aa_compare(__int64 *a1, __int64 *a2)
{
__int64 v2; // rcx
int v3; // edi
__int64 v4; // rdx
int v5; // esi
__int64 result; // rax

v2 = *a1;
v3 = *((_DWORD *)a1 + 2);
v4 = *a2;
v5 = *((_DWORD *)a2 + 2);
result = 1LL;
if ( v2 <= v4 )
{
result = 0xFFFFFFFFLL;
if ( v2 >= v4 )
{
result = 1LL;
if ( v3 <= v5 )
result = (unsigned int)-(v3 < v5);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1, __int64 *a2)
{
__int64 v2; // rcx
int v3; // edi
__int64 v4; // rdx
int v5; // esi
__int64 result; // rax

v2 = *a1;
v3 = *((_DWORD *)a1 + 2);
v4 = *a2;
v5 = *((_DWORD *)a2 + 2);
result = 1LL;
if ( v2 <= v4 )
{
result = 0xFFFFFFFFLL;
if ( v2 >= v4 )
{
result = 1LL;
if ( v3 <= v5 )
result = (unsigned int)-(v3 < v5);
}
}
return result;
}

original_code:
int sort_Li_aa_compare(
         const void *in1,
         const void *in2
         )
{
  char *cptr1, *cptr2;
  long long *llptr1, *llptr2;
  int *iptr1, *iptr2;
  long long ll1, ll2;
  int i1, i2;
  cptr1 = (char *)in1;
  cptr2 = (char *)in2;
  llptr1 = (long long *)cptr1; ll1 = *llptr1; cptr1 += sizeof(long long);
  iptr1 = (int *)cptr1; i1 = *iptr1; cptr1 += sizeof(int);
  llptr2 = (long long *)cptr2; ll2 = *llptr2; cptr2 += sizeof(long long);
  iptr2 = (int *)cptr2; i2 = *iptr2; cptr2 += sizeof(int);
  if ( ll1 > ll2 ) {
    return (1);
  }
  else if ( ll1 < ll2 ) {
    return (-1);
  }
  else {
    if ( i1 > i2 ) {
      return (1);
    }
    else if ( i1 < i2 ) {
      return (-1);
    }
    else {
      return(0);
    }
  }
}

canonical_original_code:
int sort_Li_aa_compare(void *in1, void *in2)
{
  char *cptr1; char *cptr2;
  long long *llptr1; long long *llptr2;
  int *iptr1; int *iptr2;
  long long ll1; long long ll2;
  int i1; int i2;
  cptr1 = (char *)in1;
  cptr2 = (char *)in2;
  llptr1 = (long long *)cptr1; ll1 = *llptr1; cptr1 += sizeof(long long);
  iptr1 = (int *)cptr1; i1 = *iptr1; cptr1 += sizeof(int);
  llptr2 = (long long *)cptr2; ll2 = *llptr2; cptr2 += sizeof(long long);
  iptr2 = (int *)cptr2; i2 = *iptr2; cptr2 += sizeof(int);
  if ( ll1 > ll2 ) {
    return (1);
  }
  else if ( ll1 < ll2 ) {
    return (-1);
  }
  else {
    if ( i1 > i2 ) {
      return (1);
    }
    else if ( i1 < i2 ) {
      return (-1);
    }
    else {
      return(0);
    }
  }
}


decompiled_code:
__int64 __fastcall str_compare(char *a1, char *a2)
{
char v2; // dl
char v3; // al

while ( 1 )
{
v3 = *a1;
if ( !*a1 )
return *a2 != 0;
v2 = *a2;
if ( !*a2 )
return 0xFFFFFFFFLL;
if ( v3 < v2 )
return 1LL;
if ( v3 > v2 )
break;
++a1;
++a2;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1, char *a2)
{
char v2; // dl
char v3; // al

while ( 1 )
{
v3 = *a1;
if ( !*a1 )
return *a2 != 0;
v2 = *a2;
if ( !*a2 )
return 0xFFFFFFFFLL;
if ( v3 < v2 )
return 1LL;
if ( v3 > v2 )
break;
++a1;
++a2;
}
return 0xFFFFFFFFLL;
}

original_code:
int str_compare(
         const void *in1,
         const void *in2
         )
{
  char *cptr1, *cptr2;
  cptr1 = (char *)in1;
  cptr2 = (char *)in2;
  for ( ; ; cptr1++, cptr2++ ) {
    if ( ( *cptr1 == '\0' ) && ( *cptr2 == '\0' ) ) {
      return(0);
    }
    if ( *cptr1 == '\0' ) { return(1); }
    if ( *cptr2 == '\0' ) { return(-1); }
    if ( *cptr1 < *cptr2 ) { return(1); }
    if ( *cptr2 < *cptr1 ) { return(-1); }
  }
}

canonical_original_code:
int str_compare(void *in1, void *in2)
{
  char *cptr1; char *cptr2;
  cptr1 = (char *)in1;
  cptr2 = (char *)in2;
  for ( ; ; cptr1++, cptr2++ ) {
    if ( ( *cptr1 == '\0' ) && ( *cptr2 == '\0' ) ) {
      return(0);
    }
    if ( *cptr1 == '\0' ) { return(1); }
    if ( *cptr2 == '\0' ) { return(-1); }
    if ( *cptr1 < *cptr2 ) { return(1); }
    if ( *cptr2 < *cptr1 ) { return(-1); }
  }
}


original_code:
void
qsort_asc_I4 (
     void *const pbase,
     size_t total_elems,
     size_t size,
     __compar_fn_t cmp
     )
{
  register char *base_ptr = (char *) pbase;
  if ( size != sizeof(int) ) { exit(1); }
  const size_t max_thresh = 4 * size;
  if (total_elems == 0) {
    return;
  }
  if ( total_elems > 4 ) {
    char *lo = base_ptr;
    char *hi = &lo[size * (total_elems - 1)];
    stack_node stack[(8 * sizeof(size_t))];
    stack_node *top = stack;
    ((void) ((top->lo = (((void *)0))), (top->hi = (((void *)0))), ++top));
    while ((stack < top)) {
      char *left_ptr;
      char *right_ptr;
      char *mid = lo + size * ((hi - lo) / size >> 1);
      if ( *((int *)mid) < *((int *)lo) ) {
 { int *ia = (int *)mid; int *ib = (int *)lo; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      if ( *((int *)hi) < *((int *)mid) ) {
 { int *ia = (int *)mid; int *ib = (int *)hi; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      else {
 goto jump_over;
      }
      if ( *((int *)mid) < *((int *)lo) ) {
 { int *ia = (int *)mid; int *ib = (int *)lo; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
    jump_over:;
      left_ptr = lo + size;
      right_ptr = hi - size;
      do {
 while ( *((int *)left_ptr) < *((int *)mid) ) {
   left_ptr += size;
 }
 while ( *((int *)mid) < *((int *)right_ptr) ) {
   right_ptr -= size;
 }
 if (left_ptr < right_ptr) {
   { int *ia = (int *)left_ptr; int *ib = (int *)right_ptr; int itmp = *ia; *ia = *ib; *ib = itmp; };
   if (mid == left_ptr) {
     mid = right_ptr;
   }
   else if (mid == right_ptr) {
     mid = left_ptr;
   }
   left_ptr += size;
   right_ptr -= size;
 }
 else if (left_ptr == right_ptr) {
   left_ptr += size;
   right_ptr -= size;
   break;
 }
      } while (left_ptr <= right_ptr);
      if ((size_t) (right_ptr - lo) <= max_thresh) {
 if ((size_t) (hi - left_ptr) <= max_thresh) {
   ((void) (--top, (lo = top->lo), (hi = top->hi)));
 }
 else {
   lo = left_ptr;
 }
      }
      else if ((size_t) (hi - left_ptr) <= max_thresh) {
 hi = right_ptr;
      }
      else if ((right_ptr - lo) > (hi - left_ptr)) {
 ((void) ((top->lo = (lo)), (top->hi = (right_ptr)), ++top));
 lo = left_ptr;
      }
      else {
 ((void) ((top->lo = (left_ptr)), (top->hi = (hi)), ++top));
 hi = right_ptr;
      }
    }
  }
  {
    char *const end_ptr = &base_ptr[size * (total_elems - 1)];
    char *tmp_ptr = base_ptr;
    char *thresh = ((end_ptr) < (base_ptr + max_thresh) ? (end_ptr) : (base_ptr + max_thresh));
    register char *run_ptr;
    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) {
      if ( *((int *)run_ptr) < *((int *) tmp_ptr) ) {
        tmp_ptr = run_ptr;
      }
    }
    if (tmp_ptr != base_ptr) {
      { int *ia = (int *)tmp_ptr; int *ib = (int *)base_ptr; int itmp = *ia; *ia = *ib; *ib = itmp; };
    }
    run_ptr = base_ptr + size;
    while ((run_ptr += size) <= end_ptr) {
      tmp_ptr = run_ptr - size;
      while ( *((int *)run_ptr) < *((int *)tmp_ptr) ) {
 tmp_ptr -= size;
      }
      tmp_ptr += size;
      if (tmp_ptr != run_ptr) {
 char *trav;
 trav = run_ptr + size;
 while (--trav >= run_ptr) {
   char c = *trav;
   char *hi, *lo;
   for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) {
     *hi = *lo;
   }
   *hi = c;
 }
      }
    }
  }
}

canonical_original_code:
void qsort_asc_I4(void *pbase, unsigned long total_elems, unsigned long size, int (*cmp)(void *, void *))
{
  register char *base_ptr = (char *) pbase;
  if ( size != sizeof(int) ) { exit(1); }
  unsigned long max_thresh = 4 * size;
  if (total_elems == 0) {
    return;
  }
  if ( total_elems > 4 ) {
    char *lo = base_ptr;
    char *hi = &lo[size * (total_elems - 1)];
    struct stack_node stack[-1];
    struct stack_node *top = stack;
    ((void) ((top->lo = (((void *)0))), (top->hi = (((void *)0))), ++top));
    while ((stack < top)) {
      char *left_ptr;
      char *right_ptr;
      char *mid = lo + size * ((hi - lo) / size >> 1);
      if ( *((int *)mid) < *((int *)lo) ) {
 { int *ia = (int *)mid; int *ib = (int *)lo; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      if ( *((int *)hi) < *((int *)mid) ) {
 { int *ia = (int *)mid; int *ib = (int *)hi; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      else {
 goto jump_over;
      }
      if ( *((int *)mid) < *((int *)lo) ) {
 { int *ia = (int *)mid; int *ib = (int *)lo; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
    jump_over:;
      left_ptr = lo + size;
      right_ptr = hi - size;
      do {
 while ( *((int *)left_ptr) < *((int *)mid) ) {
   left_ptr += size;
 }
 while ( *((int *)mid) < *((int *)right_ptr) ) {
   right_ptr -= size;
 }
 if (left_ptr < right_ptr) {
   { int *ia = (int *)left_ptr; int *ib = (int *)right_ptr; int itmp = *ia; *ia = *ib; *ib = itmp; };
   if (mid == left_ptr) {
     mid = right_ptr;
   }
   else if (mid == right_ptr) {
     mid = left_ptr;
   }
   left_ptr += size;
   right_ptr -= size;
 }
 else if (left_ptr == right_ptr) {
   left_ptr += size;
   right_ptr -= size;
   break;
 }
      } while (left_ptr <= right_ptr);
      if ((unsigned long) (right_ptr - lo) <= max_thresh) {
 if ((unsigned long) (hi - left_ptr) <= max_thresh) {
   ((void) (--top, (lo = top->lo), (hi = top->hi)));
 }
 else {
   lo = left_ptr;
 }
      }
      else if ((unsigned long) (hi - left_ptr) <= max_thresh) {
 hi = right_ptr;
      }
      else if ((right_ptr - lo) > (hi - left_ptr)) {
 ((void) ((top->lo = (lo)), (top->hi = (right_ptr)), ++top));
 lo = left_ptr;
      }
      else {
 ((void) ((top->lo = (left_ptr)), (top->hi = (hi)), ++top));
 hi = right_ptr;
      }
    }
  }
  {
    char *end_ptr = &base_ptr[size * (total_elems - 1)];
    char *tmp_ptr = base_ptr;
    char *thresh = ((end_ptr) < (base_ptr + max_thresh) ? (end_ptr) : (base_ptr + max_thresh));
    register char *run_ptr;
    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) {
      if ( *((int *)run_ptr) < *((int *) tmp_ptr) ) {
        tmp_ptr = run_ptr;
      }
    }
    if (tmp_ptr != base_ptr) {
      { int *ia = (int *)tmp_ptr; int *ib = (int *)base_ptr; int itmp = *ia; *ia = *ib; *ib = itmp; };
    }
    run_ptr = base_ptr + size;
    while ((run_ptr += size) <= end_ptr) {
      tmp_ptr = run_ptr - size;
      while ( *((int *)run_ptr) < *((int *)tmp_ptr) ) {
 tmp_ptr -= size;
      }
      tmp_ptr += size;
      if (tmp_ptr != run_ptr) {
 char *trav;
 trav = run_ptr + size;
 while (--trav >= run_ptr) {
   char c = *trav;
   char *hi; char *lo;
   for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) {
     *hi = *lo;
   }
   *hi = c;
 }
      }
    }
  }
}

variable_types:
pbase
void *

variable_types:
size
unsigned long

variable_types:
cmp
int (*)(void *, void *)

variable_types:
lo
char *

variable_types:
hi
char *

variable_types: struct stack_node { char *lo; char *hi; } [-1]

variable_types: struct stack_node { char *lo; char *hi; } *

variable_types:
mid
char *

variable_types:
ia
int *

variable_types:
ib
int *

variable_types: itmp int

variable_types:
thresh
char *

variable_types:
trav
char *

variable_types: c char


decompiled_code:
__int64 __fastcall div2_I4(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 i; // rcx
__int64 result; // rax

if ( a3 > 0 )
{
for ( i = 0LL; i != a3; ++i )
{
result = (unsigned int)(*(_DWORD *)(a1 + 4 * i) / *(_DWORD *)(a2 + 4 * i));
*(_DWORD *)(a4 + 4 * i) = result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 i; // rcx
__int64 result; // rax

if ( a3 > 0 )
{
for ( i = 0LL; i != a3; ++i )
{
result = (unsigned int)(*(_DWORD *)(a1 + 4 * i) / *(_DWORD *)(a2 + 4 * i));
*(_DWORD *)(a4 + 4 * i) = result;
}
}
return result;
}

original_code:
void
div2_I4(
       int *in1,
       int *in2,
       long long nR,
       int * restrict out
       )
{
  int inv1, inv2, outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 / inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

canonical_original_code:
void div2_I4(int *in1, int *in2, long long nR, int *out)
{
  int inv1; int inv2; int outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 / inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

variable_types:
nR
long long

variable_types:
out
int *

variable_types: outv int

variable_types:
i
long long


decompiled_code:
__int64 __fastcall cmp_eq_mult_scalar_I2(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 result; // rax

if ( a4 > 8 )
result = cmp_eq_mult_scalar_log_I2();
else
result = cmp_eq_mult_scalar_simple_I2();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 result; // rax

if ( a4 > 8 )
result = cmp_eq_mult_scalar_log_I2();
else
result = cmp_eq_mult_scalar_simple_I2();
return result;
}

original_code:
void
cmp_eq_mult_scalar_I2(
         short *in1,
         long long n1,
         short *in2,
         int n2,
         char * restrict out
          )
{
  if ( n2 <= 8 ) {
    cmp_eq_mult_scalar_simple_I2( in1, n1, in2, n2, out);
  }
  else
    cmp_eq_mult_scalar_log_I2( in1, n1, in2, n2, out);
}

canonical_original_code:
void cmp_eq_mult_scalar_I2(short *in1, long long n1, short *in2, int n2, char *out)
{
  if ( n2 <= 8 ) {
    cmp_eq_mult_scalar_simple_I2( in1, n1, in2, n2, out);
  }
  else
    cmp_eq_mult_scalar_log_I2( in1, n1, in2, n2, out);
}

variable_types:
out
char *


original_code:
void
sub2_I8(
       long long *in1,
       long long *in2,
       long long nR,
       long long * restrict out
       )
{
  long long inv1, inv2, outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 - inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

canonical_original_code:
void sub2_I8(long long *in1, long long *in2, long long nR, long long *out)
{
  long long inv1; long long inv2; long long outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 - inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

variable_types:
out
long long *

variable_types:
outv
long long


decompiled_code:
__int64 mk_dict()
{
return mk_dict_cc();
}

canonical_decompiled_code:
__int64 func0()
{
return mk_dict_cc();
}

original_code:
int mk_dict(const char * name, const char * pathname)
{
  return mk_dict_cc(name,pathname);
}

canonical_original_code:
int mk_dict(char *name, char *pathname)
{
  return mk_dict_cc(name,pathname);
}

variable_types:
name
char *

variable_types:
pathname
char *


decompiled_code:
__int64 del_dict()
{
return del_dict_cc();
}

canonical_decompiled_code:
__int64 func1()
{
return del_dict_cc();
}

original_code:
int del_dict(const char * name,const char * pathname)
{
  return del_dict_cc(name,pathname);
}

canonical_original_code:
int del_dict(char *name, char *pathname)
{
  return del_dict_cc(name,pathname);
}


decompiled_code:
__int64 is_dict()
{
return is_dict_cc();
}

canonical_decompiled_code:
__int64 func2()
{
return is_dict_cc();
}

original_code:
int is_dict(const char * name, const char * pathname, int * dict_exists)
{
  return is_dict_cc(name, pathname, dict_exists);
}

canonical_original_code:
int is_dict(char *name, char *pathname, int *dict_exists)
{
  return is_dict_cc(name, pathname, dict_exists);
}


decompiled_code:
__int64 add_to_dict_1()
{
return add_to_dict_cc();
}

canonical_decompiled_code:
__int64 func3()
{
return add_to_dict_cc();
}

original_code:
int add_to_dict_1(const char * name, const char * pathname, const char * key,const char * value)
{
  return add_to_dict_cc(name,pathname,key,value);
}

canonical_original_code:
int add_to_dict_1(char *name, char *pathname, char *key, char *value)
{
  return add_to_dict_cc(name,pathname,key,value);
}

variable_types:
key
char *

variable_types:
value
char *


decompiled_code:
__int64 add_to_dict_2()
{
return add_to_dict_2_cc();
}

canonical_decompiled_code:
__int64 func4()
{
return add_to_dict_2_cc();
}

original_code:
int add_to_dict_2(const char * name, const char * pathname, const char * key,const int value)
{
  return add_to_dict_2_cc(name,pathname,key,value);
}

canonical_original_code:
int add_to_dict_2(char *name, char *pathname, char *key, int value)
{
  return add_to_dict_2_cc(name,pathname,key,value);
}

variable_types: value int


decompiled_code:
__int64 add_to_dict_3()
{
return add_to_dict_3_cc();
}

canonical_decompiled_code:
__int64 func5()
{
return add_to_dict_3_cc();
}

original_code:
int add_to_dict_3(const char * name, const char * pathname, const int key,char * value)
{
  return add_to_dict_3_cc(name,pathname,key,value);
}

canonical_original_code:
int add_to_dict_3(char *name, char *pathname, int key, char *value)
{
  return add_to_dict_3_cc(name,pathname,key,value);
}

variable_types: key int


decompiled_code:
__int64 add_to_dict_4()
{
return add_to_dict_4_cc();
}

canonical_decompiled_code:
__int64 func6()
{
return add_to_dict_4_cc();
}

original_code:
int add_to_dict_4(const char * name, const char * pathname, const int key, const int value)
{
  return add_to_dict_4_cc (name, pathname, key,value);
}

canonical_original_code:
int add_to_dict_4(char *name, char *pathname, int key, int value)
{
  return add_to_dict_4_cc (name, pathname, key,value);
}


decompiled_code:
__int64 add_batch_to_dict_1()
{
return add_batch_to_dict_cc();
}

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

original_code:
int add_batch_to_dict_1(const char * name, const char * pathname, char ** batch_key, char ** batch_value, int batch_size)
{
  return add_batch_to_dict_cc(name,pathname,batch_key, batch_value, batch_size);
}

canonical_original_code:
int add_batch_to_dict_1(char *name, char *pathname, char **batch_key, char **batch_value, int batch_size)
{
  return add_batch_to_dict_cc(name,pathname,batch_key, batch_value, batch_size);
}


decompiled_code:
__int64 add_batch_to_dict_2()
{
return add_batch_to_dict_2_cc();
}

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

original_code:
int add_batch_to_dict_2(const char * name, const char * pathname, char ** batch_key, int * batch_value, int batch_size)
{
  return add_batch_to_dict_2_cc(name,pathname,batch_key, batch_value, batch_size);
}

canonical_original_code:
int add_batch_to_dict_2(char *name, char *pathname, char **batch_key, int *batch_value, int batch_size)
{
  return add_batch_to_dict_2_cc(name,pathname,batch_key, batch_value, batch_size);
}


decompiled_code:
__int64 add_batch_to_dict_3()
{
return add_batch_to_dict_3_cc();
}

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

original_code:
int add_batch_to_dict_3(const char * name, const char * pathname, int * batch_key, char ** batch_value, int batch_size)
{
  return add_batch_to_dict_3_cc(name,pathname,batch_key, batch_value, batch_size);
}

canonical_original_code:
int add_batch_to_dict_3(char *name, char *pathname, int *batch_key, char **batch_value, int batch_size)
{
  return add_batch_to_dict_3_cc(name,pathname,batch_key, batch_value, batch_size);
}


decompiled_code:
__int64 add_batch_to_dict_4()
{
return add_batch_to_dict_4_cc();
}

canonical_decompiled_code:
__int64 func10()
{
return add_batch_to_dict_4_cc();
}

original_code:
int add_batch_to_dict_4(const char * name, const char * pathname, int * batch_key, int * batch_value, int batch_size)
{
  return add_batch_to_dict_4_cc(name,pathname,batch_key, batch_value, batch_size);
}

canonical_original_code:
int add_batch_to_dict_4(char *name, char *pathname, int *batch_key, int *batch_value, int batch_size)
{
  return add_batch_to_dict_4_cc(name,pathname,batch_key, batch_value, batch_size);
}


decompiled_code:
__int64 get_from_dict_1()
{
return get_from_dict_cc();
}

canonical_decompiled_code:
__int64 func11()
{
return get_from_dict_cc();
}

original_code:
int get_from_dict_1(const char * name, const char * pathname, const char * key,char * value, int value_size, int *key_exists)
{
  return get_from_dict_cc(name,pathname,key,value,value_size, key_exists);
}

canonical_original_code:
int get_from_dict_1(char *name, char *pathname, char *key, char *value, int value_size, int *key_exists)
{
  return get_from_dict_cc(name,pathname,key,value,value_size, key_exists);
}


decompiled_code:
__int64 get_from_dict_2()
{
return get_from_dict_2_cc();
}

canonical_decompiled_code:
__int64 func12()
{
return get_from_dict_2_cc();
}

original_code:
int get_from_dict_2(const char * name, const char * pathname, const char * key,int * value, int * key_exists)
{
  return get_from_dict_2_cc(name,pathname,key,value, key_exists);
}

canonical_original_code:
int get_from_dict_2(char *name, char *pathname, char *key, int *value, int *key_exists)
{
  return get_from_dict_2_cc(name,pathname,key,value, key_exists);
}

variable_types:
value
int *


decompiled_code:
__int64 get_from_dict_3()
{
return get_from_dict_3_cc();
}

canonical_decompiled_code:
__int64 func13()
{
return get_from_dict_3_cc();
}

original_code:
int get_from_dict_3(const char * name, const char * pathname, const int key,char * value,int value_size, int* key_exists)
{
  return get_from_dict_3_cc(name,pathname,key,value,value_size, key_exists);
}

canonical_original_code:
int get_from_dict_3(char *name, char *pathname, int key, char *value, int value_size, int *key_exists)
{
  return get_from_dict_3_cc(name,pathname,key,value,value_size, key_exists);
}


decompiled_code:
__int64 get_from_dict_4()
{
return get_from_dict_4_cc();
}

canonical_decompiled_code:
__int64 func14()
{
return get_from_dict_4_cc();
}

original_code:
int get_from_dict_4(const char * name, const char * pathname, const int key, int * value, int * key_exists)
{
  return get_from_dict_4_cc(name, pathname, key, value, key_exists);
}

canonical_original_code:
int get_from_dict_4(char *name, char *pathname, int key, int *value, int *key_exists)
{
  return get_from_dict_4_cc(name, pathname, key, value, key_exists);
}


decompiled_code:
__int64 __fastcall get_first_key_val_from_dict_1(__int64 a1)
{
return get_first_key_val_from_dict_cc(a1);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
return get_first_key_val_from_dict_cc(a1);
}

original_code:
int get_first_key_val_from_dict_1(const char * name, const char * pathname, char * key, const int key_size, char * value, const int value_size, int * first_exists)
{
  return get_first_key_val_from_dict_cc(name, pathname, key, key_size, value, value_size, first_exists);
}

canonical_original_code:
int get_first_key_val_from_dict_1(char *name, char *pathname, char *key, int key_size, char *value, int value_size, int *first_exists)
{
  return get_first_key_val_from_dict_cc(name, pathname, key, key_size, value, value_size, first_exists);
}


decompiled_code:
__int64 get_first_key_val_from_dict_2()
{
return get_first_key_val_from_dict_2_cc();
}

canonical_decompiled_code:
__int64 func16()
{
return get_first_key_val_from_dict_2_cc();
}

original_code:
int get_first_key_val_from_dict_2(const char * name, const char * pathname, char * key, const int key_size, int * value, int * first_exists)
{
  return get_first_key_val_from_dict_2_cc(name, pathname, key, key_size, value, first_exists);
}

canonical_original_code:
int get_first_key_val_from_dict_2(char *name, char *pathname, char *key, int key_size, int *value, int *first_exists)
{
  return get_first_key_val_from_dict_2_cc(name, pathname, key, key_size, value, first_exists);
}


decompiled_code:
__int64 get_first_key_val_from_dict_3()
{
return get_first_key_val_from_dict_3_cc();
}

canonical_decompiled_code:
__int64 func17()
{
return get_first_key_val_from_dict_3_cc();
}

original_code:
int get_first_key_val_from_dict_3(const char * name, const char * pathname, int * key, char * value, const int value_size, int * first_exists)
{
  return get_first_key_val_from_dict_3_cc(name, pathname, key, value, value_size, first_exists);
}

canonical_original_code:
int get_first_key_val_from_dict_3(char *name, char *pathname, int *key, char *value, int value_size, int *first_exists)
{
  return get_first_key_val_from_dict_3_cc(name, pathname, key, value, value_size, first_exists);
}

variable_types:
key
int *


decompiled_code:
__int64 get_first_key_val_from_dict_4()
{
return get_first_key_val_from_dict_4_cc();
}

canonical_decompiled_code:
__int64 func18()
{
return get_first_key_val_from_dict_4_cc();
}

original_code:
int get_first_key_val_from_dict_4(const char * name, const char * pathname, int * key, int * value, int * first_exists)
{
  return get_first_key_val_from_dict_4_cc(name, pathname, key, value, first_exists);
}

canonical_original_code:
int get_first_key_val_from_dict_4(char *name, char *pathname, int *key, int *value, int *first_exists)
{
  return get_first_key_val_from_dict_4_cc(name, pathname, key, value, first_exists);
}


decompiled_code:
__int64 __fastcall get_next_key_val_from_dict_1(__int64 a1, __int64 a2)
{
return get_next_key_val_from_dict_cc(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, __int64 a2)
{
return get_next_key_val_from_dict_cc(a1, a2);
}

original_code:
int get_next_key_val_from_dict_1(const char * name, const char * pathname, char * current_key, char * key, const int key_size, char * value, const int value_size, int * next_exists)
{
  return get_next_key_val_from_dict_cc(name, pathname, current_key, key, key_size, value, value_size, next_exists);
}

canonical_original_code:
int get_next_key_val_from_dict_1(char *name, char *pathname, char *current_key, char *key, int key_size, char *value, int value_size, int *next_exists)
{
  return get_next_key_val_from_dict_cc(name, pathname, current_key, key, key_size, value, value_size, next_exists);
}


decompiled_code:
__int64 __fastcall get_next_key_val_from_dict_2(__int64 a1)
{
return get_next_key_val_from_dict_2_cc(a1);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1)
{
return get_next_key_val_from_dict_2_cc(a1);
}

original_code:
int get_next_key_val_from_dict_2(const char * name, const char * pathname, char * current_key, char * key, const int key_size, int * value, int * next_exists)
{
  return get_next_key_val_from_dict_2_cc(name, pathname, current_key, key, key_size, value, next_exists);
}

canonical_original_code:
int get_next_key_val_from_dict_2(char *name, char *pathname, char *current_key, char *key, int key_size, int *value, int *next_exists)
{
  return get_next_key_val_from_dict_2_cc(name, pathname, current_key, key, key_size, value, next_exists);
}


decompiled_code:
__int64 __fastcall get_next_key_val_from_dict_3(__int64 a1)
{
return get_next_key_val_from_dict_3_cc(a1);
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1)
{
return get_next_key_val_from_dict_3_cc(a1);
}

original_code:
int get_next_key_val_from_dict_3(const char * name, const char * pathname, int current_key, int * key, char * value, const int value_size, int * next_exists)
{
  return get_next_key_val_from_dict_3_cc(name, pathname, current_key, key, value, value_size, next_exists);
}

canonical_original_code:
int get_next_key_val_from_dict_3(char *name, char *pathname, int current_key, int *key, char *value, int value_size, int *next_exists)
{
  return get_next_key_val_from_dict_3_cc(name, pathname, current_key, key, value, value_size, next_exists);
}


decompiled_code:
__int64 get_next_key_val_from_dict_4()
{
return get_next_key_val_from_dict_4_cc();
}

canonical_decompiled_code:
__int64 func22()
{
return get_next_key_val_from_dict_4_cc();
}

original_code:
int get_next_key_val_from_dict_4(const char * name, const char * pathname, int current_key, int * key, int * value, int * next_exists)
{
  return get_next_key_val_from_dict_4_cc(name, pathname, current_key, key, value, next_exists);
}

canonical_original_code:
int get_next_key_val_from_dict_4(char *name, char *pathname, int current_key, int *key, int *value, int *next_exists)
{
  return get_next_key_val_from_dict_4_cc(name, pathname, current_key, key, value, next_exists);
}


decompiled_code:
__int64 del_from_dict_1()
{
return del_from_dict_cc();
}

canonical_decompiled_code:
__int64 func23()
{
return del_from_dict_cc();
}

original_code:
int del_from_dict_1(const char * name, const char * pathname, const char * key)
{
  return del_from_dict_cc(name,pathname,key);
}

canonical_original_code:
int del_from_dict_1(char *name, char *pathname, char *key)
{
  return del_from_dict_cc(name,pathname,key);
}


decompiled_code:
__int64 del_from_dict_2()
{
return del_from_dict_cc();
}

canonical_decompiled_code:
__int64 func24()
{
return del_from_dict_cc();
}

original_code:
int del_from_dict_2(const char * name, const char * pathname, const char * key)
{
  return del_from_dict_cc(name,pathname,key);
}

canonical_original_code:
int del_from_dict_2(char *name, char *pathname, char *key)
{
  return del_from_dict_cc(name,pathname,key);
}


decompiled_code:
__int64 del_from_dict_3()
{
return del_from_dict_3_cc();
}

canonical_decompiled_code:
__int64 func25()
{
return del_from_dict_3_cc();
}

original_code:
int del_from_dict_3(const char * name, const char * pathname, const int key)
{
  return del_from_dict_3_cc(name,pathname,key);
}

canonical_original_code:
int del_from_dict_3(char *name, char *pathname, int key)
{
  return del_from_dict_3_cc(name,pathname,key);
}


decompiled_code:
__int64 del_from_dict_4()
{
return del_from_dict_3_cc();
}

canonical_decompiled_code:
__int64 func26()
{
return del_from_dict_3_cc();
}

original_code:
int del_from_dict_4(const char * name, const char * pathname, const int key)
{
  return del_from_dict_3_cc(name,pathname,key);
}

canonical_original_code:
int del_from_dict_4(char *name, char *pathname, int key)
{
  return del_from_dict_3_cc(name,pathname,key);
}


cleanUp

decompiled_code:
__int64 cleanUp()
{
return cleanUp_cc();
}

canonical_decompiled_code:
__int64 func27()
{
return cleanUp_cc();
}

original_code:
void cleanUp()
{
  cleanUp_cc();
}

canonical_original_code:
void cleanUp()
{
  cleanUp_cc();
}


original_code:
int
pos_sel_aux_nn_copy_I4_I8(
    int *f1_select,
    char *nn_f1_select,
    int *f1_copy,
    char *nn_f1_copy,
    long long nR1,
    long long *f2,
    char *nn_f2,
    long long nR2,
    int lb,
    int ub,
    int *f3,
    long long *ptr_cnt
    )
{
  int status = 0;
  long long cnt = 0;
  long long i3 = 0;
  for ( long long i2 = 0; i2 < nR2; i2++ ) {
    if ( ( nn_f2 != ((void *)0) ) && ( nn_f2[i2] == 0 ) ) { continue; }
    long long f1idx = f2[i2];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "./AUX/pos_sel_aux_nn_copy_I4_I8.c"); }; status = -1 ; goto BYE; }; }
    if ( ( nn_f1_select != ((void *)0) ) && ( nn_f1_select[f1idx] == 0 ) ) { continue; }
    int val = f1_select[f1idx];
    if ( ( val >= lb ) && ( val <= ub ) ) {
      if ( ( nn_f1_copy != ((void *)0) ) && ( nn_f1_copy[f1idx] == 0 ) ) {
      }
      else {
        val = f1_copy[f1idx];
        f3[i3++] = val;
        cnt++;
      }
    }
  }
  *ptr_cnt = cnt;
BYE:
  return(status);
}

canonical_original_code:
int pos_sel_aux_nn_copy_I4_I8(int *f1_select, char *nn_f1_select, int *f1_copy, char *nn_f1_copy, long long nR1, long long *f2, char *nn_f2, long long nR2, int lb, int ub, int *f3, long long *ptr_cnt)
{
  int status = 0;
  long long cnt = 0;
  long long i3 = 0;
  for ( long long i2 = 0; i2 < nR2; i2++ ) {
    if ( ( nn_f2 != ((void *)0) ) && ( nn_f2[i2] == 0 ) ) { continue; }
    long long f1idx = f2[i2];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "./AUX/pos_sel_aux_nn_copy_I4_I8.c"); }; status = -1 ; goto BYE; }; }
    if ( ( nn_f1_select != ((void *)0) ) && ( nn_f1_select[f1idx] == 0 ) ) { continue; }
    int val = f1_select[f1idx];
    if ( ( val >= lb ) && ( val <= ub ) ) {
      if ( ( nn_f1_copy != ((void *)0) ) && ( nn_f1_copy[f1idx] == 0 ) ) {
      }
      else {
        val = f1_copy[f1idx];
        f3[i3++] = val;
        cnt++;
      }
    }
  }
  *ptr_cnt = cnt;
BYE:
  return(status);
}

variable_types: lb int

variable_types: ub int

variable_types: status int

variable_types:
cnt
long long

variable_types: val int


decompiled_code:
__int64 __fastcall stride_I4(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v6; // rax
__int64 result; // rax

if ( a6 <= 0 )
return 0LL;
if ( a3 < 0 || a3 >= a2 )
{
LABEL_8:
fprintf(stderr, "Line %3d of File %s \n", 35LL, "stride.c");
result = 0xFFFFFFFFLL;
}
else
{
v6 = 0LL;
while ( 1 )
{
*(_DWORD *)(a5 + 4 * v6) = *(_DWORD *)(a1 + 4 * a3);
a3 += a4;
if ( a6 == ++v6 )
break;
if ( a3 < 0 || a2 <= a3 )
goto LABEL_8;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v6; // rax
__int64 result; // rax

if ( a6 <= 0 )
return 0LL;
if ( a3 < 0 || a3 >= a2 )
{
LABEL_8:
fprintf(stderr, "Line %3d of File %s \n", 35LL, "stride.c");
result = 0xFFFFFFFFLL;
}
else
{
v6 = 0LL;
while ( 1 )
{
*(_DWORD *)(a5 + 4 * v6) = *(_DWORD *)(a1 + 4 * a3);
a3 += a4;
if ( a6 == ++v6 )
break;
if ( a3 < 0 || a2 <= a3 )
goto LABEL_8;
}
result = 0LL;
}
return result;
}

original_code:
int
stride_I4(
    int *f1,
    long long nR1,
    long long start,
    long long stride,
    int *f2,
    long long nR2
    )
{
  int status = 0;
  long long f1_idx = start;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( f1_idx < 0 ) || ( f1_idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "stride.c"); }; status = -1 ; goto BYE; }; }
    f2[i] = f1[f1_idx];
    f1_idx += stride;
  }
BYE:
  return status ;
}

canonical_original_code:
int stride_I4(int *f1, long long nR1, long long start, long long stride, int *f2, long long nR2)
{
  int status = 0;
  long long f1_idx = start;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( f1_idx < 0 ) || ( f1_idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "stride.c"); }; status = -1 ; goto BYE; }; }
    f2[i] = f1[f1_idx];
    f1_idx += stride;
  }
BYE:
  return status ;
}

variable_types:
start
long long

variable_types:
stride
long long

variable_types:
i
long long


decompiled_code:
__int64 __fastcall stride_I8(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v6; // rax
__int64 result; // rax

if ( a6 <= 0 )
return 0LL;
if ( a3 < 0 || a3 >= a2 )
{
LABEL_8:
fprintf(stderr, "Line %3d of File %s \n", 58LL, "stride.c");
result = 0xFFFFFFFFLL;
}
else
{
v6 = 0LL;
while ( 1 )
{
*(_QWORD *)(a5 + 8 * v6) = *(_QWORD *)(a1 + 8 * a3);
a3 += a4;
if ( a6 == ++v6 )
break;
if ( a3 < 0 || a2 <= a3 )
goto LABEL_8;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v6; // rax
__int64 result; // rax

if ( a6 <= 0 )
return 0LL;
if ( a3 < 0 || a3 >= a2 )
{
LABEL_8:
fprintf(stderr, "Line %3d of File %s \n", 58LL, "stride.c");
result = 0xFFFFFFFFLL;
}
else
{
v6 = 0LL;
while ( 1 )
{
*(_QWORD *)(a5 + 8 * v6) = *(_QWORD *)(a1 + 8 * a3);
a3 += a4;
if ( a6 == ++v6 )
break;
if ( a3 < 0 || a2 <= a3 )
goto LABEL_8;
}
result = 0LL;
}
return result;
}

original_code:
int
stride_I8(
    long long *f1,
    long long nR1,
    long long start,
    long long stride,
    long long *f2,
    long long nR2
    )
{
  int status = 0;
  long long f1_idx = start;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( f1_idx < 0 ) || ( f1_idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "stride.c"); }; status = -1 ; goto BYE; }; }
    f2[i] = f1[f1_idx];
    f1_idx += stride;
  }
BYE:
  return status ;
}

canonical_original_code:
int stride_I8(long long *f1, long long nR1, long long start, long long stride, long long *f2, long long nR2)
{
  int status = 0;
  long long f1_idx = start;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( f1_idx < 0 ) || ( f1_idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "stride.c"); }; status = -1 ; goto BYE; }; }
    f2[i] = f1[f1_idx];
    f1_idx += stride;
  }
BYE:
  return status ;
}