decompiled_code:
__int64 diminuto_number()
{
return diminuto_number_unsigned();
}

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

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

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

variable_types:
s
char *

variable_types:
p
unsigned long *


control

repo: coverclock/com-diag-diminuto

decompiled_code:
__int64 __fastcall control(int a1, unsigned __int64 a2)
{
int v2; // ebx

if ( a1 < 0 )
{
v2 = -1;
}
else
{
v2 = ioctl(a1, a2);
if ( v2 < 0 )
perror("ioctl");
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, unsigned __int64 a2)
{
int v2; // ebx

if ( a1 < 0 )
{
v2 = -1;
}
else
{
v2 = ioctl(a1, a2);
if ( v2 < 0 )
perror("ioctl");
}
return (unsigned int)v2;
}

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

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

variable_types: fd int

variable_types:
request
unsigned long

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

variable_types: rc int

return_type: int

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


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

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

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

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

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

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

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

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

return_type: void

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
__int64 diminuto_unittest_test()
{
unsigned int v0; // ebx
__pthread_unwind_buf_t v2; // [rsp+0h] [rbp-88h] BYREF

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

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // ebx
__pthread_unwind_buf_t v2; // [rsp+0h] [rbp-88h] BYREF

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

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

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

variable_types: tests int

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

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


decompiled_code:
__int64 diminuto_unittest_error()
{
unsigned int v0; // ebx
__pthread_unwind_buf_t v2; // [rsp+0h] [rbp-88h] BYREF

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

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // ebx
__pthread_unwind_buf_t v2; // [rsp+0h] [rbp-88h] BYREF

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

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

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

variable_types: errors int


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

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

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

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

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

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


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

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

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

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

variable_types: signum int

variable_types: mysignaled int

variable_types: MAXIMUM int


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

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

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

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

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

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

variable_types: pid int


decompiled_code:
__int64 diminuto_reaper_check()
{
unsigned int v1; // [rsp+Ch] [rbp-17Ch]
int v2; // [rsp+1Ch] [rbp-16Ch] BYREF
struct __jmp_buf_tag env; // [rsp+20h] [rbp-168h] BYREF
char v4[136]; // [rsp+100h] [rbp-88h] BYREF

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

canonical_decompiled_code:
__int64 func2()
{
unsigned int v1; // [rsp+Ch] [rbp-17Ch]
int v2; // [rsp+1Ch] [rbp-16Ch] BYREF
struct __jmp_buf_tag env; // [rsp+20h] [rbp-168h] BYREF
char v4[136]; // [rsp+100h] [rbp-88h] BYREF

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

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

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

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


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

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

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

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

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

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

variable_types: pids int

variable_types:
statusp
int *

variable_types: flag int

variable_types: status int


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

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

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

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

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

variable_types: restart int

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

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

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


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

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

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

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

variable_types:
file
char *


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

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

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

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

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

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

variable_types: rc int


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

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

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

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

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

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

variable_types: fd int


decompiled_code:
__int64 __fastcall diminuto_lock_postlock_generic(char *a1, unsigned int a2)
{
return diminuto_lock_f(a1, "-post-XXXXXX", a2, 2u);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1, unsigned int a2)
{
return func0(a1, "-post-XXXXXX", a2, 2u);
}

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

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


decompiled_code:
__int64 __fastcall diminuto_lock_postlock(char *a1)
{
signed int v1; // eax

v1 = getpid();
if ( v1 >= 0 )
return diminuto_lock_postlock_generic(a1, v1);
diminuto_log_perror("src/diminuto_lock.c", 171LL, "diminuto_lock_postlock: getpid");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1)
{
signed int v1; // eax

v1 = getpid();
if ( v1 >= 0 )
return func4(a1, v1);
diminuto_log_perror("src/diminuto_lock.c", 171LL, "diminuto_lock_postlock: getpid");
return 0xFFFFFFFFLL;
}

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

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


decompiled_code:
__int64 __fastcall diminuto_lock_unlock(const char *a1)
{
int v1; // edx
__int64 result; // rax
int *v3; // rdx

v1 = unlink(a1);
result = 0LL;
if ( v1 < 0 )
{
v3 = _errno_location();
result = 0xFFFFFFFFLL;
if ( *v3 != 2 )
{
diminuto_log_perror("src/diminuto_lock.c", 188LL, "diminuto_lock_unlock: unlink");
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1)
{
int v1; // edx
__int64 result; // rax
int *v3; // rdx

v1 = unlink(a1);
result = 0LL;
if ( v1 < 0 )
{
v3 = _errno_location();
result = 0xFFFFFFFFLL;
if ( *v3 != 2 )
{
diminuto_log_perror("src/diminuto_lock.c", 188LL, "diminuto_lock_unlock: unlink");
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int diminuto_lock_unlock(const char * file)
{
    int rc = 0;
    if (unlink(file) >= 0) {
    } else if ((*__errno_location ()) == 2) {
        rc = -1;
    } else {
        diminuto_log_perror("src/diminuto_lock.c", 188, "diminuto_lock_unlock: unlink");
        rc = -1;
    }
    return rc;
}

canonical_original_code:
int diminuto_lock_unlock(char *file)
{
    int rc = 0;
    if (unlink(file) >= 0) {
    } else if ((*__errno_location ()) == 2) {
        rc = -1;
    } else {
        diminuto_log_perror("src/diminuto_lock.c", 188, "diminuto_lock_unlock: unlink");
        rc = -1;
    }
    return rc;
}


decompiled_code:
__int64 __fastcall diminuto_lock_file_generic(char *a1, unsigned int a2)
{
return diminuto_lock_f(a1, "-file-XXXXXX", a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1, unsigned int a2)
{
return func0(a1, "-file-XXXXXX", a2, 0);
}

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

canonical_original_code:
int diminuto_lock_file_generic(char *file, int pid)
{
    return diminuto_lock_f(file, "-file-XXXXXX", pid, 0);
}


decompiled_code:
__int64 __fastcall diminuto_lock_file(char *a1)
{
signed int v1; // eax

v1 = getpid();
if ( v1 >= 0 )
return diminuto_lock_file_generic(a1, v1);
diminuto_log_perror("src/diminuto_lock.c", 237LL, "diminuto_lock_file: getpid");
return 0xFFFFFFFFLL;
}

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

v1 = getpid();
if ( v1 >= 0 )
return func8(a1, v1);
diminuto_log_perror("src/diminuto_lock.c", 237LL, "diminuto_lock_file: getpid");
return 0xFFFFFFFFLL;
}

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

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


decompiled_code:
__int64 __fastcall diminuto_kermit_tochar(int a1)
{
return (unsigned int)(a1 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)(a1 + 32);
}

original_code:
static inline unsigned char diminuto_kermit_tochar(uint16_t bb) {
    return (bb + ' ');
}

canonical_original_code:
static inline unsigned char diminuto_kermit_tochar(unsigned short bb) {
    return (bb + ' ');
}

variable_types:
bb
unsigned short

return_type: unsigned char


decompiled_code:
__int64 __fastcall diminuto_kermit_unchar(unsigned __int8 a1)
{
return (unsigned int)a1 - 32;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 a1)
{
return (unsigned int)a1 - 32;
}

original_code:
static inline uint16_t diminuto_kermit_unchar(unsigned char pp) {
    return (pp - ' ');
}

canonical_original_code:
static inline unsigned short diminuto_kermit_unchar(unsigned char pp) {
    return (pp - ' ');
}

variable_types:
pp
unsigned char

return_type: unsigned short


decompiled_code:
__int64 __fastcall diminuto_kermit_crc2chars(unsigned __int16 a1, _BYTE *a2, _BYTE *a3, _BYTE *a4)
{
__int64 result; // rax

*a2 = diminuto_kermit_tochar(a1 >> 12);
*a3 = diminuto_kermit_tochar((a1 >> 6) & 0x3F);
result = diminuto_kermit_tochar(a1 & 0x3F);
*a4 = result;
return result;
}

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

*a2 = func0(a1 >> 12);
*a3 = func0((a1 >> 6) & 0x3F);
result = func0(a1 & 0x3F);
*a4 = result;
return result;
}

original_code:
void diminuto_kermit_crc2chars(uint16_t crc, unsigned char * ap, unsigned char * bp, unsigned char * cp)
{
    *ap = diminuto_kermit_tochar((crc >> 12) & 0x0f);
    *bp = diminuto_kermit_tochar((crc >> 6) & 0x3f);
    *cp = diminuto_kermit_tochar((crc >> 0) & 0x3f);
}

canonical_original_code:
void diminuto_kermit_crc2chars(unsigned short crc, unsigned char *ap, unsigned char *bp, unsigned char *cp)
{
    *ap = diminuto_kermit_tochar((crc >> 12) & 0x0f);
    *bp = diminuto_kermit_tochar((crc >> 6) & 0x3f);
    *cp = diminuto_kermit_tochar((crc >> 0) & 0x3f);
}

variable_types:
crc
unsigned short

variable_types:
ap
unsigned char *

variable_types:
bp
unsigned char *

variable_types:
cp
unsigned char *


decompiled_code:
__int64 __fastcall diminuto_kermit_chars2crc(unsigned __int8 a1, unsigned __int8 a2, unsigned __int8 a3)
{
int v4; // ebp
int v5; // ebx

v4 = diminuto_kermit_unchar(a1);
v5 = diminuto_kermit_unchar(a2);
return (unsigned int)diminuto_kermit_unchar(a3) | (v4 << 12) | (v5 << 6);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 a1, unsigned __int8 a2, unsigned __int8 a3)
{
int v4; // ebp
int v5; // ebx

v4 = func1(a1);
v5 = func1(a2);
return (unsigned int)func1(a3) | (v4 << 12) | (v5 << 6);
}

original_code:
uint16_t diminuto_kermit_chars2crc(unsigned char aa, unsigned char bb, unsigned char cc)
{
    uint16_t crc = 0;
    crc = diminuto_kermit_unchar(aa) << 12;
    crc |= diminuto_kermit_unchar(bb) << 6;
    crc |= diminuto_kermit_unchar(cc) << 0;
    return crc;
}

canonical_original_code:
unsigned short diminuto_kermit_chars2crc(unsigned char aa, unsigned char bb, unsigned char cc)
{
    unsigned short crc = 0;
    crc = diminuto_kermit_unchar(aa) << 12;
    crc |= diminuto_kermit_unchar(bb) << 6;
    crc |= diminuto_kermit_unchar(cc) << 0;
    return crc;
}

variable_types:
aa
unsigned char

variable_types:
bb
unsigned char

variable_types:
cc
unsigned char


decompiled_code:
__int64 __fastcall diminuto_kermit_16(_BYTE *a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
_BYTE *v4; // rsi
unsigned int v5; // edx

result = a3;
if ( a2 )
{
v4 = &a1[a2];
do
{
HIWORD(v5) = WORD1(result);
LOWORD(v5) = TABLE[(unsigned __int8)(*a1++ ^ result)] ^ BYTE1(result);
result = v5;
}
while ( v4 != a1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
_BYTE *v4; // rsi
unsigned int v5; // edx

result = a3;
if ( a2 )
{
v4 = &a1[a2];
do
{
HIWORD(v5) = WORD1(result);
LOWORD(v5) = TABLE[(unsigned __int8)(*a1++ ^ result)] ^ BYTE1(result);
result = v5;
}
while ( v4 != a1 );
}
return result;
}

original_code:
uint16_t diminuto_kermit_16(const void * buffer, size_t length, uint16_t crc)
{
    uint8_t * here = (uint8_t *)buffer;
    while (length--) {
        crc = (crc >> 8) ^ TABLE[(crc ^ (*(here++))) & 0xff];
    }
    return crc;
}

canonical_original_code:
unsigned short diminuto_kermit_16(void *buffer, unsigned long length, unsigned short crc)
{
    unsigned char *here = (uint8_t *)buffer;
    while (length--) {
        crc = (crc >> 8) ^ TABLE[(crc ^ (*(here++))) & 0xff];
    }
    return crc;
}

variable_types:
buffer
void *

variable_types:
length
unsigned long

variable_types:
here
unsigned char *


decompiled_code:
size_t __fastcall diminuto_escape_trim(char *dest, char *src, unsigned __int64 a3, size_t a4)
{
size_t v5; // rdx
char *v6; // rax
unsigned __int64 v7; // rbx
size_t v8; // r14

v5 = strnlen(src, a4);
v6 = &src[v5 - 1];
v7 = v5;
if ( v5 )
{
while ( *v6 == 32 )
{
--v6;
if ( !--v7 )
goto LABEL_4;
}
if ( v5 != v7 && v7 && *v6 == 92 && (v7 <= 1 || *(v6 - 1) != 92) )
++v7;
}
LABEL_4:
v8 = a3;
if ( v7 <= a3 )
v8 = v7;
strncpy(dest, src, v8);
if ( a3 )
{
if ( v8 >= a3 )
{
if ( v7 >= a3 )
dest[--v8] = 0;
}
else
{
dest[v8] = 0;
}
}
return v8;
}

canonical_decompiled_code:
size_t __fastcall func1(char *dest, char *src, unsigned __int64 a3, size_t a4)
{
size_t v5; // rdx
char *v6; // rax
unsigned __int64 v7; // rbx
size_t v8; // r14

v5 = strnlen(src, a4);
v6 = &src[v5 - 1];
v7 = v5;
if ( v5 )
{
while ( *v6 == 32 )
{
--v6;
if ( !--v7 )
goto LABEL_4;
}
if ( v5 != v7 && v7 && *v6 == 92 && (v7 <= 1 || *(v6 - 1) != 92) )
++v7;
}
LABEL_4:
v8 = a3;
if ( v7 <= a3 )
v8 = v7;
strncpy(dest, src, v8);
if ( a3 )
{
if ( v8 >= a3 )
{
if ( v7 >= a3 )
dest[--v8] = 0;
}
else
{
dest[v8] = 0;
}
}
return v8;
}

original_code:
size_t diminuto_escape_trim(char * to, const char * from, size_t tsize, size_t fsize)
{
    const char * ff;
    size_t size;
    fsize = strnlen(from, fsize);
    size = fsize;
    ff = from + fsize - 1;
    while ((0 < size) && (' ' == *ff)) {
        --ff;
        --size;
    }
    if (0 == size) {
    } else if (fsize == size) {
    } else if ((*ff != '\\') || ((size > 1) && (*(ff - 1) == '\\'))) {
    } else {
        ++ff;
        ++size;
    }
    if (tsize < size) {
        size = tsize;
    }
    strncpy(to, from, size);
    if (tsize == 0) {
    } else if (tsize > size) {
        to[size] = '\0';
    } else if (tsize == size) {
        to[--size] = '\0';
    } else {
    }
    return size;
}

canonical_original_code:
unsigned long diminuto_escape_trim(char *to, char *from, unsigned long tsize, unsigned long fsize)
{
    char *ff;
    unsigned long size;
    fsize = strnlen(from, fsize);
    size = fsize;
    ff = from + fsize - 1;
    while ((0 < size) && (' ' == *ff)) {
        --ff;
        --size;
    }
    if (0 == size) {
    } else if (fsize == size) {
    } else if ((*ff != '\\') || ((size > 1) && (*(ff - 1) == '\\'))) {
    } else {
        ++ff;
        ++size;
    }
    if (tsize < size) {
        size = tsize;
    }
    strncpy(to, from, size);
    if (tsize == 0) {
    } else if (tsize > size) {
        to[size] = '\0';
    } else if (tsize == size) {
        to[--size] = '\0';
    } else {
    }
    return size;
}

variable_types:
to
char *

variable_types:
from
char *

variable_types:
tsize
unsigned long

variable_types:
fsize
unsigned long

variable_types:
ff
char *

variable_types:
size
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall diminuto_escape_printable(char *a1)
{
char v2; // bl

while ( 1 )
{
v2 = *a1;
if ( !*a1 )
break;
++a1;
if ( ((*_ctype_b_loc())[v2] & 0x4000) == 0 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1)
{
char v2; // bl

while ( 1 )
{
v2 = *a1;
if ( !*a1 )
break;
++a1;
if ( ((*_ctype_b_loc())[v2] & 0x4000) == 0 )
return 0LL;
}
return 1LL;
}

original_code:
int diminuto_escape_printable(const char * from)
{
    int printable = !0;
    while (*from != '\0') {
        if (!((*__ctype_b_loc ())[(int) ((*(from++)))] & (unsigned short int) _ISprint)) {
            printable = 0;
            break;
        }
    }
    return printable;
}

canonical_original_code:
int diminuto_escape_printable(char *from)
{
    int printable = !0;
    while (*from != '\0') {
        if (!((*__ctype_b_loc ())[(int) ((*(from++)))] & (unsigned short) _ISprint)) {
            printable = 0;
            break;
        }
    }
    return printable;
}

variable_types: printable int


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

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

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

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

variable_types: signum int

variable_types: mysignaled int

variable_types: MAXIMUM int


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

if ( kill(a1, 15) < 0 )
{
diminuto_log_perror("src/diminuto_terminator.c", 35LL, "diminuto_terminator_signal: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_terminator_debug[0];
if ( diminuto_terminator_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_terminator_signal: SIGTERM");
result = 0LL;
}
}
}
return result;
}

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

if ( kill(a1, 15) < 0 )
{
diminuto_log_perror("src/diminuto_terminator.c", 35LL, "diminuto_terminator_signal: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_terminator_debug[0];
if ( diminuto_terminator_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_terminator_signal: SIGTERM");
result = 0LL;
}
}
}
return result;
}

original_code:
int diminuto_terminator_signal(pid_t pid)
{
    int rc = 0;
    if (kill(pid, 15) < 0) {
        diminuto_log_perror("src/diminuto_terminator.c", 35, "diminuto_terminator_signal: kill");
        rc = -1;
    } else if (diminuto_terminator_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_terminator_signal: SIGTERM") : ((void)0));
    } else {
    }
    return rc;
}

canonical_original_code:
int diminuto_terminator_signal(int pid)
{
    int rc = 0;
    if (kill(pid, 15) < 0) {
        diminuto_log_perror("src/diminuto_terminator.c", 35, "diminuto_terminator_signal: kill");
        rc = -1;
    } else if (diminuto_terminator_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_terminator_signal: SIGTERM") : ((void)0));
    } else {
    }
    return rc;
}

variable_types: pid int

variable_types: rc int


decompiled_code:
__int64 diminuto_terminator_check()
{
unsigned int v1; // [rsp+Ch] [rbp-17Ch]
int v2; // [rsp+1Ch] [rbp-16Ch] BYREF
struct __jmp_buf_tag env; // [rsp+20h] [rbp-168h] BYREF
char v4[136]; // [rsp+100h] [rbp-88h] BYREF

v1 = -1;
if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
{
v1 = -1;
LABEL_11:
if ( diminuto_terminator_debug[0] && (diminuto_log_mask & 1) != 0 )
diminuto_log_log(7LL, "diminuto_terminator_check: SIGTERM");
return v1;
}
if ( _sigsetjmp(&env, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env);
}
_pthread_register_cancel((__pthread_unwind_buf_t *)&env);
v2 = 15;
if ( !(unsigned int)diminuto_uninterruptiblesection_block(&v2, 1LL, v4) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&env.__saved_mask.__val[5], 0) )
{
diminuto_uninterruptiblesection_cleanup(v4);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
}
_pthread_register_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
v1 = signaled;
signaled = 0;
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
diminuto_uninterruptiblesection_cleanup(v4);
}
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env);
diminuto_criticalsection_cleanup(&mutex);
if ( v1 )
goto LABEL_11;
return v1;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v1; // [rsp+Ch] [rbp-17Ch]
int v2; // [rsp+1Ch] [rbp-16Ch] BYREF
struct __jmp_buf_tag env; // [rsp+20h] [rbp-168h] BYREF
char v4[136]; // [rsp+100h] [rbp-88h] BYREF

v1 = -1;
if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
{
v1 = -1;
LABEL_11:
if ( diminuto_terminator_debug[0] && (diminuto_log_mask & 1) != 0 )
diminuto_log_log(7LL, "diminuto_terminator_check: SIGTERM");
return v1;
}
if ( _sigsetjmp(&env, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env);
}
_pthread_register_cancel((__pthread_unwind_buf_t *)&env);
v2 = 15;
if ( !(unsigned int)diminuto_uninterruptiblesection_block(&v2, 1LL, v4) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&env.__saved_mask.__val[5], 0) )
{
diminuto_uninterruptiblesection_cleanup(v4);
_pthread_unwind_next((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
}
_pthread_register_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
v1 = signaled;
signaled = 0;
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env.__saved_mask.__val[5]);
diminuto_uninterruptiblesection_cleanup(v4);
}
_pthread_unregister_cancel((__pthread_unwind_buf_t *)&env);
diminuto_criticalsection_cleanup(&mutex);
if ( v1 )
goto LABEL_11;
return v1;
}

original_code:
int diminuto_terminator_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[] = { 15 }; 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_terminator_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_terminator_check: SIGTERM") : ((void)0));
    } else {
    }
    return mysignaled;
}

canonical_original_code:
int diminuto_terminator_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[] = { 15 }; 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_terminator_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_terminator_check: SIGTERM") : ((void)0));
    } else {
    }
    return mysignaled;
}

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


decompiled_code:
__int64 __fastcall diminuto_terminator_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_terminator_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(15, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_terminator.c", 95LL, "diminuto_terminator_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_terminator_debug[0];
if ( diminuto_terminator_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_terminator_install: SIGTERM");
result = 0LL;
}
}
}
signaled = 0;
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_terminator_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(15, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_terminator.c", 95LL, "diminuto_terminator_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_terminator_debug[0];
if ( diminuto_terminator_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_terminator_install: SIGTERM");
result = 0LL;
}
}
}
signaled = 0;
return result;
}

original_code:
int diminuto_terminator_install(int restart)
{
    int rc = 0;
    struct sigaction terminator = { 0 };
    terminator.__sigaction_handler.sa_handler = diminuto_terminator_handler;
    terminator.sa_flags = restart ? 0x10000000 : 0;
    if (sigaction(15, &terminator, (struct sigaction *)0) < 0) {
        diminuto_log_perror("src/diminuto_terminator.c", 95, "diminuto_terminator_install: sigaction");
        rc = -1;
    } else if (diminuto_terminator_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_terminator_install: SIGTERM") : ((void)0));
    } else {
    }
    signaled = 0;
    return rc;
}

variable_types: restart int

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


reroot

decompiled_code:
__int64 __fastcall reroot(_QWORD *a1, _QWORD *a2, __int64 a3)
{
_QWORD *v3; // rax

v3 = a1;
do
{
v3[2] = a3;
if ( v3 == a2 )
break;
v3 = (_QWORD *)*v3;
}
while ( a1 != v3 );
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, _QWORD *a2, __int64 a3)
{
_QWORD *v3; // rax

v3 = a1;
do
{
v3[2] = a3;
if ( v3 == a2 )
break;
v3 = (_QWORD *)*v3;
}
while ( a1 != v3 );
return a3;
}

original_code:
static diminuto_list_t * reroot(
    diminuto_list_t * firstp,
    diminuto_list_t * lastp,
    diminuto_list_t * rootp
) {
    diminuto_list_t * nextp = firstp;
    do {
        nextp->root = rootp;
        if (nextp == lastp) {
            break;
        }
        nextp = nextp->next;
    } while (nextp != firstp);
    return rootp;
}

canonical_original_code:
static struct DiminutoList *reroot(struct DiminutoList *firstp, struct DiminutoList *lastp, struct DiminutoList *rootp) {
    struct DiminutoList *nextp = firstp;
    do {
        nextp->root = rootp;
        if (nextp == lastp) {
            break;
        }
        nextp = nextp->next;
    } while (nextp != firstp);
    return rootp;
}

variable_types:
firstp
struct DiminutoList *

variable_types:
lastp
struct DiminutoList *

variable_types:
rootp
struct DiminutoList *

variable_types: struct DiminutoList { struct DiminutoList *next; struct DiminutoList *prev; struct DiminutoList *root; void *data; } *


decompiled_code:
__int64 __fastcall diminuto_list_reroot(__int64 a1)
{
return reroot((_QWORD *)a1, *(_QWORD **)(a1 + 8), a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return func1((_QWORD *)a1, *(_QWORD **)(a1 + 8), a1);
}

original_code:
diminuto_list_t * diminuto_list_reroot(
    diminuto_list_t * nodep
) {
    return reroot(nodep, nodep->prev, nodep);
}

canonical_original_code:
struct DiminutoList *diminuto_list_reroot(struct DiminutoList *nodep) {
    return reroot(nodep, nodep->prev, nodep);
}

variable_types:
nodep
struct DiminutoList *

return_type: struct DiminutoList { struct DiminutoList *next; struct DiminutoList *prev; struct DiminutoList *root; void *data; } *


original_code:
diminuto_list_t * diminuto_list_splice(
    diminuto_list_t * top,
    diminuto_list_t * fromp
) {
    if (fromp->root == top->root) {
    } else if (fromp == fromp->next) {
        diminuto_list_insert(top, fromp);
    } else {
        reroot(fromp, fromp->prev, top->root);
        fromp->prev->next = top->next;
        top->next->prev = fromp->prev;
        top->next = fromp;
        fromp->prev = top;
    }
    return fromp;
}

canonical_original_code:
struct DiminutoList *diminuto_list_splice(struct DiminutoList *top, struct DiminutoList *fromp) {
    if (fromp->root == top->root) {
    } else if (fromp == fromp->next) {
        diminuto_list_insert(top, fromp);
    } else {
        reroot(fromp, fromp->prev, top->root);
        fromp->prev->next = top->next;
        top->next->prev = fromp->prev;
        top->next = fromp;
        fromp->prev = top;
    }
    return fromp;
}

variable_types:
top
struct DiminutoList *

variable_types:
fromp
struct DiminutoList *

user_defined_types: struct DiminutoList { struct DiminutoList *next; struct DiminutoList *prev; struct DiminutoList *root; void *data; }


decompiled_code:
__int64 __fastcall diminuto_list_log(const void **a1)
{
__int64 result; // rax

if ( a1 )
result = diminuto_log_emit(
"diminuto_list_t@%p[%zu]: { next=%p prev=%p root=%p data=%p }\n",
a1,
0x20uLL,
*a1,
a1[1],
a1[2],
a1[3]);
else
result = diminuto_log_emit("diminuto_list_t@%p[%zu]\n", 0LL, 0x20uLL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const void **a1)
{
__int64 result; // rax

if ( a1 )
result = diminuto_log_emit(
"diminuto_list_t@%p[%zu]: { next=%p prev=%p root=%p data=%p }\n",
a1,
0x20uLL,
*a1,
a1[1],
a1[2],
a1[3]);
else
result = diminuto_log_emit("diminuto_list_t@%p[%zu]\n", 0LL, 0x20uLL);
return result;
}

original_code:
void diminuto_list_log(
    const diminuto_list_t * nodep
) {
    if (nodep) {
        diminuto_log_emit("diminuto_list_t@%p[%zu]: { next=%p prev=%p root=%p data=%p }\n", nodep, sizeof(*nodep), nodep->next, nodep->prev, nodep->root, nodep->data);
    } else {
        diminuto_log_emit("diminuto_list_t@%p[%zu]\n", nodep, sizeof(*nodep));
    }
}

canonical_original_code:
void diminuto_list_log(struct DiminutoList *nodep) {
    if (nodep) {
        diminuto_log_emit("diminuto_list_t@%p[%zu]: { next=%p prev=%p root=%p data=%p }\n", nodep, sizeof(*nodep), nodep->next, nodep->prev, nodep->root, nodep->data);
    } else {
        diminuto_log_emit("diminuto_list_t@%p[%zu]\n", nodep, sizeof(*nodep));
    }
}


decompiled_code:
const void **__fastcall diminuto_list_audit(__int64 a1, const void *a2)
{
const void **v2; // rbx
void **v3; // rdx
const void **v4; // r12
__int64 v5; // rcx
__int64 v6; // rbp

v2 = (const void **)a1;
v4 = (const void **)diminuto_list_root(a1);
v5 = diminuto_list_audit_limit;
v6 = a1;
while ( 1 )
{
if ( v2[2] != v4 || *((const void ***)*v2 + 1) != v2 || (v3 = (void **)v2[1], *v3 != v2) )
{
diminuto_log_emit("diminuto_list_audit: next FAILED!\n", a2, v3, v5);
diminuto_list_log(v2);
return v2;
}
if ( *(const void ***)(v6 + 16) != v4
|| (v3 = *(void ***)(v6 + 8), *v3 != (void *)v6)
|| (a2 = *(const void **)v6, *(_QWORD *)(*(_QWORD *)v6 + 8LL) != v6) )
{
diminuto_log_emit("diminuto_list_audit: prev FAILED!\n", a2, v3, v5);
diminuto_list_log((const void **)v6);
return (const void **)v6;
}
v5 = (unsigned int)(v5 - 1);
if ( (int)v5 <= 0 )
break;
if ( *v2 == v3 )
return 0LL;
v6 = *(_QWORD *)(v6 + 8);
v2 = (const void **)*v2;
}
diminuto_log_emit("diminuto_list_audit: limit FAILED!\n");
diminuto_list_log(v4);
return v4;
}

canonical_decompiled_code:
const void **__fastcall func5(__int64 a1, const void *a2)
{
const void **v2; // rbx
void **v3; // rdx
const void **v4; // r12
__int64 v5; // rcx
__int64 v6; // rbp

v2 = (const void **)a1;
v4 = (const void **)func0(a1);
v5 = diminuto_list_audit_limit;
v6 = a1;
while ( 1 )
{
if ( v2[2] != v4 || *((const void ***)*v2 + 1) != v2 || (v3 = (void **)v2[1], *v3 != v2) )
{
diminuto_log_emit("diminuto_list_audit: next FAILED!\n", a2, v3, v5);
func4(v2);
return v2;
}
if ( *(const void ***)(v6 + 16) != v4
|| (v3 = *(void ***)(v6 + 8), *v3 != (void *)v6)
|| (a2 = *(const void **)v6, *(_QWORD *)(*(_QWORD *)v6 + 8LL) != v6) )
{
diminuto_log_emit("diminuto_list_audit: prev FAILED!\n", a2, v3, v5);
func4((const void **)v6);
return (const void **)v6;
}
v5 = (unsigned int)(v5 - 1);
if ( (int)v5 <= 0 )
break;
if ( *v2 == v3 )
return 0LL;
v6 = *(_QWORD *)(v6 + 8);
v2 = (const void **)*v2;
}
diminuto_log_emit("diminuto_list_audit: limit FAILED!\n");
func4(v4);
return v4;
}

original_code:
const diminuto_list_t * diminuto_list_audit(
    const diminuto_list_t * nodep
) {
    const diminuto_list_t * rootp = diminuto_list_root(nodep);
    const diminuto_list_t * nextp = nodep;
    const diminuto_list_t * prevp = nodep;
    int limit = diminuto_list_audit_limit;
    while (!0) {
        if ((nextp->root != rootp) || (nextp->next->prev != nextp) || (nextp->prev->next != nextp)) {
            diminuto_log_emit("diminuto_list_audit: next FAILED!\n");
            diminuto_list_log(nextp);
            nodep = nextp;
            break;
        } else if ((prevp->root != rootp) || (prevp->prev->next != prevp) || (prevp->next->prev != prevp)) {
            diminuto_log_emit("diminuto_list_audit: prev FAILED!\n");
            diminuto_list_log(prevp);
            nodep = prevp;
            break;
        } else if ((--limit) <= 0) {
            diminuto_log_emit("diminuto_list_audit: limit FAILED!\n");
            diminuto_list_log(rootp);
            nodep = rootp;
            break;
        } else if ((nextp = nextp->next) == (prevp = prevp->prev)) {
            nodep = ((diminuto_list_t *)0);
            break;
        } else {
            continue;
        }
    }
    return nodep;
}

canonical_original_code:
struct DiminutoList *diminuto_list_audit(struct DiminutoList *nodep) {
    struct DiminutoList *rootp = diminuto_list_root(nodep);
    struct DiminutoList *nextp = nodep;
    struct DiminutoList *prevp = nodep;
    int limit = diminuto_list_audit_limit;
    while (!0) {
        if ((nextp->root != rootp) || (nextp->next->prev != nextp) || (nextp->prev->next != nextp)) {
            diminuto_log_emit("diminuto_list_audit: next FAILED!\n");
            diminuto_list_log(nextp);
            nodep = nextp;
            break;
        } else if ((prevp->root != rootp) || (prevp->prev->next != prevp) || (prevp->next->prev != prevp)) {
            diminuto_log_emit("diminuto_list_audit: prev FAILED!\n");
            diminuto_list_log(prevp);
            nodep = prevp;
            break;
        } else if ((--limit) <= 0) {
            diminuto_log_emit("diminuto_list_audit: limit FAILED!\n");
            diminuto_list_log(rootp);
            nodep = rootp;
            break;
        } else if ((nextp = nextp->next) == (prevp = prevp->prev)) {
            nodep = ((struct DiminutoList *)0);
            break;
        } else {
            continue;
        }
    }
    return nodep;
}

variable_types: limit int


decompiled_code:
char *__fastcall diminuto_number_unsigned(const char *a1, unsigned __int64 *a2)
{
unsigned __int64 v2; // rax
char *v3; // rbx
char *endptr; // [rsp+8h] [rbp-10h] BYREF

v2 = strtoull(a1, &endptr, 0);
if ( a2 )
*a2 = v2;
v3 = endptr;
if ( *endptr )
*_errno_location() = 22;
return v3;
}

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

v2 = strtoull(a1, &endptr, 0);
if ( a2 )
*a2 = v2;
v3 = endptr;
if ( *endptr )
*_errno_location() = 22;
return v3;
}

original_code:
const char * diminuto_number_unsigned(const char * s, diminuto_unsigned_t * p)
{
    diminuto_unsigned_t n;
    char * e;
    n = strtoull(s, &e, 0);
    if (p != (diminuto_unsigned_t *)0) { *p = n; }
    if (*e != '\0') { (*__errno_location ()) = 22; }
    return e;
}

canonical_original_code:
char *diminuto_number_unsigned(char *s, unsigned long *p)
{
    unsigned long n;
    char *e;
    n = strtoull(s, &e, 0);
    if (p != (unsigned long *)0) { *p = n; }
    if (*e != '\0') { (*__errno_location ()) = 22; }
    return e;
}

variable_types:
s
char *

variable_types:
p
unsigned long *

variable_types:
n
unsigned long

variable_types:
e
char *

return_type: char *


decompiled_code:
char *__fastcall diminuto_number_signed(const char *a1, __int64 *a2)
{
__int64 v2; // rax
char *v3; // rbx
char *endptr; // [rsp+8h] [rbp-10h] BYREF

v2 = strtoll(a1, &endptr, 0);
if ( a2 )
*a2 = v2;
v3 = endptr;
if ( *endptr )
*_errno_location() = 22;
return v3;
}

canonical_decompiled_code:
char *__fastcall func1(const char *a1, __int64 *a2)
{
__int64 v2; // rax
char *v3; // rbx
char *endptr; // [rsp+8h] [rbp-10h] BYREF

v2 = strtoll(a1, &endptr, 0);
if ( a2 )
*a2 = v2;
v3 = endptr;
if ( *endptr )
*_errno_location() = 22;
return v3;
}

original_code:
const char * diminuto_number_signed(const char * s, diminuto_signed_t * p)
{
    diminuto_signed_t n;
    char * e;
    n = strtoll(s, &e, 0);
    if (p != (diminuto_signed_t *)0) { *p = n; }
    if (*e != '\0') { (*__errno_location ()) = 22; }
    return e;
}

canonical_original_code:
char *diminuto_number_signed(char *s, long *p)
{
    long n;
    char *e;
    n = strtoll(s, &e, 0);
    if (p != (long *)0) { *p = n; }
    if (*e != '\0') { (*__errno_location ()) = 22; }
    return e;
}

variable_types:
p
long *

variable_types: n long


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

result = a1;
*(_QWORD *)(a1 + 24) = a2;
return result;
}

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

result = a1;
*(_QWORD *)(a1 + 24) = a2;
return result;
}

original_code:
static inline diminuto_list_t * diminuto_list_dataset(diminuto_list_t * nodep, void * datap) {
    nodep->data = datap;
    return nodep;
}

canonical_original_code:
static inline struct DiminutoList *diminuto_list_dataset(struct DiminutoList *nodep, void *datap) {
    nodep->data = datap;
    return nodep;
}

variable_types:
datap
void *


decompiled_code:
__int64 __fastcall diminuto_list_datainit(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rax

v2 = diminuto_list_init(a1);
return diminuto_list_dataset((__int64)v2, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rax

v2 = diminuto_list_init(a1);
return func4((__int64)v2, a2);
}

original_code:
static inline diminuto_list_t * diminuto_list_datainit(diminuto_list_t * nodep, void * datap) {
    return diminuto_list_dataset(diminuto_list_init(nodep), datap);
}

canonical_original_code:
static inline struct DiminutoList *diminuto_list_datainit(struct DiminutoList *nodep, void *datap) {
    return diminuto_list_dataset(diminuto_list_init(nodep), datap);
}


decompiled_code:
_BOOL8 __fastcall diminuto_list_isempty(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

original_code:
static inline int diminuto_list_isempty(const diminuto_list_t * nodep) {
    return (nodep == nodep->next);
}

canonical_original_code:
static inline int diminuto_list_isempty(struct DiminutoList *nodep) {
    return (nodep == nodep->next);
}


decompiled_code:
__int64 __fastcall diminuto_pool_init(_QWORD *a1, __int64 a2)
{
return diminuto_list_datainit(a1, (a2 + 39) & 0xFFFFFFFFFFFFFFF8LL);
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1, __int64 a2)
{
return func5(a1, (a2 + 39) & 0xFFFFFFFFFFFFFFF8LL);
}

original_code:
diminuto_pool_t * diminuto_pool_init(diminuto_pool_t * poolp, size_t size)
{
    uintptr_t allocation;
    allocation = (sizeof(diminuto_pool_object_t) + size + sizeof(((diminuto_pool_object_t *)0)->payload[0]) - 1) & ~(sizeof(((diminuto_pool_object_t *)0)->payload[0]) - 1);
    return diminuto_list_datainit(poolp, (void *)allocation);
}

canonical_original_code:
struct DiminutoList *diminuto_pool_init(struct DiminutoList *poolp, unsigned long size)
{
    unsigned long allocation;
    allocation = (sizeof(diminuto_pool_object_t) + size + sizeof(((struct DiminutoPoolObject *)0)->payload[0]) - 1) & ~(sizeof(((struct DiminutoPoolObject *)0)->payload[0]) - 1);
    return diminuto_list_datainit(poolp, (void *)allocation);
}

variable_types:
poolp
struct DiminutoList *

variable_types:
size
unsigned long

variable_types:
allocation
unsigned long

user_defined_types: struct DiminutoPoolObject { struct DiminutoList link; unsigned long payload[]; }


decompiled_code:
__int64 __fastcall diminuto_pool_free(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax

v1 = diminuto_list_data(a1 - 32);
v2 = diminuto_list_root(v1);
v3 = diminuto_list_prev(v2);
return diminuto_list_insert(v3, a1 - 32);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax

v1 = func3(a1 - 32);
v2 = func2(v1);
v3 = func1(v2);
return diminuto_list_insert(v3, a1 - 32);
}

original_code:
void diminuto_pool_free(void * pointer)
{
    diminuto_pool_object_t * nodep;
    diminuto_pool_t * poolp;
    nodep = ((diminuto_pool_object_t *)(((char *)(pointer)) - ((size_t)(((char *)&(((diminuto_pool_object_t *)0)->payload)) - ((char *)((diminuto_pool_object_t *)0))))));
    poolp = diminuto_list_root((diminuto_list_t *)diminuto_list_data(&nodep->link));
    diminuto_list_insert(diminuto_list_prev(poolp), &nodep->link);
}

canonical_original_code:
void diminuto_pool_free(void *pointer)
{
    struct DiminutoPoolObject *nodep;
    struct DiminutoList *poolp;
    nodep = ((struct DiminutoPoolObject *)(((char *)(pointer)) - ((unsigned long)(((char *)&(((struct DiminutoPoolObject *)0)->payload)) - ((char *)((struct DiminutoPoolObject *)0))))));
    poolp = diminuto_list_root((struct DiminutoList *)diminuto_list_data(&nodep->link));
    diminuto_list_insert(diminuto_list_prev(poolp), &nodep->link);
}

variable_types:
pointer
void *

variable_types: struct DiminutoPoolObject { struct DiminutoList { struct DiminutoList *next; struct DiminutoList *prev; struct DiminutoList *root; void *data; } link; unsigned long payload[]; } *


decompiled_code:
__int64 __fastcall renameat2(unsigned int a1, __int64 a2, unsigned int a3, __int64 a4, unsigned int a5)
{
return syscall(316LL, a1, a2, a3, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, __int64 a2, unsigned int a3, __int64 a4, unsigned int a5)
{
return syscall(316LL, a1, a2, a3, a4, a5);
}

original_code:
int renameat2(int olddirfd, const char * oldpath, int newdirfd, const char * newpath, unsigned int flags) {
    return syscall(316, olddirfd, oldpath, newdirfd, newpath, flags);
}

canonical_original_code:
int renameat2(int olddirfd, char *oldpath, int newdirfd, char *newpath, unsigned int flags) {
    return syscall(316, olddirfd, oldpath, newdirfd, newpath, flags);
}

variable_types: olddirfd int

variable_types:
oldpath
char *

variable_types: newdirfd int

variable_types:
newpath
char *

variable_types:
flags
unsigned int


decompiled_code:
__int64 __fastcall diminuto_absolute_int8_t_f(char a1)
{
return abs8(a1);
}

canonical_decompiled_code:
__int64 __fastcall func7(char a1)
{
return abs8(a1);
}

original_code: static inline int8_t diminuto_absolute_int8_t_f(int8_t value) { return (value < 0) ? -value : value; }

canonical_original_code: static inline char diminuto_absolute_int8_t_f(char value) { return (value < 0) ? -value : value; }

variable_types: value char

return_type: char


decompiled_code:
__int64 __fastcall diminuto_absolute_int16_t_f(__int16 a1)
{
return abs16(a1);
}

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

original_code: static inline int16_t diminuto_absolute_int16_t_f(int16_t value) { return (value < 0) ? -value : value; }

canonical_original_code: static inline short diminuto_absolute_int16_t_f(short value) { return (value < 0) ? -value : value; }

variable_types: value short

return_type: short


decompiled_code:
__int64 __fastcall diminuto_absolute_int32_t_f(int a1)
{
return abs32(a1);
}

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

original_code: static inline int32_t diminuto_absolute_int32_t_f(int32_t value) { return (value < 0) ? -value : value; }

canonical_original_code: static inline int diminuto_absolute_int32_t_f(int value) { return (value < 0) ? -value : value; }

variable_types: value int


decompiled_code:
unsigned __int64 __fastcall diminuto_absolute_int64_t_f(__int64 a1)
{
return abs64(a1);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func10(__int64 a1)
{
return abs64(a1);
}

original_code: static inline int64_t diminuto_absolute_int64_t_f(int64_t value) { return (value < 0) ? -value : value; }

canonical_original_code: static inline long diminuto_absolute_int64_t_f(long value) { return (value < 0) ? -value : value; }

variable_types: value long

return_type: long


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


decompiled_code:
__int64 __fastcall ti_ads1115_rawtovolts(__int16 a1, __int16 a2, double *a3)
{
unsigned __int16 v3; // ax
__int64 v4; // xmm1_8
__int64 result; // rax

v3 = a1 & 0xE00;
if ( (a1 & 0xE00) == 1024 )
{
v4 = LC5;
goto LABEL_11;
}
if ( (a1 & 0xE00u) <= 0x400 )
{
if ( !v3 )
{
v4 = LC4;
goto LABEL_11;
}
if ( v3 == 512 )
{
v4 = LC1;
goto LABEL_11;
}
result = 0xFFFFFFFFLL;
}
else
{
if ( v3 == 2048 )
{
v4 = LC2;
goto LABEL_11;
}
if ( v3 <= 0x800u )
{
v4 = LC0;
if ( v3 == 1536 )
goto LABEL_11;
result = 0xFFFFFFFFLL;
}
else
{
if ( v3 == 3072 )
{
v4 = LC3;
goto LABEL_11;
}
if ( (a1 & 0xA00) == 2560 )
{
v4 = LC3;
LABEL_11:
*a3 = (double)a2 * *(double *)&v4 / 32767.0;
return 0LL;
}
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 a1, __int16 a2, double *a3)
{
unsigned __int16 v3; // ax
__int64 v4; // xmm1_8
__int64 result; // rax

v3 = a1 & 0xE00;
if ( (a1 & 0xE00) == 1024 )
{
v4 = LC5;
goto LABEL_11;
}
if ( (a1 & 0xE00u) <= 0x400 )
{
if ( !v3 )
{
v4 = LC4;
goto LABEL_11;
}
if ( v3 == 512 )
{
v4 = LC1;
goto LABEL_11;
}
result = 0xFFFFFFFFLL;
}
else
{
if ( v3 == 2048 )
{
v4 = LC2;
goto LABEL_11;
}
if ( v3 <= 0x800u )
{
v4 = LC0;
if ( v3 == 1536 )
goto LABEL_11;
result = 0xFFFFFFFFLL;
}
else
{
if ( v3 == 3072 )
{
v4 = LC3;
goto LABEL_11;
}
if ( (a1 & 0xA00) == 2560 )
{
v4 = LC3;
LABEL_11:
*a3 = (double)a2 * *(double *)&v4 / 32767.0;
return 0LL;
}
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
static inline int ti_ads1115_rawtovolts(uint16_t config, int16_t raw, double * voltsp)
{
    int rc = -1;
    double pga = 0.0;
    switch (config & TI_ADS1115_CONFIG_PGA) {
    case TI_ADS1115_CONFIG_PGA_6_144V:
        pga = 6.144;
        break;
    case TI_ADS1115_CONFIG_PGA_4_096V:
        pga = 4.096;
        break;
    case TI_ADS1115_CONFIG_PGA_2_048V:
        pga = 2.048;
        break;
    case TI_ADS1115_CONFIG_PGA_1_024V:
        pga = 1.024;
        break;
    case TI_ADS1115_CONFIG_PGA_0_512V:
        pga = 0.512;
        break;
    case TI_ADS1115_CONFIG_PGA_0_256V:
    case TI_ADS1115_CONFIG_PGA_0_256BV:
    case TI_ADS1115_CONFIG_PGA_0_256CV:
        pga = 0.256;
        break;
    default:
        break;
    }
    if (pga > 0.0) {
        *voltsp = raw;
        *voltsp *= pga;
        *voltsp /= 32767.0;
        rc = 0;
    }
    return rc;
}

canonical_original_code:
static inline int ti_ads1115_rawtovolts(unsigned short config, short raw, double *voltsp)
{
    int rc = -1;
    double pga = 0.0;
    switch (config & TI_ADS1115_CONFIG_PGA) {
    case TI_ADS1115_CONFIG_PGA_6_144V:
        pga = 6.144;
        break;
    case TI_ADS1115_CONFIG_PGA_4_096V:
        pga = 4.096;
        break;
    case TI_ADS1115_CONFIG_PGA_2_048V:
        pga = 2.048;
        break;
    case TI_ADS1115_CONFIG_PGA_1_024V:
        pga = 1.024;
        break;
    case TI_ADS1115_CONFIG_PGA_0_512V:
        pga = 0.512;
        break;
    case TI_ADS1115_CONFIG_PGA_0_256V:
    case TI_ADS1115_CONFIG_PGA_0_256BV:
    case TI_ADS1115_CONFIG_PGA_0_256CV:
        pga = 0.256;
        break;
    default:
        break;
    }
    if (pga > 0.0) {
        *voltsp = raw;
        *voltsp *= pga;
        *voltsp /= 32767.0;
        rc = 0;
    }
    return rc;
}

variable_types:
config
unsigned short

variable_types: raw short

variable_types:
voltsp
double *

variable_types: rc int

variable_types: pga double


decompiled_code:
__int16 __fastcall ti_ads1115_dtoh(__int16 a1)
{
return _bswap_16(a1);
}

canonical_decompiled_code:
__int16 __fastcall func6(__int16 a1)
{
return func5(a1);
}

original_code:
static inline uint16_t ti_ads1115_dtoh(uint16_t datum)
{
    return ntohs(datum);
}

canonical_original_code:
static inline unsigned short ti_ads1115_dtoh(unsigned short datum)
{
    return ntohs(datum);
}

variable_types:
datum
unsigned short


original_code:
diminuto_controller_state_t * diminuto_controller_init(diminuto_controller_parameters_t * sp, diminuto_controller_state_t * dp)
{
    if (sp != (diminuto_controller_parameters_t *)0) {
        sp->windup = DIMINUTO_CONTROLLER_MAXIMUM_VALUE;
        sp->minimum = DIMINUTO_CONTROLLER_MINIMUM_OUTPUT;
        sp->maximum = DIMINUTO_CONTROLLER_MAXIMUM_OUTPUT;
        sp->lower = DIMINUTO_CONTROLLER_MINIMUM_OUTPUT;
        sp->upper = DIMINUTO_CONTROLLER_MAXIMUM_OUTPUT;
        sp->kp.numerator = 1;
        sp->kp.denominator = 1;
        sp->ki.numerator = 1;
        sp->ki.denominator = 1;
        sp->kd.numerator = 1;
        sp->kd.denominator = 1;
        sp->kc.numerator = 1;
        sp->kc.denominator = 1;
        sp->filter = !0;
    }
    if (dp != (diminuto_controller_state_t *)0) {
        dp->sample = 0;
        dp->proportional = 0;
        dp->integral = 0;
        dp->differential = 0;
        dp->total = 0;
        dp->delta = 0;
        dp->previous = 0;
        dp->initialized = 0;
    }
    return dp;
}

canonical_original_code:
struct DiminutoControllerState *diminuto_controller_init(struct DiminutoControllerParameters *sp, struct DiminutoControllerState *dp)
{
    if (sp != (struct DiminutoControllerParameters *)0) {
        sp->windup = DIMINUTO_CONTROLLER_MAXIMUM_VALUE;
        sp->minimum = DIMINUTO_CONTROLLER_MINIMUM_OUTPUT;
        sp->maximum = DIMINUTO_CONTROLLER_MAXIMUM_OUTPUT;
        sp->lower = DIMINUTO_CONTROLLER_MINIMUM_OUTPUT;
        sp->upper = DIMINUTO_CONTROLLER_MAXIMUM_OUTPUT;
        sp->kp.numerator = 1;
        sp->kp.denominator = 1;
        sp->ki.numerator = 1;
        sp->ki.denominator = 1;
        sp->kd.numerator = 1;
        sp->kd.denominator = 1;
        sp->kc.numerator = 1;
        sp->kc.denominator = 1;
        sp->filter = !0;
    }
    if (dp != (struct DiminutoControllerState *)0) {
        dp->sample = 0;
        dp->proportional = 0;
        dp->integral = 0;
        dp->differential = 0;
        dp->total = 0;
        dp->delta = 0;
        dp->previous = 0;
        dp->initialized = 0;
    }
    return dp;
}

variable_types: struct DiminutoControllerParameters { int windup; short minimum; short maximum; short lower; short upper; struct DiminutoControllerGain { short numerator; short denominator; } kp; struct DiminutoControllerGain ki; struct DiminutoControllerGain kd; struct DiminutoControllerGain kc; _Bool filter; } *

variable_types:
dp
struct DiminutoControllerState *

return_type: struct DiminutoControllerState { int sample; int proportional; int integral; int differential; int total; int delta; short previous; _Bool initialized; } *

user_defined_types: struct DiminutoControllerParameters { int windup; short minimum; short maximum; short lower; short upper; struct DiminutoControllerGain kp; struct DiminutoControllerGain ki; struct DiminutoControllerGain kd; struct DiminutoControllerGain kc; _Bool filter; }


original_code:
diminuto_controller_output_t diminuto_controller(const diminuto_controller_parameters_t * sp, diminuto_controller_state_t * dp, diminuto_controller_input_t target, diminuto_controller_input_t input, diminuto_controller_output_t output)
{
    if (!dp->initialized) {
        dp->integral = 0;
        dp->previous = input;
        dp->sample = input;
        dp->initialized = !0;
    }
    if (sp->filter) {
        dp->sample += input;
        dp->sample >>= 1;
    } else {
        dp->sample = input;
    }
    dp->proportional = target;
    dp->proportional -= dp->sample;
    dp->total = apply_gain(dp->proportional, &(sp->kp));
    dp->integral += apply_gain(dp->proportional, &(sp->ki));
    if (dp->integral > sp->windup) {
        dp->integral = sp->windup;
    } else if (dp->integral < -(sp->windup)) {
        dp->integral = -(sp->windup);
    } else {
    }
    dp->total += dp->integral;
    dp->differential = dp->sample - dp->previous;
    dp->total -= apply_gain(dp->differential, &(sp->kd));
    dp->previous = dp->sample;
    dp->delta = apply_gain(dp->total, &(sp->kc));
    output += dp->delta;
    if (output < sp->minimum) {
        output = sp->minimum;
    } else if (output > sp->maximum) {
        output = sp->maximum;
    } else {
    }
    if ((sp->minimum < output) && (output < sp->lower)) {
        output = sp->minimum;
    } else if ((sp->upper < output) && (output < sp->maximum)) {
        output = sp->maximum;
    } else {
    }
    return output;
}

canonical_original_code:
short diminuto_controller(struct DiminutoControllerParameters *sp, struct DiminutoControllerState *dp, short target, short input, short output)
{
    if (!dp->initialized) {
        dp->integral = 0;
        dp->previous = input;
        dp->sample = input;
        dp->initialized = !0;
    }
    if (sp->filter) {
        dp->sample += input;
        dp->sample >>= 1;
    } else {
        dp->sample = input;
    }
    dp->proportional = target;
    dp->proportional -= dp->sample;
    dp->total = apply_gain(dp->proportional, &(sp->kp));
    dp->integral += apply_gain(dp->proportional, &(sp->ki));
    if (dp->integral > sp->windup) {
        dp->integral = sp->windup;
    } else if (dp->integral < -(sp->windup)) {
        dp->integral = -(sp->windup);
    } else {
    }
    dp->total += dp->integral;
    dp->differential = dp->sample - dp->previous;
    dp->total -= apply_gain(dp->differential, &(sp->kd));
    dp->previous = dp->sample;
    dp->delta = apply_gain(dp->total, &(sp->kc));
    output += dp->delta;
    if (output < sp->minimum) {
        output = sp->minimum;
    } else if (output > sp->maximum) {
        output = sp->maximum;
    } else {
    }
    if ((sp->minimum < output) && (output < sp->lower)) {
        output = sp->minimum;
    } else if ((sp->upper < output) && (output < sp->maximum)) {
        output = sp->maximum;
    } else {
    }
    return output;
}

variable_types: struct DiminutoControllerState { int sample; int proportional; int integral; int differential; int total; int delta; short previous; _Bool initialized; } *

variable_types: target short

variable_types: input short

variable_types: output short

user_defined_types: struct DiminutoControllerGain { short numerator; short denominator; }


run

decompiled_code:
__int64 __fastcall run(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
int i; // ebx
_QWORD *v11; // rbp
__int64 v12; // rax
char *v13; // r13
__int64 *v14; // rbp
__int64 *v15; // rbx
__int64 v16; // [rsp+10h] [rbp-138C8h]
int v17; // [rsp+18h] [rbp-138C0h]
char v18; // [rsp+20h] [rbp-138B8h] BYREF
__int64 v19; // [rsp+70h] [rbp-13868h] BYREF
char v20; // [rsp+138A0h] [rbp-38h] BYREF

v16 = diminuto_time_process();
v17 = 0;
if ( a1 > 0 )
{
do
{
v13 = &v18;
do
{
v11 = v13;
for ( i = 3; i != 13; ++i )
{
v12 = diminuto_heap_malloc();
*v11 = v12;
if ( !v12 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
++v11;
}
v13 += 80;
}
while ( v13 != &v20 );
v14 = &v19;
do
{
v15 = v14 - 10;
do
{
diminuto_heap_free();
++v15;
}
while ( v15 != v14 );
v14 += 10;
}
while ( v14 != &a9 );
++v17;
}
while ( a1 != v17 );
}
return diminuto_time_process() - v16;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
int i; // ebx
_QWORD *v11; // rbp
__int64 v12; // rax
char *v13; // r13
__int64 *v14; // rbp
__int64 *v15; // rbx
__int64 v16; // [rsp+10h] [rbp-138C8h]
int v17; // [rsp+18h] [rbp-138C0h]
char v18; // [rsp+20h] [rbp-138B8h] BYREF
__int64 v19; // [rsp+70h] [rbp-13868h] BYREF
char v20; // [rsp+138A0h] [rbp-38h] BYREF

v16 = diminuto_time_process();
v17 = 0;
if ( a1 > 0 )
{
do
{
v13 = &v18;
do
{
v11 = v13;
for ( i = 3; i != 13; ++i )
{
v12 = diminuto_heap_malloc();
*v11 = v12;
if ( !v12 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
++v11;
}
v13 += 80;
}
while ( v13 != &v20 );
v14 = &v19;
do
{
v15 = v14 - 10;
do
{
diminuto_heap_free();
++v15;
}
while ( v15 != v14 );
v14 += 10;
}
while ( v14 != &a9 );
++v17;
}
while ( a1 != v17 );
}
return diminuto_time_process() - v16;
}

original_code:
static diminuto_ticks_t run(int limit)
{
    diminuto_ticks_t before;
    diminuto_ticks_t after;
    void * pointer[COUNT][10];
    int ii;
    int jj;
    int kk;
    before = diminuto_time_process();
    for (ii = 0; ii < limit; ++ii) {
        for (jj = 0; jj < COUNT; ++jj) {
            for (kk = 0; kk < 10; ++kk) {
                do { int diminuto_unittest_condition; diminuto_unittest_condition = !!((pointer[jj][kk] = diminuto_heap_malloc(1 << (kk + 3))) != (void *)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-buffer-perf.c" "@" "38" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "(pointer[jj][kk] = diminuto_heap_malloc(1 << (kk + 3))) != (void *)0") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
            }
        }
        for (jj = 0; jj < COUNT; ++jj) {
            for (kk = 0; kk < 10; ++kk) {
                diminuto_heap_free(pointer[jj][kk]);
            }
        }
    }
    after = diminuto_time_process();
    return after - before;
}

canonical_original_code:
static unsigned long run(int limit)
{
    unsigned long before;
    unsigned long after;
    void *pointer[-1][10];
    int ii;
    int jj;
    int kk;
    before = diminuto_time_process();
    for (ii = 0; ii < limit; ++ii) {
        for (jj = 0; jj < COUNT; ++jj) {
            for (kk = 0; kk < 10; ++kk) {
                do { int diminuto_unittest_condition; diminuto_unittest_condition = !!((pointer[jj][kk] = diminuto_heap_malloc(1 << (kk + 3))) != (void *)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-buffer-perf.c" "@" "38" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "(pointer[jj][kk] = diminuto_heap_malloc(1 << (kk + 3))) != (void *)0") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
            }
        }
        for (jj = 0; jj < COUNT; ++jj) {
            for (kk = 0; kk < 10; ++kk) {
                diminuto_heap_free(pointer[jj][kk]);
            }
        }
    }
    after = diminuto_time_process();
    return after - before;
}

variable_types: limit int

variable_types:
before
unsigned long

variable_types:
after
unsigned long

variable_types:
pointer
void *[-1][10]

variable_types: ii int

variable_types: jj int

variable_types: kk int


report

decompiled_code:
void *report()
{
void *result; // rax

diminuto_time_duration();
result = &diminuto_log_mask;
if ( (diminuto_log_mask & 2) != 0 )
result = (void *)diminuto_log_log();
return result;
}

canonical_decompiled_code:
void *func8()
{
void *result; // rax

diminuto_time_duration();
result = &diminuto_log_mask;
if ( (diminuto_log_mask & 2) != 0 )
result = (void *)diminuto_log_log();
return result;
}

original_code:
static void report(diminuto_ticks_t ticks)
{
    int day, hour, minute, second;
    diminuto_ticks_t fraction;
    diminuto_time_duration(ticks, &day, &hour, &minute, &second, &fraction);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-buffer-perf.c" "@" "59" ": " "CHECKPOINT: " "elapsed %lluticks %d/%2.2d:%2.2d:%2.2d.%9.9llu\n", (long long unsigned int)ticks, day, hour, minute, second, (long long unsigned int)fraction) : ((void)0));;
}

canonical_original_code:
static void report(unsigned long ticks)
{
    int day; int hour; int minute; int second;
    unsigned long fraction;
    diminuto_time_duration(ticks, &day, &hour, &minute, &second, &fraction);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-buffer-perf.c" "@" "59" ": " "CHECKPOINT: " "elapsed %lluticks %d/%2.2d:%2.2d:%2.2d.%9.9llu\n", (unsigned long long)ticks, day, hour, minute, second, (unsigned long long)fraction) : ((void)0));;
}

variable_types:
ticks
unsigned long

variable_types: day int

variable_types: hour int

variable_types: minute int

variable_types: second int

variable_types:
fraction
unsigned long