// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movw %si, %ax
movw %di, %cx
movw %cx, -0x6(%rbp)
movw %ax, -0x8(%rbp)
movzwl -0x6(%rbp), %eax
movzwl 0x3484b(%rip), %ecx     # 0x3becc
cmpl %ecx, %eax
jne 0x76a0
movzwl -0x8(%rbp), %eax
movzwl 0x3483e(%rip), %ecx     # 0x3bece
cmpl %ecx, %eax
jne 0x76a0
movl $0x0, -0x4(%rbp)
jmp 0x7a0a
movq 0x34921(%rip), %rsi     # 0x3bfc8
leaq 0x347ea(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x76cd
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7a0a
movl 0x34801(%rip), %eax     # 0x3bed4
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x3, %eax
ja 0x76f4
movq -0x30(%rbp), %rax
leaq 0x2a925(%rip), %rcx     # 0x32010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x76f6
movzwl -0x6(%rbp), %eax
andl $0xf, %eax
movw %ax, -0xe(%rbp)
movzwl -0x8(%rbp), %eax
andl $0xf, %eax
movw %ax, -0x10(%rbp)
jmp 0x77fe
movzwl -0x6(%rbp), %eax
andl $0xff, %eax
movw %ax, -0xe(%rbp)
movzwl -0x8(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x10(%rbp)
movzwl -0x6(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x773f
movw $0x0, -0xe(%rbp)
movzwl -0x8(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x7753
movw $0x0, -0x10(%rbp)
jmp 0x77fe
movzwl -0x6(%rbp), %eax
andl $0xff, %eax
movw %ax, -0xe(%rbp)
movzwl -0x8(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x10(%rbp)
movzwl -0xe(%rbp), %eax
cmpl $0xd8, %eax
jle 0x7783
movw $0xd8, -0xe(%rbp)
movzwl -0x10(%rbp), %eax
cmpl $0xd8, %eax
jle 0x7794
movw $0xd8, -0x10(%rbp)
movzwl -0xe(%rbp), %eax
addl $0xf, %eax
movw %ax, -0xe(%rbp)
movzwl -0x10(%rbp), %eax
addl $0xf, %eax
movw %ax, -0x10(%rbp)
jmp 0x77fe
movzwl -0x6(%rbp), %eax
andl $0xff, %eax
movw %ax, -0xe(%rbp)
movzwl -0x8(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x10(%rbp)
movzwl -0xe(%rbp), %eax
cmpl $0x18, %eax
jle 0x77d5
movw $0x18, -0xe(%rbp)
movzwl -0x10(%rbp), %eax
cmpl $0x18, %eax
jle 0x77e4
movw $0x18, -0x10(%rbp)
movzwl -0xe(%rbp), %eax
addl $0xe7, %eax
movw %ax, -0xe(%rbp)
movzwl -0x10(%rbp), %eax
addl $0xe7, %eax
movw %ax, -0x10(%rbp)
movw $0x100, -0x12(%rbp)     # imm = 0x100
movw $0x1000, -0x14(%rbp)    # imm = 0x1000
movw $0x800, -0x16(%rbp)     # imm = 0x800
movw $0x200, -0x18(%rbp)     # imm = 0x200
movw $0x400, -0x1a(%rbp)     # imm = 0x400
movzwl -0x6(%rbp), %eax
movzwl -0x12(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x785a
movq 0x347a6(%rip), %rsi     # 0x3bfd8
leaq 0x3465f(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x7858
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7a0a
jmp 0x785a
movzwl -0x6(%rbp), %eax
movzwl -0x14(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x7898
movq 0x34770(%rip), %rsi     # 0x3bfe0
leaq 0x34621(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x7896
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7a0a
jmp 0x7898
movzwl -0x6(%rbp), %eax
movzwl -0x18(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x78d6
movq 0x34722(%rip), %rsi     # 0x3bfd0
leaq 0x345e3(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x78d4
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7a0a
jmp 0x78d6
movzwl -0x6(%rbp), %eax
movzwl -0x16(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x7914
movq 0x346fc(%rip), %rsi     # 0x3bfe8
leaq 0x345a5(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x7912
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7a0a
jmp 0x7914
movzwl -0x6(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
jne 0x7932
movzwl -0x8(%rbp), %eax
movzwl -0x1a(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x7961
movq 0x346b7(%rip), %rsi     # 0x3bff0
leaq 0x34558(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x795f
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7a0a
jmp 0x7961
movzwl -0x6(%rbp), %eax
andl $0xff, %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x20(%rbp)
movzwl -0x8(%rbp), %eax
andl $0xff, %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
cmpl $0x2, 0x3453e(%rip)     # 0x3bed4
jne 0x79c4
movzwl -0x6(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x79ad
movl $0x0, -0x20(%rbp)
movzwl -0x8(%rbp), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x79c2
movl $0x0, -0x24(%rbp)
jmp 0x79c4
movw -0xe(%rbp), %si
movw -0x10(%rbp), %ax
movl -0x20(%rbp), %edx
movl -0x24(%rbp), %ecx
movzwl %si, %edi
movzwl %ax, %esi
callq 0xdf90
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x79ed
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7a0a
movw -0x6(%rbp), %ax
movw %ax, 0x344d4(%rip)      # 0x3becc
movw -0x8(%rbp), %ax
movw %ax, 0x344cb(%rip)      # 0x3bece
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)