// File: /workspace/github_c_makefile_star2_O2/adsr[P]phpspy/vendor/termbox2/termbox2.h
// Function: send_attr
static int send_attr(uintattr_t fg, uintattr_t bg) {
    int rv;

    if (fg == global.last_fg && bg == global.last_bg) {
        return TB_OK;
    }

    if_err_return(rv, bytebuf_puts(&global.out, global.caps[TB_CAP_SGR0]));

    uintattr_t cfg, cbg;
    switch (global.output_mode) {
        default:
        case TB_OUTPUT_NORMAL:
            cfg = fg & 0x0f;
            cbg = bg & 0x0f;
            break;

        case TB_OUTPUT_256:
            cfg = fg & 0xff;
            cbg = bg & 0xff;
            if (fg & TB_256_BLACK) cfg = 0;
            if (bg & TB_256_BLACK) cbg = 0;
            break;

        case TB_OUTPUT_216:
            cfg = fg & 0xff;
            cbg = bg & 0xff;
            if (cfg > 216)
                cfg = 216;
            if (cbg > 216)
                cbg = 216;
            cfg += 0x0f;
            cbg += 0x0f;
            break;

        case TB_OUTPUT_GRAYSCALE:
            cfg = fg & 0xff;
            cbg = bg & 0xff;
            if (cfg > 24)
                cfg = 24;
            if (cbg > 24)
                cbg = 24;
            cfg += 0xe7;
            cbg += 0xe7;
            break;

#ifdef TB_OPT_TRUECOLOR
        case TB_OUTPUT_TRUECOLOR:
            cfg = fg & 0xffffff;
            cbg = bg & 0xffffff;
            if (fg & TB_TRUECOLOR_BLACK) cfg = 0;
            if (bg & TB_TRUECOLOR_BLACK) cbg = 0;
            break;
#endif
    }

    uintattr_t attr_bold, attr_blink, attr_italic, attr_underline, attr_reverse;
#ifdef TB_OPT_TRUECOLOR
    if (global.output_mode == TB_OUTPUT_TRUECOLOR) {
        attr_bold = TB_TRUECOLOR_BOLD;
        attr_blink = TB_TRUECOLOR_BLINK;
        attr_italic = TB_TRUECOLOR_ITALIC;
        attr_underline = TB_TRUECOLOR_UNDERLINE;
        attr_reverse = TB_TRUECOLOR_REVERSE;
    } else
#endif
    {
        attr_bold = TB_BOLD;
        attr_blink = TB_BLINK;
        attr_italic = TB_ITALIC;
        attr_underline = TB_UNDERLINE;
        attr_reverse = TB_REVERSE;
    }

    if (fg & attr_bold)
        if_err_return(rv, bytebuf_puts(&global.out, global.caps[TB_CAP_BOLD]));

    if (fg & attr_blink)
        if_err_return(rv, bytebuf_puts(&global.out, global.caps[TB_CAP_BLINK]));

    if (fg & attr_underline)
        if_err_return(rv,
            bytebuf_puts(&global.out, global.caps[TB_CAP_UNDERLINE]));

    if (fg & attr_italic)
        if_err_return(rv,
            bytebuf_puts(&global.out, global.caps[TB_CAP_ITALIC]));

    if ((fg & attr_reverse) || (bg & attr_reverse))
        if_err_return(rv,
            bytebuf_puts(&global.out, global.caps[TB_CAP_REVERSE]));

    int fg_is_default = (fg & 0xff) == 0;
    int bg_is_default = (bg & 0xff) == 0;
    if (global.output_mode == TB_OUTPUT_256) {
        if (fg & TB_256_BLACK) fg_is_default = 0;
        if (bg & TB_256_BLACK) bg_is_default = 0;
    }
#ifdef TB_OPT_TRUECOLOR
    if (global.output_mode == TB_OUTPUT_TRUECOLOR) {
        fg_is_default = ((fg & 0xffffff) == 0) && ((fg & TB_TRUECOLOR_BLACK) == 0);
        bg_is_default = ((bg & 0xffffff) == 0) && ((bg & TB_TRUECOLOR_BLACK) == 0);
    }
#endif

    if_err_return(rv, send_sgr(cfg, cbg, fg_is_default, bg_is_default));

    global.last_fg = fg;
    global.last_bg = bg;

    return TB_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movl %edi, %r14d
movl %r14d, %r15d
xorl %ebx, %ebx
cmpw %r14w, 0x1e772(%rip)    # 0x25a9c
jne 0x7335
cmpw %bp, 0x1e76b(%rip)      # 0x25a9e
je 0x7347
movq 0x1e85c(%rip), %rdi     # 0x25b98
callq 0x78d9
testl %eax, %eax
je 0x7358
movl %eax, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x1e746(%rip), %eax     # 0x25aa4
cmpl $0x2, %eax
je 0x73d4
cmpl $0x3, %eax
je 0x73a2
cmpl $0x4, %eax
jne 0x73f8
movl $0xff, %r12d
movl %r15d, %r13d
andl %r12d, %r13d
andl %ebp, %r12d
cmpw $0x18, %r13w
pushq $0x18
popq %rax
cmovael %eax, %r13d
cmpw $0x18, %r12w
cmovael %eax, %r12d
movl $0xe7, %eax
addl %eax, %r13d
addl %eax, %r12d
jmp 0x7406
movl $0xff, %r12d
movl %r15d, %r13d
andl %r12d, %r13d
andl %ebp, %r12d
movw $0xd8, %ax
cmpw %ax, %r13w
movl $0xd8, %ecx
cmovael %ecx, %r13d
cmpw %ax, %r12w
cmovael %ecx, %r12d
addl $0xf, %r13d
addl $0xf, %r12d
jmp 0x7406
movl $0xff, %r12d
movl %r15d, %r13d
andl %r12d, %r13d
andl %ebp, %r12d
xorl %eax, %eax
btl $0xd, %r14d
cmovbl %eax, %r13d
btl $0xd, %ebp
cmovbl %eax, %r12d
jmp 0x7406
movl %r15d, %r13d
andl $0xf, %r13d
movl %ebp, %r12d
andl $0xf, %r12d
btl $0x8, %r14d
jae 0x7421
movq 0x1e794(%rip), %rdi     # 0x25ba8
callq 0x78d9
testl %eax, %eax
jne 0x7345
btl $0xc, %r14d
jae 0x743c
movq 0x1e781(%rip), %rdi     # 0x25bb0
callq 0x78d9
testl %eax, %eax
jne 0x7345
btl $0x9, %r14d
jae 0x7457
movq 0x1e756(%rip), %rdi     # 0x25ba0
callq 0x78d9
testl %eax, %eax
jne 0x7345
btl $0xb, %r14d
jae 0x7472
movq 0x1e753(%rip), %rdi     # 0x25bb8
callq 0x78d9
testl %eax, %eax
jne 0x7345
btl $0xa, %r14d
setae %al
btl $0xa, %ebp
setae %cl
testb %cl, %al
jne 0x7499
movq 0x1e734(%rip), %rdi     # 0x25bc0
callq 0x78d9
testl %eax, %eax
jne 0x7345
movzwl %bp, %eax
movl 0x1e602(%rip), %edx     # 0x25aa4
xorl %ecx, %ecx
cmpl $0x2, %edx
sete %cl
shll $0xd, %ecx
orl $0xff, %ecx
andl %ecx, %r14d
andl %eax, %ecx
movl %r14d, %eax
orl %ecx, %eax
je 0x7699
movl %ecx, 0x8(%rsp)
addl $-0x2, %edx
movl %edx, 0xc(%rsp)
leaq 0x1e73b(%rip), %rdi     # 0x25c10
leaq 0x1623b(%rip), %rsi     # 0x1d717
pushq $0x2
popq %rdx
callq 0x7f4b
cmpl $0x3, 0xc(%rsp)
jae 0x7577
testl %eax, %eax
jne 0x7345
testl %r14d, %r14d
je 0x75fe
leaq 0x1e709(%rip), %rdi     # 0x25c10
leaq 0x1620c(%rip), %rsi     # 0x1d71a
pushq $0x5
popq %rdx
callq 0x7f4b
testl %eax, %eax
jne 0x7345
movzwl %r13w, %edi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x13ad6
movslq %eax, %rdx
leaq 0x1e6d7(%rip), %rdi     # 0x25c10
movq %r14, %rsi
callq 0x7f4b
testl %eax, %eax
jne 0x7345
cmpl $0x0, 0x8(%rsp)
je 0x767b
leaq 0x1e6b5(%rip), %rdi     # 0x25c10
leaq 0x161bc(%rip), %rsi     # 0x1d71e
pushq $0x1
popq %rdx
callq 0x7f4b
testl %eax, %eax
jne 0x7345
jmp 0x7605
testl %eax, %eax
jne 0x7345
testl %r14d, %r14d
je 0x7629
leaq 0x1e681(%rip), %rdi     # 0x25c10
leaq 0x167cc(%rip), %rsi     # 0x1dd62
pushq $0x1
popq %rdx
callq 0x7f4b
testl %eax, %eax
jne 0x7345
movzwl %r13w, %edi
decl %edi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x13ad6
movslq %eax, %rdx
leaq 0x1e64d(%rip), %rdi     # 0x25c10
movq %r14, %rsi
callq 0x7f4b
testl %eax, %eax
jne 0x7345
cmpl $0x0, 0x8(%rsp)
je 0x767b
leaq 0x1e62b(%rip), %rdi     # 0x25c10
leaq 0x16132(%rip), %rsi     # 0x1d71e
pushq $0x1
popq %rdx
callq 0x7f4b
testl %eax, %eax
jne 0x7345
jmp 0x7630
cmpl $0x0, 0x8(%rsp)
je 0x767b
leaq 0x1e604(%rip), %rdi     # 0x25c10
leaq 0x1610d(%rip), %rsi     # 0x1d720
pushq $0x5
popq %rdx
callq 0x7f4b
testl %eax, %eax
jne 0x7345
movzwl %r12w, %edi
jmp 0x7654
cmpl $0x0, 0x8(%rsp)
je 0x767b
leaq 0x1e5d9(%rip), %rdi     # 0x25c10
leaq 0x16728(%rip), %rsi     # 0x1dd66
pushq $0x1
popq %rdx
callq 0x7f4b
testl %eax, %eax
jne 0x7345
movzwl %r12w, %edi
decl %edi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x13ad6
movslq %eax, %rdx
leaq 0x1e5a5(%rip), %rdi     # 0x25c10
movq %r14, %rsi
callq 0x7f4b
testl %eax, %eax
jne 0x7345
leaq 0x1e58e(%rip), %rdi     # 0x25c10
leaq 0x15944(%rip), %rsi     # 0x1cfcd
pushq $0x1
popq %rdx
callq 0x7f4b
testl %eax, %eax
jne 0x7345
movw %r15w, 0x1e3fb(%rip)    # 0x25a9c
movw %bp, 0x1e3f6(%rip)      # 0x25a9e
jmp 0x7347