// File: /workspace/github_c_makefile_star2_O0/termbox[P]termbox/termbox.c
// Function: send_attr
static void send_attr(uint16_t fg, uint16_t bg) {
#define LAST_ATTR_INIT 0xFFFF
    static uint16_t lastfg = LAST_ATTR_INIT, lastbg = LAST_ATTR_INIT;
    if (fg != lastfg || bg != lastbg) {
        bytebuffer_puts(&output_buffer, funcs[T_SGR0]);

        uint16_t fgcol;
        uint16_t bgcol;

        switch (outputmode) {
        case TB_OUTPUT_256:
            fgcol = fg & 0xFF;
            bgcol = bg & 0xFF;
            break;

        case TB_OUTPUT_216:
            fgcol = fg & 0xFF;
            if (fgcol > 215)
                fgcol = 7;
            bgcol = bg & 0xFF;
            if (bgcol > 215)
                bgcol = 0;
            fgcol += 0x10;
            bgcol += 0x10;
            break;

        case TB_OUTPUT_GRAYSCALE:
            fgcol = fg & 0xFF;
            if (fgcol > 23)
                fgcol = 23;
            bgcol = bg & 0xFF;
            if (bgcol > 23)
                bgcol = 0;
            fgcol += 0xe8;
            bgcol += 0xe8;
            break;

        case TB_OUTPUT_NORMAL:
        default:
            fgcol = fg & 0x0F;
            bgcol = bg & 0x0F;
        }

        if (fg & TB_BOLD)
            bytebuffer_puts(&output_buffer, funcs[T_BOLD]);
        if (bg & TB_BOLD)
            bytebuffer_puts(&output_buffer, funcs[T_BLINK]);
        if (fg & TB_UNDERLINE)
            bytebuffer_puts(&output_buffer, funcs[T_UNDERLINE]);
        if ((fg & TB_REVERSE) || (bg & TB_REVERSE))
            bytebuffer_puts(&output_buffer, funcs[T_REVERSE]);

        write_sgr(fgcol, bgcol);

        lastfg = fg;
        lastbg = bg;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movw %si, %ax
movw %di, %cx
movw %cx, -0x2(%rbp)
movw %ax, -0x4(%rbp)
movzwl -0x2(%rbp), %eax
movzwl 0x657f(%rip), %ecx      # 0xa930
cmpl %ecx, %eax
jne 0x43c8
movzwl -0x4(%rbp), %eax
movzwl 0x6572(%rip), %ecx      # 0xa932
cmpl %ecx, %eax
je 0x45b1
movq 0x65d9(%rip), %rax      # 0xa9a8
movq 0x28(%rax), %rsi
leaq 0x65be(%rip), %rdi      # 0xa998
callq 0x3c00
movl 0x5d77(%rip), %eax      # 0xa15c
decl %eax
movl %eax, %ecx
movq %rcx, -0x10(%rbp)
subl $0x3, %eax
ja 0x44d3
movq -0x10(%rbp), %rax
leaq 0x2c6f(%rip), %rcx      # 0x7070
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl -0x2(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x6(%rbp)
movzwl -0x4(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x8(%rbp)
jmp 0x44e9
movzwl -0x2(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x6(%rbp)
movzwl -0x6(%rbp), %eax
cmpl $0xd7, %eax
jle 0x4447
movw $0x7, -0x6(%rbp)
movzwl -0x4(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x8(%rbp)
movzwl -0x8(%rbp), %eax
cmpl $0xd7, %eax
jle 0x4465
movw $0x0, -0x8(%rbp)
movzwl -0x6(%rbp), %eax
addl $0x10, %eax
movw %ax, -0x6(%rbp)
movzwl -0x8(%rbp), %eax
addl $0x10, %eax
movw %ax, -0x8(%rbp)
jmp 0x44e9
movzwl -0x2(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x6(%rbp)
movzwl -0x6(%rbp), %eax
cmpl $0x17, %eax
jle 0x4499
movw $0x17, -0x6(%rbp)
movzwl -0x4(%rbp), %eax
andl $0xff, %eax
movw %ax, -0x8(%rbp)
movzwl -0x8(%rbp), %eax
cmpl $0x17, %eax
jle 0x44b5
movw $0x0, -0x8(%rbp)
movzwl -0x6(%rbp), %eax
addl $0xe8, %eax
movw %ax, -0x6(%rbp)
movzwl -0x8(%rbp), %eax
addl $0xe8, %eax
movw %ax, -0x8(%rbp)
jmp 0x44e9
jmp 0x44d3
movzwl -0x2(%rbp), %eax
andl $0xf, %eax
movw %ax, -0x6(%rbp)
movzwl -0x4(%rbp), %eax
andl $0xf, %eax
movw %ax, -0x8(%rbp)
movzwl -0x2(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x450e
movq 0x64aa(%rip), %rax      # 0xa9a8
movq 0x38(%rax), %rsi
leaq 0x648f(%rip), %rdi      # 0xa998
callq 0x3c00
movzwl -0x4(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x4533
movq 0x6485(%rip), %rax      # 0xa9a8
movq 0x40(%rax), %rsi
leaq 0x646a(%rip), %rdi      # 0xa998
callq 0x3c00
movzwl -0x2(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x4558
movq 0x6460(%rip), %rax      # 0xa9a8
movq 0x30(%rax), %rsi
leaq 0x6445(%rip), %rdi      # 0xa998
callq 0x3c00
movzwl -0x2(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x4574
movzwl -0x4(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x458b
movq 0x642d(%rip), %rax      # 0xa9a8
movq 0x48(%rax), %rsi
leaq 0x6412(%rip), %rdi      # 0xa998
callq 0x3c00
movw -0x6(%rbp), %ax
movzwl %ax, %edi
movzwl -0x8(%rbp), %esi
callq 0x5760
movw -0x2(%rbp), %ax
movw %ax, 0x638a(%rip)       # 0xa930
movw -0x4(%rbp), %ax
movw %ax, 0x6381(%rip)       # 0xa932
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)