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

v1 = a1;
memset(&v3.sa_mask, 0, 0x90uLL);
v3.sa_handler = diminuto_hangup_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(1, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_hangup.c", 91LL, "diminuto_hangup_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_hangup_debug[0];
if ( diminuto_hangup_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_hangup_install: SIGHUP");
result = 0LL;
}
}
}
return result;
}

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

v1 = a1;
memset(&v3.sa_mask, 0, 0x90uLL);
v3.sa_handler = diminuto_hangup_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(1, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_hangup.c", 91LL, "diminuto_hangup_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_hangup_debug[0];
if ( diminuto_hangup_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_hangup_install: SIGHUP");
result = 0LL;
}
}
}
return result;
}

original_code:
int diminuto_hangup_install(int restart)
{
    struct sigaction hangup;
    memset(&hangup, 0, sizeof(hangup));
    hangup.__sigaction_handler.sa_handler = diminuto_hangup_handler;
    hangup.sa_flags = restart ? 0x10000000 : 0;
    if (sigaction(1, &hangup, (struct sigaction *)0) < 0) {
        diminuto_log_perror("src/diminuto_hangup.c", 91, "diminuto_hangup_install: sigaction");
        return -1;
    } else if (diminuto_hangup_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_hangup_install: SIGHUP") : ((void)0));
    } else {
    }
    return 0;
}

variable_types: restart int

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


repo: coverclock/com-diag-diminuto

decompiled_code:
_BOOL8 __fastcall diminuto_throttle_isempty(__int64 a1)
{
return (*(_BYTE *)(a1 + 48) & 0x10) != 0;
}

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

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

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

return_type: int


decompiled_code:
_BOOL8 __fastcall diminuto_throttle_isfull(__int64 a1)
{
return (*(_BYTE *)(a1 + 48) & 2) != 0;
}

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

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_throttle_isalarmed(__int64 a1)
{
return (*(_BYTE *)(a1 + 48) & 0x40) != 0;
}

original_code:
static inline int diminuto_throttle_isalarmed(const diminuto_throttle_t * throttlep)
{
    return (throttlep->alarmed1 != 0);
}

canonical_original_code:
static inline int diminuto_throttle_isalarmed(struct DiminutoThrottle *throttlep)
{
    return (throttlep->alarmed1 != 0);
}


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

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

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


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

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_throttle_alarmed(__int64 a1)
{
return (*(_BYTE *)(a1 + 48) & 0xC0) == 64;
}

original_code:
static inline int diminuto_throttle_alarmed(const diminuto_throttle_t * throttlep)
{
    return (throttlep->alarmed1 != 0) && (throttlep->alarmed2 == 0);
}

canonical_original_code:
static inline int diminuto_throttle_alarmed(struct DiminutoThrottle *throttlep)
{
    return (throttlep->alarmed1 != 0) && (throttlep->alarmed2 == 0);
}


decompiled_code:
_BOOL8 __fastcall diminuto_throttle_cleared(__int64 a1)
{
return (*(_BYTE *)(a1 + 48) & 0xC0) == 0x80;
}

original_code:
static inline int diminuto_throttle_cleared(const diminuto_throttle_t * throttlep)
{
    return (throttlep->alarmed1 == 0) && (throttlep->alarmed2 != 0);
}

canonical_original_code:
static inline int diminuto_throttle_cleared(struct DiminutoThrottle *throttlep)
{
    return (throttlep->alarmed1 == 0) && (throttlep->alarmed2 != 0);
}


decompiled_code:
__int64 __fastcall diminuto_throttle_admitn(__int64 a1, __int64 a2, __int64 a3)
{
diminuto_throttle_request();
return diminuto_throttle_commitn(a1, a3);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
diminuto_throttle_request();
return diminuto_throttle_commitn(a1, a3);
}

original_code:
static inline int diminuto_throttle_admitn(diminuto_throttle_t * throttlep, diminuto_ticks_t now, size_t events)
{
    diminuto_throttle_request(throttlep, now);
    return diminuto_throttle_commitn(throttlep, events);
}

canonical_original_code:
static inline int diminuto_throttle_admitn(struct DiminutoThrottle *throttlep, unsigned long now, unsigned long events)
{
    diminuto_throttle_request(throttlep, now);
    return diminuto_throttle_commitn(throttlep, events);
}

variable_types:
now
unsigned long

variable_types:
events
unsigned long


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

result = a2;
if ( a4 > 1 && a3 > a1 )
result = (a4 - 1) * (a3 - a1) + a2;
return result;
}

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

result = a2;
if ( a4 > 1 && a3 > a1 )
result = (a4 - 1) * (a3 - a1) + a2;
return result;
}

original_code:
diminuto_ticks_t diminuto_shaper_bursttolerance(diminuto_ticks_t peakincrement, diminuto_ticks_t jittertolerance, diminuto_ticks_t sustainedincrement, size_t maximumburstsize)
{
    diminuto_ticks_t limit = 0;
    diminuto_ticks_t increment = 0;
    if (maximumburstsize <= 1) {
    } else if (sustainedincrement <= peakincrement) {
    } else {
        limit = maximumburstsize - 1;
        increment = sustainedincrement;
        increment -= peakincrement;
        limit *= increment;
    }
    limit += jittertolerance;
    return limit;
}

canonical_original_code:
unsigned long diminuto_shaper_bursttolerance(unsigned long peakincrement, unsigned long jittertolerance, unsigned long sustainedincrement, unsigned long maximumburstsize)
{
    unsigned long limit = 0;
    unsigned long increment = 0;
    if (maximumburstsize <= 1) {
    } else if (sustainedincrement <= peakincrement) {
    } else {
        limit = maximumburstsize - 1;
        increment = sustainedincrement;
        increment -= peakincrement;
        limit *= increment;
    }
    limit += jittertolerance;
    return limit;
}

variable_types:
peakincrement
unsigned long

variable_types:
jittertolerance
unsigned long

variable_types:
sustainedincrement
unsigned long

variable_types:
maximumburstsize
unsigned long

variable_types:
limit
unsigned long

variable_types:
increment
unsigned long

return_type: unsigned long


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

if ( diminuto_throttle_init(a1, a2, a3, a6) && diminuto_throttle_init(a1 + 56, a4, a5, a6) )
result = a1;
else
result = 0LL;
return result;
}

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

if ( diminuto_throttle_init(a1, a2, a3, a6) && diminuto_throttle_init(a1 + 56, a4, a5, a6) )
result = a1;
else
result = 0LL;
return result;
}

original_code:
diminuto_shaper_t * diminuto_shaper_init(diminuto_shaper_t * shaperp, diminuto_ticks_t peakincrement, diminuto_ticks_t jittertolerance, diminuto_ticks_t sustainedincrement, diminuto_ticks_t bursttolerance, diminuto_ticks_t now)
{
    diminuto_shaper_t * result = (diminuto_shaper_t *)0;
    if (diminuto_throttle_init(&(shaperp->peak), peakincrement, jittertolerance, now) == (diminuto_throttle_t *)0) {
    } else if (diminuto_throttle_init(&(shaperp->sustained), sustainedincrement, bursttolerance, now) == (diminuto_throttle_t *)0) {
    } else {
        result = shaperp;
    }
    return result;
}

canonical_original_code:
struct DiminutoShaper *diminuto_shaper_init(struct DiminutoShaper *shaperp, unsigned long peakincrement, unsigned long jittertolerance, unsigned long sustainedincrement, unsigned long bursttolerance, unsigned long now)
{
    struct DiminutoShaper *result = (diminuto_shaper_t *)0;
    if (diminuto_throttle_init(&(shaperp->peak), peakincrement, jittertolerance, now) == (struct DiminutoThrottle *)0) {
    } else if (diminuto_throttle_init(&(shaperp->sustained), sustainedincrement, bursttolerance, now) == (struct DiminutoThrottle *)0) {
    } else {
        result = shaperp;
    }
    return result;
}

variable_types:
shaperp
struct DiminutoShaper *

variable_types:
bursttolerance
unsigned long

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

user_defined_types: struct DiminutoShaper { struct DiminutoThrottle peak; struct DiminutoThrottle sustained; }


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

if ( ((__int64 (*)(void))diminuto_throttle_reset)() && diminuto_throttle_reset(a1 + 56, a2) )
result = a1;
else
result = 0LL;
return result;
}

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

if ( ((__int64 (*)(void))diminuto_throttle_reset)() && diminuto_throttle_reset(a1 + 56, a2) )
result = a1;
else
result = 0LL;
return result;
}

original_code:
diminuto_shaper_t * diminuto_shaper_reset(diminuto_shaper_t * shaperp, diminuto_ticks_t now)
{
    diminuto_shaper_t * result = (diminuto_shaper_t *)0;
    if (diminuto_throttle_reset(&(shaperp->peak), now) == (diminuto_throttle_t *)0) {
    } else if (diminuto_throttle_reset(&(shaperp->sustained), now) == (diminuto_throttle_t *)0) {
    } else {
        result = shaperp;
    }
    return result;
}

canonical_original_code:
struct DiminutoShaper *diminuto_shaper_reset(struct DiminutoShaper *shaperp, unsigned long now)
{
    struct DiminutoShaper *result = (diminuto_shaper_t *)0;
    if (diminuto_throttle_reset(&(shaperp->peak), now) == (struct DiminutoThrottle *)0) {
    } else if (diminuto_throttle_reset(&(shaperp->sustained), now) == (struct DiminutoThrottle *)0) {
    } else {
        result = shaperp;
    }
    return result;
}

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


decompiled_code:
unsigned __int64 __fastcall diminuto_shaper_request(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rbx
unsigned __int64 result; // rax

v2 = ((__int64 (*)(void))diminuto_throttle_request)();
result = diminuto_throttle_request(a1 + 56, a2);
if ( v2 >= result )
result = v2;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func12(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rbx
unsigned __int64 result; // rax

v2 = ((__int64 (*)(void))diminuto_throttle_request)();
result = diminuto_throttle_request(a1 + 56, a2);
if ( v2 >= result )
result = v2;
return result;
}

original_code:
diminuto_ticks_t diminuto_shaper_request(diminuto_shaper_t * shaperp, diminuto_ticks_t now)
{
    diminuto_ticks_t peak = 0;
    diminuto_ticks_t sustained = 0;
    peak = diminuto_throttle_request(&(shaperp->peak), now);
    sustained = diminuto_throttle_request(&(shaperp->sustained), now);
    return (peak > sustained) ? peak : sustained;
}

canonical_original_code:
unsigned long diminuto_shaper_request(struct DiminutoShaper *shaperp, unsigned long now)
{
    unsigned long peak = 0;
    unsigned long sustained = 0;
    peak = diminuto_throttle_request(&(shaperp->peak), now);
    sustained = diminuto_throttle_request(&(shaperp->sustained), now);
    return (peak > sustained) ? peak : sustained;
}

variable_types:
peak
unsigned long

variable_types:
sustained
unsigned long


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_commitn(__int64 a1, __int64 a2)
{
int v2; // er12

v2 = diminuto_throttle_commitn(a1, a2);
return ((unsigned int)diminuto_throttle_commitn(a1 + 56, a2) | v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(__int64 a1, __int64 a2)
{
int v2; // er12

v2 = diminuto_throttle_commitn(a1, a2);
return ((unsigned int)diminuto_throttle_commitn(a1 + 56, a2) | v2) != 0;
}

original_code:
int diminuto_shaper_commitn(diminuto_shaper_t * shaperp, size_t events)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_commitn(&(shaperp->peak), events);
    sustained = diminuto_throttle_commitn(&(shaperp->sustained), events);
    return (peak || sustained);
}

canonical_original_code:
int diminuto_shaper_commitn(struct DiminutoShaper *shaperp, unsigned long events)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_commitn(&(shaperp->peak), events);
    sustained = diminuto_throttle_commitn(&(shaperp->sustained), events);
    return (peak || sustained);
}

variable_types: peak int

variable_types: sustained int


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_admitn(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // er13

v4 = diminuto_throttle_admitn(a1, a2, a3);
return ((unsigned int)diminuto_throttle_admitn(a1 + 56, a2, a3) | v4) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func14(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // er13

v4 = func7(a1, a2, a3);
return ((unsigned int)func7(a1 + 56, a2, a3) | v4) != 0;
}

original_code:
int diminuto_shaper_admitn(diminuto_shaper_t * shaperp, diminuto_ticks_t now, size_t events)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_admitn(&(shaperp->peak), now, events);
    sustained = diminuto_throttle_admitn(&(shaperp->sustained), now, events);
    return (peak || sustained);
}

canonical_original_code:
int diminuto_shaper_admitn(struct DiminutoShaper *shaperp, unsigned long now, unsigned long events)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_admitn(&(shaperp->peak), now, events);
    sustained = diminuto_throttle_admitn(&(shaperp->sustained), now, events);
    return (peak || sustained);
}


decompiled_code:
unsigned __int64 __fastcall diminuto_shaper_getexpected(__int64 a1)
{
__int64 v1; // rcx
unsigned __int64 result; // rax
unsigned __int64 v3; // rdx

diminuto_throttle_getexpected_isra_0(*(_QWORD *)(a1 + 32));
result = diminuto_throttle_getexpected_isra_0(*(_QWORD *)(v1 + 88));
if ( v3 >= result )
result = v3;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func15(__int64 a1)
{
__int64 v1; // rcx
unsigned __int64 result; // rax
unsigned __int64 v3; // rdx

func8(*(_QWORD *)(a1 + 32));
result = func8(*(_QWORD *)(v1 + 88));
if ( v3 >= result )
result = v3;
return result;
}

original_code:
diminuto_ticks_t diminuto_shaper_getexpected(const diminuto_shaper_t * shaperp)
{
    diminuto_ticks_t peak = 0;
    diminuto_ticks_t sustained = 0;
    peak = diminuto_throttle_getexpected(&(shaperp->peak));
    sustained = diminuto_throttle_getexpected(&(shaperp->sustained));
    return (peak > sustained) ? peak : sustained;
}

canonical_original_code:
unsigned long diminuto_shaper_getexpected(struct DiminutoShaper *shaperp)
{
    unsigned long peak = 0;
    unsigned long sustained = 0;
    peak = diminuto_throttle_getexpected(&(shaperp->peak));
    sustained = diminuto_throttle_getexpected(&(shaperp->sustained));
    return (peak > sustained) ? peak : sustained;
}


decompiled_code:
__int64 __fastcall diminuto_shaper_isempty(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

diminuto_throttle_isempty(a1);
v1 = diminuto_throttle_isempty(a1 + 56);
return (v2 != 0) & (unsigned __int8)v1;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

func0(a1);
v1 = func0(a1 + 56);
return (v2 != 0) & (unsigned __int8)v1;
}

original_code:
int diminuto_shaper_isempty(const diminuto_shaper_t * shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_isempty(&(shaperp->peak));
    sustained = diminuto_throttle_isempty(&(shaperp->sustained));
    return peak && sustained;
}

canonical_original_code:
int diminuto_shaper_isempty(struct DiminutoShaper *shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_isempty(&(shaperp->peak));
    sustained = diminuto_throttle_isempty(&(shaperp->sustained));
    return peak && sustained;
}


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_isfull(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

diminuto_throttle_isfull(a1);
v1 = diminuto_throttle_isfull(a1 + 56);
return (v1 | v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func17(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

func1(a1);
v1 = func1(a1 + 56);
return (v1 | v2) != 0;
}

original_code:
int diminuto_shaper_isfull(const diminuto_shaper_t * shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_isfull(&(shaperp->peak));
    sustained = diminuto_throttle_isfull(&(shaperp->sustained));
    return peak || sustained;
}

canonical_original_code:
int diminuto_shaper_isfull(struct DiminutoShaper *shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_isfull(&(shaperp->peak));
    sustained = diminuto_throttle_isfull(&(shaperp->sustained));
    return peak || sustained;
}


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_isalarmed(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

diminuto_throttle_isalarmed(a1);
v1 = diminuto_throttle_isalarmed(a1 + 56);
return (v1 | v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func18(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

func2(a1);
v1 = func2(a1 + 56);
return (v1 | v2) != 0;
}

original_code:
int diminuto_shaper_isalarmed(const diminuto_shaper_t * shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_isalarmed(&(shaperp->peak));
    sustained = diminuto_throttle_isalarmed(&(shaperp->sustained));
    return peak || sustained;
}

canonical_original_code:
int diminuto_shaper_isalarmed(struct DiminutoShaper *shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_isalarmed(&(shaperp->peak));
    sustained = diminuto_throttle_isalarmed(&(shaperp->sustained));
    return peak || sustained;
}


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_emptied(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

diminuto_throttle_emptied(a1);
v1 = diminuto_throttle_emptied(a1 + 56);
return (v1 | v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func19(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

func3(a1);
v1 = func3(a1 + 56);
return (v1 | v2) != 0;
}

original_code:
int diminuto_shaper_emptied(const diminuto_shaper_t * shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_emptied(&(shaperp->peak));
    sustained = diminuto_throttle_emptied(&(shaperp->sustained));
    return peak || sustained;
}

canonical_original_code:
int diminuto_shaper_emptied(struct DiminutoShaper *shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_emptied(&(shaperp->peak));
    sustained = diminuto_throttle_emptied(&(shaperp->sustained));
    return peak || sustained;
}


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_filled(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

diminuto_throttle_filled(a1);
v1 = diminuto_throttle_filled(a1 + 56);
return (v1 | v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func20(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

func4(a1);
v1 = func4(a1 + 56);
return (v1 | v2) != 0;
}

original_code:
int diminuto_shaper_filled(const diminuto_shaper_t * shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_filled(&(shaperp->peak));
    sustained = diminuto_throttle_filled(&(shaperp->sustained));
    return peak || sustained;
}

canonical_original_code:
int diminuto_shaper_filled(struct DiminutoShaper *shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_filled(&(shaperp->peak));
    sustained = diminuto_throttle_filled(&(shaperp->sustained));
    return peak || sustained;
}


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_alarmed(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

diminuto_throttle_alarmed(a1);
v1 = diminuto_throttle_alarmed(a1 + 56);
return (v1 | v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func21(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

func5(a1);
v1 = func5(a1 + 56);
return (v1 | v2) != 0;
}

original_code:
int diminuto_shaper_alarmed(const diminuto_shaper_t * shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_alarmed(&(shaperp->peak));
    sustained = diminuto_throttle_alarmed(&(shaperp->sustained));
    return peak || sustained;
}

canonical_original_code:
int diminuto_shaper_alarmed(struct DiminutoShaper *shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_alarmed(&(shaperp->peak));
    sustained = diminuto_throttle_alarmed(&(shaperp->sustained));
    return peak || sustained;
}


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_cleared(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

diminuto_throttle_cleared(a1);
v1 = diminuto_throttle_cleared(a1 + 56);
return (v1 | v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func22(__int64 a1)
{
_BOOL4 v1; // eax
int v2; // edx

func6(a1);
v1 = func6(a1 + 56);
return (v1 | v2) != 0;
}

original_code:
int diminuto_shaper_cleared(const diminuto_shaper_t * shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_cleared(&(shaperp->peak));
    sustained = diminuto_throttle_cleared(&(shaperp->sustained));
    return peak || sustained;
}

canonical_original_code:
int diminuto_shaper_cleared(struct DiminutoShaper *shaperp)
{
    int peak = 0;
    int sustained = 0;
    peak = diminuto_throttle_cleared(&(shaperp->peak));
    sustained = diminuto_throttle_cleared(&(shaperp->sustained));
    return peak || sustained;
}


decompiled_code:
__int64 __fastcall diminuto_shaper_log(__int64 a1)
{
if ( !a1 )
return diminuto_log_emit("diminuto_shaper_t@%p[%zu]\n", 0LL, 0x70uLL);
diminuto_log_emit("diminuto_shaper_t@%p[%zu]: peak@%p\n", (const void *)a1, 0x70uLL, (const void *)a1);
diminuto_throttle_log(a1);
diminuto_log_emit("diminuto_shaper_t@%p[%zu]: sustained@%p\n", (const void *)a1, 0x70uLL, (const void *)(a1 + 56));
return diminuto_throttle_log(a1 + 56);
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1)
{
if ( !a1 )
return diminuto_log_emit("diminuto_shaper_t@%p[%zu]\n", 0LL, 0x70uLL);
diminuto_log_emit("diminuto_shaper_t@%p[%zu]: peak@%p\n", (const void *)a1, 0x70uLL, (const void *)a1);
diminuto_throttle_log(a1);
diminuto_log_emit("diminuto_shaper_t@%p[%zu]: sustained@%p\n", (const void *)a1, 0x70uLL, (const void *)(a1 + 56));
return diminuto_throttle_log(a1 + 56);
}

original_code:
void diminuto_shaper_log(const diminuto_shaper_t * shaperp)
{
    if (shaperp != (diminuto_shaper_t *)0) {
        diminuto_log_emit("diminuto_shaper_t@%p[%zu]: peak@%p\n", shaperp, sizeof(*shaperp), &(shaperp->peak));
        diminuto_throttle_log(&(shaperp->peak));
        diminuto_log_emit("diminuto_shaper_t@%p[%zu]: sustained@%p\n", shaperp, sizeof(*shaperp), &(shaperp->sustained));
        diminuto_throttle_log(&(shaperp->sustained));
    } else {
        diminuto_log_emit("diminuto_shaper_t@%p[%zu]\n", shaperp, sizeof(*shaperp));
    }
}

canonical_original_code:
void diminuto_shaper_log(struct DiminutoShaper *shaperp)
{
    if (shaperp != (struct DiminutoShaper *)0) {
        diminuto_log_emit("diminuto_shaper_t@%p[%zu]: peak@%p\n", shaperp, sizeof(*shaperp), &(shaperp->peak));
        diminuto_throttle_log(&(shaperp->peak));
        diminuto_log_emit("diminuto_shaper_t@%p[%zu]: sustained@%p\n", shaperp, sizeof(*shaperp), &(shaperp->sustained));
        diminuto_throttle_log(&(shaperp->sustained));
    } else {
        diminuto_log_emit("diminuto_shaper_t@%p[%zu]\n", shaperp, sizeof(*shaperp));
    }
}

return_type: void


original_code:
void do_value()
{
    value = 0xdeadbeef;
}

canonical_original_code:
void do_value()
{
    value = 0xdeadbeef;
}


decompiled_code:
void do_sync_synchronize()
{
_mm_mfence();
}

canonical_decompiled_code:
void func8()
{
_mm_mfence();
}

original_code:
void do_sync_synchronize()
{
    __sync_synchronize();
}


decompiled_code:
void diminuto_barrier_f()
{
_mm_mfence();
}

canonical_decompiled_code:
void func9()
{
_mm_mfence();
}

original_code:
static inline void diminuto_barrier_f(void) {
    __sync_synchronize();
}

canonical_original_code:
static inline void diminuto_barrier_f() {
    __sync_synchronize();
}


decompiled_code:
__int64 do_sync_lock_test_and_set()
{
return (unsigned int)_InterlockedExchange(&lock, value);
}

canonical_decompiled_code:
__int64 func10()
{
return (unsigned int)_InterlockedExchange(&lock, value);
}

original_code:
void do_sync_lock_test_and_set()
{
    __sync_lock_test_and_set(&lock, value);
}


decompiled_code:
__int64 diminuto_barrier_acquire_f()
{
__int32 v1; // [rsp+0h] [rbp-4h] BYREF

v1 = 0;
return (unsigned int)_InterlockedExchange(&v1, 1);
}

canonical_decompiled_code:
__int64 func11()
{
__int32 v1; // [rsp+0h] [rbp-4h] BYREF

v1 = 0;
return (unsigned int)_InterlockedExchange(&v1, 1);
}

original_code:
static inline void diminuto_barrier_acquire_f(void) {
    do { volatile diminuto_spinlock_t _diminuto_barrier_acquire_lock_ = 0; __sync_lock_test_and_set(&_diminuto_barrier_acquire_lock_, 1); } while (0);
}

canonical_original_code:
static inline void diminuto_barrier_acquire_f() {
    do { int _diminuto_barrier_acquire_lock_ = 0; __sync_lock_test_and_set(&_diminuto_barrier_acquire_lock_, 1); } while (0);
}


decompiled_code:
void do_sync_lock_release()
{
lock = 0;
}

canonical_decompiled_code:
void func12()
{
lock = 0;
}

original_code:
void do_sync_lock_release()
{
    __sync_lock_release(&lock);
}


decompiled_code:
__int64 do_functions()
{
__int32 v1; // [rsp+0h] [rbp-8h] BYREF

_mm_mfence();
v1 = 0;
return (unsigned int)_InterlockedExchange(&v1, 1);
}

canonical_decompiled_code:
__int64 func13()
{
__int32 v1; // [rsp+0h] [rbp-8h] BYREF

_mm_mfence();
v1 = 0;
return (unsigned int)_InterlockedExchange(&v1, 1);
}

original_code:
void do_functions()
{
    __sync_synchronize();
    do { volatile diminuto_spinlock_t _diminuto_barrier_acquire_lock_ = 0; __sync_lock_test_and_set(&_diminuto_barrier_acquire_lock_, 1); } while (0);
    do { volatile diminuto_spinlock_t _diminuto_barrier_release_lock_ = 1; __sync_lock_release(&_diminuto_barrier_release_lock_); } while (0);
}

canonical_original_code:
void do_functions()
{
    __sync_synchronize();
    do { int _diminuto_barrier_acquire_lock_ = 0; __sync_lock_test_and_set(&_diminuto_barrier_acquire_lock_, 1); } while (0);
    do { int _diminuto_barrier_release_lock_ = 1; __sync_lock_release(&_diminuto_barrier_release_lock_); } while (0);
}


decompiled_code:
void diminuto_barrier_release_f()
{
;
}

canonical_decompiled_code:
void func14()
{
;
}

original_code:
static inline void diminuto_barrier_release_f(void) {
    do { volatile diminuto_spinlock_t _diminuto_barrier_release_lock_ = 1; __sync_lock_release(&_diminuto_barrier_release_lock_); } while (0);
}

canonical_original_code:
static inline void diminuto_barrier_release_f() {
    do { int _diminuto_barrier_release_lock_ = 1; __sync_lock_release(&_diminuto_barrier_release_lock_); } while (0);
}


decompiled_code:
int __fastcall diminuto_fd_acquire(int a1, const char *a2, int a3, unsigned int a4)
{
int result; // eax
int v5; // [rsp+0h] [rbp-Ch]

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

canonical_decompiled_code:
int __fastcall func0(int a1, const char *a2, int a3, unsigned int a4)
{
int result; // eax
int v5; // [rsp+0h] [rbp-Ch]

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

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


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

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

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

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

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


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

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

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

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

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 v4; // r15
ssize_t v8; // rax
ssize_t v9; // rbx
int v11; // eax

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

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

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

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+1Ch] [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+1Ch] [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 result; // rax
__int64 v1; // [rsp+8h] [rbp-10h]

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

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
__int64 v1; // [rsp+8h] [rbp-10h]

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

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:
int __fastcall diminuto_fd_direct_acquire(int a1, const char *a2, int a3, unsigned int a4)
{
return diminuto_fd_acquire(a1, a2, a3 | 0x105000, a4);
}

canonical_decompiled_code:
int __fastcall func10(int a1, const char *a2, int a3, unsigned int a4)
{
return func0(a1, a2, a3 | 0x105000, 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; // er12
struct stat v3; // [rsp+0h] [rbp-A8h] BYREF

v1 = 116;
memset(&v3, 0, sizeof(v3));
if ( isatty(fd) )
return v1;
if ( fstat(fd, &v3) >= 0 )
{
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;
}
diminuto_log_perror("src/diminuto_fd.c", 257LL, "diminuto_fd_type: fstat");
return 63LL;
}

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

v1 = 116;
memset(&v3, 0, sizeof(v3));
if ( isatty(fd) )
return v1;
if ( fstat(fd, &v3) >= 0 )
{
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;
}
diminuto_log_perror("src/diminuto_fd.c", 257LL, "diminuto_fd_type: fstat");
return 63LL;
}

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)
{
__int64 result; // rax

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

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

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

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
unsigned __int64 v5; // r14
double v6; // xmm0_8
unsigned __int64 v7; // rdx
unsigned __int64 v8; // r10
unsigned __int16 v9; // r9
unsigned __int16 v10; // bx
unsigned __int16 *j; // r13
unsigned __int64 v12; // rsi
unsigned __int64 v13; // rdi
__int16 v14; // r8
__int16 v15; // r11
unsigned __int64 v16; // rdx
unsigned int v18; // eax
__int64 v19; // r13
__int64 v20; // rcx
__int64 v21; // r8
__int64 v22; // rdx
__int64 v23; // rsi
unsigned __int64 i; // [rsp+8h] [rbp-3370h]
unsigned int v25; // [rsp+10h] [rbp-3368h]
unsigned __int16 v26; // [rsp+1Eh] [rbp-335Ah]
__int16 s[6572]; // [rsp+20h] [rbp-3358h] BYREF

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

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int16 v3; // bp
double v4; // xmm0_8
unsigned __int64 v5; // r14
double v6; // xmm0_8
unsigned __int64 v7; // rdx
unsigned __int64 v8; // r10
unsigned __int16 v9; // r9
unsigned __int16 v10; // bx
unsigned __int16 *j; // r13
unsigned __int64 v12; // rsi
unsigned __int64 v13; // rdi
__int16 v14; // r8
__int16 v15; // r11
unsigned __int64 v16; // rdx
unsigned int v18; // eax
__int64 v19; // r13
__int64 v20; // rcx
__int64 v21; // r8
__int64 v22; // rdx
__int64 v23; // rsi
unsigned __int64 i; // [rsp+8h] [rbp-3370h]
unsigned int v25; // [rsp+10h] [rbp-3368h]
unsigned __int16 v26; // [rsp+1Eh] [rbp-335Ah]
__int16 s[6572]; // [rsp+20h] [rbp-3358h] BYREF

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

v1 = pthread_mutex_lock(a1);
if ( !v1 )
return 0LL;
*_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; // er12

v1 = pthread_mutex_lock(a1);
if ( !v1 )
return 0LL;
*_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; // er12

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; // er12

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; // er12

v1 = pthread_mutex_unlock(a1);
if ( !v1 )
return 0LL;
*_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; // er12

v1 = pthread_mutex_unlock(a1);
if ( !v1 )
return 0LL;
*_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:
// attributes: thunk
__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 *


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

canonical_decompiled_code:
__int64 func7()
{
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 func8(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 func9(const void *a1)
{
return func8(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_4270E3 = 0;
result = buffer_0;
}
}
else
{
result = "LOCAL";
if ( !a1 )
result = "UNSPECIFIED";
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func10(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_4270E3 = 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; // r12
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; // r12
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; // r12
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; // r12
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; // r12
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; // r12
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; // r12
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; // r12
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:
__int64 __fastcall diminuto_testify(__int64 a1, unsigned int a2)
{
__int64 result; // rax
int v3; // eax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

endptr = 0LL;
if ( !a1 )
return a2;
switch ( *(_BYTE *)a1 )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
v3 = strtol((const char *)a1, &endptr, 0);
if ( *endptr )
return a2;
result = v3 != 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':
return 1LL;
case 'D':
case 'F':
case 'I':
case 'L':
case 'N':
case 'd':
case 'f':
case 'i':
case 'l':
case 'n':
return 0LL;
case 'O':
case 'o':
switch ( *(_BYTE *)(a1 + 1) )
{
case 'F':
case 'P':
case 'f':
case 'p':
return 0LL;
case 'N':
case 'n':
return 1LL;
default:
return a2;
}
default:
return a2;
}
return result;
}

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

endptr = 0LL;
if ( !a1 )
return a2;
switch ( *(_BYTE *)a1 )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
v3 = strtol((const char *)a1, &endptr, 0);
if ( *endptr )
return a2;
result = v3 != 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':
return 1LL;
case 'D':
case 'F':
case 'I':
case 'L':
case 'N':
case 'd':
case 'f':
case 'i':
case 'l':
case 'n':
return 0LL;
case 'O':
case 'o':
switch ( *(_BYTE *)(a1 + 1) )
{
case 'F':
case 'P':
case 'f':
case 'p':
return 0LL;
case 'N':
case 'n':
return 1LL;
default:
return a2;
}
default:
return a2;
}
return result;
}

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 *