// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/src/sirtextstyle.c
// Function: sir_formatstyle
bool _sir_formatstyle(sir_colormode mode, const sir_textstyle* style,
    char buf[SIR_MAXSTYLE]) {
    if (!_sir_validtextstyle(mode, style))
        return false;

    _sir_resetstr(buf);

    switch (mode) {
        case SIRCM_16:
            /* \x1b[attr;fg;bgm */
            return 0 < snprintf(buf, SIR_MAXSTYLE, "%s%"PRIu8";%"PRIu8";%"PRIu8"m",
                SIR_ESC, (uint8_t)style->attr, (uint8_t)_sir_mkansifgcolor(style->fg),
                (uint8_t)_sir_mkansibgcolor(style->bg));
        case SIRCM_256: {
            /* \x1b[attr;38;5;fg;48;5;bgm */
            return 0 < snprintf(buf, SIR_MAXSTYLE,
                "%s%"PRIu8";%"PRIu8";5;%"PRIu8";%"PRIu8";5;%"PRIu8"m", SIR_ESC,
                (uint8_t)style->attr, (uint8_t)_sir_getansifgcmd(style->fg),
                (uint8_t)style->fg, (uint8_t)_sir_getansibgcmd(style->bg),
                (uint8_t)style->bg);
        }
        case SIRCM_RGB: {
            /* \x1b[attr;38;2;rrr;ggg;bbb;48;2;rrr;ggg;bbbm */
            return 0 < snprintf(buf, SIR_MAXSTYLE,
                "%s%"PRIu8";%"PRIu8";2;%"PRIu8";%"PRIu8";%"PRIu8";%"PRIu8
                ";2;%"PRIu8";%"PRIu8";%"PRIu8"m", SIR_ESC, (uint8_t)style->attr,
                (uint8_t)_sir_getansifgcmd(style->fg), _sir_getredfromcolor(style->fg),
                _sir_getgreenfromcolor(style->fg), _sir_getbluefromcolor(style->fg),
                (uint8_t)_sir_getansibgcmd(style->bg), _sir_getredfromcolor(style->bg),
                _sir_getgreenfromcolor(style->bg), _sir_getbluefromcolor(style->bg));
        }
        case SIRCM_INVALID: // GCOVR_EXCL_START
        default:
            return false;
    } // GCOVR_EXCL_STOP
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x98, %rsp
movl %edi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movl 0x90(%rsp), %edi
movq 0x88(%rsp), %rsi
callq 0xed20
testb $0x1, %al
jne 0xe809
movb $0x0, 0x97(%rsp)
jmp 0xeab7
movq 0x80(%rsp), %rdi
callq 0xeee0
movl 0x90(%rsp), %eax
movq %rax, 0x78(%rsp)
subq $0x3, %rax
ja 0xeaaf
movq 0x78(%rsp), %rax
leaq 0x37a8(%rip), %rcx      # 0x11fe0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x80(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x88(%rsp), %rax
movl (%rax), %eax
movzbl %al, %eax
movl %eax, 0x70(%rsp)
movq 0x88(%rsp), %rax
movl 0x4(%rax), %edi
callq 0xef00
movzbl %al, %eax
movl %eax, 0x74(%rsp)
movq 0x88(%rsp), %rax
movl 0x8(%rax), %edi
callq 0xef50
movq 0x68(%rsp), %rdi
movl 0x70(%rsp), %r8d
movl 0x74(%rsp), %r9d
movzbl %al, %eax
movl $0x2b, %esi
leaq 0x3814(%rip), %rdx      # 0x120b8
leaq 0x3819(%rip), %rcx      # 0x120c4
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2170
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
setl %al
andb $0x1, %al
movb %al, 0x97(%rsp)
jmp 0xeab7
movq 0x80(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x88(%rsp), %rax
movl (%rax), %eax
movzbl %al, %eax
movl %eax, 0x5c(%rsp)
movq 0x88(%rsp), %rax
movl 0x4(%rax), %edi
callq 0xefa0
movzbl %al, %eax
movl %eax, 0x60(%rsp)
movq 0x88(%rsp), %rax
movl 0x4(%rax), %eax
movzbl %al, %eax
movl %eax, 0x64(%rsp)
movq 0x88(%rsp), %rax
movl 0x8(%rax), %edi
callq 0xefc0
movq 0x50(%rsp), %rdi
movl 0x5c(%rsp), %r8d
movl 0x60(%rsp), %r9d
movl 0x64(%rsp), %r11d
movzbl %al, %r10d
movq 0x88(%rsp), %rax
movl 0x8(%rax), %eax
movzbl %al, %eax
movl $0x2b, %esi
leaq 0x3772(%rip), %rdx      # 0x120c7
leaq 0x3768(%rip), %rcx      # 0x120c4
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x2170
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
setl %al
andb $0x1, %al
movb %al, 0x97(%rsp)
jmp 0xeab7
movq 0x80(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x88(%rsp), %rax
movl (%rax), %eax
movzbl %al, %eax
movl %eax, 0x48(%rsp)
movq 0x88(%rsp), %rax
movl 0x4(%rax), %edi
callq 0xefa0
movzbl %al, %eax
movl %eax, 0x4c(%rsp)
movq 0x88(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movzbl %al, %r15d
movq 0x88(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movzbl %al, %r14d
movq 0x88(%rsp), %rax
movl 0x4(%rax), %eax
andl $0xff, %eax
movzbl %al, %ebp
movq 0x88(%rsp), %rax
movl 0x8(%rax), %edi
callq 0xefc0
movq 0x40(%rsp), %rdi
movl 0x48(%rsp), %r8d
movl 0x4c(%rsp), %r9d
movzbl %al, %ebx
movq 0x88(%rsp), %rax
movl 0x8(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movzbl %al, %r11d
movq 0x88(%rsp), %rax
movl 0x8(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movzbl %al, %r10d
movq 0x88(%rsp), %rax
movl 0x8(%rax), %eax
andl $0xff, %eax
movzbl %al, %eax
movl $0x2b, %esi
leaq 0x3671(%rip), %rdx      # 0x120dd
leaq 0x3651(%rip), %rcx      # 0x120c4
movl %r15d, (%rsp)
movl %r14d, 0x8(%rsp)
movl %ebp, 0x10(%rsp)
movl %ebx, 0x18(%rsp)
movl %r11d, 0x20(%rsp)
movl %r10d, 0x28(%rsp)
movl %eax, 0x30(%rsp)
movb $0x0, %al
callq 0x2170
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
setl %al
andb $0x1, %al
movb %al, 0x97(%rsp)
jmp 0xeab7
jmp 0xeaaf
movb $0x0, 0x97(%rsp)
movb 0x97(%rsp), %al
andb $0x1, %al
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop