decompiled_code:
__int64 __fastcall diminuto_criticalsection_trylock(pthread_mutex_t *a1)
{
int v1; // eax
unsigned int v2; // er12

v1 = pthread_mutex_trylock(a1);
if ( v1 == 16 )
{
v2 = -1;
*_errno_location() = 16;
}
else
{
v2 = v1;
if ( v1 )
{
*_errno_location() = v1;
v2 = -1;
diminuto_log_perror(
"src/diminuto_criticalsection.c",
39LL,
"diminuto_criticalsection_trylock: pthread_mutex_trylock");
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(pthread_mutex_t *a1)
{
int v1; // eax
unsigned int v2; // er12

v1 = pthread_mutex_trylock(a1);
if ( v1 == 16 )
{
v2 = -1;
*_errno_location() = 16;
}
else
{
v2 = v1;
if ( v1 )
{
*_errno_location() = v1;
v2 = -1;
diminuto_log_perror(
"src/diminuto_criticalsection.c",
39LL,
"diminuto_criticalsection_trylock: pthread_mutex_trylock");
}
}
return v2;
}

original_code:
int diminuto_criticalsection_trylock(pthread_mutex_t * mp)
{
    int rc = 0;
    if ((rc = pthread_mutex_trylock(mp)) == 16) {
        (*__errno_location ()) = rc;
        rc = -1;
    } else if (rc != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_criticalsection.c", 39, "diminuto_criticalsection_trylock: pthread_mutex_trylock");
        rc = -1;
    } else {
    }
    return rc;
}

canonical_original_code:
int diminuto_criticalsection_trylock(union pthread_mutex_t *mp)
{
    int rc = 0;
    if ((rc = pthread_mutex_trylock(mp)) == 16) {
        (*__errno_location ()) = rc;
        rc = -1;
    } else if (rc != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_criticalsection.c", 39, "diminuto_criticalsection_trylock: pthread_mutex_trylock");
        rc = -1;
    } else {
    }
    return rc;
}

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


repo: coverclock/com-diag-diminuto

decompiled_code:
int __fastcall diminuto_criticalsection_cleanup(pthread_mutex_t *a1)
{
int result; // eax

result = pthread_mutex_unlock(a1);
if ( result )
{
*_errno_location() = result;
result = diminuto_log_perror(
"src/diminuto_criticalsection.c",
55LL,
"diminuto_criticalsection_cleanup: pthread_mutex_unlock");
}
return result;
}

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

result = pthread_mutex_unlock(a1);
if ( result )
{
*_errno_location() = result;
result = diminuto_log_perror(
"src/diminuto_criticalsection.c",
55LL,
"diminuto_criticalsection_cleanup: pthread_mutex_unlock");
}
return result;
}

original_code:
void diminuto_criticalsection_cleanup(void * vp)
{
    int rc = 0;
    pthread_mutex_t * mutexp = (pthread_mutex_t *)vp;
    if ((rc = pthread_mutex_unlock(mutexp)) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_criticalsection.c", 55, "diminuto_criticalsection_cleanup: pthread_mutex_unlock");
    }
}

canonical_original_code:
void diminuto_criticalsection_cleanup(void *vp)
{
    int rc = 0;
    union pthread_mutex_t *mutexp = (pthread_mutex_t *)vp;
    if ((rc = pthread_mutex_unlock(mutexp)) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_criticalsection.c", 55, "diminuto_criticalsection_cleanup: pthread_mutex_unlock");
    }
}

variable_types:
vp
void *

variable_types: rc int

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

return_type: void

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


decompiled_code:
int __fastcall diminuto_ipcl_compare(const char *a1, const char *a2)
{
if ( !a1 )
return 0x80000000;
if ( a2 )
return strncmp(a1, a2, 0x1000uLL);
return 0x7FFFFFFF;
}

canonical_decompiled_code:
int __fastcall func1(const char *a1, const char *a2)
{
if ( !a1 )
return 0x80000000;
if ( a2 )
return strncmp(a1, a2, 0x1000uLL);
return 0x7FFFFFFF;
}

original_code:
int diminuto_ipcl_compare(const char * path1p, const char * path2p)
{
    return (path1p == (const char *)0)
        ? (((int)1) << ((sizeof(int) * 8) - 1))
        : (path2p == (const char *)0)
            ? (~(((int)1) << ((sizeof(int) * 8) - 1)))
            : strncmp(path1p, path2p, sizeof(diminuto_path_t));
}

canonical_original_code:
int diminuto_ipcl_compare(char *path1p, char *path2p)
{
    return (path1p == (char *)0)
        ? (((int)1) << ((sizeof(int) * 8) - 1))
        : (path2p == (char *)0)
            ? (~(((int)1) << ((sizeof(int) * 8) - 1)))
            : strncmp(path1p, path2p, sizeof(diminuto_path_t));
}

return_type: int


decompiled_code:
__int64 __fastcall diminuto_ipcl_identify(__int64 a1, char *a2, size_t a3)
{
unsigned int v3; // er12

if ( *(_WORD *)a1 != 1 )
return (unsigned int)-1;
v3 = 0;
if ( a2 )
{
*a2 = 0;
strncpy(a2, (const char *)(a1 + 2), a3)[a3 - 1] = 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, char *a2, size_t a3)
{
unsigned int v3; // er12

if ( *(_WORD *)a1 != 1 )
return (unsigned int)-1;
v3 = 0;
if ( a2 )
{
*a2 = 0;
strncpy(a2, (const char *)(a1 + 2), a3)[a3 - 1] = 0;
}
return v3;
}

original_code:
int diminuto_ipcl_identify(struct sockaddr * sap, char * pathp, size_t size)
{
    int rc = 0;
    if (sap->sa_family != 1) {
        rc = -1;
    } else if (pathp == (char *)0) {
    } else {
        pathp[0] = '\0';
        (void)strncpy(pathp, ((struct sockaddr_un *)sap)->sun_path, size);
        pathp[size - 1] = '\0';
    }
    return rc;
}

canonical_original_code:
int diminuto_ipcl_identify(struct sockaddr *sap, char *pathp, unsigned long size)
{
    int rc = 0;
    if (sap->sa_family != 1) {
        rc = -1;
    } else if (pathp == (char *)0) {
    } else {
        pathp[0] = '\0';
        (void)strncpy(pathp, ((struct sockaddr_un *)sap)->sun_path, size);
        pathp[size - 1] = '\0';
    }
    return rc;
}

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

variable_types:
pathp
char *

variable_types:
size
unsigned long

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


decompiled_code:
char *__fastcall diminuto_ipcl_path(_BYTE *a1, char *a2, size_t a3)
{
char *v3; // r12
size_t v6; // rax
char v7; // [rsp+1h] [rbp-139h]
__int128 v8; // [rsp+2h] [rbp-138h] BYREF
char v9[296]; // [rsp+12h] [rbp-128h] BYREF

v8 = 0LL;
memset(v9, 0, 0xF0uLL);
v9[240] = 0;
if ( a3 )
{
if ( *a1 )
{
v3 = 0LL;
if ( (int)diminuto_fs_canonicalize(a1, &v8, 257LL) >= 0 )
{
v6 = strlen((const char *)&v8);
if ( v6 <= 1 )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_ipcl.c", 114LL, a1);
}
else if ( *(&v7 + v6) == 47 )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_ipcl.c", 118LL, a1);
}
else if ( a3 <= v6 )
{
*_errno_location() = 36;
diminuto_log_perror("src/diminuto_ipcl.c", 122LL, a1);
}
else
{
*a2 = 0;
v3 = a2;
strncpy(a2, (const char *)&v8, a3);
a2[a3 - 1] = 0;
}
}
}
else
{
*a2 = 0;
v3 = a2;
}
}
else
{
v3 = 0LL;
*_errno_location() = 36;
diminuto_log_perror("src/diminuto_ipcl.c", 104LL, a1);
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func3(_BYTE *a1, char *a2, size_t a3)
{
char *v3; // r12
size_t v6; // rax
char v7; // [rsp+1h] [rbp-139h]
__int128 v8; // [rsp+2h] [rbp-138h] BYREF
char v9[296]; // [rsp+12h] [rbp-128h] BYREF

v8 = 0LL;
memset(v9, 0, 0xF0uLL);
v9[240] = 0;
if ( a3 )
{
if ( *a1 )
{
v3 = 0LL;
if ( (int)diminuto_fs_canonicalize(a1, &v8, 257LL) >= 0 )
{
v6 = strlen((const char *)&v8);
if ( v6 <= 1 )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_ipcl.c", 114LL, a1);
}
else if ( *(&v7 + v6) == 47 )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_ipcl.c", 118LL, a1);
}
else if ( a3 <= v6 )
{
*_errno_location() = 36;
diminuto_log_perror("src/diminuto_ipcl.c", 122LL, a1);
}
else
{
*a2 = 0;
v3 = a2;
strncpy(a2, (const char *)&v8, a3);
a2[a3 - 1] = 0;
}
}
}
else
{
*a2 = 0;
v3 = a2;
}
}
else
{
v3 = 0LL;
*_errno_location() = 36;
diminuto_log_perror("src/diminuto_ipcl.c", 104LL, a1);
}
return v3;
}

original_code:
char * diminuto_ipcl_path(const char * path, char * buffer, size_t size)
{
    char * result = (char *)0;
    diminuto_local_t canonical = { '\0', };
    size_t length = 0;
    if (size <= 0) {
        (*__errno_location ()) = 36;
        diminuto_log_perror("src/diminuto_ipcl.c", 104, path);
    } else if (path[0] == '\0') {
        buffer[0] = '\0';
        result = buffer;
    } else if (diminuto_fs_canonicalize(path, canonical, sizeof(canonical)) < 0) {
    } else if ((length = strlen(canonical)) < 2) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipcl.c", 114, path);
    } else if (canonical[length - 1] == '/') {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipcl.c", 118, path);
    } else if (length >= size) {
        (*__errno_location ()) = 36;
        diminuto_log_perror("src/diminuto_ipcl.c", 122, path);
    } else {
        buffer[0] = '\0';
        (void)strncpy(buffer, canonical, size);
        buffer[size - 1] = '\0';
        result = buffer;
    }
    return result;
}

canonical_original_code:
char *diminuto_ipcl_path(char *path, char *buffer, unsigned long size)
{
    char *result = (char *)0;
    char canonical[-1] = { '\0', };
    unsigned long length = 0;
    if (size <= 0) {
        (*__errno_location ()) = 36;
        diminuto_log_perror("src/diminuto_ipcl.c", 104, path);
    } else if (path[0] == '\0') {
        buffer[0] = '\0';
        result = buffer;
    } else if (diminuto_fs_canonicalize(path, canonical, sizeof(canonical)) < 0) {
    } else if ((length = strlen(canonical)) < 2) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipcl.c", 114, path);
    } else if (canonical[length - 1] == '/') {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipcl.c", 118, path);
    } else if (length >= size) {
        (*__errno_location ()) = 36;
        diminuto_log_perror("src/diminuto_ipcl.c", 122, path);
    } else {
        buffer[0] = '\0';
        (void)strncpy(buffer, canonical, size);
        buffer[size - 1] = '\0';
        result = buffer;
    }
    return result;
}

variable_types:
path
char *

variable_types:
buffer
char *

variable_types:
result
char *

variable_types:
canonical
char [-1]

variable_types:
length
unsigned long

return_type: char *


decompiled_code:
__int64 __fastcall diminuto_ipcl_nearend(int fd, char *a2, size_t a3)
{
int v4; // er12
socklen_t len; // [rsp+Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-98h] BYREF
int v8; // [rsp+78h] [rbp-30h]
__int16 v9; // [rsp+7Ch] [rbp-2Ch]

len = 110;
memset(&addr, 0, 0x68uLL);
v8 = 0;
v9 = 0;
v4 = getsockname(fd, &addr, &len);
if ( v4 < 0 )
diminuto_log_perror("src/diminuto_ipcl.c", 144LL, "diminuto_ipcl_nearend: getsockname");
else
diminuto_ipcl_identify((__int64)&addr, a2, a3);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func5(int fd, char *a2, size_t a3)
{
int v4; // er12
socklen_t len; // [rsp+Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-98h] BYREF
int v8; // [rsp+78h] [rbp-30h]
__int16 v9; // [rsp+7Ch] [rbp-2Ch]

len = 110;
memset(&addr, 0, 0x68uLL);
v8 = 0;
v9 = 0;
v4 = getsockname(fd, &addr, &len);
if ( v4 < 0 )
diminuto_log_perror("src/diminuto_ipcl.c", 144LL, "diminuto_ipcl_nearend: getsockname");
else
func2((__int64)&addr, a2, a3);
return (unsigned int)v4;
}

original_code:
int diminuto_ipcl_nearend(int fd, char * pathp, size_t psize)
{
    int rc = -1;
    struct sockaddr_un sa = { 0, };
    socklen_t length = sizeof(sa);
    if ((rc = getsockname(fd, (struct sockaddr *)&sa, &length)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 144, "diminuto_ipcl_nearend: getsockname");
    } else {
        diminuto_ipcl_identify((struct sockaddr *)&sa, pathp, psize);
    }
    return rc;
}

canonical_original_code:
int diminuto_ipcl_nearend(int fd, char *pathp, unsigned long psize)
{
    int rc = -1;
    struct sockaddr_un sa = { 0, };
    unsigned int length = sizeof(sa);
    if ((rc = getsockname(fd, (struct sockaddr *)&sa, &length)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 144, "diminuto_ipcl_nearend: getsockname");
    } else {
        diminuto_ipcl_identify((struct sockaddr *)&sa, pathp, psize);
    }
    return rc;
}

variable_types: fd int

variable_types:
psize
unsigned long

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

variable_types:
length
unsigned int

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


decompiled_code:
__int64 __fastcall diminuto_ipcl_farend(int fd, char *a2, size_t a3)
{
int v4; // er12
socklen_t len; // [rsp+Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-98h] BYREF
int v8; // [rsp+78h] [rbp-30h]
__int16 v9; // [rsp+7Ch] [rbp-2Ch]

len = 110;
memset(&addr, 0, 0x68uLL);
v8 = 0;
v9 = 0;
v4 = getpeername(fd, &addr, &len);
if ( v4 < 0 )
diminuto_log_perror("src/diminuto_ipcl.c", 159LL, "diminuto_ipcl_farend: getpeername");
else
diminuto_ipcl_identify((__int64)&addr, a2, a3);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func6(int fd, char *a2, size_t a3)
{
int v4; // er12
socklen_t len; // [rsp+Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-98h] BYREF
int v8; // [rsp+78h] [rbp-30h]
__int16 v9; // [rsp+7Ch] [rbp-2Ch]

len = 110;
memset(&addr, 0, 0x68uLL);
v8 = 0;
v9 = 0;
v4 = getpeername(fd, &addr, &len);
if ( v4 < 0 )
diminuto_log_perror("src/diminuto_ipcl.c", 159LL, "diminuto_ipcl_farend: getpeername");
else
func2((__int64)&addr, a2, a3);
return (unsigned int)v4;
}

original_code:
int diminuto_ipcl_farend(int fd, char * pathp, size_t psize)
{
    int rc = -1;
    struct sockaddr_un sa = { 0 };
    socklen_t length = sizeof(sa);
    if ((rc = getpeername(fd, (struct sockaddr *)&sa, &length)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 159, "diminuto_ipcl_farend: getpeername");
    } else {
        diminuto_ipcl_identify((struct sockaddr *)&sa, pathp, psize);
    }
    return rc;
}

canonical_original_code:
int diminuto_ipcl_farend(int fd, char *pathp, unsigned long psize)
{
    int rc = -1;
    struct sockaddr_un sa = { 0 };
    unsigned int length = sizeof(sa);
    if ((rc = getpeername(fd, (struct sockaddr *)&sa, &length)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 159, "diminuto_ipcl_farend: getpeername");
    } else {
        diminuto_ipcl_identify((struct sockaddr *)&sa, pathp, psize);
    }
    return rc;
}


decompiled_code:
__int64 __fastcall diminuto_ipcl_source(int fd, const char *a2)
{
int v2; // er12
_BYTE vars0[104]; // [rsp+0h] [rbp+0h] BYREF
int anonymous0; // [rsp+68h] [rbp+68h]
__int16 anonymous1; // [rsp+6Ch] [rbp+6Ch]

v2 = fd;
memset(vars0, 0, sizeof(vars0));
anonymous0 = 0;
anonymous1 = 0;
if ( a2 )
{
if ( *a2 )
{
*(_WORD *)vars0 = 1;
strncpy(&vars0[2], a2, 0x6CuLL);
v2 = bind(fd, (const struct sockaddr *)vars0, 0x6Eu);
if ( v2 < 0 )
diminuto_log_perror("src/diminuto_ipcl.c", 202LL, "diminuto_ipcl_source: bind");
}
}
else
{
*_errno_location() = 22;
v2 = -1;
diminuto_log_perror("src/diminuto_ipcl.c", 189LL, "diminuto_ipcl_source: NULL");
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func7(int fd, const char *a2)
{
int v2; // er12
_BYTE vars0[104]; // [rsp+0h] [rbp+0h] BYREF
int anonymous0; // [rsp+68h] [rbp+68h]
__int16 anonymous1; // [rsp+6Ch] [rbp+6Ch]

v2 = fd;
memset(vars0, 0, sizeof(vars0));
anonymous0 = 0;
anonymous1 = 0;
if ( a2 )
{
if ( *a2 )
{
*(_WORD *)vars0 = 1;
strncpy(&vars0[2], a2, 0x6CuLL);
v2 = bind(fd, (const struct sockaddr *)vars0, 0x6Eu);
if ( v2 < 0 )
diminuto_log_perror("src/diminuto_ipcl.c", 202LL, "diminuto_ipcl_source: bind");
}
}
else
{
*_errno_location() = 22;
v2 = -1;
diminuto_log_perror("src/diminuto_ipcl.c", 189LL, "diminuto_ipcl_source: NULL");
}
return (unsigned int)v2;
}

original_code:
int diminuto_ipcl_source(int fd, const char * path)
{
    int rc = fd;
    struct sockaddr_un sa = { 0 };
    socklen_t length = sizeof(sa);
    if (path == (const char *)0) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipcl.c", 189, "diminuto_ipcl_source: NULL");
        rc = -1;
    } else if (path[0] == '\0') {
    } else {
        sa.sun_family = 1;
        (void)strncpy(sa.sun_path, path, sizeof(sa.sun_path));
        if ((rc = bind(fd, (struct sockaddr *)&sa, length)) < 0) {
            diminuto_log_perror("src/diminuto_ipcl.c", 202, "diminuto_ipcl_source: bind");
        }
    }
    return rc;
}

canonical_original_code:
int diminuto_ipcl_source(int fd, char *path)
{
    int rc = fd;
    struct sockaddr_un sa = { 0 };
    unsigned int length = sizeof(sa);
    if (path == (char *)0) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipcl.c", 189, "diminuto_ipcl_source: NULL");
        rc = -1;
    } else if (path[0] == '\0') {
    } else {
        sa.sun_family = 1;
        (void)strncpy(sa.sun_path, path, sizeof(sa.sun_path));
        if ((rc = bind(fd, (struct sockaddr *)&sa, length)) < 0) {
            diminuto_log_perror("src/diminuto_ipcl.c", 202, "diminuto_ipcl_source: bind");
        }
    }
    return rc;
}


decompiled_code:
__int64 __fastcall diminuto_ipcl_remove(const char *a1)
{
__int64 result; // rax

if ( a1 )
{
if ( unlink(a1) < 0 )
{
diminuto_log_perror("src/diminuto_ipcl.c", 228LL, "diminuto_ipcl_remove: unlink");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
else
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_ipcl.c", 223LL, "diminuto_ipcl_remove: NULL");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1)
{
__int64 result; // rax

if ( a1 )
{
if ( unlink(a1) < 0 )
{
diminuto_log_perror("src/diminuto_ipcl.c", 228LL, "diminuto_ipcl_remove: unlink");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
else
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_ipcl.c", 223LL, "diminuto_ipcl_remove: NULL");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int diminuto_ipcl_remove(const char * path)
{
    int rc = 0;
    if (path == (const char *)0) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipcl.c", 223, "diminuto_ipcl_remove: NULL");
        rc = -1;
    } else if (unlink(path) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 228, "diminuto_ipcl_remove: unlink");
        rc = -1;
    } else {
    }
    return rc;
}

canonical_original_code:
int diminuto_ipcl_remove(char *path)
{
    int rc = 0;
    if (path == (char *)0) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipcl.c", 223, "diminuto_ipcl_remove: NULL");
        rc = -1;
    } else if (unlink(path) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 228, "diminuto_ipcl_remove: unlink");
        rc = -1;
    } else {
    }
    return rc;
}


decompiled_code:
__int64 __fastcall diminuto_ipcl_stream_provider_base(const char *a1, unsigned int a2, __int64 (__fastcall *a3)(_QWORD, __int64), __int64 a4)
{
int v5; // ebp
int v7; // eax
unsigned int v8; // er12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rsi
int v12; // ebx

v5 = a2;
if ( a2 >= 0x81 )
v5 = 128;
v7 = socket(1, 1, 0);
v8 = v7;
if ( v7 >= 0 )
{
if ( !a3
|| (v9 = a3((unsigned int)v7, a4),
v10 = "diminuto_ipcl_stream_provider_base: injector",
v11 = 260LL,
v12 = v9,
v9 >= 0) )
{
v12 = diminuto_ipcl_source(v8, a1);
if ( v12 < 0 )
{
LABEL_11:
diminuto_ipcl_close_isra_0(v8);
return (unsigned int)v12;
}
v12 = listen(v8, v5);
if ( v12 >= 0 )
return v8;
v10 = "diminuto_ipcl_stream_provider_base: listen";
v11 = 265LL;
}
diminuto_log_perror("src/diminuto_ipcl.c", v11, v10);
goto LABEL_11;
}
diminuto_log_perror("src/diminuto_ipcl.c", 258LL, "diminuto_ipcl_stream_provider_base: socket");
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1, unsigned int a2, __int64 (__fastcall *a3)(_QWORD, __int64), __int64 a4)
{
int v5; // ebp
int v7; // eax
unsigned int v8; // er12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rsi
int v12; // ebx

v5 = a2;
if ( a2 >= 0x81 )
v5 = 128;
v7 = socket(1, 1, 0);
v8 = v7;
if ( v7 >= 0 )
{
if ( !a3
|| (v9 = a3((unsigned int)v7, a4),
v10 = "diminuto_ipcl_stream_provider_base: injector",
v11 = 260LL,
v12 = v9,
v9 >= 0) )
{
v12 = func7(v8, a1);
if ( v12 < 0 )
{
LABEL_11:
func0(v8);
return (unsigned int)v12;
}
v12 = listen(v8, v5);
if ( v12 >= 0 )
return v8;
v10 = "diminuto_ipcl_stream_provider_base: listen";
v11 = 265LL;
}
diminuto_log_perror("src/diminuto_ipcl.c", v11, v10);
goto LABEL_11;
}
diminuto_log_perror("src/diminuto_ipcl.c", 258LL, "diminuto_ipcl_stream_provider_base: socket");
return v8;
}

original_code:
int diminuto_ipcl_stream_provider_base(const char * path, int backlog, diminuto_ipc_injector_t * functionp, void * datap)
{
    int rc = -1;
    int fd = -1;
    if (backlog > 128) {
        backlog = 128;
    } else if (backlog < 0) {
        backlog = 128;
    } else {
    }
    if ((rc = fd = socket(1, SOCK_STREAM, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 258, "diminuto_ipcl_stream_provider_base: socket");
    } else if ((functionp != (diminuto_ipc_injector_t *)0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 260, "diminuto_ipcl_stream_provider_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path)) < 0) {
        diminuto_ipcl_close(fd);
    } else if ((rc = listen(fd, backlog)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 265, "diminuto_ipcl_stream_provider_base: listen");
        diminuto_ipcl_close(fd);
    } else {
    }
    return (rc < 0) ? rc : fd;
}

canonical_original_code:
int diminuto_ipcl_stream_provider_base(char *path, int backlog, int (*functionp)(int fd, void *), void *datap)
{
    int rc = -1;
    int fd = -1;
    if (backlog > 128) {
        backlog = 128;
    } else if (backlog < 0) {
        backlog = 128;
    } else {
    }
    if ((rc = fd = socket(1, SOCK_STREAM, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 258, "diminuto_ipcl_stream_provider_base: socket");
    } else if ((functionp != (int (*)(int fd, void *))0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 260, "diminuto_ipcl_stream_provider_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path)) < 0) {
        diminuto_ipcl_close(fd);
    } else if ((rc = listen(fd, backlog)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 265, "diminuto_ipcl_stream_provider_base: listen");
        diminuto_ipcl_close(fd);
    } else {
    }
    return (rc < 0) ? rc : fd;
}

variable_types: backlog int

variable_types:
functionp
int (*)(int fd, void *)

variable_types:
datap
void *


decompiled_code:
__int64 __fastcall diminuto_ipcl_stream_accept_generic(int fd, char *a2, size_t a3)
{
int v4; // er12
socklen_t addr_len; // [rsp+Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-98h] BYREF
int v8; // [rsp+78h] [rbp-30h]
__int16 v9; // [rsp+7Ch] [rbp-2Ch]

addr_len = 110;
memset(&addr, 0, 0x68uLL);
v8 = 0;
v9 = 0;
v4 = accept(fd, &addr, &addr_len);
if ( v4 >= 0 )
{
diminuto_ipcl_identify((__int64)&addr, a2, a3);
}
else if ( *_errno_location() != 4 )
{
diminuto_log_perror("src/diminuto_ipcl.c", 285LL, "diminuto_ipcl_accept_generic: accept");
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func10(int fd, char *a2, size_t a3)
{
int v4; // er12
socklen_t addr_len; // [rsp+Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-98h] BYREF
int v8; // [rsp+78h] [rbp-30h]
__int16 v9; // [rsp+7Ch] [rbp-2Ch]

addr_len = 110;
memset(&addr, 0, 0x68uLL);
v8 = 0;
v9 = 0;
v4 = accept(fd, &addr, &addr_len);
if ( v4 >= 0 )
{
func2((__int64)&addr, a2, a3);
}
else if ( *_errno_location() != 4 )
{
diminuto_log_perror("src/diminuto_ipcl.c", 285LL, "diminuto_ipcl_accept_generic: accept");
}
return (unsigned int)v4;
}

original_code:
int diminuto_ipcl_stream_accept_generic(int fd, char * pathp, size_t psize)
{
    int rc = -1;
    struct sockaddr_un sa = { 0 };
    socklen_t length = sizeof(sa);
    if ((rc = accept(fd, (struct sockaddr *)&sa, &length)) >= 0) {
        diminuto_ipcl_identify((struct sockaddr *)&sa, pathp, psize);
    } else if ((*__errno_location ()) == 4) {
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 285, "diminuto_ipcl_accept_generic: accept");
    }
    return rc;
}

canonical_original_code:
int diminuto_ipcl_stream_accept_generic(int fd, char *pathp, unsigned long psize)
{
    int rc = -1;
    struct sockaddr_un sa = { 0 };
    unsigned int length = sizeof(sa);
    if ((rc = accept(fd, (struct sockaddr *)&sa, &length)) >= 0) {
        diminuto_ipcl_identify((struct sockaddr *)&sa, pathp, psize);
    } else if ((*__errno_location ()) == 4) {
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 285, "diminuto_ipcl_accept_generic: accept");
    }
    return rc;
}

variable_types: rc int


decompiled_code:
__int64 __fastcall diminuto_ipcl_stream_consumer_base(char *src, const char *a2, __int64 (__fastcall *a3)(_QWORD, __int64), __int64 a4)
{
int v7; // eax
unsigned int v8; // er12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rsi
int v12; // ebx
int *v13; // rax
__int64 v14; // rdi
struct sockaddr v16[9]; // [rsp+0h] [rbp-98h] BYREF

v16[0].sa_family = 1;
strncpy(v16[0].sa_data, src, 0x6CuLL);
v7 = socket(1, 1, 0);
v8 = v7;
if ( v7 >= 0 )
{
if ( a3 )
{
v9 = a3((unsigned int)v7, a4);
v10 = "diminuto_ipcl_stream_consumer_base: injector";
v11 = 304LL;
v12 = v9;
if ( v9 < 0 )
goto LABEL_7;
}
v12 = diminuto_ipcl_source(v8, a2);
if ( v12 >= 0 )
{
v12 = connect(v8, v16, 0x6Eu);
if ( v12 >= 0 )
return v8;
v13 = _errno_location();
v10 = "diminuto_ipcl_stream_consumer_base: connect";
v11 = 313LL;
if ( *v13 != 4 )
LABEL_7:
diminuto_log_perror("src/diminuto_ipcl.c", v11, v10);
}
v14 = v8;
v8 = v12;
diminuto_ipcl_close_isra_0(v14);
return v8;
}
diminuto_log_perror("src/diminuto_ipcl.c", 302LL, "diminuto_ipcl_stream_consumer_base: socket");
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func11(char *src, const char *a2, __int64 (__fastcall *a3)(_QWORD, __int64), __int64 a4)
{
int v7; // eax
unsigned int v8; // er12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rsi
int v12; // ebx
int *v13; // rax
__int64 v14; // rdi
struct sockaddr v16[9]; // [rsp+0h] [rbp-98h] BYREF

v16[0].sa_family = 1;
strncpy(v16[0].sa_data, src, 0x6CuLL);
v7 = socket(1, 1, 0);
v8 = v7;
if ( v7 >= 0 )
{
if ( a3 )
{
v9 = a3((unsigned int)v7, a4);
v10 = "diminuto_ipcl_stream_consumer_base: injector";
v11 = 304LL;
v12 = v9;
if ( v9 < 0 )
goto LABEL_7;
}
v12 = func7(v8, a2);
if ( v12 >= 0 )
{
v12 = connect(v8, v16, 0x6Eu);
if ( v12 >= 0 )
return v8;
v13 = _errno_location();
v10 = "diminuto_ipcl_stream_consumer_base: connect";
v11 = 313LL;
if ( *v13 != 4 )
LABEL_7:
diminuto_log_perror("src/diminuto_ipcl.c", v11, v10);
}
v14 = v8;
v8 = v12;
func0(v14);
return v8;
}
diminuto_log_perror("src/diminuto_ipcl.c", 302LL, "diminuto_ipcl_stream_consumer_base: socket");
return v8;
}

original_code:
int diminuto_ipcl_stream_consumer_base(const char * path, const char * path0, diminuto_ipc_injector_t * functionp, void * datap)
{
    int rc = -1;
    int fd = -1;
    struct sockaddr_un sa = { 0 };
    socklen_t length = sizeof(sa);
    sa.sun_family = 1;
    (void)strncpy(sa.sun_path, path, sizeof(sa.sun_path));
    if ((rc = fd = socket(1, SOCK_STREAM, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 302, "diminuto_ipcl_stream_consumer_base: socket");
    } else if ((functionp != (diminuto_ipc_injector_t *)0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 304, "diminuto_ipcl_stream_consumer_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path0)) < 0) {
        diminuto_ipcl_close(fd);
    } else if ((rc = connect(fd, (struct sockaddr *)&sa, length)) >= 0) {
    } else if ((*__errno_location ()) == 4) {
        diminuto_ipcl_close(fd);
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 313, "diminuto_ipcl_stream_consumer_base: connect");
        diminuto_ipcl_close(fd);
    }
    return (rc < 0) ? rc : fd;
}

canonical_original_code:
int diminuto_ipcl_stream_consumer_base(char *path, char *path0, int (*functionp)(int fd, void *), void *datap)
{
    int rc = -1;
    int fd = -1;
    struct sockaddr_un sa = { 0 };
    unsigned int length = sizeof(sa);
    sa.sun_family = 1;
    (void)strncpy(sa.sun_path, path, sizeof(sa.sun_path));
    if ((rc = fd = socket(1, SOCK_STREAM, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 302, "diminuto_ipcl_stream_consumer_base: socket");
    } else if ((functionp != (int (*)(int fd, void *))0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 304, "diminuto_ipcl_stream_consumer_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path0)) < 0) {
        diminuto_ipcl_close(fd);
    } else if ((rc = connect(fd, (struct sockaddr *)&sa, length)) >= 0) {
    } else if ((*__errno_location ()) == 4) {
        diminuto_ipcl_close(fd);
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 313, "diminuto_ipcl_stream_consumer_base: connect");
        diminuto_ipcl_close(fd);
    }
    return (rc < 0) ? rc : fd;
}


decompiled_code:
__int64 __fastcall diminuto_ipcl_datagram_peer_base(const char *a1, __int64 (__fastcall *a2)(_QWORD, __int64), __int64 a3)
{
int v4; // eax
unsigned int v5; // er12
int v6; // ebx
int v7; // eax
__int64 result; // rax
__int64 v9; // rdi

v4 = socket(1, 2, 0);
v5 = v4;
if ( v4 < 0 )
{
diminuto_log_perror("src/diminuto_ipcl.c", 330LL, "diminuto_ipcl_datagram_peer_base: socket");
result = v5;
}
else if ( a2 && (v6 = a2((unsigned int)v4, a3), v6 < 0) )
{
diminuto_log_perror("src/diminuto_ipcl.c", 332LL, "diminuto_ipcl_datagram_peer_base: injector");
diminuto_ipcl_close_isra_0(v5);
result = (unsigned int)v6;
}
else
{
v7 = diminuto_ipcl_source(v5, a1);
if ( v7 < 0 )
{
v9 = v5;
v5 = v7;
diminuto_ipcl_close_isra_0(v9);
}
result = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(const char *a1, __int64 (__fastcall *a2)(_QWORD, __int64), __int64 a3)
{
int v4; // eax
unsigned int v5; // er12
int v6; // ebx
int v7; // eax
__int64 result; // rax
__int64 v9; // rdi

v4 = socket(1, 2, 0);
v5 = v4;
if ( v4 < 0 )
{
diminuto_log_perror("src/diminuto_ipcl.c", 330LL, "diminuto_ipcl_datagram_peer_base: socket");
result = v5;
}
else if ( a2 && (v6 = a2((unsigned int)v4, a3), v6 < 0) )
{
diminuto_log_perror("src/diminuto_ipcl.c", 332LL, "diminuto_ipcl_datagram_peer_base: injector");
func0(v5);
result = (unsigned int)v6;
}
else
{
v7 = func7(v5, a1);
if ( v7 < 0 )
{
v9 = v5;
v5 = v7;
func0(v9);
}
result = v5;
}
return result;
}

original_code:
int diminuto_ipcl_datagram_peer_base(const char * path, diminuto_ipc_injector_t * functionp, void * datap)
{
    int rc = -1;
    int fd = -1;
    if ((rc = fd = socket(1, SOCK_DGRAM, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 330, "diminuto_ipcl_datagram_peer_base: socket");
    } else if ((functionp != (diminuto_ipc_injector_t *)0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 332, "diminuto_ipcl_datagram_peer_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path)) < 0) {
        diminuto_ipcl_close(fd);
    } else {
    }
    return (rc < 0) ? rc : fd;
}

canonical_original_code:
int diminuto_ipcl_datagram_peer_base(char *path, int (*functionp)(int fd, void *), void *datap)
{
    int rc = -1;
    int fd = -1;
    if ((rc = fd = socket(1, SOCK_DGRAM, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 330, "diminuto_ipcl_datagram_peer_base: socket");
    } else if ((functionp != (int (*)(int fd, void *))0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 332, "diminuto_ipcl_datagram_peer_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path)) < 0) {
        diminuto_ipcl_close(fd);
    } else {
    }
    return (rc < 0) ? rc : fd;
}


decompiled_code:
ssize_t __fastcall diminuto_ipcl_datagram_receive_generic(int fd, void *a2, size_t a3, char *a4, size_t a5, int a6)
{
ssize_t v8; // rax
ssize_t v9; // r12
int v11; // eax
socklen_t addr_len; // [rsp+Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-98h] BYREF
int v14; // [rsp+78h] [rbp-30h]
__int16 v15; // [rsp+7Ch] [rbp-2Ch]

addr_len = 110;
memset(&addr, 0, 0x68uLL);
v14 = 0;
v15 = 0;
v8 = recvfrom(fd, a2, a3, a6, &addr, &addr_len);
v9 = v8;
if ( v8 > 0 )
{
diminuto_ipcl_identify((__int64)&addr, a4, a5);
}
else if ( v8 )
{
v11 = *_errno_location();
if ( v11 != 11 && v11 != 4 )
diminuto_log_perror("src/diminuto_ipcl.c", 360LL, "diminuto_ipcl_datagram_receive_generic: recvfrom");
}
return v9;
}

canonical_decompiled_code:
ssize_t __fastcall func13(int fd, void *a2, size_t a3, char *a4, size_t a5, int a6)
{
ssize_t v8; // rax
ssize_t v9; // r12
int v11; // eax
socklen_t addr_len; // [rsp+Ch] [rbp-9Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-98h] BYREF
int v14; // [rsp+78h] [rbp-30h]
__int16 v15; // [rsp+7Ch] [rbp-2Ch]

addr_len = 110;
memset(&addr, 0, 0x68uLL);
v14 = 0;
v15 = 0;
v8 = recvfrom(fd, a2, a3, a6, &addr, &addr_len);
v9 = v8;
if ( v8 > 0 )
{
func2((__int64)&addr, a4, a5);
}
else if ( v8 )
{
v11 = *_errno_location();
if ( v11 != 11 && v11 != 4 )
diminuto_log_perror("src/diminuto_ipcl.c", 360LL, "diminuto_ipcl_datagram_receive_generic: recvfrom");
}
return v9;
}

original_code:
ssize_t diminuto_ipcl_datagram_receive_generic(int fd, void * buffer, size_t size, char * pathp, size_t psize, int flags)
{
    ssize_t total = -1;
    struct sockaddr_un sa = { 0 };
    socklen_t length = sizeof(sa);
    if ((total = recvfrom(fd, buffer, size, flags, (struct sockaddr *)&sa, &length)) > 0) {
        diminuto_ipcl_identify((struct sockaddr *)&sa, pathp, psize);
    } else if (total == 0) {
    } else if ((*__errno_location ()) == 4) {
    } else if ((*__errno_location ()) == 11) {
    } else if ((*__errno_location ()) == 11) {
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 360, "diminuto_ipcl_datagram_receive_generic: recvfrom");
    }
    return total;
}

canonical_original_code:
long diminuto_ipcl_datagram_receive_generic(int fd, void *buffer, unsigned long size, char *pathp, unsigned long psize, int flags)
{
    long total = -1;
    struct sockaddr_un sa = { 0 };
    unsigned int length = sizeof(sa);
    if ((total = recvfrom(fd, buffer, size, flags, (struct sockaddr *)&sa, &length)) > 0) {
        diminuto_ipcl_identify((struct sockaddr *)&sa, pathp, psize);
    } else if (total == 0) {
    } else if ((*__errno_location ()) == 4) {
    } else if ((*__errno_location ()) == 11) {
    } else if ((*__errno_location ()) == 11) {
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 360, "diminuto_ipcl_datagram_receive_generic: recvfrom");
    }
    return total;
}

variable_types:
buffer
void *

variable_types: flags int

variable_types: total long

return_type: long


decompiled_code:
ssize_t __fastcall diminuto_ipcl_datagram_send_generic(int fd, void *buf, size_t n, struct sockaddr *addr, int flags)
{
socklen_t v6; // er9
struct sockaddr *v9; // rsi
ssize_t v10; // r12
int v12; // eax
__int16 v13[52]; // [rsp+0h] [rbp-98h] BYREF
int v14; // [rsp+68h] [rbp-30h]
__int16 v15; // [rsp+6Ch] [rbp-2Ch]

v6 = 0;
v9 = addr;
memset(v13, 0, sizeof(v13));
v14 = 0;
v15 = 0;
if ( addr )
{
v13[0] = 1;
strncpy((char *)&v13[1], (const char *)addr, 0x6CuLL);
v6 = 110;
v9 = (struct sockaddr *)v13;
}
v10 = sendto(fd, buf, n, flags, v9, v6);
if ( v10 < 0 )
{
v12 = *_errno_location();
if ( v12 != 11 && v12 != 4 )
diminuto_log_perror("src/diminuto_ipcl.c", 391LL, "diminuto_ipcl_datagram_send_generic: sendto");
}
return v10;
}

canonical_decompiled_code:
ssize_t __fastcall func14(int fd, void *buf, size_t n, struct sockaddr *addr, int flags)
{
socklen_t v6; // er9
struct sockaddr *v9; // rsi
ssize_t v10; // r12
int v12; // eax
__int16 v13[52]; // [rsp+0h] [rbp-98h] BYREF
int v14; // [rsp+68h] [rbp-30h]
__int16 v15; // [rsp+6Ch] [rbp-2Ch]

v6 = 0;
v9 = addr;
memset(v13, 0, sizeof(v13));
v14 = 0;
v15 = 0;
if ( addr )
{
v13[0] = 1;
strncpy((char *)&v13[1], (const char *)addr, 0x6CuLL);
v6 = 110;
v9 = (struct sockaddr *)v13;
}
v10 = sendto(fd, buf, n, flags, v9, v6);
if ( v10 < 0 )
{
v12 = *_errno_location();
if ( v12 != 11 && v12 != 4 )
diminuto_log_perror("src/diminuto_ipcl.c", 391LL, "diminuto_ipcl_datagram_send_generic: sendto");
}
return v10;
}

original_code:
ssize_t diminuto_ipcl_datagram_send_generic(int fd, const void * buffer, size_t size, const char * path, int flags)
{
    ssize_t total = -1;
    struct sockaddr_un sa = { 0, };
    struct sockaddr * sap = (struct sockaddr *)0;
    socklen_t length = 0;
    if (path != (const char *)0) {
        length = sizeof(sa);
        sa.sun_family = 1;
        (void)strncpy(sa.sun_path, path, sizeof(sa.sun_path));
        sap = (struct sockaddr *)&sa;
    }
    if ((total = sendto(fd, buffer, size, flags, sap, length)) > 0) {
    } else if (total == 0) {
    } else if ((*__errno_location ()) == 4) {
    } else if ((*__errno_location ()) == 11) {
    } else if ((*__errno_location ()) == 11) {
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 391, "diminuto_ipcl_datagram_send_generic: sendto");
    }
    return total;
}

canonical_original_code:
long diminuto_ipcl_datagram_send_generic(int fd, void *buffer, unsigned long size, char *path, int flags)
{
    long total = -1;
    struct sockaddr_un sa = { 0, };
    struct sockaddr *sap = (struct sockaddr *)0;
    unsigned int length = 0;
    if (path != (char *)0) {
        length = sizeof(sa);
        sa.sun_family = 1;
        (void)strncpy(sa.sun_path, path, sizeof(sa.sun_path));
        sap = (struct sockaddr *)&sa;
    }
    if ((total = sendto(fd, buffer, size, flags, sap, length)) > 0) {
    } else if (total == 0) {
    } else if ((*__errno_location ()) == 4) {
    } else if ((*__errno_location ()) == 11) {
    } else if ((*__errno_location ()) == 11) {
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 391, "diminuto_ipcl_datagram_send_generic: sendto");
    }
    return total;
}

variable_types:
size
unsigned long

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


decompiled_code:
__int64 __fastcall diminuto_ipcl_packet_provider_base(const char *a1, unsigned int a2, __int64 (__fastcall *a3)(_QWORD, __int64), __int64 a4)
{
int v5; // ebp
int v7; // eax
unsigned int v8; // er12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rsi
int v12; // ebx

v5 = a2;
if ( a2 >= 0x81 )
v5 = 128;
v7 = socket(1, 5, 0);
v8 = v7;
if ( v7 >= 0 )
{
if ( !a3
|| (v9 = a3((unsigned int)v7, a4),
v10 = "diminuto_ipcl_packet_provider_base: injector",
v11 = 417LL,
v12 = v9,
v9 >= 0) )
{
v12 = diminuto_ipcl_source(v8, a1);
if ( v12 < 0 )
{
LABEL_11:
diminuto_ipcl_close_isra_0(v8);
return (unsigned int)v12;
}
v12 = listen(v8, v5);
if ( v12 >= 0 )
return v8;
v10 = "diminuto_ipcl_packet_provider_base: listen";
v11 = 422LL;
}
diminuto_log_perror("src/diminuto_ipcl.c", v11, v10);
goto LABEL_11;
}
diminuto_log_perror("src/diminuto_ipcl.c", 415LL, "diminuto_ipcl_packet_provider_base: socket");
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func15(const char *a1, unsigned int a2, __int64 (__fastcall *a3)(_QWORD, __int64), __int64 a4)
{
int v5; // ebp
int v7; // eax
unsigned int v8; // er12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rsi
int v12; // ebx

v5 = a2;
if ( a2 >= 0x81 )
v5 = 128;
v7 = socket(1, 5, 0);
v8 = v7;
if ( v7 >= 0 )
{
if ( !a3
|| (v9 = a3((unsigned int)v7, a4),
v10 = "diminuto_ipcl_packet_provider_base: injector",
v11 = 417LL,
v12 = v9,
v9 >= 0) )
{
v12 = func7(v8, a1);
if ( v12 < 0 )
{
LABEL_11:
func0(v8);
return (unsigned int)v12;
}
v12 = listen(v8, v5);
if ( v12 >= 0 )
return v8;
v10 = "diminuto_ipcl_packet_provider_base: listen";
v11 = 422LL;
}
diminuto_log_perror("src/diminuto_ipcl.c", v11, v10);
goto LABEL_11;
}
diminuto_log_perror("src/diminuto_ipcl.c", 415LL, "diminuto_ipcl_packet_provider_base: socket");
return v8;
}

original_code:
int diminuto_ipcl_packet_provider_base(const char * path, int backlog, diminuto_ipc_injector_t * functionp, void * datap)
{
    int rc = -1;
    int fd = -1;
    if (backlog > 128) {
        backlog = 128;
    } else if (backlog < 0) {
        backlog = 128;
    } else {
    }
    if ((rc = fd = socket(1, SOCK_SEQPACKET, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 415, "diminuto_ipcl_packet_provider_base: socket");
    } else if ((functionp != (diminuto_ipc_injector_t *)0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 417, "diminuto_ipcl_packet_provider_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path)) < 0) {
        diminuto_ipcl_close(fd);
    } else if ((rc = listen(fd, backlog)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 422, "diminuto_ipcl_packet_provider_base: listen");
        diminuto_ipcl_close(fd);
    } else {
    }
    return (rc < 0) ? rc : fd;
}

canonical_original_code:
int diminuto_ipcl_packet_provider_base(char *path, int backlog, int (*functionp)(int fd, void *), void *datap)
{
    int rc = -1;
    int fd = -1;
    if (backlog > 128) {
        backlog = 128;
    } else if (backlog < 0) {
        backlog = 128;
    } else {
    }
    if ((rc = fd = socket(1, SOCK_SEQPACKET, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 415, "diminuto_ipcl_packet_provider_base: socket");
    } else if ((functionp != (int (*)(int fd, void *))0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 417, "diminuto_ipcl_packet_provider_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path)) < 0) {
        diminuto_ipcl_close(fd);
    } else if ((rc = listen(fd, backlog)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 422, "diminuto_ipcl_packet_provider_base: listen");
        diminuto_ipcl_close(fd);
    } else {
    }
    return (rc < 0) ? rc : fd;
}

variable_types:
path
char *


decompiled_code:
__int64 __fastcall diminuto_ipcl_packet_consumer_base(char *src, const char *a2, __int64 (__fastcall *a3)(_QWORD, __int64), __int64 a4)
{
int v7; // eax
unsigned int v8; // er12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rsi
int v12; // ebx
int *v13; // rax
__int64 v14; // rdi
struct sockaddr v16[9]; // [rsp+0h] [rbp-98h] BYREF

v16[0].sa_family = 1;
strncpy(v16[0].sa_data, src, 0x6CuLL);
v7 = socket(1, 5, 0);
v8 = v7;
if ( v7 >= 0 )
{
if ( a3 )
{
v9 = a3((unsigned int)v7, a4);
v10 = "diminuto_ipcl_packet_consumer_base: injector";
v11 = 444LL;
v12 = v9;
if ( v9 < 0 )
goto LABEL_7;
}
v12 = diminuto_ipcl_source(v8, a2);
if ( v12 >= 0 )
{
v12 = connect(v8, v16, 0x6Eu);
if ( v12 >= 0 )
return v8;
v13 = _errno_location();
v10 = "diminuto_ipcl_stream_consumer_base: connect";
v11 = 453LL;
if ( *v13 != 4 )
LABEL_7:
diminuto_log_perror("src/diminuto_ipcl.c", v11, v10);
}
v14 = v8;
v8 = v12;
diminuto_ipcl_close_isra_0(v14);
return v8;
}
diminuto_log_perror("src/diminuto_ipcl.c", 442LL, "diminuto_ipcl_packet_consumer_base: socket");
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func16(char *src, const char *a2, __int64 (__fastcall *a3)(_QWORD, __int64), __int64 a4)
{
int v7; // eax
unsigned int v8; // er12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rsi
int v12; // ebx
int *v13; // rax
__int64 v14; // rdi
struct sockaddr v16[9]; // [rsp+0h] [rbp-98h] BYREF

v16[0].sa_family = 1;
strncpy(v16[0].sa_data, src, 0x6CuLL);
v7 = socket(1, 5, 0);
v8 = v7;
if ( v7 >= 0 )
{
if ( a3 )
{
v9 = a3((unsigned int)v7, a4);
v10 = "diminuto_ipcl_packet_consumer_base: injector";
v11 = 444LL;
v12 = v9;
if ( v9 < 0 )
goto LABEL_7;
}
v12 = func7(v8, a2);
if ( v12 >= 0 )
{
v12 = connect(v8, v16, 0x6Eu);
if ( v12 >= 0 )
return v8;
v13 = _errno_location();
v10 = "diminuto_ipcl_stream_consumer_base: connect";
v11 = 453LL;
if ( *v13 != 4 )
LABEL_7:
diminuto_log_perror("src/diminuto_ipcl.c", v11, v10);
}
v14 = v8;
v8 = v12;
func0(v14);
return v8;
}
diminuto_log_perror("src/diminuto_ipcl.c", 442LL, "diminuto_ipcl_packet_consumer_base: socket");
return v8;
}

original_code:
int diminuto_ipcl_packet_consumer_base(const char * path, const char * path0, diminuto_ipc_injector_t * functionp, void * datap)
{
    int rc = -1;
    int fd = -1;
    struct sockaddr_un sa = { 0 };
    socklen_t length = sizeof(sa);
    sa.sun_family = 1;
    (void)strncpy(sa.sun_path, path, sizeof(sa.sun_path));
    if ((rc = fd = socket(1, SOCK_SEQPACKET, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 442, "diminuto_ipcl_packet_consumer_base: socket");
    } else if ((functionp != (diminuto_ipc_injector_t *)0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 444, "diminuto_ipcl_packet_consumer_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path0)) < 0) {
        diminuto_ipcl_close(fd);
    } else if ((rc = connect(fd, (struct sockaddr *)&sa, length)) >= 0) {
    } else if ((*__errno_location ()) == 4) {
        diminuto_ipcl_close(fd);
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 453, "diminuto_ipcl_stream_consumer_base: connect");
        diminuto_ipcl_close(fd);
    }
    return (rc < 0) ? rc : fd;
}

canonical_original_code:
int diminuto_ipcl_packet_consumer_base(char *path, char *path0, int (*functionp)(int fd, void *), void *datap)
{
    int rc = -1;
    int fd = -1;
    struct sockaddr_un sa = { 0 };
    unsigned int length = sizeof(sa);
    sa.sun_family = 1;
    (void)strncpy(sa.sun_path, path, sizeof(sa.sun_path));
    if ((rc = fd = socket(1, SOCK_SEQPACKET, 0)) < 0) {
        diminuto_log_perror("src/diminuto_ipcl.c", 442, "diminuto_ipcl_packet_consumer_base: socket");
    } else if ((functionp != (int (*)(int fd, void *))0) && ((rc = (*functionp)(fd, datap)) < 0)) {
        diminuto_log_perror("src/diminuto_ipcl.c", 444, "diminuto_ipcl_packet_consumer_base: injector");
        diminuto_ipcl_close(fd);
    } else if ((rc = diminuto_ipcl_source(fd, path0)) < 0) {
        diminuto_ipcl_close(fd);
    } else if ((rc = connect(fd, (struct sockaddr *)&sa, length)) >= 0) {
    } else if ((*__errno_location ()) == 4) {
        diminuto_ipcl_close(fd);
    } else {
        diminuto_log_perror("src/diminuto_ipcl.c", 453, "diminuto_ipcl_stream_consumer_base: connect");
        diminuto_ipcl_close(fd);
    }
    return (rc < 0) ? rc : fd;
}


decompiled_code:
_BOOL8 __fastcall diminuto_store_ismissing(__int64 a1)
{
return a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1)
{
return a1 == 0;
}

original_code:
static inline int diminuto_store_ismissing(const diminuto_store_t * nodep)
{
    return (nodep == ((diminuto_store_t *)0));
}

canonical_original_code:
static inline int diminuto_store_ismissing(struct DiminutoStore *nodep)
{
    return (nodep == ((struct DiminutoStore *)0));
}

variable_types: struct DiminutoStore { struct DiminutoTree { struct DiminutoTree *parent; struct DiminutoTree *left; struct DiminutoTree *right; struct DiminutoTree **root; void *data; unsigned long color; unsigned long error; } tree; void *key; void *value; } *

user_defined_types: struct DiminutoStore { struct DiminutoTree tree; void *key; void *value; }


decompiled_code:
__int64 __fastcall diminuto_store_upcast(__int64 a1)
{
bool v1; // zf
__int64 result; // rax

v1 = !diminuto_store_ismissing(a1);
result = 0LL;
if ( v1 )
result = a1;
return result;
}

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

v1 = !func0(a1);
result = 0LL;
if ( v1 )
result = a1;
return result;
}

original_code:
static inline diminuto_tree_t * diminuto_store_upcast(const diminuto_store_t * pointer)
{
    return diminuto_store_ismissing(pointer) ? ((diminuto_tree_t *)0) : (diminuto_tree_t *)&(pointer->tree);
}

canonical_original_code:
static inline struct DiminutoTree *diminuto_store_upcast(struct DiminutoStore *pointer)
{
    return diminuto_store_ismissing(pointer) ? ((struct DiminutoTree *)0) : (struct DiminutoTree *)&(pointer->tree);
}

variable_types: struct DiminutoStore { struct DiminutoTree tree; void *key; void *value; } *

return_type: struct DiminutoTree { struct DiminutoTree *parent; struct DiminutoTree *left; struct DiminutoTree *right; struct DiminutoTree **root; void *data; unsigned long color; unsigned long error; } *


decompiled_code:
__int64 __fastcall diminuto_store_log(const void **a1)
{
__int64 v1; // rax

if ( !a1 )
return diminuto_log_emit("diminuto_store_t@%p[%zu]\n", 0LL, 0x40uLL);
diminuto_log_emit("diminuto_store_t@%p[%zu]: { key=%p value=%p }\n", a1, 0x40uLL, a1[6], a1[7]);
v1 = diminuto_store_upcast((__int64)a1);
return diminuto_tree_log(v1);
}

canonical_decompiled_code:
__int64 __fastcall func2(const void **a1)
{
__int64 v1; // rax

if ( !a1 )
return diminuto_log_emit("diminuto_store_t@%p[%zu]\n", 0LL, 0x40uLL);
diminuto_log_emit("diminuto_store_t@%p[%zu]: { key=%p value=%p }\n", a1, 0x40uLL, a1[6], a1[7]);
v1 = func1((__int64)a1);
return diminuto_tree_log(v1);
}

original_code:
void diminuto_store_log(diminuto_store_t * nodep)
{
    if (nodep) {
        diminuto_log_emit("diminuto_store_t@%p[%zu]: { key=%p value=%p }\n", nodep, sizeof(*nodep), nodep->key, nodep->value);
        diminuto_tree_log(diminuto_store_upcast(nodep));
    } else {
        diminuto_log_emit("diminuto_store_t@%p[%zu]\n", nodep, sizeof(*nodep));
    }
}

canonical_original_code:
void diminuto_store_log(struct DiminutoStore *nodep)
{
    if (nodep) {
        diminuto_log_emit("diminuto_store_t@%p[%zu]: { key=%p value=%p }\n", nodep, sizeof(*nodep), nodep->key, nodep->value);
        diminuto_tree_log(diminuto_store_upcast(nodep));
    } else {
        diminuto_log_emit("diminuto_store_t@%p[%zu]\n", nodep, sizeof(*nodep));
    }
}

user_defined_types: struct DiminutoTree { struct DiminutoTree *parent; struct DiminutoTree *left; struct DiminutoTree *right; struct DiminutoTree **root; void *data; unsigned long color; unsigned long error; }


decompiled_code:
_BOOL8 __fastcall diminuto_throttle_emptied(__int64 a1)
{
return (*(_BYTE *)(a1 + 48) & 0x30) == 16;
}

original_code:
static inline int diminuto_throttle_emptied(const diminuto_throttle_t * throttlep)
{
    return (throttlep->empty1 != 0) && (throttlep->empty2 == 0);
}

canonical_original_code:
static inline int diminuto_throttle_emptied(struct DiminutoThrottle *throttlep)
{
    return (throttlep->empty1 != 0) && (throttlep->empty2 == 0);
}

variable_types: struct DiminutoThrottle { unsigned long now; unsigned long then; unsigned long increment; unsigned long limit; unsigned long expected; unsigned long actual; unsigned long full0; unsigned long full1; unsigned long full2; unsigned long empty0; unsigned long empty1; unsigned long empty2; unsigned long alarmed1; unsigned long alarmed2; } *


decompiled_code:
_BOOL8 __fastcall diminuto_throttle_filled(__int64 a1)
{
return (*(_BYTE *)(a1 + 48) & 6) == 2;
}

original_code:
static inline int diminuto_throttle_filled(const diminuto_throttle_t * throttlep)
{
    return (throttlep->full1 != 0) && (throttlep->full2 == 0);
}

canonical_original_code:
static inline int diminuto_throttle_filled(struct DiminutoThrottle *throttlep)
{
    return (throttlep->full1 != 0) && (throttlep->full2 == 0);
}

user_defined_types: struct DiminutoThrottle { unsigned long now; unsigned long then; unsigned long increment; unsigned long limit; unsigned long expected; unsigned long actual; unsigned long full0; unsigned long full1; unsigned long full2; unsigned long empty0; unsigned long empty1; unsigned long empty2; unsigned long alarmed1; unsigned long alarmed2; }


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

result = a3;
if ( a2 > 1 )
result = a2 * a3;
if ( a1 > 1 )
result = result / a1 - ((result % a1 == 0) - 1LL);
return result;
}

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

result = a3;
if ( a2 > 1 )
result = a2 * a3;
if ( a1 > 1 )
result = result / a1 - ((result % a1 == 0) - 1LL);
return result;
}

original_code:
diminuto_ticks_t diminuto_throttle_interarrivaltime(size_t numerator, size_t denominator, diminuto_ticks_t frequency)
{
    diminuto_ticks_t increment = 0;
    increment = frequency;
    if (denominator > 1) {
        increment *= denominator;
    }
    if (numerator <= 1) {
    } else if ((increment % numerator) > 0) {
        increment /= numerator;
        increment += 1;
    } else {
        increment /= numerator;
    }
    return increment;
}

canonical_original_code:
unsigned long diminuto_throttle_interarrivaltime(unsigned long numerator, unsigned long denominator, unsigned long frequency)
{
    unsigned long increment = 0;
    increment = frequency;
    if (denominator > 1) {
        increment *= denominator;
    }
    if (numerator <= 1) {
    } else if ((increment % numerator) > 0) {
        increment /= numerator;
        increment += 1;
    } else {
        increment /= numerator;
    }
    return increment;
}

variable_types:
numerator
unsigned long

variable_types:
denominator
unsigned long

variable_types:
frequency
unsigned long

variable_types:
increment
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall diminuto_throttle_jittertolerance(__int64 a1, unsigned __int64 a2)
{
__int64 result; // rax

result = 0LL;
if ( a2 > 1 )
result = a1 * (a2 - 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned __int64 a2)
{
__int64 result; // rax

result = 0LL;
if ( a2 > 1 )
result = a1 * (a2 - 1);
return result;
}

original_code:
diminuto_ticks_t diminuto_throttle_jittertolerance(diminuto_ticks_t increment, size_t maximumburstsize)
{
    diminuto_ticks_t limit = 0;
    if (maximumburstsize > 1) {
        limit = maximumburstsize - 1;
        limit *= increment;
    }
    return limit;
}

canonical_original_code:
unsigned long diminuto_throttle_jittertolerance(unsigned long increment, unsigned long maximumburstsize)
{
    unsigned long limit = 0;
    if (maximumburstsize > 1) {
        limit = maximumburstsize - 1;
        limit *= increment;
    }
    return limit;
}

variable_types:
maximumburstsize
unsigned long

variable_types:
limit
unsigned long


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

*(_QWORD *)a1 = a2;
result = a1;
*(_QWORD *)(a1 + 8) = a2 - *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)(a1 + 40) = 0LL;
*(_BYTE *)(a1 + 48) = 56;
return result;
}

original_code:
diminuto_throttle_t * diminuto_throttle_reset(diminuto_throttle_t * throttlep, diminuto_ticks_t now)
{
    throttlep->now = now;
    throttlep->then = now - throttlep->increment;
    throttlep->expected = 0;
    throttlep->actual = 0;
    throttlep->full0 = throttlep->full1 = throttlep->full2 = 0;
    throttlep->empty0 = throttlep->empty1 = throttlep->empty2 = !0;
    throttlep->alarmed1 = throttlep->alarmed2 = 0;
    return throttlep;
}

canonical_original_code:
struct DiminutoThrottle *diminuto_throttle_reset(struct DiminutoThrottle *throttlep, unsigned long now)
{
    throttlep->now = now;
    throttlep->then = now - throttlep->increment;
    throttlep->expected = 0;
    throttlep->actual = 0;
    throttlep->full0 = throttlep->full1 = throttlep->full2 = 0;
    throttlep->empty0 = throttlep->empty1 = throttlep->empty2 = !0;
    throttlep->alarmed1 = throttlep->alarmed2 = 0;
    return throttlep;
}

variable_types:
throttlep
struct DiminutoThrottle *

variable_types:
now
unsigned long

return_type: struct DiminutoThrottle { unsigned long now; unsigned long then; unsigned long increment; unsigned long limit; unsigned long expected; unsigned long actual; unsigned long full0; unsigned long full1; unsigned long full2; unsigned long empty0; unsigned long empty1; unsigned long empty2; unsigned long alarmed1; unsigned long alarmed2; } *


decompiled_code:
__int64 __fastcall diminuto_throttle_init(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
*(_QWORD *)(a1 + 24) = a3;
*(_QWORD *)(a1 + 16) = a2;
return diminuto_throttle_reset(a1, a4);
}

original_code:
diminuto_throttle_t * diminuto_throttle_init(diminuto_throttle_t * throttlep, diminuto_ticks_t increment, diminuto_ticks_t limit, diminuto_ticks_t now)
{
    throttlep->increment = increment;
    throttlep->limit = limit;
    return diminuto_throttle_reset(throttlep, now);
}

canonical_original_code:
struct DiminutoThrottle *diminuto_throttle_init(struct DiminutoThrottle *throttlep, unsigned long increment, unsigned long limit, unsigned long now)
{
    throttlep->increment = increment;
    throttlep->limit = limit;
    return diminuto_throttle_reset(throttlep, now);
}


decompiled_code:
unsigned __int64 __fastcall diminuto_throttle_request(__int64 a1, __int64 a2)
{
__int64 v2; // rax
unsigned __int64 v3; // rdx
char v4; // al
unsigned __int64 result; // rax
unsigned __int64 v6; // rcx
unsigned __int64 v7; // rax

v2 = *(_QWORD *)(a1 + 8);
v3 = *(_QWORD *)(a1 + 32);
*(_QWORD *)a1 = a2;
if ( v3 > a2 - v2 )
{
v6 = *(_QWORD *)(a1 + 24);
v7 = v3 + v2 - a2;
*(_QWORD *)(a1 + 40) = v7;
if ( v7 > v6 )
{
result = v7 - v6;
*(_BYTE *)(a1 + 48) = *(_BYTE *)(a1 + 48) & 0xF6 | 1;
}
else
{
*(_BYTE *)(a1 + 48) &= 0xF6u;
result = 0LL;
}
}
else
{
v4 = *(_BYTE *)(a1 + 48);
*(_QWORD *)(a1 + 40) = 0LL;
*(_BYTE *)(a1 + 48) = v4 & 0xF6 | 8;
result = 0LL;
}
return result;
}

original_code:
diminuto_ticks_t diminuto_throttle_request(diminuto_throttle_t * throttlep, diminuto_ticks_t now)
{
    diminuto_ticks_t delay = 0;
    diminuto_ticks_t elapsed = 0;
    elapsed = (throttlep->now = now) - throttlep->then;
    if (throttlep->expected <= elapsed) {
        throttlep->actual = 0;
        throttlep->full0 = 0;
        throttlep->empty0 = !0;
        delay = 0;
    } else if ((throttlep->actual = throttlep->expected - elapsed) <= throttlep->limit) {
        throttlep->full0 = 0;
        throttlep->empty0 = 0;
        delay = 0;
    } else {
        throttlep->full0 = !0;
        throttlep->empty0 = 0;
        delay = throttlep->actual - throttlep->limit;
    }
    return delay;
}

canonical_original_code:
unsigned long diminuto_throttle_request(struct DiminutoThrottle *throttlep, unsigned long now)
{
    unsigned long delay = 0;
    unsigned long elapsed = 0;
    elapsed = (throttlep->now = now) - throttlep->then;
    if (throttlep->expected <= elapsed) {
        throttlep->actual = 0;
        throttlep->full0 = 0;
        throttlep->empty0 = !0;
        delay = 0;
    } else if ((throttlep->actual = throttlep->expected - elapsed) <= throttlep->limit) {
        throttlep->full0 = 0;
        throttlep->empty0 = 0;
        delay = 0;
    } else {
        throttlep->full0 = !0;
        throttlep->empty0 = 0;
        delay = throttlep->actual - throttlep->limit;
    }
    return delay;
}

variable_types:
delay
unsigned long

variable_types:
elapsed
unsigned long


original_code:
int diminuto_throttle_commitn(diminuto_throttle_t * throttlep, size_t events)
{
    throttlep->then = throttlep->now;
    throttlep->expected = throttlep->actual + (events * throttlep->increment);
    throttlep->full2 = throttlep->full1;
    throttlep->full1 = throttlep->full0;
    throttlep->empty2 = throttlep->empty1;
    throttlep->empty1 = throttlep->empty0;
    throttlep->alarmed2 = throttlep->alarmed1;
    if (diminuto_throttle_emptied(throttlep)) {
        throttlep->alarmed1 = 0;
    } else if (diminuto_throttle_filled(throttlep)) {
        throttlep->alarmed1 = !0;
    } else {
    }
    return throttlep->alarmed1;
}

canonical_original_code:
int diminuto_throttle_commitn(struct DiminutoThrottle *throttlep, unsigned long events)
{
    throttlep->then = throttlep->now;
    throttlep->expected = throttlep->actual + (events * throttlep->increment);
    throttlep->full2 = throttlep->full1;
    throttlep->full1 = throttlep->full0;
    throttlep->empty2 = throttlep->empty1;
    throttlep->empty1 = throttlep->empty0;
    throttlep->alarmed2 = throttlep->alarmed1;
    if (diminuto_throttle_emptied(throttlep)) {
        throttlep->alarmed1 = 0;
    } else if (diminuto_throttle_filled(throttlep)) {
        throttlep->alarmed1 = !0;
    } else {
    }
    return throttlep->alarmed1;
}

variable_types:
events
unsigned long


original_code:
void diminuto_throttle_log(const diminuto_throttle_t * throttlep)
{
    if (throttlep != (diminuto_throttle_t *)0) {
        diminuto_log_emit("diminuto_throttle_t@%p[%zu]: { iat=%llu i=%llu l=%llu x=%llu x1=%llu f=%d,%d,%d e=%d,%d,%d a=%d,%d }\n", throttlep, sizeof(*throttlep), (diminuto_llu_t)(throttlep->now - throttlep->then), (diminuto_llu_t)throttlep->increment, (diminuto_llu_t)throttlep->limit, (diminuto_llu_t)throttlep->expected, (diminuto_llu_t)throttlep->actual, throttlep->full0, throttlep->full1, throttlep->full2, throttlep->empty0, throttlep->empty1, throttlep->empty2, throttlep->alarmed1, throttlep->alarmed2);
    } else {
        diminuto_log_emit("diminuto_throttle_t@%p[%zu]\n", throttlep, sizeof(*throttlep));
    }
}

canonical_original_code:
void diminuto_throttle_log(struct DiminutoThrottle *throttlep)
{
    if (throttlep != (struct DiminutoThrottle *)0) {
        diminuto_log_emit("diminuto_throttle_t@%p[%zu]: { iat=%llu i=%llu l=%llu x=%llu x1=%llu f=%d,%d,%d e=%d,%d,%d a=%d,%d }\n", throttlep, sizeof(*throttlep), (diminuto_llu_t)(throttlep->now - throttlep->then), (unsigned long long)throttlep->increment, (unsigned long long)throttlep->limit, (unsigned long long)throttlep->expected, (unsigned long long)throttlep->actual, throttlep->full0, throttlep->full1, throttlep->full2, throttlep->empty0, throttlep->empty1, throttlep->empty2, throttlep->alarmed1, throttlep->alarmed2);
    } else {
        diminuto_log_emit("diminuto_throttle_t@%p[%zu]\n", throttlep, sizeof(*throttlep));
    }
}


decompiled_code:
// attributes: thunk
int diminuto_compare_strings(const char *s1, const char *s2)
{
return strcmp(s1, s2);
}

canonical_decompiled_code:
int func0(const char *s1, const char *s2)
{
return strcmp(s1, s2);
}

original_code:
int diminuto_compare_strings(const void * thisp, const void * thatp)
{
    return strcmp(thisp, thatp);
}

canonical_original_code:
int diminuto_compare_strings(void *thisp, void *thatp)
{
    return strcmp(thisp, thatp);
}

variable_types:
thisp
void *

variable_types:
thatp
void *


decompiled_code:
__int64 __fastcall diminuto_compare_pointers(__int64 a1, __int64 a2)
{
return a1 - a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return a1 - a2;
}

original_code:
int diminuto_compare_pointers(const void * thisp, const void * thatp)
{
    return ((intptr_t)thisp) - ((intptr_t)thatp);
}

canonical_original_code:
int diminuto_compare_pointers(void *thisp, void *thatp)
{
    return ((long)thisp) - ((long)thatp);
}


decompiled_code:
// attributes: thunk
__int64 diminuto_number()
{
return diminuto_number_unsigned();
}

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

original_code:
static inline const char * diminuto_number(const char * s, diminuto_unsigned_t * p) {
    return diminuto_number_unsigned(s, p);
}

canonical_original_code:
static inline char *diminuto_number(char *s, unsigned long *p) {
    return diminuto_number_unsigned(s, p);
}

variable_types:
s
char *

variable_types:
p
unsigned long *


control

decompiled_code:
int __fastcall control(int a1, unsigned __int64 a2)
{
int result; // eax
int v3; // [rsp+0h] [rbp-Ch]

if ( a1 < 0 )
return -1;
result = ioctl(a1, a2);
if ( result < 0 )
{
v3 = result;
perror("ioctl");
result = v3;
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(int a1, unsigned __int64 a2)
{
int result; // eax
int v3; // [rsp+0h] [rbp-Ch]

if ( a1 < 0 )
return -1;
result = ioctl(a1, a2);
if ( result < 0 )
{
v3 = result;
perror("ioctl");
result = v3;
}
return result;
}

original_code:
static int control(int fd, unsigned long request, diminuto_mmdriver_op_t * opp)
{
    int rc = -1;
    if (fd < 0) {
    } else if ((rc = ioctl(fd, request, opp)) < 0) {
        perror("ioctl");
    } else {
    }
    return rc;
}

canonical_original_code:
static int control(int fd, unsigned long request, struct DiminutoMmDriverOp *opp)
{
    int rc = -1;
    if (fd < 0) {
    } else if ((rc = ioctl(fd, request, opp)) < 0) {
        perror("ioctl");
    } else {
    }
    return rc;
}

variable_types: fd int

variable_types:
request
unsigned long

variable_types: struct DiminutoMmDriverOp { unsigned long offset; enum DiminutoDatumWidth { DIMINUTO_DATUM_WIDTH8=expr, DIMINUTO_DATUM_WIDTH16=expr, DIMINUTO_DATUM_WIDTH32=expr, DIMINUTO_DATUM_WIDTH64=expr } width; union DiminutoDatumValue { unsigned char value8; unsigned short value16; unsigned int value32; unsigned long value64; } datum; union DiminutoDatumValue mask; } *

variable_types: rc int

user_defined_types: struct DiminutoMmDriverOp { unsigned long offset; enum DiminutoDatumWidth width; union DiminutoDatumValue datum; union DiminutoDatumValue mask; }


decompiled_code:
__int64 diminuto_unittest_setlogmask()
{
__int64 result; // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

result = diminuto_criticalsection_lock(&mutex);
if ( !(_DWORD)result )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
diminuto_log_importmask(0LL);
diminuto_log_setmask();
setvbuf(stderr, 0LL, 2, 0LL);
diminuto_core_enable();
_pthread_unregister_cancel(&buf);
result = ((__int64 (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

result = diminuto_criticalsection_lock(&mutex);
if ( !(_DWORD)result )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
diminuto_log_importmask(0LL);
diminuto_log_setmask();
setvbuf(stderr, 0LL, 2, 0LL);
diminuto_core_enable();
_pthread_unregister_cancel(&buf);
result = ((__int64 (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
}
return result;
}

original_code:
void diminuto_unittest_setlogmask()
{
    do { pthread_mutex_t * _diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        diminuto_log_importmask((const char *)0);
        diminuto_log_setmask();
        setvbuf(stderr, (char *)0, 2, 0);
        diminuto_core_enable();
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
}

canonical_original_code:
void diminuto_unittest_setlogmask()
{
    do { union pthread_mutex_t *_diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        diminuto_log_importmask((char *)0);
        diminuto_log_setmask();
        setvbuf(stderr, (char *)0, 2, 0);
        diminuto_core_enable();
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
}

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

variable_types: struct __pthread_unwind_buf_t { struct { long __cancel_jmp_buf[8]; int __mask_was_saved; } __cancel_jmp_buf[1]; void *__pad[4]; }


decompiled_code:
__int64 diminuto_unittest_test()
{
unsigned int v0; // er12
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return (unsigned int)-1;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v0 = ++diminuto_unittest_tests;
_pthread_unregister_cancel(&buf);
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // er12
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return (unsigned int)-1;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v0 = ++diminuto_unittest_tests;
_pthread_unregister_cancel(&buf);
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
return v0;
}

original_code:
int diminuto_unittest_test()
{
    int tests = -1;
    do { pthread_mutex_t * _diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        tests = ++diminuto_unittest_tests;
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return tests;
}

canonical_original_code:
int diminuto_unittest_test()
{
    int tests = -1;
    do { union pthread_mutex_t *_diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        tests = ++diminuto_unittest_tests;
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return tests;
}

variable_types: tests int

user_defined_types: struct __pthread_unwind_buf_t { struct { long __cancel_jmp_buf[8]; int __mask_was_saved; } __cancel_jmp_buf[1]; void *__pad[4]; }


decompiled_code:
__int64 diminuto_unittest_error()
{
unsigned int v0; // er12
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return (unsigned int)-1;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v0 = ++diminuto_unittest_errors;
_pthread_unregister_cancel(&buf);
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
return v0;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // er12
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return (unsigned int)-1;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v0 = ++diminuto_unittest_errors;
_pthread_unregister_cancel(&buf);
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
return v0;
}

original_code:
int diminuto_unittest_error()
{
    int errors = -1;
    do { pthread_mutex_t * _diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        errors = ++diminuto_unittest_errors;
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return errors;
}

canonical_original_code:
int diminuto_unittest_error()
{
    int errors = -1;
    do { union pthread_mutex_t *_diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        errors = ++diminuto_unittest_errors;
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return errors;
}

variable_types: errors int


decompiled_code:
__int64 diminuto_unittest_flush()
{
__int64 result; // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

result = diminuto_criticalsection_lock(&mutex);
if ( !(_DWORD)result )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
fflush(stdout);
fflush(stderr);
_pthread_unregister_cancel(&buf);
result = ((__int64 (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

result = diminuto_criticalsection_lock(&mutex);
if ( !(_DWORD)result )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
((void (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
fflush(stdout);
fflush(stderr);
_pthread_unregister_cancel(&buf);
result = ((__int64 (__fastcall *)(void *))diminuto_criticalsection_cleanup)(&mutex);
}
return result;
}

original_code:
void diminuto_unittest_flush()
{
    do { pthread_mutex_t * _diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        fflush(stdout);
        fflush(stderr);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
}

canonical_original_code:
void diminuto_unittest_flush()
{
    do { union pthread_mutex_t *_diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        fflush(stdout);
        fflush(stderr);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
}


decompiled_code:
void __fastcall diminuto_reaper_handler(int a1)
{
if ( a1 == 17 && signaled != 0x7FFFFFFF )
++signaled;
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
if ( a1 == 17 && signaled != 0x7FFFFFFF )
++signaled;
}

original_code:
static void diminuto_reaper_handler(int signum)
{
    int mysignaled = -1;
    static const int MAXIMUM = ~(((int)1) << ((sizeof(signaled) * 8) - 1));
    if (signum == 17) {
        mysignaled = signaled;
        if (mysignaled < MAXIMUM) {
            mysignaled += 1;
            signaled = mysignaled;
        }
    }
}

canonical_original_code:
static void diminuto_reaper_handler(int signum)
{
    int mysignaled = -1;
    static int MAXIMUM = ~(((int)1) << ((sizeof(signaled) * 8) - 1));
    if (signum == 17) {
        mysignaled = signaled;
        if (mysignaled < MAXIMUM) {
            mysignaled += 1;
            signaled = mysignaled;
        }
    }
}

variable_types: signum int

variable_types: mysignaled int

variable_types: MAXIMUM int


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

if ( kill(a1, 17) < 0 )
{
diminuto_log_perror("src/diminuto_reaper.c", 34LL, "diminuto_reaper_signal: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_reaper_debug[0];
if ( diminuto_reaper_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_reaper_signal: SIGCHLD");
result = 0LL;
}
}
}
return result;
}

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

if ( kill(a1, 17) < 0 )
{
diminuto_log_perror("src/diminuto_reaper.c", 34LL, "diminuto_reaper_signal: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_reaper_debug[0];
if ( diminuto_reaper_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_reaper_signal: SIGCHLD");
result = 0LL;
}
}
}
return result;
}

original_code:
int diminuto_reaper_signal(pid_t pid)
{
    int rc = 0;
    if (kill(pid, 17) < 0) {
        diminuto_log_perror("src/diminuto_reaper.c", 34, "diminuto_reaper_signal: kill");
        rc = -1;
    } else if (diminuto_reaper_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_reaper_signal: SIGCHLD") : ((void)0));
    } else {
    }
    return rc;
}

canonical_original_code:
int diminuto_reaper_signal(int pid)
{
    int rc = 0;
    if (kill(pid, 17) < 0) {
        diminuto_log_perror("src/diminuto_reaper.c", 34, "diminuto_reaper_signal: kill");
        rc = -1;
    } else if (diminuto_reaper_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_reaper_signal: SIGCHLD") : ((void)0));
    } else {
    }
    return rc;
}

variable_types: pid int


decompiled_code:
__int64 diminuto_reaper_check()
{
int v0; // eax
unsigned int v2; // [rsp+4h] [rbp-184h]
int v3; // [rsp+1Ch] [rbp-16Ch] BYREF
struct __jmp_buf_tag env; // [rsp+20h] [rbp-168h] BYREF
char v5[136]; // [rsp+100h] [rbp-88h] BYREF

v2 = -1;
if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
goto LABEL_9;
if ( _sigsetjmp(&env, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env);
}
_pthread_register_cancel((__pthread_unwind_buf_t *)&env);
v3 = 17;
if ( !(unsigned int)diminuto_uninterruptiblesection_block(&v3, 1LL, v5) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&env.__saved_mask.__val[5], 0) )
{
((void (__fastcall *)(char *))diminuto_uninterruptiblesection_cleanup)(v5);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
}
_pthread_register_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
v0 = signaled;
signaled = 0;
v2 = v0;
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
((void (__fastcall *)(char *))diminuto_uninterruptiblesection_cleanup)(v5);
}
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env);
diminuto_criticalsection_cleanup(&mutex);
if ( v2 )
{
LABEL_9:
if ( diminuto_reaper_debug[0] && (diminuto_log_mask & 1) != 0 )
diminuto_log_log(7LL, "diminuto_reaper_check: SIGCHLD [%d]", v2);
}
return v2;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // eax
unsigned int v2; // [rsp+4h] [rbp-184h]
int v3; // [rsp+1Ch] [rbp-16Ch] BYREF
struct __jmp_buf_tag env; // [rsp+20h] [rbp-168h] BYREF
char v5[136]; // [rsp+100h] [rbp-88h] BYREF

v2 = -1;
if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
goto LABEL_9;
if ( _sigsetjmp(&env, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env);
}
_pthread_register_cancel((__pthread_unwind_buf_t *)&env);
v3 = 17;
if ( !(unsigned int)diminuto_uninterruptiblesection_block(&v3, 1LL, v5) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&env.__saved_mask.__val[5], 0) )
{
((void (__fastcall *)(char *))diminuto_uninterruptiblesection_cleanup)(v5);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
}
_pthread_register_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
v0 = signaled;
signaled = 0;
v2 = v0;
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
((void (__fastcall *)(char *))diminuto_uninterruptiblesection_cleanup)(v5);
}
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env);
diminuto_criticalsection_cleanup(&mutex);
if ( v2 )
{
LABEL_9:
if ( diminuto_reaper_debug[0] && (diminuto_log_mask & 1) != 0 )
diminuto_log_log(7LL, "diminuto_reaper_check: SIGCHLD [%d]", v2);
}
return v2;
}

original_code:
int diminuto_reaper_check(void)
{
    int mysignaled = -1;
    do { pthread_mutex_t * _diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        do { const int _diminuto_uninterrutiblesection_signals[] = { 17 }; sigset_t _diminuto_uninterruptiblesection_set; if (diminuto_uninterruptiblesection_block(_diminuto_uninterrutiblesection_signals, (sizeof(_diminuto_uninterrutiblesection_signals) / sizeof(_diminuto_uninterrutiblesection_signals[0])), &_diminuto_uninterruptiblesection_set) == 0) { do { __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine) (void *) = (diminuto_uninterruptiblesection_cleanup); void *__cancel_arg = (&_diminuto_uninterruptiblesection_set); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
            mysignaled = signaled;
            signaled = 0;
        } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    if (!mysignaled) {
    } else if (diminuto_reaper_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_reaper_check: SIGCHLD [%d]", mysignaled) : ((void)0));
   } else {
    }
    return mysignaled;
}

canonical_original_code:
int diminuto_reaper_check()
{
    int mysignaled = -1;
    do { union pthread_mutex_t *_diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (&mutex); if (diminuto_criticalsection_lock(_diminuto_criticalsection_mp) == 0) { do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (diminuto_criticalsection_cleanup); void *__cancel_arg = (_diminuto_criticalsection_mp); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
        do { int _diminuto_uninterrutiblesection_signals[] = { 17 }; struct __sigset_t _diminuto_uninterruptiblesection_set; if (diminuto_uninterruptiblesection_block(_diminuto_uninterrutiblesection_signals, (sizeof(_diminuto_uninterrutiblesection_signals) / sizeof(_diminuto_uninterrutiblesection_signals[0])), &_diminuto_uninterruptiblesection_set) == 0) { do { struct __pthread_unwind_buf_t __cancel_buf; void (*__cancel_routine)(void *) = (diminuto_uninterruptiblesection_cleanup); void *__cancel_arg = (&_diminuto_uninterruptiblesection_set); int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) __cancel_buf.__cancel_jmp_buf, 0); if (__builtin_expect ((__not_first_call), 0)) { __cancel_routine (__cancel_arg); __pthread_unwind_next (&__cancel_buf); } __pthread_register_cancel (&__cancel_buf); do {; do { ((void)0);
            mysignaled = signaled;
            signaled = 0;
        } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    if (!mysignaled) {
    } else if (diminuto_reaper_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_reaper_check: SIGCHLD [%d]", mysignaled) : ((void)0));
   } else {
    }
    return mysignaled;
}

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


decompiled_code:
__int64 __fastcall diminuto_reaper_reap_generic(__pid_t a1, int *a2, int a3)
{
__pid_t v3; // eax
unsigned int v4; // er12
__int64 result; // rax
int stat_loc[7]; // [rsp+Ch] [rbp-1Ch] BYREF

stat_loc[0] = -1;
v3 = waitpid(a1, stat_loc, a3);
v4 = v3;
if ( v3 < 0 )
{
if ( *_errno_location() == 10 )
{
result = 0LL;
}
else
{
diminuto_log_perror("src/diminuto_reaper.c", 93LL, "diminuto_reaper_reap_generic: waitpid");
result = v4;
}
}
else
{
if ( !v3 )
goto LABEL_3;
if ( diminuto_reaper_debug[0] )
{
if ( (diminuto_log_mask & 1) != 0 )
diminuto_log_log(
7LL,
"diminuto_reaper_reap_generic: waitpid [%d] (%d)",
(unsigned int)v3,
(unsigned int)stat_loc[0]);
}
if ( a2 )
{
*a2 = stat_loc[0];
result = v4;
}
else
{
LABEL_3:
result = v4;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__pid_t a1, int *a2, int a3)
{
__pid_t v3; // eax
unsigned int v4; // er12
__int64 result; // rax
int stat_loc[7]; // [rsp+Ch] [rbp-1Ch] BYREF

stat_loc[0] = -1;
v3 = waitpid(a1, stat_loc, a3);
v4 = v3;
if ( v3 < 0 )
{
if ( *_errno_location() == 10 )
{
result = 0LL;
}
else
{
diminuto_log_perror("src/diminuto_reaper.c", 93LL, "diminuto_reaper_reap_generic: waitpid");
result = v4;
}
}
else
{
if ( !v3 )
goto LABEL_3;
if ( diminuto_reaper_debug[0] )
{
if ( (diminuto_log_mask & 1) != 0 )
diminuto_log_log(
7LL,
"diminuto_reaper_reap_generic: waitpid [%d] (%d)",
(unsigned int)v3,
(unsigned int)stat_loc[0]);
}
if ( a2 )
{
*a2 = stat_loc[0];
result = v4;
}
else
{
LABEL_3:
result = v4;
}
}
return result;
}

original_code:
pid_t diminuto_reaper_reap_generic(pid_t pids, int * statusp, int flag)
{
    pid_t pid = -1;
    int status = -1;
    pid = waitpid(pids, &status, flag);
    if ((pid < 0) && ((*__errno_location ()) == 10)) {
        pid = 0;
    } else if (pid < 0) {
        diminuto_log_perror("src/diminuto_reaper.c", 93, "diminuto_reaper_reap_generic: waitpid");
    } else if (pid == 0) {
    } else if (diminuto_reaper_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_reaper_reap_generic: waitpid [%d] (%d)", pid, status) : ((void)0));
    } else {
    }
    if (pid <= 0) {
    } else if (statusp == (int *)0) {
    } else {
        *statusp = status;
    }
    return pid;
}

canonical_original_code:
int diminuto_reaper_reap_generic(int pids, int *statusp, int flag)
{
    int pid = -1;
    int status = -1;
    pid = waitpid(pids, &status, flag);
    if ((pid < 0) && ((*__errno_location ()) == 10)) {
        pid = 0;
    } else if (pid < 0) {
        diminuto_log_perror("src/diminuto_reaper.c", 93, "diminuto_reaper_reap_generic: waitpid");
    } else if (pid == 0) {
    } else if (diminuto_reaper_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_reaper_reap_generic: waitpid [%d] (%d)", pid, status) : ((void)0));
    } else {
    }
    if (pid <= 0) {
    } else if (statusp == (int *)0) {
    } else {
        *statusp = status;
    }
    return pid;
}

variable_types: pids int

variable_types:
statusp
int *

variable_types: flag int

variable_types: status int


decompiled_code:
__int64 __fastcall diminuto_reaper_install(int a1)
{
int v1; // edx
__int64 result; // rax
struct sigaction v3; // [rsp+0h] [rbp-A8h] BYREF

v1 = a1;
memset(&v3.sa_mask, 0, 0x90uLL);
v3.sa_handler = diminuto_reaper_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(17, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_reaper.c", 122LL, "diminuto_reaper_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_reaper_debug[0];
if ( diminuto_reaper_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_reaper_install: SIGCHLD");
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
int v1; // edx
__int64 result; // rax
struct sigaction v3; // [rsp+0h] [rbp-A8h] BYREF

v1 = a1;
memset(&v3.sa_mask, 0, 0x90uLL);
v3.sa_handler = diminuto_reaper_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(17, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_reaper.c", 122LL, "diminuto_reaper_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_reaper_debug[0];
if ( diminuto_reaper_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_reaper_install: SIGCHLD");
result = 0LL;
}
}
}
return result;
}

original_code:
int diminuto_reaper_install(int restart)
{
    int rc = 0;
    struct sigaction reaper = { 0 };
    reaper.__sigaction_handler.sa_handler = diminuto_reaper_handler;
    reaper.sa_flags = restart ? 0x10000000 : 0;
    if (sigaction(17, &reaper, (struct sigaction *)0) < 0) {
        diminuto_log_perror("src/diminuto_reaper.c", 122, "diminuto_reaper_install: sigaction");
        rc = -1;
    } else if (diminuto_reaper_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_reaper_install: SIGCHLD") : ((void)0));
    } else {
    }
    return rc;
}

variable_types: restart 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)(); }

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


decompiled_code:
__int64 __fastcall diminuto_lock_lock_generic(void *a1, int a2)
{
return diminuto_lock_f(a1, "-lock-XXXXXX", a2, 1u);
}

canonical_decompiled_code:
__int64 __fastcall func1(void *a1, int a2)
{
return func0(a1, "-lock-XXXXXX", a2, 1u);
}

original_code:
int diminuto_lock_lock_generic(const char * file, pid_t pid)
{
    return diminuto_lock_f(file, "-lock-XXXXXX", pid, (1 << 0));
}

canonical_original_code:
int diminuto_lock_lock_generic(char *file, int pid)
{
    return diminuto_lock_f(file, "-lock-XXXXXX", pid, (1 << 0));
}

variable_types:
file
char *


decompiled_code:
__int64 __fastcall diminuto_lock_lock(void *a1)
{
int v1; // eax

v1 = getpid();
if ( v1 >= 0 )
return diminuto_lock_lock_generic(a1, v1);
diminuto_log_perror("src/diminuto_lock.c", 124LL, "diminuto_lock_lock: getpid");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(void *a1)
{
int v1; // eax

v1 = getpid();
if ( v1 >= 0 )
return func1(a1, v1);
diminuto_log_perror("src/diminuto_lock.c", 124LL, "diminuto_lock_lock: getpid");
return 0xFFFFFFFFLL;
}

original_code:
int diminuto_lock_lock(const char * file)
{
    int rc = -1;
    pid_t pid = -1;
    if ((pid = getpid()) < 0) {
        diminuto_log_perror("src/diminuto_lock.c", 124, "diminuto_lock_lock: getpid");
    } else {
        rc = diminuto_lock_lock_generic(file, pid);
    }
    return rc;
}

canonical_original_code:
int diminuto_lock_lock(char *file)
{
    int rc = -1;
    int pid = -1;
    if ((pid = getpid()) < 0) {
        diminuto_log_perror("src/diminuto_lock.c", 124, "diminuto_lock_lock: getpid");
    } else {
        rc = diminuto_lock_lock_generic(file, pid);
    }
    return rc;
}

variable_types: rc int


decompiled_code:
int __fastcall diminuto_lock_prelock(const char *a1)
{
int v1; // eax
int result; // eax
int *v3; // r8

v1 = open(a1, 193, 384LL);
if ( v1 < 0 )
{
v3 = _errno_location();
result = -1;
if ( *v3 != 17 )
{
diminuto_log_perror("src/diminuto_lock.c", 146LL, "diminuto_lock_prelock: open");
result = -1;
}
}
else
{
result = close(v1);
if ( result )
{
diminuto_log_perror("src/diminuto_lock.c", 154LL, "diminuto_lock_prelock: close");
result = 0;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(const char *a1)
{
int v1; // eax
int result; // eax
int *v3; // r8

v1 = open(a1, 193, 384LL);
if ( v1 < 0 )
{
v3 = _errno_location();
result = -1;
if ( *v3 != 17 )
{
diminuto_log_perror("src/diminuto_lock.c", 146LL, "diminuto_lock_prelock: open");
result = -1;
}
}
else
{
result = close(v1);
if ( result )
{
diminuto_log_perror("src/diminuto_lock.c", 154LL, "diminuto_lock_prelock: close");
result = 0;
}
}
return result;
}

original_code:
int diminuto_lock_prelock(const char * file)
{
    int rc = -1;
    int fd = -1;
    if ((fd = open(file, 0100 | 0200 | 01, 0600)) >= 0) {
        rc = 0;
    } else if ((*__errno_location ()) == 17) {
    } else {
        diminuto_log_perror("src/diminuto_lock.c", 146, "diminuto_lock_prelock: open");
    }
    if (fd < 0) {
    } else if (close(fd) == 0) {
     } else {
        diminuto_log_perror("src/diminuto_lock.c", 154, "diminuto_lock_prelock: close");
    }
    return rc;
}

canonical_original_code:
int diminuto_lock_prelock(char *file)
{
    int rc = -1;
    int fd = -1;
    if ((fd = open(file, 0100 | 0200 | 01, 0600)) >= 0) {
        rc = 0;
    } else if ((*__errno_location ()) == 17) {
    } else {
        diminuto_log_perror("src/diminuto_lock.c", 146, "diminuto_lock_prelock: open");
    }
    if (fd < 0) {
    } else if (close(fd) == 0) {
     } else {
        diminuto_log_perror("src/diminuto_lock.c", 154, "diminuto_lock_prelock: close");
    }
    return rc;
}

variable_types: fd int