decompiled_code:
char *__fastcall reverse_lookup(const char *a1)
{
int v1; // eax
int v2; // ebx
char *result; // rax
const char *v4; // rax
struct addrinfo *pai; // [rsp+0h] [rbp-40h] BYREF
struct addrinfo req; // [rsp+8h] [rbp-38h] BYREF

*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 1;
*(_OWORD *)&req.ai_canonname = 0LL;
v1 = getaddrinfo(a1, 0LL, &req, &pai);
if ( v1 )
{
v4 = gai_strerror(v1);
fprintf(stderr, "getaddrinfo failed: %s\n", v4);
result = 0LL;
}
else
{
v2 = getnameinfo(pai->ai_addr, pai->ai_addrlen, buf_0, 0x401u, 0LL, 0, 8);
freeaddrinfo(pai);
result = buf_0;
if ( v2 )
result = 0LL;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func8(const char *a1)
{
int v1; // eax
int v2; // ebx
char *result; // rax
const char *v4; // rax
struct addrinfo *pai; // [rsp+0h] [rbp-40h] BYREF
struct addrinfo req; // [rsp+8h] [rbp-38h] BYREF

*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 1;
*(_OWORD *)&req.ai_canonname = 0LL;
v1 = getaddrinfo(a1, 0LL, &req, &pai);
if ( v1 )
{
v4 = gai_strerror(v1);
fprintf(stderr, "getaddrinfo failed: %s\n", v4);
result = 0LL;
}
else
{
v2 = getnameinfo(pai->ai_addr, pai->ai_addrlen, buf_0, 0x401u, 0LL, 0, 8);
freeaddrinfo(pai);
result = buf_0;
if ( v2 )
result = 0LL;
}
return result;
}

original_code:
char *
reverse_lookup(char *ip)
{
    static char buf[1025];
    struct addrinfo *addrs;
    struct addrinfo hints;
    int ret;
    memset(&hints, 0, sizeof (hints));
    hints.ai_family = 0;
    hints.ai_socktype = SOCK_STREAM;
    ret = getaddrinfo(ip, ((void *)0), &hints, &addrs);
    if (ret != 0)
    {
        fprintf (stderr, "getaddrinfo failed: %s\n", gai_strerror (ret));
        return ((void *)0);
    }
    ret = getnameinfo(addrs->ai_addr, addrs->ai_addrlen, buf, sizeof(buf), ((void *)0), 0, 8);
    freeaddrinfo (addrs);
    if (ret != 0)
    {
        return ((void *)0);
    }
    return buf;
}

canonical_original_code:
char *reverse_lookup(char *ip)
{
    static char buf[1025];
    struct addrinfo *addrs;
    struct addrinfo hints;
    int ret;
    memset(&hints, 0, sizeof (hints));
    hints.ai_family = 0;
    hints.ai_socktype = SOCK_STREAM;
    ret = getaddrinfo(ip, ((void *)0), &hints, &addrs);
    if (ret != 0)
    {
        fprintf (stderr, "getaddrinfo failed: %s\n", gai_strerror (ret));
        return ((void *)0);
    }
    ret = getnameinfo(addrs->ai_addr, addrs->ai_addrlen, buf, sizeof(buf), ((void *)0), 0, 8);
    freeaddrinfo (addrs);
    if (ret != 0)
    {
        return ((void *)0);
    }
    return buf;
}

variable_types:
ip
char *

variable_types:
buf
char [1025]

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }

variable_types: ret int


repo: cotillion/cd-gamedriver

decompiled_code:
int update_snoop_file()
{
__int64 v0; // rbx
__int64 v1; // rax
int v2; // edi
bool v3; // al
char *v4; // rbp
int result; // eax
__int64 v6; // r12
__int64 v7; // rbx
__int64 v8; // rax
const char *v9; // rdi

v0 = 1LL;
if ( num_super_snooped )
{
do
{
v1 = *((_QWORD *)&all_players + v0 - 1);
if ( v1 )
{
v2 = *(_DWORD *)(v1 + 256);
if ( v2 >= 0 )
{
close(v2);
*(_DWORD *)(*((_QWORD *)&all_players + v0 - 1) + 256LL) = -1;
--num_super_snooped;
}
}
v3 = (_DWORD)v0++ != 4000;
}
while ( v3 && num_super_snooped != 0 );
}
read_snoop_file();
v4 = (char *)&all_players;
do
{
while ( 1 )
{
result = num_super_snooped;
if ( num_super_snooped > 0 )
break;
LABEL_14:
v4 += 8;
if ( v4 == (char *)&all_players + 32000 )
return result;
}
v6 = *(_QWORD *)v4;
v7 = 0LL;
while ( 1 )
{
if ( v6 )
{
v8 = *(_QWORD *)(v6 + 8);
if ( v8 )
{
v9 = *(const char **)(v8 + 152);
if ( v9 )
{
if ( !strcmp(v9, &super_snooped[16 * v7]) )
break;
}
}
}
result = num_super_snooped;
if ( num_super_snooped <= (int)++v7 )
goto LABEL_14;
}
v4 += 8;
result = open((const char *)&super_snoopfile[4 * v7], 1089, 384LL);
*(_DWORD *)(v6 + 256) = result;
}
while ( v4 != (char *)&all_players + 32000 );
return result;
}

canonical_decompiled_code:
int func1()
{
__int64 v0; // rbx
__int64 v1; // rax
int v2; // edi
bool v3; // al
char *v4; // rbp
int result; // eax
__int64 v6; // r12
__int64 v7; // rbx
__int64 v8; // rax
const char *v9; // rdi

v0 = 1LL;
if ( num_super_snooped )
{
do
{
v1 = *((_QWORD *)&all_players + v0 - 1);
if ( v1 )
{
v2 = *(_DWORD *)(v1 + 256);
if ( v2 >= 0 )
{
close(v2);
*(_DWORD *)(*((_QWORD *)&all_players + v0 - 1) + 256LL) = -1;
--num_super_snooped;
}
}
v3 = (_DWORD)v0++ != 4000;
}
while ( v3 && num_super_snooped != 0 );
}
func0();
v4 = (char *)&all_players;
do
{
while ( 1 )
{
result = num_super_snooped;
if ( num_super_snooped > 0 )
break;
LABEL_14:
v4 += 8;
if ( v4 == (char *)&all_players + 32000 )
return result;
}
v6 = *(_QWORD *)v4;
v7 = 0LL;
while ( 1 )
{
if ( v6 )
{
v8 = *(_QWORD *)(v6 + 8);
if ( v8 )
{
v9 = *(const char **)(v8 + 152);
if ( v9 )
{
if ( !strcmp(v9, &super_snooped[16 * v7]) )
break;
}
}
}
result = num_super_snooped;
if ( num_super_snooped <= (int)++v7 )
goto LABEL_14;
}
v4 += 8;
result = open((const char *)&super_snoopfile[4 * v7], 1089, 384LL);
*(_DWORD *)(v6 + 256) = result;
}
while ( v4 != (char *)&all_players + 32000 );
return result;
}

original_code:
void
update_snoop_file()
{
    int i, j;
    for (i = 0; num_super_snooped && i < 4000; i++)
 if (all_players[i] && all_players[i]->snoop_fd >= 0) {
     (void)close(all_players[i]->snoop_fd);
     all_players[i]->snoop_fd = -1;
     num_super_snooped--;
 }
    read_snoop_file();
    for (i = 0; i < 4000; i++)
 for (j = 0; j < num_super_snooped; j++)
     if (all_players[i] && all_players[i]->ob &&
  all_players[i]->ob->living_name &&
  strcmp(all_players[i]->ob->living_name, super_snooped[j]) == 0) {
  all_players[i]->snoop_fd = open(super_snoopfile[j],
       01 | 02000 | 0100,
       0600);
  break;
     }
}

canonical_original_code:
void update_snoop_file()
{
    int i; int j;
    for (i = 0; num_super_snooped && i < 4000; i++)
 if (all_players[i] && all_players[i]->snoop_fd >= 0) {
     (void)close(all_players[i]->snoop_fd);
     all_players[i]->snoop_fd = -1;
     num_super_snooped--;
 }
    read_snoop_file();
    for (i = 0; i < 4000; i++)
 for (j = 0; j < num_super_snooped; j++)
     if (all_players[i] && all_players[i]->ob &&
  all_players[i]->ob->living_name &&
  strcmp(all_players[i]->ob->living_name, super_snooped[j]) == 0) {
  all_players[i]->snoop_fd = open(super_snoopfile[j],
       01 | 02000 | 0100,
       0600);
  break;
     }
}

variable_types: i int

variable_types: j int

return_type: void


siphash

variable_types:
key
unsigned char [16]

variable_types:
m
unsigned char *

variable_types:
len
unsigned long

variable_types:
mi
unsigned long

variable_types:
i
unsigned long

variable_types:
blocks
unsigned long

return_type: unsigned long


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // r12
FILE *v4; // rax
FILE *v5; // rbp
int v6; // er13
int v7; // er14
char *v8; // rax
const char *v9; // r15
char *v10; // rdi
int v11; // eax
char v13; // [rsp+0h] [rbp-2028h] BYREF
char s[8231]; // [rsp+1h] [rbp-2027h] BYREF

if ( argc != 3 )
{
fwrite("Usage: make_table input.h output.h\n", 1uLL, 0x23uLL, _bss_start);
exit(1);
}
v3 = fopen(argv[1], "r");
if ( !v3 || (v4 = fopen(argv[2], "w"), (v5 = v4) == 0LL) )
{
perror("fopen");
exit(1);
}
v6 = 0;
v7 = 0x7FFFFFFF;
fwrite("/*\n", 1uLL, 3uLL, v4);
fwrite(" * This file is automatically generated; do not edit.\n", 1uLL, 0x36uLL, v5);
fwrite(" */\n\n", 1uLL, 5uLL, v5);
fwrite("#ifdef EFUN_TABLE\n", 1uLL, 0x12uLL, v5);
fwrite("static void (*efun_table[])(int) = {\n", 1uLL, 0x25uLL, v5);
while ( fgets(&v13, 0x2000, v3) )
{
if ( v13 == 35 && !strcmp(strtok(s, " \t\n"), "define") )
{
v8 = strtok(0LL, " \t\n");
v9 = v8;
if ( v8 )
{
if ( *v8 == 70 && v8[1] == 95 )
{
lower(v8);
fprintf(v5, "\t%s,\n", v9);
v10 = strtok(0LL, " \t\n");
if ( v10 )
{
v11 = atoi(v10);
if ( v7 > v11 )
v7 = v11;
if ( v6 < v11 )
v6 = v11;
}
}
}
}
}
fwrite("};\n", 1uLL, 3uLL, v5);
fwrite("#else /* EFUN_TABLE */\n", 1uLL, 0x17uLL, v5);
fprintf(v5, "#define EFUN_FIRST %4d\n", (unsigned int)v7);
fprintf(v5, "#define EFUN_LAST %4d\n", (unsigned int)v6);
fwrite("#endif /* EFUN_TABLE */\n", 1uLL, 0x18uLL, v5);
fclose(v5);
fclose(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // r12
FILE *v4; // rax
FILE *v5; // rbp
int v6; // er13
int v7; // er14
char *v8; // rax
const char *v9; // r15
char *v10; // rdi
int v11; // eax
char v13; // [rsp+0h] [rbp-2028h] BYREF
char s[8231]; // [rsp+1h] [rbp-2027h] BYREF

if ( argc != 3 )
{
fwrite("Usage: make_table input.h output.h\n", 1uLL, 0x23uLL, _bss_start);
exit(1);
}
v3 = fopen(argv[1], "r");
if ( !v3 || (v4 = fopen(argv[2], "w"), (v5 = v4) == 0LL) )
{
perror("fopen");
exit(1);
}
v6 = 0;
v7 = 0x7FFFFFFF;
fwrite("/*\n", 1uLL, 3uLL, v4);
fwrite(" * This file is automatically generated; do not edit.\n", 1uLL, 0x36uLL, v5);
fwrite(" */\n\n", 1uLL, 5uLL, v5);
fwrite("#ifdef EFUN_TABLE\n", 1uLL, 0x12uLL, v5);
fwrite("static void (*efun_table[])(int) = {\n", 1uLL, 0x25uLL, v5);
while ( fgets(&v13, 0x2000, v3) )
{
if ( v13 == 35 && !strcmp(strtok(s, " \t\n"), "define") )
{
v8 = strtok(0LL, " \t\n");
v9 = v8;
if ( v8 )
{
if ( *v8 == 70 && v8[1] == 95 )
{
func7(v8);
fprintf(v5, "\t%s,\n", v9);
v10 = strtok(0LL, " \t\n");
if ( v10 )
{
v11 = atoi(v10);
if ( v7 > v11 )
v7 = v11;
if ( v6 < v11 )
v6 = v11;
}
}
}
}
}
fwrite("};\n", 1uLL, 3uLL, v5);
fwrite("#else /* EFUN_TABLE */\n", 1uLL, 0x17uLL, v5);
fprintf(v5, "#define EFUN_FIRST %4d\n", (unsigned int)v7);
fprintf(v5, "#define EFUN_LAST %4d\n", (unsigned int)v6);
fwrite("#endif /* EFUN_TABLE */\n", 1uLL, 0x18uLL, v5);
fclose(v5);
fclose(v3);
return 0;
}

original_code:
int
main(int argc, char *argv[])
{
    char buf[0x100];
    char *local_port;
    char *remote_port;
    char *addr;
    char *ptr;
    char *ident = "";
    char *reverse;
    (void)setlinebuf(stdout);
    (void)printf("\n");
    while (1)
    {
        if (fgets(buf, sizeof(buf), stdin) == ((void *)0))
            break;
        if ((ptr = strrchr(buf, '\n')))
            *ptr = '\0';
        addr = strtok(buf, ",");
        local_port = strtok(((void *)0), ",");
        remote_port = strtok(((void *)0), ",");
        if (addr == ((void *)0) || local_port == ((void *)0) || remote_port == ((void *)0))
        {
            fprintf(stderr, "Invalid input format: %s\n", buf);
            continue;
        }
        reverse = reverse_lookup(addr);
        if (reverse == ((void *)0))
            reverse = addr;
        printf("%s,%s,%s,%s,%s\n", addr, local_port, remote_port, reverse, ident);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    char buf[256];
    char *local_port;
    char *remote_port;
    char *addr;
    char *ptr;
    char *ident = "";
    char *reverse;
    (void)setlinebuf(stdout);
    (void)printf("\n");
    while (1)
    {
        if (fgets(buf, sizeof(buf), stdin) == ((void *)0))
            break;
        if ((ptr = strrchr(buf, '\n')))
            *ptr = '\0';
        addr = strtok(buf, ",");
        local_port = strtok(((void *)0), ",");
        remote_port = strtok(((void *)0), ",");
        if (addr == ((void *)0) || local_port == ((void *)0) || remote_port == ((void *)0))
        {
            fprintf(stderr, "Invalid input format: %s\n", buf);
            continue;
        }
        reverse = reverse_lookup(addr);
        if (reverse == ((void *)0))
            reverse = addr;
        printf("%s,%s,%s,%s,%s\n", addr, local_port, remote_port, reverse, ident);
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
buf
char [256]

variable_types:
addr
char *

variable_types:
ptr
char *

variable_types:
ident
char *

variable_types:
reverse
char *

return_type: int


lower

decompiled_code:
void __fastcall lower(char *a1)
{
__int64 v1; // rbx
_BYTE *v2; // rbp
const unsigned __int16 **v3; // r12

v1 = *a1;
if ( (_BYTE)v1 )
{
v2 = a1;
v3 = __ctype_b_loc();
do
{
if ( ((*v3)[v1] & 0x100) != 0 )
*v2 = (*__ctype_tolower_loc())[v1];
v1 = (char)*++v2;
}
while ( (_BYTE)v1 );
}
}

canonical_decompiled_code:
void __fastcall func7(char *a1)
{
__int64 v1; // rbx
_BYTE *v2; // rbp
const unsigned __int16 **v3; // r12

v1 = *a1;
if ( (_BYTE)v1 )
{
v2 = a1;
v3 = __ctype_b_loc();
do
{
if ( ((*v3)[v1] & 0x100) != 0 )
*v2 = (*__ctype_tolower_loc())[v1];
v1 = (char)*++v2;
}
while ( (_BYTE)v1 );
}
}

original_code:
void
lower(char *string)
{
    while (*string) {
        if (((*__ctype_b_loc ())[(int) ((*string))] & (unsigned short int) _ISupper))
     *string = tolower(*string);
 string++;
    }
}

canonical_original_code:
void lower(char *string)
{
    while (*string) {
        if (((*__ctype_b_loc ())[(int) ((*string))] & (unsigned short) _ISupper))
     *string = tolower(*string);
 string++;
    }
}

variable_types:
string
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__m128i v3; // xmm0
struct _IO_FILE *v4; // rdi
const char *v5; // rsi
__int64 v6; // rcx
__int64 v7; // rdi
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rbp
char **v11; // rax
char **v12; // rbx
__int64 v13; // rax
__int64 v15; // rax
int v16; // edx
unsigned int *v17; // rax
unsigned int v18; // ebx
unsigned int *v19; // rax
char **v20; // rbp
char *v21; // rax
long double v22; // [rsp+0h] [rbp-118h]
__int64 v23; // [rsp+20h] [rbp-F8h] BYREF
int v24; // [rsp+28h] [rbp-F0h]
jmp_buf env; // [rsp+30h] [rbp-E8h] BYREF

setlinebuf(stdout);
parse_args(argc, (char **)argv);
LOWORD(const0) = 2;
*((_QWORD *)&const0 + 1) = 0LL;
v3 = _mm_load_si128((const __m128i *)&const0);
const1 = 2;
constempty = 128;
*((_QWORD *)&const1 + 1) = 1LL;
*((_QWORD *)&constempty + 1) = funcempty;
funcempty[4] = 6;
catch_value = v3;
if ( !setlocale(6, "C") )
fprintf(stderr, "Unable to set LC_ALL to: %s.\n", "C");
v4 = 0LL;
v5 = "en_US.ISO-8859-1";
if ( !setlocale(0, "en_US.ISO-8859-1") )
{
v4 = stderr;
v5 = "Unable to set LC_CTYPE to: %s.\n";
fprintf(stderr, "Unable to set LC_CTYPE to: %s.\n", "en_US.ISO-8859-1");
}
set_current_time();
v22 = 60.0;
set_profile_timebase(v4, v5, DWORD2(v22), v6);
reserved_area = (__int64)malloc(0x1000000uLL);
init_random();
init_tasks();
query_load_av();
init_num_args();
init_machine();
init_cfuns();
init_hash();
init_signals();
if ( chdir(mudlib_path) == -1 )
{
fprintf(stderr, "Bad mudlib directory: %s\n", "/home/mud/genesis/lib");
goto LABEL_26;
}
if ( setjmp(env) )
{
clear_state();
add_message("Anomaly in the fabric of world space.\n");
}
else
{
v24 = 0;
v23 = 0LL;
exception = &v23;
auto_ob = 0LL;
master_ob = 0LL;
auto_ob = load_object("secure/auto", 1LL, 0LL, 0LL);
v7 = auto_ob;
if ( auto_ob )
{
add_ref(auto_ob, "main");
*(_BYTE *)(*(_QWORD *)(auto_ob + 16LL) + 232LL) |= 8u;
}
get_simul_efun(v7);
master_ob = load_object("secure/master", 1LL, 0LL, 0LL);
if ( master_ob )
{
add_ref(master_ob, "main");
*(_BYTE *)(*(_QWORD *)(master_ob + 16LL) + 232LL) |= 8u;
resolve_master_fkntab();
create_object(master_ob);
load_parse_information();
clear_state();
}
}
exception = 0LL;
if ( !auto_ob )
{
fwrite("The file secure/auto must be loadable.\n", 1uLL, 0x27uLL, stderr);
goto LABEL_26;
}
if ( !master_ob )
{
fwrite("The file secure/master must be loadable.\n", 1uLL, 0x29uLL, stderr);
goto LABEL_26;
}
v8 = apply_master_ob(35LL, 0LL);
set_inc_list(v8);
v9 = apply_master_ob(36LL, 0LL);
v10 = v9;
if ( v9 )
{
if ( *(_WORD *)v9 == 8 )
{
v17 = *(unsigned int **)(v9 + 8);
if ( *v17 )
{
v18 = 0;
do
{
v19 = &v17[4 * v18];
if ( *((_WORD *)v19 + 4) == 4 )
add_pre_define(*((_QWORD *)v19 + 2));
v17 = *(unsigned int **)(v10 + 8);
++v18;
}
while ( *v17 > v18 );
}
}
}
if ( flag )
{
printf("Applying driver flag: %s\n", (const char *)flag);
push_string(flag, 0LL);
apply_master_ob(0LL, 1LL);
if ( game_is_being_shut_down )
{
fwrite("Shutdown by master object.\n", 1uLL, 0x1BuLL, stderr);
exit(0);
}
}
v11 = (char **)apply_master_ob(34LL, 0LL);
v12 = v11;
if ( v11 && *(_WORD *)v11 == 4 )
{
v20 = (char **)xalloc(16LL);
if ( !v20 )
{
fatal("xalloc failed\n");
JUMPOUT(0x1017LL);
}
*v20 = string_copy(v12[1]);
v21 = (char *)lpc_predefs;
lpc_predefs = v20;
v20[1] = v21;
}
v13 = apply_master_ob(44LL, 0LL);
if ( v13 && *(_WORD *)v13 == 16 )
{
v15 = *(_QWORD *)(v13 + 8);
v16 = *(_DWORD *)(v15 + 12);
vbfc_object = v15;
if ( v16 )
*(_DWORD *)(v15 + 12) = v16 + 1;
}
else
{
vbfc_object = 0LL;
}
if ( game_is_being_shut_down )
LABEL_26:
exit(1);
init_call_out();
preload_objects((unsigned int)e_flag);
apply_master_ob(3LL, 0LL);
mainloop();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__m128i v3; // xmm0
struct _IO_FILE *v4; // rdi
const char *v5; // rsi
__int64 v6; // rcx
__int64 v7; // rdi
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rbp
char **v11; // rax
char **v12; // rbx
__int64 v13; // rax
__int64 v15; // rax
int v16; // edx
unsigned int *v17; // rax
unsigned int v18; // ebx
unsigned int *v19; // rax
char **v20; // rbp
char *v21; // rax
long double v22; // [rsp+0h] [rbp-118h]
__int64 v23; // [rsp+20h] [rbp-F8h] BYREF
int v24; // [rsp+28h] [rbp-F0h]
jmp_buf env; // [rsp+30h] [rbp-E8h] BYREF

setlinebuf(stdout);
func1(argc, (char **)argv);
LOWORD(const0) = 2;
*((_QWORD *)&const0 + 1) = 0LL;
v3 = _mm_load_si128((const __m128i *)&const0);
const1 = 2;
constempty = 128;
*((_QWORD *)&const1 + 1) = 1LL;
*((_QWORD *)&constempty + 1) = funcempty;
funcempty[4] = 6;
catch_value = v3;
if ( !setlocale(6, "C") )
fprintf(stderr, "Unable to set LC_ALL to: %s.\n", "C");
v4 = 0LL;
v5 = "en_US.ISO-8859-1";
if ( !setlocale(0, "en_US.ISO-8859-1") )
{
v4 = stderr;
v5 = "Unable to set LC_CTYPE to: %s.\n";
fprintf(stderr, "Unable to set LC_CTYPE to: %s.\n", "en_US.ISO-8859-1");
}
set_current_time();
v22 = 60.0;
set_profile_timebase(v4, v5, DWORD2(v22), v6);
reserved_area = (__int64)malloc(0x1000000uLL);
init_random();
init_tasks();
query_load_av();
init_num_args();
init_machine();
init_cfuns();
init_hash();
init_signals();
if ( chdir(mudlib_path) == -1 )
{
fprintf(stderr, "Bad mudlib directory: %s\n", "/home/mud/genesis/lib");
goto LABEL_26;
}
if ( setjmp(env) )
{
clear_state();
add_message("Anomaly in the fabric of world space.\n");
}
else
{
v24 = 0;
v23 = 0LL;
exception = &v23;
auto_ob = 0LL;
master_ob = 0LL;
auto_ob = load_object("secure/auto", 1LL, 0LL, 0LL);
v7 = auto_ob;
if ( auto_ob )
{
add_ref(auto_ob, "main");
*(_BYTE *)(*(_QWORD *)(auto_ob + 16LL) + 232LL) |= 8u;
}
get_simul_efun(v7);
master_ob = load_object("secure/master", 1LL, 0LL, 0LL);
if ( master_ob )
{
add_ref(master_ob, "main");
*(_BYTE *)(*(_QWORD *)(master_ob + 16LL) + 232LL) |= 8u;
resolve_master_fkntab();
create_object(master_ob);
load_parse_information();
clear_state();
}
}
exception = 0LL;
if ( !auto_ob )
{
fwrite("The file secure/auto must be loadable.\n", 1uLL, 0x27uLL, stderr);
goto LABEL_26;
}
if ( !master_ob )
{
fwrite("The file secure/master must be loadable.\n", 1uLL, 0x29uLL, stderr);
goto LABEL_26;
}
v8 = apply_master_ob(35LL, 0LL);
set_inc_list(v8);
v9 = apply_master_ob(36LL, 0LL);
v10 = v9;
if ( v9 )
{
if ( *(_WORD *)v9 == 8 )
{
v17 = *(unsigned int **)(v9 + 8);
if ( *v17 )
{
v18 = 0;
do
{
v19 = &v17[4 * v18];
if ( *((_WORD *)v19 + 4) == 4 )
add_pre_define(*((_QWORD *)v19 + 2));
v17 = *(unsigned int **)(v10 + 8);
++v18;
}
while ( *v17 > v18 );
}
}
}
if ( flag )
{
printf("Applying driver flag: %s\n", (const char *)flag);
push_string(flag, 0LL);
apply_master_ob(0LL, 1LL);
if ( game_is_being_shut_down )
{
fwrite("Shutdown by master object.\n", 1uLL, 0x1BuLL, stderr);
exit(0);
}
}
v11 = (char **)apply_master_ob(34LL, 0LL);
v12 = v11;
if ( v11 && *(_WORD *)v11 == 4 )
{
v20 = (char **)xalloc(16LL);
if ( !v20 )
{
fatal("xalloc failed\n");
JUMPOUT(0x1017LL);
}
*v20 = func2(v12[1]);
v21 = (char *)lpc_predefs;
lpc_predefs = v20;
v20[1] = v21;
}
v13 = apply_master_ob(44LL, 0LL);
if ( v13 && *(_WORD *)v13 == 16 )
{
v15 = *(_QWORD *)(v13 + 8);
v16 = *(_DWORD *)(v15 + 12);
vbfc_object = v15;
if ( v16 )
*(_DWORD *)(v15 + 12) = v16 + 1;
}
else
{
vbfc_object = 0LL;
}
if ( game_is_being_shut_down )
LABEL_26:
exit(1);
init_call_out();
preload_objects((unsigned int)e_flag);
apply_master_ob(3LL, 0LL);
mainloop();
return 0;
}


lower

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

result = a1 + 32;
if ( (char)a1 >= 96 )
result = a1;
return result;
}

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

result = a1 + 32;
if ( (char)a1 >= 96 )
result = a1;
return result;
}


LoadTGA

repo: courtc/imager

original_code:
int LoadTGA(void *pRaw, int rawlen, unsigned int *puWidth, unsigned int *puHeight, void **ppData)
{
 TGAHDR_t hdr;
 memcpy(&hdr,pRaw,sizeof(TGAHDR_t));
 if( hdr.colourmaptype != 0 ) {
  return -10;
 }
 if( hdr.imagetype != 2 ) {
  return -11;
 }
 if( hdr.bits != 32 ) {
  return -12;
 }
 *puWidth = hdr.width;
 *puHeight = hdr.height;
 *ppData = malloc(hdr.width*hdr.height*4);
 memcpy(*ppData,(uint8*)pRaw + sizeof(TGAHDR_t) + hdr.identsize,rawlen - (sizeof(TGAHDR_t) + hdr.identsize));
 return 0;
}

canonical_original_code:
int LoadTGA(void *pRaw, int rawlen, unsigned int *puWidth, unsigned int *puHeight, void **ppData)
{
 struct TGAHDR_t hdr;
 memcpy(&hdr,pRaw,sizeof(TGAHDR_t));
 if( hdr.colourmaptype != 0 ) {
  return -10;
 }
 if( hdr.imagetype != 2 ) {
  return -11;
 }
 if( hdr.bits != 32 ) {
  return -12;
 }
 *puWidth = hdr.width;
 *puHeight = hdr.height;
 *ppData = malloc(hdr.width*hdr.height*4);
 memcpy(*ppData,(unsigned char *)pRaw + sizeof(TGAHDR_t) + hdr.identsize,rawlen - (sizeof(TGAHDR_t) + hdr.identsize));
 return 0;
}

variable_types:
pRaw
void *

variable_types: rawlen int

variable_types:
puWidth
unsigned int *

variable_types:
puHeight
unsigned int *

variable_types:
ppData
void **

variable_types: struct TGAHDR_t { unsigned char identsize; unsigned char colourmaptype; unsigned char imagetype; unsigned short colourmapstart; unsigned short colourmaplength; unsigned char colourmapbits; short xstart; short ystart; unsigned short width; unsigned short height; unsigned char bits; unsigned char descriptor; }


decompiled_code:
__int64 __fastcall ringbuffer_create(__int64 a1, unsigned int a2)
{
void *v2; // rax
__int64 result; // rax

v2 = malloc(a2);
*(_QWORD *)(a1 + 16) = v2;
if ( !v2 )
return 0xFFFFFFFFLL;
*(_DWORD *)a1 = a2;
result = 0LL;
*(_QWORD *)(a1 + 4) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2)
{
void *v2; // rax
__int64 result; // rax

v2 = malloc(a2);
*(_QWORD *)(a1 + 16) = v2;
if ( !v2 )
return 0xFFFFFFFFLL;
*(_DWORD *)a1 = a2;
result = 0LL;
*(_QWORD *)(a1 + 4) = 0LL;
return result;
}

original_code:
int ringbuffer_create(ringbuffer_t *buf, unsigned int size)
{
 buf->data = malloc(size);
 if (buf->data == ((void *)0))
  return -1;
 buf->size = size;
 buf->in = 0;
 buf->out = 0;
 return 0;
}

canonical_original_code:
int ringbuffer_create(struct ringbuffer *buf, unsigned int size)
{
 buf->data = malloc(size);
 if (buf->data == ((void *)0))
  return -1;
 buf->size = size;
 buf->in = 0;
 buf->out = 0;
 return 0;
}

variable_types: struct ringbuffer { unsigned int size; unsigned int in; unsigned int out; void *data; } *

variable_types:
size
unsigned int


decompiled_code:
void __fastcall ringbuffer_destroy(__int64 a1)
{
free(*(void **)(a1 + 16));
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
free(*(void **)(a1 + 16));
}

original_code:
void ringbuffer_destroy(ringbuffer_t *buf)
{
 free(buf->data);
}

canonical_original_code:
void ringbuffer_destroy(struct ringbuffer *buf)
{
 free(buf->data);
}

user_defined_types: struct ringbuffer { unsigned int size; unsigned int in; unsigned int out; void *data; }


decompiled_code:
void __fastcall ringbuffer_flush(__int64 a1)
{
*(_QWORD *)(a1 + 4) = 0LL;
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
*(_QWORD *)(a1 + 4) = 0LL;
}

original_code:
void ringbuffer_flush(ringbuffer_t *buf)
{
 buf->in = 0;
 buf->out = 0;
}

canonical_original_code:
void ringbuffer_flush(struct ringbuffer *buf)
{
 buf->in = 0;
 buf->out = 0;
}


decompiled_code:
__int64 __fastcall ringbuffer_empty(_DWORD *a1)
{
unsigned int v1; // edx
unsigned int v2; // eax

v1 = a1[1];
v2 = a1[2];
if ( v1 >= v2 )
v2 += *a1;
return v2 - v1;
}

canonical_decompiled_code:
__int64 __fastcall func3(_DWORD *a1)
{
unsigned int v1; // edx
unsigned int v2; // eax

v1 = a1[1];
v2 = a1[2];
if ( v1 >= v2 )
v2 += *a1;
return v2 - v1;
}

original_code:
unsigned int ringbuffer_empty(ringbuffer_t *buf)
{
 if (buf->in < buf->out)
  return buf->out - buf->in;
 else
  return buf->size - (buf->in - buf->out);
}

canonical_original_code:
unsigned int ringbuffer_empty(struct ringbuffer *buf)
{
 if (buf->in < buf->out)
  return buf->out - buf->in;
 else
  return buf->size - (buf->in - buf->out);
}

return_type: unsigned int


decompiled_code:
__int64 __fastcall ringbuffer_full(_DWORD *a1)
{
unsigned int v1; // eax
unsigned int v2; // edx

v1 = a1[1];
v2 = a1[2];
if ( v1 < v2 )
v1 += *a1;
return v1 - v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(_DWORD *a1)
{
unsigned int v1; // eax
unsigned int v2; // edx

v1 = a1[1];
v2 = a1[2];
if ( v1 < v2 )
v1 += *a1;
return v1 - v2;
}

original_code:
unsigned int ringbuffer_full(ringbuffer_t *buf)
{
 if (buf->in >= buf->out)
  return buf->in - buf->out;
 else
  return buf->size - (buf->out - buf->in);
}

canonical_original_code:
unsigned int ringbuffer_full(struct ringbuffer *buf)
{
 if (buf->in >= buf->out)
  return buf->in - buf->out;
 else
  return buf->size - (buf->out - buf->in);
}


decompiled_code:
__int64 __fastcall ringbuffer_write(__int64 a1, char *a2, unsigned int a3)
{
unsigned int v4; // eax
__int64 result; // rax
char *v7; // r14
unsigned int v9; // esi
char *v10; // rdi

v4 = ringbuffer_empty((_DWORD *)a1);
if ( v4 <= a3 )
a3 = v4;
result = 0LL;
if ( a3 )
{
v7 = *(char **)(a1 + 16);
v9 = *(_DWORD *)a1 - *(_DWORD *)(a1 + 4);
v10 = &v7[*(unsigned int *)(a1 + 4)];
if ( v9 <= a3 )
{
memcpy(v10, a2, v9);
memcpy(v7, &a2[v9], a3 + *(_DWORD *)(a1 + 4) - *(_DWORD *)a1);
*(_DWORD *)(a1 + 4) = a3 + *(_DWORD *)(a1 + 4) - *(_DWORD *)a1;
result = a3;
}
else
{
memcpy(v10, a2, a3);
*(_DWORD *)(a1 + 4) += a3;
result = a3;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, char *a2, unsigned int a3)
{
unsigned int v4; // eax
__int64 result; // rax
char *v7; // r14
unsigned int v9; // esi
char *v10; // rdi

v4 = func3((_DWORD *)a1);
if ( v4 <= a3 )
a3 = v4;
result = 0LL;
if ( a3 )
{
v7 = *(char **)(a1 + 16);
v9 = *(_DWORD *)a1 - *(_DWORD *)(a1 + 4);
v10 = &v7[*(unsigned int *)(a1 + 4)];
if ( v9 <= a3 )
{
memcpy(v10, a2, v9);
memcpy(v7, &a2[v9], a3 + *(_DWORD *)(a1 + 4) - *(_DWORD *)a1);
*(_DWORD *)(a1 + 4) = a3 + *(_DWORD *)(a1 + 4) - *(_DWORD *)a1;
result = a3;
}
else
{
memcpy(v10, a2, a3);
*(_DWORD *)(a1 + 4) += a3;
result = a3;
}
}
return result;
}

original_code:
int ringbuffer_write(ringbuffer_t *buf, const void *data, unsigned int size)
{
 char *b = (char *)buf->data;
 unsigned int left = ringbuffer_empty(buf);
 unsigned int wlen = (((size)<(left))?(size):(left));
 char *to = b + buf->in;
 if (wlen == 0) {
  return 0;
 } else if (wlen < (buf->size - buf->in)) {
  memcpy(to, data, wlen);
  buf->in += wlen;
 } else {
  const char *d2 = (const char *)data + (buf->size - buf->in);
  memcpy(to, data, buf->size - buf->in);
  memcpy(b, d2, wlen - (buf->size - buf->in));
  buf->in = wlen - (buf->size - buf->in);
 }
 return wlen;
}

canonical_original_code:
int ringbuffer_write(struct ringbuffer *buf, void *data, unsigned int size)
{
 char *b = (char *)buf->data;
 unsigned int left = ringbuffer_empty(buf);
 unsigned int wlen = (((size)<(left))?(size):(left));
 char *to = b + buf->in;
 if (wlen == 0) {
  return 0;
 } else if (wlen < (buf->size - buf->in)) {
  memcpy(to, data, wlen);
  buf->in += wlen;
 } else {
  char *d2 = (const char *)data + (buf->size - buf->in);
  memcpy(to, data, buf->size - buf->in);
  memcpy(b, d2, wlen - (buf->size - buf->in));
  buf->in = wlen - (buf->size - buf->in);
 }
 return wlen;
}

variable_types:
data
void *

variable_types:
b
char *

variable_types:
left
unsigned int

variable_types:
wlen
unsigned int

variable_types:
to
char *


decompiled_code:
__int64 __fastcall ringbuffer_read(__int64 a1, char *a2, unsigned int a3)
{
unsigned int v4; // eax
__int64 result; // rax
char *v6; // r14
__int64 v9; // rsi
unsigned int v10; // edi
char *v11; // rsi

v4 = ringbuffer_full((_DWORD *)a1);
if ( v4 <= a3 )
a3 = v4;
result = 0LL;
if ( a3 )
{
v6 = *(char **)(a1 + 16);
v9 = *(unsigned int *)(a1 + 8);
v10 = *(_DWORD *)a1 - *(_DWORD *)(a1 + 8);
v11 = &v6[v9];
if ( v10 <= a3 )
{
memcpy(a2, v11, v10);
memcpy(&a2[v10], v6, a3 + *(_DWORD *)(a1 + 8) - *(_DWORD *)a1);
*(_DWORD *)(a1 + 8) = a3 + *(_DWORD *)(a1 + 8) - *(_DWORD *)a1;
result = a3;
}
else
{
memcpy(a2, v11, a3);
*(_DWORD *)(a1 + 8) += a3;
result = a3;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, char *a2, unsigned int a3)
{
unsigned int v4; // eax
__int64 result; // rax
char *v6; // r14
__int64 v9; // rsi
unsigned int v10; // edi
char *v11; // rsi

v4 = func4((_DWORD *)a1);
if ( v4 <= a3 )
a3 = v4;
result = 0LL;
if ( a3 )
{
v6 = *(char **)(a1 + 16);
v9 = *(unsigned int *)(a1 + 8);
v10 = *(_DWORD *)a1 - *(_DWORD *)(a1 + 8);
v11 = &v6[v9];
if ( v10 <= a3 )
{
memcpy(a2, v11, v10);
memcpy(&a2[v10], v6, a3 + *(_DWORD *)(a1 + 8) - *(_DWORD *)a1);
*(_DWORD *)(a1 + 8) = a3 + *(_DWORD *)(a1 + 8) - *(_DWORD *)a1;
result = a3;
}
else
{
memcpy(a2, v11, a3);
*(_DWORD *)(a1 + 8) += a3;
result = a3;
}
}
return result;
}

original_code:
int ringbuffer_read(ringbuffer_t *buf, void *data, unsigned int size)
{
 const char *b = (const char *)buf->data;
 unsigned int left = ringbuffer_full(buf);
 unsigned int rlen = (((size)<(left))?(size):(left));
 const char *from = b + buf->out;
 if (rlen == 0) {
  return 0;
 } else if (rlen < (buf->size - buf->out)) {
  memcpy(data, from, rlen);
  buf->out += rlen;
 } else {
  char *d2 = (char *)data + (buf->size - buf->out);
  memcpy(data, from, buf->size - buf->out);
  memcpy(d2, b, rlen - (buf->size - buf->out));
  buf->out = rlen - (buf->size - buf->out);
 }
 return rlen;
}

canonical_original_code:
int ringbuffer_read(struct ringbuffer *buf, void *data, unsigned int size)
{
 char *b = (const char *)buf->data;
 unsigned int left = ringbuffer_full(buf);
 unsigned int rlen = (((size)<(left))?(size):(left));
 char *from = b + buf->out;
 if (rlen == 0) {
  return 0;
 } else if (rlen < (buf->size - buf->out)) {
  memcpy(data, from, rlen);
  buf->out += rlen;
 } else {
  char *d2 = (char *)data + (buf->size - buf->out);
  memcpy(data, from, buf->size - buf->out);
  memcpy(d2, b, rlen - (buf->size - buf->out));
  buf->out = rlen - (buf->size - buf->out);
 }
 return rlen;
}

variable_types:
rlen
unsigned int

variable_types:
from
char *


decompiled_code:
__int64 __fastcall mime_matches_magicx(__int64 a1, unsigned int a2, __int64 a3, int a4)
{
__int64 v4; // r13
unsigned int v5; // er15
_BOOL4 v6; // eax
int v7; // edx
int v8; // eax
size_t v9; // r14
__int64 v10; // rcx
__int64 i; // rax
__int64 v13; // [rsp+8h] [rbp-60h]
char s1[88]; // [rsp+10h] [rbp-58h] BYREF

if ( a4 <= 0 )
return a2;
v4 = a3;
v5 = a2;
v13 = a3 + 24LL * (unsigned int)(a4 - 1) + 24;
do
{
v9 = *(unsigned int *)(v4 + 16);
memcpy(s1, (const void *)(a1 + *(unsigned int *)(v4 + 20)), v9);
v10 = *(_QWORD *)(v4 + 8);
if ( v10 && (_DWORD)v9 )
{
for ( i = 0LL; i != v9; ++i )
s1[i] &= *(_BYTE *)(v10 + i);
}
v6 = memcmp(s1, *(const void **)v4, v9) == 0;
v7 = v6 & v5;
v8 = v5 | v6;
if ( !a2 )
v7 = v8;
v5 = v7;
if ( v7 != a2 )
break;
v4 += 24LL;
}
while ( v13 != v4 );
return v5;
}

original_code:
static int mime_matches_magicx(char *text, int or0_and1,
  const struct magic *m, int count)
{
 char buf[32];
 int match = or0_and1;
 int i;
 for (i = 0; i < count; ++i) {
  int res;
  memcpy(buf, text + m[i].off, m[i].len);
  if (m[i].mask != ((void *)0)) {
   unsigned int j;
   for (j = 0; j < m[i].len; ++j)
    buf[j] &= m[i].mask[j];
  }
  res = !memcmp(buf, m[i].magic, m[i].len);
  if (or0_and1)
   match &= res;
  else
   match |= res;
  if (match != or0_and1)
   break;
 }
 return match;
}

canonical_original_code:
static int mime_matches_magicx(char *text, int or0_and1, struct magic *m, int count)
{
 char buf[32];
 int match = or0_and1;
 int i;
 for (i = 0; i < count; ++i) {
  int res;
  memcpy(buf, text + m[i].off, m[i].len);
  if (m[i].mask != ((void *)0)) {
   unsigned int j;
   for (j = 0; j < m[i].len; ++j)
    buf[j] &= m[i].mask[j];
  }
  res = !memcmp(buf, m[i].magic, m[i].len);
  if (or0_and1)
   match &= res;
  else
   match |= res;
  if (match != or0_and1)
   break;
 }
 return match;
}

variable_types:
text
char *

variable_types: struct magic { char *magic; char *mask; unsigned int len; unsigned int off; } *

variable_types: count int

variable_types:
buf
char [32]

variable_types: match int

variable_types: i int

variable_types: res int

variable_types:
j
unsigned int


LoadJPEG

decompiled_code:
__int64 __fastcall LoadJPEG(__int64 a1, unsigned int a2, _DWORD *a3, _DWORD *a4, _QWORD *a5)
{
_QWORD *v8; // rax

v8 = jpeg_decode(a1, a2);
if ( !v8 )
return 0xFFFFFFFFLL;
*a3 = *(_DWORD *)v8;
*a4 = *((_DWORD *)v8 + 1);
*a5 = v8[1];
free(v8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned int a2, _DWORD *a3, _DWORD *a4, _QWORD *a5)
{
_QWORD *v8; // rax

v8 = jpeg_decode(a1, a2);
if ( !v8 )
return 0xFFFFFFFFLL;
*a3 = *(_DWORD *)v8;
*a4 = *((_DWORD *)v8 + 1);
*a5 = v8[1];
free(v8);
return 0LL;
}

original_code:
int LoadJPEG(void *pRaw, int rawlen, unsigned int *puWidth, unsigned int *puHeight, void **ppData) {
  decjpeg_t *pJPEG;
  pJPEG = jpeg_decode(pRaw,rawlen);
  if( pJPEG == ((void *)0) )
    return -1;
  *puWidth = pJPEG->width;
  *puHeight = pJPEG->height;
  *ppData = pJPEG->pData;
  free(pJPEG);
  return 0;
}

canonical_original_code:
int LoadJPEG(void *pRaw, int rawlen, unsigned int *puWidth, unsigned int *puHeight, void **ppData) {
  struct decjpeg_t *pJPEG;
  pJPEG = jpeg_decode(pRaw,rawlen);
  if( pJPEG == ((void *)0) )
    return -1;
  *puWidth = pJPEG->width;
  *puHeight = pJPEG->height;
  *ppData = pJPEG->pData;
  free(pJPEG);
  return 0;
}

variable_types:
pRaw
void *

variable_types: rawlen int

variable_types:
puWidth
unsigned int *

variable_types:
puHeight
unsigned int *

variable_types:
ppData
void **

variable_types: struct decjpeg_t { int width; void *pData; } *


repo: coverclock/com-diag-diminuto

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

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

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

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

if ( kill(a1, 2) < 0 )
{
diminuto_log_perror("src/diminuto_interrupter.c", 35LL, "diminuto_interrupter_signal: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_interrupter_debug[0];
if ( diminuto_interrupter_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_interrupter_signal: SIGINT");
result = 0LL;
}
}
}
return result;
}

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

if ( kill(a1, 2) < 0 )
{
diminuto_log_perror("src/diminuto_interrupter.c", 35LL, "diminuto_interrupter_signal: kill");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_interrupter_debug[0];
if ( diminuto_interrupter_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_interrupter_signal: SIGINT");
result = 0LL;
}
}
}
return result;
}

original_code:
int diminuto_interrupter_signal(pid_t pid)
{
    int rc = 0;
    if (kill(pid, 2) < 0) {
        diminuto_log_perror("src/diminuto_interrupter.c", 35, "diminuto_interrupter_signal: kill");
        rc = -1;
    } else if (diminuto_interrupter_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_interrupter_signal: SIGINT") : ((void)0));
    } else {
    }
    return rc;
}

canonical_original_code:
int diminuto_interrupter_signal(int pid)
{
    int rc = 0;
    if (kill(pid, 2) < 0) {
        diminuto_log_perror("src/diminuto_interrupter.c", 35, "diminuto_interrupter_signal: kill");
        rc = -1;
    } else if (diminuto_interrupter_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_interrupter_signal: SIGINT") : ((void)0));
    } else {
    }
    return rc;
}

variable_types: pid int

variable_types: rc int


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

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

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

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

original_code:
int diminuto_interrupter_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[] = { 2 }; 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_interrupter_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_interrupter_check: SIGINT") : ((void)0));
    } else {
    }
    return mysignaled;
}

canonical_original_code:
int diminuto_interrupter_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[] = { 2 }; 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_interrupter_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_interrupter_check: SIGINT") : ((void)0));
    } else {
    }
    return mysignaled;
}

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

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

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

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

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


decompiled_code:
__int64 __fastcall diminuto_interrupter_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_interrupter_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(2, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_interrupter.c", 95LL, "diminuto_interrupter_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_interrupter_debug[0];
if ( diminuto_interrupter_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_interrupter_install: SIGINT");
result = 0LL;
}
}
}
signaled = 0;
return result;
}

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

v1 = a1;
memset(&v3.sa_mask, 0, 0x90uLL);
v3.sa_handler = diminuto_interrupter_handler;
if ( a1 )
v1 = 0x10000000;
v3.sa_flags = v1;
if ( sigaction(2, &v3, 0LL) < 0 )
{
diminuto_log_perror("src/diminuto_interrupter.c", 95LL, "diminuto_interrupter_install: sigaction");
result = 0xFFFFFFFFLL;
}
else
{
result = diminuto_interrupter_debug[0];
if ( diminuto_interrupter_debug[0] )
{
result = diminuto_log_mask & 1;
if ( (diminuto_log_mask & 1) != 0 )
{
diminuto_log_log(7LL, "diminuto_interrupter_install: SIGINT");
result = 0LL;
}
}
}
signaled = 0;
return result;
}

original_code:
int diminuto_interrupter_install(int restart)
{
    int rc = 0;
    struct sigaction interrupter = { 0 };
    interrupter.__sigaction_handler.sa_handler = diminuto_interrupter_handler;
    interrupter.sa_flags = restart ? 0x10000000 : 0;
    if (sigaction(2, &interrupter, (struct sigaction *)0) < 0) {
        diminuto_log_perror("src/diminuto_interrupter.c", 95, "diminuto_interrupter_install: sigaction");
        rc = -1;
    } else if (diminuto_interrupter_debug) {
        ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_DEBUG)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_DEBUG, "diminuto_interrupter_install: SIGINT") : ((void)0));
    } else {
    }
    signaled = 0;
    return rc;
}

variable_types: restart int

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

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

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


decompiled_code:
__int64 f9()
{
unsigned int v0; // er12

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v0 = diminuto_stacktrace();
if ( (diminuto_log_mask & 2) == 0 )
return v0;
}
else
{
v0 = diminuto_stacktrace();
if ( (diminuto_log_mask & 2) == 0 )
return v0;
}
diminuto_log_log();
return v0;
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v0; // er12

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v0 = diminuto_stacktrace();
if ( (diminuto_log_mask & 2) == 0 )
return v0;
}
else
{
v0 = diminuto_stacktrace();
if ( (diminuto_log_mask & 2) == 0 )
return v0;
}
diminuto_log_log();
return v0;
}

original_code:
int f9(void) {
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "19" ": " "CHECKPOINT: " "f%d\n", 9) : ((void)0));;
    rc = diminuto_stacktrace();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "21" ": " "CHECKPOINT: " "f%d %d\n", 9, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f9() {
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "19" ": " "CHECKPOINT: " "f%d\n", 9) : ((void)0));;
    rc = diminuto_stacktrace();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "21" ": " "CHECKPOINT: " "f%d %d\n", 9, rc) : ((void)0));;
    return rc;
}


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f9(6LL, "tst/unittest-stacktrace.c@27: CHECKPOINT: f%d\n", v4);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f9(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func7(6LL, "tst/unittest-stacktrace.c@27: CHECKPOINT: f%d\n", v4);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func7(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f8(void) {
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "27" ": " "CHECKPOINT: " "f%d\n", 8) : ((void)0));;
    rc = f9();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "29" ": " "CHECKPOINT: " "f%d %d\n", 8, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f8() {
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "27" ": " "CHECKPOINT: " "f%d\n", 8) : ((void)0));;
    rc = f9();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "29" ": " "CHECKPOINT: " "f%d %d\n", 8, rc) : ((void)0));;
    return rc;
}


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f8(6LL, "tst/unittest-stacktrace.c@35: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f8(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func8(6LL, "tst/unittest-stacktrace.c@35: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func8(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f7(void) {
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "35" ": " "CHECKPOINT: " "f%d\n", 7) : ((void)0));;
    rc = f8();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "37" ": " "CHECKPOINT: " "f%d %d\n", 7, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f7() {
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "35" ": " "CHECKPOINT: " "f%d\n", 7) : ((void)0));;
    rc = f8();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "37" ": " "CHECKPOINT: " "f%d %d\n", 7, rc) : ((void)0));;
    return rc;
}


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f7(6LL, "tst/unittest-stacktrace.c@43: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f7(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func9(6LL, "tst/unittest-stacktrace.c@43: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func9(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f6(void) {
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "43" ": " "CHECKPOINT: " "f%d\n", 6) : ((void)0));;
    rc = f7();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "45" ": " "CHECKPOINT: " "f%d %d\n", 6, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f6() {
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "43" ": " "CHECKPOINT: " "f%d\n", 6) : ((void)0));;
    rc = f7();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "45" ": " "CHECKPOINT: " "f%d %d\n", 6, rc) : ((void)0));;
    return rc;
}


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f1(6LL, "tst/unittest-stacktrace.c@97: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f1(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func15(6LL, "tst/unittest-stacktrace.c@97: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func15(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f0(void)
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "97" ": " "CHECKPOINT: " "f%d\n", 0) : ((void)0));;
    rc = f1();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "99" ": " "CHECKPOINT: " "f%d %d\n", 0, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f0()
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "97" ": " "CHECKPOINT: " "f%d\n", 0) : ((void)0));;
    rc = f1();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "99" ": " "CHECKPOINT: " "f%d %d\n", 0, rc) : ((void)0));;
    return rc;
}


main

decompiled_code:
// local variable allocation has failed, the output may be wrong!
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
char v3; // dl
int v4; // ebx
int v5; // ebx
int v6; // edi

diminuto_unittest_setlogmask();
v3 = diminuto_log_mask;
if ( (diminuto_log_mask & 4) != 0 )
{
argv = (const char **)"tst/unittest-stacktrace.c@107: SETLOGMASK: logmask=0x%x\n";
*(_QWORD *)&argc = 5LL;
diminuto_log_log();
v3 = diminuto_log_mask;
}
if ( (v3 & 2) != 0 )
{
argv = (const char **)"tst/unittest-stacktrace.c@109: CHECKPOINT: main\n";
*(_QWORD *)&argc = 6LL;
diminuto_log_log();
}
v4 = f0(*(_QWORD *)&argc, argv);
if ( (diminuto_log_mask & 2) != 0 )
diminuto_log_log();
if ( v4 < 0 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
v5 = diminuto_unittest_errors;
if ( (diminuto_log_mask & 4) != 0 )
diminuto_log_log();
diminuto_unittest_flush();
v6 = 255;
if ( v5 <= 255 )
v6 = v5;
exit(v6);
}

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

diminuto_unittest_setlogmask();
v3 = diminuto_log_mask;
if ( (diminuto_log_mask & 4) != 0 )
{
argv = (const char **)"tst/unittest-stacktrace.c@107: SETLOGMASK: logmask=0x%x\n";
*(_QWORD *)&argc = 5LL;
diminuto_log_log();
v3 = diminuto_log_mask;
}
if ( (v3 & 2) != 0 )
{
argv = (const char **)"tst/unittest-stacktrace.c@109: CHECKPOINT: main\n";
*(_QWORD *)&argc = 6LL;
diminuto_log_log();
}
v4 = func16(*(_QWORD *)&argc, argv);
if ( (diminuto_log_mask & 2) != 0 )
diminuto_log_log();
if ( v4 < 0 )
{
__errno_location();
diminuto_unittest_error();
if ( (diminuto_log_mask & 0x10) != 0 )
diminuto_log_log();
diminuto_stacktrace();
diminuto_unittest_flush();
diminuto_core_fatal();
}
v5 = diminuto_unittest_errors;
if ( (diminuto_log_mask & 4) != 0 )
diminuto_log_log();
diminuto_unittest_flush();
v6 = 255;
if ( v5 <= 255 )
v6 = v5;
exit(v6);
}

original_code:
int main(int argc, char ** argv)
{
    int count;
    do { diminuto_unittest_setlogmask(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-stacktrace.c" "@" "107" ": " "SETLOGMASK: logmask=0x%x\n", diminuto_log_mask) : ((void)0)); } while (0);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "109" ": " "CHECKPOINT: " "main\n") : ((void)0));;
    count = f0();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "113" ": " "CHECKPOINT: " "main %d\n", count) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(count >= 0); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-stacktrace.c" "@" "115" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "count >= 0") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
    do { int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_errors; ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-stacktrace.c" "@" "117" ": " "EXIT: tests=%d errors=%d %s " "\n", diminuto_unittest_number, diminuto_unittest_count, (diminuto_unittest_count == 0) ? "SUCCESS." : "FAILURE!") : ((void)0)); diminuto_unittest_flush(); exit(diminuto_unittest_count > DIMINUTO_UNITTEST_MAXIMUM ? DIMINUTO_UNITTEST_MAXIMUM : diminuto_unittest_count); } while (0);
}

canonical_original_code:
int main(int argc, char **argv)
{
    int count;
    do { diminuto_unittest_setlogmask(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-stacktrace.c" "@" "107" ": " "SETLOGMASK: logmask=0x%x\n", diminuto_log_mask) : ((void)0)); } while (0);
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "109" ": " "CHECKPOINT: " "main\n") : ((void)0));;
    count = f0();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "113" ": " "CHECKPOINT: " "main %d\n", count) : ((void)0));;
    do { int diminuto_unittest_condition; diminuto_unittest_condition = !!(count >= 0); if (!diminuto_unittest_condition) { int diminuto_unittest_errno; int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_errno = (*__errno_location ()); diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_error(); ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_ERROR)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_ERROR, "tst/unittest-stacktrace.c" "@" "115" ": " "ASSERT: tests=%d errors=%d errno=%d !(%s)!\n", diminuto_unittest_number, diminuto_unittest_count, diminuto_unittest_errno, "count >= 0") : ((void)0)); diminuto_stacktrace(); diminuto_unittest_flush(); diminuto_core_fatal(); } } while (0);
    do { int diminuto_unittest_number; int diminuto_unittest_count; diminuto_unittest_number = diminuto_unittest_tests; diminuto_unittest_count = diminuto_unittest_errors; ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_NOTICE)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_NOTICE, "tst/unittest-stacktrace.c" "@" "117" ": " "EXIT: tests=%d errors=%d %s " "\n", diminuto_unittest_number, diminuto_unittest_count, (diminuto_unittest_count == 0) ? "SUCCESS." : "FAILURE!") : ((void)0)); diminuto_unittest_flush(); exit(diminuto_unittest_count > DIMINUTO_UNITTEST_MAXIMUM ? DIMINUTO_UNITTEST_MAXIMUM : diminuto_unittest_count); } while (0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: count int


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f6(6LL, "tst/unittest-stacktrace.c@52: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f6(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func10(6LL, "tst/unittest-stacktrace.c@52: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func10(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f5(void)
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "52" ": " "CHECKPOINT: " "f%d\n", 5) : ((void)0));;
    rc = f6();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "54" ": " "CHECKPOINT: " "f%d %d\n", 5, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f5()
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "52" ": " "CHECKPOINT: " "f%d\n", 5) : ((void)0));;
    rc = f6();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "54" ": " "CHECKPOINT: " "f%d %d\n", 5, rc) : ((void)0));;
    return rc;
}


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f5(6LL, "tst/unittest-stacktrace.c@61: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f5(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func11(6LL, "tst/unittest-stacktrace.c@61: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func11(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f4(void)
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "61" ": " "CHECKPOINT: " "f%d\n", 4) : ((void)0));;
    rc = f5();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "63" ": " "CHECKPOINT: " "f%d %d\n", 4, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f4()
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "61" ": " "CHECKPOINT: " "f%d\n", 4) : ((void)0));;
    rc = f5();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "63" ": " "CHECKPOINT: " "f%d %d\n", 4, rc) : ((void)0));;
    return rc;
}


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f4(6LL, "tst/unittest-stacktrace.c@70: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f4(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func12(6LL, "tst/unittest-stacktrace.c@70: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func12(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f3(void)
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "70" ": " "CHECKPOINT: " "f%d\n", 3) : ((void)0));;
    rc = f4();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "72" ": " "CHECKPOINT: " "f%d %d\n", 3, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f3()
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "70" ": " "CHECKPOINT: " "f%d\n", 3) : ((void)0));;
    rc = f4();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "72" ": " "CHECKPOINT: " "f%d %d\n", 3, rc) : ((void)0));;
    return rc;
}


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f3(6LL, "tst/unittest-stacktrace.c@79: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f3(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func13(6LL, "tst/unittest-stacktrace.c@79: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func13(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f2(void)
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "79" ": " "CHECKPOINT: " "f%d\n", 2) : ((void)0));;
    rc = f3();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "81" ": " "CHECKPOINT: " "f%d %d\n", 2, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f2()
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "79" ": " "CHECKPOINT: " "f%d\n", 2) : ((void)0));;
    rc = f3();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "81" ": " "CHECKPOINT: " "f%d %d\n", 2, rc) : ((void)0));;
    return rc;
}


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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = f2(6LL, "tst/unittest-stacktrace.c@88: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = f2(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

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

if ( (diminuto_log_mask & 2) != 0 )
{
diminuto_log_log();
v2 = func14(6LL, "tst/unittest-stacktrace.c@88: CHECKPOINT: f%d\n");
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
else
{
v2 = func14(a1, a2);
if ( (diminuto_log_mask & 2) == 0 )
return v2;
}
diminuto_log_log();
return v2;
}

original_code:
int f1(void)
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "88" ": " "CHECKPOINT: " "f%d\n", 1) : ((void)0));;
    rc = f2();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "90" ": " "CHECKPOINT: " "f%d %d\n", 1, rc) : ((void)0));;
    return rc;
}

canonical_original_code:
int f1()
{
    int rc;
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "88" ": " "CHECKPOINT: " "f%d\n", 1) : ((void)0));;
    rc = f2();
    ((((diminuto_log_mask) & (DIMINUTO_LOG_MASK_INFORMATION)) != 0) ? diminuto_log_log(DIMINUTO_LOG_PRIORITY_INFORMATION, "tst/unittest-stacktrace.c" "@" "90" ": " "CHECKPOINT: " "f%d %d\n", 1, rc) : ((void)0));;
    return rc;
}


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

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

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

return_type: long


decompiled_code:
__int16 __fastcall diminuto_ipc_port(_BYTE *a1, const char *a2)
{
bool v2; // zf
const char *v3; // rbp
struct servent *v4; // rax
__int16 result; // ax
_BYTE *v6; // r8
unsigned __int64 v7; // [rsp+8h] [rbp-10h] BYREF

v2 = *a1 == 58;
v7 = 0LL;
v3 = &a1[v2];
v4 = getservbyname(v3, a2);
if ( v4 )
return _bswap_16(v4->s_port);
v6 = (_BYTE *)diminuto_number_unsigned(v3, &v7);
result = 0;
if ( !*v6 )
{
result = v7;
if ( v7 > 0xFFFF )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_ipc.c", 61LL, "diminuto_ipc_port: magnitude");
result = 0;
}
}
return result;
}

canonical_decompiled_code:
__int16 __fastcall func4(_BYTE *a1, const char *a2)
{
bool v2; // zf
const char *v3; // rbp
struct servent *v4; // rax
__int16 result; // ax
_BYTE *v6; // r8
unsigned __int64 v7; // [rsp+8h] [rbp-10h] BYREF

v2 = *a1 == 58;
v7 = 0LL;
v3 = &a1[v2];
v4 = getservbyname(v3, a2);
if ( v4 )
return func2(v4->s_port);
v6 = (_BYTE *)diminuto_number_unsigned(v3, &v7);
result = 0;
if ( !*v6 )
{
result = v7;
if ( v7 > 0xFFFF )
{
*_errno_location() = 22;
diminuto_log_perror("src/diminuto_ipc.c", 61LL, "diminuto_ipc_port: magnitude");
result = 0;
}
}
return result;
}

original_code:
diminuto_port_t diminuto_ipc_port(const char * service, const char * protocol)
{
    diminuto_port_t port = 0;
    const char * sp = (const char *)0;
    struct servent * portp = (struct servent *)0;
    diminuto_unsigned_t temp = 0;
    const char * end = (const char *)0;
    if (*(sp = service) == ':') { sp += 1; }
    if ((portp = getservbyname(sp, protocol)) != (struct servent *)0) {
        port = ntohs(portp->s_port);
    } else if (*(end = diminuto_number_unsigned(sp, &temp)) != '\0') {
    } else if (temp > (diminuto_port_t)~0) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipc.c", 61, "diminuto_ipc_port: magnitude");
        port = 0;
    } else {
        port = temp;
    }
    return port;
}

canonical_original_code:
unsigned short diminuto_ipc_port(char *service, char *protocol)
{
    unsigned short port = 0;
    char *sp = (const char *)0;
    struct servent *portp = (struct servent *)0;
    unsigned long temp = 0;
    char *end = (const char *)0;
    if (*(sp = service) == ':') { sp += 1; }
    if ((portp = getservbyname(sp, protocol)) != (struct servent *)0) {
        port = ntohs(portp->s_port);
    } else if (*(end = diminuto_number_unsigned(sp, &temp)) != '\0') {
    } else if (temp > (unsigned short)~0) {
        (*__errno_location ()) = 22;
        diminuto_log_perror("src/diminuto_ipc.c", 61, "diminuto_ipc_port: magnitude");
        port = 0;
    } else {
        port = temp;
    }
    return port;
}

variable_types:
service
char *

variable_types:
protocol
char *

variable_types:
port
unsigned short

variable_types:
sp
char *

variable_types: struct servent { char *s_name; char **s_aliases; int s_port; char *s_proto; } *

variable_types:
temp
unsigned long

variable_types:
end
char *

return_type: unsigned short


decompiled_code:
char *__fastcall diminuto_ipc_port2string(unsigned __int16 a1, char *a2, size_t a3)
{
if ( a3 )
{
*a2 = 0;
snprintf(a2, a3, "%u", a1);
a2[a3 - 1] = 0;
}
return a2;
}

canonical_decompiled_code:
char *__fastcall func5(unsigned __int16 a1, char *a2, size_t a3)
{
if ( a3 )
{
*a2 = 0;
snprintf(a2, a3, "%u", a1);
a2[a3 - 1] = 0;
}
return a2;
}

original_code:
char * diminuto_ipc_port2string(diminuto_port_t port, void * buffer, size_t length) {
    char * string = (char *)buffer;
    if (length > 0) {
        string[0] = '\0';
        (void)snprintf(string, length, "%u", port);
        string[length - 1] = '\0';
    }
    return string;
}

canonical_original_code:
char *diminuto_ipc_port2string(unsigned short port, void *buffer, unsigned long length) {
    char *string = (char *)buffer;
    if (length > 0) {
        string[0] = '\0';
        (void)snprintf(string, length, "%u", port);
        string[length - 1] = '\0';
    }
    return string;
}

variable_types:
buffer
void *

variable_types:
length
unsigned long

variable_types:
string
char *

return_type: char *


decompiled_code:
__int64 __fastcall diminuto_ipc_close(int a1)
{
unsigned int v1; // er12

v1 = a1;
if ( close(a1) < 0 )
{
v1 = -2;
diminuto_log_perror("src/diminuto_ipc.c", 89LL, "diminuto_ipc_close: close");
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
unsigned int v1; // er12

v1 = a1;
if ( close(a1) < 0 )
{
v1 = -2;
diminuto_log_perror("src/diminuto_ipc.c", 89LL, "diminuto_ipc_close: close");
}
return v1;
}

original_code:
int diminuto_ipc_close(int fd)
{
    if (close(fd) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 89, "diminuto_ipc_close: close");
        fd = -2;
    }
    return fd;
}

variable_types: fd int


decompiled_code:
__int64 __fastcall diminuto_ipc_shutdown(int a1)
{
unsigned int v1; // er12

v1 = a1;
if ( shutdown(a1, 2) < 0 )
{
v1 = -3;
diminuto_log_perror("src/diminuto_ipc.c", 99LL, "diminuto_ipc_shutdown: shutdown");
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
unsigned int v1; // er12

v1 = a1;
if ( shutdown(a1, 2) < 0 )
{
v1 = -3;
diminuto_log_perror("src/diminuto_ipc.c", 99LL, "diminuto_ipc_shutdown: shutdown");
}
return v1;
}

original_code:
int diminuto_ipc_shutdown(int fd)
{
    if (shutdown(fd, SHUT_RDWR) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 99, "diminuto_ipc_shutdown: shutdown");
        fd = -3;
    }
    return fd;
}


decompiled_code:
__int64 __fastcall diminuto_ipc_type(int a1)
{
socklen_t len; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

addr = 0LL;
len = 16;
if ( getsockname(a1, &addr, &len) >= 0 )
return addr.sa_family;
diminuto_log_perror("src/diminuto_ipc.c", 117LL, "diminuto_ipc_type: getsockname");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
socklen_t len; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

addr = 0LL;
len = 16;
if ( getsockname(a1, &addr, &len) >= 0 )
return addr.sa_family;
diminuto_log_perror("src/diminuto_ipc.c", 117LL, "diminuto_ipc_type: getsockname");
return 0LL;
}

original_code:
int diminuto_ipc_type(int fd)
{
    int rc = 0;
    struct sockaddr sa = { 0, };
    socklen_t length = sizeof(sa);
    if (getsockname(fd, (struct sockaddr *)&sa, &length) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 117, "diminuto_ipc_type: getsockname");
    } else {
        rc = sa.sa_family;
    }
    return rc;
}

canonical_original_code:
int diminuto_ipc_type(int fd)
{
    int rc = 0;
    struct sockaddr sa = { 0, };
    unsigned int length = sizeof(sa);
    if (getsockname(fd, (struct sockaddr *)&sa, &length) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 117, "diminuto_ipc_type: getsockname");
    } else {
        rc = sa.sa_family;
    }
    return rc;
}

variable_types: rc int

variable_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

variable_types:
length
unsigned int


decompiled_code:
__int64 __fastcall diminuto_ipc_set_status(int fd, int a2, __int64 a3)
{
unsigned int v3; // er12
int v5; // eax
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rbx

v3 = fd;
v5 = fcntl(fd, 3, 0LL);
if ( v5 == -1 )
{
v3 = -6;
diminuto_log_perror("src/diminuto_ipc.c", 134LL, "diminuto_ipc_set_status: fcntl(F_GETFL)");
}
else
{
v6 = v5;
v7 = a3 | v5;
v8 = v6 & ~a3;
if ( !a2 )
v7 = v8;
if ( fcntl(fd, 4, v7) < 0 )
{
v3 = -7;
diminuto_log_perror("src/diminuto_ipc.c", 137LL, "diminuto_ipc_set_status: fcntl(F_SETFL)");
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func9(int fd, int a2, __int64 a3)
{
unsigned int v3; // er12
int v5; // eax
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rbx

v3 = fd;
v5 = fcntl(fd, 3, 0LL);
if ( v5 == -1 )
{
v3 = -6;
diminuto_log_perror("src/diminuto_ipc.c", 134LL, "diminuto_ipc_set_status: fcntl(F_GETFL)");
}
else
{
v6 = v5;
v7 = a3 | v5;
v8 = v6 & ~a3;
if ( !a2 )
v7 = v8;
if ( fcntl(fd, 4, v7) < 0 )
{
v3 = -7;
diminuto_log_perror("src/diminuto_ipc.c", 137LL, "diminuto_ipc_set_status: fcntl(F_SETFL)");
}
}
return v3;
}

original_code:
int diminuto_ipc_set_status(int fd, int enable, long mask)
{
    long flags = 0;
    if ((flags = fcntl(fd, 3, 0)) == -1) {
        diminuto_log_perror("src/diminuto_ipc.c", 134, "diminuto_ipc_set_status: fcntl(F_GETFL)");
        fd = -6;
    } else if (fcntl(fd, 4, enable ? (flags|mask) : (flags&(~mask))) <0) {
        diminuto_log_perror("src/diminuto_ipc.c", 137, "diminuto_ipc_set_status: fcntl(F_SETFL)");
        fd = -7;
    } else {
    }
    return fd;
}

variable_types: enable int

variable_types: mask long

variable_types: flags long


decompiled_code:
__int64 __fastcall diminuto_ipc_set_socket(unsigned int a1, int a2, int a3, int a4)
{
__int64 result; // rax
int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optval[0] = a4;
if ( setsockopt(a1, a2, a3, optval, 4u) >= 0 )
return a1;
if ( *_errno_location() == 1 )
{
diminuto_log_perror("src/diminuto_ipc.c", 151LL, "diminuto_ipc_set_socket: setsockopt: must be root");
result = 4294967288LL;
}
else
{
diminuto_log_perror("src/diminuto_ipc.c", 154LL, "diminuto_ipc_set_socket: setsockopt");
result = 4294967287LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, int a2, int a3, int a4)
{
__int64 result; // rax
int optval[3]; // [rsp+Ch] [rbp-Ch] BYREF

optval[0] = a4;
if ( setsockopt(a1, a2, a3, optval, 4u) >= 0 )
return a1;
if ( *_errno_location() == 1 )
{
diminuto_log_perror("src/diminuto_ipc.c", 151LL, "diminuto_ipc_set_socket: setsockopt: must be root");
result = 4294967288LL;
}
else
{
diminuto_log_perror("src/diminuto_ipc.c", 154LL, "diminuto_ipc_set_socket: setsockopt");
result = 4294967287LL;
}
return result;
}

original_code:
int diminuto_ipc_set_socket(int fd, int level, int option, int value)
{
    if (setsockopt(fd, level, option, &value, sizeof(value)) >= 0) {
    } else if ((*__errno_location ()) == 1) {
        diminuto_log_perror("src/diminuto_ipc.c", 151, "diminuto_ipc_set_socket: setsockopt: must be root");
        fd = -8;
    } else {
        diminuto_log_perror("src/diminuto_ipc.c", 154, "diminuto_ipc_set_socket: setsockopt");
        fd = -9;
    }
    return fd;
}

variable_types: level int

variable_types: option int

variable_types: value int


decompiled_code:
__int64 __fastcall diminuto_ipc_get_control(int a1, int a2)
{
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = 0;
if ( ioctl(a1, a2, v3) >= 0 )
return v3[0];
diminuto_log_perror("src/diminuto_ipc.c", 166LL, "diminuto_ipc_get_control: ioctl");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2)
{
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = 0;
if ( ioctl(a1, a2, v3) >= 0 )
return v3[0];
diminuto_log_perror("src/diminuto_ipc.c", 166LL, "diminuto_ipc_get_control: ioctl");
return 0xFFFFFFFFLL;
}

original_code:
int diminuto_ipc_get_control(int fd, int option)
{
    int value = 0;
    if (ioctl(fd, option, &value) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 166, "diminuto_ipc_get_control: ioctl");
        value = -1;
    }
    return value;
}


decompiled_code:
__int64 __fastcall diminuto_ipc_get_timestamp(int a1)
{
__int128 v2; // [rsp+0h] [rbp-18h] BYREF

v2 = 0LL;
if ( ioctl(a1, 0x8906uLL, &v2) >= 0 )
return diminuto_frequency_seconds2ticks_constprop_0(v2);
diminuto_log_perror("src/diminuto_ipc.c", 179LL, "diminuto_ipc_get_timestamp: ioctl");
return -1LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1)
{
__int128 v2; // [rsp+0h] [rbp-18h] BYREF

v2 = 0LL;
if ( ioctl(a1, 0x8906uLL, &v2) >= 0 )
return func3(v2);
diminuto_log_perror("src/diminuto_ipc.c", 179LL, "diminuto_ipc_get_timestamp: ioctl");
return -1LL;
}

original_code:
diminuto_sticks_t diminuto_ipc_get_timestamp(int fd)
{
    struct timeval value = { 0, };
    diminuto_sticks_t ticks = -1;
    if (ioctl(fd, 0x8906, &value) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 179, "diminuto_ipc_get_timestamp: ioctl");
    } else {
        ticks = diminuto_frequency_seconds2ticks(value.tv_sec, value.tv_usec, 1000000LL);
    }
    return ticks;
}

canonical_original_code:
long diminuto_ipc_get_timestamp(int fd)
{
    struct timeval value = { 0, };
    long ticks = -1;
    if (ioctl(fd, 0x8906, &value) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 179, "diminuto_ipc_get_timestamp: ioctl");
    } else {
        ticks = diminuto_frequency_seconds2ticks(value.tv_sec, value.tv_usec, 1000000LL);
    }
    return ticks;
}

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: ticks long


decompiled_code:
__int64 __fastcall diminuto_ipc_set_interface(int fd, const char *a2)
{
socklen_t v2; // er8
__int128 *v3; // rcx
__int64 result; // rax
char *v5; // rax
__int128 v6[2]; // [rsp+0h] [rbp-38h] BYREF
__int64 v7; // [rsp+20h] [rbp-18h]

v7 = 0LL;
v6[0] = 0LL;
v6[1] = 0LL;
if ( !a2 )
return (unsigned int)fd;
v2 = 0;
v3 = v6;
if ( *a2 )
{
v5 = strncpy((char *)v6, a2, 0xFuLL);
v2 = 40;
v3 = (__int128 *)v5;
}
if ( setsockopt(fd, 1, 25, v3, v2) >= 0 )
return (unsigned int)fd;
if ( *_errno_location() == 1 )
{
diminuto_log_perror("src/diminuto_ipc.c", 205LL, "diminuto_ipc_set_interface: setsockopt: must be root");
result = 4294967292LL;
}
else
{
diminuto_log_perror("src/diminuto_ipc.c", &loc_D0, "diminuto_ipc_set_interface: setsockopt");
result = 4294967291LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(int fd, const char *a2)
{
socklen_t v2; // er8
__int128 *v3; // rcx
__int64 result; // rax
char *v5; // rax
__int128 v6[2]; // [rsp+0h] [rbp-38h] BYREF
__int64 v7; // [rsp+20h] [rbp-18h]

v7 = 0LL;
v6[0] = 0LL;
v6[1] = 0LL;
if ( !a2 )
return (unsigned int)fd;
v2 = 0;
v3 = v6;
if ( *a2 )
{
v5 = strncpy((char *)v6, a2, 0xFuLL);
v2 = 40;
v3 = (__int128 *)v5;
}
if ( setsockopt(fd, 1, 25, v3, v2) >= 0 )
return (unsigned int)fd;
if ( *_errno_location() == 1 )
{
diminuto_log_perror("src/diminuto_ipc.c", 205LL, "diminuto_ipc_set_interface: setsockopt: must be root");
result = 4294967292LL;
}
else
{
diminuto_log_perror("src/diminuto_ipc.c", &loc_D0, "diminuto_ipc_set_interface: setsockopt");
result = 4294967291LL;
}
return result;
}

original_code:
int diminuto_ipc_set_interface(int fd, const char * interface)
{
    struct ifreq intf = { 0 };
    socklen_t length = 0;
    if (interface != (const char *)0) {
        if (interface[0] != '\0') {
            strncpy(intf.ifr_ifrn.ifrn_name, interface, sizeof(intf.ifr_ifrn.ifrn_name));
            intf.ifr_ifrn.ifrn_name[sizeof(intf.ifr_ifrn.ifrn_name) - 1] = '\0';
            length = sizeof(intf);
        }
        if (setsockopt(fd, 1, 25, (void *)&intf, length) >= 0) {
        } else if ((*__errno_location ()) == 1) {
            diminuto_log_perror("src/diminuto_ipc.c", 205, "diminuto_ipc_set_interface: setsockopt: must be root");
            fd = -4;
        } else {
            diminuto_log_perror("src/diminuto_ipc.c", 208, "diminuto_ipc_set_interface: setsockopt");
            fd = -5;
        }
    }
    return fd;
}

canonical_original_code:
int diminuto_ipc_set_interface(int fd, char *interface)
{
    struct ifreq intf = { 0 };
    unsigned int length = 0;
    if (interface != (char *)0) {
        if (interface[0] != '\0') {
            strncpy(intf.ifr_ifrn.ifrn_name, interface, sizeof(intf.ifr_ifrn.ifrn_name));
            intf.ifr_ifrn.ifrn_name[sizeof(intf.ifr_ifrn.ifrn_name) - 1] = '\0';
            length = sizeof(intf);
        }
        if (setsockopt(fd, 1, 25, (void *)&intf, length) >= 0) {
        } else if ((*__errno_location ()) == 1) {
            diminuto_log_perror("src/diminuto_ipc.c", 205, "diminuto_ipc_set_interface: setsockopt: must be root");
            fd = -4;
        } else {
            diminuto_log_perror("src/diminuto_ipc.c", 208, "diminuto_ipc_set_interface: setsockopt");
            fd = -5;
        }
    }
    return fd;
}

variable_types:
interface
char *

variable_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; } ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }

user_defined_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }


decompiled_code:
__int64 __fastcall diminuto_ipc_set_send(unsigned int a1, __int64 a2)
{
if ( a2 < 0 )
return a1;
if ( a2 <= 0x7FFFFFFF )
return diminuto_ipc_set_socket(a1, 1, 7, a2);
return diminuto_ipc_set_socket(a1, 1, 7, 0x7FFFFFFF);
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1, __int64 a2)
{
if ( a2 < 0 )
return a1;
if ( a2 <= 0x7FFFFFFF )
return func10(a1, 1, 7, a2);
return func10(a1, 1, 7, 0x7FFFFFFF);
}

original_code:
int diminuto_ipc_set_send(int fd, ssize_t size)
{
    static const int MAXIMUM = ((((int)(~(int)0)) < 0) ? ((int)(~(((int)1)<<((sizeof(int) * 8)-1)))) : ((int)(~((int)0))));
    if (size < 0) {
    } else if (size > MAXIMUM) {
        fd = diminuto_ipc_set_socket(fd, 1, 7, MAXIMUM);
    } else {
        int value;
        fd = diminuto_ipc_set_socket(fd, 1, 7, value = size);
    }
    return fd;
}

canonical_original_code:
int diminuto_ipc_set_send(int fd, long size)
{
    static int MAXIMUM = ((((int)(~(int)0)) < 0) ? ((int)(~(((int)1)<<((sizeof(int) * 8)-1)))) : ((int)(~((int)0))));
    if (size < 0) {
    } else if (size > MAXIMUM) {
        fd = diminuto_ipc_set_socket(fd, 1, 7, MAXIMUM);
    } else {
        int value;
        fd = diminuto_ipc_set_socket(fd, 1, 7, value = size);
    }
    return fd;
}

variable_types: size long

variable_types: MAXIMUM int


decompiled_code:
__int64 __fastcall diminuto_ipc_set_receive(unsigned int a1, __int64 a2)
{
if ( a2 < 0 )
return a1;
if ( a2 <= 0x7FFFFFFF )
return diminuto_ipc_set_socket(a1, 1, 8, a2);
return diminuto_ipc_set_socket(a1, 1, 8, 0x7FFFFFFF);
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1, __int64 a2)
{
if ( a2 < 0 )
return a1;
if ( a2 <= 0x7FFFFFFF )
return func10(a1, 1, 8, a2);
return func10(a1, 1, 8, 0x7FFFFFFF);
}

original_code:
int diminuto_ipc_set_receive(int fd, ssize_t size)
{
    static const int MAXIMUM = ((((int)(~(int)0)) < 0) ? ((int)(~(((int)1)<<((sizeof(int) * 8)-1)))) : ((int)(~((int)0))));
    if (size < 0) {
    } else if (size > MAXIMUM) {
        fd = diminuto_ipc_set_socket(fd, 1, 8, MAXIMUM);
    } else {
        int value;
        fd = diminuto_ipc_set_socket(fd, 1, 8, value = size);
    }
    return fd;
}

canonical_original_code:
int diminuto_ipc_set_receive(int fd, long size)
{
    static int MAXIMUM = ((((int)(~(int)0)) < 0) ? ((int)(~(((int)1)<<((sizeof(int) * 8)-1)))) : ((int)(~((int)0))));
    if (size < 0) {
    } else if (size > MAXIMUM) {
        fd = diminuto_ipc_set_socket(fd, 1, 8, MAXIMUM);
    } else {
        int value;
        fd = diminuto_ipc_set_socket(fd, 1, 8, value = size);
    }
    return fd;
}


decompiled_code:
__int64 __fastcall diminuto_ipc_set_linger(int fd, unsigned __int64 a2)
{
unsigned int v2; // er12
int v4; // ecx
unsigned __int64 v6; // rsi
unsigned __int64 v7; // rax
__int64 optval; // [rsp+8h] [rbp-20h] BYREF

v2 = fd;
optval = 0LL;
v4 = diminuto_ipc_debug;
if ( diminuto_ipc_debug )
{
diminuto_log_emit("diminuto_ipc_set_linger: fd=%d ticks=0x%llx\n", (unsigned int)fd, a2);
v4 = diminuto_ipc_debug;
}
if ( !a2 )
{
optval = 0LL;
goto LABEL_5;
}
v6 = diminuto_frequency();
if ( ~v6 < a2 )
{
optval = 0x7FFFFFFF00000001LL;
LABEL_5:
if ( !v4 )
goto LABEL_6;
goto LABEL_13;
}
LODWORD(optval) = 1;
v7 = (v6 + a2 - 1) / v6;
if ( v7 > 0x7FFFFFFF )
LODWORD(v7) = 0x7FFFFFFF;
HIDWORD(optval) = v7;
if ( v4 )
LABEL_13:
diminuto_log_emit("diminuto_ipc_set_linger: l_onoff=%d l_linger=%d\n", (unsigned int)optval, HIDWORD(optval));
LABEL_6:
if ( setsockopt(fd, 1, 13, &optval, 8u) < 0 )
{
v2 = -10;
diminuto_log_perror("src/diminuto_ipc.c", 276LL, "diminuto_ipc_set_linger: setsockopt");
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func17(int fd, unsigned __int64 a2)
{
unsigned int v2; // er12
int v4; // ecx
unsigned __int64 v6; // rsi
unsigned __int64 v7; // rax
__int64 optval; // [rsp+8h] [rbp-20h] BYREF

v2 = fd;
optval = 0LL;
v4 = diminuto_ipc_debug;
if ( diminuto_ipc_debug )
{
diminuto_log_emit("diminuto_ipc_set_linger: fd=%d ticks=0x%llx\n", (unsigned int)fd, a2);
v4 = diminuto_ipc_debug;
}
if ( !a2 )
{
optval = 0LL;
goto LABEL_5;
}
v6 = func0();
if ( ~v6 < a2 )
{
optval = 0x7FFFFFFF00000001LL;
LABEL_5:
if ( !v4 )
goto LABEL_6;
goto LABEL_13;
}
LODWORD(optval) = 1;
v7 = (v6 + a2 - 1) / v6;
if ( v7 > 0x7FFFFFFF )
LODWORD(v7) = 0x7FFFFFFF;
HIDWORD(optval) = v7;
if ( v4 )
LABEL_13:
diminuto_log_emit("diminuto_ipc_set_linger: l_onoff=%d l_linger=%d\n", (unsigned int)optval, HIDWORD(optval));
LABEL_6:
if ( setsockopt(fd, 1, 13, &optval, 8u) < 0 )
{
v2 = -10;
diminuto_log_perror("src/diminuto_ipc.c", 276LL, "diminuto_ipc_set_linger: setsockopt");
}
return v2;
}

original_code:
int diminuto_ipc_set_linger(int fd, diminuto_ticks_t ticks)
{
    struct linger opt = { 0, };
    static const int MAXIMUM = ((((int)(~(int)0)) < 0) ? ((int)(~(((int)1)<<((sizeof(int) * 8)-1)))) : ((int)(~((int)0))));
    if (diminuto_ipc_debug) {
        diminuto_log_emit("diminuto_ipc_set_linger: fd=%d ticks=0x%llx\n", fd, (unsigned long long)ticks);
    }
    if (ticks == 0) {
        opt.l_onoff = 0;
        opt.l_linger = 0;
    } else if (ticks <= (((((diminuto_ticks_t)(~(diminuto_ticks_t)0)) < 0) ? ((diminuto_ticks_t)(~(((diminuto_ticks_t)1)<<((sizeof(diminuto_ticks_t) * 8)-1)))) : ((diminuto_ticks_t)(~((diminuto_ticks_t)0)))) - diminuto_frequency())) {
        opt.l_onoff = !0;
        ticks += diminuto_frequency();
        ticks -= 1;
        ticks /= diminuto_frequency();
        opt.l_linger = (ticks <= MAXIMUM) ? ticks : MAXIMUM;
    } else {
        opt.l_onoff = !0;
        opt.l_linger = MAXIMUM;
    }
    if (diminuto_ipc_debug) {
        diminuto_log_emit("diminuto_ipc_set_linger: l_onoff=%d l_linger=%d\n", opt.l_onoff, opt.l_linger);
    }
    if (setsockopt(fd, 1, 13, &opt, sizeof(opt)) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 276, "diminuto_ipc_set_linger: setsockopt");
        fd = -10;
    }
    return fd;
}

canonical_original_code:
int diminuto_ipc_set_linger(int fd, unsigned long ticks)
{
    struct linger opt = { 0, };
    static int MAXIMUM = ((((int)(~(int)0)) < 0) ? ((int)(~(((int)1)<<((sizeof(int) * 8)-1)))) : ((int)(~((int)0))));
    if (diminuto_ipc_debug) {
        diminuto_log_emit("diminuto_ipc_set_linger: fd=%d ticks=0x%llx\n", fd, (unsigned long long)ticks);
    }
    if (ticks == 0) {
        opt.l_onoff = 0;
        opt.l_linger = 0;
    } else if (ticks <= (((((diminuto_ticks_t)(~(unsigned long)0)) < 0) ? ((diminuto_ticks_t)(~(((unsigned long)1)<<((sizeof(diminuto_ticks_t) * 8)-1)))) : ((diminuto_ticks_t)(~((unsigned long)0)))) - diminuto_frequency())) {
        opt.l_onoff = !0;
        ticks += diminuto_frequency();
        ticks -= 1;
        ticks /= diminuto_frequency();
        opt.l_linger = (ticks <= MAXIMUM) ? ticks : MAXIMUM;
    } else {
        opt.l_onoff = !0;
        opt.l_linger = MAXIMUM;
    }
    if (diminuto_ipc_debug) {
        diminuto_log_emit("diminuto_ipc_set_linger: l_onoff=%d l_linger=%d\n", opt.l_onoff, opt.l_linger);
    }
    if (setsockopt(fd, 1, 13, &opt, sizeof(opt)) < 0) {
        diminuto_log_perror("src/diminuto_ipc.c", 276, "diminuto_ipc_set_linger: setsockopt");
        fd = -10;
    }
    return fd;
}

variable_types:
ticks
unsigned long

variable_types: struct linger { int l_onoff; int l_linger; }


decompiled_code:
// attributes: thunk
__int64 __fastcall diminuto_ipc_inject_defaults(unsigned int a1)
{
return diminuto_ipc_set_reuseaddress_constprop_0(a1);
}

canonical_decompiled_code:
__int64 __fastcall func18(unsigned int a1)
{
return func11(a1);
}

original_code:
int diminuto_ipc_inject_defaults(int fd, void * datap)
{
    return diminuto_ipc_set_reuseaddress(fd, !0);
}

canonical_original_code:
int diminuto_ipc_inject_defaults(int fd, void *datap)
{
    return diminuto_ipc_set_reuseaddress(fd, !0);
}

variable_types: fd int

variable_types:
datap
void *