// File: /workspace/github_c_makefile_star2_O1/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, %ebx
movl %edi, %ebp
movl %ebp, %r15d
cmpw %bp, 0x1e212(%rip)      # 0x25a9c
jne 0x7897
xorl %eax, %eax
cmpw %bx, 0x1e209(%rip)      # 0x25a9e
je 0x78bc
movq 0x1e2fa(%rip), %r14     # 0x25b98
movq %r14, %rdi
callq 0x6160
leaq 0x1e363(%rip), %rdi     # 0x25c10
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
testl %eax, %eax
je 0x78cb
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x1e1d3(%rip), %eax     # 0x25aa4
cmpl $0x2, %eax
je 0x7943
cmpl $0x3, %eax
je 0x7917
cmpl $0x4, %eax
jne 0x7966
movl $0xff, %r12d
movl %r15d, %r13d
andl %r12d, %r13d
andl %ebx, %r12d
cmpw $0x18, %r13w
movl $0x18, %eax
cmovael %eax, %r13d
cmpw $0x18, %r12w
cmovael %eax, %r12d
movl $0xe7, %eax
addl %eax, %r13d
addl %eax, %r12d
jmp 0x7974
movl $0xff, %r12d
movl %r15d, %r13d
andl %r12d, %r13d
andl %ebx, %r12d
movl $0xd8, %eax
cmpl %eax, %r13d
cmovael %eax, %r13d
cmpl %eax, %r12d
cmovael %eax, %r12d
addl $0xf, %r13d
addl $0xf, %r12d
jmp 0x7974
movl $0xff, %r12d
movl %r15d, %r13d
andl %r12d, %r13d
andl %ebx, %r12d
xorl %eax, %eax
btl $0xd, %ebp
cmovbl %eax, %r13d
btl $0xd, %ebx
cmovbl %eax, %r12d
jmp 0x7974
movl %r15d, %r13d
andl $0xf, %r13d
movl %ebx, %r12d
andl $0xf, %r12d
btl $0x8, %ebp
jae 0x79a3
movq 0x1e227(%rip), %r14     # 0x25ba8
movq %r14, %rdi
callq 0x6160
leaq 0x1e280(%rip), %rdi     # 0x25c10
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
testl %eax, %eax
jne 0x78bc
btl $0xc, %ebp
jae 0x79d2
movq 0x1e200(%rip), %r14     # 0x25bb0
movq %r14, %rdi
callq 0x6160
leaq 0x1e251(%rip), %rdi     # 0x25c10
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
testl %eax, %eax
jne 0x78bc
btl $0x9, %ebp
jae 0x7a01
movq 0x1e1c1(%rip), %r14     # 0x25ba0
movq %r14, %rdi
callq 0x6160
leaq 0x1e222(%rip), %rdi     # 0x25c10
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
testl %eax, %eax
jne 0x78bc
btl $0xb, %ebp
jae 0x7a30
movq 0x1e1aa(%rip), %r14     # 0x25bb8
movq %r14, %rdi
callq 0x6160
leaq 0x1e1f3(%rip), %rdi     # 0x25c10
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
testl %eax, %eax
jne 0x78bc
btl $0xa, %ebp
setae %al
btl $0xa, %ebx
setae %cl
testb %cl, %al
jne 0x7a6b
movq 0x1e177(%rip), %r14     # 0x25bc0
movq %r14, %rdi
callq 0x6160
leaq 0x1e1b8(%rip), %rdi     # 0x25c10
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
testl %eax, %eax
jne 0x78bc
movzwl %bx, %eax
movl 0x1e02f(%rip), %r14d    # 0x25aa4
xorl %edx, %edx
cmpl $0x2, %r14d
sete %dl
shll $0xd, %edx
orl $0xff, %edx
andl %edx, %ebp
andl %eax, %edx
xorl %eax, %eax
movl %ebp, %ecx
orl %edx, %ecx
je 0x7b6f
movl %edx, 0xc(%rsp)
addl $-0x2, %r14d
leaq 0x1e16a(%rip), %rdi     # 0x25c10
leaq 0x16c6a(%rip), %rsi     # 0x1e717
movl $0x2, %edx
callq 0x8728
cmpl $0x3, %r14d
jae 0x7b6b
testl %eax, %eax
jne 0x7b6f
testl %ebp, %ebp
je 0x7b3b
leaq 0x1e13c(%rip), %rdi     # 0x25c10
leaq 0x16c3f(%rip), %rsi     # 0x1e71a
movl $0x5, %edx
callq 0x8728
testl %eax, %eax
jne 0x7b6f
movzwl %r13w, %edi
leaq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0x13f3d
movslq %eax, %rdx
leaq 0x1e108(%rip), %rdi     # 0x25c10
movq %r13, %rsi
callq 0x8728
testl %eax, %eax
jne 0x7b6f
cmpl $0x0, 0xc(%rsp)
je 0x7c51
leaq 0x1e0ea(%rip), %rdi     # 0x25c10
leaq 0x16bf1(%rip), %rsi     # 0x1e71e
movl $0x1, %edx
callq 0x8728
testl %eax, %eax
jne 0x7b6f
cmpl $0x0, 0xc(%rsp)
je 0x7c51
leaq 0x1e0c3(%rip), %rdi     # 0x25c10
leaq 0x16bcc(%rip), %rsi     # 0x1e720
movl $0x5, %edx
callq 0x8728
testl %eax, %eax
jne 0x7b6f
movzwl %r12w, %edi
jmp 0x7c2a
testl %eax, %eax
je 0x7b8d
testl %eax, %eax
jne 0x78bc
movw %r15w, 0x1df1d(%rip)    # 0x25a9c
movw %bx, 0x1df18(%rip)      # 0x25a9e
xorl %eax, %eax
jmp 0x78bc
testl %ebp, %ebp
je 0x7bfd
leaq 0x1e078(%rip), %rdi     # 0x25c10
leaq 0x171c3(%rip), %rsi     # 0x1ed62
movl $0x1, %edx
callq 0x8728
testl %eax, %eax
jne 0x7b6f
movzwl %r13w, %edi
decl %edi
leaq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0x13f3d
movslq %eax, %rdx
leaq 0x1e046(%rip), %rdi     # 0x25c10
movq %r13, %rsi
callq 0x8728
testl %eax, %eax
jne 0x7b6f
cmpl $0x0, 0xc(%rsp)
je 0x7c51
leaq 0x1e02c(%rip), %rdi     # 0x25c10
leaq 0x16b33(%rip), %rsi     # 0x1e71e
movl $0x1, %edx
callq 0x8728
testl %eax, %eax
jne 0x7b6f
cmpl $0x0, 0xc(%rsp)
je 0x7c51
leaq 0x1e005(%rip), %rdi     # 0x25c10
leaq 0x17154(%rip), %rsi     # 0x1ed66
movl $0x1, %edx
callq 0x8728
testl %eax, %eax
jne 0x7b6f
movzwl %r12w, %edi
decl %edi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x13f3d
movslq %eax, %rdx
leaq 0x1dfcf(%rip), %rdi     # 0x25c10
movq %r14, %rsi
callq 0x8728
testl %eax, %eax
jne 0x7b6f
leaq 0x1dfb8(%rip), %rdi     # 0x25c10
leaq 0x1636e(%rip), %rsi     # 0x1dfcd
movl $0x1, %edx
callq 0x8728
testl %eax, %eax
jne 0x7b6f
xorl %eax, %eax
jmp 0x7b6f