// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testq %rdi, %rdi
je 0x32d7
movb $0x0, (%rbx)
movq %fs:0x0, %rax
leaq -0x150(%rax), %r12
movl (%r12), %ebp
pushq $0xb
popq %rcx
pushq $0x17
popq %rdx
xorl %esi, %esi
leaq 0xb953(%rip), %r15      # 0xec50
movl $0x8fff0000, %eax       # imm = 0x8FFF0000
movq %rcx, %r13
shlq $0x4, %r13
movl (%r13,%r15), %edi
cmpl %ebp, %edi
je 0x3353
cmpq %rdx, %rsi
je 0x3461
cmpl %ebp, %edi
setb %r8b
leaq -0x1(%rcx), %rdi
cmpq %rsi, %rdi
setb %r9b
orb %r8b, %r9b
cmpb $0x1, %r9b
jne 0x3347
cmpq %rdx, %rcx
jae 0x3461
incq %rcx
movq %rcx, %rsi
movq %rdx, %rdi
leaq (%rdi,%rsi), %rcx
shrq %rcx
movq %rdi, %rdx
jmp 0x3302
andq $0x0, 0x10(%rsp)
cmpl $0x80170000, %ebp       # imm = 0x80170000
jne 0x33d0
pushq $0x1
popq %rsi
movl $0x100, %edi            # imm = 0x100
callq 0x2220
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x33d0
movq %rax, %r14
movq $0x100, 0x8(%rsp)       # imm = 0x100
movq 0x8(%rsp), %rsi
movl 0x4(%r12), %r9d
cmpb $0x0, 0x8(%r12)
leaq 0x8(%r12), %rax
leaq 0x5fe7(%rip), %r10      # 0x9387
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x6171(%rip), %r8       # 0x9520
pushq $0x1
popq %rdx
movl $0x100, %ecx            # imm = 0x100
movq %r14, %rdi
xorl %eax, %eax
pushq %r10
callq 0x2040
popq %rcx
popq %rdx
testl %eax, %eax
jne 0x33d3
movq 0x8(%rsp), %rax
jmp 0x33d3
xorl %r14d, %r14d
movq $0x100, 0x8(%rsp)       # imm = 0x100
movq 0x8(%rsp), %rsi
movq 0x108(%r12), %r9
movq 0x110(%r12), %r10
movl 0x118(%r12), %r11d
testq %r14, %r14
je 0x3404
cmpb $0x0, (%r14)
jne 0x3427
addq %r13, %r15
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x3420
cmpb $0x0, (%rax)
leaq 0x5f6d(%rip), %r14      # 0x9387
cmovneq %rax, %r14
jmp 0x3427
leaq 0x5f60(%rip), %r14      # 0x9387
subq $0x8, %rsp
leaq 0x6109(%rip), %r8       # 0x953b
pushq $0x1
popq %rdx
pushq $-0x1
popq %rcx
movq %rbx, %rdi
xorl %eax, %eax
pushq %r14
pushq %r11
pushq %r10
callq 0x2040
addq $0x20, %rsp
testl %eax, %eax
jne 0x3455
movq 0x8(%rsp), %rax
leaq 0x10(%rsp), %rdi
callq 0x5098
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq