decompiled_code:
char *__fastcall diminuto_map_map(unsigned __int64 a1, __int64 a2, char **a3, size_t *a4)
{
unsigned __int64 v6; // rdx
__off_t v7; // rbx
size_t v8; // r14
unsigned __int64 v9; // r12
int v10; // eax
int v11; // er15
char *v12; // rax
char *v13; // r12

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

canonical_decompiled_code:
char *__fastcall func0(unsigned __int64 a1, __int64 a2, char **a3, size_t *a4)
{
unsigned __int64 v6; // rdx
__off_t v7; // rbx
size_t v8; // r14
unsigned __int64 v9; // r12
int v10; // eax
int v11; // er15
char *v12; // rax
char *v13; // r12

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

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


repo: coverclock/com-diag-diminuto

decompiled_code:
int __fastcall diminuto_map_unmap(void **a1, size_t *a2)
{
int result; // eax
size_t v4; // rsi
int v5; // [rsp+Ch] [rbp-1Ch]

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

canonical_decompiled_code:
int __fastcall func1(void **a1, size_t *a2)
{
int result; // eax
size_t v4; // rsi
int v5; // [rsp+Ch] [rbp-1Ch]

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

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

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

return_type: long


decompiled_code:
__int64 __fastcall diminuto_frequency_ticks2units(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // r8

v2 = diminuto_mux_frequency();
v3 = a1;
if ( v2 < a2 )
return a2 / v2 * a1;
if ( v2 <= a2 )
return v3;
return a1 / (v2 / a2);
}

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 func2(__int64 a1)
{
return func1(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_mux_frequency();
return diminuto_frequency_ticks2units(a1 % v2, a2);
}

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

v2 = func0();
return func1(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(unsigned int *a1)
{
__int64 result; // rax

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

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

if ( (a1[66] & 0x80000000) != 0 )
{
result = a1[65];
if ( (int)result >= 0 )
{
result = 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; } *

return_type: void

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


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

diminuto_mux_init(a1 + 8);
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 1760) = 0x800000007FFFFFFFLL;
result = a1;
*(_QWORD *)(a1 + 1752) = 0LL;
*(_BYTE *)(a1 + 1768) = 0;
return result;
}

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

diminuto_mux_init(a1 + 8);
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 1760) = 0x800000007FFFFFFFLL;
result = a1;
*(_QWORD *)(a1 + 1752) = 0LL;
*(_BYTE *)(a1 + 1768) = 0;
return result;
}

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


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

free(*(void **)a1);
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 1760) = 0x800000007FFFFFFFLL;
result = 0LL;
*(_QWORD *)(a1 + 1752) = 0LL;
*(_BYTE *)(a1 + 1768) = 1;
return result;
}

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(struct pollfd **a1, __int64 a2, const __sigset_t *a3)
{
unsigned int *v3; // r15
unsigned int *v4; // r14
unsigned int *v5; // r13
unsigned int *v6; // rax
int v7; // edx
int v8; // eax
unsigned int v9; // ebp
int v11; // er9
nfds_t v12; // rbx
__int64 v13; // rax
bool v14; // zf
__int64 v15; // rax
__int64 v16; // rax
struct timespec *v17; // rdx
int v18; // eax
nfds_t v19; // rdx
struct pollfd *v20; // rax
__int64 v21; // rdx
unsigned int *v22; // [rsp+8h] [rbp-60h]
unsigned int *v23; // [rsp+10h] [rbp-58h]
struct timespec timeout; // [rsp+20h] [rbp-48h] BYREF

v3 = (unsigned int *)(a1 + 135);
v4 = (unsigned int *)(a1 + 101);
v5 = (unsigned int *)(a1 + 67);
a1[220] = (struct pollfd *)0x800000007FFFFFFFLL;
v22 = (unsigned int *)(a1 + 33);
poll_bounds_isra_0((__int64)a1, *((_DWORD *)a1 + 130), *((_DWORD *)a1 + 131));
poll_bounds_isra_0((__int64)a1, *((_DWORD *)a1 + 198), *((_DWORD *)a1 + 199));
poll_bounds_isra_0((__int64)a1, *((_DWORD *)a1 + 266), *((_DWORD *)a1 + 267));
poll_bounds_isra_0((__int64)a1, *((_DWORD *)a1 + 334), *((_DWORD *)a1 + 335));
v23 = v6;
poll_bounds_isra_0((__int64)a1, *((_DWORD *)a1 + 402), *((_DWORD *)a1 + 403));
v7 = *((_DWORD *)a1 + 440);
v8 = *((_DWORD *)a1 + 441);
if ( v7 > v8 )
{
if ( a2 < 0 )
return 0;
v12 = 0LL;
goto LABEL_8;
}
v11 = v8 - v7 + 1;
v12 = v11;
if ( (unsigned __int64)a1[219] < v11 )
{
v13 = diminuto_heap_realloc(*a1, 8LL * v11);
a1[219] = (struct pollfd *)v12;
v14 = *((_BYTE *)a1 + 1768) == 0;
*a1 = (struct pollfd *)v13;
if ( v14 )
goto LABEL_7;
v19 = v12;
LABEL_15:
v20 = *a1;
v21 = (__int64)&(*a1)[v19];
do
{
v20->fd = -1;
++v20;
v20[-1].events = 0;
v20[-1].revents = 0;
}
while ( v20 != (struct pollfd *)v21 );
goto LABEL_17;
}
if ( !*((_BYTE *)a1 + 1768) )
goto LABEL_7;
v19 = (nfds_t)a1[219];
if ( v19 )
goto LABEL_15;
LABEL_17:
poll_before((__int64)a1, (__int64)v22, 1);
poll_before((__int64)a1, (__int64)v5, 4);
poll_before((__int64)a1, (__int64)v4, 1);
poll_before((__int64)a1, (__int64)v3, 2);
poll_before((__int64)a1, (__int64)v23, 2);
*((_BYTE *)a1 + 1768) = 0;
LABEL_7:
if ( a2 >= 0 )
{
LABEL_8:
timeout.tv_sec = diminuto_frequency_ticks2wholeseconds(a2);
v15 = diminuto_mux_frequency();
v16 = diminuto_frequency_ticks2fractionalseconds(a2, v15);
v17 = &timeout;
timeout.tv_nsec = v16;
goto LABEL_9;
}
v17 = 0LL;
LABEL_9:
v18 = ppoll(*a1, v12, v17, a3);
v9 = v18;
if ( v18 > 0 )
{
poll_after((__int64)a1, (__int64)v22, 1u);
poll_after((__int64)a1, (__int64)v5, 4u);
poll_after((__int64)a1, (__int64)v4, 1u);
poll_after((__int64)a1, (__int64)v3, 2u);
poll_after((__int64)a1, (__int64)v23, 2u);
diminuto_mux_set_reset(v22);
diminuto_mux_set_reset(v5);
diminuto_mux_set_reset(v4);
diminuto_mux_set_reset(v3);
diminuto_mux_set_reset(v23);
return v9;
}
if ( !v18 )
return 0;
if ( *_errno_location() != 4 )
diminuto_log_perror("src/diminuto_poll.c", 162LL, "diminuto_poll_wait");
return v9;
}

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 func11(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)
{
__int64 result; // rax
int v2; // edx
unsigned int v3; // edi

result = 102LL;
v2 = a1 & 0xF000;
if ( v2 != 0x8000 )
{
result = 100LL;
if ( v2 != 0x4000 )
{
result = 108LL;
if ( v2 != 40960 )
{
result = 99LL;
if ( v2 != 0x2000 )
{
result = 98LL;
if ( v2 != 24576 )
{
result = 112LL;
if ( v2 != 4096 )
{
result = 115LL;
if ( v2 != 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 }


decompiled_code:
__int64 __fastcall diminuto_fs_walk(char *name, __int64 (__fastcall *a2)(__int64, const char *, char *, unsigned __int64, struct stat *), __int64 a3)
{
__int128 v5; // [rsp+0h] [rbp-2028h] BYREF
char v6[4080]; // [rsp+10h] [rbp-2018h] BYREF
__int128 v7; // [rsp+1000h] [rbp-1028h] BYREF
char v8[4080]; // [rsp+1010h] [rbp-1018h] BYREF

v5 = 0LL;
memset(v6, 0, sizeof(v6));
memset(v8, 0, sizeof(v8));
v7 = 0LL;
if ( realpath(name, (char *)&v5) )
return diminuto_fs_walker_localalias((const char *)&v5, (char *)&v7, 0LL, 0LL, a2, a3);
diminuto_log_perror("src/diminuto_fs.c", 261LL, name);
return 4294967294LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *name, __int64 (__fastcall *a2)(__int64, const char *, char *, unsigned __int64, struct stat *), __int64 a3)
{
__int128 v5; // [rsp+0h] [rbp-2028h] BYREF
char v6[4080]; // [rsp+10h] [rbp-2018h] BYREF
__int128 v7; // [rsp+1000h] [rbp-1028h] BYREF
char v8[4080]; // [rsp+1010h] [rbp-1018h] BYREF

v5 = 0LL;
memset(v6, 0, sizeof(v6));
memset(v8, 0, sizeof(v8));
v7 = 0LL;
if ( realpath(name, (char *)&v5) )
return func2((const char *)&v5, (char *)&v7, 0LL, 0LL, a2, a3);
diminuto_log_perror("src/diminuto_fs.c", 261LL, name);
return 4294967294LL;
}

original_code:
int diminuto_fs_walk(const char * root, diminuto_fs_walker_t * walkerp, void * statep)
{
    diminuto_path_t real = { '\0', };
    diminuto_path_t path = { '\0', };
    if (realpath(root, real) == (char *)0) {
        diminuto_log_perror("src/diminuto_fs.c", 261, root);
        return -2;
    }
    return diminuto_fs_walker(real, path, 0, 0, walkerp, statep);
}

canonical_original_code:
int diminuto_fs_walk(char *root, int (*walkerp)(void *statep, char *name, char *path, unsigned long depth, struct stat *statp), void *statep)
{
    char real[-1] = { '\0', };
    char path[-1] = { '\0', };
    if (realpath(root, real) == (char *)0) {
        diminuto_log_perror("src/diminuto_fs.c", 261, root);
        return -2;
    }
    return diminuto_fs_walker(real, path, 0, 0, walkerp, statep);
}

variable_types:
root
char *

variable_types: int (*)(void *statep, char *name, char *path, unsigned long depth, 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]; } *statp)

variable_types:
statep
void *

variable_types:
real
char [-1]

variable_types:
path
char [-1]

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


decompiled_code:
__int64 __fastcall diminuto_fs_mkdir_p(char *src, __mode_t mode, int a3)
{
size_t v4; // rax
size_t v5; // r12
void *v6; // rsp
__int64 *v7; // rax
void *v8; // rsp
__int64 *v9; // rdi
__int64 v10; // rcx
char *v11; // rdi
char *v12; // rax
const char *v13; // r12
int v14; // er13
size_t v15; // rax
unsigned int v16; // er12
size_t v18; // [rsp+0h] [rbp-50h] BYREF
char *v19; // [rsp+8h] [rbp-48h]
char *save_ptr; // [rsp+18h] [rbp-38h] BYREF

save_ptr = 0LL;
v4 = strlen(src);
if ( v4 > 0xFFF )
{
v16 = -1;
*_errno_location() = 36;
}
else
{
if ( v4 )
{
v5 = v4 + 1;
if ( Debug )
diminuto_log_emit("diminuto_fs_mkdir_p: path=\"%s\"\n", src);
v18 = v5 + 23;
v6 = alloca(v5 + 8);
v19 = (char *)&v18;
strncpy((char *)&v18, src, v5);
if ( a3 )
{
LABEL_9:
if ( Debug )
diminuto_log_emit("diminuto_fs_mkdir_p: source=\"%s\"\n", v19);
v8 = alloca(v18 & 0xFFFFFFFFFFFFFFF0LL);
v9 = (__int64 *)&v18;
if ( (unsigned int)v5 >= 8 )
{
v10 = (unsigned int)v5 >> 3;
memset(&v18, 0, 8 * v10);
v9 = (__int64 *)(&v18 + v10);
}
if ( (v5 & 4) != 0 )
{
*(_DWORD *)v9 = 0;
v9 = (__int64 *)((char *)v9 + 4);
if ( (v5 & 2) == 0 )
{
LABEL_15:
if ( (v5 & 1) == 0 )
{
LABEL_16:
v11 = v19;
while ( 1 )
{
v12 = strtok_r(v11, SLASH_0, &save_ptr);
v13 = v12;
if ( !v12 )
goto LABEL_26;
v14 = Debug;
if ( Debug )
break;
if ( v19 != v12 )
goto LABEL_20;
strcat((char *)&v18, v19);
LABEL_23:
v11 = 0LL;
v16 = mkdir((const char *)&v18, mode);
if ( v16 )
{
v18 = 0LL;
v11 = 0LL;
if ( *_errno_location() != 17 )
return v16;
}
}
diminuto_log_emit("diminuto_fs_mkdir_p: token=\"%s\"\n", v12);
v14 = Debug;
if ( v19 != v13 )
LABEL_20:
*(_WORD *)((char *)&v18 + strlen((const char *)&v18)) = *(_WORD *)SLASH_0;
v15 = strlen((const char *)&v18);
strcpy((char *)&v18 + v15, v13);
if ( v14 )
diminuto_log_emit("diminuto_fs_mkdir_p: sink=\"%s\"\n", (const char *)&v18);
goto LABEL_23;
}
LABEL_31:
*(_BYTE *)v9 = 0;
goto LABEL_16;
}
}
else if ( (v5 & 2) == 0 )
{
goto LABEL_15;
}
v9 = (__int64 *)((char *)v9 + 2);
*((_WORD *)v9 - 1) = 0;
if ( (v5 & 1) == 0 )
goto LABEL_16;
goto LABEL_31;
}
v7 = (__int64 *)strrchr((const char *)&v18, 47);
if ( &v18 != (size_t *)v7 && v7 )
{
*(_BYTE *)v7 = 0;
goto LABEL_9;
}
}
LABEL_26:
v16 = 0;
}
return v16;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *src, __mode_t mode, int a3)
{
size_t v4; // rax
size_t v5; // r12
void *v6; // rsp
__int64 *v7; // rax
void *v8; // rsp
__int64 *v9; // rdi
__int64 v10; // rcx
char *v11; // rdi
char *v12; // rax
const char *v13; // r12
int v14; // er13
size_t v15; // rax
unsigned int v16; // er12
size_t v18; // [rsp+0h] [rbp-50h] BYREF
char *v19; // [rsp+8h] [rbp-48h]
char *save_ptr; // [rsp+18h] [rbp-38h] BYREF

save_ptr = 0LL;
v4 = strlen(src);
if ( v4 > 0xFFF )
{
v16 = -1;
*_errno_location() = 36;
}
else
{
if ( v4 )
{
v5 = v4 + 1;
if ( Debug )
diminuto_log_emit("diminuto_fs_mkdir_p: path=\"%s\"\n", src);
v18 = v5 + 23;
v6 = alloca(v5 + 8);
v19 = (char *)&v18;
strncpy((char *)&v18, src, v5);
if ( a3 )
{
LABEL_9:
if ( Debug )
diminuto_log_emit("diminuto_fs_mkdir_p: source=\"%s\"\n", v19);
v8 = alloca(v18 & 0xFFFFFFFFFFFFFFF0LL);
v9 = (__int64 *)&v18;
if ( (unsigned int)v5 >= 8 )
{
v10 = (unsigned int)v5 >> 3;
memset(&v18, 0, 8 * v10);
v9 = (__int64 *)(&v18 + v10);
}
if ( (v5 & 4) != 0 )
{
*(_DWORD *)v9 = 0;
v9 = (__int64 *)((char *)v9 + 4);
if ( (v5 & 2) == 0 )
{
LABEL_15:
if ( (v5 & 1) == 0 )
{
LABEL_16:
v11 = v19;
while ( 1 )
{
v12 = strtok_r(v11, SLASH_0, &save_ptr);
v13 = v12;
if ( !v12 )
goto LABEL_26;
v14 = Debug;
if ( Debug )
break;
if ( v19 != v12 )
goto LABEL_20;
strcat((char *)&v18, v19);
LABEL_23:
v11 = 0LL;
v16 = mkdir((const char *)&v18, mode);
if ( v16 )
{
v18 = 0LL;
v11 = 0LL;
if ( *_errno_location() != 17 )
return v16;
}
}
diminuto_log_emit("diminuto_fs_mkdir_p: token=\"%s\"\n", v12);
v14 = Debug;
if ( v19 != v13 )
LABEL_20:
*(_WORD *)((char *)&v18 + strlen((const char *)&v18)) = *(_WORD *)SLASH_0;
v15 = strlen((const char *)&v18);
strcpy((char *)&v18 + v15, v13);
if ( v14 )
diminuto_log_emit("diminuto_fs_mkdir_p: sink=\"%s\"\n", (const char *)&v18);
goto LABEL_23;
}
LABEL_31:
*(_BYTE *)v9 = 0;
goto LABEL_16;
}
}
else if ( (v5 & 2) == 0 )
{
goto LABEL_15;
}
v9 = (__int64 *)((char *)v9 + 2);
*((_WORD *)v9 - 1) = 0;
if ( (v5 & 1) == 0 )
goto LABEL_16;
goto LABEL_31;
}
v7 = (__int64 *)strrchr((const char *)&v18, 47);
if ( &v18 != (size_t *)v7 && v7 )
{
*(_BYTE *)v7 = 0;
goto LABEL_9;
}
}
LABEL_26:
v16 = 0;
}
return v16;
}

original_code:
int diminuto_fs_mkdir_p(const char * path, mode_t mode, int all)
{
    int rc = 0;
    size_t length = 0;
    char * source = (char *)0;
    char * sink = (char *)0;
    char * target = (char *)0;
    char * saveptr = (char *)0;
    char * token = (char *)0;
    static const char SLASH[] = "/";
    do {
        length = strlen(path);
        if (length >= sizeof(diminuto_path_t)) {
            rc = -1;
            (*__errno_location ()) = 36;
            break;
        } else if (length <= 0) {
            break;
        } else {
            length += 1;
        }
        if (Debug) { diminuto_log_emit("diminuto_fs_mkdir_p: path=\"%s\"\n", path); }
        source = (char *)__builtin_alloca (length);
        strncpy(source, path, length);
        if (all) {
        } else if ((token = strrchr(source, SLASH[0])) == (char *)0) {
            break;
        } else if (token == source) {
            break;
        } else {
            *token = '\0';
        }
        if (Debug) { diminuto_log_emit("diminuto_fs_mkdir_p: source=\"%s\"\n", source); }
        sink = (char *)__builtin_alloca (length);
        memset(sink, 0, length);
        target = source;
        while ((token = strtok_r(target, SLASH, &saveptr)) != (char *)0) {
            if (Debug) { diminuto_log_emit("diminuto_fs_mkdir_p: token=\"%s\"\n", token); }
            if (token != source) {
                strcat(sink, SLASH);
            }
            strcat(sink, token);
            if (Debug) { diminuto_log_emit("diminuto_fs_mkdir_p: sink=\"%s\"\n", sink); }
            rc = mkdir(sink, mode);
            if (rc == 0) {
            } else if ((*__errno_location ()) == 17) {
                rc = 0;
            } else {
                break;
            }
            target = (char *)0;
        }
    } while (0);
    return rc;
}

canonical_original_code:
int diminuto_fs_mkdir_p(char *path, unsigned int mode, int all)
{
    int rc = 0;
    unsigned long length = 0;
    char *source = (char *)0;
    char *sink = (char *)0;
    char *target = (char *)0;
    char *saveptr = (char *)0;
    char *token = (char *)0;
    static char SLASH[] = "/";
    do {
        length = strlen(path);
        if (length >= sizeof(diminuto_path_t)) {
            rc = -1;
            (*__errno_location ()) = 36;
            break;
        } else if (length <= 0) {
            break;
        } else {
            length += 1;
        }
        if (Debug) { diminuto_log_emit("diminuto_fs_mkdir_p: path=\"%s\"\n", path); }
        source = (char *)__builtin_alloca (length);
        strncpy(source, path, length);
        if (all) {
        } else if ((token = strrchr(source, SLASH[0])) == (char *)0) {
            break;
        } else if (token == source) {
            break;
        } else {
            *token = '\0';
        }
        if (Debug) { diminuto_log_emit("diminuto_fs_mkdir_p: source=\"%s\"\n", source); }
        sink = (char *)__builtin_alloca (length);
        memset(sink, 0, length);
        target = source;
        while ((token = strtok_r(target, SLASH, &saveptr)) != (char *)0) {
            if (Debug) { diminuto_log_emit("diminuto_fs_mkdir_p: token=\"%s\"\n", token); }
            if (token != source) {
                strcat(sink, SLASH);
            }
            strcat(sink, token);
            if (Debug) { diminuto_log_emit("diminuto_fs_mkdir_p: sink=\"%s\"\n", sink); }
            rc = mkdir(sink, mode);
            if (rc == 0) {
            } else if ((*__errno_location ()) == 17) {
                rc = 0;
            } else {
                break;
            }
            target = (char *)0;
        }
    } while (0);
    return rc;
}

variable_types:
path
char *

variable_types: all int

variable_types: rc int

variable_types:
length
unsigned long

variable_types:
source
char *

variable_types:
sink
char *

variable_types:
target
char *

variable_types:
saveptr
char *

variable_types:
token
char *

variable_types:
SLASH
char []


decompiled_code:
__int64 __fastcall diminuto_fs_canonicalize(char *s, char *dest, unsigned __int64 a3)
{
char *v3; // rbp
size_t v4; // rax
size_t v5; // rbx
int v6; // er15
unsigned __int64 v7; // r13
size_t v8; // r8
char *v9; // r14
size_t v10; // r15
const char *v11; // rbx
char *v12; // rax
size_t v13; // rax
__int64 result; // rax
char *v15; // rax
char *v16; // r13
size_t v17; // rax
__int64 v18; // r10
char *v19; // rax
char *v20; // rax
__int64 v22; // [rsp+8h] [rbp-2048h]
size_t v23; // [rsp+8h] [rbp-2048h]
__int64 v24; // [rsp+10h] [rbp-2040h]
char desta[16]; // [rsp+18h] [rbp-2038h] BYREF
char v26[4080]; // [rsp+28h] [rbp-2028h] BYREF
char resolved[16]; // [rsp+1018h] [rbp-1038h] BYREF
char v28[4080]; // [rsp+1028h] [rbp-1028h] BYREF

v3 = s;
memset(v26, 0, sizeof(v26));
*(_OWORD *)desta = 0LL;
memset(v28, 0, sizeof(v28));
*(_OWORD *)resolved = 0LL;
if ( Debug )
diminuto_log_emit("diminuto_fs_canonicalize: relative=\"%s\"\n", s);
v4 = strnlen(s, 0x1000uLL);
v5 = v4;
if ( v4 == 4096 )
{
*_errno_location() = 36;
diminuto_log_perror("src/diminuto_fs.c", 364LL, s);
return 0xFFFFFFFFLL;
}
if ( !v4 )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_fs.c", 369LL, s);
return 0xFFFFFFFFLL;
}
if ( *s == 47 )
{
v6 = Debug;
if ( !s[1] )
goto LABEL_7;
}
else
{
v6 = Debug;
if ( *s == 47 )
{
LABEL_7:
v7 = 1LL;
v8 = 0LL;
v9 = (char *)&LC7;
goto LABEL_8;
}
}
if ( *s == 47 && s[1] == 46 )
{
v8 = 0LL;
v7 = 1LL;
v9 = (char *)&LC7;
if ( !s[2] )
{
if ( !v6 )
goto LABEL_9;
goto LABEL_31;
}
}
v22 = v4;
if ( !strcmp(s, "/..") )
goto LABEL_7;
v15 = strrchr(s, 47);
v16 = v15;
if ( !v15 )
{
v7 = v5 + 1;
if ( !v6 )
{
v9 = s;
v3 = ".";
goto LABEL_25;
}
v9 = s;
v8 = v5;
v18 = 1LL;
v3 = ".";
goto LABEL_36;
}
v9 = v15 + 1;
v17 = strnlen(v15 + 1, 0x1000uLL);
v18 = v22;
v8 = v17;
if ( !v17 )
{
v7 = 1LL;
v9 = (char *)&LC7;
goto LABEL_24;
}
if ( v16[1] == 46 && !v9[1] || v16[1] == 46 && v9[1] == 46 && !v9[2] )
{
v7 = 1LL;
v8 = 0LL;
v9 = (char *)&LC7;
goto LABEL_24;
}
v7 = v17 + 1;
if ( v9 > s + 1 )
{
v24 = v22;
v23 = v17;
v20 = strncpy(desta, s, v9 - s);
v8 = v23;
v18 = v24;
v3 = v20;
LABEL_24:
if ( !v6 )
{
LABEL_25:
v19 = realpath(v3, resolved);
v11 = v19;
if ( !v19 )
{
diminuto_log_perror("src/diminuto_fs.c", 432LL, v3);
return 0xFFFFFFFFLL;
}
v28[4079] = 0;
v10 = strlen(v19);
v7 += v10;
goto LABEL_32;
}
LABEL_36:
diminuto_log_emit("diminuto_fs_canonicalize: path=\"%s\"[%zu] file=\"%s\"[%zu]\n", v3, v18 - v8, v9, v8);
goto LABEL_25;
}
LABEL_8:
if ( v6 )
{
LABEL_31:
v3 = (char *)&LC7;
v10 = 0LL;
diminuto_log_emit("diminuto_fs_canonicalize: path=\"%s\"[%zu] file=\"%s\"[%zu]\n", &LC7, -(__int64)v8, v9, v8);
v11 = &LC7;
LABEL_32:
if ( Debug )
diminuto_log_emit("diminuto_fs_canonicalize: prefix=\"%s\"\n", v11);
goto LABEL_10;
}
LABEL_9:
v3 = (char *)&LC7;
v10 = 0LL;
v11 = &LC7;
LABEL_10:
if ( a3 <= v7 )
{
*_errno_location() = 36;
diminuto_log_perror("src/diminuto_fs.c", 447LL, v3);
result = 0xFFFFFFFFLL;
}
else
{
v12 = stpcpy(dest, v11);
if ( v11[v10 - 1] != 47 )
*(_WORD *)v12 = 47;
v13 = strlen(dest);
strcpy(&dest[v13], v9);
result = (unsigned int)Debug;
if ( Debug )
{
diminuto_log_emit("diminuto_fs_canonicalize: absolute=\"%s\"\n", dest);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s, char *dest, unsigned __int64 a3)
{
char *v3; // rbp
size_t v4; // rax
size_t v5; // rbx
int v6; // er15
unsigned __int64 v7; // r13
size_t v8; // r8
char *v9; // r14
size_t v10; // r15
const char *v11; // rbx
char *v12; // rax
size_t v13; // rax
__int64 result; // rax
char *v15; // rax
char *v16; // r13
size_t v17; // rax
__int64 v18; // r10
char *v19; // rax
char *v20; // rax
__int64 v22; // [rsp+8h] [rbp-2048h]
size_t v23; // [rsp+8h] [rbp-2048h]
__int64 v24; // [rsp+10h] [rbp-2040h]
char desta[16]; // [rsp+18h] [rbp-2038h] BYREF
char v26[4080]; // [rsp+28h] [rbp-2028h] BYREF
char resolved[16]; // [rsp+1018h] [rbp-1038h] BYREF
char v28[4080]; // [rsp+1028h] [rbp-1028h] BYREF

v3 = s;
memset(v26, 0, sizeof(v26));
*(_OWORD *)desta = 0LL;
memset(v28, 0, sizeof(v28));
*(_OWORD *)resolved = 0LL;
if ( Debug )
diminuto_log_emit("diminuto_fs_canonicalize: relative=\"%s\"\n", s);
v4 = strnlen(s, 0x1000uLL);
v5 = v4;
if ( v4 == 4096 )
{
*_errno_location() = 36;
diminuto_log_perror("src/diminuto_fs.c", 364LL, s);
return 0xFFFFFFFFLL;
}
if ( !v4 )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_fs.c", 369LL, s);
return 0xFFFFFFFFLL;
}
if ( *s == 47 )
{
v6 = Debug;
if ( !s[1] )
goto LABEL_7;
}
else
{
v6 = Debug;
if ( *s == 47 )
{
LABEL_7:
v7 = 1LL;
v8 = 0LL;
v9 = (char *)&LC7;
goto LABEL_8;
}
}
if ( *s == 47 && s[1] == 46 )
{
v8 = 0LL;
v7 = 1LL;
v9 = (char *)&LC7;
if ( !s[2] )
{
if ( !v6 )
goto LABEL_9;
goto LABEL_31;
}
}
v22 = v4;
if ( !strcmp(s, "/..") )
goto LABEL_7;
v15 = strrchr(s, 47);
v16 = v15;
if ( !v15 )
{
v7 = v5 + 1;
if ( !v6 )
{
v9 = s;
v3 = ".";
goto LABEL_25;
}
v9 = s;
v8 = v5;
v18 = 1LL;
v3 = ".";
goto LABEL_36;
}
v9 = v15 + 1;
v17 = strnlen(v15 + 1, 0x1000uLL);
v18 = v22;
v8 = v17;
if ( !v17 )
{
v7 = 1LL;
v9 = (char *)&LC7;
goto LABEL_24;
}
if ( v16[1] == 46 && !v9[1] || v16[1] == 46 && v9[1] == 46 && !v9[2] )
{
v7 = 1LL;
v8 = 0LL;
v9 = (char *)&LC7;
goto LABEL_24;
}
v7 = v17 + 1;
if ( v9 > s + 1 )
{
v24 = v22;
v23 = v17;
v20 = strncpy(desta, s, v9 - s);
v8 = v23;
v18 = v24;
v3 = v20;
LABEL_24:
if ( !v6 )
{
LABEL_25:
v19 = realpath(v3, resolved);
v11 = v19;
if ( !v19 )
{
diminuto_log_perror("src/diminuto_fs.c", 432LL, v3);
return 0xFFFFFFFFLL;
}
v28[4079] = 0;
v10 = strlen(v19);
v7 += v10;
goto LABEL_32;
}
LABEL_36:
diminuto_log_emit("diminuto_fs_canonicalize: path=\"%s\"[%zu] file=\"%s\"[%zu]\n", v3, v18 - v8, v9, v8);
goto LABEL_25;
}
LABEL_8:
if ( v6 )
{
LABEL_31:
v3 = (char *)&LC7;
v10 = 0LL;
diminuto_log_emit("diminuto_fs_canonicalize: path=\"%s\"[%zu] file=\"%s\"[%zu]\n", &LC7, -(__int64)v8, v9, v8);
v11 = &LC7;
LABEL_32:
if ( Debug )
diminuto_log_emit("diminuto_fs_canonicalize: prefix=\"%s\"\n", v11);
goto LABEL_10;
}
LABEL_9:
v3 = (char *)&LC7;
v10 = 0LL;
v11 = &LC7;
LABEL_10:
if ( a3 <= v7 )
{
*_errno_location() = 36;
diminuto_log_perror("src/diminuto_fs.c", 447LL, v3);
result = 0xFFFFFFFFLL;
}
else
{
v12 = stpcpy(dest, v11);
if ( v11[v10 - 1] != 47 )
*(_WORD *)v12 = 47;
v13 = strlen(dest);
strcpy(&dest[v13], v9);
result = (unsigned int)Debug;
if ( Debug )
{
diminuto_log_emit("diminuto_fs_canonicalize: absolute=\"%s\"\n", dest);
result = 0LL;
}
}
return result;
}

original_code:
int diminuto_fs_canonicalize(const char * path, char * buffer, size_t size)
{
    int rc = -1;
    const char * file = (char *)0;
    char * prefix = (char *)0;
    diminuto_path_t relativepath = { '\0', };
    diminuto_path_t absolutepath = { '\0', };
    size_t length = 1;
    size_t plength = 0;
    size_t flength = 0;
    size_t xlength = 0;
    do {
        if (Debug) { diminuto_log_emit("diminuto_fs_canonicalize: relative=\"%s\"\n", path); }
        if ((plength = strnlen(path, sizeof(relativepath))) >= sizeof(relativepath)) {
            (*__errno_location ()) = 36;
            diminuto_log_perror("src/diminuto_fs.c", 364, path);
            break;
        } else if (plength == 0) {
            (*__errno_location ()) = 22;
            diminuto_log_perror("src/diminuto_fs.c", 369, path);
            break;
        } else if (strcmp(path, "/") == 0) {
            path = "";
            plength = 0;
            file = "";
            flength = 0;
        } else if (strcmp(path, "/.") == 0) {
            path = "";
            plength = 0;
            file = "";
            flength = 0;
        } else if (strcmp(path, "/..") == 0) {
            path = "";
            plength = 0;
            file = "";
            flength = 0;
        } else if ((file = strrchr(path, '/')) == (const char *)0) {
            file = path;
            flength = plength;
            path = ".";
            plength = 1;
        } else if ((flength = strnlen(++file, sizeof(relativepath))) == 0) {
            file = "";
            flength = 0;
        } else if (strcmp(file, ".") == 0) {
            file = "";
            flength = 0;
        } else if (strcmp(file, "..") == 0) {
            file = "";
            flength = 0;
        } else if (file <= (path + 1)) {
            path = "";
            plength = 0;
        } else {
            strncpy(relativepath, path, file - path);
            path = relativepath;
        }
        length += flength;
        if (Debug) { diminuto_log_emit("diminuto_fs_canonicalize: path=\"%s\"[%zu] file=\"%s\"[%zu]\n", path, plength - flength, file, flength); }
        if (plength == 0) {
            prefix = "";
        } else if ((prefix = realpath(path, absolutepath)) == (char *)0) {
            diminuto_log_perror("src/diminuto_fs.c", 432, path);
            break;
        } else {
            absolutepath[sizeof(absolutepath) - 1] = '\0';
        }
        length += (xlength = strlen(prefix));
        if (Debug) { diminuto_log_emit("diminuto_fs_canonicalize: prefix=\"%s\"\n", prefix); }
        if (length >= size) {
            (*__errno_location ()) = 36;
            diminuto_log_perror("src/diminuto_fs.c", 447, path);
            break;
        }
        strcpy(buffer, prefix);
        if (prefix[xlength - 1] != '/') {
            strcat(buffer, "/");
        }
        strcat(buffer, file);
        if (Debug) { diminuto_log_emit("diminuto_fs_canonicalize: absolute=\"%s\"\n", buffer); }
        rc = 0;
    } while (0);
    return rc;
}

canonical_original_code:
int diminuto_fs_canonicalize(char *path, char *buffer, unsigned long size)
{
    int rc = -1;
    char *file = (char *)0;
    char *prefix = (char *)0;
    char relativepath[-1] = { '\0', };
    char absolutepath[-1] = { '\0', };
    unsigned long length = 1;
    unsigned long plength = 0;
    unsigned long flength = 0;
    unsigned long xlength = 0;
    do {
        if (Debug) { diminuto_log_emit("diminuto_fs_canonicalize: relative=\"%s\"\n", path); }
        if ((plength = strnlen(path, sizeof(relativepath))) >= sizeof(relativepath)) {
            (*__errno_location ()) = 36;
            diminuto_log_perror("src/diminuto_fs.c", 364, path);
            break;
        } else if (plength == 0) {
            (*__errno_location ()) = 22;
            diminuto_log_perror("src/diminuto_fs.c", 369, path);
            break;
        } else if (strcmp(path, "/") == 0) {
            path = "";
            plength = 0;
            file = "";
            flength = 0;
        } else if (strcmp(path, "/.") == 0) {
            path = "";
            plength = 0;
            file = "";
            flength = 0;
        } else if (strcmp(path, "/..") == 0) {
            path = "";
            plength = 0;
            file = "";
            flength = 0;
        } else if ((file = strrchr(path, '/')) == (char *)0) {
            file = path;
            flength = plength;
            path = ".";
            plength = 1;
        } else if ((flength = strnlen(++file, sizeof(relativepath))) == 0) {
            file = "";
            flength = 0;
        } else if (strcmp(file, ".") == 0) {
            file = "";
            flength = 0;
        } else if (strcmp(file, "..") == 0) {
            file = "";
            flength = 0;
        } else if (file <= (path + 1)) {
            path = "";
            plength = 0;
        } else {
            strncpy(relativepath, path, file - path);
            path = relativepath;
        }
        length += flength;
        if (Debug) { diminuto_log_emit("diminuto_fs_canonicalize: path=\"%s\"[%zu] file=\"%s\"[%zu]\n", path, plength - flength, file, flength); }
        if (plength == 0) {
            prefix = "";
        } else if ((prefix = realpath(path, absolutepath)) == (char *)0) {
            diminuto_log_perror("src/diminuto_fs.c", 432, path);
            break;
        } else {
            absolutepath[sizeof(absolutepath) - 1] = '\0';
        }
        length += (xlength = strlen(prefix));
        if (Debug) { diminuto_log_emit("diminuto_fs_canonicalize: prefix=\"%s\"\n", prefix); }
        if (length >= size) {
            (*__errno_location ()) = 36;
            diminuto_log_perror("src/diminuto_fs.c", 447, path);
            break;
        }
        strcpy(buffer, prefix);
        if (prefix[xlength - 1] != '/') {
            strcat(buffer, "/");
        }
        strcat(buffer, file);
        if (Debug) { diminuto_log_emit("diminuto_fs_canonicalize: absolute=\"%s\"\n", buffer); }
        rc = 0;
    } while (0);
    return rc;
}

variable_types:
buffer
char *

variable_types:
size
unsigned long

variable_types:
file
char *

variable_types:
prefix
char *

variable_types:
relativepath
char [-1]

variable_types:
absolutepath
char [-1]

variable_types:
plength
unsigned long

variable_types:
flength
unsigned long

variable_types:
xlength
unsigned long


decompiled_code:
__int64 __fastcall diminuto_fs_type(char *file)
{
int v1; // er8
__int64 result; // rax
struct stat v3; // [rsp+0h] [rbp-98h] BYREF

memset(&v3, 0, sizeof(v3));
v1 = stat(file, &v3);
result = 45LL;
if ( v1 >= 0 )
result = diminuto_fs_mode2type(v3.st_mode);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *file)
{
int v1; // er8
__int64 result; // rax
struct stat v3; // [rsp+0h] [rbp-98h] BYREF

memset(&v3, 0, sizeof(v3));
v1 = stat(file, &v3);
result = 45LL;
if ( v1 >= 0 )
result = func1(v3.st_mode);
return result;
}

original_code:
diminuto_fs_type_t diminuto_fs_type(const char * path)
{
    struct stat status = { 0, };
    diminuto_fs_type_t type = DIMINUTO_FS_TYPE_NONE;
    if (stat(path, &status) < 0) {
    } else {
        type = diminuto_fs_mode2type(status.st_mode);
    }
    return type;
}

canonical_original_code:
enum DiminutoFsType diminuto_fs_type(char *path)
{
    struct stat status = { 0, };
    enum DiminutoFsType type = DIMINUTO_FS_TYPE_NONE;
    if (stat(path, &status) < 0) {
    } else {
        type = diminuto_fs_mode2type(status.st_mode);
    }
    return type;
}

variable_types:
path
char *

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

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 }


foo

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

if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
result = diminuto_log_log();
}
}
}
}
}
if ( *(_WORD *)(a1 + 14) != 88 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
result = diminuto_core_fatal();
}
return result;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
result = diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
result = diminuto_log_log();
}
}
}
}
}
if ( *(_WORD *)(a1 + 14) != 88 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
result = diminuto_core_fatal();
}
return result;
}

original_code:
static void foo(array_t * pointer) {
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "39" ": " "CHECKPOINT: " "foo(pointer)\n") : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "40" ": " "CHECKPOINT: " "pointer=%p\n", (void *)pointer) : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "41" ": " "CHECKPOINT: " "sizeof=%zu\n", sizeof(*pointer)) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(sizeof(*pointer) == 16); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "42" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "sizeof(*pointer) == 16") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "43" ": " "CHECKPOINT: " "zeroth=%zu\n", sizeof((*pointer)[0])) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(sizeof((*pointer)[0]) == 2); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "44" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "sizeof((*pointer)[0]) == 2") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "45" ": " "CHECKPOINT: " "countof=%zu\n", sizeof(*pointer) / sizeof((*pointer)[0])) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!((sizeof(*pointer) / sizeof((*pointer)[0])) == 8); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "46" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "(sizeof(*pointer) / sizeof((*pointer)[0])) == 8") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "47" ": " "CHECKPOINT: " "eighth=%u\n", (*pointer)[7]) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!((*pointer)[7] == 88); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "48" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "(*pointer)[7] == 88") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
}

canonical_original_code:
static void foo(unsigned short (*pointer)[-1]) {
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "39" ": " "CHECKPOINT: " "foo(pointer)\n") : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "40" ": " "CHECKPOINT: " "pointer=%p\n", (void *)pointer) : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "41" ": " "CHECKPOINT: " "sizeof=%zu\n", sizeof(*pointer)) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(sizeof(*pointer) == 16); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "42" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "sizeof(*pointer) == 16") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "43" ": " "CHECKPOINT: " "zeroth=%zu\n", sizeof((*pointer)[0])) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(sizeof((*pointer)[0]) == 2); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "44" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "sizeof((*pointer)[0]) == 2") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "45" ": " "CHECKPOINT: " "countof=%zu\n", sizeof(*pointer) / sizeof((*pointer)[0])) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!((sizeof(*pointer) / sizeof((*pointer)[0])) == 8); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "46" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "(sizeof(*pointer) / sizeof((*pointer)[0])) == 8") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "47" ": " "CHECKPOINT: " "eighth=%u\n", (*pointer)[7]) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!((*pointer)[7] == 88); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "48" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "(*pointer)[7] == 88") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
}

variable_types:
pointer
unsigned short (*)[-1]


bar

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
diminuto_log_log();
}
}
}
result = a1;
if ( *(_WORD *)(a1 + 14) != 88 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
result = diminuto_core_fatal();
}
return result;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
if ( (diminuto_log_mask & 2) != 0 )
diminuto_log_log();
}
}
}
result = a1;
if ( *(_WORD *)(a1 + 14) != 88 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
result = diminuto_core_fatal();
}
return result;
}

original_code:
static void bar(array_t variable) {
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "56" ": " "CHECKPOINT: " "bar(variable)\n") : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "57" ": " "CHECKPOINT: " "variable=%p\n", (void *)variable) : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "65" ": " "CHECKPOINT: " "variable=%p\n", (void *)&variable) : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "66" ": " "CHECKPOINT: " "eighth=%u\n", variable[7]) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(variable[7] == 88); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "67" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "variable[7] == 88") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
}

canonical_original_code:
static void bar(unsigned short variable[-1]) {
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "56" ": " "CHECKPOINT: " "bar(variable)\n") : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "57" ": " "CHECKPOINT: " "variable=%p\n", (void *)variable) : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "65" ": " "CHECKPOINT: " "variable=%p\n", (void *)&variable) : ((void)0));;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-arraytype.c" "@" "66" ": " "CHECKPOINT: " "eighth=%u\n", variable[7]) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(variable[7] == 88); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-arraytype.c" "@" "67" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "variable[7] == 88") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
}

variable_types:
variable
unsigned short [-1]