// File: /workspace/github_c_makefile_star2_O3/aremmell[P]libsir/src/sirerrors.c
// Function: sir_geterror
uint32_t _sir_geterror(char message[SIR_MAXERROR]) {
    _sir_resetstr(message);

    static const size_t low  = 0;
    static const size_t high = _sir_countof(sir_errors) - 1;

    uint32_t retval = _SIR_E_UNKNOWN;

    _SIR_DECLARE_BIN_SEARCH(low, high);
    _SIR_BEGIN_BIN_SEARCH()

    if (sir_errors[_mid].e == _sir_te.lasterror) {
        char* heap_msg = NULL;

        if (_SIR_E_PLATFORM == sir_errors[_mid].e) {
            heap_msg = calloc(SIR_MAXERROR, sizeof(char));
            if (_sir_validptrnofail(heap_msg)) {
                _sir_snprintf_trunc(heap_msg, SIR_MAXERROR, _SIR_E_PLATFORM_ERRORFORMAT, _sir_te.os_code,
                    (_sir_validstrnofail(_sir_te.os_msg) ? _sir_te.os_msg : SIR_UNKNOWN));
            }
        }

        _sir_snprintf_trunc(message, SIR_MAXERROR, SIR_ERRORFORMAT, _sir_te.loc.func, //-V576
            _sir_te.loc.file, _sir_te.loc.line, (_sir_validstrnofail(heap_msg)
                ? heap_msg : (_sir_validstrnofail(sir_errors[_mid].msg)
                ? sir_errors[_mid].msg : SIR_UNKNOWN)));

        _sir_safefree(&heap_msg);

        retval = sir_errors[_mid].e;
        break;
    }

    _SIR_ITERATE_BIN_SEARCH((sir_errors[_mid].e < _sir_te.lasterror ? 1 : -1));
    _SIR_END_BIN_SEARCH();

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
testq %rdi, %rdi
je 0x33aa
movb $0x0, (%rbx)
movq %fs:0x0, %rax
leaq -0x150(%rax), %r12
movl (%r12), %eax
cmpl $0x800c0000, %eax       # imm = 0x800C0000
jne 0x3423
movq $0x0, 0x8(%rsp)
leaq 0xa8e8(%rip), %r15      # 0xdcc0
movl $0x800c0000, %eax       # imm = 0x800C0000
movq $0x100, (%rsp)          # imm = 0x100
movq (%rsp), %rsi
movq 0x108(%r12), %r9
movq 0x110(%r12), %r10
movl 0x118(%r12), %r11d
movl %eax, %ebp
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x354d
cmpb $0x0, (%rax)
leaq 0x5f6d(%rip), %r14      # 0x9387
cmovneq %rax, %r14
jmp 0x3554
movl $0x17, %esi
movl $0xb, %ecx
movl $0x800c0000, %edi       # imm = 0x800C0000
xorl %edx, %edx
leaq 0xa7d5(%rip), %r15      # 0xdc10
movl $0x8fff0000, %ebp       # imm = 0x8FFF0000
cmpq %rsi, %rdx
je 0x3591
cmpl %eax, %edi
setb %dil
leaq -0x1(%rcx), %r8
cmpq %rdx, %r8
setb %r9b
orb %dil, %r9b
cmpb $0x1, %r9b
jne 0x3475
cmpq %rsi, %rcx
jae 0x3591
incq %rcx
movq %rcx, %rdx
movq %rsi, %r8
leaq (%r8,%rdx), %rcx
shrq %rcx
movq %rcx, %r9
shlq $0x4, %r9
movl (%r9,%r15), %edi
movq %r8, %rsi
cmpl %eax, %edi
jne 0x3440
addq %r9, %r15
movq $0x0, 0x8(%rsp)
cmpl $0x80170000, %eax       # imm = 0x80170000
jne 0x33dd
movl $0x100, %edi            # imm = 0x100
movl $0x1, %esi
callq 0x2220
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x35a0
movq %rax, %r14
movq $0x100, (%rsp)          # imm = 0x100
movq (%rsp), %rsi
movl 0x4(%r12), %r9d
cmpb $0x0, 0x8(%r12)
leaq 0x8(%r12), %rax
leaq 0x5e9f(%rip), %r10      # 0x9387
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x6029(%rip), %r8       # 0x9520
movl $0x100, %ecx            # imm = 0x100
movq %r14, %rdi
movl $0x1, %edx
xorl %eax, %eax
pushq %r10
callq 0x2040
addq $0x10, %rsp
testl %eax, %eax
jne 0x3519
movq (%rsp), %rax
movq $0x100, (%rsp)          # imm = 0x100
movq (%rsp), %rsi
movq 0x108(%r12), %r9
movq 0x110(%r12), %r10
movl 0x118(%r12), %r11d
movl $0x80170000, %ebp       # imm = 0x80170000
cmpb $0x0, (%r14)
jne 0x3554
jmp 0x3403
leaq 0x5e33(%rip), %r14      # 0x9387
subq $0x8, %rsp
leaq 0x5fdc(%rip), %r8       # 0x953b
movq %rbx, %rdi
movl $0x1, %edx
movq $-0x1, %rcx
xorl %eax, %eax
pushq %r14
pushq %r11
pushq %r10
callq 0x2040
addq $0x20, %rsp
testl %eax, %eax
jne 0x3587
movq (%rsp), %rax
leaq 0x8(%rsp), %rdi
callq 0x53e0
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x80170000, %eax       # imm = 0x80170000
jmp 0x33dd