decompiled_code:
__int64 __fastcall diminuto_fd_acquire(int a1, const char *a2, int a3, unsigned int a4)
{
int v4; // ebx

v4 = a1;
if ( a1 < 0 )
{
v4 = open(a2, a3, a4);
if ( v4 < 0 )
diminuto_log_perror("src/diminuto_fd.c", 53LL, a2);
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, const char *a2, int a3, unsigned int a4)
{
int v4; // ebx

v4 = a1;
if ( a1 < 0 )
{
v4 = open(a2, a3, a4);
if ( v4 < 0 )
diminuto_log_perror("src/diminuto_fd.c", 53LL, a2);
}
return (unsigned int)v4;
}

original_code:
int diminuto_fd_acquire(int fd, const char * device, int flags, mode_t mode)
{
    if (fd >= 0) {
    } else if ((fd = open(device, flags, mode)) < 0) {
        diminuto_log_perror("src/diminuto_fd.c", 53, device);
    } else {
    }
    return fd;
}

canonical_original_code:
int diminuto_fd_acquire(int fd, char *device, int flags, unsigned int mode)
{
    if (fd >= 0) {
    } else if ((fd = open(device, flags, mode)) < 0) {
        diminuto_log_perror("src/diminuto_fd.c", 53, device);
    } else {
    }
    return fd;
}

variable_types: fd int

variable_types:
device
char *

variable_types: flags int

variable_types:
mode
unsigned int


repo: coverclock/com-diag-diminuto

decompiled_code:
__int64 __fastcall diminuto_fd_relinquish(int a1, const char *a2)
{
unsigned int v2; // ebx
const char *v4; // rbp

v2 = a1;
if ( a1 >= 0 )
{
v4 = a2;
if ( close(a1) >= 0 )
{
v2 = -1;
}
else
{
if ( !a2 )
v4 = "diminuto_fd_relinquish: close";
diminuto_log_perror("src/diminuto_fd.c", 66LL, v4);
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, const char *a2)
{
unsigned int v2; // ebx
const char *v4; // rbp

v2 = a1;
if ( a1 >= 0 )
{
v4 = a2;
if ( close(a1) >= 0 )
{
v2 = -1;
}
else
{
if ( !a2 )
v4 = "diminuto_fd_relinquish: close";
diminuto_log_perror("src/diminuto_fd.c", 66LL, v4);
}
}
return v2;
}

original_code:
int diminuto_fd_relinquish(int fd, const char * device)
{
    if (fd < 0) {
    } else if (close(fd) < 0) {
        diminuto_log_perror("src/diminuto_fd.c", 66, device ? device : "diminuto_fd_relinquish: close");
    } else {
        fd = -1;
    }
    return fd;
}

canonical_original_code:
int diminuto_fd_relinquish(int fd, char *device)
{
    if (fd < 0) {
    } else if (close(fd) < 0) {
        diminuto_log_perror("src/diminuto_fd.c", 66, device ? device : "diminuto_fd_relinquish: close");
    } else {
        fd = -1;
    }
    return fd;
}

return_type: int


decompiled_code:
ssize_t __fastcall diminuto_fd_read_generic(int fd, void *buf, ssize_t a3, size_t a4)
{
ssize_t v7; // r13
ssize_t v8; // rax
ssize_t v9; // rbx
int v10; // eax

v7 = 0LL;
do
{
if ( !a4 )
break;
v8 = read(fd, buf, a4);
v9 = v8;
if ( !v8 )
break;
if ( v8 < 0 )
{
v10 = *_errno_location();
if ( v10 != 11 && v10 != 4 )
diminuto_log_perror("src/diminuto_fd.c", 95LL, "diminuto_fd_read_generic: read");
if ( !v7 )
v7 = v9;
return v7;
}
buf = (char *)buf + v8;
a4 -= v8;
v7 += v8;
}
while ( a3 > v7 );
return v7;
}

canonical_decompiled_code:
ssize_t __fastcall func2(int fd, void *buf, ssize_t a3, size_t a4)
{
ssize_t v7; // r13
ssize_t v8; // rax
ssize_t v9; // rbx
int v10; // eax

v7 = 0LL;
do
{
if ( !a4 )
break;
v8 = read(fd, buf, a4);
v9 = v8;
if ( !v8 )
break;
if ( v8 < 0 )
{
v10 = *_errno_location();
if ( v10 != 11 && v10 != 4 )
diminuto_log_perror("src/diminuto_fd.c", 95LL, "diminuto_fd_read_generic: read");
if ( !v7 )
v7 = v9;
return v7;
}
buf = (char *)buf + v8;
a4 -= v8;
v7 += v8;
}
while ( a3 > v7 );
return v7;
}

original_code:
ssize_t diminuto_fd_read_generic(int fd, void * buffer, size_t min, size_t max)
{
    ssize_t total = 0;
    char * bp = (char *)0;
    ssize_t current = -1;
    size_t slack = 0;
    bp = (char *)buffer;
    slack = max;
    while (slack > 0) {
        if ((current = read(fd, bp, slack)) == 0) {
            break;
        } else if (current < 0) {
            if ((*__errno_location ()) == 4) {
            } else if ((*__errno_location ()) == 11) {
            } else if ((*__errno_location ()) == 11) {
            } else {
                diminuto_log_perror("src/diminuto_fd.c", 95, "diminuto_fd_read_generic: read");
            }
            if (total == 0) {
                total = current;
            }
            break;
        } else {
            bp += current;
            slack -= current;
            total += current;
            if (total >= (ssize_t)min) {
                break;
            }
        }
    }
    return total;
}

canonical_original_code:
long diminuto_fd_read_generic(int fd, void *buffer, unsigned long min, unsigned long max)
{
    long total = 0;
    char *bp = (char *)0;
    long current = -1;
    unsigned long slack = 0;
    bp = (char *)buffer;
    slack = max;
    while (slack > 0) {
        if ((current = read(fd, bp, slack)) == 0) {
            break;
        } else if (current < 0) {
            if ((*__errno_location ()) == 4) {
            } else if ((*__errno_location ()) == 11) {
            } else if ((*__errno_location ()) == 11) {
            } else {
                diminuto_log_perror("src/diminuto_fd.c", 95, "diminuto_fd_read_generic: read");
            }
            if (total == 0) {
                total = current;
            }
            break;
        } else {
            bp += current;
            slack -= current;
            total += current;
            if (total >= (long)min) {
                break;
            }
        }
    }
    return total;
}

variable_types:
buffer
void *

variable_types:
min
unsigned long

variable_types:
max
unsigned long

variable_types: total long

variable_types:
bp
char *

variable_types: current long

variable_types:
slack
unsigned long

return_type: long


decompiled_code:
ssize_t __fastcall diminuto_fd_write_generic(int fd, void *buf, ssize_t a3, size_t a4)
{
ssize_t v7; // r13
ssize_t v8; // rax
ssize_t v9; // rbx
int v10; // eax

v7 = 0LL;
do
{
if ( !a4 )
break;
v8 = write(fd, buf, a4);
v9 = v8;
if ( !v8 )
break;
if ( v8 < 0 )
{
v10 = *_errno_location();
if ( v10 != 11 && v10 != 4 )
diminuto_log_perror("src/diminuto_fd.c", 135LL, "diminuto_fd_write: write");
if ( !v7 )
v7 = v9;
return v7;
}
buf = (char *)buf + v8;
a4 -= v8;
v7 += v8;
}
while ( a3 > v7 );
return v7;
}

canonical_decompiled_code:
ssize_t __fastcall func3(int fd, void *buf, ssize_t a3, size_t a4)
{
ssize_t v7; // r13
ssize_t v8; // rax
ssize_t v9; // rbx
int v10; // eax

v7 = 0LL;
do
{
if ( !a4 )
break;
v8 = write(fd, buf, a4);
v9 = v8;
if ( !v8 )
break;
if ( v8 < 0 )
{
v10 = *_errno_location();
if ( v10 != 11 && v10 != 4 )
diminuto_log_perror("src/diminuto_fd.c", 135LL, "diminuto_fd_write: write");
if ( !v7 )
v7 = v9;
return v7;
}
buf = (char *)buf + v8;
a4 -= v8;
v7 += v8;
}
while ( a3 > v7 );
return v7;
}

original_code:
ssize_t diminuto_fd_write_generic(int fd, const void * buffer, size_t min, size_t max)
{
    ssize_t total = 0;
    const char * bp = (const char *)0;
    ssize_t current = -1;
    size_t slack = 0;
    bp = (char *)buffer;
    slack = max;
    while (slack > 0) {
        if ((current = write(fd, bp, slack)) == 0) {
            break;
        } else if (current < 0) {
            if ((*__errno_location ()) == 4) {
            } else if ((*__errno_location ()) == 11) {
            } else if ((*__errno_location ()) == 11) {
            } else {
                diminuto_log_perror("src/diminuto_fd.c", 135, "diminuto_fd_write: write");
            }
            if (total == 0) {
                total = current;
            }
            break;
        } else {
            bp += current;
            slack -= current;
            total += current;
            if (total >= (ssize_t)min) {
                break;
            }
        }
    }
    return total;
}

canonical_original_code:
long diminuto_fd_write_generic(int fd, void *buffer, unsigned long min, unsigned long max)
{
    long total = 0;
    char *bp = (const char *)0;
    long current = -1;
    unsigned long slack = 0;
    bp = (char *)buffer;
    slack = max;
    while (slack > 0) {
        if ((current = write(fd, bp, slack)) == 0) {
            break;
        } else if (current < 0) {
            if ((*__errno_location ()) == 4) {
            } else if ((*__errno_location ()) == 11) {
            } else if ((*__errno_location ()) == 11) {
            } else {
                diminuto_log_perror("src/diminuto_fd.c", 135, "diminuto_fd_write: write");
            }
            if (total == 0) {
                total = current;
            }
            break;
        } else {
            bp += current;
            slack -= current;
            total += current;
            if (total >= (long)min) {
                break;
            }
        }
    }
    return total;
}


decompiled_code:
__int64 __fastcall diminuto_fd_readable_generic(int fd, int a2)
{
__int64 result; // rax
int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v3[0] = -1;
isatty(fd);
if ( ioctl(fd, 0x541BuLL, v3) >= 0 )
return v3[0];
result = -1LL;
if ( !a2 )
{
diminuto_log_perror("src/diminuto_fd.c", 170LL, "diminuto_fd_readable: ioctl");
result = -1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd, int a2)
{
__int64 result; // rax
int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v3[0] = -1;
isatty(fd);
if ( ioctl(fd, 0x541BuLL, v3) >= 0 )
return v3[0];
result = -1LL;
if ( !a2 )
{
diminuto_log_perror("src/diminuto_fd.c", 170LL, "diminuto_fd_readable: ioctl");
result = -1LL;
}
return result;
}

original_code:
ssize_t diminuto_fd_readable_generic(int fd, int suppress)
{
    ssize_t result = -1;
    int request = -1;
    int count = -1;
    request = isatty(fd) ? 0x541B : 0x541B;
    if (ioctl(fd, request, &count) >= 0) {
        result = count;
    } else if (!suppress) {
        diminuto_log_perror("src/diminuto_fd.c", 170, "diminuto_fd_readable: ioctl");
    } else {
    }
    return result;
}

canonical_original_code:
long diminuto_fd_readable_generic(int fd, int suppress)
{
    long result = -1;
    int request = -1;
    int count = -1;
    request = isatty(fd) ? 0x541B : 0x541B;
    if (ioctl(fd, request, &count) >= 0) {
        result = count;
    } else if (!suppress) {
        diminuto_log_perror("src/diminuto_fd.c", 170, "diminuto_fd_readable: ioctl");
    } else {
    }
    return result;
}

variable_types: suppress int

variable_types: result long

variable_types: request int

variable_types: count int


decompiled_code:
__int64 diminuto_fd_count()
{
return 1024LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 1024LL;
}

original_code:
ssize_t diminuto_fd_count(void)
{
    return 1024;
}

canonical_original_code:
long diminuto_fd_count()
{
    return 1024;
}


decompiled_code:
rlim_t diminuto_fd_limit()
{
struct rlimit v1; // [rsp+0h] [rbp-18h] BYREF

if ( getrlimit(RLIMIT_NOFILE, &v1) >= 0 )
return v1.rlim_cur;
diminuto_log_perror("src/diminuto_fd.c", 191LL, "diminuto_fd_limit: getrlimit");
return -1LL;
}

canonical_decompiled_code:
rlim_t func6()
{
struct rlimit v1; // [rsp+0h] [rbp-18h] BYREF

if ( getrlimit(RLIMIT_NOFILE, &v1) >= 0 )
return v1.rlim_cur;
diminuto_log_perror("src/diminuto_fd.c", 191LL, "diminuto_fd_limit: getrlimit");
return -1LL;
}

original_code:
ssize_t diminuto_fd_limit(void)
{
    ssize_t result = -1;
    struct rlimit limit;
    if (getrlimit(RLIMIT_NOFILE, &limit) >= 0) {
        result = limit.rlim_cur;
    } else {
        diminuto_log_perror("src/diminuto_fd.c", 191, "diminuto_fd_limit: getrlimit");
    }
    return result;
}

canonical_original_code:
long diminuto_fd_limit()
{
    long result = -1;
    struct rlimit limit;
    if (getrlimit(RLIMIT_NOFILE, &limit) >= 0) {
        result = limit.rlim_cur;
    } else {
        diminuto_log_perror("src/diminuto_fd.c", 191, "diminuto_fd_limit: getrlimit");
    }
    return result;
}

variable_types: struct rlimit { unsigned long rlim_cur; unsigned long rlim_max; }


decompiled_code:
__int64 diminuto_fd_maximum()
{
__int64 v0; // rbx

v0 = sysconf(4);
if ( v0 < 0 )
diminuto_log_perror("src/diminuto_fd.c", 203LL, "diminuto_fd_maximum: sysconf");
return v0;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rbx

v0 = sysconf(4);
if ( v0 < 0 )
diminuto_log_perror("src/diminuto_fd.c", 203LL, "diminuto_fd_maximum: sysconf");
return v0;
}

original_code:
ssize_t diminuto_fd_maximum(void)
{
    ssize_t result = -1;
    result = sysconf(_SC_OPEN_MAX);
    if (result < 0) {
        diminuto_log_perror("src/diminuto_fd.c", 203, "diminuto_fd_maximum: sysconf");
    }
    return result;
}

canonical_original_code:
long diminuto_fd_maximum()
{
    long result = -1;
    result = sysconf(_SC_OPEN_MAX);
    if (result < 0) {
        diminuto_log_perror("src/diminuto_fd.c", 203, "diminuto_fd_maximum: sysconf");
    }
    return result;
}


decompiled_code:
__int64 __fastcall diminuto_fd_map_ref(_QWORD *a1, int a2)
{
__int64 result; // rax

result = 0LL;
if ( a2 >= 0 && (unsigned __int64)a2 < *a1 )
result = (__int64)&a1[a2 + 1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, int a2)
{
__int64 result; // rax

result = 0LL;
if ( a2 >= 0 && (unsigned __int64)a2 < *a1 )
result = (__int64)&a1[a2 + 1];
return result;
}

original_code:
void ** diminuto_fd_map_ref(diminuto_fd_map_t * mapp, int fd)
{
    return ((0 <= fd) && (fd < mapp->count)) ? &(mapp->data[fd]) : (void **)0;
}

canonical_original_code:
void **diminuto_fd_map_ref(struct DiminutoFdMap *mapp, int fd)
{
    return ((0 <= fd) && (fd < mapp->count)) ? &(mapp->data[fd]) : (void **)0;
}

variable_types: struct DiminutoFdMap { unsigned long count; void *data[]; } *

return_type: void **


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

v1 = getpagesize();
if ( v1 > 0 )
return diminuto_memory_aligned(v1, a1);
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_fd.c", 234LL, "diminuto_fd_direct_alloc: getpagesize");
return 0LL;
}

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

v1 = getpagesize();
if ( v1 > 0 )
return diminuto_memory_aligned(v1, a1);
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_fd.c", 234LL, "diminuto_fd_direct_alloc: getpagesize");
return 0LL;
}

original_code:
void * diminuto_fd_direct_alloc(size_t size)
{
    ssize_t alignment = -1;
    void * pointer = (void *)0;
    if ((alignment = getpagesize()) <= 0) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_fd.c", 234, "diminuto_fd_direct_alloc: getpagesize");
    } else if ((pointer = diminuto_memory_aligned(alignment, size)) == 0) {
    } else {
    }
    return pointer;
}

canonical_original_code:
void *diminuto_fd_direct_alloc(unsigned long size)
{
    long alignment = -1;
    void *pointer = (void *)0;
    if ((alignment = getpagesize()) <= 0) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_fd.c", 234, "diminuto_fd_direct_alloc: getpagesize");
    } else if ((pointer = diminuto_memory_aligned(alignment, size)) == 0) {
    } else {
    }
    return pointer;
}

variable_types:
size
unsigned long

variable_types: alignment long

variable_types:
pointer
void *

return_type: void *


decompiled_code:
__int64 __fastcall diminuto_fd_direct_acquire(int a1, const char *a2, int a3, unsigned int a4)
{
return diminuto_fd_acquire(a1, a2, a3 | 0x105000u, a4);
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, const char *a2, int a3, unsigned int a4)
{
return func0(a1, a2, a3 | 0x105000u, a4);
}

original_code:
int diminuto_fd_direct_acquire(int fd, const char * device, int flags, mode_t mode)
{
    return diminuto_fd_acquire(fd, device, flags | 040000 | 04010000, mode);
}

canonical_original_code:
int diminuto_fd_direct_acquire(int fd, char *device, int flags, unsigned int mode)
{
    return diminuto_fd_acquire(fd, device, flags | 040000 | 04010000, mode);
}

variable_types: fd int

variable_types:
device
char *

variable_types: flags int

variable_types:
mode
unsigned int


decompiled_code:
__int64 __fastcall diminuto_fd_type(int fd)
{
unsigned int v1; // ebp
struct stat v3; // [rsp+0h] [rbp-A8h] BYREF

memset(&v3, 0, sizeof(v3));
v1 = 116;
if ( !isatty(fd) )
{
if ( fstat(fd, &v3) < 0 )
{
diminuto_log_perror("src/diminuto_fd.c", 257LL, "diminuto_fd_type: fstat");
v1 = 63;
}
else
{
v1 = diminuto_fs_mode2type(v3.st_mode);
if ( v1 == 63 )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_fd.c", 262LL, "diminuto_fd_type: stat.st_mode");
}
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func11(int fd)
{
unsigned int v1; // ebp
struct stat v3; // [rsp+0h] [rbp-A8h] BYREF

memset(&v3, 0, sizeof(v3));
v1 = 116;
if ( !isatty(fd) )
{
if ( fstat(fd, &v3) < 0 )
{
diminuto_log_perror("src/diminuto_fd.c", 257LL, "diminuto_fd_type: fstat");
v1 = 63;
}
else
{
v1 = diminuto_fs_mode2type(v3.st_mode);
if ( v1 == 63 )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_fd.c", 262LL, "diminuto_fd_type: stat.st_mode");
}
}
}
return v1;
}

original_code:
diminuto_fd_type_t diminuto_fd_type(int fd)
{
    diminuto_fd_type_t type = DIMINUTO_FS_TYPE_UNKNOWN;
    struct stat status = { 0 };
    if (isatty(fd)) {
        type = DIMINUTO_FS_TYPE_TTY;
    } else if (fstat(fd, &status) < 0) {
        diminuto_log_perror("src/diminuto_fd.c", 257, "diminuto_fd_type: fstat");
    } else {
        type = diminuto_fs_mode2type(status.st_mode);
        if (type == DIMINUTO_FS_TYPE_UNKNOWN) {
            (*__errno_location ()) = 22;
            diminuto_log_perror("src/diminuto_fd.c", 262, "diminuto_fd_type: stat.st_mode");
        }
    }
    return type;
}

canonical_original_code:
enum DiminutoFsType diminuto_fd_type(int fd)
{
    enum DiminutoFsType type = DIMINUTO_FS_TYPE_UNKNOWN;
    struct stat status = { 0 };
    if (isatty(fd)) {
        type = DIMINUTO_FS_TYPE_TTY;
    } else if (fstat(fd, &status) < 0) {
        diminuto_log_perror("src/diminuto_fd.c", 257, "diminuto_fd_type: fstat");
    } else {
        type = diminuto_fs_mode2type(status.st_mode);
        if (type == DIMINUTO_FS_TYPE_UNKNOWN) {
            (*__errno_location ()) = 22;
            diminuto_log_perror("src/diminuto_fd.c", 262, "diminuto_fd_type: stat.st_mode");
        }
    }
    return type;
}

variable_types: enum DiminutoFsType { DIMINUTO_FS_TYPE_NONE=expr, DIMINUTO_FS_TYPE_UNKNOWN=expr, DIMINUTO_FS_TYPE_TTY=expr, DIMINUTO_FS_TYPE_SOCKET=expr, DIMINUTO_FS_TYPE_SYMLINK=expr, DIMINUTO_FS_TYPE_FILE=expr, DIMINUTO_FS_TYPE_BLOCKDEV=expr, DIMINUTO_FS_TYPE_DIRECTORY=expr, DIMINUTO_FS_TYPE_CHARACTERDEV=expr, DIMINUTO_FS_TYPE_FIFO=expr, DIMINUTO_FS_TYPE_0=expr, DIMINUTO_FS_TYPE_1=expr, DIMINUTO_FS_TYPE_2=expr, DIMINUTO_FS_TYPE_3=expr, DIMINUTO_FS_TYPE_4=expr, DIMINUTO_FS_TYPE_5=expr, DIMINUTO_FS_TYPE_6=expr, DIMINUTO_FS_TYPE_7=expr, DIMINUTO_FS_TYPE_8=expr, DIMINUTO_FS_TYPE_9=expr, DIMINUTO_FS_TYPE_A=expr, DIMINUTO_FS_TYPE_B=expr, DIMINUTO_FS_TYPE_C=expr, DIMINUTO_FS_TYPE_D=expr, DIMINUTO_FS_TYPE_E=expr, DIMINUTO_FS_TYPE_F=expr }

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


flicker

decompiled_code:
__int64 __fastcall flicker(int a1, int a2)
{
double v2; // xmm0_8

if ( a1 && a2 )
v2 = ((double)(int)abs32(a1 + a2) / 255.0 + (double)(int)abs32(a2 - a1) / 255.0) * 0.5 * 100.0;
else
v2 = 0.0;
return (unsigned int)(int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2)
{
double v2; // xmm0_8

if ( a1 && a2 )
v2 = ((double)(int)abs32(a1 + a2) / 255.0 + (double)(int)abs32(a2 - a1) / 255.0) * 0.5 * 100.0;
else
v2 = 0.0;
return (unsigned int)(int)v2;
}

original_code:
static uint32_t flicker(uint32_t on, uint32_t off)
{
    double score;
    if (off == 0) {
        score = 0.0;
    } else if (on == 0) {
        score = 0.0;
    } else {
        double accum;
        accum = abs(off - on);
        accum /= MAX;
        score = accum;
        accum = abs(off + on);
        accum /= MAX;
        score += accum;
        score /= 2.0;
        score *= 100.0;
    }
    return (unsigned int)score;
}

canonical_original_code:
static unsigned int flicker(unsigned int on, unsigned int off)
{
    double score;
    if (off == 0) {
        score = 0.0;
    } else if (on == 0) {
        score = 0.0;
    } else {
        double accum;
        accum = abs(off - on);
        accum /= MAX;
        score = accum;
        accum = abs(off + on);
        accum /= MAX;
        score += accum;
        score /= 2.0;
        score *= 100.0;
    }
    return (unsigned int)score;
}

variable_types:
on
unsigned int

variable_types:
off
unsigned int

variable_types: score double

variable_types: accum double

return_type: unsigned int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int16 v3; // bp
double v4; // xmm0_8
double v5; // xmm0_8
unsigned __int64 v6; // rsi
__int16 v7; // r11
int v8; // er8
unsigned __int64 v9; // rbx
unsigned __int64 v10; // rdi
int v11; // er13
unsigned __int64 v12; // r12
unsigned __int16 *v13; // r14
unsigned __int16 v14; // r9
unsigned __int64 v15; // r14
unsigned __int16 v16; // ax
unsigned int v17; // eax
unsigned __int16 v18; // dx
__int64 i; // [rsp+8h] [rbp-3370h]
unsigned int v21; // [rsp+10h] [rbp-3368h]
unsigned __int16 v22; // [rsp+1Eh] [rbp-335Ah]
__int16 s[6572]; // [rsp+20h] [rbp-3358h] BYREF

printf("%10s %10s %10s %10s %5s %5s %s\n", "DUTY", "LIMIT", "ON", "OFF", "SCORE", "COUNT", "FACTORS");
v22 = 0;
v3 = 0;
for ( i = 0LL; i != 256; ++i )
{
v12 = 255 - i;
if ( i < 0 )
v4 = (double)(int)(i & 1 | ((unsigned __int64)i >> 1)) + (double)(int)(i & 1 | ((unsigned __int64)i >> 1));
else
v4 = (double)(int)i;
if ( v4 < 0.0 )
v5 = sqrt(v4);
else
v5 = sqrt(v4);
v21 = (int)v5;
if ( (unsigned int)(int)v5 > 0x198D )
__assert_fail("limit < countof(PRIMES)", "fun/pwmfactors.c", 0x2ECu, "main");
memset(s, 0, 0x331CuLL);
if ( v21 )
{
v13 = (unsigned __int16 *)&PRIMES;
v9 = i;
v11 = 0;
do
{
v14 = *v13;
v10 = v9 / *v13;
if ( *v13 <= v9 && !(v9 % v14) )
{
v6 = v12 / v14;
if ( v14 <= v12 && !(v12 % v14) )
{
if ( v14 > 0x198Du )
__assert_fail("prime < countof(used)", "fun/pwmfactors.c", 0x2F7u, "main");
v8 = v11;
while ( 1 )
{
v7 = s[v14] + 1 - v11 + v8++;
if ( v3 < v14 )
v3 = *v13;
v9 = v10;
v10 /= v14;
if ( v14 > v9 )
break;
if ( v9 % v14 )
{
s[v14] = v7;
v11 = v8;
v12 = v6;
goto LABEL_17;
}
if ( v14 > v6 )
{
s[v14] = v7;
v11 = v8;
v12 = v6;
goto LABEL_17;
}
if ( v6 % v14 )
{
s[v14] = v7;
v11 = v8;
v12 = v6;
goto LABEL_17;
}
v6 /= v14;
}
s[v14] = v7;
v11 = v8;
v12 = v6;
}
}
LABEL_17:
++v13;
}
while ( (unsigned __int16 *)((char *)&PRIMES + 2 * v21) != v13 );
}
else
{
v9 = i;
LOWORD(v11) = 0;
}
v15 = 0xFF % (v9 + v12);
if ( v15 )
__assert_fail("(MAX % (on + off)) == 0", "fun/pwmfactors.c", 0x2FEu, "main");
if ( (unsigned __int16)v11 >= v22 )
{
v16 = v22;
if ( v22 < (unsigned __int16)v11 )
v16 = v11;
v22 = v16;
v17 = flicker(v9, v12);
printf("%10llu %10llu %10llu %10llu %5u %5u ", i, v21, v9, v12, v17, (unsigned __int16)v11);
do
{
v18 = s[v15];
if ( v18 )
printf(" %u^%u,", (unsigned int)v15, v18);
++v15;
}
while ( v15 != 6542 );
printf(" (%u)\n", v3);
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int16 v3; // bp
double v4; // xmm0_8
double v5; // xmm0_8
unsigned __int64 v6; // rsi
__int16 v7; // r11
int v8; // er8
unsigned __int64 v9; // rbx
unsigned __int64 v10; // rdi
int v11; // er13
unsigned __int64 v12; // r12
unsigned __int16 *v13; // r14
unsigned __int16 v14; // r9
unsigned __int64 v15; // r14
unsigned __int16 v16; // ax
unsigned int v17; // eax
unsigned __int16 v18; // dx
__int64 i; // [rsp+8h] [rbp-3370h]
unsigned int v21; // [rsp+10h] [rbp-3368h]
unsigned __int16 v22; // [rsp+1Eh] [rbp-335Ah]
__int16 s[6572]; // [rsp+20h] [rbp-3358h] BYREF

printf("%10s %10s %10s %10s %5s %5s %s\n", "DUTY", "LIMIT", "ON", "OFF", "SCORE", "COUNT", "FACTORS");
v22 = 0;
v3 = 0;
for ( i = 0LL; i != 256; ++i )
{
v12 = 255 - i;
if ( i < 0 )
v4 = (double)(int)(i & 1 | ((unsigned __int64)i >> 1)) + (double)(int)(i & 1 | ((unsigned __int64)i >> 1));
else
v4 = (double)(int)i;
if ( v4 < 0.0 )
v5 = sqrt(v4);
else
v5 = sqrt(v4);
v21 = (int)v5;
if ( (unsigned int)(int)v5 > 0x198D )
__assert_fail("limit < countof(PRIMES)", "fun/pwmfactors.c", 0x2ECu, "main");
memset(s, 0, 0x331CuLL);
if ( v21 )
{
v13 = (unsigned __int16 *)&PRIMES;
v9 = i;
v11 = 0;
do
{
v14 = *v13;
v10 = v9 / *v13;
if ( *v13 <= v9 && !(v9 % v14) )
{
v6 = v12 / v14;
if ( v14 <= v12 && !(v12 % v14) )
{
if ( v14 > 0x198Du )
__assert_fail("prime < countof(used)", "fun/pwmfactors.c", 0x2F7u, "main");
v8 = v11;
while ( 1 )
{
v7 = s[v14] + 1 - v11 + v8++;
if ( v3 < v14 )
v3 = *v13;
v9 = v10;
v10 /= v14;
if ( v14 > v9 )
break;
if ( v9 % v14 )
{
s[v14] = v7;
v11 = v8;
v12 = v6;
goto LABEL_17;
}
if ( v14 > v6 )
{
s[v14] = v7;
v11 = v8;
v12 = v6;
goto LABEL_17;
}
if ( v6 % v14 )
{
s[v14] = v7;
v11 = v8;
v12 = v6;
goto LABEL_17;
}
v6 /= v14;
}
s[v14] = v7;
v11 = v8;
v12 = v6;
}
}
LABEL_17:
++v13;
}
while ( (unsigned __int16 *)((char *)&PRIMES + 2 * v21) != v13 );
}
else
{
v9 = i;
LOWORD(v11) = 0;
}
v15 = 0xFF % (v9 + v12);
if ( v15 )
__assert_fail("(MAX % (on + off)) == 0", "fun/pwmfactors.c", 0x2FEu, "main");
if ( (unsigned __int16)v11 >= v22 )
{
v16 = v22;
if ( v22 < (unsigned __int16)v11 )
v16 = v11;
v22 = v16;
v17 = func7(v9, v12);
printf("%10llu %10llu %10llu %10llu %5u %5u ", i, v21, v9, v12, v17, (unsigned __int16)v11);
do
{
v18 = s[v15];
if ( v18 )
printf(" %u^%u,", (unsigned int)v15, v18);
++v15;
}
while ( v15 != 6542 );
printf(" (%u)\n", v3);
}
}
return 0;
}

original_code:
int main(int argc, char * argv[])
{
    int index;
    uint64_t duty;
    uint64_t on;
    uint64_t off;
    uint64_t on0;
    uint64_t off0;
    uint32_t limit;
    uint16_t prime;
    uint16_t highest;
    uint16_t used[(sizeof(PRIMES) / sizeof(PRIMES[0]))];
    uint16_t count;
    uint16_t most;
    uint32_t score;
    printf("%10s %10s %10s %10s %5s %5s %s\n", "DUTY", "LIMIT", "ON", "OFF", "SCORE", "COUNT", "FACTORS");
    most = 0;
    highest = 0;
    for (duty = MIN; duty <= MAX; ++duty) {
        on = duty;
        off = MAX - on;
        ((void) sizeof (((MAX % (on + off)) == 0) ? 1 : 0), __extension__ ({ if ((MAX % (on + off)) == 0) ; else __assert_fail ("(MAX % (on + off)) == 0", "fun/pwmfactors.c", 745, __extension__ __PRETTY_FUNCTION__); }));
        limit = (uint32_t)sqrt((double)duty);
        ((void) sizeof ((limit < (sizeof(PRIMES) / sizeof(PRIMES[0]))) ? 1 : 0), __extension__ ({ if (limit < (sizeof(PRIMES) / sizeof(PRIMES[0]))) ; else __assert_fail ("limit < countof(PRIMES)", "fun/pwmfactors.c", 748, __extension__ __PRETTY_FUNCTION__); }));
        memset(&used, 0, sizeof(used));
        count = 0;
        for (index = 0; index < limit; ++index) {
            ((void) sizeof ((index < (sizeof(PRIMES) / sizeof(PRIMES[0]))) ? 1 : 0), __extension__ ({ if (index < (sizeof(PRIMES) / sizeof(PRIMES[0]))) ; else __assert_fail ("index < countof(PRIMES)", "fun/pwmfactors.c", 754, __extension__ __PRETTY_FUNCTION__); }));
            prime = PRIMES[index];
            while (((on0 = (on / prime)) > 0) && ((on % prime) == 0) && ((off0 = (off / prime)) > 0) && ((off % prime) == 0)) {
                on = on0;
                off = off0;
                ((void) sizeof ((prime < (sizeof(used) / sizeof(used[0]))) ? 1 : 0), __extension__ ({ if (prime < (sizeof(used) / sizeof(used[0]))) ; else __assert_fail ("prime < countof(used)", "fun/pwmfactors.c", 759, __extension__ __PRETTY_FUNCTION__); }));
                used[prime]++;
                count++;
                if (prime > highest) { highest = prime; }
            }
        }
        ((void) sizeof (((MAX % (on + off)) == 0) ? 1 : 0), __extension__ ({ if ((MAX % (on + off)) == 0) ; else __assert_fail ("(MAX % (on + off)) == 0", "fun/pwmfactors.c", 766, __extension__ __PRETTY_FUNCTION__); }));
        if (count < most) {
            continue;
        }
        if (count > most) {
            most = count;
        }
        score = flicker(on, off);
        printf("%10llu %10llu %10llu %10llu %5u %5u ", (unsigned long long)duty, (unsigned long long)limit, (unsigned long long)on, (unsigned long long)off, score, count);
        for (index = 0; index < (sizeof(used) / sizeof(used[0])); ++index) {
            if (used[index] > 0) {
                printf(" %u^%u,", index, used[index]);
            }
        }
        printf(" (%u)\n", highest);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int index;
    unsigned long duty;
    unsigned long on;
    unsigned long off;
    unsigned long on0;
    unsigned long off0;
    unsigned int limit;
    unsigned short prime;
    unsigned short highest;
    unsigned short used[-1];
    unsigned short count;
    unsigned short most;
    unsigned int score;
    printf("%10s %10s %10s %10s %5s %5s %s\n", "DUTY", "LIMIT", "ON", "OFF", "SCORE", "COUNT", "FACTORS");
    most = 0;
    highest = 0;
    for (duty = MIN; duty <= MAX; ++duty) {
        on = duty;
        off = MAX - on;
        ((void) sizeof (((MAX % (on + off)) == 0) ? 1 : 0), __extension__ ({ if ((MAX % (on + off)) == 0) ; else __assert_fail ("(MAX % (on + off)) == 0", "fun/pwmfactors.c", 745, __extension__ __PRETTY_FUNCTION__); }));
        limit = (unsigned int)sqrt((double)duty);
        ((void) sizeof ((limit < (sizeof(PRIMES) / sizeof(PRIMES[0]))) ? 1 : 0), __extension__ ({ if (limit < (sizeof(PRIMES) / sizeof(PRIMES[0]))) ; else __assert_fail ("limit < countof(PRIMES)", "fun/pwmfactors.c", 748, __extension__ __PRETTY_FUNCTION__); }));
        memset(&used, 0, sizeof(used));
        count = 0;
        for (index = 0; index < limit; ++index) {
            ((void) sizeof ((index < (sizeof(PRIMES) / sizeof(PRIMES[0]))) ? 1 : 0), __extension__ ({ if (index < (sizeof(PRIMES) / sizeof(PRIMES[0]))) ; else __assert_fail ("index < countof(PRIMES)", "fun/pwmfactors.c", 754, __extension__ __PRETTY_FUNCTION__); }));
            prime = PRIMES[index];
            while (((on0 = (on / prime)) > 0) && ((on % prime) == 0) && ((off0 = (off / prime)) > 0) && ((off % prime) == 0)) {
                on = on0;
                off = off0;
                ((void) sizeof ((prime < (sizeof(used) / sizeof(used[0]))) ? 1 : 0), __extension__ ({ if (prime < (sizeof(used) / sizeof(used[0]))) ; else __assert_fail ("prime < countof(used)", "fun/pwmfactors.c", 759, __extension__ __PRETTY_FUNCTION__); }));
                used[prime]++;
                count++;
                if (prime > highest) { highest = prime; }
            }
        }
        ((void) sizeof (((MAX % (on + off)) == 0) ? 1 : 0), __extension__ ({ if ((MAX % (on + off)) == 0) ; else __assert_fail ("(MAX % (on + off)) == 0", "fun/pwmfactors.c", 766, __extension__ __PRETTY_FUNCTION__); }));
        if (count < most) {
            continue;
        }
        if (count > most) {
            most = count;
        }
        score = flicker(on, off);
        printf("%10llu %10llu %10llu %10llu %5u %5u ", (unsigned long long)duty, (unsigned long long)limit, (unsigned long long)on, (unsigned long long)off, score, count);
        for (index = 0; index < (sizeof(used) / sizeof(used[0])); ++index) {
            if (used[index] > 0) {
                printf(" %u^%u,", index, used[index]);
            }
        }
        printf(" (%u)\n", highest);
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: index int

variable_types:
duty
unsigned long

variable_types:
on
unsigned long

variable_types:
off
unsigned long

variable_types:
limit
unsigned int

variable_types:
prime
unsigned short

variable_types:
highest
unsigned short

variable_types:
used
unsigned short [-1]

variable_types:
count
unsigned short

variable_types:
most
unsigned short

variable_types:
score
unsigned int


decompiled_code:
__int64 __fastcall diminuto_mutex_fini(__int64 a1)
{
int v1; // eax
__int64 result; // rax
int v3; // ebp

v1 = pthread_mutex_destroy((pthread_mutex_t *)a1);
if ( v1 )
{
*_errno_location() = v1;
diminuto_log_perror("src/diminuto_mutex.c", 53LL, "diminuto_mutex_fini: pthread_mutex_destroy");
result = a1;
}
else
{
v3 = pthread_mutexattr_destroy((pthread_mutexattr_t *)(a1 + 40));
result = 0LL;
if ( v3 )
{
*_errno_location() = v3;
diminuto_log_perror("src/diminuto_mutex.c", 56LL, "diminuto_mutex_fini: pthread_mutexattr_destroy");
result = a1;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
int v1; // eax
__int64 result; // rax
int v3; // ebp

v1 = pthread_mutex_destroy((pthread_mutex_t *)a1);
if ( v1 )
{
*_errno_location() = v1;
diminuto_log_perror("src/diminuto_mutex.c", 53LL, "diminuto_mutex_fini: pthread_mutex_destroy");
result = a1;
}
else
{
v3 = pthread_mutexattr_destroy((pthread_mutexattr_t *)(a1 + 40));
result = 0LL;
if ( v3 )
{
*_errno_location() = v3;
diminuto_log_perror("src/diminuto_mutex.c", 56LL, "diminuto_mutex_fini: pthread_mutexattr_destroy");
result = a1;
}
}
return result;
}

original_code:
diminuto_mutex_t * diminuto_mutex_fini(diminuto_mutex_t * mp)
{
    diminuto_mutex_t * result = mp;
    int rc = DIMINUTO_MUTEX_ERROR;
    if ((rc = pthread_mutex_destroy(&(mp->mutex))) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 53, "diminuto_mutex_fini: pthread_mutex_destroy");
    } else if ((rc = pthread_mutexattr_destroy(&(mp->attribute))) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 56, "diminuto_mutex_fini: pthread_mutexattr_destroy");
    } else {
        result = (diminuto_mutex_t *)0;
    }
    return result;
}

canonical_original_code:
struct DiminutoMutex *diminuto_mutex_fini(struct DiminutoMutex *mp)
{
    struct DiminutoMutex *result = mp;
    int rc = DIMINUTO_MUTEX_ERROR;
    if ((rc = pthread_mutex_destroy(&(mp->mutex))) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 53, "diminuto_mutex_fini: pthread_mutex_destroy");
    } else if ((rc = pthread_mutexattr_destroy(&(mp->attribute))) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 56, "diminuto_mutex_fini: pthread_mutexattr_destroy");
    } else {
        result = (struct DiminutoMutex *)0;
    }
    return result;
}

variable_types:
mp
struct DiminutoMutex *

variable_types: struct DiminutoMutex { 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; } mutex; union pthread_mutexattr_t { char __size[4]; int __align; } attribute; } *

variable_types: rc int

user_defined_types: struct DiminutoMutex { union pthread_mutex_t mutex; union pthread_mutexattr_t attribute; }

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:
__int64 __fastcall diminuto_mutex_lock(pthread_mutex_t *a1)
{
unsigned int v1; // ebx

v1 = pthread_mutex_lock(a1);
if ( v1 )
{
*_errno_location() = v1;
diminuto_log_perror("src/diminuto_mutex.c", 74LL, "diminuto_mutex_lock: pthread_mutex_lock");
}
return v1;
}

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

v1 = pthread_mutex_lock(a1);
if ( v1 )
{
*_errno_location() = v1;
diminuto_log_perror("src/diminuto_mutex.c", 74LL, "diminuto_mutex_lock: pthread_mutex_lock");
}
return v1;
}

original_code:
int diminuto_mutex_lock(diminuto_mutex_t * mp)
{
    int rc = DIMINUTO_MUTEX_ERROR;
    if ((rc = pthread_mutex_lock(&(mp->mutex))) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 74, "diminuto_mutex_lock: pthread_mutex_lock");
    }
    return rc;
}

canonical_original_code:
int diminuto_mutex_lock(struct DiminutoMutex *mp)
{
    int rc = DIMINUTO_MUTEX_ERROR;
    if ((rc = pthread_mutex_lock(&(mp->mutex))) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 74, "diminuto_mutex_lock: pthread_mutex_lock");
    }
    return rc;
}

user_defined_types: union pthread_mutexattr_t { char __size[4]; int __align; }

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


decompiled_code:
__int64 __fastcall diminuto_mutex_lock_try(pthread_mutex_t *a1)
{
unsigned int v1; // ebx

v1 = pthread_mutex_trylock(a1);
if ( (v1 & 0xFFFFFFEF) != 0 )
{
*_errno_location() = v1;
diminuto_log_perror("src/diminuto_mutex.c", 90LL, "diminuto_mutex_lock_try: pthread_mutex_trylock");
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(pthread_mutex_t *a1)
{
unsigned int v1; // ebx

v1 = pthread_mutex_trylock(a1);
if ( (v1 & 0xFFFFFFEF) != 0 )
{
*_errno_location() = v1;
diminuto_log_perror("src/diminuto_mutex.c", 90LL, "diminuto_mutex_lock_try: pthread_mutex_trylock");
}
return v1;
}

original_code:
int diminuto_mutex_lock_try(diminuto_mutex_t * mp)
{
    int rc = DIMINUTO_MUTEX_ERROR;
    if ((rc = pthread_mutex_trylock(&(mp->mutex))) == 0) {
    } else if (rc == DIMINUTO_MUTEX_BUSY) {
    } else {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 90, "diminuto_mutex_lock_try: pthread_mutex_trylock");
    }
    return rc;
}

canonical_original_code:
int diminuto_mutex_lock_try(struct DiminutoMutex *mp)
{
    int rc = DIMINUTO_MUTEX_ERROR;
    if ((rc = pthread_mutex_trylock(&(mp->mutex))) == 0) {
    } else if (rc == DIMINUTO_MUTEX_BUSY) {
    } else {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 90, "diminuto_mutex_lock_try: pthread_mutex_trylock");
    }
    return rc;
}


decompiled_code:
__int64 __fastcall diminuto_mutex_unlock(pthread_mutex_t *a1)
{
unsigned int v1; // ebx

v1 = pthread_mutex_unlock(a1);
if ( v1 )
{
*_errno_location() = v1;
diminuto_log_perror("src/diminuto_mutex.c", 102LL, "diminuto_mutex_unlock: pthread_mutex_unlock");
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func3(pthread_mutex_t *a1)
{
unsigned int v1; // ebx

v1 = pthread_mutex_unlock(a1);
if ( v1 )
{
*_errno_location() = v1;
diminuto_log_perror("src/diminuto_mutex.c", 102LL, "diminuto_mutex_unlock: pthread_mutex_unlock");
}
return v1;
}

original_code:
int diminuto_mutex_unlock(diminuto_mutex_t * mp)
{
    int rc = DIMINUTO_MUTEX_ERROR;
    if ((rc = pthread_mutex_unlock(&(mp->mutex))) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 102, "diminuto_mutex_unlock: pthread_mutex_unlock");
    }
    return rc;
}

canonical_original_code:
int diminuto_mutex_unlock(struct DiminutoMutex *mp)
{
    int rc = DIMINUTO_MUTEX_ERROR;
    if ((rc = pthread_mutex_unlock(&(mp->mutex))) != 0) {
        (*__errno_location ()) = rc;
        diminuto_log_perror("src/diminuto_mutex.c", 102, "diminuto_mutex_unlock: pthread_mutex_unlock");
    }
    return rc;
}


decompiled_code:
__int64 __fastcall diminuto_mutex_cleanup(pthread_mutex_t *a1)
{
return diminuto_mutex_unlock(a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(pthread_mutex_t *a1)
{
return func3(a1);
}

original_code:
void diminuto_mutex_cleanup(void * vp)
{
    diminuto_mutex_t * mp = (diminuto_mutex_t *)vp;
    diminuto_mutex_unlock(mp);
}

canonical_original_code:
void diminuto_mutex_cleanup(void *vp)
{
    struct DiminutoMutex *mp = (diminuto_mutex_t *)vp;
    diminuto_mutex_unlock(mp);
}

variable_types:
vp
void *

return_type: void


decompiled_code:
__int64 diminuto_ipc_endpoint()
{
return diminuto_ipc_endpoint_prefer();
}

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

original_code:
static inline int diminuto_ipc_endpoint(const char * string, diminuto_ipc_endpoint_t * endpoint) {
    return diminuto_ipc_endpoint_prefer(string, endpoint, DIMINUTO_IPC_PREFERENCE_NONE);
}

canonical_original_code:
static inline int diminuto_ipc_endpoint(char *string, struct DiminutoIpcEndpoint *endpoint) {
    return diminuto_ipc_endpoint_prefer(string, endpoint, DIMINUTO_IPC_PREFERENCE_NONE);
}

variable_types:
string
char *

variable_types: struct DiminutoIpcEndpoint { enum DiminutoIpcType { DIMINUTO_IPC_TYPE_UNSPECIFIED=0, DIMINUTO_IPC_TYPE_IPV4=2, DIMINUTO_IPC_TYPE_IPV6=10, DIMINUTO_IPC_TYPE_LOCAL=1 } type; unsigned int ipv4; struct diminuto_ipv6_t { unsigned short u16[-1]; } ipv6; unsigned short tcp; unsigned short udp; char local[-1]; } *

user_defined_types: struct DiminutoIpcEndpoint { enum DiminutoIpcType type; unsigned int ipv4; struct diminuto_ipv6_t ipv6; unsigned short tcp; unsigned short udp; char local[-1]; }


decompiled_code:
int __fastcall diminuto_ipc6_compare(const void *a1, const void *a2)
{
return memcmp(a1, a2, 0x10uLL);
}

canonical_decompiled_code:
int __fastcall func10(const void *a1, const void *a2)
{
return memcmp(a1, a2, 0x10uLL);
}

original_code:
static inline int diminuto_ipc6_compare(const diminuto_ipv6_t * address1p, const diminuto_ipv6_t * address2p) {
    return memcmp(address1p, address2p, sizeof(diminuto_ipv6_t));
}

canonical_original_code:
static inline int diminuto_ipc6_compare(struct diminuto_ipv6_t *address1p, struct diminuto_ipv6_t *address2p) {
    return memcmp(address1p, address2p, sizeof(diminuto_ipv6_t));
}

variable_types: struct diminuto_ipv6_t { unsigned short u16[-1]; } *


decompiled_code:
_BOOL8 __fastcall diminuto_ipc6_is_unspecified(const void *a1)
{
return diminuto_ipc6_compare(a1, &DIMINUTO_IPC6_UNSPECIFIED) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(const void *a1)
{
return func10(a1, &DIMINUTO_IPC6_UNSPECIFIED) == 0;
}

original_code:
static inline int diminuto_ipc6_is_unspecified(const diminuto_ipv6_t * addressp) {
    return (diminuto_ipc6_compare(addressp, &DIMINUTO_IPC6_UNSPECIFIED) == 0);
}

canonical_original_code:
static inline int diminuto_ipc6_is_unspecified(struct diminuto_ipv6_t *addressp) {
    return (diminuto_ipc6_compare(addressp, &DIMINUTO_IPC6_UNSPECIFIED) == 0);
}

user_defined_types: struct diminuto_ipv6_t { unsigned short u16[-1]; }


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

result = "IPV4";
if ( a1 != 2 )
{
if ( a1 > 2 )
{
result = "IPV6";
if ( a1 != 10 )
{
snprintf(buffer_0, 0xCuLL, "%d", a1);
byte_4290E3 = 0;
result = buffer_0;
}
}
else
{
result = "LOCAL";
if ( !a1 )
result = "UNSPECIFIED";
}
}
return result;
}

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

result = "IPV4";
if ( a1 != 2 )
{
if ( a1 > 2 )
{
result = "IPV6";
if ( a1 != 10 )
{
snprintf(buffer_0, 0xCuLL, "%d", a1);
byte_4290E3 = 0;
result = buffer_0;
}
}
else
{
result = "LOCAL";
if ( !a1 )
result = "UNSPECIFIED";
}
}
return result;
}

original_code:
static const char * type2string(diminuto_ipc_type_t type)
{
    static char buffer[sizeof(int) * 3];
    const char * result = "invalid";
    switch (type) {
    case DIMINUTO_IPC_TYPE_UNSPECIFIED: result = "UNSPECIFIED"; break;
    case DIMINUTO_IPC_TYPE_IPV4: result = "IPV4"; break;
    case DIMINUTO_IPC_TYPE_IPV6: result = "IPV6"; break;
    case DIMINUTO_IPC_TYPE_LOCAL: result = "LOCAL"; break;
    default:
        snprintf(buffer, sizeof(buffer), "%d", type);
        buffer[sizeof(buffer) - 1] = '\0';
        result = buffer;
        break;
    }
    return result;
}

canonical_original_code:
static char *type2string(enum DiminutoIpcType type)
{
    static char buffer[-1];
    char *result = "invalid";
    switch (type) {
    case DIMINUTO_IPC_TYPE_UNSPECIFIED: result = "UNSPECIFIED"; break;
    case DIMINUTO_IPC_TYPE_IPV4: result = "IPV4"; break;
    case DIMINUTO_IPC_TYPE_IPV6: result = "IPV6"; break;
    case DIMINUTO_IPC_TYPE_LOCAL: result = "LOCAL"; break;
    default:
        snprintf(buffer, sizeof(buffer), "%d", type);
        buffer[sizeof(buffer) - 1] = '\0';
        result = buffer;
        break;
    }
    return result;
}

variable_types: enum DiminutoIpcType { DIMINUTO_IPC_TYPE_UNSPECIFIED=0, DIMINUTO_IPC_TYPE_IPV4=2, DIMINUTO_IPC_TYPE_IPV6=10, DIMINUTO_IPC_TYPE_LOCAL=1 }

variable_types:
buffer
char [-1]

variable_types:
result
char *

return_type: char *


decompiled_code:
void *__fastcall diminuto_heap_malloc_set(void *(**a1)(size_t size))
{
void *v1; // rbx
void *(**v2)(size_t); // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned int)diminuto_criticalsection_lock(&mutex_3) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex_3);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = diminuto_heap_malloc_func_p;
v2 = a1;
if ( !a1 )
v2 = &malloc;
diminuto_heap_malloc_func_p = v2;
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex_3);
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func0(void *(**a1)(size_t size))
{
void *v1; // rbx
void *(**v2)(size_t); // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned int)diminuto_criticalsection_lock(&mutex_3) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex_3);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = diminuto_heap_malloc_func_p;
v2 = a1;
if ( !a1 )
v2 = &malloc;
diminuto_heap_malloc_func_p = v2;
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex_3);
}
return v1;
}

original_code: diminuto_heap_malloc_func_t * diminuto_heap_malloc_set(diminuto_heap_malloc_func_t * now) { static pthread_mutex_t mutex = { { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } }; diminuto_heap_malloc_func_t * was; 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); was = diminuto_heap_malloc_func_p; diminuto_heap_malloc_func_p = (now != (diminuto_heap_malloc_func_t *)0) ? now : &malloc; } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0); return was; }

canonical_original_code: void *(*diminuto_heap_malloc_set(void *(*now)(unsigned long size)))(unsigned long size) { static union pthread_mutex_t mutex = { { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } }; void *(*was)(unsigned long size); 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); was = diminuto_heap_malloc_func_p; diminuto_heap_malloc_func_p = (now != (void *(*)(unsigned long size))0) ? now : &malloc; } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0); return was; }

variable_types:
now
void *(*)(unsigned long size)

variable_types:
was
void *(*)(unsigned long size)

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

return_type: void *(*)(unsigned long size)


decompiled_code:
void *__fastcall diminuto_heap_free_set(void (**a1)(void *ptr))
{
void *v1; // rbx
void (**v2)(void *); // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned int)diminuto_criticalsection_lock(&mutex_2) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex_2);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = diminuto_heap_free_func_p;
v2 = a1;
if ( !a1 )
v2 = &free;
diminuto_heap_free_func_p = v2;
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex_2);
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func1(void (**a1)(void *ptr))
{
void *v1; // rbx
void (**v2)(void *); // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned int)diminuto_criticalsection_lock(&mutex_2) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex_2);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = diminuto_heap_free_func_p;
v2 = a1;
if ( !a1 )
v2 = &free;
diminuto_heap_free_func_p = v2;
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex_2);
}
return v1;
}

original_code: diminuto_heap_free_func_t * diminuto_heap_free_set(diminuto_heap_free_func_t * now) { static pthread_mutex_t mutex = { { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } }; diminuto_heap_free_func_t * was; 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); was = diminuto_heap_free_func_p; diminuto_heap_free_func_p = (now != (diminuto_heap_free_func_t *)0) ? now : &free; } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0); return was; }

canonical_original_code: void (*diminuto_heap_free_set(void (*now)(void *ptr)))(void *ptr) { static union pthread_mutex_t mutex = { { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } }; void (*was)(void *ptr); 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); was = diminuto_heap_free_func_p; diminuto_heap_free_func_p = (now != (void (*)(void *ptr))0) ? now : &free; } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0); return was; }

variable_types:
now
void (*)(void *ptr)

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:
was
void (*)(void *ptr)

return_type: void (*)(void *ptr)

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:
void *__fastcall diminuto_heap_calloc_set(void *(**a1)(size_t nmemb, size_t size))
{
void *v1; // rbx
void *(**v2)(size_t, size_t); // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned int)diminuto_criticalsection_lock(&mutex_1) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex_1);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = diminuto_heap_calloc_func_p;
v2 = a1;
if ( !a1 )
v2 = &calloc;
diminuto_heap_calloc_func_p = v2;
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex_1);
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func2(void *(**a1)(size_t nmemb, size_t size))
{
void *v1; // rbx
void *(**v2)(size_t, size_t); // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned int)diminuto_criticalsection_lock(&mutex_1) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex_1);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = diminuto_heap_calloc_func_p;
v2 = a1;
if ( !a1 )
v2 = &calloc;
diminuto_heap_calloc_func_p = v2;
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex_1);
}
return v1;
}

original_code: diminuto_heap_calloc_func_t * diminuto_heap_calloc_set(diminuto_heap_calloc_func_t * now) { static pthread_mutex_t mutex = { { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } }; diminuto_heap_calloc_func_t * was; 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); was = diminuto_heap_calloc_func_p; diminuto_heap_calloc_func_p = (now != (diminuto_heap_calloc_func_t *)0) ? now : &calloc; } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0); return was; }

canonical_original_code: void *(*diminuto_heap_calloc_set(void *(*now)(unsigned long nmemb, unsigned long size)))(unsigned long nmemb, unsigned long size) { static union pthread_mutex_t mutex = { { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } }; void *(*was)(unsigned long nmemb, unsigned long size); 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); was = diminuto_heap_calloc_func_p; diminuto_heap_calloc_func_p = (now != (void *(*)(unsigned long nmemb, unsigned long size))0) ? now : &calloc; } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0); return was; }


decompiled_code:
void *__fastcall diminuto_heap_realloc_set(void *(**a1)(void *ptr, size_t size))
{
void *v1; // rbx
void *(**v2)(void *, size_t); // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned int)diminuto_criticalsection_lock(&mutex_0) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex_0);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = diminuto_heap_realloc_func_p;
v2 = a1;
if ( !a1 )
v2 = &realloc;
diminuto_heap_realloc_func_p = v2;
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex_0);
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func3(void *(**a1)(void *ptr, size_t size))
{
void *v1; // rbx
void *(**v2)(void *, size_t); // rax
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned int)diminuto_criticalsection_lock(&mutex_0) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex_0);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = diminuto_heap_realloc_func_p;
v2 = a1;
if ( !a1 )
v2 = &realloc;
diminuto_heap_realloc_func_p = v2;
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex_0);
}
return v1;
}

original_code: diminuto_heap_realloc_func_t * diminuto_heap_realloc_set(diminuto_heap_realloc_func_t * now) { static pthread_mutex_t mutex = { { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } }; diminuto_heap_realloc_func_t * was; 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); was = diminuto_heap_realloc_func_p; diminuto_heap_realloc_func_p = (now != (diminuto_heap_realloc_func_t *)0) ? now : &realloc; } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0); return was; }

canonical_original_code: void *(*diminuto_heap_realloc_set(void *(*now)(void *ptr, unsigned long size)))(void *ptr, unsigned long size) { static union pthread_mutex_t mutex = { { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } }; void *(*was)(void *ptr, unsigned long size); 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); was = diminuto_heap_realloc_func_p; diminuto_heap_realloc_func_p = (now != (void *(*)(void *ptr, unsigned long size))0) ? now : &realloc; } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0); return was; }


decompiled_code:
__int64 diminuto_heap_calloc()
{
return diminuto_heap_calloc_func_p();
}

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

original_code: void * diminuto_heap_calloc (size_t nmemb, size_t size) { return (*diminuto_heap_calloc_func_p)(nmemb, size); }

canonical_original_code: void *diminuto_heap_calloc(unsigned long nmemb, unsigned long size) { return (*diminuto_heap_calloc_func_p)(nmemb, size); }

variable_types:
nmemb
unsigned long

variable_types:
size
unsigned long


decompiled_code:
__int64 diminuto_heap_realloc()
{
return diminuto_heap_realloc_func_p();
}

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

original_code: void * diminuto_heap_realloc (void * ptr, size_t size) { return (*diminuto_heap_realloc_func_p)(ptr, size); }

canonical_original_code: void *diminuto_heap_realloc(void *ptr, unsigned long size) { return (*diminuto_heap_realloc_func_p)(ptr, size); }

variable_types:
ptr
void *


decompiled_code:
__int64 diminuto_heap_malloc()
{
return diminuto_heap_malloc_func_p();
}

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

original_code: void * diminuto_heap_malloc (size_t size) { return (*diminuto_heap_malloc_func_p)(size); }

canonical_original_code: void *diminuto_heap_malloc(unsigned long size) { return (*diminuto_heap_malloc_func_p)(size); }


decompiled_code:
__int64 diminuto_heap_free()
{
return diminuto_heap_free_func_p();
}

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

original_code: void diminuto_heap_free (void * ptr) { (void) (*diminuto_heap_free_func_p)(ptr); }

canonical_original_code: void diminuto_heap_free(void *ptr) { (void) (*diminuto_heap_free_func_p)(ptr); }


decompiled_code:
_BOOL8 __fastcall diminuto_testify(__int64 a1, _BOOL4 a2)
{
int v4; // eax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

endptr = 0LL;
if ( a1 )
{
switch ( *(_BYTE *)a1 )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
v4 = strtol((const char *)a1, &endptr, 0);
if ( !*endptr )
a2 = v4 != 0;
break;
case 'A':
case 'C':
case 'E':
case 'H':
case 'T':
case 'U':
case 'Y':
case 'a':
case 'c':
case 'e':
case 'h':
case 't':
case 'u':
case 'y':
a2 = 1;
break;
case 'D':
case 'F':
case 'I':
case 'L':
case 'N':
case 'd':
case 'f':
case 'i':
case 'l':
case 'n':
a2 = 0;
break;
case 'O':
case 'o':
switch ( *(_BYTE *)(a1 + 1) )
{
case 'F':
case 'P':
case 'f':
case 'p':
a2 = 0;
break;
case 'N':
case 'n':
a2 = 1;
break;
default:
return a2;
}
break;
default:
return a2;
}
}
return a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1, _BOOL4 a2)
{
int v4; // eax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

endptr = 0LL;
if ( a1 )
{
switch ( *(_BYTE *)a1 )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
v4 = strtol((const char *)a1, &endptr, 0);
if ( !*endptr )
a2 = v4 != 0;
break;
case 'A':
case 'C':
case 'E':
case 'H':
case 'T':
case 'U':
case 'Y':
case 'a':
case 'c':
case 'e':
case 'h':
case 't':
case 'u':
case 'y':
a2 = 1;
break;
case 'D':
case 'F':
case 'I':
case 'L':
case 'N':
case 'd':
case 'f':
case 'i':
case 'l':
case 'n':
a2 = 0;
break;
case 'O':
case 'o':
switch ( *(_BYTE *)(a1 + 1) )
{
case 'F':
case 'P':
case 'f':
case 'p':
a2 = 0;
break;
case 'N':
case 'n':
a2 = 1;
break;
default:
return a2;
}
break;
default:
return a2;
}
}
return a2;
}

original_code:
int diminuto_testify(const char * testimony, int otherwise) {
    int result = otherwise;
    int32_t value = 0;
    char * endp = (char *)0;
    if (testimony != (const char *)0) {
        switch (testimony[0]) {
        case 'a': case 'A':
        case 'c': case 'C':
        case 'e': case 'E':
        case 'h': case 'H':
        case 't': case 'T':
        case 'u': case 'U':
        case 'y': case 'Y':
            result = !0;
            break;
        case 'd': case 'D':
        case 'f': case 'F':
        case 'i': case 'I':
        case 'n': case 'N':
        case 'l': case 'L':
            result = 0;
            break;
        case 'o': case 'O':
            switch (testimony[1]) {
            case 'n': case 'N':
                result = !0;
                break;
            case 'f': case 'F':
            case 'p': case 'P':
                result = 0;
                break;
            default:
                break;
            }
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            value = strtol(testimony, &endp, 0);
            result = (*endp == '\0') ? !!value : otherwise;
            break;
        default:
            break;
        }
    }
    return result;
}

canonical_original_code:
int diminuto_testify(char *testimony, int otherwise) {
    int result = otherwise;
    int value = 0;
    char *endp = (char *)0;
    if (testimony != (char *)0) {
        switch (testimony[0]) {
        case 'a': case 'A':
        case 'c': case 'C':
        case 'e': case 'E':
        case 'h': case 'H':
        case 't': case 'T':
        case 'u': case 'U':
        case 'y': case 'Y':
            result = !0;
            break;
        case 'd': case 'D':
        case 'f': case 'F':
        case 'i': case 'I':
        case 'n': case 'N':
        case 'l': case 'L':
            result = 0;
            break;
        case 'o': case 'O':
            switch (testimony[1]) {
            case 'n': case 'N':
                result = !0;
                break;
            case 'f': case 'F':
            case 'p': case 'P':
                result = 0;
                break;
            default:
                break;
            }
            break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            value = strtol(testimony, &endp, 0);
            result = (*endp == '\0') ? !!value : otherwise;
            break;
        default:
            break;
        }
    }
    return result;
}

variable_types:
testimony
char *

variable_types: otherwise int

variable_types: result int

variable_types: value int

variable_types:
endp
char *


decompiled_code:
char *__fastcall diminuto_map_map(unsigned __int64 a1, __int64 a2, char **a3, size_t *a4)
{
unsigned __int64 v6; // rbx
size_t v7; // rbp
int v8; // eax
int v9; // er12
char *v10; // rax
char *v11; // rbx

*a3 = 0LL;
*a4 = 0LL;
v6 = a1 % getpagesize();
v7 = v6 + a2;
v8 = open("/dev/mem", 1052674);
if ( v8 < 0 )
{
diminuto_log_perror("src/diminuto_map.c", 45LL, "diminuto_map_map: open");
v11 = 0LL;
}
else
{
v9 = v8;
v10 = (char *)mmap(0LL, v7, 3, 1, v8, a1 - v6);
if ( v10 == (char *)-1LL )
{
diminuto_log_perror("src/diminuto_map.c", 50LL, "diminuto_map_map: mmap");
v11 = 0LL;
}
else
{
*a3 = v10;
*a4 = v7;
v11 = &v10[v6];
}
if ( close(v9) < 0 )
diminuto_log_perror("src/diminuto_map.c", 64LL, "diminuto_map_map: close");
}
return v11;
}

canonical_decompiled_code:
char *__fastcall func0(unsigned __int64 a1, __int64 a2, char **a3, size_t *a4)
{
unsigned __int64 v6; // rbx
size_t v7; // rbp
int v8; // eax
int v9; // er12
char *v10; // rax
char *v11; // rbx

*a3 = 0LL;
*a4 = 0LL;
v6 = a1 % getpagesize();
v7 = v6 + a2;
v8 = open("/dev/mem", 1052674);
if ( v8 < 0 )
{
diminuto_log_perror("src/diminuto_map.c", 45LL, "diminuto_map_map: open");
v11 = 0LL;
}
else
{
v9 = v8;
v10 = (char *)mmap(0LL, v7, 3, 1, v8, a1 - v6);
if ( v10 == (char *)-1LL )
{
diminuto_log_perror("src/diminuto_map.c", 50LL, "diminuto_map_map: mmap");
v11 = 0LL;
}
else
{
*a3 = v10;
*a4 = v7;
v11 = &v10[v6];
}
if ( close(v9) < 0 )
diminuto_log_perror("src/diminuto_map.c", 64LL, "diminuto_map_map: close");
}
return v11;
}

original_code:
void * diminuto_map_map(uintptr_t start, size_t length, void ** startp, size_t * lengthp)
{
    void * result = (void *)0;
    int fd = -1;
    void * base = (void *)0;
    size_t size = 0;
    int pagesize;
    size_t offset;
    off_t address;
    do {
        *startp = (void *)0;
        *lengthp = 0;
        pagesize = getpagesize();
        offset = start % pagesize;
        address = start - offset;
        size = length + offset;
        if ((fd = open("/dev/mem", 02 | 04010000)) < 0) {
            diminuto_log_perror("src/diminuto_map.c", 45, "diminuto_map_map: open");
            break;
        }
        if ((base = mmap(0, size, (0x1 | 0x2), 0x01, fd, address)) == (void *)-1) {
            diminuto_log_perror("src/diminuto_map.c", 50, "diminuto_map_map: mmap");
            break;
        }
        *startp = base;
        *lengthp = size;
        result = (unsigned char *)base + offset;
    } while (0);
    if (fd < 0) {
    } else if ((fd = close(fd)) < 0) {
        diminuto_log_perror("src/diminuto_map.c", 64, "diminuto_map_map: close");
    }
    return result;
}

canonical_original_code:
void *diminuto_map_map(unsigned long start, unsigned long length, void **startp, unsigned long *lengthp)
{
    void *result = (void *)0;
    int fd = -1;
    void *base = (void *)0;
    unsigned long size = 0;
    int pagesize;
    unsigned long offset;
    long address;
    do {
        *startp = (void *)0;
        *lengthp = 0;
        pagesize = getpagesize();
        offset = start % pagesize;
        address = start - offset;
        size = length + offset;
        if ((fd = open("/dev/mem", 02 | 04010000)) < 0) {
            diminuto_log_perror("src/diminuto_map.c", 45, "diminuto_map_map: open");
            break;
        }
        if ((base = mmap(0, size, (0x1 | 0x2), 0x01, fd, address)) == (void *)-1) {
            diminuto_log_perror("src/diminuto_map.c", 50, "diminuto_map_map: mmap");
            break;
        }
        *startp = base;
        *lengthp = size;
        result = (unsigned char *)base + offset;
    } while (0);
    if (fd < 0) {
    } else if ((fd = close(fd)) < 0) {
        diminuto_log_perror("src/diminuto_map.c", 64, "diminuto_map_map: close");
    }
    return result;
}

variable_types:
start
unsigned long

variable_types:
length
unsigned long

variable_types:
startp
void **

variable_types:
lengthp
unsigned long *

variable_types:
result
void *

variable_types: fd int

variable_types:
base
void *

variable_types: pagesize int

variable_types:
offset
unsigned long

variable_types: address long


decompiled_code:
__int64 __fastcall diminuto_map_unmap(void **a1, size_t *a2)
{
size_t v3; // rsi
int v4; // er12

v3 = *a2;
v4 = 0;
if ( v3 )
{
v4 = munmap(*a1, v3);
if ( v4 < 0 )
{
diminuto_log_perror("src/diminuto_map.c", 78LL, "diminuto_map_unmap: munmap");
}
else
{
*a1 = 0LL;
*a2 = 0LL;
}
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(void **a1, size_t *a2)
{
size_t v3; // rsi
int v4; // er12

v3 = *a2;
v4 = 0;
if ( v3 )
{
v4 = munmap(*a1, v3);
if ( v4 < 0 )
{
diminuto_log_perror("src/diminuto_map.c", 78LL, "diminuto_map_unmap: munmap");
}
else
{
*a1 = 0LL;
*a2 = 0LL;
}
}
return (unsigned int)v4;
}

original_code:
int diminuto_map_unmap(void ** startp, size_t * lengthp)
{
    int rc = 0;
    if (*lengthp == 0) {
    } else if ((rc = munmap(*startp, *lengthp)) < 0) {
        diminuto_log_perror("src/diminuto_map.c", 78, "diminuto_map_unmap: munmap");
    } else {
        *startp = (void *)0;
        *lengthp = 0;
    }
    return rc;
}

canonical_original_code:
int diminuto_map_unmap(void **startp, unsigned long *lengthp)
{
    int rc = 0;
    if (*lengthp == 0) {
    } else if ((rc = munmap(*startp, *lengthp)) < 0) {
        diminuto_log_perror("src/diminuto_map.c", 78, "diminuto_map_unmap: munmap");
    } else {
        *startp = (void *)0;
        *lengthp = 0;
    }
    return rc;
}

variable_types: rc int


decompiled_code:
__int64 diminuto_mux_frequency()
{
return 1000000000LL;
}

original_code:
static inline diminuto_sticks_t diminuto_mux_frequency(void) {
    return (1000000000LL);
}

canonical_original_code:
static inline long diminuto_mux_frequency() {
    return (1000000000LL);
}


decompiled_code:
__int64 __fastcall diminuto_frequency_ticks2units(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rcx
bool v4; // cc
__int64 result; // rax

v2 = diminuto_frequency();
v3 = v2;
v4 = v2 <= a2;
if ( v2 < a2 )
return a1 * (a2 / v2);
result = a1;
if ( !v4 )
result = a1 / (v3 / a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rcx
bool v4; // cc
__int64 result; // rax

v2 = func1();
v3 = v2;
v4 = v2 <= a2;
if ( v2 < a2 )
return a1 * (a2 / v2);
result = a1;
if ( !v4 )
result = a1 / (v3 / a2);
return result;
}

original_code:
static inline diminuto_sticks_t diminuto_frequency_ticks2units(diminuto_sticks_t ticks, diminuto_sticks_t hertz)
{
    return
        (hertz > diminuto_frequency()) ?
            (ticks * (hertz / diminuto_frequency())) :
        (hertz < diminuto_frequency()) ?
            (ticks / (diminuto_frequency() / hertz)) :
        ticks;
}

canonical_original_code:
static inline long diminuto_frequency_ticks2units(long ticks, long hertz)
{
    return
        (hertz > diminuto_frequency()) ?
            (ticks * (hertz / diminuto_frequency())) :
        (hertz < diminuto_frequency()) ?
            (ticks / (diminuto_frequency() / hertz)) :
        ticks;
}

variable_types: ticks long

variable_types: hertz long


decompiled_code:
__int64 __fastcall diminuto_frequency_ticks2wholeseconds(__int64 a1)
{
return diminuto_frequency_ticks2units(a1, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return func2(a1, 1LL);
}

original_code:
static inline diminuto_sticks_t diminuto_frequency_ticks2wholeseconds(diminuto_sticks_t ticks)
{
    return diminuto_frequency_ticks2units(ticks, 1);
}

canonical_original_code:
static inline long diminuto_frequency_ticks2wholeseconds(long ticks)
{
    return diminuto_frequency_ticks2units(ticks, 1);
}


decompiled_code:
__int64 __fastcall diminuto_frequency_ticks2fractionalseconds(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = diminuto_frequency();
return diminuto_frequency_ticks2units(a1 % v2, a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = func1();
return func2(a1 % v2, a2);
}

original_code:
static inline diminuto_sticks_t diminuto_frequency_ticks2fractionalseconds(diminuto_sticks_t ticks, diminuto_sticks_t hertz)
{
    return diminuto_frequency_ticks2units(ticks % diminuto_frequency(), hertz);
}

canonical_original_code:
static inline long diminuto_frequency_ticks2fractionalseconds(long ticks, long hertz)
{
    return diminuto_frequency_ticks2units(ticks % diminuto_frequency(), hertz);
}


decompiled_code:
__int64 __fastcall diminuto_mux_set_reset(_DWORD *a1)
{
__int64 result; // rax

if ( (int)a1[66] < 0 && (int)a1[65] >= 0 )
{
result = (unsigned int)a1[64];
a1[66] = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1)
{
__int64 result; // rax

if ( (int)a1[66] < 0 && (int)a1[65] >= 0 )
{
result = (unsigned int)a1[64];
a1[66] = result;
}
return result;
}

original_code:
static inline void diminuto_mux_set_reset(diminuto_mux_set_t * setp)
{
    if (setp->next >= 0) {
    } else if (setp->max < 0) {
    } else {
        setp->next = setp->min;
    }
}

canonical_original_code:
static inline void diminuto_mux_set_reset(struct DiminutoMuxSet *setp)
{
    if (setp->next >= 0) {
    } else if (setp->max < 0) {
    } else {
        setp->next = setp->min;
    }
}

variable_types: struct DiminutoMuxSet { struct fd_set { long fds_bits[-1]; } active; struct fd_set ready; int min; int max; int next; } *

user_defined_types: struct DiminutoMuxSet { struct fd_set active; struct fd_set ready; int min; int max; int next; }


original_code:
static void poll_before(diminuto_poll_t * pollp, diminuto_mux_set_t * setp, short mask)
{
    if (setp->max >= 0) {
        int fd;
        for (fd = setp->min; fd <= setp->max; ++fd) {
            if (((((&setp->active)->fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
                struct pollfd * pollfdp;
                pollfdp = &(pollp->pollfd[fd - pollp->min]);
                pollfdp->fd = fd;
                pollfdp->events |= mask;
            }
        }
    }
}

canonical_original_code:
static void poll_before(struct DiminutoPoll *pollp, struct DiminutoMuxSet *setp, short mask)
{
    if (setp->max >= 0) {
        int fd;
        for (fd = setp->min; fd <= setp->max; ++fd) {
            if (((((&setp->active)->fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
                struct pollfd *pollfdp;
                pollfdp = &(pollp->pollfd[fd - pollp->min]);
                pollfdp->fd = fd;
                pollfdp->events |= mask;
            }
        }
    }
}

variable_types: struct DiminutoPoll { struct pollfd { int fd; short events; short revents; } *pollfd; struct DiminutoMux { struct fd_set { long fds_bits[-1]; } read_or_accept; struct fd_set urgent_or_interrupt; struct DiminutoMuxSet { struct fd_set active; struct fd_set ready; int min; int max; int next; } read; struct DiminutoMuxSet write; struct DiminutoMuxSet accept; struct DiminutoMuxSet urgent; struct DiminutoMuxSet interrupt; struct __sigset_t { unsigned long __val[-1]; } mask; } mux; unsigned long nfds; int min; int max; _Bool refresh; } *

variable_types:
setp
struct DiminutoMuxSet *

variable_types: mask short

user_defined_types: struct DiminutoPoll { struct pollfd *pollfd; struct DiminutoMux mux; unsigned long nfds; int min; int max; _Bool refresh; }

user_defined_types: struct DiminutoMux { struct fd_set read_or_accept; struct fd_set urgent_or_interrupt; struct DiminutoMuxSet read; struct DiminutoMuxSet write; struct DiminutoMuxSet accept; struct DiminutoMuxSet urgent; struct DiminutoMuxSet interrupt; struct __sigset_t mask; }


original_code:
static void poll_after(diminuto_poll_t * pollp, diminuto_mux_set_t * setp, short mask)
{
    if (setp->max >= 0) {
        int fd;
        for (fd = setp->min; fd <= setp->max; ++fd) {
            struct pollfd * pollfdp;
            pollfdp = &(pollp->pollfd[fd - pollp->min]);
            if (pollfdp->fd < 0) {
            } else if ((pollfdp->revents & mask) == 0) {
                ((void) (((&setp->ready)->fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] &= ~((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))));
            } else {
                ((void) (((&setp->ready)->fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))));
            }
        }
    }
}

canonical_original_code:
static void poll_after(struct DiminutoPoll *pollp, struct DiminutoMuxSet *setp, short mask)
{
    if (setp->max >= 0) {
        int fd;
        for (fd = setp->min; fd <= setp->max; ++fd) {
            struct pollfd *pollfdp;
            pollfdp = &(pollp->pollfd[fd - pollp->min]);
            if (pollfdp->fd < 0) {
            } else if ((pollfdp->revents & mask) == 0) {
                ((void) (((&setp->ready)->fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] &= ~((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))));
            } else {
                ((void) (((&setp->ready)->fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))));
            }
        }
    }
}

variable_types: struct pollfd { int fd; short events; short revents; } *

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


original_code:
diminuto_poll_t * diminuto_poll_init(diminuto_poll_t * pollp)
{
    diminuto_mux_init(&pollp->mux);
    pollp->pollfd = (struct pollfd *)0;
    pollp->nfds = 0;
    pollp->min = DIMINUTO_MUX_MOSTPOSITIVE;
    pollp->max = DIMINUTO_MUX_MOSTNEGATIVE;
    pollp->refresh = 0;
    return pollp;
}

canonical_original_code:
struct DiminutoPoll *diminuto_poll_init(struct DiminutoPoll *pollp)
{
    diminuto_mux_init(&pollp->mux);
    pollp->pollfd = (struct pollfd *)0;
    pollp->nfds = 0;
    pollp->min = DIMINUTO_MUX_MOSTPOSITIVE;
    pollp->max = DIMINUTO_MUX_MOSTNEGATIVE;
    pollp->refresh = 0;
    return pollp;
}

variable_types:
pollp
struct DiminutoPoll *

return_type: struct DiminutoPoll { struct pollfd { int fd; short events; short revents; } *pollfd; struct DiminutoMux { struct fd_set { long fds_bits[-1]; } read_or_accept; struct fd_set urgent_or_interrupt; struct DiminutoMuxSet { struct fd_set active; struct fd_set ready; int min; int max; int next; } read; struct DiminutoMuxSet write; struct DiminutoMuxSet accept; struct DiminutoMuxSet urgent; struct DiminutoMuxSet interrupt; struct __sigset_t { unsigned long __val[-1]; } mask; } mux; unsigned long nfds; int min; int max; _Bool refresh; } *


original_code:
diminuto_poll_t * diminuto_poll_fini(diminuto_poll_t * pollp)
{
    free(pollp->pollfd);
    pollp->pollfd = (struct pollfd *)0;
    pollp->nfds = 0;
    pollp->min = DIMINUTO_MUX_MOSTPOSITIVE;
    pollp->max = DIMINUTO_MUX_MOSTNEGATIVE;
    pollp->refresh = !0;
    return (diminuto_poll_t *)0;
}

canonical_original_code:
struct DiminutoPoll *diminuto_poll_fini(struct DiminutoPoll *pollp)
{
    free(pollp->pollfd);
    pollp->pollfd = (struct pollfd *)0;
    pollp->nfds = 0;
    pollp->min = DIMINUTO_MUX_MOSTPOSITIVE;
    pollp->max = DIMINUTO_MUX_MOSTNEGATIVE;
    pollp->refresh = !0;
    return (struct DiminutoPoll *)0;
}

user_defined_types: struct pollfd { int fd; short events; short revents; }


decompiled_code:
__int64 __fastcall diminuto_poll_wait_generic(__int64 a1, __int64 a2, const __sigset_t *a3)
{
_DWORD *v4; // rbp
int v5; // edx
int v6; // eax
nfds_t v7; // rax
unsigned __int64 v8; // rax
__int64 v9; // rdx
__int64 v10; // rax
struct timespec *v11; // rdx
int v13; // [rsp+8h] [rbp-60h]
nfds_t nfds; // [rsp+10h] [rbp-58h]
struct timespec timeout; // [rsp+20h] [rbp-48h] BYREF

*(_DWORD *)(a1 + 1760) = 0x7FFFFFFF;
*(_DWORD *)(a1 + 1764) = 0x80000000;
v4 = (_DWORD *)(a1 + 264);
poll_bounds(a1, a1 + 264);
poll_bounds(a1, a1 + 536);
poll_bounds(a1, a1 + 808);
poll_bounds(a1, a1 + 1080);
poll_bounds(a1, a1 + 1352);
v5 = *(_DWORD *)(a1 + 1760);
v6 = *(_DWORD *)(a1 + 1764);
if ( v5 > v6 )
{
if ( a2 < 0 )
return 0;
nfds = 0LL;
goto LABEL_10;
}
v7 = v6 - v5 + 1;
nfds = v7;
if ( v7 > *(_QWORD *)(a1 + 1752) )
{
*(_QWORD *)a1 = diminuto_heap_realloc(*(_QWORD *)a1, 8 * v7);
*(_QWORD *)(a1 + 1752) = nfds;
}
if ( *(_BYTE *)(a1 + 1768) )
{
if ( *(_QWORD *)(a1 + 1752) )
{
v8 = 0LL;
do
{
v9 = *(_QWORD *)a1 + 8 * v8;
*(_DWORD *)v9 = -1;
*(_WORD *)(v9 + 4) = 0;
*(_WORD *)(v9 + 6) = 0;
++v8;
}
while ( *(_QWORD *)(a1 + 1752) > v8 );
}
poll_before(a1, (__int64)v4, 1);
poll_before(a1, a1 + 536, 4);
poll_before(a1, a1 + 808, 1);
poll_before(a1, a1 + 1080, 2);
poll_before(a1, a1 + 1352, 2);
*(_BYTE *)(a1 + 1768) = 0;
}
if ( a2 >= 0 )
{
LABEL_10:
timeout.tv_sec = diminuto_frequency_ticks2wholeseconds(a2);
v10 = diminuto_mux_frequency();
timeout.tv_nsec = diminuto_frequency_ticks2fractionalseconds(a2, v10);
v11 = &timeout;
goto LABEL_11;
}
v11 = 0LL;
LABEL_11:
v13 = ppoll(*(struct pollfd **)a1, nfds, v11, a3);
if ( v13 > 0 )
{
poll_after(a1, (__int64)v4, 1u);
poll_after(a1, a1 + 536, 4u);
poll_after(a1, a1 + 808, 1u);
poll_after(a1, a1 + 1080, 2u);
poll_after(a1, a1 + 1352, 2u);
diminuto_mux_set_reset(v4);
diminuto_mux_set_reset((_DWORD *)(a1 + 536));
diminuto_mux_set_reset((_DWORD *)(a1 + 808));
diminuto_mux_set_reset((_DWORD *)(a1 + 1080));
diminuto_mux_set_reset((_DWORD *)(a1 + 1352));
}
else if ( v13 && *_errno_location() != 4 )
{
diminuto_log_perror("src/diminuto_poll.c", 162LL, "diminuto_poll_wait");
}
return (unsigned int)v13;
}

original_code:
int diminuto_poll_wait_generic(diminuto_poll_t * pollp, diminuto_sticks_t ticks, const sigset_t * maskp)
{
    int rc = 0;
    struct timespec * top = (struct timespec *)0;
    struct timespec timeout;
    nfds_t nfds = 0;
    int fd;
    struct pollfd * pollfdp;
    pollp->min = DIMINUTO_MUX_MOSTPOSITIVE;
    pollp->max = DIMINUTO_MUX_MOSTNEGATIVE;
    poll_bounds(pollp, &pollp->mux.read);
    poll_bounds(pollp, &pollp->mux.write);
    poll_bounds(pollp, &pollp->mux.accept);
    poll_bounds(pollp, &pollp->mux.urgent);
    poll_bounds(pollp, &pollp->mux.interrupt);
    if (pollp->min <= pollp->max) { nfds = pollp->max - pollp->min + 1; }
    if (nfds > pollp->nfds) {
        pollp->pollfd = diminuto_heap_realloc(pollp->pollfd, nfds * sizeof(struct pollfd));
        pollp->nfds = nfds;
    }
    if (nfds <= 0) {
    } else if (!(pollp->refresh)) {
    } else {
        for (fd = 0; fd < pollp->nfds; ++fd) {
            pollfdp = &(pollp->pollfd[fd]);
            pollfdp->fd = -1;
            pollfdp->events = 0;
            pollfdp->revents = 0;
        }
        poll_before(pollp, &pollp->mux.read, 0x001);
        poll_before(pollp, &pollp->mux.write, 0x004);
        poll_before(pollp, &pollp->mux.accept, 0x001);
        poll_before(pollp, &pollp->mux.urgent, 0x002);
        poll_before(pollp, &pollp->mux.interrupt, 0x002);
        pollp->refresh = 0;
    }
    if (ticks >= 0) {
        timeout.tv_sec = diminuto_frequency_ticks2wholeseconds(ticks);
        timeout.tv_nsec = diminuto_frequency_ticks2fractionalseconds(ticks, diminuto_mux_frequency());
        top = &timeout;
    }
    if ((nfds > 0) || (ticks >= 0)) {
        rc = ppoll(pollp->pollfd, nfds, top, maskp);
        if (rc > 0) {
            poll_after(pollp, &pollp->mux.read, 0x001);
            poll_after(pollp, &pollp->mux.write, 0x004);
            poll_after(pollp, &pollp->mux.accept, 0x001);
            poll_after(pollp, &pollp->mux.urgent, 0x002);
            poll_after(pollp, &pollp->mux.interrupt, 0x002);
            diminuto_mux_set_reset(&pollp->mux.read);
            diminuto_mux_set_reset(&pollp->mux.write);
            diminuto_mux_set_reset(&pollp->mux.accept);
            diminuto_mux_set_reset(&pollp->mux.urgent);
            diminuto_mux_set_reset(&pollp->mux.interrupt);
        } else if (rc == 0) {
        } else if ((*__errno_location ()) == 4) {
        } else {
            diminuto_log_perror("src/diminuto_poll.c", 162, "diminuto_poll_wait");
        }
    }
    return rc;
}

canonical_original_code:
int diminuto_poll_wait_generic(struct DiminutoPoll *pollp, long ticks, struct __sigset_t *maskp)
{
    int rc = 0;
    struct timespec *top = (struct timespec *)0;
    struct timespec timeout;
    unsigned long nfds = 0;
    int fd;
    struct pollfd *pollfdp;
    pollp->min = DIMINUTO_MUX_MOSTPOSITIVE;
    pollp->max = DIMINUTO_MUX_MOSTNEGATIVE;
    poll_bounds(pollp, &pollp->mux.read);
    poll_bounds(pollp, &pollp->mux.write);
    poll_bounds(pollp, &pollp->mux.accept);
    poll_bounds(pollp, &pollp->mux.urgent);
    poll_bounds(pollp, &pollp->mux.interrupt);
    if (pollp->min <= pollp->max) { nfds = pollp->max - pollp->min + 1; }
    if (nfds > pollp->nfds) {
        pollp->pollfd = diminuto_heap_realloc(pollp->pollfd, nfds * sizeof(struct pollfd));
        pollp->nfds = nfds;
    }
    if (nfds <= 0) {
    } else if (!(pollp->refresh)) {
    } else {
        for (fd = 0; fd < pollp->nfds; ++fd) {
            pollfdp = &(pollp->pollfd[fd]);
            pollfdp->fd = -1;
            pollfdp->events = 0;
            pollfdp->revents = 0;
        }
        poll_before(pollp, &pollp->mux.read, 0x001);
        poll_before(pollp, &pollp->mux.write, 0x004);
        poll_before(pollp, &pollp->mux.accept, 0x001);
        poll_before(pollp, &pollp->mux.urgent, 0x002);
        poll_before(pollp, &pollp->mux.interrupt, 0x002);
        pollp->refresh = 0;
    }
    if (ticks >= 0) {
        timeout.tv_sec = diminuto_frequency_ticks2wholeseconds(ticks);
        timeout.tv_nsec = diminuto_frequency_ticks2fractionalseconds(ticks, diminuto_mux_frequency());
        top = &timeout;
    }
    if ((nfds > 0) || (ticks >= 0)) {
        rc = ppoll(pollp->pollfd, nfds, top, maskp);
        if (rc > 0) {
            poll_after(pollp, &pollp->mux.read, 0x001);
            poll_after(pollp, &pollp->mux.write, 0x004);
            poll_after(pollp, &pollp->mux.accept, 0x001);
            poll_after(pollp, &pollp->mux.urgent, 0x002);
            poll_after(pollp, &pollp->mux.interrupt, 0x002);
            diminuto_mux_set_reset(&pollp->mux.read);
            diminuto_mux_set_reset(&pollp->mux.write);
            diminuto_mux_set_reset(&pollp->mux.accept);
            diminuto_mux_set_reset(&pollp->mux.urgent);
            diminuto_mux_set_reset(&pollp->mux.interrupt);
        } else if (rc == 0) {
        } else if ((*__errno_location ()) == 4) {
        } else {
            diminuto_log_perror("src/diminuto_poll.c", 162, "diminuto_poll_wait");
        }
    }
    return rc;
}

variable_types:
maskp
struct __sigset_t *

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

variable_types:
nfds
unsigned long


decompiled_code:
__int64 __fastcall diminuto_poll_dump(const void **a1)
{
unsigned __int64 v2; // rbx
unsigned int *v3; // r12
__int64 v4; // rcx

diminuto_log_emit("poll@%p: nfds=%lu\n", a1, a1[219]);
diminuto_log_emit("poll@%p: min=%d\n", a1, *((unsigned int *)a1 + 440));
diminuto_log_emit("poll@%p: max=%d\n", a1, *((unsigned int *)a1 + 441));
diminuto_log_emit("poll@%p: refresh=%d\n", a1, *((unsigned __int8 *)a1 + 1768));
diminuto_log_emit("poll@%p: pollfd=%p\n", a1, *a1);
if ( a1[219] )
{
v2 = 0LL;
do
{
v3 = (unsigned int *)((char *)*a1 + 8 * v2);
v4 = *v3;
if ( (int)v4 >= 0 )
{
diminuto_log_emit("poll@%p: pollfd[%lu].fd=%d\n", a1, v2, v4);
diminuto_log_emit("poll@%p: pollfd[%lu].events=0x%x\n", a1, v2, (unsigned int)*((__int16 *)v3 + 2));
diminuto_log_emit("poll@%p: pollfd[%lu].revents=0x%x\n", a1, v2, (unsigned int)*((__int16 *)v3 + 3));
}
++v2;
}
while ( (unsigned __int64)a1[219] > v2 );
}
return diminuto_mux_dump(a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func12(const void **a1)
{
unsigned __int64 v2; // rbx
unsigned int *v3; // r12
__int64 v4; // rcx

diminuto_log_emit("poll@%p: nfds=%lu\n", a1, a1[219]);
diminuto_log_emit("poll@%p: min=%d\n", a1, *((unsigned int *)a1 + 440));
diminuto_log_emit("poll@%p: max=%d\n", a1, *((unsigned int *)a1 + 441));
diminuto_log_emit("poll@%p: refresh=%d\n", a1, *((unsigned __int8 *)a1 + 1768));
diminuto_log_emit("poll@%p: pollfd=%p\n", a1, *a1);
if ( a1[219] )
{
v2 = 0LL;
do
{
v3 = (unsigned int *)((char *)*a1 + 8 * v2);
v4 = *v3;
if ( (int)v4 >= 0 )
{
diminuto_log_emit("poll@%p: pollfd[%lu].fd=%d\n", a1, v2, v4);
diminuto_log_emit("poll@%p: pollfd[%lu].events=0x%x\n", a1, v2, (unsigned int)*((__int16 *)v3 + 2));
diminuto_log_emit("poll@%p: pollfd[%lu].revents=0x%x\n", a1, v2, (unsigned int)*((__int16 *)v3 + 3));
}
++v2;
}
while ( (unsigned __int64)a1[219] > v2 );
}
return diminuto_mux_dump(a1 + 1);
}

original_code:
void diminuto_poll_dump(diminuto_poll_t * pollp)
{
    nfds_t ii;
    struct pollfd * pollfdp;
    diminuto_log_emit("poll@%p: nfds=%lu\n", pollp, (long unsigned int)pollp->nfds);
    diminuto_log_emit("poll@%p: min=%d\n", pollp, pollp->min);
    diminuto_log_emit("poll@%p: max=%d\n", pollp, pollp->max);
    diminuto_log_emit("poll@%p: refresh=%d\n", pollp, pollp->refresh);
    diminuto_log_emit("poll@%p: pollfd=%p\n", pollp, pollp->pollfd);
    for (ii = 0; ii < pollp->nfds; ++ii) {
        pollfdp = &pollp->pollfd[ii];
        if (pollfdp->fd >= 0) {
            diminuto_log_emit("poll@%p: pollfd[%lu].fd=%d\n", pollp, (long unsigned int)ii, pollfdp->fd);
            diminuto_log_emit("poll@%p: pollfd[%lu].events=0x%x\n", pollp, (long unsigned int)ii, pollfdp->events);
            diminuto_log_emit("poll@%p: pollfd[%lu].revents=0x%x\n", pollp, (long unsigned int)ii, pollfdp->revents);
        }
    }
    diminuto_mux_dump(&pollp->mux);
}

canonical_original_code:
void diminuto_poll_dump(struct DiminutoPoll *pollp)
{
    unsigned long ii;
    struct pollfd *pollfdp;
    diminuto_log_emit("poll@%p: nfds=%lu\n", pollp, (unsigned long)pollp->nfds);
    diminuto_log_emit("poll@%p: min=%d\n", pollp, pollp->min);
    diminuto_log_emit("poll@%p: max=%d\n", pollp, pollp->max);
    diminuto_log_emit("poll@%p: refresh=%d\n", pollp, pollp->refresh);
    diminuto_log_emit("poll@%p: pollfd=%p\n", pollp, pollp->pollfd);
    for (ii = 0; ii < pollp->nfds; ++ii) {
        pollfdp = &pollp->pollfd[ii];
        if (pollfdp->fd >= 0) {
            diminuto_log_emit("poll@%p: pollfd[%lu].fd=%d\n", pollp, (unsigned long)ii, pollfdp->fd);
            diminuto_log_emit("poll@%p: pollfd[%lu].events=0x%x\n", pollp, (unsigned long)ii, pollfdp->events);
            diminuto_log_emit("poll@%p: pollfd[%lu].revents=0x%x\n", pollp, (unsigned long)ii, pollfdp->revents);
        }
    }
    diminuto_mux_dump(&pollp->mux);
}

variable_types:
ii
unsigned long


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

result = (unsigned int)Debug;
Debug = a1;
return result;
}

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

result = (unsigned int)Debug;
Debug = a1;
return result;
}

original_code:
int diminuto_fs_debug(int now)
{
    int was = 0;
    was = Debug;
    Debug = now;
    return was;
}

variable_types: now int

variable_types: was int


decompiled_code:
__int64 __fastcall diminuto_fs_mode2type(unsigned __int16 a1)
{
int v1; // edx
__int64 result; // rax
unsigned int v3; // edi

v1 = a1 & 0xF000;
result = 102LL;
if ( v1 != 0x8000 )
{
result = 100LL;
if ( v1 != 0x4000 )
{
result = 108LL;
if ( v1 != 40960 )
{
result = 99LL;
if ( v1 != 0x2000 )
{
result = 98LL;
if ( v1 != 24576 )
{
result = 112LL;
if ( v1 != 4096 )
{
result = 115LL;
if ( v1 != 49152 )
{
v3 = a1 >> 12;
result = v3 + 55;
if ( v3 <= 9 )
result = v3 + 48;
}
}
}
}
}
}
}
return result;
}

original_code:
diminuto_fs_type_t diminuto_fs_mode2type(mode_t mode)
{
    diminuto_fs_type_t type = DIMINUTO_FS_TYPE_NONE;
    if (((((mode)) & 0170000) == (0100000))) {
        type = DIMINUTO_FS_TYPE_FILE;
    } else if (((((mode)) & 0170000) == (0040000))) {
        type = DIMINUTO_FS_TYPE_DIRECTORY;
    } else if (((((mode)) & 0170000) == (0120000))) {
        type = DIMINUTO_FS_TYPE_SYMLINK;
    } else if (((((mode)) & 0170000) == (0020000))) {
        type = DIMINUTO_FS_TYPE_CHARACTERDEV;
    } else if (((((mode)) & 0170000) == (0060000))) {
        type = DIMINUTO_FS_TYPE_BLOCKDEV;
    } else if (((((mode)) & 0170000) == (0010000))) {
        type = DIMINUTO_FS_TYPE_FIFO;
    } else if (((((mode)) & 0170000) == (0140000))) {
        type = DIMINUTO_FS_TYPE_SOCKET;
    } else {
        mode = (mode & 0170000) >> 12 ;
        if ((0 <= mode) && (mode <= 9)) {
            type = (diminuto_fs_type_t)('0' + mode);
        } else if ((0xa <= mode) && (mode <= 0xf)) {
            type = (diminuto_fs_type_t)('A' + mode - 0xa);
        } else {
            type = DIMINUTO_FS_TYPE_UNKNOWN;
        }
    }
    return type;
}

canonical_original_code:
enum DiminutoFsType diminuto_fs_mode2type(unsigned int mode)
{
    enum DiminutoFsType type = DIMINUTO_FS_TYPE_NONE;
    if (((((mode)) & 0170000) == (0100000))) {
        type = DIMINUTO_FS_TYPE_FILE;
    } else if (((((mode)) & 0170000) == (0040000))) {
        type = DIMINUTO_FS_TYPE_DIRECTORY;
    } else if (((((mode)) & 0170000) == (0120000))) {
        type = DIMINUTO_FS_TYPE_SYMLINK;
    } else if (((((mode)) & 0170000) == (0020000))) {
        type = DIMINUTO_FS_TYPE_CHARACTERDEV;
    } else if (((((mode)) & 0170000) == (0060000))) {
        type = DIMINUTO_FS_TYPE_BLOCKDEV;
    } else if (((((mode)) & 0170000) == (0010000))) {
        type = DIMINUTO_FS_TYPE_FIFO;
    } else if (((((mode)) & 0170000) == (0140000))) {
        type = DIMINUTO_FS_TYPE_SOCKET;
    } else {
        mode = (mode & 0170000) >> 12 ;
        if ((0 <= mode) && (mode <= 9)) {
            type = (diminuto_fs_type_t)('0' + mode);
        } else if ((0xa <= mode) && (mode <= 0xf)) {
            type = (diminuto_fs_type_t)('A' + mode - 0xa);
        } else {
            type = DIMINUTO_FS_TYPE_UNKNOWN;
        }
    }
    return type;
}

variable_types:
mode
unsigned int

variable_types: enum DiminutoFsType { DIMINUTO_FS_TYPE_NONE=expr, DIMINUTO_FS_TYPE_UNKNOWN=expr, DIMINUTO_FS_TYPE_TTY=expr, DIMINUTO_FS_TYPE_SOCKET=expr, DIMINUTO_FS_TYPE_SYMLINK=expr, DIMINUTO_FS_TYPE_FILE=expr, DIMINUTO_FS_TYPE_BLOCKDEV=expr, DIMINUTO_FS_TYPE_DIRECTORY=expr, DIMINUTO_FS_TYPE_CHARACTERDEV=expr, DIMINUTO_FS_TYPE_FIFO=expr, DIMINUTO_FS_TYPE_0=expr, DIMINUTO_FS_TYPE_1=expr, DIMINUTO_FS_TYPE_2=expr, DIMINUTO_FS_TYPE_3=expr, DIMINUTO_FS_TYPE_4=expr, DIMINUTO_FS_TYPE_5=expr, DIMINUTO_FS_TYPE_6=expr, DIMINUTO_FS_TYPE_7=expr, DIMINUTO_FS_TYPE_8=expr, DIMINUTO_FS_TYPE_9=expr, DIMINUTO_FS_TYPE_A=expr, DIMINUTO_FS_TYPE_B=expr, DIMINUTO_FS_TYPE_C=expr, DIMINUTO_FS_TYPE_D=expr, DIMINUTO_FS_TYPE_E=expr, DIMINUTO_FS_TYPE_F=expr }