// File: /workspace/github_c_makefile_star2_O1/nkanaev[P]tipsy/src/tigr.c
// Function: tigrKeyFromX11
uint8_t tigrKeyFromX11(KeySym sym) {
    if (sym >= 'a' && sym <= 'z') {
        return (uint8_t)sym - ('a' - 'A');
    }

    if (sym >= '0' && sym <= '9') {
        return (uint8_t)sym;
    }

    switch (sym) {
        case XK_KP_0:
            return TK_PAD0;
        case XK_KP_1:
            return TK_PAD1;
        case XK_KP_2:
            return TK_PAD2;
        case XK_KP_3:
            return TK_PAD3;
        case XK_KP_4:
            return TK_PAD4;
        case XK_KP_5:
            return TK_PAD5;
        case XK_KP_6:
            return TK_PAD6;
        case XK_KP_7:
            return TK_PAD7;
        case XK_KP_8:
            return TK_PAD8;
        case XK_KP_9:
            return TK_PAD9;

        case XK_KP_Multiply:
            return TK_PADMUL;
        case XK_KP_Divide:
            return TK_PADDIV;
        case XK_KP_Add:
            return TK_PADADD;
        case XK_KP_Subtract:
            return TK_PADSUB;
        case XK_KP_Decimal:
            return TK_PADDOT;
        case XK_KP_Enter:
            return TK_PADENTER;

        case XK_F1:
            return TK_F1;
        case XK_F2:
            return TK_F2;
        case XK_F3:
            return TK_F3;
        case XK_F4:
            return TK_F4;
        case XK_F5:
            return TK_F5;
        case XK_F6:
            return TK_F6;
        case XK_F7:
            return TK_F7;
        case XK_F8:
            return TK_F8;
        case XK_F9:
            return TK_F9;
        case XK_F10:
            return TK_F10;
        case XK_F11:
            return TK_F11;
        case XK_F12:
            return TK_F12;

        case XK_BackSpace:
            return TK_BACKSPACE;
        case XK_Tab:
            return TK_TAB;
        case XK_Return:
            return TK_RETURN;
        case XK_Pause:
            return TK_PAUSE;
        case XK_Caps_Lock:
            return TK_CAPSLOCK;
        case XK_Escape:
            return TK_ESCAPE;
        case XK_space:
            return TK_SPACE;

        case XK_Page_Up:
            return TK_PAGEUP;
        case XK_Page_Down:
            return TK_PAGEDN;
        case XK_End:
            return TK_END;
        case XK_Home:
            return TK_HOME;
        case XK_Left:
            return TK_LEFT;
        case XK_Up:
            return TK_UP;
        case XK_Right:
            return TK_RIGHT;
        case XK_Down:
            return TK_DOWN;
        case XK_Insert:
            return TK_INSERT;
        case XK_Delete:
            return TK_DELETE;

        case XK_Meta_L:
            return TK_LWIN;
        case XK_Meta_R:
            return TK_RWIN;
        case XK_Num_Lock:
            return TK_NUMLOCK;
        case XK_Scroll_Lock:
            return TK_SCROLL;
        case XK_Shift_L:
            return TK_LSHIFT;
        case XK_Shift_R:
            return TK_RSHIFT;
        case XK_Control_L:
            return TK_LCONTROL;
        case XK_Control_R:
            return TK_RCONTROL;
        case XK_Alt_L:
            return TK_LALT;
        case XK_Alt_R:
            return TK_RALT;

        case XK_semicolon:
            return TK_SEMICOLON;
        case XK_equal:
            return TK_EQUALS;
        case XK_comma:
            return TK_COMMA;
        case XK_minus:
            return TK_MINUS;
        case XK_period:
            return TK_DOT;
        case XK_slash:
            return TK_SLASH;
        case XK_grave:
            return TK_BACKTICK;
        case XK_bracketleft:
            return TK_LSQUARE;
        case XK_backslash:
            return TK_BACKSLASH;
        case XK_bracketright:
            return TK_RSQUARE;
        case XK_apostrophe:
            return TK_TICK;
    }
    return 0;
}

// Assembly:
movq %rdi, %rax
leaq -0x61(%rdi), %rcx
cmpq $0x19, %rcx
ja 0x6805
addb $-0x20, %al
retq
leaq -0x30(%rax), %rcx
cmpq $0x9, %rcx
jbe 0x6804
cmpq $0xff7e, %rax           # imm = 0xFF7E
jle 0x683b
leaq -0xffaa(%rax), %rcx
cmpq $0x55, %rcx
ja 0x68f4
leaq 0x48a9(%rip), %rax      # 0xb0d8
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb $-0x76, %al
retq
cmpq $0xff0c, %rax           # imm = 0xFF0C
jg 0x6866
cmpq $0x3c, %rax
jg 0x6892
leaq -0x27(%rax), %rcx
cmpq $0x8, %rcx
ja 0x68d2
leaq 0x47f2(%rip), %rax      # 0xb04c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb $-0x3c, %al
retq
cmpq $0xff1a, %rax           # imm = 0xFF1A
jle 0x68b7
leaq -0xff50(%rax), %rcx
cmpq $0x13, %rcx
ja 0x6935
leaq 0x4802(%rip), %rax      # 0xb088
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb $-0x57, %al
retq
cmpq $0xff07, %rax           # imm = 0xFF07
jg 0x68e1
leaq -0x5b(%rax), %rcx
cmpq $0x5, %rcx
ja 0x6911
leaq 0x47c5(%rip), %rax      # 0xb070
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb $-0x3f, %al
retq
cmpq $0xff0d, %rax           # imm = 0xFF0D
je 0x690e
cmpq $0xff13, %rax           # imm = 0xFF13
je 0x690b
cmpq $0xff14, %rax           # imm = 0xFF14
jne 0x6940
movb $-0x4d, %al
retq
cmpq $0x20, %rax
je 0x6932
cmpq $0x3b, %rax
jne 0x6940
movb $-0x46, %al
retq
cmpq $0xff08, %rax           # imm = 0xFF08
je 0x692f
cmpq $0xff09, %rax           # imm = 0xFF09
jne 0x6940
movb $-0x63, %al
retq
cmpq $0xff7f, %rax           # imm = 0xFF7F
je 0x69c7
cmpq $0xff8d, %rax           # imm = 0xFF8D
jne 0x6940
movb $-0x74, %al
retq
movb $-0x5e, %al
retq
movb $-0x62, %al
retq
cmpq $0x3d, %rax
jne 0x6940
movb $-0x45, %al
retq
movb $-0x44, %al
retq
movb $-0x43, %al
retq
movb $-0x42, %al
retq
movb $-0x41, %al
retq
movb $-0x3e, %al
retq
movb $-0x40, %al
retq
movb $-0x3d, %al
retq
movb $-0x64, %al
retq
movb $-0x5b, %al
retq
cmpq $0xff1b, %rax           # imm = 0xFF1B
jne 0x6940
movb $-0x5c, %al
retq
xorl %eax, %eax
retq
movb $-0x52, %al
retq
movb $-0x58, %al
retq
movb $-0x55, %al
retq
movb $-0x59, %al
retq
movb $-0x5a, %al
retq
movb $-0x56, %al
retq
movb $-0x53, %al
retq
movb $-0x54, %al
retq
movb $-0x50, %al
retq
movb $-0x4f, %al
retq
movb $-0x49, %al
retq
movb $-0x6d, %al
retq
movb $-0x70, %al
retq
movb $-0x7d, %al
retq
movb $-0x68, %al
retq
movb $-0x77, %al
retq
movb $-0x71, %al
retq
movb $-0x73, %al
retq
movb $-0x80, %al
retq
movb $-0x7a, %al
retq
movb $-0x7e, %al
retq
movb $-0x78, %al
retq
movb $-0x72, %al
retq
movb $-0x75, %al
retq
movb $-0x51, %al
retq
movb $-0x79, %al
retq
movb $-0x7b, %al
retq
movb $-0x7c, %al
retq
movb $-0x69, %al
retq
movb $-0x7f, %al
retq
movb $-0x6a, %al
retq
movb $-0x6e, %al
retq
movb $-0x48, %al
retq
movb $-0x67, %al
retq
movb $-0x4b, %al
retq
movb $-0x6f, %al
retq
movb $-0x66, %al
retq
movb $-0x6c, %al
retq
movb $-0x6b, %al
retq
movb $-0x4a, %al
retq
movb $-0x65, %al
retq
movb $-0x4c, %al
retq
movb $-0x47, %al
retq
movb $-0x5d, %al
retq
movb $-0x4e, %al
retq