// File: /workspace/github_c_makefile_star2_O3/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, %r12d
xorl %ebx, %ebx
cmpw %r14w, 0x1e319(%rip)    # 0x25a9c
jne 0x778e
cmpw %bp, 0x1e312(%rip)      # 0x25a9e
je 0x77b5
movq 0x1e403(%rip), %r15     # 0x25b98
movq %r15, %rdi
callq 0x6160
leaq 0x1e46c(%rip), %rdi     # 0x25c10
movq %r15, %rsi
movq %rax, %rdx
callq 0x8535
testl %eax, %eax
je 0x77c6
movl %eax, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x1e2d8(%rip), %eax     # 0x25aa4
cmpl $0x2, %eax
je 0x7830
cmpl $0x3, %eax
je 0x7809
cmpl $0x4, %eax
jne 0x7855
movl $0xff, %ecx
movl %r12d, %r13d
andl %ecx, %r13d
andl %ebp, %ecx
cmpw $0x18, %r13w
movl $0x18, %eax
cmovael %eax, %r13d
cmpw $0x18, %cx
cmovael %eax, %ecx
movl $0xe7, %eax
addl %eax, %r13d
addl %eax, %ecx
jmp 0x784f
movl $0xff, %ecx
movl %r12d, %r13d
andl %ecx, %r13d
andl %ebp, %ecx
movl $0xd8, %eax
cmpl %eax, %r13d
cmovael %eax, %r13d
cmpl %eax, %ecx
cmovael %eax, %ecx
addl $0xf, %r13d
addl $0xf, %ecx
jmp 0x784f
movl $0xff, %ecx
movl %r12d, %r13d
andl %ecx, %r13d
andl %ebp, %ecx
xorl %eax, %eax
btl $0xd, %r14d
cmovbl %eax, %r13d
btl $0xd, %ebp
cmovbl %eax, %ecx
movl %ecx, 0x8(%rsp)
jmp 0x7865
movl %r12d, %r13d
andl $0xf, %r13d
movl %ebp, %eax
andl $0xf, %eax
movl %eax, 0x8(%rsp)
btl $0x8, %r14d
jae 0x7895
movq 0x1e335(%rip), %r15     # 0x25ba8
movq %r15, %rdi
callq 0x6160
leaq 0x1e38e(%rip), %rdi     # 0x25c10
movq %r15, %rsi
movq %rax, %rdx
callq 0x8535
testl %eax, %eax
jne 0x77b3
btl $0xc, %r14d
jae 0x78c5
movq 0x1e30d(%rip), %r15     # 0x25bb0
movq %r15, %rdi
callq 0x6160
leaq 0x1e35e(%rip), %rdi     # 0x25c10
movq %r15, %rsi
movq %rax, %rdx
callq 0x8535
testl %eax, %eax
jne 0x77b3
btl $0x9, %r14d
jae 0x78f5
movq 0x1e2cd(%rip), %r15     # 0x25ba0
movq %r15, %rdi
callq 0x6160
leaq 0x1e32e(%rip), %rdi     # 0x25c10
movq %r15, %rsi
movq %rax, %rdx
callq 0x8535
testl %eax, %eax
jne 0x77b3
btl $0xb, %r14d
jae 0x7925
movq 0x1e2b5(%rip), %r15     # 0x25bb8
movq %r15, %rdi
callq 0x6160
leaq 0x1e2fe(%rip), %rdi     # 0x25c10
movq %r15, %rsi
movq %rax, %rdx
callq 0x8535
testl %eax, %eax
jne 0x77b3
btl $0xa, %r14d
setae %al
btl $0xa, %ebp
setae %cl
testb %cl, %al
jne 0x7961
movq 0x1e281(%rip), %r15     # 0x25bc0
movq %r15, %rdi
callq 0x6160
leaq 0x1e2c2(%rip), %rdi     # 0x25c10
movq %r15, %rsi
movq %rax, %rdx
callq 0x8535
testl %eax, %eax
jne 0x77b3
movzwl %bp, %eax
movl 0x1e13a(%rip), %ecx     # 0x25aa4
xorl %r15d, %r15d
cmpl $0x2, %ecx
sete %r15b
shll $0xd, %r15d
orl $0xff, %r15d
andl %r15d, %r14d
andl %eax, %r15d
movl %r14d, %eax
orl %r15d, %eax
je 0x7b6d
addl $-0x2, %ecx
movl %ecx, 0xc(%rsp)
leaq 0x1e271(%rip), %rdi     # 0x25c10
leaq 0x16d71(%rip), %rsi     # 0x1e717
movl $0x2, %edx
callq 0x8535
cmpl $0x3, 0xc(%rsp)
jae 0x7a45
testl %eax, %eax
jne 0x77b3
testl %r14d, %r14d
je 0x7ace
leaq 0x1e23d(%rip), %rdi     # 0x25c10
leaq 0x16d40(%rip), %rsi     # 0x1e71a
movl $0x5, %edx
callq 0x8535
testl %eax, %eax
jne 0x77b3
movzwl %r13w, %edi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x13b6e
movslq %eax, %rdx
leaq 0x1e209(%rip), %rdi     # 0x25c10
movq %r14, %rsi
callq 0x8535
testl %eax, %eax
jne 0x77b3
testl %r15d, %r15d
je 0x7b4d
leaq 0x1e1e9(%rip), %rdi     # 0x25c10
leaq 0x16cf0(%rip), %rsi     # 0x1e71e
movl $0x1, %edx
callq 0x8535
testl %eax, %eax
jne 0x77b3
jmp 0x7ad3
testl %eax, %eax
jne 0x77b3
testl %r14d, %r14d
je 0x7afa
leaq 0x1e1b3(%rip), %rdi     # 0x25c10
leaq 0x172fe(%rip), %rsi     # 0x1ed62
movl $0x1, %edx
callq 0x8535
testl %eax, %eax
jne 0x77b3
movzwl %r13w, %edi
decl %edi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x13b6e
movslq %eax, %rdx
leaq 0x1e17d(%rip), %rdi     # 0x25c10
movq %r14, %rsi
callq 0x8535
testl %eax, %eax
jne 0x77b3
testl %r15d, %r15d
je 0x7b4d
leaq 0x1e15d(%rip), %rdi     # 0x25c10
leaq 0x16c64(%rip), %rsi     # 0x1e71e
movl $0x1, %edx
callq 0x8535
testl %eax, %eax
jne 0x77b3
jmp 0x7aff
testl %r15d, %r15d
je 0x7b4d
leaq 0x1e136(%rip), %rdi     # 0x25c10
leaq 0x16c3f(%rip), %rsi     # 0x1e720
movl $0x5, %edx
callq 0x8535
testl %eax, %eax
jne 0x77b3
movzwl 0x8(%rsp), %edi
jmp 0x7b26
testl %r15d, %r15d
je 0x7b4d
leaq 0x1e10a(%rip), %rdi     # 0x25c10
leaq 0x17259(%rip), %rsi     # 0x1ed66
movl $0x1, %edx
callq 0x8535
testl %eax, %eax
jne 0x77b3
movzwl 0x8(%rsp), %edi
decl %edi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x13b6e
movslq %eax, %rdx
leaq 0x1e0d3(%rip), %rdi     # 0x25c10
movq %r14, %rsi
callq 0x8535
testl %eax, %eax
jne 0x77b3
leaq 0x1e0bc(%rip), %rdi     # 0x25c10
leaq 0x16472(%rip), %rsi     # 0x1dfcd
movl $0x1, %edx
callq 0x8535
testl %eax, %eax
jne 0x77b3
movw %r12w, 0x1df27(%rip)    # 0x25a9c
movw %bp, 0x1df22(%rip)      # 0x25a9e
jmp 0x77b5