gvWait

decompiled_code:
__int64 __fastcall gvWait(pthread_cond_t *a1, pthread_mutex_t *a2)
{
return (unsigned int)-(pthread_cond_wait(a1, a2) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func0(pthread_cond_t *a1, pthread_mutex_t *a2)
{
return (unsigned int)-(pthread_cond_wait(a1, a2) != 0);
}

original_code:
int
gvWait(GVcondvarptr condVar, GVlockptr lock)
{

    {
 if (pthread_cond_wait(condVar, lock) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
int gvWait(union pthread_cond_t *condVar, union pthread_mutex_t *lock)
{

    {
 if (pthread_cond_wait(condVar, lock) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

variable_types: union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } *

variable_types: union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

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

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


gvNotify

repo: schumajs/egl-gles-remoting

decompiled_code:
__int64 __fastcall gvNotify(pthread_cond_t *a1)
{
return (unsigned int)-(pthread_cond_signal(a1) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func1(pthread_cond_t *a1)
{
return (unsigned int)-(pthread_cond_signal(a1) != 0);
}

original_code:
int
gvNotify(GVcondvarptr condVar)
{

    {
 if (pthread_cond_signal(condVar) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
int gvNotify(union pthread_cond_t *condVar)
{

    {
 if (pthread_cond_signal(condVar) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

return_type: int

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }


gvDestroyCondVar

decompiled_code:
__int64 __fastcall gvDestroyCondVar(void *ptr)
{
unsigned int v1; // er12

if ( pthread_cond_destroy((pthread_cond_t *)ptr) )
return (unsigned int)-1;
v1 = 0;
free(ptr);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(void *ptr)
{
unsigned int v1; // er12

if ( pthread_cond_destroy((pthread_cond_t *)ptr) )
return (unsigned int)-1;
v1 = 0;
free(ptr);
return v1;
}

original_code:
int
gvDestroyCondVar(GVcondvarptr condVar)
{

    {
 if (pthread_cond_destroy(condVar) != 0)
 {
     goto e0;
 }
 free(condVar);
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
int gvDestroyCondVar(union pthread_cond_t *condVar)
{

    {
 if (pthread_cond_destroy(condVar) != 0)
 {
     goto e0;
 }
 free(condVar);
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}


initHeapMgrClient

decompiled_code:
__int64 initHeapMgrClient()
{
char *v0; // rax
int v1; // ebp
char *v2; // rax
int v3; // ebx
_QWORD *v4; // rax
__int64 **v5; // rax
__int64 v6; // rdx
__int64 v7; // rax

v0 = getenv("GV_HMGR_SHM_FD");
v1 = atoi(v0);
v2 = getenv("GV_HMGR_SHM_SIZE");
v3 = atoi(v2);
v4 = malloc(0x10uLL);
if ( !v4 )
return 0xFFFFFFFFLL;
*(_DWORD *)v4 = v1;
v4[1] = v3;
v5 = (__int64 **)gvCreateShmStreamTransport(v4, 0LL);
transport = (__int64)v5;
if ( !v5 )
return 0xFFFFFFFFLL;
v6 = **v5;
v7 = *v5[1];
ocLock = v6;
icLock = v7;
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rax
int v1; // ebp
char *v2; // rax
int v3; // ebx
_QWORD *v4; // rax
__int64 **v5; // rax
__int64 v6; // rdx
__int64 v7; // rax

v0 = getenv("GV_HMGR_SHM_FD");
v1 = atoi(v0);
v2 = getenv("GV_HMGR_SHM_SIZE");
v3 = atoi(v2);
v4 = malloc(0x10uLL);
if ( !v4 )
return 0xFFFFFFFFLL;
*(_DWORD *)v4 = v1;
v4[1] = v3;
v5 = (__int64 **)gvCreateShmStreamTransport(v4, 0LL);
transport = (__int64)v5;
if ( !v5 )
return 0xFFFFFFFFLL;
v6 = **v5;
v7 = *v5[1];
ocLock = v6;
icLock = v7;
return 0LL;
}

original_code:
static int
initHeapMgrClient()
{
    GVshmptr heapMgrShm;
    int heapMgrShmFd = atoi(getenv("GV_HMGR_SHM_FD"));
    int heapMgrShmSize = atoi(getenv("GV_HMGR_SHM_SIZE"));

    {
 if ((heapMgrShm = malloc(sizeof(struct GVshm))) == ((void *)0))
 {
     goto e0;
 }
 heapMgrShm->id = heapMgrShmFd;
 heapMgrShm->size = heapMgrShmSize;
 if ((transport
      = gvCreateShmStreamTransport(heapMgrShm,
       0,
       heapMgrShmSize)) == ((void *)0))
 {
     goto e0;
 }
 ocLock = transport->callChanel->exclusiveAccess;
 icLock = transport->returnChanel->exclusiveAccess;
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
static int initHeapMgrClient()
{
    struct GVshm *heapMgrShm;
    int heapMgrShmFd = atoi(getenv("GV_HMGR_SHM_FD"));
    int heapMgrShmSize = atoi(getenv("GV_HMGR_SHM_SIZE"));

    {
 if ((heapMgrShm = malloc(sizeof(struct GVshm))) == ((void *)0))
 {
     goto e0;
 }
 heapMgrShm->id = heapMgrShmFd;
 heapMgrShm->size = heapMgrShmSize;
 if ((transport
      = gvCreateShmStreamTransport(heapMgrShm,
       0,
       heapMgrShmSize)) == ((void *)0))
 {
     goto e0;
 }
 ocLock = transport->callChanel->exclusiveAccess;
 icLock = transport->returnChanel->exclusiveAccess;
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

variable_types: struct GVshm { int id; unsigned long size; } *

variable_types: heapMgrShmFd int

variable_types: heapMgrShmSize int


gvAlloc

decompiled_code:
__int64 __fastcall gvAlloc(__int64 a1)
{
unsigned int v1; // er12
__int64 v3; // [rsp+8h] [rbp-20h] BYREF
__int64 v4; // [rsp+18h] [rbp-10h] BYREF

v3 = a1;
if ( processInitiated )
goto LABEL_4;
if ( (unsigned int)initHeapMgrClient() != -1 )
{
processInitiated = 1;
LABEL_4:
v1 = gvStartSending(transport, ocLock, 0LL);
gvSendData(transport, &v3, 8LL);
gvStopSending(transport, ocLock);
gvStartReceiving(transport, icLock, v1);
gvReceiveData(transport, &v4, 8LL);
gvStopReceiving(transport, icLock);
return v4;
}
return -1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // er12
__int64 v3; // [rsp+8h] [rbp-20h] BYREF
__int64 v4; // [rsp+18h] [rbp-10h] BYREF

v3 = a1;
if ( processInitiated )
goto LABEL_4;
if ( (unsigned int)func0() != -1 )
{
processInitiated = 1;
LABEL_4:
v1 = gvStartSending(transport, ocLock, 0LL);
gvSendData(transport, &v3, 8LL);
gvStopSending(transport, ocLock);
gvStartReceiving(transport, icLock, v1);
gvReceiveData(transport, &v4, 8LL);
gvStopReceiving(transport, icLock);
return v4;
}
return -1LL;
}

original_code:
size_t
gvAlloc(size_t length)
{
    GVcallid callId;
    size_t offset;
    do { if (!processInitiated) { if (initHeapMgrClient() == -1) return -1; processInitiated = 1; } } while (0);
    callId = gvStartSending(transport, ocLock, 0x0);
    gvSendData(transport, &length, sizeof(size_t));
    gvStopSending(transport, ocLock);
    gvStartReceiving(transport, icLock, callId);
    gvReceiveData(transport, &offset, sizeof(size_t));
    gvStopReceiving(transport, icLock);
    return offset;
}

canonical_original_code:
unsigned long gvAlloc(unsigned long length)
{
    int callId;
    unsigned long offset;
    do { if (!processInitiated) { if (initHeapMgrClient() == -1) return -1; processInitiated = 1; } } while (0);
    callId = gvStartSending(transport, ocLock, 0x0);
    gvSendData(transport, &length, sizeof(unsigned long));
    gvStopSending(transport, ocLock);
    gvStartReceiving(transport, icLock, callId);
    gvReceiveData(transport, &offset, sizeof(unsigned long));
    gvStopReceiving(transport, icLock);
    return offset;
}

variable_types:
length
unsigned long

variable_types: callId int

variable_types:
offset
unsigned long

return_type: unsigned long


gvFree

decompiled_code:
__int64 __fastcall gvFree(__int64 a1)
{
__int64 result; // rax
unsigned int v2; // er12
__int64 v3; // [rsp+8h] [rbp-20h] BYREF
unsigned int v4[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v3 = a1;
if ( !processInitiated )
{
result = initHeapMgrClient();
if ( (_DWORD)result == -1 )
return result;
processInitiated = 1;
}
v2 = gvStartSending(transport, ocLock, 1LL);
gvSendData(transport, &v3, 8LL);
gvStopSending(transport, ocLock);
gvStartReceiving(transport, icLock, v2);
gvReceiveData(transport, v4, 4LL);
gvStopReceiving(transport, icLock);
return v4[0];
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax
unsigned int v2; // er12
__int64 v3; // [rsp+8h] [rbp-20h] BYREF
unsigned int v4[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v3 = a1;
if ( !processInitiated )
{
result = func0();
if ( (_DWORD)result == -1 )
return result;
processInitiated = 1;
}
v2 = gvStartSending(transport, ocLock, 1LL);
gvSendData(transport, &v3, 8LL);
gvStopSending(transport, ocLock);
gvStartReceiving(transport, icLock, v2);
gvReceiveData(transport, v4, 4LL);
gvStopReceiving(transport, icLock);
return v4[0];
}

original_code:
int
gvFree(size_t offset)
{
    GVcallid callId;
    int status;
    do { if (!processInitiated) { if (initHeapMgrClient() == -1) return -1; processInitiated = 1; } } while (0);
    callId = gvStartSending(transport, ocLock, 0x1);
    gvSendData(transport, &offset, sizeof(size_t));
    gvStopSending(transport, ocLock);
    gvStartReceiving(transport, icLock, callId);
    gvReceiveData(transport, &status, sizeof(int));
    gvStopReceiving(transport, icLock);
    return status;
}

canonical_original_code:
int gvFree(unsigned long offset)
{
    int callId;
    int status;
    do { if (!processInitiated) { if (initHeapMgrClient() == -1) return -1; processInitiated = 1; } } while (0);
    callId = gvStartSending(transport, ocLock, 0x1);
    gvSendData(transport, &offset, sizeof(unsigned long));
    gvStopSending(transport, ocLock);
    gvStartReceiving(transport, icLock, callId);
    gvReceiveData(transport, &status, sizeof(int));
    gvStopReceiving(transport, icLock);
    return status;
}

variable_types: status int


gvAcquireLock

decompiled_code:
__int64 __fastcall gvAcquireLock(pthread_mutex_t *a1)
{
return (unsigned int)-(pthread_mutex_lock(a1) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func0(pthread_mutex_t *a1)
{
return (unsigned int)-(pthread_mutex_lock(a1) != 0);
}

original_code:
int
gvAcquireLock(GVlockptr lock)
{

    {
 if (pthread_mutex_lock(lock) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
int gvAcquireLock(union pthread_mutex_t *lock)
{

    {
 if (pthread_mutex_lock(lock) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

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


gvReleaseLock

decompiled_code:
__int64 __fastcall gvReleaseLock(pthread_mutex_t *a1)
{
return (unsigned int)-(pthread_mutex_unlock(a1) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func1(pthread_mutex_t *a1)
{
return (unsigned int)-(pthread_mutex_unlock(a1) != 0);
}

original_code:
int
gvReleaseLock(GVlockptr lock)
{

    {
 if (pthread_mutex_unlock(lock) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
int gvReleaseLock(union pthread_mutex_t *lock)
{

    {
 if (pthread_mutex_unlock(lock) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}


gvDestroyLock

decompiled_code:
__int64 __fastcall gvDestroyLock(void *ptr)
{
unsigned int v1; // er12

if ( pthread_mutex_destroy((pthread_mutex_t *)ptr) )
return (unsigned int)-1;
v1 = 0;
free(ptr);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(void *ptr)
{
unsigned int v1; // er12

if ( pthread_mutex_destroy((pthread_mutex_t *)ptr) )
return (unsigned int)-1;
v1 = 0;
free(ptr);
return v1;
}

original_code:
int
gvDestroyLock(GVlockptr lock)
{

    {
 if (pthread_mutex_destroy(lock) != 0)
 {
     goto e0;
 }
 free(lock);
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
int gvDestroyLock(union pthread_mutex_t *lock)
{

    {
 if (pthread_mutex_destroy(lock) != 0)
 {
     goto e0;
 }
 free(lock);
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}


initJanitorClient

decompiled_code:
__int64 initJanitorClient()
{
char *v0; // rax
int v1; // ebp
char *v2; // rax
int v3; // ebx
_QWORD *v4; // rax
__int64 **v5; // rax
__int64 v6; // rdx
__int64 v7; // rax

v0 = getenv("GV_JANITOR_SHM_FD");
v1 = atoi(v0);
v2 = getenv("GV_JANITOR_SHM_SIZE");
v3 = atoi(v2);
v4 = malloc(0x10uLL);
if ( !v4 )
return 0xFFFFFFFFLL;
*(_DWORD *)v4 = v1;
v4[1] = v3;
v5 = (__int64 **)gvCreateShmStreamTransport(v4, 0LL);
transport = (__int64)v5;
if ( !v5 )
return 0xFFFFFFFFLL;
v6 = **v5;
v7 = *v5[1];
ocLock = v6;
icLock = v7;
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rax
int v1; // ebp
char *v2; // rax
int v3; // ebx
_QWORD *v4; // rax
__int64 **v5; // rax
__int64 v6; // rdx
__int64 v7; // rax

v0 = getenv("GV_JANITOR_SHM_FD");
v1 = atoi(v0);
v2 = getenv("GV_JANITOR_SHM_SIZE");
v3 = atoi(v2);
v4 = malloc(0x10uLL);
if ( !v4 )
return 0xFFFFFFFFLL;
*(_DWORD *)v4 = v1;
v4[1] = v3;
v5 = (__int64 **)gvCreateShmStreamTransport(v4, 0LL);
transport = (__int64)v5;
if ( !v5 )
return 0xFFFFFFFFLL;
v6 = **v5;
v7 = *v5[1];
ocLock = v6;
icLock = v7;
return 0LL;
}

original_code:
static int
initJanitorClient()
{
    GVshmptr janitorShm;
    int janitorShmFd = atoi(getenv("GV_JANITOR_SHM_FD"));
    int janitorShmSize = atoi(getenv("GV_JANITOR_SHM_SIZE"));

    {
 if ((janitorShm = malloc(sizeof(struct GVshm))) == ((void *)0))
 {
     goto e0;
 }
 janitorShm->id = janitorShmFd;
 janitorShm->size = janitorShmSize;
 if ((transport
      = gvCreateShmStreamTransport(janitorShm,
       0,
       janitorShmSize)) == ((void *)0))
 {
     goto e0;
 }
 ocLock = transport->callChanel->exclusiveAccess;
 icLock = transport->returnChanel->exclusiveAccess;
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
static int initJanitorClient()
{
    struct GVshm *janitorShm;
    int janitorShmFd = atoi(getenv("GV_JANITOR_SHM_FD"));
    int janitorShmSize = atoi(getenv("GV_JANITOR_SHM_SIZE"));

    {
 if ((janitorShm = malloc(sizeof(struct GVshm))) == ((void *)0))
 {
     goto e0;
 }
 janitorShm->id = janitorShmFd;
 janitorShm->size = janitorShmSize;
 if ((transport
      = gvCreateShmStreamTransport(janitorShm,
       0,
       janitorShmSize)) == ((void *)0))
 {
     goto e0;
 }
 ocLock = transport->callChanel->exclusiveAccess;
 icLock = transport->returnChanel->exclusiveAccess;
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

variable_types: janitorShmFd int

variable_types: janitorShmSize int

user_defined_types: struct GVshm { int id; unsigned long size; }


gvBonjour

decompiled_code:
__int64 __fastcall gvBonjour(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // er12
__int64 v4; // [rsp+0h] [rbp-28h] BYREF
__int64 v5; // [rsp+8h] [rbp-20h] BYREF
unsigned int v6[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v5 = a1;
v4 = a2;
if ( !processInitiated )
{
result = initJanitorClient(a1, a2);
if ( (_DWORD)result == -1 )
return result;
processInitiated = 1;
}
v3 = gvStartSending(transport, ocLock, 0LL);
gvSendData(transport, &v5, 8LL);
gvSendData(transport, &v4, 8LL);
gvStopSending(transport, ocLock);
gvStartReceiving(transport, icLock, v3);
gvReceiveData(transport, v6, 4LL);
gvStopReceiving(transport, icLock);
return v6[0];
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // er12
__int64 v4; // [rsp+0h] [rbp-28h] BYREF
__int64 v5; // [rsp+8h] [rbp-20h] BYREF
unsigned int v6[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v5 = a1;
v4 = a2;
if ( !processInitiated )
{
result = func0(a1, a2);
if ( (_DWORD)result == -1 )
return result;
processInitiated = 1;
}
v3 = gvStartSending(transport, ocLock, 0LL);
gvSendData(transport, &v5, 8LL);
gvSendData(transport, &v4, 8LL);
gvStopSending(transport, ocLock);
gvStartReceiving(transport, icLock, v3);
gvReceiveData(transport, v6, 4LL);
gvStopReceiving(transport, icLock);
return v6[0];
}

original_code:
int
gvBonjour(size_t offset, size_t length)
{
    GVcallid callId;
    int status;
    do { if (!processInitiated) { if (initJanitorClient() == -1) return -1; processInitiated = 1; } } while (0);
    callId = gvStartSending(transport, ocLock, 0x0);
    gvSendData(transport, &offset, sizeof(size_t));
    gvSendData(transport, &length, sizeof(size_t));
    gvStopSending(transport, ocLock);
    gvStartReceiving(transport, icLock, callId);
    gvReceiveData(transport, &status, sizeof(int));
    gvStopReceiving(transport, icLock);
    return status;
}

canonical_original_code:
int gvBonjour(unsigned long offset, unsigned long length)
{
    int callId;
    int status;
    do { if (!processInitiated) { if (initJanitorClient() == -1) return -1; processInitiated = 1; } } while (0);
    callId = gvStartSending(transport, ocLock, 0x0);
    gvSendData(transport, &offset, sizeof(unsigned long));
    gvSendData(transport, &length, sizeof(unsigned long));
    gvStopSending(transport, ocLock);
    gvStartReceiving(transport, icLock, callId);
    gvReceiveData(transport, &status, sizeof(int));
    gvStopReceiving(transport, icLock);
    return status;
}


gvAuRevoir

decompiled_code:
__int64 __fastcall gvAuRevoir(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // er12
__int64 v4; // [rsp+8h] [rbp-20h] BYREF
unsigned int v5[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v4 = a1;
if ( !processInitiated )
{
result = initJanitorClient(a1, a2);
if ( (_DWORD)result == -1 )
return result;
processInitiated = 1;
}
v3 = gvStartSending(transport, ocLock, 1LL);
gvSendData(transport, &v4, 8LL);
gvStopSending(transport, ocLock);
gvStartReceiving(transport, icLock, v3);
gvReceiveData(transport, v5, 4LL);
gvStopReceiving(transport, icLock);
return v5[0];
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // er12
__int64 v4; // [rsp+8h] [rbp-20h] BYREF
unsigned int v5[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v4 = a1;
if ( !processInitiated )
{
result = func0(a1, a2);
if ( (_DWORD)result == -1 )
return result;
processInitiated = 1;
}
v3 = gvStartSending(transport, ocLock, 1LL);
gvSendData(transport, &v4, 8LL);
gvStopSending(transport, ocLock);
gvStartReceiving(transport, icLock, v3);
gvReceiveData(transport, v5, 4LL);
gvStopReceiving(transport, icLock);
return v5[0];
}

original_code:
int
gvAuRevoir(size_t offset)
{
    GVcallid callId;
    int status;
    do { if (!processInitiated) { if (initJanitorClient() == -1) return -1; processInitiated = 1; } } while (0);
    callId = gvStartSending(transport, ocLock, 0x1);
    gvSendData(transport, &offset, sizeof(size_t));
    gvStopSending(transport, ocLock);
    gvStartReceiving(transport, icLock, callId);
    gvReceiveData(transport, &status, sizeof(int));
    gvStopReceiving(transport, icLock);
    return status;
}

canonical_original_code:
int gvAuRevoir(unsigned long offset)
{
    int callId;
    int status;
    do { if (!processInitiated) { if (initJanitorClient() == -1) return -1; processInitiated = 1; } } while (0);
    callId = gvStartSending(transport, ocLock, 0x1);
    gvSendData(transport, &offset, sizeof(unsigned long));
    gvStopSending(transport, ocLock);
    gvStartReceiving(transport, icLock, callId);
    gvReceiveData(transport, &status, sizeof(int));
    gvStopReceiving(transport, icLock);
    return status;
}


gvDelOffsetState

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

if ( pthread_rwlock_wrlock(&processStateLock) )
return -1;
if ( (unsigned int)gvDelProcessStateItem(a1) == -1 || (result = pthread_rwlock_unlock(&processStateLock)) != 0 )
{
pthread_rwlock_unlock(&processStateLock);
result = -1;
}
return result;
}

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

if ( pthread_rwlock_wrlock(&processStateLock) )
return -1;
if ( (unsigned int)gvDelProcessStateItem(a1) == -1 || (result = pthread_rwlock_unlock(&processStateLock)) != 0 )
{
pthread_rwlock_unlock(&processStateLock);
result = -1;
}
return result;
}

original_code:
int
gvDelOffsetState(size_t offset)
{

    {
        if (pthread_rwlock_wrlock(&processStateLock) != 0)
        {
            goto e0;
        }
 if (gvDelProcessStateItem(offset) == -1)
 {
     goto e1;
 }
        if (pthread_rwlock_unlock(&processStateLock) != 0)
        {
            goto e1;
        }
    }
    while (0) e0:
    {
 return -1;
    }
    while (0) e1:
    {
        pthread_rwlock_unlock(&processStateLock);
        return -1;
    }
    return 0;
}

canonical_original_code:
int gvDelOffsetState(unsigned long offset)
{

    {
        if (pthread_rwlock_wrlock(&processStateLock) != 0)
        {
            goto e0;
        }
 if (gvDelProcessStateItem(offset) == -1)
 {
     goto e1;
 }
        if (pthread_rwlock_unlock(&processStateLock) != 0)
        {
            goto e1;
        }
    }
    while (0) e0:
    {
 return -1;
    }
    while (0) e1:
    {
        pthread_rwlock_unlock(&processStateLock);
        return -1;
    }
    return 0;
}


gvGetOffsetState

decompiled_code:
__int64 __fastcall gvGetOffsetState(__int64 a1)
{
__int64 v1; // r12

v1 = 0LL;
if ( pthread_rwlock_rdlock(&processStateLock) )
return v1;
v1 = gvGetProcessStateItem(a1);
if ( v1 )
{
if ( !pthread_rwlock_unlock(&processStateLock) )
return v1;
}
pthread_rwlock_unlock(&processStateLock);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // r12

v1 = 0LL;
if ( pthread_rwlock_rdlock(&processStateLock) )
return v1;
v1 = gvGetProcessStateItem(a1);
if ( v1 )
{
if ( !pthread_rwlock_unlock(&processStateLock) )
return v1;
}
pthread_rwlock_unlock(&processStateLock);
return 0LL;
}

original_code:
GVoffsetstateptr
gvGetOffsetState(size_t offset)
{
    GVoffsetstateptr state;

    {
        if (pthread_rwlock_rdlock(&processStateLock) != 0)
        {
            goto e0;
        }
 if ((state
      = (GVoffsetstateptr) gvGetProcessStateItem(offset)) == ((void *)0))
 {
     goto e1;
 }
        if (pthread_rwlock_unlock(&processStateLock) != 0)
        {
            goto e1;
        }
    }
    while (0) e0:
    {
 return ((void *)0);
    }
    while (0) e1:
    {
        pthread_rwlock_unlock(&processStateLock);
        return ((void *)0);
    }
    return state;
}

canonical_original_code:
struct GVoffsetstate *gvGetOffsetState(unsigned long offset)
{
    struct GVoffsetstate *state;

    {
        if (pthread_rwlock_rdlock(&processStateLock) != 0)
        {
            goto e0;
        }
 if ((state
      = (struct GVoffsetstate *) gvGetProcessStateItem(offset)) == ((void *)0))
 {
     goto e1;
 }
        if (pthread_rwlock_unlock(&processStateLock) != 0)
        {
            goto e1;
        }
    }
    while (0) e0:
    {
 return ((void *)0);
    }
    while (0) e1:
    {
        pthread_rwlock_unlock(&processStateLock);
        return ((void *)0);
    }
    return state;
}

variable_types: struct GVoffsetstate { unsigned long thread; struct GVshmstreamtrp { struct GVtransport { struct GVchanel { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *exclusiveAccess; } *callChanel; struct GVchanel *returnChanel; int (*read)(struct GVchanel *, void *, unsigned long); void *(*readPtr)(struct GVchanel *); int (*take)(struct GVchanel *, unsigned long); int (*write)(struct GVchanel *, void *, unsigned long); void *(*writePtr)(struct GVchanel *); int (*give)(struct GVchanel *, unsigned long); void *(*peek)(struct GVchanel *, unsigned long); } base; struct GVshm { int id; unsigned long size; } *shm; unsigned long offset; unsigned long length; } *transport; } *

user_defined_types: struct GVoffsetstate { unsigned long thread; struct GVshmstreamtrp *transport; }

user_defined_types: struct GVshmstreamtrp { struct GVtransport base; struct GVshm *shm; unsigned long offset; unsigned long length; }

user_defined_types: struct GVtransport { struct GVchanel *callChanel; struct GVchanel *returnChanel; int (*read)(struct GVchanel *, void *, unsigned long); void *(*readPtr)(struct GVchanel *); int (*take)(struct GVchanel *, unsigned long); int (*write)(struct GVchanel *, void *, unsigned long); void *(*writePtr)(struct GVchanel *); int (*give)(struct GVchanel *, unsigned long); void *(*peek)(struct GVchanel *, unsigned long); }

user_defined_types: struct GVchanel { union pthread_mutex_t *exclusiveAccess; }


gvPutOffsetState

decompiled_code:
int __fastcall gvPutOffsetState(__int64 a1, __int64 a2)
{
int result; // eax

if ( !pthread_rwlock_wrlock(&processStateLock) && (unsigned int)gvPutProcessStateItem(a1, a2) != -1 )
{
result = pthread_rwlock_unlock(&processStateLock);
if ( !result )
return result;
pthread_rwlock_unlock(&processStateLock);
}
return -1;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 a2)
{
int result; // eax

if ( !pthread_rwlock_wrlock(&processStateLock) && (unsigned int)gvPutProcessStateItem(a1, a2) != -1 )
{
result = pthread_rwlock_unlock(&processStateLock);
if ( !result )
return result;
pthread_rwlock_unlock(&processStateLock);
}
return -1;
}

original_code:
int
gvPutOffsetState(size_t offset,
   GVoffsetstateptr state)
{

    {
        if (pthread_rwlock_wrlock(&processStateLock) != 0)
        {
            goto e0;
        }
 if (gvPutProcessStateItem(offset, state) == -1)
 {
     goto e0;
 }
        if (pthread_rwlock_unlock(&processStateLock) != 0)
        {
            goto e1;
        }
    }
    while (0) e0:
    {
 return -1;
    }
    while (0) e1:
    {
        pthread_rwlock_unlock(&processStateLock);
        return -1;
    }
    return 0;
}

canonical_original_code:
int gvPutOffsetState(unsigned long offset, struct GVoffsetstate *state)
{

    {
        if (pthread_rwlock_wrlock(&processStateLock) != 0)
        {
            goto e0;
        }
 if (gvPutProcessStateItem(offset, state) == -1)
 {
     goto e0;
 }
        if (pthread_rwlock_unlock(&processStateLock) != 0)
        {
            goto e1;
        }
    }
    while (0) e0:
    {
 return -1;
    }
    while (0) e1:
    {
        pthread_rwlock_unlock(&processStateLock);
        return -1;
    }
    return 0;
}


gvGetCurrentThreadTransport

decompiled_code:
__int64 gvGetCurrentThreadTransport()
{
if ( threadStateMapInitiated )
return gvGetThreadStateItem(0LL);
if ( (unsigned int)gvInitThreadStateMap() == -1 )
return -1LL;
threadStateMapInitiated = 1;
return gvGetThreadStateItem(0LL);
}

canonical_decompiled_code:
__int64 func3()
{
if ( threadStateMapInitiated )
return gvGetThreadStateItem(0LL);
if ( (unsigned int)gvInitThreadStateMap() == -1 )
return -1LL;
threadStateMapInitiated = 1;
return gvGetThreadStateItem(0LL);
}

original_code:
GVtransportptr
gvGetCurrentThreadTransport()
{
    GVtransportptr transport;
    do { if (!threadStateMapInitiated) { if (gvInitThreadStateMap() == -1) return -1; threadStateMapInitiated = 1; } } while (0);

    {
 if ((transport
      = (GVtransportptr) gvGetThreadStateItem(
   0x0)) == ((void *)0))
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return ((void *)0);
    }
    return transport;
}

canonical_original_code:
struct GVtransport *gvGetCurrentThreadTransport()
{
    struct GVtransport *transport;
    do { if (!threadStateMapInitiated) { if (gvInitThreadStateMap() == -1) return -1; threadStateMapInitiated = 1; } } while (0);

    {
 if ((transport
      = (struct GVtransport *) gvGetThreadStateItem(
   0x0)) == ((void *)0))
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return ((void *)0);
    }
    return transport;
}

variable_types: struct GVtransport { struct GVchanel { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *exclusiveAccess; } *callChanel; struct GVchanel *returnChanel; int (*read)(struct GVchanel *, void *, unsigned long); void *(*readPtr)(struct GVchanel *); int (*take)(struct GVchanel *, unsigned long); int (*write)(struct GVchanel *, void *, unsigned long); void *(*writePtr)(struct GVchanel *); int (*give)(struct GVchanel *, unsigned long); void *(*peek)(struct GVchanel *, unsigned long); } *


gvSetCurrentThreadTransport

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

if ( !threadStateMapInitiated )
{
result = gvInitThreadStateMap();
if ( (_DWORD)result == -1 )
return result;
threadStateMapInitiated = 1;
}
return (unsigned int)-((unsigned int)gvPutThreadStateItem(0LL, a1) == -1);
}

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

if ( !threadStateMapInitiated )
{
result = gvInitThreadStateMap();
if ( (_DWORD)result == -1 )
return result;
threadStateMapInitiated = 1;
}
return (unsigned int)-((unsigned int)gvPutThreadStateItem(0LL, a1) == -1);
}

original_code:
int
gvSetCurrentThreadTransport(GVtransportptr transport)
{
    do { if (!threadStateMapInitiated) { if (gvInitThreadStateMap() == -1) return -1; threadStateMapInitiated = 1; } } while (0);

    {
 if (gvPutThreadStateItem(0x0, transport) == -1)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}

canonical_original_code:
int gvSetCurrentThreadTransport(struct GVtransport *transport)
{
    do { if (!threadStateMapInitiated) { if (gvInitThreadStateMap() == -1) return -1; threadStateMapInitiated = 1; } } while (0);

    {
 if (gvPutThreadStateItem(0x0, transport) == -1)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return 0;
}


dispatchLoopThread

decompiled_code:
void *__fastcall dispatchLoopThread(void *a1)
{
__int64 v2; // rbx
__int64 v3; // r12
int v4; // eax

if ( pthread_setcancelstate(0, 0LL) )
return 0LL;
v2 = *(_QWORD *)a1;
v3 = *((_QWORD *)a1 + 1);
free(a1);
if ( (unsigned int)gvSetCurrentThreadTransport(v2) == -1 )
return 0LL;
while ( 1 )
{
v4 = gvStartReceiving(v2, 0LL);
if ( v4 == -1 )
break;
(*(void (**)(void))(v3 + 8LL * v4))();
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
__int64 v2; // rbx
__int64 v3; // r12
int v4; // eax

if ( pthread_setcancelstate(0, 0LL) )
return 0LL;
v2 = *(_QWORD *)a1;
v3 = *((_QWORD *)a1 + 1);
free(a1);
if ( (unsigned int)gvSetCurrentThreadTransport(v2) == -1 )
return 0LL;
while ( 1 )
{
v4 = gvStartReceiving(v2, 0LL);
if ( v4 == -1 )
break;
(*(void (**)(void))(v3 + 8LL * v4))();
}
return 0LL;
}

original_code:
static void
*dispatchLoopThread(void *data)
{
    GVcmdid cmdId;
    GVdispatchfunc *jumpTable;
    struct ThreadArg *threadArg;
    GVtransportptr transport;

    {
 if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, ((void *)0)) != 0)
 {
     goto e0;
 }
 threadArg = (struct ThreadArg *)data;
 transport = threadArg->transport;
 jumpTable = threadArg->jumpTable;
 free(threadArg);
 if (gvSetCurrentThreadTransport(transport) == -1)
 {
     goto e0;
 }
 while (1)
 {
     if ((cmdId = gvStartReceiving(transport, ((void *)0))) == -1)
     {
  goto e0;
     }
     jumpTable[cmdId]();
 }
    }
    while (0) e0:
    {
 return ((void *)0);
    }
    return ((void *)0);
}

canonical_original_code:
static void *dispatchLoopThread(void *data)
{
    int cmdId;
    void (**jumpTable)();
    struct ThreadArg *threadArg;
    struct GVtransport *transport;

    {
 if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, ((void *)0)) != 0)
 {
     goto e0;
 }
 threadArg = (struct ThreadArg *)data;
 transport = threadArg->transport;
 jumpTable = threadArg->jumpTable;
 free(threadArg);
 if (gvSetCurrentThreadTransport(transport) == -1)
 {
     goto e0;
 }
 while (1)
 {
     if ((cmdId = gvStartReceiving(transport, ((void *)0))) == -1)
     {
  goto e0;
     }
     jumpTable[cmdId]();
 }
    }
    while (0) e0:
    {
 return ((void *)0);
    }
    return ((void *)0);
}

variable_types:
data
void *

variable_types: cmdId int

variable_types:
jumpTable
void (**)()

variable_types: struct ThreadArg { struct GVtransport { struct GVchanel { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *exclusiveAccess; } *callChanel; struct GVchanel *returnChanel; int (*read)(struct GVchanel *, void *, unsigned long); void *(*readPtr)(struct GVchanel *); int (*take)(struct GVchanel *, unsigned long); int (*write)(struct GVchanel *, void *, unsigned long); void *(*writePtr)(struct GVchanel *); int (*give)(struct GVchanel *, unsigned long); void *(*peek)(struct GVchanel *, unsigned long); } *transport; void (**jumpTable)(); } *

return_type: void *

user_defined_types: struct ThreadArg { struct GVtransport *transport; void (**jumpTable)(); }


gvDispatchLoop

decompiled_code:
pthread_t __fastcall gvDispatchLoop(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
pthread_t result; // rax
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = malloc(0x10uLL);
if ( !v2 || (*v2 = a1, v2[1] = a2, pthread_create(newthread, 0LL, dispatchLoopThread, v2)) )
result = -1LL;
else
result = newthread[0];
return result;
}

canonical_decompiled_code:
pthread_t __fastcall func1(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
pthread_t result; // rax
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = malloc(0x10uLL);
if ( !v2 || (*v2 = a1, v2[1] = a2, pthread_create(newthread, 0LL, dispatchLoopThread, v2)) )
result = -1LL;
else
result = newthread[0];
return result;
}

original_code:
unsigned long
gvDispatchLoop(GVtransportptr transport,
        GVdispatchfunc jumpTable[])
{
    pthread_t thread;
    struct ThreadArg *threadArg;

    {
 if ((threadArg = malloc(sizeof(struct ThreadArg))) == ((void *)0))
 {
     goto e0;
 }
 threadArg->transport = transport;
 threadArg->jumpTable = jumpTable;
 if (pthread_create(&thread, ((void *)0), dispatchLoopThread, threadArg) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return thread;
}

canonical_original_code:
unsigned long gvDispatchLoop(struct GVtransport *transport, void (*jumpTable[])())
{
    unsigned long thread;
    struct ThreadArg *threadArg;

    {
 if ((threadArg = malloc(sizeof(struct ThreadArg))) == ((void *)0))
 {
     goto e0;
 }
 threadArg->transport = transport;
 threadArg->jumpTable = jumpTable;
 if (pthread_create(&thread, ((void *)0), dispatchLoopThread, threadArg) != 0)
 {
     goto e0;
 }
    }
    while (0) e0:
    {
 return -1;
    }
    return thread;
}

variable_types:
jumpTable
void (*[])()

variable_types:
thread
unsigned long


gvSleep

decompiled_code:
__int64 __fastcall gvSleep(int a1, int a2)
{
struct timespec v3; // [rsp+0h] [rbp-28h] BYREF
struct timespec remaining; // [rsp+10h] [rbp-18h] BYREF

v3.tv_sec = a1;
v3.tv_nsec = a2;
nanosleep(&v3, &remaining);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
struct timespec v3; // [rsp+0h] [rbp-28h] BYREF
struct timespec remaining; // [rsp+10h] [rbp-18h] BYREF

v3.tv_sec = a1;
v3.tv_nsec = a2;
nanosleep(&v3, &remaining);
return 0LL;
}

original_code:
int
gvSleep(int sec, int nsec)
{
    struct timespec sleepTime;
    struct timespec returnTime;
    sleepTime.tv_sec = sec;
    sleepTime.tv_nsec = nsec;
    nanosleep(&sleepTime, &returnTime);
    return 0;
}

variable_types: sec int

variable_types: nsec int

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


repo: schwannden/libsnp

decompiled_code:
void __fastcall err_doit(int a1, int a2, const char *a3, void *a4)
{
int *v6; // rbx
size_t v7; // rbx
char *v8; // rax
char *v9; // rax
int errnum; // [rsp+Ch] [rbp-14Ch]
char s[328]; // [rsp+10h] [rbp-148h] BYREF

v6 = _errno_location();
errnum = *v6;
vsprintf(s, a3, a4);
if ( daemon_proc )
{
if ( a1 )
{
v7 = strlen(s);
v8 = strerror(errnum);
snprintf(&s[v7], 256 - (int)v7, ": %s\n", v8);
}
syslog(a2, s);
}
else
{
fflush(stdout);
if ( a2 == 3 )
{
fprintf(stderr, "[INFO] (%s:%d) %s\n", "error_functions.c", 153LL, s);
}
else
{
v9 = strerror(*v6);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) %s\n", "error_functions.c", 155LL, v9, s);
}
fflush(stderr);
}
}

canonical_decompiled_code:
void __fastcall func0(int a1, int a2, const char *a3, void *a4)
{
int *v6; // rbx
size_t v7; // rbx
char *v8; // rax
char *v9; // rax
int errnum; // [rsp+Ch] [rbp-14Ch]
char s[328]; // [rsp+10h] [rbp-148h] BYREF

v6 = _errno_location();
errnum = *v6;
vsprintf(s, a3, a4);
if ( daemon_proc )
{
if ( a1 )
{
v7 = strlen(s);
v8 = strerror(errnum);
snprintf(&s[v7], 256 - (int)v7, ": %s\n", v8);
}
syslog(a2, s);
}
else
{
fflush(stdout);
if ( a2 == 3 )
{
fprintf(stderr, "[INFO] (%s:%d) %s\n", "error_functions.c", 153LL, s);
}
else
{
v9 = strerror(*v6);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) %s\n", "error_functions.c", 155LL, v9, s);
}
fflush(stderr);
}
}

original_code:
static void
err_doit(int errnoflag, int level, const char *fmt, va_list ap)
{
  int errno_save, n;
  char buf[256 + 1];
  errno_save = (*__errno_location ());
  vsprintf(buf, fmt, ap);
  if (daemon_proc)
    {
      n = strlen(buf);
      if (errnoflag)
        snprintf(buf + n, 256 - n, ": %s\n", strerror(errno_save));
      syslog(level, buf);
    }
  else
    {
      fflush(stdout);
      if (level == 3)
        fprintf(stderr, "[INFO]  (%s:%d) " "%s" "\n", "error_functions.c", 153, buf);
      else
        fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "%s" "\n", "error_functions.c", 155, strerror((*__errno_location ())), buf);
      fflush(stderr);
    }
  return;
}

canonical_original_code:
static void err_doit(int errnoflag, int level, char *fmt, __builtin_va_list ap)
{
  int errno_save; int n;
  char buf[-1];
  errno_save = (*__errno_location ());
  vsprintf(buf, fmt, ap);
  if (daemon_proc)
    {
      n = strlen(buf);
      if (errnoflag)
        snprintf(buf + n, 256 - n, ": %s\n", strerror(errno_save));
      syslog(level, buf);
    }
  else
    {
      fflush(stdout);
      if (level == 3)
        fprintf(stderr, "[INFO]  (%s:%d) " "%s" "\n", "error_functions.c", 153, buf);
      else
        fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "%s" "\n", "error_functions.c", 155, strerror((*__errno_location ())), buf);
      fflush(stderr);
    }
  return;
}

variable_types: errnoflag int

variable_types: level int

variable_types:
fmt
char *

variable_types: n int

variable_types:
buf
char [-1]

return_type: void


decompiled_code:
void nonfatal_sys_ret(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(1, 3, a1, va);
}

canonical_decompiled_code:
void func1(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func0(1, 3, a1, va);
}

original_code:
void
nonfatal_sys_ret(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 3, fmt, ap);
  __builtin_va_end(ap);
  return;
}

canonical_original_code:
void nonfatal_sys_ret(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 3, fmt, ap);
  __builtin_va_end(ap);
  return;
}


decompiled_code:
void err_ret(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(1, 3, a1, va);
}

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

va_start(va, a1);
func0(1, 3, a1, va);
}

original_code:
void
err_ret(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 3, fmt, ap);
  __builtin_va_end(ap);
  return;
}

canonical_original_code:
void err_ret(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 3, fmt, ap);
  __builtin_va_end(ap);
  return;
}


decompiled_code:
void __noreturn fatal_sys_exit(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(1, 1, a1, va);
exit(1);
}

canonical_decompiled_code:
void __noreturn func3(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func0(1, 1, a1, va);
exit(1);
}

original_code:
void
fatal_sys_exit(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 1, fmt, ap);
  __builtin_va_end(ap);
  exit(1);
}

canonical_original_code:
void fatal_sys_exit(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 1, fmt, ap);
  __builtin_va_end(ap);
  exit(1);
}


decompiled_code:
void __noreturn err_sys(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(1, 1, a1, va);
exit(1);
}

canonical_decompiled_code:
void __noreturn func4(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func0(1, 1, a1, va);
exit(1);
}

original_code:
void
err_sys(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 1, fmt, ap);
  __builtin_va_end(ap);
  exit(1);
}

canonical_original_code:
void err_sys(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 1, fmt, ap);
  __builtin_va_end(ap);
  exit(1);
}


decompiled_code:
void __noreturn fatal_sys_dump(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(1, 1, a1, va);
abort();
}

canonical_decompiled_code:
void __noreturn func5(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func0(1, 1, a1, va);
abort();
}

original_code:
void
fatal_sys_dump(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 1, fmt, ap);
  __builtin_va_end(ap);
  abort();
  exit(1);
}

canonical_original_code:
void fatal_sys_dump(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 1, fmt, ap);
  __builtin_va_end(ap);
  abort();
  exit(1);
}


decompiled_code:
void __noreturn err_dump(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(1, 1, a1, va);
abort();
}

canonical_decompiled_code:
void __noreturn func6(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func0(1, 1, a1, va);
abort();
}

original_code:
void
err_dump(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 1, fmt, ap);
  __builtin_va_end(ap);
  abort();
  exit(1);
}

canonical_original_code:
void err_dump(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(1, 1, fmt, ap);
  __builtin_va_end(ap);
  abort();
  exit(1);
}


decompiled_code:
void nonfatal_user_ret(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(0, 3, a1, va);
}

canonical_decompiled_code:
void func7(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func0(0, 3, a1, va);
}

original_code:
void
nonfatal_user_ret(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(0, 3, fmt, ap);
  __builtin_va_end(ap);
  return;
}

canonical_original_code:
void nonfatal_user_ret(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(0, 3, fmt, ap);
  __builtin_va_end(ap);
  return;
}


decompiled_code:
void err_msg(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(0, 3, a1, va);
}

canonical_decompiled_code:
void func8(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func0(0, 3, a1, va);
}

original_code:
void
err_msg(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(0, 3, fmt, ap);
  __builtin_va_end(ap);
  return;
}

canonical_original_code:
void err_msg(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(0, 3, fmt, ap);
  __builtin_va_end(ap);
  return;
}


decompiled_code:
void __noreturn fatal_user_exit(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(0, 1, a1, va);
exit(1);
}

canonical_decompiled_code:
void __noreturn func9(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func0(0, 1, a1, va);
exit(1);
}

original_code:
void
fatal_user_exit(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(0, 1, fmt, ap);
  __builtin_va_end(ap);
  exit(1);
}

canonical_original_code:
void fatal_user_exit(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(0, 1, fmt, ap);
  __builtin_va_end(ap);
  exit(1);
}


decompiled_code:
void __noreturn err_quit(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
err_doit(0, 1, a1, va);
exit(1);
}

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

va_start(va, a1);
func0(0, 1, a1, va);
exit(1);
}

original_code:
void
err_quit(const char *fmt, ...)
{
  va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(0, 1, fmt, ap);
  __builtin_va_end(ap);
  exit(1);
}

canonical_original_code:
void err_quit(char *fmt, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,fmt);
  err_doit(0, 1, fmt, ap);
  __builtin_va_end(ap);
  exit(1);
}


decompiled_code:
char *__fastcall Inet_ntop(int af, const void *a2, char *a3, socklen_t a4)
{
if ( a3 )
{
if ( inet_ntop(af, a2, a3, a4) )
return a3;
}
else
{
fatal_sys_exit("3rd argument can not ne NULL");
if ( inet_ntop(af, a2, 0LL, a4) )
return a3;
}
fatal_sys_exit("inet_ntop error");
return a3;
}

canonical_decompiled_code:
char *__fastcall func0(int af, const void *a2, char *a3, socklen_t a4)
{
if ( a3 )
{
if ( inet_ntop(af, a2, a3, a4) )
return a3;
}
else
{
fatal_sys_exit("3rd argument can not ne NULL");
if ( inet_ntop(af, a2, 0LL, a4) )
return a3;
}
fatal_sys_exit("inet_ntop error");
return a3;
}

original_code:
const char*
Inet_ntop( int family, const void* sa, char* str, socklen_t socklen )
{
  if( str == ((void *)0) )
  fatal_sys_exit( "3rd argument can not ne NULL" );
  if( (inet_ntop(family, sa, str, socklen) == ((void *)0)) )
  fatal_sys_exit( "inet_ntop error" );
  return str;
}

canonical_original_code:
char *Inet_ntop(int family, void *sa, char *str, unsigned int socklen)
{
  if( str == ((void *)0) )
  fatal_sys_exit( "3rd argument can not ne NULL" );
  if( (inet_ntop(family, sa, str, socklen) == ((void *)0)) )
  fatal_sys_exit( "inet_ntop error" );
  return str;
}

variable_types: family int

variable_types:
sa
void *

variable_types:
str
char *

variable_types:
socklen
unsigned int

return_type: char *


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

result = inet_pton(a1, a2, a3);
if ( result <= 0 )
result = fatal_sys_exit("inet_pton error for %s", a2);
return result;
}

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

result = inet_pton(a1, a2, a3);
if ( result <= 0 )
result = fatal_sys_exit("inet_pton error for %s", a2);
return result;
}

original_code:
void
Inet_pton(int family, const char *strptr, void *addrptr)
{
  if ( inet_pton(family, strptr, addrptr) <= 0)
    fatal_sys_exit("inet_pton error for %s", strptr);
}

canonical_original_code:
void Inet_pton(int family, char *strptr, void *addrptr)
{
  if ( inet_pton(family, strptr, addrptr) <= 0)
    fatal_sys_exit("inet_pton error for %s", strptr);
}

variable_types:
strptr
char *

variable_types:
addrptr
void *


Accept

decompiled_code:
__int64 __fastcall Accept(int fd, struct sockaddr *addr, socklen_t *addr_len)
{
int v4; // er12

do
{
v4 = accept(fd, addr, addr_len);
if ( v4 >= 0 )
return (unsigned int)v4;
}
while ( (*_errno_location() & 0xFFFFFFDF) == 71 );
fatal_sys_exit("accept error");
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(int fd, struct sockaddr *addr, socklen_t *addr_len)
{
int v4; // er12

do
{
v4 = accept(fd, addr, addr_len);
if ( v4 >= 0 )
return (unsigned int)v4;
}
while ( (*_errno_location() & 0xFFFFFFDF) == 71 );
fatal_sys_exit("accept error");
return (unsigned int)v4;
}

original_code:
int
Accept(int fd, struct sockaddr *sa, socklen_t *salenptr)
{
  int n;
again:
  if ( (n = accept(fd, sa, salenptr)) < 0) {
    if ((*__errno_location ()) == 71 || (*__errno_location ()) == 103)
      goto again;
    else
      fatal_sys_exit("accept error");
  }
  return(n);
}

canonical_original_code:
int Accept(int fd, struct sockaddr *sa, unsigned int *salenptr)
{
  int n;
again:
  if ( (n = accept(fd, sa, salenptr)) < 0) {
    if ((*__errno_location ()) == 71 || (*__errno_location ()) == 103)
      goto again;
    else
      fatal_sys_exit("accept error");
  }
  return(n);
}

variable_types: fd int

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

variable_types:
salenptr
unsigned int *


Bind

decompiled_code:
int __fastcall Bind(int a1, const struct sockaddr *a2, socklen_t a3)
{
int result; // eax

result = bind(a1, a2, a3);
if ( result < 0 )
result = fatal_sys_exit("bind error");
return result;
}

canonical_decompiled_code:
int __fastcall func3(int a1, const struct sockaddr *a2, socklen_t a3)
{
int result; // eax

result = bind(a1, a2, a3);
if ( result < 0 )
result = fatal_sys_exit("bind error");
return result;
}

original_code:
void
Bind(int fd, const struct sockaddr *sa, socklen_t salen)
{
  if (bind(fd, sa, salen) < 0)
    fatal_sys_exit("bind error");
}

canonical_original_code:
void Bind(int fd, struct sockaddr *sa, unsigned int salen)
{
  if (bind(fd, sa, salen) < 0)
    fatal_sys_exit("bind error");
}

variable_types:
salen
unsigned int

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


Connect

decompiled_code:
int __fastcall Connect(int a1, const struct sockaddr *a2, socklen_t a3)
{
int result; // eax

result = connect(a1, a2, a3);
if ( result < 0 )
result = fatal_sys_exit("connect error");
return result;
}

canonical_decompiled_code:
int __fastcall func4(int a1, const struct sockaddr *a2, socklen_t a3)
{
int result; // eax

result = connect(a1, a2, a3);
if ( result < 0 )
result = fatal_sys_exit("connect error");
return result;
}

original_code:
void
Connect(int fd, const struct sockaddr *sa, socklen_t salen)
{
  if (connect(fd, sa, salen) < 0)
    fatal_sys_exit("connect error");
}

canonical_original_code:
void Connect(int fd, struct sockaddr *sa, unsigned int salen)
{
  if (connect(fd, sa, salen) < 0)
    fatal_sys_exit("connect error");
}


Getpeername

decompiled_code:
int __fastcall Getpeername(int a1, struct sockaddr *a2, socklen_t *a3)
{
int result; // eax

result = getpeername(a1, a2, a3);
if ( result < 0 )
result = fatal_sys_exit("getpeername error");
return result;
}

canonical_decompiled_code:
int __fastcall func5(int a1, struct sockaddr *a2, socklen_t *a3)
{
int result; // eax

result = getpeername(a1, a2, a3);
if ( result < 0 )
result = fatal_sys_exit("getpeername error");
return result;
}

original_code:
void
Getpeername(int fd, struct sockaddr *sa, socklen_t *salenptr)
{
  if (getpeername(fd, sa, salenptr) < 0)
    fatal_sys_exit("getpeername error");
}

canonical_original_code:
void Getpeername(int fd, struct sockaddr *sa, unsigned int *salenptr)
{
  if (getpeername(fd, sa, salenptr) < 0)
    fatal_sys_exit("getpeername error");
}


Getsockname

decompiled_code:
int __fastcall Getsockname(int a1, struct sockaddr *a2, socklen_t *a3)
{
int result; // eax

result = getsockname(a1, a2, a3);
if ( result < 0 )
result = fatal_sys_exit("getsockname error");
return result;
}

canonical_decompiled_code:
int __fastcall func6(int a1, struct sockaddr *a2, socklen_t *a3)
{
int result; // eax

result = getsockname(a1, a2, a3);
if ( result < 0 )
result = fatal_sys_exit("getsockname error");
return result;
}

original_code:
void
Getsockname(int fd, struct sockaddr *sa, socklen_t *salenptr)
{
  if (getsockname(fd, sa, salenptr) < 0)
    fatal_sys_exit("getsockname error");
}

canonical_original_code:
void Getsockname(int fd, struct sockaddr *sa, unsigned int *salenptr)
{
  if (getsockname(fd, sa, salenptr) < 0)
    fatal_sys_exit("getsockname error");
}


Getsockopt

decompiled_code:
int __fastcall Getsockopt(int a1, int a2, int a3, void *a4, socklen_t *a5)
{
int result; // eax

result = getsockopt(a1, a2, a3, a4, a5);
if ( result < 0 )
result = fatal_sys_exit("getsockopt error");
return result;
}

canonical_decompiled_code:
int __fastcall func7(int a1, int a2, int a3, void *a4, socklen_t *a5)
{
int result; // eax

result = getsockopt(a1, a2, a3, a4, a5);
if ( result < 0 )
result = fatal_sys_exit("getsockopt error");
return result;
}

original_code:
void
Getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlenptr)
{
  if (getsockopt(fd, level, optname, optval, optlenptr) < 0)
    fatal_sys_exit("getsockopt error");
}

canonical_original_code:
void Getsockopt(int fd, int level, int optname, void *optval, unsigned int *optlenptr)
{
  if (getsockopt(fd, level, optname, optval, optlenptr) < 0)
    fatal_sys_exit("getsockopt error");
}

variable_types: optname int

variable_types:
optval
void *

variable_types:
optlenptr
unsigned int *


Setsockopt

decompiled_code:
int __fastcall Setsockopt(int a1, int a2, int a3, const void *a4, socklen_t a5)
{
int result; // eax

result = setsockopt(a1, a2, a3, a4, a5);
if ( result < 0 )
result = err_sys("setsockopt error");
return result;
}

canonical_decompiled_code:
int __fastcall func8(int a1, int a2, int a3, const void *a4, socklen_t a5)
{
int result; // eax

result = setsockopt(a1, a2, a3, a4, a5);
if ( result < 0 )
result = err_sys("setsockopt error");
return result;
}

original_code:
void
Setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
{
 if (setsockopt(fd, level, optname, optval, optlen) < 0)
  err_sys("setsockopt error");
}

canonical_original_code:
void Setsockopt(int fd, int level, int optname, void *optval, unsigned int optlen)
{
 if (setsockopt(fd, level, optname, optval, optlen) < 0)
  err_sys("setsockopt error");
}

variable_types: level int

variable_types:
optlen
unsigned int


Shutdown

decompiled_code:
int __fastcall Shutdown(int a1, int a2)
{
int result; // eax

result = shutdown(a1, a2);
if ( result < 0 )
result = fatal_sys_exit("shutdown error");
return result;
}

canonical_decompiled_code:
int __fastcall func9(int a1, int a2)
{
int result; // eax

result = shutdown(a1, a2);
if ( result < 0 )
result = fatal_sys_exit("shutdown error");
return result;
}

original_code:
void
Shutdown(int fd, int how)
{
  if (shutdown(fd, how) < 0)
    fatal_sys_exit("shutdown error");
}

variable_types: how int


Sockatmark

decompiled_code:
__int64 __fastcall Sockatmark(int a1)
{
int v1; // er12

v1 = sockatmark(a1);
if ( v1 < 0 )
fatal_sys_exit("sockatmark error");
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1)
{
int v1; // er12

v1 = sockatmark(a1);
if ( v1 < 0 )
fatal_sys_exit("sockatmark error");
return (unsigned int)v1;
}

original_code:
int
Sockatmark(int fd)
{
  int n;
  if ( (n = sockatmark(fd)) < 0)
    fatal_sys_exit("sockatmark error");
  return(n);
}

variable_types: n int


Socket

decompiled_code:
__int64 __fastcall Socket(int a1, int a2, int a3)
{
int v3; // er12

v3 = socket(a1, a2, a3);
if ( v3 < 0 )
fatal_sys_exit("socket error");
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int a2, int a3)
{
int v3; // er12

v3 = socket(a1, a2, a3);
if ( v3 < 0 )
fatal_sys_exit("socket error");
return (unsigned int)v3;
}

original_code:
int
Socket(int family, int type, int protocol)
{
  int n;
  if ( (n = socket(family, type, protocol)) < 0)
    fatal_sys_exit("socket error");
  return(n);
}

variable_types: family int

variable_types: type int

variable_types: protocol int


Socketpair

decompiled_code:
int __fastcall Socketpair(int a1, int a2, int a3, int *a4)
{
int result; // eax

result = socketpair(a1, a2, a3, a4);
if ( result < 0 )
result = fatal_sys_exit("socketpair error");
return result;
}

canonical_decompiled_code:
int __fastcall func12(int a1, int a2, int a3, int *a4)
{
int result; // eax

result = socketpair(a1, a2, a3, a4);
if ( result < 0 )
result = fatal_sys_exit("socketpair error");
return result;
}

original_code:
void
Socketpair(int family, int type, int protocol, int *fd)
{
  int n;
  if ( (n = socketpair(family, type, protocol, fd)) < 0)
    fatal_sys_exit("socketpair error");
}

variable_types:
fd
int *


Listen

decompiled_code:
int __fastcall Listen(int fd, int n)
{
char *v3; // rax
int result; // eax

v3 = getenv("LISTENQ");
if ( v3 )
n = atoi(v3);
result = listen(fd, n);
if ( result < 0 )
result = fatal_sys_exit("listen error");
return result;
}

canonical_decompiled_code:
int __fastcall func13(int fd, int n)
{
char *v3; // rax
int result; // eax

v3 = getenv("LISTENQ");
if ( v3 )
n = atoi(v3);
result = listen(fd, n);
if ( result < 0 )
result = fatal_sys_exit("listen error");
return result;
}

original_code:
void
Listen(int fd, int backlog)
{
  char *ptr;
  if ( (ptr = getenv("LISTENQ")) != ((void *)0))
    backlog = atoi(ptr);
  if (listen(fd, backlog) < 0)
    fatal_sys_exit("listen error");
}

variable_types: backlog int

variable_types:
ptr
char *


Readn

decompiled_code:
signed __int64 __fastcall Readn(int a1, void *a2, size_t a3)
{
signed __int64 result; // rax
signed __int64 v4; // r12

result = readn(a1, a2, a3);
v4 = result;
if ( result < 0 )
{
fatal_sys_exit("readn error");
result = v4;
}
return result;
}

canonical_decompiled_code:
signed __int64 __fastcall func1(int a1, void *a2, size_t a3)
{
signed __int64 result; // rax
signed __int64 v4; // r12

result = func0(a1, a2, a3);
v4 = result;
if ( result < 0 )
{
fatal_sys_exit("readn error");
result = v4;
}
return result;
}

original_code:
ssize_t
Readn( int fd, void* buf, size_t n )
{
  ssize_t number_read;
  if( (number_read = readn(fd, buf, n)) < 0 )
  fatal_sys_exit( "readn error" );
  return number_read;
}

canonical_original_code:
long Readn(int fd, void *buf, unsigned long n)
{
  long number_read;
  if( (number_read = readn(fd, buf, n)) < 0 )
  fatal_sys_exit( "readn error" );
  return number_read;
}

variable_types: fd int

variable_types:
buf
void *

variable_types:
n
unsigned long

return_type: long


writen

decompiled_code:
size_t __fastcall writen(int fd, void *buf, size_t n)
{
size_t v3; // r13
size_t v5; // rbx
ssize_t v6; // rax

v3 = n;
v5 = n;
if ( !n )
return v3;
do
{
while ( 1 )
{
v6 = write(fd, buf, v5);
if ( v6 <= 0 )
break;
buf = (char *)buf + v6;
v5 -= v6;
if ( !v5 )
return v3;
}
}
while ( v6 && *_errno_location() == 4 );
return -1LL;
}

canonical_decompiled_code:
size_t __fastcall func2(int fd, void *buf, size_t n)
{
size_t v3; // r13
size_t v5; // rbx
ssize_t v6; // rax

v3 = n;
v5 = n;
if ( !n )
return v3;
do
{
while ( 1 )
{
v6 = write(fd, buf, v5);
if ( v6 <= 0 )
break;
buf = (char *)buf + v6;
v5 -= v6;
if ( !v5 )
return v3;
}
}
while ( v6 && *_errno_location() == 4 );
return -1LL;
}

original_code:
ssize_t
writen( int fd, const void* vptr, size_t n )
{
  size_t bytes_left = n;
  ssize_t bytes_written;
  const char* ptr = vptr;
  while( bytes_left > 0 ) {
  if( (bytes_written = write(fd, ptr, bytes_left)) <= 0 )
    if( bytes_written < 0 && (*__errno_location ()) == 4 )
      bytes_written = 0;
    else
    return -1;
  bytes_left -= bytes_written;
  ptr += bytes_written;
  }
  return n;
}

canonical_original_code:
long writen(int fd, void *vptr, unsigned long n)
{
  unsigned long bytes_left = n;
  long bytes_written;
  char *ptr = vptr;
  while( bytes_left > 0 ) {
  if( (bytes_written = write(fd, ptr, bytes_left)) <= 0 )
    if( bytes_written < 0 && (*__errno_location ()) == 4 )
      bytes_written = 0;
    else
    return -1;
  bytes_left -= bytes_written;
  ptr += bytes_written;
  }
  return n;
}

variable_types:
vptr
void *


Writen

decompiled_code:
size_t __fastcall Writen(int a1, void *a2, size_t a3)
{
size_t result; // rax

result = writen(a1, a2, a3);
if ( result != a3 )
result = fatal_sys_exit("writen error");
return result;
}

canonical_decompiled_code:
size_t __fastcall func3(int a1, void *a2, size_t a3)
{
size_t result; // rax

result = func2(a1, a2, a3);
if ( result != a3 )
result = fatal_sys_exit("writen error");
return result;
}

original_code:
void
Writen( int fd, const void *ptr, size_t nbytes )
{
  if (writen(fd, ptr, nbytes) != nbytes)
    fatal_sys_exit("writen error");
}

canonical_original_code:
void Writen(int fd, void *ptr, unsigned long nbytes)
{
  if (writen(fd, ptr, nbytes) != nbytes)
    fatal_sys_exit("writen error");
}

variable_types:
ptr
void *

variable_types:
nbytes
unsigned long


decompiled_code:
ssize_t __fastcall my_read(int fd, _BYTE *a2)
{
ssize_t result; // rax
__int64 v3; // rdx
__int64 v4; // rcx
char v5; // dl

result = readline_buff_size;
if ( readline_buff_size > 0 )
{
v3 = readline_buff_front;
v4 = readline_buff_front + 1;
LABEL_3:
readline_buff_front = v4;
v5 = readline_buff[v3];
readline_buff_size = result - 1;
result = 1LL;
*a2 = v5;
return result;
}
while ( 1 )
{
result = read(fd, readline_buff, 0x400uLL);
readline_buff_size = result;
if ( result >= 0 )
break;
*_errno_location() = 4;
}
if ( result )
{
v4 = 1LL;
v3 = 0LL;
goto LABEL_3;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func4(int fd, _BYTE *a2)
{
ssize_t result; // rax
__int64 v3; // rdx
__int64 v4; // rcx
char v5; // dl

result = readline_buff_size;
if ( readline_buff_size > 0 )
{
v3 = readline_buff_front;
v4 = readline_buff_front + 1;
LABEL_3:
readline_buff_front = v4;
v5 = readline_buff[v3];
readline_buff_size = result - 1;
result = 1LL;
*a2 = v5;
return result;
}
while ( 1 )
{
result = read(fd, readline_buff, 0x400uLL);
readline_buff_size = result;
if ( result >= 0 )
break;
*_errno_location() = 4;
}
if ( result )
{
v4 = 1LL;
v3 = 0LL;
goto LABEL_3;
}
return result;
}

original_code:
ssize_t
my_read( int fd, char* ptr )
{
  if( readline_buff_size <= 0 ){
again:
  if( (readline_buff_size = read( fd, readline_buff, sizeof(readline_buff))) < 0 )
    if( (*__errno_location ()) = 4 )
    goto again;
    else
    return -1;
  else if( readline_buff_size == 0 )
    return 0;
  else
    readline_buff_front = 0;
  }
  *ptr = readline_buff[ readline_buff_front++ ];
  readline_buff_size--;
  return 1;
}

canonical_original_code:
long my_read(int fd, char *ptr)
{
  if( readline_buff_size <= 0 ){
again:
  if( (readline_buff_size = read( fd, readline_buff, sizeof(readline_buff))) < 0 )
    if( (*__errno_location ()) = 4 )
    goto again;
    else
    return -1;
  else if( readline_buff_size == 0 )
    return 0;
  else
    readline_buff_front = 0;
  }
  *ptr = readline_buff[ readline_buff_front++ ];
  readline_buff_size--;
  return 1;
}


readline

original_code:
ssize_t
readline( int fd, void* void_ptr, size_t maxline )
{
  ssize_t bytes_read, read_status;
  char* ptr = void_ptr;
  for( bytes_read = 1 ; bytes_read < maxline ; bytes_read++ )
    if( (read_status = my_read( fd, ptr )) == 1 ) {
      if( *ptr++ == '\n' ){
      *ptr = '\0';
      return bytes_read;
      }
    } else if( read_status == 0 ) {
      *ptr = '\0';
      return bytes_read-1;
    } else
      return -1;
}

canonical_original_code:
long readline(int fd, void *void_ptr, unsigned long maxline)
{
  long bytes_read; long read_status;
  char *ptr = void_ptr;
  for( bytes_read = 1 ; bytes_read < maxline ; bytes_read++ )
    if( (read_status = my_read( fd, ptr )) == 1 ) {
      if( *ptr++ == '\n' ){
      *ptr = '\0';
      return bytes_read;
      }
    } else if( read_status == 0 ) {
      *ptr = '\0';
      return bytes_read-1;
    } else
      return -1;
}

variable_types:
maxline
unsigned long


readlinebuf

decompiled_code:
__int64 __fastcall readlinebuf(_QWORD *a1)
{
__int64 result; // rax

result = readline_buff_size;
if ( readline_buff_size > 0 )
*a1 = &readline_buff[readline_buff_front];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1)
{
__int64 result; // rax

result = readline_buff_size;
if ( readline_buff_size > 0 )
*a1 = &readline_buff[readline_buff_front];
return result;
}

original_code:
ssize_t
readlinebuf( void** ptrptr )
{
  if( readline_buff_size > 0 )
  *ptrptr = readline_buff+readline_buff_front;
  return readline_buff_size;
}

canonical_original_code:
long readlinebuf(void **ptrptr)
{
  if( readline_buff_size > 0 )
  *ptrptr = readline_buff+readline_buff_front;
  return readline_buff_size;
}

variable_types:
ptrptr
void **


Readline

decompiled_code:
__int64 __fastcall Readline(int a1, _BYTE *a2, unsigned __int64 a3)
{
__int64 result; // rax
__int64 v4; // r12

result = readline(a1, a2, a3);
v4 = result;
if ( result < 0 )
{
fatal_sys_exit("readline error");
result = v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, _BYTE *a2, unsigned __int64 a3)
{
__int64 result; // rax
__int64 v4; // r12

result = func5(a1, a2, a3);
v4 = result;
if ( result < 0 )
{
fatal_sys_exit("readline error");
result = v4;
}
return result;
}

original_code:
ssize_t
Readline( int fd, void* target_ptr, size_t maxline )
{
  ssize_t n;
  if( (n = readline( fd, target_ptr, maxline )) < 0 )
  fatal_sys_exit( "readline error" );
  return n;
}

canonical_original_code:
long Readline(int fd, void *target_ptr, unsigned long maxline)
{
  long n;
  if( (n = readline( fd, target_ptr, maxline )) < 0 )
  fatal_sys_exit( "readline error" );
  return n;
}

variable_types: n long


decompiled_code:
struct addrinfo *__fastcall host_serv(const char *a1, const char *a2, int a3, int a4)
{
bool v4; // zf
struct addrinfo *result; // rax
struct addrinfo *pai; // [rsp+8h] [rbp-40h] BYREF
struct addrinfo req; // [rsp+10h] [rbp-38h] BYREF

*(_OWORD *)&req.ai_socktype = 0LL;
req.ai_socktype = a4;
req.ai_next = 0LL;
req.ai_flags = 2;
req.ai_family = a3;
*(_OWORD *)&req.ai_addr = 0LL;
v4 = getaddrinfo(a1, a2, &req, &pai) == 0;
result = 0LL;
if ( v4 )
result = pai;
return result;
}

canonical_decompiled_code:
struct addrinfo *__fastcall func8(const char *a1, const char *a2, int a3, int a4)
{
bool v4; // zf
struct addrinfo *result; // rax
struct addrinfo *pai; // [rsp+8h] [rbp-40h] BYREF
struct addrinfo req; // [rsp+10h] [rbp-38h] BYREF

*(_OWORD *)&req.ai_socktype = 0LL;
req.ai_socktype = a4;
req.ai_next = 0LL;
req.ai_flags = 2;
req.ai_family = a3;
*(_OWORD *)&req.ai_addr = 0LL;
v4 = getaddrinfo(a1, a2, &req, &pai) == 0;
result = 0LL;
if ( v4 )
result = pai;
return result;
}

original_code:
struct addrinfo*
host_serv(const char *host, const char *serv, int family, int socktype)
{
  int n;
  struct addrinfo hints, *res;
  bzero(&hints, sizeof(struct addrinfo));
  hints.ai_flags = 0x0002;
  hints.ai_family = family;
  hints.ai_socktype = socktype;
  if ( (n = getaddrinfo(host, serv, &hints, &res)) != 0)
    return(((void *)0));
  return(res);
}

canonical_original_code:
struct addrinfo *host_serv(char *host, char *serv, int family, int socktype)
{
  int n;
  struct addrinfo hints; struct addrinfo *res;
  bzero(&hints, sizeof(struct addrinfo));
  hints.ai_flags = 0x0002;
  hints.ai_family = family;
  hints.ai_socktype = socktype;
  if ( (n = getaddrinfo(host, serv, &hints, &res)) != 0)
    return(((void *)0));
  return(res);
}

variable_types:
host
char *

variable_types:
serv
char *

variable_types: socktype int

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *

user_defined_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }


decompiled_code:
struct addrinfo *__fastcall Host_serv(const char *a1, const char *a2, int a3, int a4)
{
const char *v4; // r12
const char *v5; // rbp
int v6; // eax
const char *v8; // rcx
struct addrinfo *pai; // [rsp+0h] [rbp-50h] BYREF
struct addrinfo req; // [rsp+8h] [rbp-48h] BYREF

v4 = a2;
v5 = a1;
*(_OWORD *)&req.ai_socktype = 0LL;
req.ai_socktype = a4;
req.ai_next = 0LL;
req.ai_flags = 2;
req.ai_family = a3;
*(_OWORD *)&req.ai_addr = 0LL;
v6 = getaddrinfo(a1, a2, &req, &pai);
if ( !v6 )
return pai;
v8 = gai_strerror(v6);
if ( !a2 )
v4 = "(no service name)";
if ( !a1 )
v5 = "(no hostname)";
err_quit("host_serv error for %s, %s: %s", v5, v4, v8);
return pai;
}

canonical_decompiled_code:
struct addrinfo *__fastcall func9(const char *a1, const char *a2, int a3, int a4)
{
const char *v4; // r12
const char *v5; // rbp
int v6; // eax
const char *v8; // rcx
struct addrinfo *pai; // [rsp+0h] [rbp-50h] BYREF
struct addrinfo req; // [rsp+8h] [rbp-48h] BYREF

v4 = a2;
v5 = a1;
*(_OWORD *)&req.ai_socktype = 0LL;
req.ai_socktype = a4;
req.ai_next = 0LL;
req.ai_flags = 2;
req.ai_family = a3;
*(_OWORD *)&req.ai_addr = 0LL;
v6 = getaddrinfo(a1, a2, &req, &pai);
if ( !v6 )
return pai;
v8 = gai_strerror(v6);
if ( !a2 )
v4 = "(no service name)";
if ( !a1 )
v5 = "(no hostname)";
err_quit("host_serv error for %s, %s: %s", v5, v4, v8);
return pai;
}

original_code:
struct addrinfo *
Host_serv(const char *host, const char *serv, int family, int socktype)
{
  int n;
  struct addrinfo hints, *res;
  bzero(&hints, sizeof(struct addrinfo));
  hints.ai_flags = 0x0002;
  hints.ai_family = family;
  hints.ai_socktype = socktype;
  if ( (n = getaddrinfo(host, serv, &hints, &res)) != 0)
    err_quit("host_serv error for %s, %s: %s",
         (host == ((void *)0)) ? "(no hostname)" : host,
         (serv == ((void *)0)) ? "(no service name)" : serv,
         gai_strerror(n));
  return(res);
}

canonical_original_code:
struct addrinfo *Host_serv(char *host, char *serv, int family, int socktype)
{
  int n;
  struct addrinfo hints; struct addrinfo *res;
  bzero(&hints, sizeof(struct addrinfo));
  hints.ai_flags = 0x0002;
  hints.ai_family = family;
  hints.ai_socktype = socktype;
  if ( (n = getaddrinfo(host, serv, &hints, &res)) != 0)
    err_quit("host_serv error for %s, %s: %s",
         (host == ((void *)0)) ? "(no hostname)" : host,
         (serv == ((void *)0)) ? "(no service name)" : serv,
         gai_strerror(n));
  return(res);
}

variable_types: family int

variable_types: n int

return_type: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *


decompiled_code:
__int64 __fastcall Sctp_sendmsg(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int v4; // er12

v4 = sctp_sendmsg(a1, a2, a3, a4);
if ( v4 < 0 )
fatal_sys_exit("sctp_sendmsg error");
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int v4; // er12

v4 = sctp_sendmsg(a1, a2, a3, a4);
if ( v4 < 0 )
fatal_sys_exit("sctp_sendmsg error");
return (unsigned int)v4;
}

original_code:
int
Sctp_sendmsg (int sock_fd, void* data, size_t len, SA* to,
              socklen_t tolen, uint32_t ppid, uint32_t flags,
              uint16_t stream_no, uint32_t timetolive, uint32_t context)
{
  int ret;
  ret = sctp_sendmsg (sock_fd, data, len, to, tolen, ppid, flags,
                      stream_no, timetolive, context);
  if (ret < 0)
    fatal_sys_exit ("sctp_sendmsg error");
  return ret;
}

canonical_original_code:
int Sctp_sendmsg(int sock_fd, void *data, unsigned long len, struct sockaddr *to, unsigned int tolen, unsigned int ppid, unsigned int flags, unsigned short stream_no, unsigned int timetolive, unsigned int context)
{
  int ret;
  ret = sctp_sendmsg (sock_fd, data, len, to, tolen, ppid, flags,
                      stream_no, timetolive, context);
  if (ret < 0)
    fatal_sys_exit ("sctp_sendmsg error");
  return ret;
}

variable_types:
data
void *

variable_types:
len
unsigned long

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

variable_types:
tolen
unsigned int

variable_types:
ppid
unsigned int

variable_types:
flags
unsigned int

variable_types:
timetolive
unsigned int

variable_types:
context
unsigned int

variable_types: ret int


decompiled_code:
char *__fastcall sock_ntop(const char *a1, unsigned int a2)
{
__int64 v2; // rcx
const char *v3; // r12
unsigned __int16 v4; // ax
char *result; // rax
char s[32]; // [rsp+8h] [rbp-20h] BYREF

v2 = *(unsigned __int16 *)a1;
if ( (_WORD)v2 == 1 )
{
if ( a1[2] )
{
snprintf(str_0, 0x80uLL, "%s", a1 + 2);
result = str_0;
}
else
{
dword_A30 = 2712686;
result = str_0;
*(__m128i *)str_0 = _mm_load_si128((const __m128i *)&LC7);
}
}
else if ( (_WORD)v2 == 2 )
{
v3 = inet_ntop(2, a1 + 4, str_0, 0x80u);
if ( v3 && (v3 = str_0, (v4 = _bswap_16(*((_WORD *)a1 + 1))) != 0) )
{
snprintf(s, 8uLL, ":%d", v4);
strcat(str_0, s);
result = str_0;
}
else
{
result = (char *)v3;
}
}
else
{
snprintf(str_0, 0x80uLL, "sock_ntop: unknown AF_xxx: %d, len %d", v2, a2);
result = str_0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func8(const char *a1, unsigned int a2)
{
__int64 v2; // rcx
const char *v3; // r12
unsigned __int16 v4; // ax
char *result; // rax
char s[32]; // [rsp+8h] [rbp-20h] BYREF

v2 = *(unsigned __int16 *)a1;
if ( (_WORD)v2 == 1 )
{
if ( a1[2] )
{
snprintf(str_0, 0x80uLL, "%s", a1 + 2);
result = str_0;
}
else
{
dword_A30 = 2712686;
result = str_0;
*(__m128i *)str_0 = _mm_load_si128((const __m128i *)&LC7);
}
}
else if ( (_WORD)v2 == 2 )
{
v3 = inet_ntop(2, a1 + 4, str_0, 0x80u);
if ( v3 && (v3 = str_0, (v4 = func0(*((_WORD *)a1 + 1))) != 0) )
{
snprintf(s, 8uLL, ":%d", v4);
strcat(str_0, s);
result = str_0;
}
else
{
result = (char *)v3;
}
}
else
{
snprintf(str_0, 0x80uLL, "sock_ntop: unknown AF_xxx: %d, len %d", v2, a2);
result = str_0;
}
return result;
}

original_code:
char *
sock_ntop(const struct sockaddr *sa, socklen_t salen)
{
    char portstr[8];
    static char str[128];
  switch (sa->sa_family) {
  case 2: {
    struct sockaddr_in *sin = (struct sockaddr_in *) sa;
    if (inet_ntop(2, &sin->sin_addr, str, sizeof(str)) == ((void *)0))
      return(((void *)0));
    if (ntohs(sin->sin_port) != 0) {
      snprintf(portstr, sizeof(portstr), ":%d", ntohs(sin->sin_port));
      strcat(str, portstr);
    }
    return(str);
  }
  case 1: {
    struct sockaddr_un *unp = (struct sockaddr_un *) sa;
    if (unp->sun_path[0] == 0)
      strcpy(str, "(no pathname bound)");
    else
      snprintf(str, sizeof(str), "%s", unp->sun_path);
    return(str);
  }
  default:
    snprintf(str, sizeof(str), "sock_ntop: unknown AF_xxx: %d, len %d",
         sa->sa_family, salen);
    return(str);
  }
    return (((void *)0));
}

canonical_original_code:
char *sock_ntop(struct sockaddr *sa, unsigned int salen)
{
    char portstr[8];
    static char str[128];
  switch (sa->sa_family) {
  case 2: {
    struct sockaddr_in *sin = (struct sockaddr_in *) sa;
    if (inet_ntop(2, &sin->sin_addr, str, sizeof(str)) == ((void *)0))
      return(((void *)0));
    if (ntohs(sin->sin_port) != 0) {
      snprintf(portstr, sizeof(portstr), ":%d", ntohs(sin->sin_port));
      strcat(str, portstr);
    }
    return(str);
  }
  case 1: {
    struct sockaddr_un *unp = (struct sockaddr_un *) sa;
    if (unp->sun_path[0] == 0)
      strcpy(str, "(no pathname bound)");
    else
      snprintf(str, sizeof(str), "%s", unp->sun_path);
    return(str);
  }
  default:
    snprintf(str, sizeof(str), "sock_ntop: unknown AF_xxx: %d, len %d",
         sa->sa_family, salen);
    return(str);
  }
    return (((void *)0));
}

variable_types:
salen
unsigned int

variable_types:
portstr
char [8]

variable_types:
str
char [128]

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: struct sockaddr_un { unsigned short sun_family; char sun_path[108]; } *

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


decompiled_code:
char *__fastcall Sock_ntop(const char *a1, unsigned int a2)
{
char *result; // rax

result = sock_ntop(a1, a2);
if ( !result )
{
err_sys("sock_ntop error");
result = 0LL;
}
return result;
}

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

result = func8(a1, a2);
if ( !result )
{
err_sys("sock_ntop error");
result = 0LL;
}
return result;
}

original_code:
char *
Sock_ntop(const struct sockaddr *sa, socklen_t salen)
{
  char *ptr;
  if ( (ptr = sock_ntop(sa, salen)) == ((void *)0))
    err_sys("sock_ntop error");
  return(ptr);
}

canonical_original_code:
char *Sock_ntop(struct sockaddr *sa, unsigned int salen)
{
  char *ptr;
  if ( (ptr = sock_ntop(sa, salen)) == ((void *)0))
    err_sys("sock_ntop error");
  return(ptr);
}

variable_types:
ptr
char *


decompiled_code:
int __fastcall sctp_list_addresses(const char *a1, _QWORD *a2)
{
unsigned int v3; // ebp
char *v4; // rax
int result; // eax

if ( (int)a2 <= 0 )
return fatal_user_exit("error sctp_list_addresses: cannot list %n addresses", a2);
v3 = 0;
do
{
++v3;
v4 = Sock_ntop(a1, 0x10u);
result = fprintf(stderr, "[INFO] (%s:%d) %d. %s\n", "sctp.c", 238LL, v3, v4);
if ( *(_WORD *)a1 != 2 )
result = fatal_user_exit("sctp_list_addresses unknown AF");
a1 += 16;
}
while ( v3 != (_DWORD)a2 );
return result;
}

canonical_decompiled_code:
int __fastcall func10(const char *a1, _QWORD *a2)
{
unsigned int v3; // ebp
char *v4; // rax
int result; // eax

if ( (int)a2 <= 0 )
return fatal_user_exit("error sctp_list_addresses: cannot list %n addresses", a2);
v3 = 0;
do
{
++v3;
v4 = func9(a1, 0x10u);
result = fprintf(stderr, "[INFO] (%s:%d) %d. %s\n", "sctp.c", 238LL, v3, v4);
if ( *(_WORD *)a1 != 2 )
result = fatal_user_exit("sctp_list_addresses unknown AF");
a1 += 16;
}
while ( v3 != (_DWORD)a2 );
return result;
}

original_code:
void
sctp_list_addresses (struct sockaddr_storage* addrs, int n)
{
  if (n<1)
    fatal_user_exit ("error sctp_list_addresses: cannot list %n addresses", n);
  struct sockaddr_storage* current;
  int i, socklen;
  current = addrs;
  for (i = 0 ; i < n ; i++)
    {
      fprintf(stderr, "[INFO]  (%s:%d) " "    %d. %s" "\n", "sctp.c", 238, i+1, Sock_ntop ((SA*)current, socklen));
      switch (current->ss_family)
        {
          case 2: socklen = sizeof (struct sockaddr_in); break;
          default: fatal_user_exit ("sctp_list_addresses unknown AF");
        }
      current = (struct sockaddr_storage*) ((char*) current + socklen);
    }
}

canonical_original_code:
void sctp_list_addresses(struct sockaddr_storage *addrs, int n)
{
  if (n<1)
    fatal_user_exit ("error sctp_list_addresses: cannot list %n addresses", n);
  struct sockaddr_storage *current;
  int i; int socklen;
  current = addrs;
  for (i = 0 ; i < n ; i++)
    {
      fprintf(stderr, "[INFO]  (%s:%d) " "    %d. %s" "\n", "sctp.c", 238, i+1, Sock_ntop ((struct sockaddr *)current, socklen));
      switch (current->ss_family)
        {
          case 2: socklen = sizeof (struct sockaddr_in); break;
          default: fatal_user_exit ("sctp_list_addresses unknown AF");
        }
      current = (struct sockaddr_storage *) ((char *) current + socklen);
    }
}

variable_types: struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; } *

variable_types: i int

variable_types: socklen int


decompiled_code:
__int64 Sctp_bindx()
{
int v0; // er12

v0 = sctp_bindx();
if ( v0 < 0 )
err_sys("sctp_bindx error");
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func12()
{
int v0; // er12

v0 = sctp_bindx();
if ( v0 < 0 )
err_sys("sctp_bindx error");
return (unsigned int)v0;
}

original_code:
int
Sctp_bindx(int sock_fd,struct sockaddr_storage *at,int num,int op)
{
  int ret;
  ret = sctp_bindx (sock_fd, (struct sockaddr*) at, num, op);
  if (ret < 0)
    err_sys("sctp_bindx error");
  return ret;
}

canonical_original_code:
int Sctp_bindx(int sock_fd, struct sockaddr_storage *at, int num, int op)
{
  int ret;
  ret = sctp_bindx (sock_fd, (struct sockaddr *) at, num, op);
  if (ret < 0)
    err_sys("sctp_bindx error");
  return ret;
}

variable_types: num int

variable_types: op int

user_defined_types: struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; }


decompiled_code:
__int64 __fastcall sctp_bind_arg_list(unsigned int a1, __int64 *a2, int a3)
{
__int64 *v3; // r15
int v4; // er13
char *v5; // rbx
__int64 v6; // rdi
struct addrinfo *v7; // r14
char *ptr; // [rsp+0h] [rbp-58h]
char s[66]; // [rsp+16h] [rbp-42h] BYREF

v3 = a2;
v4 = a3;
ptr = (char *)calloc(a3, 0x80uLL);
v5 = ptr;
sprintf(s, "%d", 9987LL);
if ( v4 <= 0 )
{
v4 = 0;
}
else
{
do
{
v6 = *v3++;
v7 = (struct addrinfo *)Host_serv(v6, s, 0LL, 5LL);
memcpy(v5, v7->ai_addr, v7->ai_addrlen);
freeaddrinfo(v7);
v5 += v7->ai_addrlen;
}
while ( v3 != &a2[(unsigned int)(v4 - 1) + 1] );
}
Sctp_bindx(a1, ptr, (unsigned int)v4, 1LL);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned int a1, __int64 *a2, int a3)
{
__int64 *v3; // r15
int v4; // er13
char *v5; // rbx
__int64 v6; // rdi
struct addrinfo *v7; // r14
char *ptr; // [rsp+0h] [rbp-58h]
char s[66]; // [rsp+16h] [rbp-42h] BYREF

v3 = a2;
v4 = a3;
ptr = (char *)calloc(a3, 0x80uLL);
v5 = ptr;
sprintf(s, "%d", 9987LL);
if ( v4 <= 0 )
{
v4 = 0;
}
else
{
do
{
v6 = *v3++;
v7 = (struct addrinfo *)Host_serv(v6, s, 0LL, 5LL);
memcpy(v5, v7->ai_addr, v7->ai_addrlen);
freeaddrinfo(v7);
v5 += v7->ai_addrlen;
}
while ( v3 != &a2[(unsigned int)(v4 - 1) + 1] );
}
func12(a1, ptr, (unsigned int)v4, 1LL);
free(ptr);
return 0LL;
}

original_code:
int
sctp_bind_arg_list(int sock_fd, char **argv, int argc)
{
  struct addrinfo *addr;
  char *bindbuf, *p, portbuf[10];
  int addrcnt=0;
  int i;
  bindbuf = (char *) calloc (argc, sizeof (struct sockaddr_storage));
  p = bindbuf;
  sprintf(portbuf, "%d", 9987);
  for( i=0; i<argc; i++ )
    {
      addr = Host_serv(argv[i], portbuf, 0, SOCK_SEQPACKET);
      memcpy(p, addr->ai_addr, addr->ai_addrlen);
      freeaddrinfo(addr);
      addrcnt++;
      p += addr->ai_addrlen;
    }
  Sctp_bindx ( sock_fd, (struct sockaddr_storage*) bindbuf, addrcnt, 0x01);
  free (bindbuf);
  return 0;
}

canonical_original_code:
int sctp_bind_arg_list(int sock_fd, char **argv, int argc)
{
  struct addrinfo *addr;
  char *bindbuf; char *p; char portbuf[10];
  int addrcnt = 0;
  int i;
  bindbuf = (char *) calloc (argc, sizeof (struct sockaddr_storage));
  p = bindbuf;
  sprintf(portbuf, "%d", 9987);
  for( i=0; i<argc; i++ )
    {
      addr = Host_serv(argv[i], portbuf, 0, SOCK_SEQPACKET);
      memcpy(p, addr->ai_addr, addr->ai_addrlen);
      freeaddrinfo(addr);
      addrcnt++;
      p += addr->ai_addrlen;
    }
  Sctp_bindx ( sock_fd, (struct sockaddr_storage *) bindbuf, addrcnt, 0x01);
  free (bindbuf);
  return 0;
}

variable_types:
argv
char **

variable_types: argc int

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *

variable_types:
bindbuf
char *

variable_types:
p
char *

variable_types:
portbuf
char [10]

variable_types: addrcnt int


Fork

decompiled_code:
__int64 Fork()
{
unsigned int v0; // er12

v0 = fork();
if ( v0 == -1 )
fatal_sys_exit("fork error");
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // er12

v0 = fork();
if ( v0 == -1 )
fatal_sys_exit("fork error");
return v0;
}

original_code:
pid_t
Fork(void)
{
  pid_t pid;
  if ( (pid = fork()) == -1)
    fatal_sys_exit("fork error");
  return(pid);
}

canonical_original_code:
int Fork()
{
  int pid;
  if ( (pid = fork()) == -1)
    fatal_sys_exit("fork error");
  return(pid);
}

variable_types: pid int


Malloc

decompiled_code:
void *__fastcall Malloc(size_t a1)
{
void *v1; // r12

v1 = malloc(a1);
if ( !v1 )
fatal_sys_exit("malloc error");
return v1;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *v1; // r12

v1 = malloc(a1);
if ( !v1 )
fatal_sys_exit("malloc error");
return v1;
}

original_code:
void*
Malloc(size_t size)
{
  void* buf = malloc (size);
  if (buf == ((void *)0))
    fatal_sys_exit ("malloc error");
  return buf;
}

canonical_original_code:
void *Malloc(unsigned long size)
{
  void *buf = malloc (size);
  if (buf == ((void *)0))
    fatal_sys_exit ("malloc error");
  return buf;
}

variable_types:
size
unsigned long

variable_types:
buf
void *


Close

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

result = close(a1);
if ( result == -1 )
result = fatal_sys_exit("close error");
return result;
}

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

result = close(a1);
if ( result == -1 )
result = fatal_sys_exit("close error");
return result;
}

original_code:
void
Close(int fd)
{
  if (close(fd) == -1)
    fatal_sys_exit("close error");
}

variable_types: fd int


Sigaction

decompiled_code:
__int64 __fastcall Sigaction(int a1, const struct sigaction *a2, struct sigaction *a3)
{
int v3; // ecx
int v4; // eax
int v5; // ecx

v3 = a2->sa_flags;
v4 = v3 | 0x10000000;
v5 = v3 | 0x20000000;
if ( a1 == 14 )
v4 = v5;
a2->sa_flags = v4;
if ( sigaction(a1, a2, a3) < 0 )
fatal_sys_exit("sigaction error");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, const struct sigaction *a2, struct sigaction *a3)
{
int v3; // ecx
int v4; // eax
int v5; // ecx

v3 = a2->sa_flags;
v4 = v3 | 0x10000000;
v5 = v3 | 0x20000000;
if ( a1 == 14 )
v4 = v5;
a2->sa_flags = v4;
if ( sigaction(a1, a2, a3) < 0 )
fatal_sys_exit("sigaction error");
return 0LL;
}

original_code:
int Sigaction( int sig, struct sigaction* ptrNewDisp, struct sigaction* ptrOldDisp )
{
  if( sig == 14 ) {
  ptrNewDisp->sa_flags |= 0x20000000;
  } else {
  ptrNewDisp->sa_flags |= 0x10000000;
  }
  if( (sigaction( sig, ptrNewDisp, ptrOldDisp ) < 0) )
  fatal_sys_exit( "sigaction error" );
  return 0;
}

canonical_original_code:
int Sigaction(int sig, struct sigaction *ptrNewDisp, struct sigaction *ptrOldDisp)
{
  if( sig == 14 ) {
  ptrNewDisp->sa_flags |= 0x20000000;
  } else {
  ptrNewDisp->sa_flags |= 0x10000000;
  }
  if( (sigaction( sig, ptrNewDisp, ptrOldDisp ) < 0) )
  fatal_sys_exit( "sigaction error" );
  return 0;
}

variable_types: sig int

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

variable_types:
ptrOldDisp
struct sigaction *

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

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


Recv

decompiled_code:
ssize_t __fastcall Recv(int a1, void *a2, size_t a3, int a4)
{
ssize_t result; // rax
ssize_t v5; // r12

result = recv(a1, a2, a3, a4);
v5 = result;
if ( result < 0 )
{
fatal_sys_exit("recv error");
result = v5;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func0(int a1, void *a2, size_t a3, int a4)
{
ssize_t result; // rax
ssize_t v5; // r12

result = recv(a1, a2, a3, a4);
v5 = result;
if ( result < 0 )
{
fatal_sys_exit("recv error");
result = v5;
}
return result;
}

original_code:
ssize_t
Recv(int fd, void *ptr, size_t nbytes, int flags)
{
  ssize_t n;
  if ( (n = recv(fd, ptr, nbytes, flags)) < 0)
    fatal_sys_exit("recv error");
  return(n);
}

canonical_original_code:
long Recv(int fd, void *ptr, unsigned long nbytes, int flags)
{
  long n;
  if ( (n = recv(fd, ptr, nbytes, flags)) < 0)
    fatal_sys_exit("recv error");
  return(n);
}

variable_types:
ptr
void *

variable_types:
nbytes
unsigned long

variable_types: flags int

variable_types: n long


Recvfrom

decompiled_code:
ssize_t __fastcall Recvfrom(int a1, void *a2, size_t a3, int a4, struct sockaddr *a5, socklen_t *a6)
{
ssize_t result; // rax
ssize_t v7; // r12

result = recvfrom(a1, a2, a3, a4, a5, a6);
v7 = result;
if ( result < 0 )
{
fatal_sys_exit("recvfrom error");
result = v7;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func1(int a1, void *a2, size_t a3, int a4, struct sockaddr *a5, socklen_t *a6)
{
ssize_t result; // rax
ssize_t v7; // r12

result = recvfrom(a1, a2, a3, a4, a5, a6);
v7 = result;
if ( result < 0 )
{
fatal_sys_exit("recvfrom error");
result = v7;
}
return result;
}

original_code:
ssize_t
Recvfrom(int fd, void *ptr, size_t nbytes, int flags,
     struct sockaddr *sa, socklen_t *salenptr)
{
  ssize_t n;
  if ( (n = recvfrom(fd, ptr, nbytes, flags, sa, salenptr)) < 0)
    fatal_sys_exit("recvfrom error");
  return(n);
}

canonical_original_code:
long Recvfrom(int fd, void *ptr, unsigned long nbytes, int flags, struct sockaddr *sa, unsigned int *salenptr)
{
  long n;
  if ( (n = recvfrom(fd, ptr, nbytes, flags, sa, salenptr)) < 0)
    fatal_sys_exit("recvfrom error");
  return(n);
}

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

variable_types:
salenptr
unsigned int *


Recvmsg

decompiled_code:
ssize_t __fastcall Recvmsg(int a1, struct msghdr *a2, int a3)
{
ssize_t result; // rax
ssize_t v4; // r12

result = recvmsg(a1, a2, a3);
v4 = result;
if ( result < 0 )
{
fatal_sys_exit("recvmsg error");
result = v4;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func2(int a1, struct msghdr *a2, int a3)
{
ssize_t result; // rax
ssize_t v4; // r12

result = recvmsg(a1, a2, a3);
v4 = result;
if ( result < 0 )
{
fatal_sys_exit("recvmsg error");
result = v4;
}
return result;
}

original_code:
ssize_t
Recvmsg(int fd, struct msghdr *msg, int flags)
{
  ssize_t n;
  if ( (n = recvmsg(fd, msg, flags)) < 0)
    fatal_sys_exit("recvmsg error");
  return(n);
}

canonical_original_code:
long Recvmsg(int fd, struct msghdr *msg, int flags)
{
  long n;
  if ( (n = recvmsg(fd, msg, flags)) < 0)
    fatal_sys_exit("recvmsg error");
  return(n);
}

variable_types: struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec { void *iov_base; unsigned long iov_len; } *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; } *

user_defined_types: struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; }


Select

decompiled_code:
__int64 __fastcall Select(int a1, fd_set *a2, fd_set *a3, fd_set *a4, struct timeval *a5)
{
int v5; // er12

v5 = select(a1, a2, a3, a4, a5);
if ( v5 < 0 )
fatal_sys_exit("select error");
return (unsigned int)v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, fd_set *a2, fd_set *a3, fd_set *a4, struct timeval *a5)
{
int v5; // er12

v5 = select(a1, a2, a3, a4, a5);
if ( v5 < 0 )
fatal_sys_exit("select error");
return (unsigned int)v5;
}

original_code:
int
Select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
       struct timeval *timeout)
{
  int n;
  if ( (n = select(nfds, readfds, writefds, exceptfds, timeout)) < 0)
    fatal_sys_exit("select error");
  return(n);
}

canonical_original_code:
int Select(int nfds, struct fd_set *readfds, struct fd_set *writefds, struct fd_set *exceptfds, struct timeval *timeout)
{
  int n;
  if ( (n = select(nfds, readfds, writefds, exceptfds, timeout)) < 0)
    fatal_sys_exit("select error");
  return(n);
}

variable_types: nfds int

variable_types: struct fd_set { long __fds_bits[-1]; } *

variable_types:
writefds
struct fd_set *

variable_types:
exceptfds
struct fd_set *

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

variable_types: n int


Send

decompiled_code:
ssize_t __fastcall Send(int a1, const void *a2, size_t a3, int a4)
{
ssize_t result; // rax

result = send(a1, a2, a3, a4);
if ( result != a3 )
result = fatal_sys_exit("send error");
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func4(int a1, const void *a2, size_t a3, int a4)
{
ssize_t result; // rax

result = send(a1, a2, a3, a4);
if ( result != a3 )
result = fatal_sys_exit("send error");
return result;
}

original_code:
void
Send(int fd, const void *ptr, size_t nbytes, int flags)
{
  if (send(fd, ptr, nbytes, flags) != (ssize_t)nbytes)
    fatal_sys_exit("send error");
}

canonical_original_code:
void Send(int fd, void *ptr, unsigned long nbytes, int flags)
{
  if (send(fd, ptr, nbytes, flags) != (long)nbytes)
    fatal_sys_exit("send error");
}

variable_types: fd int


Sendto

decompiled_code:
ssize_t __fastcall Sendto(int a1, const void *a2, size_t a3, int a4, const struct sockaddr *a5, socklen_t a6)
{
ssize_t result; // rax

result = sendto(a1, a2, a3, a4, a5, a6);
if ( result != a3 )
result = fatal_sys_exit("sendto error");
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func5(int a1, const void *a2, size_t a3, int a4, const struct sockaddr *a5, socklen_t a6)
{
ssize_t result; // rax

result = sendto(a1, a2, a3, a4, a5, a6);
if ( result != a3 )
result = fatal_sys_exit("sendto error");
return result;
}

original_code:
void
Sendto(int fd, const void *ptr, size_t nbytes, int flags,
     const struct sockaddr *sa, socklen_t salen)
{
  if (sendto(fd, ptr, nbytes, flags, sa, salen) != (ssize_t)nbytes)
    fatal_sys_exit("sendto error");
}

canonical_original_code:
void Sendto(int fd, void *ptr, unsigned long nbytes, int flags, struct sockaddr *sa, unsigned int salen)
{
  if (sendto(fd, ptr, nbytes, flags, sa, salen) != (long)nbytes)
    fatal_sys_exit("sendto error");
}

variable_types:
salen
unsigned int


Sendmsg

decompiled_code:
ssize_t __fastcall Sendmsg(int a1, const struct msghdr *a2, int a3)
{
unsigned __int64 v3; // rcx
struct iovec *v6; // rsi
__int64 v7; // rbx
unsigned int v8; // edx
__int64 v9; // rax
ssize_t result; // rax

v3 = a2->msg_iovlen;
if ( v3 )
{
v6 = a2->msg_iov;
v7 = 0LL;
v8 = 0;
v9 = 0LL;
do
{
v7 += v6[v9].iov_len;
v9 = ++v8;
}
while ( v8 < v3 );
}
else
{
v7 = 0LL;
}
result = sendmsg(a1, a2, a3);
if ( result != v7 )
result = fatal_sys_exit("sendmsg error");
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func6(int a1, const struct msghdr *a2, int a3)
{
unsigned __int64 v3; // rcx
struct iovec *v6; // rsi
__int64 v7; // rbx
unsigned int v8; // edx
__int64 v9; // rax
ssize_t result; // rax

v3 = a2->msg_iovlen;
if ( v3 )
{
v6 = a2->msg_iov;
v7 = 0LL;
v8 = 0;
v9 = 0LL;
do
{
v7 += v6[v9].iov_len;
v9 = ++v8;
}
while ( v8 < v3 );
}
else
{
v7 = 0LL;
}
result = sendmsg(a1, a2, a3);
if ( result != v7 )
result = fatal_sys_exit("sendmsg error");
return result;
}

original_code:
void
Sendmsg(int fd, const struct msghdr *msg, int flags)
{
  unsigned int i;
  ssize_t nbytes;
  nbytes = 0;
  for (i = 0; i < msg->msg_iovlen; i++)
    nbytes += msg->msg_iov[i].iov_len;
  if (sendmsg(fd, msg, flags) != nbytes)
    fatal_sys_exit("sendmsg error");
}

canonical_original_code:
void Sendmsg(int fd, struct msghdr *msg, int flags)
{
  unsigned int i;
  long nbytes;
  nbytes = 0;
  for (i = 0; i < msg->msg_iovlen; i++)
    nbytes += msg->msg_iov[i].iov_len;
  if (sendmsg(fd, msg, flags) != nbytes)
    fatal_sys_exit("sendmsg error");
}

variable_types:
i
unsigned int

variable_types: nbytes long

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


Read

decompiled_code:
__int64 __fastcall Read(int fd, void *buf, size_t nbytes)
{
int v4; // er13

do
{
v4 = read(fd, buf, nbytes);
if ( v4 >= 0 )
return v4;
}
while ( *_errno_location() == 4 );
fatal_sys_exit("read error");
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func10(int fd, void *buf, size_t nbytes)
{
int v4; // er13

do
{
v4 = read(fd, buf, nbytes);
if ( v4 >= 0 )
return v4;
}
while ( *_errno_location() == 4 );
fatal_sys_exit("read error");
return v4;
}

original_code:
ssize_t
Read( int fd, void* buf, size_t n )
{
  int bytes_read;
again:
  if( (bytes_read = read(fd, buf, n)) < 0 )
  if( (*__errno_location ()) == 4 )
    goto again;
  else
    fatal_sys_exit( "read error" );
  return bytes_read;
}

canonical_original_code:
long Read(int fd, void *buf, unsigned long n)
{
  int bytes_read;
again:
  if( (bytes_read = read(fd, buf, n)) < 0 )
  if( (*__errno_location ()) == 4 )
    goto again;
  else
    fatal_sys_exit( "read error" );
  return bytes_read;
}

variable_types:
buf
void *

variable_types:
n
unsigned long