decompiled_code:
unsigned __int64 __fastcall diminuto_ping4_datagram_receive(int fd, __int64 a2, char *a3, _BYTE *a4, _WORD *a5, _WORD *a6, __int64 a7, __int64 a8)
{
__int64 v12; // rax
unsigned __int64 v13; // rbx
__int64 v15; // rdx
char *v16; // r15
__int64 v17; // rsi
char *v18; // rdi
__int16 v19; // ax
__int64 v20; // rdx
__int64 v22; // r8
__int64 v23; // r9
int v24; // eax
unsigned __int64 v25; // [rsp+8h] [rbp-C0h]
socklen_t addr_len; // [rsp+1Ch] [rbp-ACh] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-A8h] BYREF
char buf[80]; // [rsp+30h] [rbp-98h] BYREF
int v29; // [rsp+80h] [rbp-48h]

memset(buf, 0, sizeof(buf));
v29 = 0;
*(_QWORD *)&addr.sa_family = 0LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
addr_len = 16;
v12 = recvfrom(fd, buf, 0x54uLL, 0, &addr, &addr_len);
v13 = v12;
if ( v12 <= 0 )
{
if ( v12 )
{
v24 = *_errno_location();
if ( v24 != 4 && v24 != 11 )
diminuto_log_perror("src/diminuto_ping4.c", 189LL, "diminuto_ping4_datagram_recv: recvfrom");
}
}
else
{
if ( diminuto_ping4_debug )
diminuto_dump((__int64)stderr, (__int64)buf, v12);
diminuto_ipc4_identify(&addr, a2, 0LL);
v25 = v13;
if ( v13 > 0x1B )
{
v15 = (4 * buf[0]) & 0x3C;
v16 = &buf[v15];
v17 = v13 - v15;
v18 = &buf[v15];
v19 = diminuto_inet_checksum(&buf[v15], v13 - v15);
v13 = 0LL;
if ( !v19 )
{
if ( a3 )
*a3 = *v16;
if ( a4 )
*a4 = v16[1];
v13 = 0LL;
if ( !*v16 )
{
if ( a5 )
*a5 = *((_WORD *)v16 + 2);
if ( a6 )
*a6 = *((_WORD *)v16 + 3);
if ( a7 )
*(_BYTE *)a7 = buf[8];
v13 = 0LL;
if ( v25 > 0x53 )
{
if ( a8 )
*(_QWORD *)a8 = diminuto_time_clock(v18, v17, v20, a7, v22, v23) - *((_QWORD *)v16 + 1);
v13 = v25 - 20;
}
}
}
}
else
{
v13 = 0LL;
}
}
return v13;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(int fd, __int64 a2, char *a3, _BYTE *a4, _WORD *a5, _WORD *a6, __int64 a7, __int64 a8)
{
__int64 v12; // rax
unsigned __int64 v13; // rbx
__int64 v15; // rdx
char *v16; // r15
__int64 v17; // rsi
char *v18; // rdi
__int16 v19; // ax
__int64 v20; // rdx
__int64 v22; // r8
__int64 v23; // r9
int v24; // eax
unsigned __int64 v25; // [rsp+8h] [rbp-C0h]
socklen_t addr_len; // [rsp+1Ch] [rbp-ACh] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-A8h] BYREF
char buf[80]; // [rsp+30h] [rbp-98h] BYREF
int v29; // [rsp+80h] [rbp-48h]

memset(buf, 0, sizeof(buf));
v29 = 0;
*(_QWORD *)&addr.sa_family = 0LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
addr_len = 16;
v12 = recvfrom(fd, buf, 0x54uLL, 0, &addr, &addr_len);
v13 = v12;
if ( v12 <= 0 )
{
if ( v12 )
{
v24 = *_errno_location();
if ( v24 != 4 && v24 != 11 )
diminuto_log_perror("src/diminuto_ping4.c", 189LL, "diminuto_ping4_datagram_recv: recvfrom");
}
}
else
{
if ( diminuto_ping4_debug )
func2((__int64)stderr, (__int64)buf, v12);
diminuto_ipc4_identify(&addr, a2, 0LL);
v25 = v13;
if ( v13 > 0x1B )
{
v15 = (4 * buf[0]) & 0x3C;
v16 = &buf[v15];
v17 = v13 - v15;
v18 = &buf[v15];
v19 = func3(&buf[v15], v13 - v15);
v13 = 0LL;
if ( !v19 )
{
if ( a3 )
*a3 = *v16;
if ( a4 )
*a4 = v16[1];
v13 = 0LL;
if ( !*v16 )
{
if ( a5 )
*a5 = *((_WORD *)v16 + 2);
if ( a6 )
*a6 = *((_WORD *)v16 + 3);
if ( a7 )
*(_BYTE *)a7 = buf[8];
v13 = 0LL;
if ( v25 > 0x53 )
{
if ( a8 )
*(_QWORD *)a8 = diminuto_time_clock(v18, v17, v20, a7, v22, v23) - *((_QWORD *)v16 + 1);
v13 = v25 - 20;
}
}
}
}
else
{
v13 = 0LL;
}
}
return v13;
}

original_code:
ssize_t diminuto_ping4_datagram_receive(int fd, diminuto_ipv4_t * addressp, uint8_t * typep, uint8_t * codep, uint16_t * idp, uint16_t * seqp, uint8_t * ttlp, diminuto_ticks_t * elapsedp)
{
    ssize_t total;
    icmp_echo_reply_datagram_t buffer = { 0 };
    struct sockaddr_in sa = { 0 };
    socklen_t length = sizeof(sa);
    struct iphdr * ipp;
    struct icmp * icmpp;
    diminuto_ticks_t now;
    diminuto_ticks_t then;
    if ((total = recvfrom(fd, &buffer, sizeof(buffer), 0, (struct sockaddr *)&sa, &length)) > 0) {
        if (diminuto_ping4_debug) { diminuto_dump(stderr, &buffer, total); }
        diminuto_ipc4_identify((struct sockaddr *)&sa, addressp, (diminuto_port_t *)0);
        if (total < (sizeof(struct iphdr) + 8)) {
            total = 0;
        } else {
            ipp = (struct iphdr *)(&buffer);
            icmpp = (struct icmp *)((&(buffer.payload[0])) + (ipp->ihl << 2));
            if (diminuto_inet_checksum(icmpp, total - ((char *)icmpp - (char *)ipp)) != 0) {
                total = 0;
            } else {
                if (typep != (uint8_t *)0) {
                    *typep = icmpp->icmp_type;
                }
                if (codep != (uint8_t *)0) {
                    *codep = icmpp->icmp_code;
                }
                if (icmpp->icmp_type != 0) {
                    total = 0;
                } else {
                    if (idp != (uint16_t *)0) {
                        *idp = icmpp->icmp_hun.ih_idseq.icd_id;
                    }
                    if (seqp != (uint16_t *)0) {
                        *seqp = icmpp->icmp_hun.ih_idseq.icd_seq;
                    }
                    if (ttlp != (uint8_t *)0) {
                        *ttlp = ipp->ttl;
                    }
                    if (total < sizeof(buffer)) {
                        total = 0;
                    } else {
                        if (elapsedp != (diminuto_ticks_t *)0) {
                            now = diminuto_time_clock();
                            memcpy(&then, icmpp->icmp_dun.id_data, sizeof(diminuto_ticks_t));
                            *elapsedp = now - then;
                        }
                        total -= sizeof(struct iphdr);
                    }
                }
            }
        }
    } else if (total == 0) {
    } else if (((*__errno_location ()) != 4) && ((*__errno_location ()) != 11) && ((*__errno_location ()) != 11)) {
        diminuto_log_perror("src/diminuto_ping4.c", 189, "diminuto_ping4_datagram_recv: recvfrom");
    } else {
    }
    return total;
}

canonical_original_code:
long diminuto_ping4_datagram_receive(int fd, unsigned int *addressp, unsigned char *typep, unsigned char *codep, unsigned short *idp, unsigned short *seqp, unsigned char *ttlp, unsigned long *elapsedp)
{
    long total;
    union icmp_echo_reply_datagram_t buffer = { 0 };
    struct sockaddr_in sa = { 0 };
    unsigned int length = sizeof(sa);
    struct iphdr *ipp;
    struct icmp *icmpp;
    unsigned long now;
    unsigned long then;
    if ((total = recvfrom(fd, &buffer, sizeof(buffer), 0, (struct sockaddr *)&sa, &length)) > 0) {
        if (diminuto_ping4_debug) { diminuto_dump(stderr, &buffer, total); }
        diminuto_ipc4_identify((struct sockaddr *)&sa, addressp, (unsigned short *)0);
        if (total < (sizeof(struct iphdr) + 8)) {
            total = 0;
        } else {
            ipp = (struct iphdr *)(&buffer);
            icmpp = (struct icmp *)((&(buffer.payload[0])) + (ipp->ihl << 2));
            if (diminuto_inet_checksum(icmpp, total - ((char *)icmpp - (char *)ipp)) != 0) {
                total = 0;
            } else {
                if (typep != (unsigned char *)0) {
                    *typep = icmpp->icmp_type;
                }
                if (codep != (unsigned char *)0) {
                    *codep = icmpp->icmp_code;
                }
                if (icmpp->icmp_type != 0) {
                    total = 0;
                } else {
                    if (idp != (unsigned short *)0) {
                        *idp = icmpp->icmp_hun.ih_idseq.icd_id;
                    }
                    if (seqp != (unsigned short *)0) {
                        *seqp = icmpp->icmp_hun.ih_idseq.icd_seq;
                    }
                    if (ttlp != (unsigned char *)0) {
                        *ttlp = ipp->ttl;
                    }
                    if (total < sizeof(buffer)) {
                        total = 0;
                    } else {
                        if (elapsedp != (unsigned long *)0) {
                            now = diminuto_time_clock();
                            memcpy(&then, icmpp->icmp_dun.id_data, sizeof(diminuto_ticks_t));
                            *elapsedp = now - then;
                        }
                        total -= sizeof(struct iphdr);
                    }
                }
            }
        }
    } else if (total == 0) {
    } else if (((*__errno_location ()) != 4) && ((*__errno_location ()) != 11) && ((*__errno_location ()) != 11)) {
        diminuto_log_perror("src/diminuto_ping4.c", 189, "diminuto_ping4_datagram_recv: recvfrom");
    } else {
    }
    return total;
}

variable_types:
addressp
unsigned int *

variable_types:
typep
unsigned char *

variable_types:
codep
unsigned char *

variable_types:
idp
unsigned short *

variable_types:
seqp
unsigned short *

variable_types:
ttlp
unsigned char *

variable_types:
elapsedp
unsigned long *

variable_types: union icmp_echo_reply_datagram_t { struct { struct iphdr { unsigned int ihl; unsigned int version; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; } ip; struct icmp { unsigned char icmp_type; unsigned char icmp_code; unsigned short icmp_cksum; union { unsigned char ih_pptr; struct in_addr { unsigned int s_addr; } ih_gwaddr; struct ih_idseq { unsigned short icd_id; unsigned short icd_seq; } ih_idseq; unsigned int ih_void; struct ih_pmtu { unsigned short ipm_void; unsigned short ipm_nextmtu; } ih_pmtu; struct ih_rtradv { unsigned char irt_num_addrs; unsigned char irt_wpa; unsigned short irt_lifetime; } ih_rtradv; } icmp_hun; union { struct { unsigned int its_otime; unsigned int its_rtime; unsigned int its_ttime; } id_ts; struct { struct ip { unsigned int ip_hl; unsigned int ip_v; unsigned char ip_tos; unsigned short ip_len; unsigned short ip_id; unsigned short ip_off; unsigned char ip_ttl; unsigned char ip_p; unsigned short ip_sum; struct in_addr ip_src; } idi_ip; } id_ip; struct icmp_ra_addr { unsigned int ira_addr; unsigned int ira_preference; } id_radv; unsigned int id_mask; unsigned char id_data[1]; } icmp_dun; } icmp; } header; char payload[-1]; }

variable_types:
length
unsigned int

variable_types: struct iphdr { unsigned int ihl; unsigned int version; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; } *

variable_types:
then
unsigned long

user_defined_types: union icmp_echo_reply_datagram_t { struct { struct iphdr ip; struct icmp icmp; } header; char payload[-1]; }


repo: coverclock/com-diag-diminuto

decompiled_code:
__int64 __fastcall diminuto_atomic_apply(__int64 a1, __int64 (__fastcall *a2)(__int64, __int64), __int64 a3, __int64 a4)
{
__int64 v4; // rbx
__pthread_unwind_buf_t buf; // [rsp+20h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock() )
return -1LL;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(a1);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v4 = a2(a3, a4);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(a1);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 (__fastcall *a2)(__int64, __int64), __int64 a3, __int64 a4)
{
__int64 v4; // rbx
__pthread_unwind_buf_t buf; // [rsp+20h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock() )
return -1LL;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(a1);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v4 = a2(a3, a4);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(a1);
return v4;
}

original_code:
void * diminuto_atomic_apply(pthread_mutex_t * mutexp, diminuto_atomic_functor_t * functorp, void * sharedp, void * contextp)
{
 void * resultp = (void *)DIMINUTO_ATOMIC_ERROR;
 do { pthread_mutex_t * _diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (mutexp); 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);
  resultp = (*functorp)(sharedp, contextp);
 } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
 return resultp;
}

canonical_original_code:
void *diminuto_atomic_apply(union pthread_mutex_t *mutexp, void *(*functorp)(void *sharedp, void *contextp), void *sharedp, void *contextp)
{
 void *resultp = (void *)DIMINUTO_ATOMIC_ERROR;
 do { union pthread_mutex_t *_diminuto_criticalsection_mp; _diminuto_criticalsection_mp = (mutexp); 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);
  resultp = (*functorp)(sharedp, contextp);
 } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
 return resultp;
}

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: void *(*)(void *sharedp, void *contextp)

variable_types:
sharedp
void *

variable_types:
contextp
void *

variable_types:
resultp
void *

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:
void *__fastcall diminuto_module_load_generic(const char *a1, char a2)
{
void *v2; // rbx
char *v4; // rax

v2 = dlopen(a1, a2);
if ( !v2 && (a2 & 4) == 0 && (diminuto_log_mask & 0x10) != 0 )
{
v4 = dlerror();
diminuto_log_log(3LL, "src/diminuto_module.c@34: diminuto_module_load_generic: dlopen: %s\n", v4);
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func0(const char *a1, char a2)
{
void *v2; // rbx
char *v4; // rax

v2 = dlopen(a1, a2);
if ( !v2 && (a2 & 4) == 0 && (diminuto_log_mask & 0x10) != 0 )
{
v4 = dlerror();
diminuto_log_log(3LL, "src/diminuto_module.c@34: diminuto_module_load_generic: dlopen: %s\n", v4);
}
return v2;
}

original_code:
diminuto_module_handle_t diminuto_module_load_generic(const char * filename, int flags)
{
    diminuto_module_handle_t handle;
    if ((handle = dlopen(filename, flags)) != (diminuto_module_handle_t)0) {
    } else if ((flags & 0x00004) == 0x00004) {
    } else {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "src/diminuto_module.c" "@" "34" ": " "diminuto_module_load_generic: dlopen: %s\n", dlerror()) : ((void)0));
    }
    return handle;
}

canonical_original_code:
void *diminuto_module_load_generic(char *filename, int flags)
{
    void *handle;
    if ((handle = dlopen(filename, flags)) != (void *)0) {
    } else if ((flags & 0x00004) == 0x00004) {
    } else {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "src/diminuto_module.c" "@" "34" ": " "diminuto_module_load_generic: dlopen: %s\n", dlerror()) : ((void)0));
    }
    return handle;
}

variable_types:
filename
char *

variable_types: flags int

variable_types:
handle
void *


decompiled_code:
void *__fastcall diminuto_module_handle(const char *a1)
{
return diminuto_module_load_generic(a1, 4);
}

canonical_decompiled_code:
void *__fastcall func1(const char *a1)
{
return func0(a1, 4);
}

original_code:
diminuto_module_handle_t diminuto_module_handle(const char * filename)
{
    return diminuto_module_load_generic(filename, 0x00004);
}

canonical_original_code:
void *diminuto_module_handle(char *filename)
{
    return diminuto_module_load_generic(filename, 0x00004);
}


decompiled_code:
void *__fastcall diminuto_module_load(const char *a1)
{
return diminuto_module_load_generic(a1, 9);
}

canonical_decompiled_code:
void *__fastcall func2(const char *a1)
{
return func0(a1, 9);
}

original_code:
diminuto_module_handle_t diminuto_module_load(const char * filename)
{
    return diminuto_module_load_generic(filename, 0x00001 | 0x00100 | 0x00008);
}

canonical_original_code:
void *diminuto_module_load(char *filename)
{
    return diminuto_module_load_generic(filename, 0x00001 | 0x00100 | 0x00008);
}


decompiled_code:
void *__fastcall diminuto_module_symbol(void *a1, const char *a2, const char *a3)
{
void *v3; // rbx
const char *v4; // rbp
char *v6; // rax

if ( a3 )
{
v3 = dlvsym(a1, a2, a3);
v4 = "dlvsym";
}
else
{
v3 = dlsym(a1, a2);
v4 = "dlsym";
}
if ( !v3 && (diminuto_log_mask & 0x10) != 0 )
{
v6 = dlerror();
diminuto_log_log(3LL, "src/diminuto_module.c@95: diminuto_module_symbol: %s: %s", v4, v6);
}
return v3;
}

canonical_decompiled_code:
void *__fastcall func3(void *a1, const char *a2, const char *a3)
{
void *v3; // rbx
const char *v4; // rbp
char *v6; // rax

if ( a3 )
{
v3 = dlvsym(a1, a2, a3);
v4 = "dlvsym";
}
else
{
v3 = dlsym(a1, a2);
v4 = "dlsym";
}
if ( !v3 && (diminuto_log_mask & 0x10) != 0 )
{
v6 = dlerror();
diminuto_log_log(3LL, "src/diminuto_module.c@95: diminuto_module_symbol: %s: %s", v4, v6);
}
return v3;
}

original_code:
void * diminuto_module_symbol(diminuto_module_handle_t handle, const char * symbol, const char * version)
{
    void * resolved;
    const char * label;
    if (version == (const char *)0) {
        label = "dlsym";
        resolved = dlsym(handle, symbol);
    } else {
        label = "dlvsym";
        resolved = dlvsym(handle, symbol, version);
    }
    if (resolved == (void *)0) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "src/diminuto_module.c" "@" "95" ": " "diminuto_module_symbol: %s: %s", label, dlerror()) : ((void)0));
    }
    return resolved;
}

canonical_original_code:
void *diminuto_module_symbol(void *handle, char *symbol, char *version)
{
    void *resolved;
    char *label;
    if (version == (char *)0) {
        label = "dlsym";
        resolved = dlsym(handle, symbol);
    } else {
        label = "dlvsym";
        resolved = dlvsym(handle, symbol, version);
    }
    if (resolved == (void *)0) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "src/diminuto_module.c" "@" "95" ": " "diminuto_module_symbol: %s: %s", label, dlerror()) : ((void)0));
    }
    return resolved;
}

variable_types:
symbol
char *

variable_types:
version
char *

variable_types:
resolved
void *

variable_types:
label
char *


decompiled_code:
void *__fastcall diminuto_module_unload(void *handle, int a2)
{
bool v2; // dl
void *result; // rax
char *v4; // rax

do
v2 = dlclose(handle) == 0;
while ( a2 && v2 );
if ( a2 || v2 )
return 0LL;
result = handle;
if ( (diminuto_log_mask & 0x10) != 0 )
{
v4 = dlerror();
diminuto_log_log(3LL, "src/diminuto_module.c@133: diminuto_module_unload: dlclose: %s\n", v4);
result = handle;
}
return result;
}

canonical_decompiled_code:
void *__fastcall func4(void *handle, int a2)
{
bool v2; // dl
void *result; // rax
char *v4; // rax

do
v2 = dlclose(handle) == 0;
while ( a2 && v2 );
if ( a2 || v2 )
return 0LL;
result = handle;
if ( (diminuto_log_mask & 0x10) != 0 )
{
v4 = dlerror();
diminuto_log_log(3LL, "src/diminuto_module.c@133: diminuto_module_unload: dlclose: %s\n", v4);
result = handle;
}
return result;
}

original_code:
diminuto_module_handle_t diminuto_module_unload(diminuto_module_handle_t handle, int force)
{
    int rc;
    do {
        rc = dlclose(handle);
    } while (force && (rc == 0));
    if (force) {
        handle = (diminuto_module_handle_t)0;
    } else if (rc == 0) {
        handle = (diminuto_module_handle_t)0;
    } else {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "src/diminuto_module.c" "@" "133" ": " "diminuto_module_unload: dlclose: %s\n", dlerror()) : ((void)0));
    }
    return handle;
}

canonical_original_code:
void *diminuto_module_unload(void *handle, int force)
{
    int rc;
    do {
        rc = dlclose(handle);
    } while (force && (rc == 0));
    if (force) {
        handle = (void *)0;
    } else if (rc == 0) {
        handle = (void *)0;
    } else {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "src/diminuto_module.c" "@" "133" ": " "diminuto_module_unload: dlclose: %s\n", dlerror()) : ((void)0));
    }
    return handle;
}

variable_types: force int

variable_types: rc int


decompiled_code:
const void *__fastcall diminuto_buffer_malloc(__int64 a1)
{
const void *v1; // rbx
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-88h] BYREF

if ( a1 )
{
if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
{
v1 = 0LL;
}
else
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = (const void *)diminuto_buffer_pool_get(&meta, a1, (unsigned int)fail);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
}
}
else
{
*_errno_location() = 0;
v1 = 0LL;
}
if ( debug )
diminuto_log_emit("diminuto_buffer_malloc: size=%zu ptr=%p\n", a1, v1);
return v1;
}

canonical_decompiled_code:
const void *__fastcall func6(__int64 a1)
{
const void *v1; // rbx
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-88h] BYREF

if ( a1 )
{
if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
{
v1 = 0LL;
}
else
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = (const void *)diminuto_buffer_pool_get(&meta, a1, (unsigned int)fail);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
}
}
else
{
*_errno_location() = 0;
v1 = 0LL;
}
if ( debug )
diminuto_log_emit("diminuto_buffer_malloc: size=%zu ptr=%p\n", a1, v1);
return v1;
}

original_code:
void * diminuto_buffer_malloc(size_t size)
{
    void * ptr = (void *)0;
    if (size > 0) {
        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);
            ptr = diminuto_buffer_pool_get((diminuto_buffer_pool_t *)&meta, size, fail);
        } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    } else {
        (*__errno_location ()) = 0;
    }
    if (debug) {
        diminuto_log_emit("diminuto_buffer_malloc: size=%zu ptr=%p\n", size, ptr);
    }
    return ptr;
}

canonical_original_code:
void *diminuto_buffer_malloc(unsigned long size)
{
    void *ptr = (void *)0;
    if (size > 0) {
        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);
            ptr = diminuto_buffer_pool_get((struct DiminutoBufferPool *)&meta, size, fail);
        } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    } else {
        (*__errno_location ()) = 0;
    }
    if (debug) {
        diminuto_log_emit("diminuto_buffer_malloc: size=%zu ptr=%p\n", size, ptr);
    }
    return ptr;
}

variable_types:
size
unsigned long

variable_types:
ptr
void *

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 DiminutoBufferPool { unsigned long count; unsigned long *sizes; void **pool; }

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


decompiled_code:
void __fastcall diminuto_buffer_free(const void *a1)
{
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( debug )
diminuto_log_emit("diminuto_buffer_free: ptr=%p\n", a1);
if ( a1 && !(unsigned int)diminuto_criticalsection_lock(&mutex) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
diminuto_buffer_pool_put(&meta, a1);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
}
}

canonical_decompiled_code:
void __fastcall func7(const void *a1)
{
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( debug )
diminuto_log_emit("diminuto_buffer_free: ptr=%p\n", a1);
if ( a1 && !(unsigned int)diminuto_criticalsection_lock(&mutex) )
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
diminuto_buffer_pool_put(&meta, a1);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
}
}

original_code:
void diminuto_buffer_free(void * ptr)
{
    if (debug) {
        diminuto_log_emit("diminuto_buffer_free: ptr=%p\n", ptr);
    }
    if (ptr != (void *)0) {
        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_buffer_pool_put((diminuto_buffer_pool_t *)&meta, ptr);
        } 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_buffer_free(void *ptr)
{
    if (debug) {
        diminuto_log_emit("diminuto_buffer_free: ptr=%p\n", ptr);
    }
    if (ptr != (void *)0) {
        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_buffer_pool_put((struct DiminutoBufferPool *)&meta, ptr);
        } 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; } *

return_type: void


decompiled_code:
const void *__fastcall diminuto_buffer_realloc(_QWORD *a1, unsigned __int64 a2)
{
const void *v2; // rbx
__int64 v4; // rbp
void *v5; // rax
size_t v6; // rdx
__int64 v7; // [rsp+18h] [rbp-A0h] BYREF
__pthread_unwind_buf_t buf; // [rsp+20h] [rbp-98h] BYREF

if ( a1 )
{
if ( a2 )
{
v7 = 0LL;
if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
{
v4 = 0LL;
}
else
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v4 = buffer_pool_effective((unsigned __int64 *)&meta, *(a1 - 1));
buffer_pool_hash((unsigned __int64 *)&meta, a2, &v7);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
}
v2 = a1;
if ( v7 != v4 )
{
v5 = (void *)diminuto_buffer_malloc(a2);
v2 = v5;
if ( v5 )
{
v6 = v4 - 8;
if ( v4 - 8 > a2 )
v6 = a2;
memcpy(v5, a1, v6);
}
diminuto_buffer_free(a1);
}
}
else
{
diminuto_buffer_free(a1);
*_errno_location() = 0;
v2 = 0LL;
}
}
else
{
v2 = diminuto_buffer_malloc(a2);
}
if ( debug )
diminuto_log_emit("diminuto_buffer_realloc: ptr=%p size=%zu pointer=%p\n", a1, a2, v2);
return v2;
}

canonical_decompiled_code:
const void *__fastcall func8(_QWORD *a1, unsigned __int64 a2)
{
const void *v2; // rbx
__int64 v4; // rbp
void *v5; // rax
size_t v6; // rdx
__int64 v7; // [rsp+18h] [rbp-A0h] BYREF
__pthread_unwind_buf_t buf; // [rsp+20h] [rbp-98h] BYREF

if ( a1 )
{
if ( a2 )
{
v7 = 0LL;
if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
{
v4 = 0LL;
}
else
{
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v4 = func2((unsigned __int64 *)&meta, *(a1 - 1));
func1((unsigned __int64 *)&meta, a2, &v7);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
}
v2 = a1;
if ( v7 != v4 )
{
v5 = (void *)func6(a2);
v2 = v5;
if ( v5 )
{
v6 = v4 - 8;
if ( v4 - 8 > a2 )
v6 = a2;
memcpy(v5, a1, v6);
}
func7(a1);
}
}
else
{
func7(a1);
*_errno_location() = 0;
v2 = 0LL;
}
}
else
{
v2 = func6(a2);
}
if ( debug )
diminuto_log_emit("diminuto_buffer_realloc: ptr=%p size=%zu pointer=%p\n", a1, a2, v2);
return v2;
}

original_code:
void * diminuto_buffer_realloc(void * ptr, size_t size)
{
    void * ptrprime = (void *)0;
    if (ptr == (void *)0) {
        ptrprime = diminuto_buffer_malloc(size);
    } else if (size == 0) {
        diminuto_buffer_free(ptr);
        (*__errno_location ()) = 0;
        ptrprime = (void *)0;
    } else {
        diminuto_buffer_t * buffer = (diminuto_buffer_t *)0;
        size_t actual = 0;
        size_t requested = 0;
        buffer = ((diminuto_buffer_t *)(((char *)(ptr)) - ((size_t)(((char *)&(((diminuto_buffer_t *)0)->payload)) - ((char *)((diminuto_buffer_t *)0))))));
        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);
            actual = buffer_pool_effective(&meta, buffer->header.item);
            (void)buffer_pool_hash(&meta, size, &requested);
        } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
        if (actual == requested) {
            ptrprime = ptr;
        } else {
            ptrprime = diminuto_buffer_malloc(size);
            if (ptrprime != (void *)0) {
                size_t length;
                length = actual - sizeof(diminuto_buffer_t);
                memcpy(ptrprime, ptr, size < length ? size : length);
            }
            diminuto_buffer_free(ptr);
        }
    }
    if (debug) {
        diminuto_log_emit("diminuto_buffer_realloc: ptr=%p size=%zu pointer=%p\n", ptr, size, ptrprime);
    }
    return ptrprime;
}

canonical_original_code:
void *diminuto_buffer_realloc(void *ptr, unsigned long size)
{
    void *ptrprime = (void *)0;
    if (ptr == (void *)0) {
        ptrprime = diminuto_buffer_malloc(size);
    } else if (size == 0) {
        diminuto_buffer_free(ptr);
        (*__errno_location ()) = 0;
        ptrprime = (void *)0;
    } else {
        struct DiminutoBuffer *buffer = (diminuto_buffer_t *)0;
        unsigned long actual = 0;
        unsigned long requested = 0;
        buffer = ((struct DiminutoBuffer *)(((char *)(ptr)) - ((unsigned long)(((char *)&(((struct DiminutoBuffer *)0)->payload)) - ((char *)((struct DiminutoBuffer *)0))))));
        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);
            actual = buffer_pool_effective(&meta, buffer->header.item);
            (void)buffer_pool_hash(&meta, size, &requested);
        } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
        if (actual == requested) {
            ptrprime = ptr;
        } else {
            ptrprime = diminuto_buffer_malloc(size);
            if (ptrprime != (void *)0) {
                unsigned long length;
                length = actual - sizeof(diminuto_buffer_t);
                memcpy(ptrprime, ptr, size < length ? size : length);
            }
            diminuto_buffer_free(ptr);
        }
    }
    if (debug) {
        diminuto_log_emit("diminuto_buffer_realloc: ptr=%p size=%zu pointer=%p\n", ptr, size, ptrprime);
    }
    return ptrprime;
}

variable_types:
ptrprime
void *

variable_types: struct DiminutoBuffer { unsigned long align[]; union { unsigned long item; struct DiminutoBuffer *next; } header; unsigned long payload[]; } *

variable_types:
actual
unsigned long

variable_types:
requested
unsigned long

variable_types:
length
unsigned long


decompiled_code:
const void *__fastcall diminuto_buffer_calloc(__int64 a1, __int64 a2)
{
void *v2; // rax
const void *v3; // rbx

v2 = (void *)diminuto_buffer_malloc(a2 * a1);
v3 = v2;
if ( v2 )
memset(v2, 0, a2 * a1);
if ( debug )
diminuto_log_emit("diminuto_buffer_calloc: nmemb=%zu size=%zu ptr=%p\n", a1, a2, v3);
return v3;
}

canonical_decompiled_code:
const void *__fastcall func9(__int64 a1, __int64 a2)
{
void *v2; // rax
const void *v3; // rbx

v2 = (void *)func6(a2 * a1);
v3 = v2;
if ( v2 )
memset(v2, 0, a2 * a1);
if ( debug )
diminuto_log_emit("diminuto_buffer_calloc: nmemb=%zu size=%zu ptr=%p\n", a1, a2, v3);
return v3;
}

original_code:
void * diminuto_buffer_calloc(size_t nmemb, size_t size)
{
    void * ptr = (void *)0;
    size_t length = 0;
    length = nmemb * size;
    ptr = diminuto_buffer_malloc(length);
    if (ptr != (void *)0) {
        memset(ptr, 0, length);
    }
    if (debug) {
        diminuto_log_emit("diminuto_buffer_calloc: nmemb=%zu size=%zu ptr=%p\n", nmemb, size, ptr);
    }
    return ptr;
}

canonical_original_code:
void *diminuto_buffer_calloc(unsigned long nmemb, unsigned long size)
{
    void *ptr = (void *)0;
    unsigned long length = 0;
    length = nmemb * size;
    ptr = diminuto_buffer_malloc(length);
    if (ptr != (void *)0) {
        memset(ptr, 0, length);
    }
    if (debug) {
        diminuto_log_emit("diminuto_buffer_calloc: nmemb=%zu size=%zu ptr=%p\n", nmemb, size, ptr);
    }
    return ptr;
}

variable_types:
nmemb
unsigned long


decompiled_code:
char *__fastcall diminuto_buffer_strdup(char *src)
{
size_t v1; // rax
char *v2; // rax
char *v3; // rbx

v1 = strlen(src);
v2 = (char *)diminuto_buffer_malloc(v1 + 1);
v3 = v2;
if ( v2 )
strcpy(v2, src);
return v3;
}

canonical_decompiled_code:
char *__fastcall func10(char *src)
{
size_t v1; // rax
char *v2; // rax
char *v3; // rbx

v1 = strlen(src);
v2 = (char *)func6(v1 + 1);
v3 = v2;
if ( v2 )
strcpy(v2, src);
return v3;
}

original_code:
char * diminuto_buffer_strdup(const char * s)
{
    char * ptr = (char *)0;
    size_t length = 0;
    length = strlen(s);
    ptr = (char *)diminuto_buffer_malloc(length + 1);
    if (ptr != (char *)0) {
        strcpy(ptr, s);
    }
    return ptr;
}

canonical_original_code:
char *diminuto_buffer_strdup(char *s)
{
    char *ptr = (char *)0;
    unsigned long length = 0;
    length = strlen(s);
    ptr = (char *)diminuto_buffer_malloc(length + 1);
    if (ptr != (char *)0) {
        strcpy(ptr, s);
    }
    return ptr;
}

variable_types:
s
char *

variable_types:
ptr
char *

return_type: char *


decompiled_code:
char *__fastcall diminuto_buffer_strndup(char *src, size_t a2)
{
size_t v2; // rbp
char *v3; // rax
char *v4; // rbx

v2 = strnlen(src, a2);
v3 = (char *)diminuto_buffer_malloc(v2 + 1);
v4 = v3;
if ( v3 )
{
strncpy(v3, src, v2);
v4[v2] = 0;
}
return v4;
}

canonical_decompiled_code:
char *__fastcall func11(char *src, size_t a2)
{
size_t v2; // rbp
char *v3; // rax
char *v4; // rbx

v2 = strnlen(src, a2);
v3 = (char *)func6(v2 + 1);
v4 = v3;
if ( v3 )
{
strncpy(v3, src, v2);
v4[v2] = 0;
}
return v4;
}

original_code:
char * diminuto_buffer_strndup(const char * s, size_t n)
{
    char * ptr = (char *)0;
    size_t length = 0;
    length = strnlen(s, n);
    ptr = (char *)diminuto_buffer_malloc(length + 1);
    if (ptr != (char *)0) {
        strncpy(ptr, s, length);
        ptr[length] = '\0';
    }
    return ptr;
}

canonical_original_code:
char *diminuto_buffer_strndup(char *s, unsigned long n)
{
    char *ptr = (char *)0;
    unsigned long length = 0;
    length = strnlen(s, n);
    ptr = (char *)diminuto_buffer_malloc(length + 1);
    if (ptr != (char *)0) {
        strncpy(ptr, s, length);
        ptr[length] = '\0';
    }
    return ptr;
}

variable_types:
n
unsigned long


decompiled_code:
__int64 diminuto_buffer_fini()
{
__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_buffer_pool_free(&meta);
_pthread_unregister_cancel(&v1);
result = diminuto_criticalsection_cleanup(&mutex);
}
return result;
}

canonical_decompiled_code:
__int64 func12()
{
__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_buffer_pool_free(&meta);
_pthread_unregister_cancel(&v1);
result = diminuto_criticalsection_cleanup(&mutex);
}
return result;
}

original_code:
void diminuto_buffer_fini(void)
{
    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_buffer_pool_free((diminuto_buffer_pool_t *)&meta);
    } 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_buffer_fini()
{
    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_buffer_pool_free((struct DiminutoBufferPool *)&meta);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
}

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


decompiled_code:
__int64 __fastcall diminuto_buffer_prealloc(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return 0LL;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v2 = diminuto_buffer_pool_prealloc(&meta, a1, a2);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return 0LL;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v2 = diminuto_buffer_pool_prealloc(&meta, a1, a2);
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
return v2;
}

original_code:
size_t diminuto_buffer_prealloc(size_t nmemb, size_t size)
{
    size_t result = 0;
    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);
        result = diminuto_buffer_pool_prealloc((diminuto_buffer_pool_t *)&meta, nmemb, size);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return result;
}

canonical_original_code:
unsigned long diminuto_buffer_prealloc(unsigned long nmemb, unsigned long size)
{
    unsigned long result = 0;
    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);
        result = diminuto_buffer_pool_prealloc((struct DiminutoBufferPool *)&meta, nmemb, size);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return result;
}

variable_types:
result
unsigned long

return_type: unsigned long


decompiled_code:
__int64 diminuto_buffer_log()
{
__int64 v0; // rbx
__pthread_unwind_buf_t v2; // [rsp+0h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return 0LL;
if ( _sigsetjmp((struct __jmp_buf_tag *)&v2, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&v2);
}
_pthread_register_cancel(&v2);
v0 = diminuto_buffer_pool_log(&meta);
_pthread_unregister_cancel(&v2);
diminuto_criticalsection_cleanup(&mutex);
return v0;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 v0; // rbx
__pthread_unwind_buf_t v2; // [rsp+0h] [rbp-88h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return 0LL;
if ( _sigsetjmp((struct __jmp_buf_tag *)&v2, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&v2);
}
_pthread_register_cancel(&v2);
v0 = diminuto_buffer_pool_log(&meta);
_pthread_unregister_cancel(&v2);
diminuto_criticalsection_cleanup(&mutex);
return v0;
}

original_code:
size_t diminuto_buffer_log(void)
{
    size_t result = 0;
    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);
        result = diminuto_buffer_pool_log((diminuto_buffer_pool_t *)&meta);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return result;
}

canonical_original_code:
unsigned long diminuto_buffer_log()
{
    unsigned long result = 0;
    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);
        result = diminuto_buffer_pool_log((struct DiminutoBufferPool *)&meta);
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return result;
}


decompiled_code:
_BOOL8 __fastcall diminuto_buffer_set(__int64 *a1)
{
_BOOL4 v1; // ebx
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return 0;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = a1 != 0LL;
if ( a1 )
{
meta = *a1;
off_898 = (void *)a1[1];
off_8A0 = (void *)a1[2];
}
else
{
meta = 10LL;
off_898 = &POOL;
off_8A0 = &pool;
}
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func15(__int64 *a1)
{
_BOOL4 v1; // ebx
__pthread_unwind_buf_t buf; // [rsp+10h] [rbp-78h] BYREF

if ( (unsigned int)diminuto_criticalsection_lock(&mutex) )
return 0;
if ( _sigsetjmp((struct __jmp_buf_tag *)&buf, 0) )
{
diminuto_criticalsection_cleanup(&mutex);
_pthread_unwind_next(&buf);
}
_pthread_register_cancel(&buf);
v1 = a1 != 0LL;
if ( a1 )
{
meta = *a1;
off_898 = (void *)a1[1];
off_8A0 = (void *)a1[2];
}
else
{
meta = 10LL;
off_898 = &POOL;
off_8A0 = &pool;
}
_pthread_unregister_cancel(&buf);
diminuto_criticalsection_cleanup(&mutex);
return v1;
}

original_code:
int diminuto_buffer_set(diminuto_buffer_pool_t * poolp)
{
    int result = 0;
    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);
        result = (poolp != (diminuto_buffer_pool_t *)0);
        if (result) {
            meta.count = poolp->count;
            meta.sizes = poolp->sizes;
            meta.pool = (diminuto_buffer_t **)(poolp->pool);
        } else {
            meta.count = (sizeof(POOL) / sizeof(POOL[0]));
            meta.sizes = POOL;
            meta.pool = pool;
        }
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return result;
}

canonical_original_code:
int diminuto_buffer_set(struct DiminutoBufferPool *poolp)
{
    int result = 0;
    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);
        result = (poolp != (struct DiminutoBufferPool *)0);
        if (result) {
            meta.count = poolp->count;
            meta.sizes = poolp->sizes;
            meta.pool = (struct DiminutoBuffer **)(poolp->pool);
        } else {
            meta.count = (sizeof(POOL) / sizeof(POOL[0]));
            meta.sizes = POOL;
            meta.pool = pool;
        }
    } while (0); do { } while (0); } while (0); __pthread_unregister_cancel (&__cancel_buf); if (!0) __cancel_routine (__cancel_arg); } while (0); } } while (0);
    return result;
}

variable_types: struct DiminutoBufferPool { unsigned long count; unsigned long *sizes; void **pool; } *

variable_types: result int

return_type: int

user_defined_types: struct DiminutoBuffer { unsigned long align[]; union { unsigned long item; struct DiminutoBuffer *next; } header; unsigned long payload[]; }


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

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

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

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

original_code:
int diminuto_buffer_debug(int after)
{
    int before = 0;
    before = debug;
    debug = after;
    return before;
}

variable_types: after int

variable_types: before int


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

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

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

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

original_code:
int diminuto_buffer_nomalloc(int after)
{
    int before = 0;
    before = fail;
    fail = after;
    return before;
}


decompiled_code:
__int64 __fastcall diminuto_buffer_hash(unsigned __int64 a1, _QWORD *a2)
{
return (unsigned int)buffer_pool_hash((unsigned __int64 *)&meta, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func18(unsigned __int64 a1, _QWORD *a2)
{
return (unsigned int)func1((unsigned __int64 *)&meta, a1, a2);
}

original_code:
size_t diminuto_buffer_hash(size_t requested, size_t * actualp)
{
    return buffer_pool_hash(&meta, requested, actualp);
}

canonical_original_code:
unsigned long diminuto_buffer_hash(unsigned long requested, unsigned long *actualp)
{
    return buffer_pool_hash(&meta, requested, actualp);
}

variable_types:
actualp
unsigned long *


decompiled_code:
__int64 __fastcall diminuto_buffer_effective(unsigned __int64 a1)
{
return buffer_pool_effective((unsigned __int64 *)&meta, a1);
}

canonical_decompiled_code:
__int64 __fastcall func19(unsigned __int64 a1)
{
return func2((unsigned __int64 *)&meta, a1);
}

original_code:
size_t diminuto_buffer_effective(size_t item)
{
    return buffer_pool_effective(&meta, item);
}

canonical_original_code:
unsigned long diminuto_buffer_effective(unsigned long item)
{
    return buffer_pool_effective(&meta, item);
}

variable_types:
item
unsigned long


decompiled_code:
__int64 diminuto_buffer_count()
{
return buffer_pool_count((__int64)&meta);
}

canonical_decompiled_code:
__int64 func20()
{
return func0((__int64)&meta);
}

original_code:
size_t diminuto_buffer_count(void)
{
    return buffer_pool_count(&meta);
}

canonical_original_code:
unsigned long diminuto_buffer_count()
{
    return buffer_pool_count(&meta);
}


decompiled_code:
unsigned __int64 __fastcall diminuto_buffer_size(unsigned __int64 a1)
{
return buffer_pool_size((unsigned __int64 *)&meta, a1);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func21(unsigned __int64 a1)
{
return func3((unsigned __int64 *)&meta, a1);
}

original_code:
size_t diminuto_buffer_size(size_t item)
{
    return buffer_pool_size(&meta, item);
}

canonical_original_code:
unsigned long diminuto_buffer_size(unsigned long item)
{
    return buffer_pool_size(&meta, item);
}


decompiled_code:
__int64 __fastcall diminuto_buffer_isempty(unsigned __int64 a1)
{
_BOOL4 v1; // edx
__int64 result; // rax

v1 = buffer_pool_isexternal((unsigned __int64 *)&meta, a1);
LODWORD(result) = 1;
if ( !v1 )
LODWORD(result) = buffer_pool_first((__int64)&meta, a1) == 0;
return (int)result;
}

canonical_decompiled_code:
__int64 __fastcall func22(unsigned __int64 a1)
{
_BOOL4 v1; // edx
__int64 result; // rax

v1 = func4((unsigned __int64 *)&meta, a1);
LODWORD(result) = 1;
if ( !v1 )
LODWORD(result) = func5((__int64)&meta, a1) == 0;
return (int)result;
}

original_code:
size_t diminuto_buffer_isempty(size_t item)
{
    return (buffer_pool_isexternal(&meta, item) || (buffer_pool_first(&meta, item) == (diminuto_buffer_t *)0));
}

canonical_original_code:
unsigned long diminuto_buffer_isempty(unsigned long item)
{
    return (buffer_pool_isexternal(&meta, item) || (buffer_pool_first(&meta, item) == (struct DiminutoBuffer *)0));
}


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

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

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

canonical_original_code:
static void diminuto_hangup_handler(int signum)
{
    int mysignaled = -1;
    static int MAXIMUM = ~(((int)1) << ((sizeof(signaled) * 8) - 1));
    if (signum == 1) {
        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_hangup_signal(__pid_t a1)
{
__int64 result; // rax

if ( kill(a1, 1) < 0 )
{
diminuto_log_perror("src/diminuto_hangup.c", 32LL, "diminuto_hangup_kill: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_hangup_debug[0];
if ( diminuto_hangup_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_hangup_signal: SIGHUP");
result = 0LL;
}
}
}
return result;
}

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

if ( kill(a1, 1) < 0 )
{
diminuto_log_perror("src/diminuto_hangup.c", 32LL, "diminuto_hangup_kill: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_hangup_debug[0];
if ( diminuto_hangup_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_hangup_signal: SIGHUP");
result = 0LL;
}
}
}
return result;
}

original_code:
pid_t diminuto_hangup_signal(pid_t pid)
{
    int rc = 0;
    if (kill(pid, 1) < 0) {
        diminuto_log_perror("src/diminuto_hangup.c", 32, "diminuto_hangup_kill: kill");
        rc = -1;
    } else if (diminuto_hangup_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_hangup_signal: SIGHUP") : ((void)0));
    } else {
    }
    return rc;
}

canonical_original_code:
int diminuto_hangup_signal(int pid)
{
    int rc = 0;
    if (kill(pid, 1) < 0) {
        diminuto_log_perror("src/diminuto_hangup.c", 32, "diminuto_hangup_kill: kill");
        rc = -1;
    } else if (diminuto_hangup_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_hangup_signal: SIGHUP") : ((void)0));
    } else {
    }
    return rc;
}

variable_types: pid int

variable_types: rc int


decompiled_code:
__int64 diminuto_hangup_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_hangup_debug[0] && (diminuto_log_mask & 1) != 0 )
diminuto_log_log(7LL, "diminuto_hangup_check: SIGHUP");
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 = 1;
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_hangup_debug[0] && (diminuto_log_mask & 1) != 0 )
diminuto_log_log(7LL, "diminuto_hangup_check: SIGHUP");
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 = 1;
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_hangup_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[] = { 1 }; 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_hangup_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_hangup_check: SIGHUP") : ((void)0));
    } else {
    }
    return mysignaled;
}

canonical_original_code:
int diminuto_hangup_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[] = { 1 }; 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_hangup_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_hangup_check: SIGHUP") : ((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 __sigset_t { unsigned long __val[-1]; }


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

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

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

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

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

variable_types: restart int

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

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:
_BOOL8 __fastcall diminuto_throttle_isempty(__int64 a1)
{
return (*(_BYTE *)(a1 + 48) & 0x10) != 0;
}

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

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

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


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

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

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

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


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

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

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


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

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

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


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

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

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


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

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

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


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

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

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


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

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

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

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

variable_types:
now
unsigned long

variable_types:
events
unsigned long


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

if ( a3 > a1 && a4 > 1 )
v4 = (a4 - 1) * (a3 - a1);
else
v4 = 0LL;
return v4 + a2;
}

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

if ( a3 > a1 && a4 > 1 )
v4 = (a4 - 1) * (a3 - a1);
else
v4 = 0LL;
return v4 + a2;
}

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

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

variable_types:
peakincrement
unsigned long

variable_types:
jittertolerance
unsigned long

variable_types:
sustainedincrement
unsigned long

variable_types:
maximumburstsize
unsigned long

variable_types:
limit
unsigned long

variable_types:
increment
unsigned long


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

result = diminuto_throttle_init(a1, a2, a3, a6);
if ( result )
{
result = diminuto_throttle_init(a1 + 56, a4, a5, a6);
if ( result )
result = a1;
}
return result;
}

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

result = diminuto_throttle_init(a1, a2, a3, a6);
if ( result )
{
result = diminuto_throttle_init(a1 + 56, a4, a5, a6);
if ( result )
result = a1;
}
return result;
}

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

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

variable_types:
shaperp
struct DiminutoShaper *

variable_types:
bursttolerance
unsigned long

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

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


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

result = ((__int64 (*)(void))diminuto_throttle_reset)();
if ( result )
{
result = diminuto_throttle_reset(a1 + 56, a2);
if ( result )
result = a1;
}
return result;
}

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

result = ((__int64 (*)(void))diminuto_throttle_reset)();
if ( result )
{
result = diminuto_throttle_reset(a1 + 56, a2);
if ( result )
result = a1;
}
return result;
}

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

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

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


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

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

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

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

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

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

variable_types:
peak
unsigned long

variable_types:
sustained
unsigned long


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

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

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

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

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

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

variable_types: peak int

variable_types: sustained int


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

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

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

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

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

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


decompiled_code:
unsigned __int64 __fastcall diminuto_shaper_getexpected(__int64 a1)
{
unsigned __int64 v1; // rbx
unsigned __int64 result; // rax

v1 = diminuto_throttle_getexpected(a1);
result = diminuto_throttle_getexpected(a1 + 56);
if ( v1 >= result )
result = v1;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func15(__int64 a1)
{
unsigned __int64 v1; // rbx
unsigned __int64 result; // rax

v1 = func0(a1);
result = func0(a1 + 56);
if ( v1 >= result )
result = v1;
return result;
}

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_isempty(__int64 a1)
{
_BOOL4 v1; // ebp

v1 = diminuto_throttle_isempty(a1);
return v1 & diminuto_throttle_isempty(a1 + 56);
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(__int64 a1)
{
_BOOL4 v1; // ebp

v1 = func1(a1);
return v1 & func1(a1 + 56);
}

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_isfull(__int64 a1)
{
_BOOL4 v1; // ebp

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

canonical_decompiled_code:
_BOOL8 __fastcall func17(__int64 a1)
{
_BOOL4 v1; // ebp

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

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_isalarmed(__int64 a1)
{
_BOOL4 v1; // ebp

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

canonical_decompiled_code:
_BOOL8 __fastcall func18(__int64 a1)
{
_BOOL4 v1; // ebp

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

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_emptied(__int64 a1)
{
_BOOL4 v1; // ebp

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

canonical_decompiled_code:
_BOOL8 __fastcall func19(__int64 a1)
{
_BOOL4 v1; // ebp

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

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_filled(__int64 a1)
{
_BOOL4 v1; // ebp

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

canonical_decompiled_code:
_BOOL8 __fastcall func20(__int64 a1)
{
_BOOL4 v1; // ebp

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

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_alarmed(__int64 a1)
{
_BOOL4 v1; // ebp

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

canonical_decompiled_code:
_BOOL8 __fastcall func21(__int64 a1)
{
_BOOL4 v1; // ebp

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

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

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


decompiled_code:
_BOOL8 __fastcall diminuto_shaper_cleared(__int64 a1)
{
_BOOL4 v1; // ebp

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

canonical_decompiled_code:
_BOOL8 __fastcall func22(__int64 a1)
{
_BOOL4 v1; // ebp

v1 = func7(a1);
return func7(a1 + 56) || v1;
}

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

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


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

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

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

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


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

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


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

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

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


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

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

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

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


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

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

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


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

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

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

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

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

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


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

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

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


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

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

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

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

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

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


decompiled_code:
void diminuto_barrier_release_f()
{
;
}

canonical_decompiled_code:
void func14()
{
;
}

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

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