// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testq %rdi, %rdi
je 0x33a8
movb $0x0, (%rbx)
movq %fs:0x0, %rax
movl -0x150(%rax), %ecx
cmpl $0x800c0000, %ecx       # imm = 0x800C0000
jne 0x33d0
movl $0x800c0000, %ebp       # imm = 0x800C0000
leaq 0xa8f2(%rip), %r14      # 0xdcc0
jmp 0x3444
movl $0x17, %edi
movl $0xb, %edx
movl $0x800c0000, %r8d       # imm = 0x800C0000
xorl %esi, %esi
leaq 0xa827(%rip), %r14      # 0xdc10
movl $0x8fff0000, %ebp       # imm = 0x8FFF0000
cmpq %rdi, %rsi
je 0x355a
cmpl %ecx, %r8d
setb %r8b
leaq -0x1(%rdx), %r9
cmpq %rsi, %r9
setb %r10b
orb %r8b, %r10b
cmpb $0x1, %r10b
jne 0x3424
cmpq %rdi, %rdx
jae 0x355a
incq %rdx
movq %rdx, %rsi
movq %rdi, %r9
leaq (%r9,%rsi), %rdx
shrq %rdx
movq %rdx, %r10
shlq $0x4, %r10
movl (%r10,%r14), %r8d
movq %r9, %rdi
cmpl %ecx, %r8d
jne 0x33ee
addq %r10, %r14
movl %r8d, %ebp
leaq -0x150(%rax), %r15
movq $0x0, 0x10(%rsp)
cmpl $0x80170000, %ebp       # imm = 0x80170000
jne 0x34c9
movl $0x100, %edi            # imm = 0x100
movl $0x1, %esi
callq 0x2220
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x34c9
movq $0x100, 0x8(%rsp)       # imm = 0x100
movq 0x8(%rsp), %rsi
movl 0x4(%r15), %r9d
cmpb $0x0, 0x8(%r15)
leaq 0x8(%r15), %rcx
leaq 0x5ef0(%rip), %r10      # 0x9387
cmovneq %rcx, %r10
subq $0x8, %rsp
leaq 0x607a(%rip), %r8       # 0x9520
movl $0x100, %ecx            # imm = 0x100
movq %rax, %rdi
movl $0x1, %edx
xorl %eax, %eax
pushq %r10
callq 0x2040
addq $0x10, %rsp
testl %eax, %eax
jne 0x34c9
movq 0x8(%rsp), %rax
movq $0x100, 0x8(%rsp)       # imm = 0x100
movq 0x8(%rsp), %rsi
movq 0x108(%r15), %r9
movq 0x110(%r15), %r10
movl 0x118(%r15), %r11d
movq 0x10(%rsp), %r15
testq %r15, %r15
je 0x34fc
cmpb $0x0, (%r15)
jne 0x351c
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x3515
cmpb $0x0, (%rax)
leaq 0x5e78(%rip), %r15      # 0x9387
cmovneq %rax, %r15
jmp 0x351c
leaq 0x5e6b(%rip), %r15      # 0x9387
subq $0x8, %rsp
leaq 0x6014(%rip), %r8       # 0x953b
movq %rbx, %rdi
movl $0x1, %edx
movq $-0x1, %rcx
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
callq 0x2040
addq $0x20, %rsp
testl %eax, %eax
jne 0x3550
movq 0x8(%rsp), %rax
leaq 0x10(%rsp), %rdi
callq 0x5490
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq