// File: /workspace/github_c_makefile_star2_O3/adsr[P]phpspy/vendor/termbox2/termbox2.h
// Function: extract_event
static int extract_event(struct tb_event *event) {
    int rv;
    struct bytebuf_t *in = &global.in;

    if (in->len == 0) {
        return TB_ERR;
    }

    if (in->buf[0] == '\x1b') {
        // Escape sequence?
        // In TB_INPUT_ESC, skip if the buffer is a single escape char
        if (!((global.input_mode & TB_INPUT_ESC) && in->len == 1)) {
            if_ok_or_need_more_return(rv, extract_esc(event));
        }

        // Escape key?
        if (global.input_mode & TB_INPUT_ESC) {
            event->type = TB_EVENT_KEY;
            event->ch = 0;
            event->key = TB_KEY_ESC;
            event->mod = 0;
            bytebuf_shift(in, 1);
            return TB_OK;
        }

        // Recurse for alt key
        event->mod |= TB_MOD_ALT;
        bytebuf_shift(in, 1);
        return extract_event(event);
    }

    // ASCII control key?
    if ((uint16_t)in->buf[0] < TB_KEY_SPACE || in->buf[0] == TB_KEY_BACKSPACE2)
    {
        event->type = TB_EVENT_KEY;
        event->ch = 0;
        event->key = (uint16_t)in->buf[0];
        event->mod |= TB_MOD_CTRL;
        bytebuf_shift(in, 1);
        return TB_OK;
    }

    // UTF-8?
    if (in->len >= (size_t)tb_utf8_char_length(in->buf[0])) {
        event->type = TB_EVENT_KEY;
        tb_utf8_char_to_unicode(&event->ch, in->buf);
        event->key = 0;
        bytebuf_shift(in, tb_utf8_char_length(in->buf[0]));
        return TB_OK;
    }

    // Need more input
    return TB_ERR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x12775(%rip), %rdx     # 0x25c00
testq %rdx, %rdx
je 0x1372f
movq %rdi, %r13
movq %rdi, (%rsp)
movq 0x12756(%rip), %rax     # 0x25bf8
movsbl (%rax), %ecx
cmpl $0x1b, %ecx
jne 0x13739
movl 0x125ec(%rip), %eax     # 0x25aa0
cmpq $0x1, %rdx
sete %cl
testb %al, %cl
jne 0x1360b
movq %r13, %rdi
xorl %esi, %esi
callq 0x139cd
cmpl $-0x2, %eax
je 0x135f2
testl %eax, %eax
je 0x135f2
movq 0x12713(%rip), %r15     # 0x25bf8
movq 0x12714(%rip), %r14     # 0x25c00
testq %r14, %r14
sete %al
movq 0x126ef(%rip), %rdx     # 0x25be8
testq %rdx, %rdx
sete %cl
orb %al, %cl
je 0x1350f
leaq 0x126ce(%rip), %rax     # 0x25bd8
xorl %r12d, %r12d
jmp 0x13568
xorl %ecx, %ecx
xorl %r12d, %r12d
leaq 0x126bd(%rip), %rax     # 0x25bd8
movq %rax, %rsi
movb (%r15,%rcx), %dil
movq 0x8(%rax), %rax
cmpb %dil, (%rax)
je 0x13536
addq $0x20, %rax
decq %rdx
jne 0x13526
jmp 0x13565
incq %r12
cmpl $0x0, 0x18(%rax)
je 0x13552
incq %rcx
cmpq %r14, %rcx
jae 0x13568
movq 0x10(%rax), %rdx
testq %rdx, %rdx
jne 0x1355e
jmp 0x13568
incq %rcx
cmpq %r14, %rcx
jae 0x13568
movq 0x10(%rax), %rdx
testq %rdx, %rdx
jne 0x1351b
jmp 0x13568
movq %rsi, %rax
cmpl $0x0, 0x18(%rax)
jne 0x1381d
cmpq $0x0, 0x10(%rax)
sete %al
cmpq %r12, %r14
seta %cl
orb %al, %cl
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
cmpb $0x1, %cl
jne 0x13808
leaq 0x113d9(%rip), %rbx     # 0x24970
xorl %r13d, %r13d
movq (%rbx), %r12
movq %r12, %rdi
callq 0x6160
cmpq %rax, %r14
jb 0x135c0
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x6080
testl %eax, %eax
je 0x13656
incq %r13
addq $0x8, %rbx
cmpq $0x3, %r13
jne 0x1359a
movq (%rsp), %r13
movq %r13, %rdi
movl $0x1, %esi
callq 0x139cd
movl %eax, %ecx
negl %eax
movl $0x0, %eax
sbbl %eax, %eax
cmpl $-0x2, %ecx
je 0x13808
cmpl $-0x2, %eax
je 0x13819
movl %eax, %ebp
testl %eax, %eax
je 0x13808
movl 0x12495(%rip), %eax     # 0x25aa0
testb $0x1, %al
jne 0x13784
orb $0x1, 0x1(%r13)
movq 0x125e1(%rip), %rdx     # 0x25c00
xorl %ebx, %ebx
testq %rdx, %rdx
setne %bl
subq %rbx, %rdx
movq 0x125c7(%rip), %rdi     # 0x25bf8
leaq (%rdi,%rbx), %rsi
callq 0x6490
movq 0x125bf(%rip), %rdx     # 0x25c00
subq %rbx, %rdx
movq %rdx, 0x125b5(%rip)     # 0x25c00
jne 0x1349b
jmp 0x1372f
leal -0x1(%r13), %eax
cmpl $0x2, %eax
jae 0x136ee
testq %r14, %r14
je 0x135cd
movq $-0x1, %rcx
xorl %eax, %eax
xorl %esi, %esi
movq $-0x1, %rbx
movq $-0x1, %r12
movzbl (%r15,%rax), %edx
cmpl $0x3b, %edx
jne 0x1369d
cmpq $-0x1, %rbx
cmovneq %rax, %r12
cmoveq %rax, %rbx
jmp 0x136c2
cmpq $-0x1, %rcx
jne 0x136c2
movl %edx, %ecx
orl $0x20, %ecx
cmpl $0x6d, %ecx
jne 0x136bb
xorl %esi, %esi
cmpl $0x4d, %edx
sete %sil
movq %rax, %rcx
jmp 0x136c2
movq $-0x1, %rcx
incq %rax
cmpq %rax, %r14
jne 0x13685
cmpq $-0x1, %rcx
sete %al
cmpq $-0x1, %rbx
sete %cl
orb %al, %cl
cmpq $-0x1, %r12
sete %al
orb %cl, %al
jne 0x135cd
jmp 0x1385c
testl %r13d, %r13d
jne 0x135cd
cmpq $0x6, %r14
jb 0x135cd
movzbl 0x3(%r15), %ecx
leal -0x20(%rcx), %eax
andl $0x3, %ecx
leaq 0x8ec1(%rip), %rdx      # 0x1c5d4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %ecx, %ecx
testb $0x40, %al
sete %cl
leal -0x1c(,%rcx,4), %ecx
jmp 0x13970
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x13808
testl $0xffe0, %ecx           # imm = 0xFFE0
setne %sil
cmpb $0x7f, %cl
setne %dil
testb %sil, %dil
jne 0x137a7
movb $0x1, (%r13)
movl $0x0, 0x4(%r13)
movsbl (%rax), %ecx
movw %cx, 0x2(%r13)
orb $0x2, 0x1(%r13)
decq %rdx
leaq 0x1(%rax), %rsi
movq %rax, %rdi
callq 0x6490
decq 0x12481(%rip)           # 0x25c00
jmp 0x13806
movq $0x1b0001, (%r13)       # imm = 0x1B0001
movq 0x1246d(%rip), %rdx     # 0x25c00
xorl %ebx, %ebx
testq %rdx, %rdx
setne %bl
subq %rbx, %rdx
movq 0x12453(%rip), %rdi     # 0x25bf8
jmp 0x137f6
movzbl %cl, %ecx
leaq 0x8eef(%rip), %rbx      # 0x1c6a0
movzbl (%rcx,%rbx), %ecx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpq %rcx, %rdx
jb 0x13808
movb $0x1, (%r13)
leaq 0x4(%r13), %rdi
movq %rax, %rsi
callq 0x8352
movw $0x0, 0x2(%r13)
movq 0x1241a(%rip), %rdi     # 0x25bf8
movzbl (%rdi), %eax
movzbl (%rax,%rbx), %ebx
movq 0x12414(%rip), %rdx     # 0x25c00
cmpq %rbx, %rdx
cmovbq %rdx, %rbx
subq %rbx, %rdx
leaq (%rdi,%rbx), %rsi
callq 0x6490
subq %rbx, 0x123fa(%rip)     # 0x25c00
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
jmp 0x13808
movb $0x1, (%r13)
movl $0x0, 0x4(%r13)
movzwl 0x1c(%rax), %ecx
movw %cx, 0x2(%r13)
movb 0x1e(%rax), %al
movb %al, 0x1(%r13)
cmpq %r12, %r14
cmovbq %r14, %r12
subq %r12, %r14
leaq (%r15,%r12), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x6490
subq %r12, 0x123a6(%rip)     # 0x25c00
jmp 0x13806
movl %esi, %r14d
xorl %eax, %eax
cmpq $0x2, %r13
sete %al
xorq $0x3, %rax
addq %rax, %r15
movq %r15, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x6560
leal -0x20(%rax), %ebp
cmpq $0x2, %r13
movq 0x1236c(%rip), %rcx     # 0x25bf8
leaq 0x1(%rcx,%rbx), %rdi
cmovnel %eax, %ebp
xorl %esi, %esi
movl $0xa, %edx
callq 0x6560
movq %rax, %r15
movq 0x1234e(%rip), %rax     # 0x25bf8
leaq (%rax,%r12), %rdi
incq %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x6560
movl %ebp, %ecx
andl $0x3, %ecx
leaq 0x8d1b(%rip), %rdx      # 0x1c5e4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %ecx, %ecx
testb $0x40, %bpl
sete %cl
leal -0x1c(,%rcx,4), %ecx
jmp 0x13902
movw $0xffe7, %cx            # imm = 0xFFE7
jmp 0x13902
movw $0xffe5, %cx            # imm = 0xFFE5
jmp 0x13902
xorl %ecx, %ecx
testb $0x40, %bpl
sete %cl
leal (%rcx,%rcx,2), %ecx
addl $0xffe3, %ecx           # imm = 0xFFE3
movq (%rsp), %r12
testl %r14d, %r14d
movq 0x122f0(%rip), %r14     # 0x25c00
movl $0xffe5, %edx           # imm = 0xFFE5
cmovnel %ecx, %edx
movw %dx, 0x2(%r12)
testb $0x20, %bpl
je 0x1392a
orb $0x8, 0x1(%r12)
movl $0xff, %ecx
andl %ecx, %r15d
decl %r15d
movl %r15d, 0x10(%r12)
andl %ecx, %eax
decl %eax
movl %eax, 0x14(%r12)
testq %r14, %r14
je 0x139c3
movq 0x122a9(%rip), %r15     # 0x25bf8
movq %r14, %rbx
jmp 0x139a3
movw $0xffe7, %cx            # imm = 0xFFE7
jmp 0x13970
movw $0xffe5, %cx            # imm = 0xFFE5
jmp 0x13970
xorl %ecx, %ecx
testb $0x40, %al
sete %cl
leal (%rcx,%rcx,2), %ecx
addl $0xffe3, %ecx           # imm = 0xFFE3
movq (%rsp), %r12
movw %cx, 0x2(%r12)
testb $0x20, %al
je 0x13984
orb $0x8, 0x1(%r12)
movzbl 0x4(%r15), %eax
addl $-0x21, %eax
movl %eax, 0x10(%r12)
movzbl 0x5(%r15), %eax
addl $-0x21, %eax
movl %eax, 0x14(%r12)
movl $0x6, %ebx
cmpq %rbx, %r14
cmovbq %r14, %rbx
subq %rbx, %r14
leaq (%r15,%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x6490
subq %rbx, 0x1223d(%rip)     # 0x25c00
movb $0x3, (%r12)
jmp 0x13806