// File: /workspace/github_c_makefile_star2_O0/termbox[P]termbox/demo/keyboard.c
// Function: main
int main(int argc, char **argv)
{
    (void) argc; (void) argv;
    int ret;

    ret = tb_init();
    if (ret) {
        fprintf(stderr, "tb_init() failed with error code %d\n", ret);
        return 1;
    }

    tb_select_input_mode(TB_INPUT_ESC | TB_INPUT_MOUSE);
    struct tb_event ev;

    tb_clear();
    draw_keyboard();
    tb_present();
    int inputmode = 0;
    int ctrlxpressed = 0;

    while (tb_poll_event(&ev)) {
        switch (ev.type) {
        case TB_EVENT_KEY:
            if (ev.key == TB_KEY_CTRL_Q && ctrlxpressed) {
                tb_shutdown();
                return 0;
            }
            if (ev.key == TB_KEY_CTRL_C && ctrlxpressed) {
                static int chmap[] = {
                    TB_INPUT_ESC | TB_INPUT_MOUSE, /* 101 */
                    TB_INPUT_ALT | TB_INPUT_MOUSE, /* 110 */
                    TB_INPUT_ESC,                  /* 001 */
                    TB_INPUT_ALT,                  /* 010 */
                };
                inputmode++;
                if (inputmode >= 4) {
                    inputmode = 0;
                }
                tb_select_input_mode(chmap[inputmode]);
            }
            if (ev.key == TB_KEY_CTRL_X)
                ctrlxpressed = 1;
            else
                ctrlxpressed = 0;

            tb_clear();
            draw_keyboard();
            dispatch_press(&ev);
            pretty_print_press(&ev);
            tb_present();
            break;
        case TB_EVENT_RESIZE:
            tb_clear();
            draw_keyboard();
            pretty_print_resize(&ev);
            tb_present();
            break;
        case TB_EVENT_MOUSE:
            tb_clear();
            draw_keyboard();
            pretty_print_mouse(&ev);
            tb_present();
            break;
        default:
            break;
        }
    }
    tb_shutdown();
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x6ef0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x66ab
movq 0x696d(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
leaq 0x3cd0(%rip), %rsi      # 0xa368
movb $0x0, %al
callq 0x5170
movl $0x1, -0x4(%rbp)
jmp 0x67ec
movl $0x5, %edi
callq 0x7e90
callq 0x7e60
callq 0x5540
callq 0x7180
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
leaq -0x2c(%rbp), %rdi
callq 0x7a70
cmpl $0x0, %eax
je 0x67e0
movzbl -0x2c(%rbp), %eax
movl %eax, -0x38(%rbp)
subl $0x1, %eax
je 0x6711
jmp 0x66f2
movl -0x38(%rbp), %eax
subl $0x2, %eax
je 0x67a5
jmp 0x6700
movl -0x38(%rbp), %eax
subl $0x3, %eax
je 0x67bf
jmp 0x67d9
movzwl -0x2a(%rbp), %eax
cmpl $0x11, %eax
jne 0x6731
cmpl $0x0, -0x34(%rbp)
je 0x6731
callq 0x6f10
movl $0x0, -0x4(%rbp)
jmp 0x67ec
movzwl -0x2a(%rbp), %eax
cmpl $0x3, %eax
jne 0x6769
cmpl $0x0, -0x34(%rbp)
je 0x6769
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
cmpl $0x4, -0x30(%rbp)
jl 0x6756
movl $0x0, -0x30(%rbp)
movslq -0x30(%rbp), %rcx
leaq 0x954f(%rip), %rax      # 0xfcb0
movl (%rax,%rcx,4), %edi
callq 0x7e90
movzwl -0x2a(%rbp), %eax
cmpl $0x18, %eax
jne 0x677b
movl $0x1, -0x34(%rbp)
jmp 0x6782
movl $0x0, -0x34(%rbp)
callq 0x7e60
callq 0x5540
leaq -0x2c(%rbp), %rdi
callq 0x6530
leaq -0x2c(%rbp), %rdi
callq 0x61d0
callq 0x7180
jmp 0x67db
callq 0x7e60
callq 0x5540
leaq -0x2c(%rbp), %rdi
callq 0x63c0
callq 0x7180
jmp 0x67db
callq 0x7e60
callq 0x5540
leaq -0x2c(%rbp), %rdi
callq 0x6410
callq 0x7180
jmp 0x67db
jmp 0x67db
jmp 0x66d2
callq 0x6f10
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop