// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/src/sirtextstyle.c
// Function: sir_settextstyle
bool _sir_settextstyle(sir_level level, const sir_textstyle* style) {
    (void)_sir_seterror(_SIR_E_NOERROR);

    if (!_sir_sanity() || !_sir_validlevel(level))
        return false;

    _SIR_LOCK_SECTION(sir_text_style_data, data, SIRMI_TEXTSTYLE, false);
    bool updated              = false;
    static const size_t low   = 0;
    static const size_t high  = SIR_NUMLEVELS - 1;

    _SIR_DECLARE_BIN_SEARCH(low, high);
    _SIR_BEGIN_BIN_SEARCH()

    if (data->map[_mid].level == level) {
        (void)memcpy(&data->map[_mid].style, style, sizeof(sir_textstyle));
        updated = _sir_formatstyle(*data->color_mode, style, data->map[_mid].str);
        break;
    }

    _SIR_ITERATE_BIN_SEARCH((data->map[_mid].level < level ? 1 : -1));
    _SIR_END_BIN_SEARCH();
    _SIR_UNLOCK_SECTION(SIRMI_TEXTSTYLE);

    SIR_ASSERT(updated);
    return updated;
}

// Assembly:
subq $0x38, %rsp
movw %di, %ax
movw %ax, 0x34(%rsp)
movq %rsi, 0x28(%rsp)
movl $0x80010000, %edi       # imm = 0x80010000
leaq 0x3ab4(%rip), %rsi      # 0x12091
leaq 0x3a9e(%rip), %rdx      # 0x12082
movl $0x46, %ecx
callq 0x3940
callq 0x9d10
testb $0x1, %al
jne 0xe5f9
jmp 0xe61a
leaq 0x3a91(%rip), %rsi      # 0x12091
leaq 0x3a7b(%rip), %rdx      # 0x12082
movl $0x48, %ecx
movzwl 0x34(%rsp), %edi
callq 0x8080
testb $0x1, %al
jne 0xe624
movb $0x0, 0x37(%rsp)
jmp 0xe7ad
movl $0x3, %edi
callq 0x9650
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0xe662
movl $0x800f0000, %edi       # imm = 0x800F0000
leaq 0x3a4a(%rip), %rsi      # 0x12091
leaq 0x3a34(%rip), %rdx      # 0x12082
movl $0x4b, %ecx
callq 0x3940
movb $0x0, 0x37(%rsp)
jmp 0xe7ad
jmp 0xe664
movb $0x0, 0x1f(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x7, 0x8(%rsp)
movq 0x10(%rsp), %rax
addq 0x8(%rsp), %rax
shrq %rax
movq %rax, (%rsp)
movq 0x20(%rsp), %rax
movq (%rax), %rax
imulq $0x3c, (%rsp), %rcx
addq %rcx, %rax
movzwl (%rax), %eax
movzwl 0x34(%rsp), %ecx
cmpl %ecx, %eax
jne 0xe6fe
movq 0x20(%rsp), %rax
movq (%rax), %rax
imulq $0x3c, (%rsp), %rcx
addq %rcx, %rax
movq 0x28(%rsp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x4(%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0xc(%rax)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rax), %edi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rax
movq (%rax), %rdx
imulq $0x3c, (%rsp), %rax
addq %rax, %rdx
addq $0x10, %rdx
callq 0xe7c0
andb $0x1, %al
movb %al, 0x1f(%rsp)
jmp 0xe799
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0xe70f
jmp 0xe799
movq 0x20(%rsp), %rax
movq (%rax), %rax
imulq $0x3c, (%rsp), %rcx
addq %rcx, %rax
movzwl (%rax), %edx
movzwl 0x34(%rsp), %esi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0x1, %eax
cmpl %esi, %edx
cmovll %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jle 0xe75a
movq (%rsp), %rax
subq $0x1, %rax
cmpq 0x10(%rsp), %rax
jb 0xe75a
movq (%rsp), %rax
subq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0xe77c
movq (%rsp), %rax
addq $0x1, %rax
cmpq 0x8(%rsp), %rax
ja 0xe778
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, 0x10(%rsp)
jmp 0xe77a
jmp 0xe799
jmp 0xe77c
movq 0x10(%rsp), %rax
addq 0x8(%rsp), %rax
shrq %rax
movq %rax, (%rsp)
movb $0x1, %al
testb $0x1, %al
jne 0xe68c
jmp 0xe799
movl $0x3, %edi
callq 0x9aa0
movb 0x1f(%rsp), %al
andb $0x1, %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
andb $0x1, %al
addq $0x38, %rsp
retq
nopl (%rax,%rax)