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

if ( kill(a1, 14) < 0 )
{
diminuto_log_perror("src/diminuto_alarm.c", 35LL, "diminuto_alarm_signal: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_alarm_debug[0];
if ( diminuto_alarm_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_alarm_signal: SIGALRM");
result = 0LL;
}
}
}
return result;
}

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

if ( kill(a1, 14) < 0 )
{
diminuto_log_perror("src/diminuto_alarm.c", 35LL, "diminuto_alarm_signal: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_alarm_debug[0];
if ( diminuto_alarm_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_alarm_signal: SIGALRM");
result = 0LL;
}
}
}
return result;
}

original_code:
int diminuto_alarm_signal(pid_t pid)
{
    int rc = 0;
    if (kill(pid, 14) < 0) {
        diminuto_log_perror("src/diminuto_alarm.c", 35, "diminuto_alarm_signal: kill");
        rc = -1;
    } else if (diminuto_alarm_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_alarm_signal: SIGALRM") : ((void)0));
    } else {
    }
    return rc;
}

canonical_original_code:
int diminuto_alarm_signal(int pid)
{
    int rc = 0;
    if (kill(pid, 14) < 0) {
        diminuto_log_perror("src/diminuto_alarm.c", 35, "diminuto_alarm_signal: kill");
        rc = -1;
    } else if (diminuto_alarm_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_alarm_signal: SIGALRM") : ((void)0));
    } else {
    }
    return rc;
}

variable_types: pid int


repo: coverclock/com-diag-diminuto

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

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

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

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

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

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

variable_types: mysignaled int

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

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

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

return_type: int

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_alarm_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_alarm_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(14, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_alarm.c", 94LL, "diminuto_alarm_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_alarm_debug[0];
if ( diminuto_alarm_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_alarm_install: SIGALRM");
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_alarm_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(14, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_alarm.c", 94LL, "diminuto_alarm_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_alarm_debug[0];
if ( diminuto_alarm_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_alarm_install: SIGALRM");
result = 0LL;
}
}
}
return result;
}

original_code:
int diminuto_alarm_install(int restart)
{
    int rc = 0;
    struct sigaction alarm = { 0 };
    alarm.__sigaction_handler.sa_handler = diminuto_alarm_handler;
    alarm.sa_flags = restart ? 0x10000000 : 0;
    if (sigaction(14, &alarm, (struct sigaction *)0) < 0) {
        diminuto_log_perror("src/diminuto_alarm.c", 94, "diminuto_alarm_install: sigaction");
        rc = -1;
    } else if (diminuto_alarm_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_alarm_install: SIGALRM") : ((void)0));
    } else {
    }
    return rc;
}

variable_types: restart int

variable_types: rc int

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

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

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


original_code:
int diminuto_cue_debounce(diminuto_cue_state_t * statep, int input)
{
    statep->c = statep->b;
    statep->b = statep->a;
    statep->a = !!input;
    statep->p = statep->r;
    return statep->r = (statep->p & (statep->a | statep->b | statep->c)) | (statep->a & statep->b & statep->c);
}

canonical_original_code:
int diminuto_cue_debounce(struct DiminutoCueState *statep, int input)
{
    statep->c = statep->b;
    statep->b = statep->a;
    statep->a = !!input;
    statep->p = statep->r;
    return statep->r = (statep->p & (statep->a | statep->b | statep->c)) | (statep->a & statep->b & statep->c);
}

variable_types: struct DiminutoCueState { unsigned char a; unsigned char b; unsigned char c; unsigned char r; unsigned char p; } *

variable_types: input int


decompiled_code:
__int64 __fastcall diminuto_cue_edge(_BYTE *a1)
{
char v1; // dl
__int64 result; // rax

v1 = *a1 & 8;
if ( (*a1 & 0x10) != 0 )
result = v1 == 0 ? 6 : 3;
else
result = v1 != 0 ? 5 : 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1)
{
char v1; // dl
__int64 result; // rax

v1 = *a1 & 8;
if ( (*a1 & 0x10) != 0 )
result = v1 == 0 ? 6 : 3;
else
result = v1 != 0 ? 5 : 0;
return result;
}

original_code:
diminuto_cue_edge_t diminuto_cue_edge(const diminuto_cue_state_t * statep)
{
    diminuto_cue_edge_t result;
    if (!statep->p) {
        if (!statep->r) {
            result = DIMINUTO_CUE_EDGE_LOW;
        } else {
            result = DIMINUTO_CUE_EDGE_RISING;
        }
    } else {
        if (!statep->r) {
            result = DIMINUTO_CUE_EDGE_FALLING;
        } else {
            result = DIMINUTO_CUE_EDGE_HIGH;
        }
    }
    return result;
}

canonical_original_code:
enum DiminutoCueEdge diminuto_cue_edge(struct DiminutoCueState *statep)
{
    enum DiminutoCueEdge result;
    if (!statep->p) {
        if (!statep->r) {
            result = DIMINUTO_CUE_EDGE_LOW;
        } else {
            result = DIMINUTO_CUE_EDGE_RISING;
        }
    } else {
        if (!statep->r) {
            result = DIMINUTO_CUE_EDGE_FALLING;
        } else {
            result = DIMINUTO_CUE_EDGE_HIGH;
        }
    }
    return result;
}

variable_types: enum DiminutoCueEdge { DIMINUTO_CUE_EDGE_LOW=expr, DIMINUTO_CUE_EDGE_RISING=expr, DIMINUTO_CUE_EDGE_HIGH=expr, DIMINUTO_CUE_EDGE_FALLING=expr }

user_defined_types: struct DiminutoCueState { unsigned char a; unsigned char b; unsigned char c; unsigned char r; unsigned char p; }


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

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

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

return_type: long


decompiled_code:
// attributes: thunk
__int64 diminuto_frequency_f()
{
return diminuto_frequency();
}

canonical_decompiled_code:
__int64 func1()
{
return func0();
}

original_code:
diminuto_sticks_t diminuto_frequency_f(void)
{
    return diminuto_frequency();
}

canonical_original_code:
long diminuto_frequency_f()
{
    return diminuto_frequency();
}


decompiled_code:
__int64 __fastcall diminuto_fletcher_16(unsigned __int8 *a1, __int64 a2, _BYTE *a3, _BYTE *a4)
{
unsigned __int16 v6; // si
unsigned int v7; // ecx
unsigned __int8 *v9; // r11
int v10; // edx
unsigned int v11; // eax
__int64 result; // rax

v6 = (unsigned __int8)*a3;
v7 = (unsigned __int8)*a4;
if ( a2 )
{
v9 = &a1[a2];
do
{
v10 = *a1++;
v11 = (v10 + (unsigned int)v6) % 0xFF;
v6 = v11;
v7 = ((unsigned __int16)v7 + v11) % 0xFF;
}
while ( a1 != v9 );
*a3 = v11;
*a4 = v7;
result = (v7 << 8) | (unsigned __int8)*a3;
}
else
{
*a3 = v6;
*a4 = v7;
result = (v7 << 8) | (unsigned __int8)*a3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, __int64 a2, _BYTE *a3, _BYTE *a4)
{
unsigned __int16 v6; // si
unsigned int v7; // ecx
unsigned __int8 *v9; // r11
int v10; // edx
unsigned int v11; // eax
__int64 result; // rax

v6 = (unsigned __int8)*a3;
v7 = (unsigned __int8)*a4;
if ( a2 )
{
v9 = &a1[a2];
do
{
v10 = *a1++;
v11 = (v10 + (unsigned int)v6) % 0xFF;
v6 = v11;
v7 = ((unsigned __int16)v7 + v11) % 0xFF;
}
while ( a1 != v9 );
*a3 = v11;
*a4 = v7;
result = (v7 << 8) | (unsigned __int8)*a3;
}
else
{
*a3 = v6;
*a4 = v7;
result = (v7 << 8) | (unsigned __int8)*a3;
}
return result;
}

original_code:
uint16_t diminuto_fletcher_16(const void * buffer, size_t length, uint8_t * ap, uint8_t * bp)
{
    uint16_t result = 0;
    const uint8_t * pp = (const uint8_t *)0;
    uint16_t a = 0;
    uint16_t b = 0;
    a = *ap;
    b = *bp;
    for (pp = (const uint8_t *)buffer; length > 0; --length) {
        a = (a + *(pp++)) % 0xff;
        b = (b + a) % 0xff;
    }
    *ap = a;
    *bp = b;
    result = *bp;
    result <<= 8;
    result |= *ap;
    return result;
}

canonical_original_code:
unsigned short diminuto_fletcher_16(void *buffer, unsigned long length, unsigned char *ap, unsigned char *bp)
{
    unsigned short result = 0;
    unsigned char *pp = (const uint8_t *)0;
    unsigned short a = 0;
    unsigned short b = 0;
    a = *ap;
    b = *bp;
    for (pp = (unsigned char *)buffer; length > 0; --length) {
        a = (a + *(pp++)) % 0xff;
        b = (b + a) % 0xff;
    }
    *ap = a;
    *bp = b;
    result = *bp;
    result <<= 8;
    result |= *ap;
    return result;
}

variable_types:
buffer
void *

variable_types:
length
unsigned long

variable_types:
ap
unsigned char *

variable_types:
bp
unsigned char *

variable_types:
result
unsigned short

variable_types:
pp
unsigned char *

variable_types:
a
unsigned short

variable_types:
b
unsigned short

return_type: unsigned short


decompiled_code:
__int64 diminuto_module_example_dtor()
{
fwrite("diminuto_module_example_dtor\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
fwrite("diminuto_module_example_dtor\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}

original_code:
int diminuto_module_example_dtor(void)
{
    fputs("diminuto_module_example_dtor\n", stderr);
    return 0;
}

canonical_original_code:
int diminuto_module_example_dtor()
{
    fputs("diminuto_module_example_dtor\n", stderr);
    return 0;
}


decompiled_code:
__int64 diminuto_module_example_ctor()
{
fwrite("diminuto_module_example_ctor\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
fwrite("diminuto_module_example_ctor\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}

original_code:
int diminuto_module_example_ctor(void)
{
    fputs("diminuto_module_example_ctor\n", stderr);
    return 0;
}

canonical_original_code:
int diminuto_module_example_ctor()
{
    fputs("diminuto_module_example_ctor\n", stderr);
    return 0;
}


decompiled_code:
__int64 __fastcall diminuto_module_example_function(int a1)
{
return (unsigned int)~a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
return (unsigned int)~a1;
}

original_code:
int diminuto_module_example_function(int input) {
    return ~input;
}


decompiled_code:
// attributes: thunk
__int64 __fastcall diminuto_meter_now()
{
return diminuto_time_elapsed();
}

canonical_decompiled_code:
__int64 __fastcall func8()
{
return diminuto_time_elapsed();
}

original_code:
static inline diminuto_sticks_t diminuto_meter_now()
{
    return diminuto_time_elapsed();
}

canonical_original_code:
static inline long diminuto_meter_now()
{
    return diminuto_time_elapsed();
}


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

result = *a1;
*a1 = result + a2;
return result;
}

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

result = *a1;
*a1 = result + a2;
return result;
}

original_code:
static void * application_functor(void * dp, void * cp) {
    int * ip = (int *)dp;
 void * rp = (void *)(intptr_t)*ip;
    int vp = (intptr_t)cp;
    *ip += vp;
    return rp;
}

canonical_original_code:
static void *application_functor(void *dp, void *cp) {
    int *ip = (int *)dp;
 void *rp = (void *)(intptr_t)*ip;
    int vp = (intptr_t)cp;
    *ip += vp;
    return rp;
}

variable_types:
dp
void *

variable_types:
cp
void *

variable_types:
ip
int *

variable_types:
rp
void *

variable_types: vp int

return_type: void *


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // edi

diminuto_unittest_setlogmask();
if ( (diminuto_log_mask & 4) != 0 )
{
argv = (const char **)"tst/unittest-atomicapply.c@52: SETLOGMASK: logmask=0x%x\n";
diminuto_log_log();
}
diminuto_unittest_test();
if ( (diminuto_log_mask & 4) != 0 )
{
argv = (const char **)"tst/unittest-atomicapply.c@55: TEST: %d tests=%d \n";
diminuto_log_log();
}
diminuto_unittest_flush();
if ( (unsigned int)library_settor_constprop_0(1LL, argv) )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
{
argv = (const char **)"tst/unittest-atomicapply.c@57: ASSERT: tests=%d errors=%d errno=%d !(%s)!\n";
diminuto_log_log();
}
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
if ( (unsigned int)library_settor_constprop_0(2LL, argv) != 1 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
{
argv = (const char **)"tst/unittest-atomicapply.c@58: ASSERT: tests=%d errors=%d errno=%d !(%s)!\n";
diminuto_log_log();
}
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
if ( (unsigned int)library_settor_constprop_0(4294967293LL, argv) != 3 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
if ( (diminuto_log_mask & 4) != 0 )
diminuto_log_log();
diminuto_unittest_flush();
v3 = diminuto_unittest_errors;
if ( (diminuto_log_mask & 4) != 0 )
diminuto_log_log();
diminuto_unittest_flush();
v4 = 255;
if ( v3 <= 255 )
v4 = v3;
exit(v4);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // edi

diminuto_unittest_setlogmask();
if ( (diminuto_log_mask & 4) != 0 )
{
argv = (const char **)"tst/unittest-atomicapply.c@52: SETLOGMASK: logmask=0x%x\n";
diminuto_log_log();
}
diminuto_unittest_test();
if ( (diminuto_log_mask & 4) != 0 )
{
argv = (const char **)"tst/unittest-atomicapply.c@55: TEST: %d tests=%d \n";
diminuto_log_log();
}
diminuto_unittest_flush();
if ( (unsigned int)func8(1LL, argv) )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
{
argv = (const char **)"tst/unittest-atomicapply.c@57: ASSERT: tests=%d errors=%d errno=%d !(%s)!\n";
diminuto_log_log();
}
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
if ( (unsigned int)func8(2LL, argv) != 1 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
{
argv = (const char **)"tst/unittest-atomicapply.c@58: ASSERT: tests=%d errors=%d errno=%d !(%s)!\n";
diminuto_log_log();
}
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
if ( (unsigned int)func8(4294967293LL, argv) != 3 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
if ( (diminuto_log_mask & 4) != 0 )
diminuto_log_log();
diminuto_unittest_flush();
v3 = diminuto_unittest_errors;
if ( (diminuto_log_mask & 4) != 0 )
diminuto_log_log();
diminuto_unittest_flush();
v4 = 255;
if ( v3 <= 255 )
v4 = v3;
exit(v4);
}

original_code:
int main(void)
{
    do { diminuto_unittest_setlogmask(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-atomicapply.c" "@" "52" ": " "SETLOGMASK: logmask=0x%x\n", diminuto_log_mask) : ((void)0)); } while (0);
    {
        do { int diminuto_unittest_local = 0; do { int diminuto_unittest_number = 0; diminuto_unittest_number = diminuto_unittest_test(); diminuto_unittest_local = diminuto_unittest_errors; ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-atomicapply.c" "@" "55" ": " "TEST: %d tests=%d " "\n", (0), diminuto_unittest_number) : ((void)0)); diminuto_unittest_flush(); } while (0); do {;
        do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(library_settor(application_functor, 1) == 0); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-atomicapply.c" "@" "57" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "library_settor(application_functor, 1) == 0") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
        do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(library_settor(application_functor, 2) == 1); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-atomicapply.c" "@" "58" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "library_settor(application_functor, 2) == 1") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
        do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(library_settor(application_functor, -3) == 3); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-atomicapply.c" "@" "59" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "library_settor(application_functor, -3) == 3") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
        } while (0); do { int diminuto_unittest_number; int diminuto_unittest_count; int diminuto_unittest_added; diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_errors; diminuto_unittest_added = diminuto_unittest_count - diminuto_unittest_local; ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-atomicapply.c" "@" "61" ": " "STATUS: tests=%d errors=%d %s " "\n", diminuto_unittest_number, diminuto_unittest_count, (diminuto_unittest_added == 0) ? "SUCCESS." : "FAILURE!") : ((void)0)); diminuto_unittest_flush(); } while (0); } while (0);;
    }
    do { int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_errors; ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-atomicapply.c" "@" "64" ": " "EXIT: tests=%d errors=%d %s " "\n", diminuto_unittest_number, diminuto_unittest_count, (diminuto_unittest_count == 0) ? "SUCCESS." : "FAILURE!") : ((void)0)); diminuto_unittest_flush(); exit(diminuto_unittest_count > DIMINUTO_UNITTEST_MAXIMUM ? DIMINUTO_UNITTEST_MAXIMUM : diminuto_unittest_count); } while (0);
}

canonical_original_code:
int main()
{
    do { diminuto_unittest_setlogmask(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-atomicapply.c" "@" "52" ": " "SETLOGMASK: logmask=0x%x\n", diminuto_log_mask) : ((void)0)); } while (0);
    {
        do { int diminuto_unittest_local = 0; do { int diminuto_unittest_number = 0; diminuto_unittest_number = diminuto_unittest_test(); diminuto_unittest_local = diminuto_unittest_errors; ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-atomicapply.c" "@" "55" ": " "TEST: %d tests=%d " "\n", (0), diminuto_unittest_number) : ((void)0)); diminuto_unittest_flush(); } while (0); do {;
        do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(library_settor(application_functor, 1) == 0); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-atomicapply.c" "@" "57" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "library_settor(application_functor, 1) == 0") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
        do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(library_settor(application_functor, 2) == 1); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-atomicapply.c" "@" "58" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "library_settor(application_functor, 2) == 1") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
        do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(library_settor(application_functor, -3) == 3); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-atomicapply.c" "@" "59" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "library_settor(application_functor, -3) == 3") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
        } while (0); do { int diminuto_unittest_number; int diminuto_unittest_count; int diminuto_unittest_added; diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_errors; diminuto_unittest_added = diminuto_unittest_count - diminuto_unittest_local; ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-atomicapply.c" "@" "61" ": " "STATUS: tests=%d errors=%d %s " "\n", diminuto_unittest_number, diminuto_unittest_count, (diminuto_unittest_added == 0) ? "SUCCESS." : "FAILURE!") : ((void)0)); diminuto_unittest_flush(); } while (0); } while (0);;
    }
    do { int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_errors; ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-atomicapply.c" "@" "64" ": " "EXIT: tests=%d errors=%d %s " "\n", diminuto_unittest_number, diminuto_unittest_count, (diminuto_unittest_count == 0) ? "SUCCESS." : "FAILURE!") : ((void)0)); diminuto_unittest_flush(); exit(diminuto_unittest_count > DIMINUTO_UNITTEST_MAXIMUM ? DIMINUTO_UNITTEST_MAXIMUM : diminuto_unittest_count); } while (0);
}


decompiled_code:
// attributes: thunk
__int64 diminuto_ipc6_close()
{
return diminuto_ipc_close();
}

canonical_decompiled_code:
__int64 func8()
{
return diminuto_ipc_close();
}

original_code:
static inline int diminuto_ipc6_close(int fd) {
    return diminuto_ipc_close(fd);
}

variable_types: fd int


decompiled_code:
int *__fastcall diminuto_assert_f(int a1, const char *a2, const char *a3, unsigned int a4, unsigned int a5, int a6)
{
__int64 v8; // rbp
int *result; // rax
int v10; // er10
int *v11; // rbx
char *v12; // rax
int *v13; // [rsp-10h] [rbp-58h]
int v15; // [rsp+8h] [rbp-40h]
int v16; // [rsp+8h] [rbp-40h]
int v17; // [rsp+Ch] [rbp-3Ch]

v8 = a5;
result = _errno_location();
v10 = *result;
v11 = result;
if ( !a1 )
{
v12 = (char *)&LC0;
if ( (_DWORD)v8 )
{
v17 = v10;
v12 = strerror(v8);
v10 = v17;
if ( a6 )
goto LABEL_4;
}
else if ( a6 )
{
LABEL_4:
v15 = v10;
diminuto_log_log(3LL, "%s@%d: diminuto_%s(%s) FAILED! %d=\"%s\"\n", a3, a4, "assert", a2, v8, v12);
diminuto_stacktrace();
diminuto_core_enable();
result = (int *)diminuto_core_fatal();
v10 = v15;
goto LABEL_5;
}
v16 = v10;
diminuto_log_log(4LL, "%s@%d: diminuto_%s(%s) FAILED! %d=\"%s\"\n", a3, a4, "expect", a2, v8, v12);
result = v13;
v10 = v16;
}
LABEL_5:
*v11 = v10;
return result;
}

canonical_decompiled_code:
int *__fastcall func0(int a1, const char *a2, const char *a3, unsigned int a4, unsigned int a5, int a6)
{
__int64 v8; // rbp
int *result; // rax
int v10; // er10
int *v11; // rbx
char *v12; // rax
int *v13; // [rsp-10h] [rbp-58h]
int v15; // [rsp+8h] [rbp-40h]
int v16; // [rsp+8h] [rbp-40h]
int v17; // [rsp+Ch] [rbp-3Ch]

v8 = a5;
result = _errno_location();
v10 = *result;
v11 = result;
if ( !a1 )
{
v12 = (char *)&LC0;
if ( (_DWORD)v8 )
{
v17 = v10;
v12 = strerror(v8);
v10 = v17;
if ( a6 )
goto LABEL_4;
}
else if ( a6 )
{
LABEL_4:
v15 = v10;
diminuto_log_log(3LL, "%s@%d: diminuto_%s(%s) FAILED! %d=\"%s\"\n", a3, a4, "assert", a2, v8, v12);
diminuto_stacktrace();
diminuto_core_enable();
result = (int *)diminuto_core_fatal();
v10 = v15;
goto LABEL_5;
}
v16 = v10;
diminuto_log_log(4LL, "%s@%d: diminuto_%s(%s) FAILED! %d=\"%s\"\n", a3, a4, "expect", a2, v8, v12);
result = v13;
v10 = v16;
}
LABEL_5:
*v11 = v10;
return result;
}

original_code:
void diminuto_assert_f(int condition, const char * string, const char * file, int line, int error, int fatal)
{
    int save = (*__errno_location ());
    if (!condition) {
        diminuto_log_log(fatal ? DIMINUTO_LOG_PRIORITY_ERROR : DIMINUTO_LOG_PRIORITY_WARNING, "%s@%d: diminuto_%s(%s) FAILED! %d=\"%s\"\n", file, line, fatal ? "assert" : "expect", string, error, (error != 0) ? strerror(error) : "");
        if (fatal) {
            (void)diminuto_stacktrace();
            (void)diminuto_core_enable();
            diminuto_core_fatal();
        }
    }
    (*__errno_location ()) = save;
}

canonical_original_code:
void diminuto_assert_f(int condition, char *string, char *file, int line, int error, int fatal)
{
    int save = (*__errno_location ());
    if (!condition) {
        diminuto_log_log(fatal ? DIMINUTO_LOG_PRIORITY_ERROR : DIMINUTO_LOG_PRIORITY_WARNING, "%s@%d: diminuto_%s(%s) FAILED! %d=\"%s\"\n", file, line, fatal ? "assert" : "expect", string, error, (error != 0) ? strerror(error) : "");
        if (fatal) {
            (void)diminuto_stacktrace();
            (void)diminuto_core_enable();
            diminuto_core_fatal();
        }
    }
    (*__errno_location ()) = save;
}

variable_types: condition int

variable_types:
string
char *

variable_types:
file
char *

variable_types: line int

variable_types: error int

variable_types: fatal int

variable_types: save int

return_type: void


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

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

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


decompiled_code:
unsigned __int64 __fastcall diminuto_timer_window(__int64 a1)
{
unsigned __int64 result; // rax
unsigned __int64 v2; // rdi

result = diminuto_timer_frequency();
v2 = 2 * a1;
if ( result < v2 )
result = v2;
return result;
}

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

result = func7();
v2 = 2 * a1;
if ( result < v2 )
result = v2;
return result;
}

original_code:
static inline diminuto_ticks_t diminuto_timer_window(diminuto_ticks_t interval)
{
    diminuto_ticks_t minimum = 0;
    diminuto_ticks_t result = 0;
    minimum = diminuto_frequency();
    result = interval * 2;
    if (result < minimum) {
        result = minimum;
    }
    return result;
}

canonical_original_code:
static inline unsigned long diminuto_timer_window(unsigned long interval)
{
    unsigned long minimum = 0;
    unsigned long result = 0;
    minimum = diminuto_frequency();
    result = interval * 2;
    if (result < minimum) {
        result = minimum;
    }
    return result;
}

variable_types:
interval
unsigned long

variable_types:
minimum
unsigned long

variable_types:
result
unsigned long

return_type: unsigned long


decompiled_code:
__int64 diminuto_timer_oneshot()
{
return diminuto_timer_setitimer();
}

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

original_code:
static inline diminuto_sticks_t diminuto_timer_oneshot(diminuto_ticks_t ticks)
{
    return diminuto_timer_setitimer(ticks, 0);
}

canonical_original_code:
static inline long diminuto_timer_oneshot(unsigned long ticks)
{
    return diminuto_timer_setitimer(ticks, 0);
}

variable_types:
ticks
unsigned long


decompiled_code:
__int64 __fastcall diminuto_mux_wait(__int64 a1, __int64 a2)
{
return diminuto_mux_wait_generic(a1, a2, a1 + 1616);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return diminuto_mux_wait_generic(a1, a2, a1 + 1616);
}

original_code:
static inline int diminuto_mux_wait(diminuto_mux_t * muxp, diminuto_sticks_t timeout)
{
    return diminuto_mux_wait_generic(muxp, timeout, &(muxp->mask));
}

canonical_original_code:
static inline int diminuto_mux_wait(struct DiminutoMux *muxp, long timeout)
{
    return diminuto_mux_wait_generic(muxp, timeout, &(muxp->mask));
}

variable_types: struct DiminutoMux { struct fd_set { long fds_bits[-1]; } read_or_accept; struct fd_set urgent_or_interrupt; struct DiminutoMuxSet { struct fd_set active; struct fd_set ready; int min; int max; int next; } read; struct DiminutoMuxSet write; struct DiminutoMuxSet accept; struct DiminutoMuxSet urgent; struct DiminutoMuxSet interrupt; struct __sigset_t { unsigned long __val[-1]; } mask; } *

variable_types: timeout long

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


original_code:
static inline int avago_apds9301_rawtolux(uint16_t raw0, uint16_t raw1, double * luxp)
{
    double lux = 0.0;
    double chan0 = 0.0;
    double chan1 = 0.0;
    double ratio = 0.0;
    chan0 = raw0;
    chan1 = raw1;
    ratio = chan1 / chan0;
    if (ratio <= 0.50) {
        lux = (0.0304 * chan0) - (0.062 * chan1 * pow(ratio, 1.4));
    } else if ((0.50 < ratio) && (ratio <= 0.61)) {
        lux = (0.0224 * chan0) - (0.031 * chan1);
    } else if ((0.61 < ratio) && (ratio <= 0.80)) {
        lux = (0.0128 * chan0) - (0.0153 * chan1);
    } else if ((0.80 < ratio) && (ratio <= 1.30)) {
        lux = (0.00146 * chan0) - (0.00112 * chan1);
    } else {
        lux = 0.0;
    }
    *luxp = lux;
    return 0;
}

canonical_original_code:
static inline int avago_apds9301_rawtolux(unsigned short raw0, unsigned short raw1, double *luxp)
{
    double lux = 0.0;
    double chan0 = 0.0;
    double chan1 = 0.0;
    double ratio = 0.0;
    chan0 = raw0;
    chan1 = raw1;
    ratio = chan1 / chan0;
    if (ratio <= 0.50) {
        lux = (0.0304 * chan0) - (0.062 * chan1 * pow(ratio, 1.4));
    } else if ((0.50 < ratio) && (ratio <= 0.61)) {
        lux = (0.0224 * chan0) - (0.031 * chan1);
    } else if ((0.61 < ratio) && (ratio <= 0.80)) {
        lux = (0.0128 * chan0) - (0.0153 * chan1);
    } else if ((0.80 < ratio) && (ratio <= 1.30)) {
        lux = (0.00146 * chan0) - (0.00112 * chan1);
    } else {
        lux = 0.0;
    }
    *luxp = lux;
    return 0;
}

variable_types:
luxp
double *

variable_types: lux double

variable_types: ratio double


decompiled_code:
__int64 diminuto_timer_periodic()
{
return diminuto_timer_setitimer();
}

original_code:
static inline diminuto_sticks_t diminuto_timer_periodic(diminuto_ticks_t ticks)
{
    return diminuto_timer_setitimer(ticks, !0);
}

canonical_original_code:
static inline long diminuto_timer_periodic(unsigned long ticks)
{
    return diminuto_timer_setitimer(ticks, !0);
}


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


decompiled_code:
// attributes: thunk
__int64 diminuto_throttle_now()
{
return diminuto_time_elapsed();
}

canonical_decompiled_code:
__int64 func1()
{
return diminuto_time_elapsed();
}

original_code:
static inline diminuto_sticks_t diminuto_throttle_now(void)
{
    return diminuto_time_elapsed();
}

canonical_original_code:
static inline long diminuto_throttle_now()
{
    return diminuto_time_elapsed();
}


decompiled_code:
// attributes: thunk
__int64 diminuto_shaper_now()
{
return diminuto_throttle_now();
}

canonical_decompiled_code:
__int64 func2()
{
return func1();
}

original_code:
static inline diminuto_sticks_t diminuto_shaper_now(void)
{
    return diminuto_throttle_now();
}

canonical_original_code:
static inline long diminuto_shaper_now()
{
    return diminuto_throttle_now();
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r15
char *v4; // rax
char *v5; // rdx
int v6; // er12
__int64 v7; // r13
unsigned __int16 v8; // bp
__int64 v10; // rbx
__int64 v11; // r14
unsigned __int16 v12; // r15
unsigned __int16 v13; // bx
unsigned __int16 i; // r13
double v15; // [rsp+0h] [rbp-68h]
double v16; // [rsp+8h] [rbp-60h]
unsigned __int16 v17; // [rsp+10h] [rbp-58h]
unsigned __int16 v18; // [rsp+12h] [rbp-56h]
int v19; // [rsp+14h] [rbp-54h]
const char *v20; // [rsp+18h] [rbp-50h]
char *endptr; // [rsp+20h] [rbp-48h] BYREF
__int64 v22[8]; // [rsp+28h] [rbp-40h] BYREF

v3 = *argv;
endptr = 0LL;
v22[0] = 0LL;
v4 = strrchr(v3, 47);
v5 = v4 + 1;
if ( !v4 )
v5 = (char *)v3;
v20 = v5;
if ( argc != 2 )
{
if ( argc > 2 )
{
v6 = strcmp(argv[1], "-d");
v7 = (v6 == 0) + 1LL;
v8 = strtoul(argv[v7], &endptr, 0);
if ( endptr && !*endptr && (LOWORD(v10) = strtoul(argv[v7 + 1], &endptr, 0), endptr) && !*endptr )
{
v10 = (unsigned __int16)v10;
if ( (int)avago_apds9301_rawtolux(v8, (unsigned __int16)v10, v22) < 0 )
__assert_fail("rc >= 0", "fun/luxcompute.c", 0x70u, "main");
if ( !v6 )
fprintf(stderr, "%s: 0x%x %d 0x%x %d %f\n", v20, v8, v8, (unsigned int)v10, v10, *(double *)v22);
printf("%0.2lf\n", *(double *)v22);
v19 = 0;
}
else
{
*__errno_location() = 22;
diminuto_log_perror();
v19 = 1;
}
return v19;
}
LABEL_24:
fprintf(stderr, "usage: %s [ -p | [ -d ] CHAN0 CHAN1 ]\n", v20);
return 1;
}
v19 = strcmp(argv[1], "-p");
if ( v19 )
goto LABEL_24;
v11 = 0LL;
v12 = 0;
v13 = 0;
v18 = 0;
v17 = 0;
v16 = 2.225073858507201e-308;
v15 = 1.797693134862316e308;
while ( 1 )
{
for ( i = 0; ; ++i )
{
if ( (int)avago_apds9301_rawtolux(v13, i, v22) < 0 )
__assert_fail("rc >= 0", "fun/luxcompute.c", 0x4Au, "main");
if ( v15 > *(double *)v22 )
{
v18 = i;
v17 = v13;
v15 = *(double *)v22;
}
if ( *(double *)v22 > v16 )
{
v16 = *(double *)v22;
v11 = i;
v12 = v13;
}
if ( i == 0xFFFF )
break;
}
if ( v13 == 0xFFFF )
break;
++v13;
}
fprintf(stderr, "%s: 0x%x 0x%x %f 0x%x 0x%x %f\n", v20, v17, v18, v15, v12, v11, v16);
return v19;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r15
char *v4; // rax
char *v5; // rdx
int v6; // er12
__int64 v7; // r13
unsigned __int16 v8; // bp
__int64 v10; // rbx
__int64 v11; // r14
unsigned __int16 v12; // r15
unsigned __int16 v13; // bx
unsigned __int16 i; // r13
double v15; // [rsp+0h] [rbp-68h]
double v16; // [rsp+8h] [rbp-60h]
unsigned __int16 v17; // [rsp+10h] [rbp-58h]
unsigned __int16 v18; // [rsp+12h] [rbp-56h]
int v19; // [rsp+14h] [rbp-54h]
const char *v20; // [rsp+18h] [rbp-50h]
char *endptr; // [rsp+20h] [rbp-48h] BYREF
__int64 v22[8]; // [rsp+28h] [rbp-40h] BYREF

v3 = *argv;
endptr = 0LL;
v22[0] = 0LL;
v4 = strrchr(v3, 47);
v5 = v4 + 1;
if ( !v4 )
v5 = (char *)v3;
v20 = v5;
if ( argc != 2 )
{
if ( argc > 2 )
{
v6 = strcmp(argv[1], "-d");
v7 = (v6 == 0) + 1LL;
v8 = strtoul(argv[v7], &endptr, 0);
if ( endptr && !*endptr && (LOWORD(v10) = strtoul(argv[v7 + 1], &endptr, 0), endptr) && !*endptr )
{
v10 = (unsigned __int16)v10;
if ( (int)func7(v8, (unsigned __int16)v10, v22) < 0 )
__assert_fail("rc >= 0", "fun/luxcompute.c", 0x70u, "main");
if ( !v6 )
fprintf(stderr, "%s: 0x%x %d 0x%x %d %f\n", v20, v8, v8, (unsigned int)v10, v10, *(double *)v22);
printf("%0.2lf\n", *(double *)v22);
v19 = 0;
}
else
{
*__errno_location() = 22;
diminuto_log_perror();
v19 = 1;
}
return v19;
}
LABEL_24:
fprintf(stderr, "usage: %s [ -p | [ -d ] CHAN0 CHAN1 ]\n", v20);
return 1;
}
v19 = strcmp(argv[1], "-p");
if ( v19 )
goto LABEL_24;
v11 = 0LL;
v12 = 0;
v13 = 0;
v18 = 0;
v17 = 0;
v16 = 2.225073858507201e-308;
v15 = 1.797693134862316e308;
while ( 1 )
{
for ( i = 0; ; ++i )
{
if ( (int)func7(v13, i, v22) < 0 )
__assert_fail("rc >= 0", "fun/luxcompute.c", 0x4Au, "main");
if ( v15 > *(double *)v22 )
{
v18 = i;
v17 = v13;
v15 = *(double *)v22;
}
if ( *(double *)v22 > v16 )
{
v16 = *(double *)v22;
v11 = i;
v12 = v13;
}
if ( i == 0xFFFF )
break;
}
if ( v13 == 0xFFFF )
break;
++v13;
}
fprintf(stderr, "%s: 0x%x 0x%x %f 0x%x 0x%x %f\n", v20, v17, v18, v15, v12, v11, v16);
return v19;
}

original_code:
int main(int argc, char ** argv)
{
    int rc = -1;
    int offset = 0;
    int debug = 0;
    const char * program = (const char *)0;
    char * endptr = (char *)0;
    uint16_t raw0 = 0;
    uint16_t raw1 = 0;
    double lux = 0.0;
    program = ((program = strrchr(argv[0], '/')) == (char *)0) ? argv[0] : program + 1;
    if (argc != 2) {
    } else if (strncmp(argv[1], "-p", sizeof("-p")) != 0) {
    } else {
        uint16_t minraw0 = 0;
        uint16_t maxraw0 = 0;
        uint16_t minraw1 = 0;
        uint16_t maxraw1 = 0;
        double min = ((double)1.79769313486231570814527423731704357e+308L);
        double max = ((double)2.22507385850720138309023271733240406e-308L);
        raw0 = 0x0000;
        while (!0) {
            raw1 = 0x0000;
            while (!0) {
                rc = avago_apds9301_rawtolux(raw0, raw1, &lux);
                ((void) sizeof ((rc >= 0) ? 1 : 0), __extension__ ({ if (rc >= 0) ; else __assert_fail ("rc >= 0", "fun/luxcompute.c", 74, __extension__ __PRETTY_FUNCTION__); }));
                if (lux < min) { min = lux; minraw0 = raw0; minraw1 = raw1; }
                if (lux > max) { max = lux; maxraw0 = raw0; maxraw1 = raw1; }
                if (raw1 >= 0xffff) { break; }
                raw1 += 1;
            }
            if (raw0 >= 0xffff) { break; }
            raw0 += 1;
        }
        fprintf(stderr, "%s: 0x%x 0x%x %f 0x%x 0x%x %f\n", program, minraw0, minraw1, min, maxraw0, maxraw1, max);
        return 0;
    }
    if (argc < 3) {
        fprintf(stderr, "usage: %s [ -p | [ -d ] CHAN0 CHAN1 ]\n", program);
        return 1;
    }
    if (strncmp(argv[1], "-d", sizeof("-d")) == 0) {
        debug = !0;
        offset = 1;
    }
    raw0 = strtoul(argv[offset + 1], &endptr, 0);
    if ((endptr == (char *)0) || (*endptr != '\0')) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("fun/luxcompute.c", 100, argv[offset + 1]);
        return 1;
    }
    raw1 = strtoul(argv[offset + 2], &endptr, 0);
    if ((endptr == (char *)0) || (*endptr != '\0')) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("fun/luxcompute.c", 107, argv[offset + 2]);
        return 1;
    }
    rc = avago_apds9301_rawtolux(raw0, raw1, &lux);
    ((void) sizeof ((rc >= 0) ? 1 : 0), __extension__ ({ if (rc >= 0) ; else __assert_fail ("rc >= 0", "fun/luxcompute.c", 112, __extension__ __PRETTY_FUNCTION__); }));
    if (debug) {
        fprintf(stderr, "%s: 0x%x %d 0x%x %d %f\n", program, raw0, raw0, raw1, raw1, lux);
    }
    printf("%0.2lf\n", lux);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    int rc = -1;
    int offset = 0;
    int debug = 0;
    char *program = (const char *)0;
    char *endptr = (char *)0;
    unsigned short raw0 = 0;
    unsigned short raw1 = 0;
    double lux = 0.0;
    program = ((program = strrchr(argv[0], '/')) == (char *)0) ? argv[0] : program + 1;
    if (argc != 2) {
    } else if (strncmp(argv[1], "-p", sizeof("-p")) != 0) {
    } else {
        unsigned short minraw0 = 0;
        unsigned short maxraw0 = 0;
        unsigned short minraw1 = 0;
        unsigned short maxraw1 = 0;
        double min = ((double)1.79769313486231570814527423731704357e+308L);
        double max = ((double)2.22507385850720138309023271733240406e-308L);
        raw0 = 0x0000;
        while (!0) {
            raw1 = 0x0000;
            while (!0) {
                rc = avago_apds9301_rawtolux(raw0, raw1, &lux);
                ((void) sizeof ((rc >= 0) ? 1 : 0), __extension__ ({ if (rc >= 0) ; else __assert_fail ("rc >= 0", "fun/luxcompute.c", 74, __extension__ __PRETTY_FUNCTION__); }));
                if (lux < min) { min = lux; minraw0 = raw0; minraw1 = raw1; }
                if (lux > max) { max = lux; maxraw0 = raw0; maxraw1 = raw1; }
                if (raw1 >= 0xffff) { break; }
                raw1 += 1;
            }
            if (raw0 >= 0xffff) { break; }
            raw0 += 1;
        }
        fprintf(stderr, "%s: 0x%x 0x%x %f 0x%x 0x%x %f\n", program, minraw0, minraw1, min, maxraw0, maxraw1, max);
        return 0;
    }
    if (argc < 3) {
        fprintf(stderr, "usage: %s [ -p | [ -d ] CHAN0 CHAN1 ]\n", program);
        return 1;
    }
    if (strncmp(argv[1], "-d", sizeof("-d")) == 0) {
        debug = !0;
        offset = 1;
    }
    raw0 = strtoul(argv[offset + 1], &endptr, 0);
    if ((endptr == (char *)0) || (*endptr != '\0')) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("fun/luxcompute.c", 100, argv[offset + 1]);
        return 1;
    }
    raw1 = strtoul(argv[offset + 2], &endptr, 0);
    if ((endptr == (char *)0) || (*endptr != '\0')) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("fun/luxcompute.c", 107, argv[offset + 2]);
        return 1;
    }
    rc = avago_apds9301_rawtolux(raw0, raw1, &lux);
    ((void) sizeof ((rc >= 0) ? 1 : 0), __extension__ ({ if (rc >= 0) ; else __assert_fail ("rc >= 0", "fun/luxcompute.c", 112, __extension__ __PRETTY_FUNCTION__); }));
    if (debug) {
        fprintf(stderr, "%s: 0x%x %d 0x%x %d %f\n", program, raw0, raw0, raw1, raw1, lux);
    }
    printf("%0.2lf\n", lux);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: rc int

variable_types: offset int

variable_types: debug int

variable_types:
program
char *

variable_types:
endptr
char *

variable_types: min double

variable_types: max double


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

v2 = diminuto_frequency();
if ( v2 < a2 )
{
a1 /= a2 / v2;
return a1;
}
if ( v2 <= a2 )
return a1;
return v2 / a2 * a1;
}

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

v2 = func0();
if ( v2 < a2 )
{
a1 /= a2 / v2;
return a1;
}
if ( v2 <= a2 )
return a1;
return v2 / a2 * a1;
}

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

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

variable_types: units long

variable_types: hertz long


decompiled_code:
__int64 diminuto_reaper_reap()
{
return diminuto_reaper_reap_generic();
}

canonical_decompiled_code:
__int64 func8()
{
return diminuto_reaper_reap_generic();
}

original_code:
static inline pid_t diminuto_reaper_reap(int * statusp) {
    return diminuto_reaper_reap_generic(-1, statusp, 1);
}

canonical_original_code:
static inline int diminuto_reaper_reap(int *statusp) {
    return diminuto_reaper_reap_generic(-1, statusp, 1);
}

variable_types:
statusp
int *


decompiled_code:
// attributes: thunk
__int64 __fastcall diminuto_frequency_ticks2wholeseconds(__int64 a1)
{
return diminuto_frequency_ticks2units_constprop_0(a1);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return func8(a1);
}

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

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

variable_types: ticks long


decompiled_code:
__int64 __fastcall diminuto_memory_alignment(__int64 a1, __int64 a2)
{
return -a2 & (a2 + a1 - 1);
}

original_code:
static inline size_t diminuto_memory_alignment(size_t size, size_t alignment)
{
    --alignment;
    return (size + alignment) & (~alignment);
}

canonical_original_code:
static inline unsigned long diminuto_memory_alignment(unsigned long size, unsigned long alignment)
{
    --alignment;
    return (size + alignment) & (~alignment);
}

variable_types:
size
unsigned long

variable_types:
alignment
unsigned long