// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x3a90
movl $0x8fff0000, 0x9c(%rsp) # imm = 0x8FFF0000
movq $0x0, 0x90(%rsp)
movq $0x17, 0x88(%rsp)
movq 0x90(%rsp), %rax
addq 0x88(%rsp), %rax
shrq %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rcx
leaq 0x11ee7(%rip), %rax     # 0x15c50
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, 0x64(%rsp)
movq %fs:0x0, %rax
movq %rax, %rcx
movl 0x64(%rsp), %eax
leaq -0x150(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x405c
movq $0x0, 0x78(%rsp)
movq 0x80(%rsp), %rax
leaq 0x11ea0(%rip), %rcx     # 0x15c50
shlq $0x4, %rax
addq %rax, %rcx
movl $0x80170000, %eax       # imm = 0x80170000
cmpl (%rcx), %eax
jne 0x3ecf
movl $0x100, %edi            # imm = 0x100
movl $0x1, %esi
callq 0x2230
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
xorl %esi, %esi
leaq 0xc779(%rip), %rdx      # 0x1055f
leaq 0xc751(%rip), %rcx      # 0x1053e
movl $0xd4, %r8d
callq 0x4150
testb $0x1, %al
jne 0x3e01
jmp 0x3ecd
jmp 0x3e03
movq $0x100, 0x70(%rsp)      # imm = 0x100
movq 0x78(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x58(%rsp)
movq %fs:0x0, %rax
leaq -0x150(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, 0x60(%rsp)
movq %fs:0x0, %rax
leaq -0x150(%rax), %rdi
addq $0x8, %rdi
xorl %esi, %esi
leaq 0xc705(%rip), %rdx      # 0x1055f
leaq 0xc6dd(%rip), %rcx      # 0x1053e
movl $0xd6, %r8d
callq 0x3b80
testb $0x1, %al
jne 0x3e72
jmp 0x3e90
movq %fs:0x0, %rax
leaq -0x150(%rax), %rax
addq $0x8, %rax
movq %rax, 0x48(%rsp)
jmp 0x3e9e
leaq 0xc4f0(%rip), %rax      # 0x10387
movq %rax, 0x48(%rsp)
jmp 0x3e9e
movl 0x60(%rsp), %ecx
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %r8
leaq 0xc6b5(%rip), %rdx      # 0x1056d
movb $0x0, %al
callq 0x2170
cmpl $0x0, %eax
jne 0x3ec9
movq 0x70(%rsp), %rax
jmp 0x3ecb
jmp 0x3ecd
jmp 0x3ecf
jmp 0x3ed1
movq $0x100, 0x68(%rsp)      # imm = 0x100
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %fs:0x0, %rax
leaq -0x150(%rax), %rax
movq 0x108(%rax), %rax
movq %rax, 0x30(%rsp)
movq %fs:0x0, %rax
leaq -0x150(%rax), %rax
movq 0x110(%rax), %rax
movq %rax, 0x38(%rsp)
movq %fs:0x0, %rax
leaq -0x150(%rax), %rax
movl 0x118(%rax), %eax
movl %eax, 0x44(%rsp)
movq 0x78(%rsp), %rdi
xorl %esi, %esi
leaq 0xc605(%rip), %rdx      # 0x1055f
leaq 0xc5dd(%rip), %rcx      # 0x1053e
movl $0xdb, %r8d
callq 0x3b80
testb $0x1, %al
jne 0x3f72
jmp 0x3f7e
movq 0x78(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x3ff2
movq 0x80(%rsp), %rcx
leaq 0x11cc3(%rip), %rax     # 0x15c50
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
leaq 0xc5be(%rip), %rdx      # 0x1055f
leaq 0xc596(%rip), %rcx      # 0x1053e
movl $0xdc, %r8d
callq 0x3b80
testb $0x1, %al
jne 0x3fb9
jmp 0x3fda
movq 0x80(%rsp), %rcx
leaq 0x11c88(%rip), %rax     # 0x15c50
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x3fe8
leaq 0xc3a6(%rip), %rax      # 0x10387
movq %rax, 0x10(%rsp)
jmp 0x3fe8
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x44(%rsp), %r9d
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rax
leaq 0xc571(%rip), %rdx      # 0x10588
movq %rax, (%rsp)
movb $0x0, %al
callq 0x2170
cmpl $0x0, %eax
jne 0x402c
movq 0x68(%rsp), %rax
jmp 0x402e
leaq 0x78(%rsp), %rdi
callq 0x7910
movq 0x80(%rsp), %rcx
leaq 0x11c09(%rip), %rax     # 0x15c50
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, 0x9c(%rsp)
jmp 0x4140
movq 0x90(%rsp), %rax
cmpq 0x88(%rsp), %rax
jne 0x4073
jmp 0x4140
movq 0x80(%rsp), %rcx
leaq 0x11bce(%rip), %rax     # 0x15c50
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movq %fs:0x0, %rax
movl 0xc(%rsp), %edx
leaq -0x150(%rax), %rax
movl (%rax), %esi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0x1, %eax
cmpl %esi, %edx
cmovbl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jle 0x40e9
movq 0x80(%rsp), %rax
subq $0x1, %rax
cmpq 0x90(%rsp), %rax
jb 0x40e9
movq 0x80(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x4119
movq 0x80(%rsp), %rax
addq $0x1, %rax
cmpq 0x88(%rsp), %rax
ja 0x4115
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x4117
jmp 0x4140
jmp 0x4119
movq 0x90(%rsp), %rax
addq 0x88(%rsp), %rax
shrq %rax
movq %rax, 0x80(%rsp)
movb $0x1, %al
testb $0x1, %al
jne 0x3d5a
jmp 0x4140
movl 0x9c(%rsp), %eax
addq $0xa8, %rsp
retq
nop