// File: /workspace/github_c_makefile_star2_O0/moefh[P]hed/src/input.c
// Function: read_key_seq
static int read_key_seq(char *seq, size_t len)
{
  if (len == 1 && seq[0] >= 32 && seq[0] < 127)
    return ALT_KEY(seq[0]);
  
  if (len == 2 && seq[0] == '[' && IS_LETTER(seq[1])) {
    switch (seq[1]) {
    case 'A': return KEY_ARROW_UP;
    case 'B': return KEY_ARROW_DOWN;
    case 'C': return KEY_ARROW_RIGHT;
    case 'D': return KEY_ARROW_LEFT;
    case 'H': return KEY_HOME;
    case 'F': return KEY_END;
    }
  }

  if (len == 3 && seq[0] == '[' && IS_DIGIT(seq[1]) && seq[2] == '~') {
    switch (seq[1]) {
    case '1': return KEY_HOME;
    case '2': return KEY_INS;
    case '3': return KEY_DEL;
    case '4': return KEY_END;
    case '5': return KEY_PAGE_UP;
    case '6': return KEY_PAGE_DOWN;
    case '7': return KEY_HOME;
    case '8': return KEY_END;
    }
  }

  if (len == 3 && seq[0] == '[' && IS_DIGIT(seq[1]) && seq[2] == '^') {
    switch (seq[1]) {
    case '1': return KEY_CTRL_HOME;
    case '2': return KEY_CTRL_INS;
    case '3': return KEY_CTRL_DEL;
    case '4': return KEY_CTRL_END;
    case '5': return KEY_CTRL_PAGE_UP;
    case '6': return KEY_CTRL_PAGE_DOWN;
    case '7': return KEY_CTRL_HOME;
    case '8': return KEY_CTRL_END;
    }
  }
  
  if (len == 5 && seq[0] == '[' && IS_DIGIT(seq[1]) && seq[2] == ';' && IS_DIGIT(seq[3])) {
    if (seq[1] == '1' && seq[3] == '5' && seq[4] == 'H') return KEY_CTRL_HOME;
    if (seq[1] == '1' && seq[3] == '5' && seq[4] == 'F') return KEY_CTRL_END;
  }
  
  if (len == 2 && seq[0] == 'O') {
    switch (seq[1]) {
    case 'F': return KEY_END;
    case 'H': return KEY_HOME;
    case 'P': return KEY_F1;
    case 'Q': return KEY_F2;
    case 'R': return KEY_F3;
    case 'S': return KEY_F4;
    }
  }

  if (len == 3 && seq[0] == '[' && seq[1] == '[' && IS_LETTER(seq[2])) {
    switch (seq[2]) {
    case 'A': return KEY_F1;
    case 'B': return KEY_F2;
    case 'C': return KEY_F3;
    case 'D': return KEY_F4;
    case 'E': return KEY_F5;
    }
  }

  if (len == 4 && seq[0] == '[' && IS_DIGIT(seq[1]) && IS_DIGIT(seq[2]) && seq[3] == '~') {
    if (seq[1] == '1' && seq[2] == '5') return KEY_F5;
    if (seq[1] == '1' && seq[2] == '7') return KEY_F6;
    if (seq[1] == '1' && seq[2] == '8') return KEY_F7;
    if (seq[1] == '1' && seq[2] == '9') return KEY_F8;
    if (seq[1] == '2' && seq[2] == '0') return KEY_F9;
    if (seq[1] == '2' && seq[2] == '1') return KEY_F10;
    if (seq[1] == '2' && seq[2] == '3') return KEY_F11;
    if (seq[1] == '2' && seq[2] == '4') return KEY_F12;
    
    if (seq[1] == '2' && seq[2] == '5') return KEY_SHIFT_F1;
    if (seq[1] == '2' && seq[2] == '6') return KEY_SHIFT_F2;
    if (seq[1] == '2' && seq[2] == '8') return KEY_SHIFT_F3;
    if (seq[1] == '2' && seq[2] == '9') return KEY_SHIFT_F4;
    if (seq[1] == '3' && seq[2] == '1') return KEY_SHIFT_F5;
    if (seq[1] == '3' && seq[2] == '2') return KEY_SHIFT_F6;
    if (seq[1] == '3' && seq[2] == '3') return KEY_SHIFT_F7;
    if (seq[1] == '3' && seq[2] == '4') return KEY_SHIFT_F8;
  }
  
  //err_msg(editor, "-> unrecognized key: %.*s", (int)len, seq);
  seq[len] = '\0';
  return KEY_BAD_SEQUENCE;
}

// Assembly:
movq %rdi, -0x10(%rsp)
movq %rsi, -0x18(%rsp)
cmpq $0x1, -0x18(%rsp)
jne 0x2cd5
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jl 0x2cd5
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x7f, %eax
jge 0x2cd5
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
andl $0x1f, %eax
addl $0x112000, %eax         # imm = 0x112000
movl %eax, -0x4(%rsp)
jmp 0x34a9
cmpq $0x2, -0x18(%rsp)
jne 0x2d8f
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x2d8f
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x41, %eax
jl 0x2d8f
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x5a, %eax
jg 0x2d8f
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x20(%rsp)
subl $0x7, %eax
ja 0x2d8d
movq -0x20(%rsp), %rax
leaq 0x8502(%rip), %rcx      # 0xb238
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x111002, -0x4(%rsp)   # imm = 0x111002
jmp 0x34a9
movl $0x111003, -0x4(%rsp)   # imm = 0x111003
jmp 0x34a9
movl $0x111001, -0x4(%rsp)   # imm = 0x111001
jmp 0x34a9
movl $0x111000, -0x4(%rsp)   # imm = 0x111000
jmp 0x34a9
movl $0x111006, -0x4(%rsp)   # imm = 0x111006
jmp 0x34a9
movl $0x111007, -0x4(%rsp)   # imm = 0x111007
jmp 0x34a9
jmp 0x2d8f
cmpq $0x3, -0x18(%rsp)
jne 0x2e79
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x2e79
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x30, %eax
jl 0x2e79
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x39, %eax
jg 0x2e79
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x7e, %eax
jne 0x2e79
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
addl $-0x31, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rsp)
subl $0x7, %eax
ja 0x2e77
movq -0x28(%rsp), %rax
leaq 0x8452(%rip), %rcx      # 0xb258
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x111006, -0x4(%rsp)   # imm = 0x111006
jmp 0x34a9
movl $0x111004, -0x4(%rsp)   # imm = 0x111004
jmp 0x34a9
movl $0x111005, -0x4(%rsp)   # imm = 0x111005
jmp 0x34a9
movl $0x111007, -0x4(%rsp)   # imm = 0x111007
jmp 0x34a9
movl $0x111008, -0x4(%rsp)   # imm = 0x111008
jmp 0x34a9
movl $0x111009, -0x4(%rsp)   # imm = 0x111009
jmp 0x34a9
movl $0x111006, -0x4(%rsp)   # imm = 0x111006
jmp 0x34a9
movl $0x111007, -0x4(%rsp)   # imm = 0x111007
jmp 0x34a9
jmp 0x2e79
cmpq $0x3, -0x18(%rsp)
jne 0x2f63
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x2f63
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x30, %eax
jl 0x2f63
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x39, %eax
jg 0x2f63
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x5e, %eax
jne 0x2f63
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
addl $-0x31, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rsp)
subl $0x7, %eax
ja 0x2f61
movq -0x30(%rsp), %rax
leaq 0x8388(%rip), %rcx      # 0xb278
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x11101a, -0x4(%rsp)   # imm = 0x11101A
jmp 0x34a9
movl $0x111018, -0x4(%rsp)   # imm = 0x111018
jmp 0x34a9
movl $0x111019, -0x4(%rsp)   # imm = 0x111019
jmp 0x34a9
movl $0x11101b, -0x4(%rsp)   # imm = 0x11101B
jmp 0x34a9
movl $0x11101c, -0x4(%rsp)   # imm = 0x11101C
jmp 0x34a9
movl $0x11101d, -0x4(%rsp)   # imm = 0x11101D
jmp 0x34a9
movl $0x11101a, -0x4(%rsp)   # imm = 0x11101A
jmp 0x34a9
movl $0x11101b, -0x4(%rsp)   # imm = 0x11101B
jmp 0x34a9
jmp 0x2f63
cmpq $0x5, -0x18(%rsp)
jne 0x3042
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x3042
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x30, %eax
jl 0x3042
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x39, %eax
jg 0x3042
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x3b, %eax
jne 0x3042
movq -0x10(%rsp), %rax
movsbl 0x3(%rax), %eax
cmpl $0x30, %eax
jl 0x3042
movq -0x10(%rsp), %rax
movsbl 0x3(%rax), %eax
cmpl $0x39, %eax
jg 0x3042
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x31, %eax
jne 0x3009
movq -0x10(%rsp), %rax
movsbl 0x3(%rax), %eax
cmpl $0x35, %eax
jne 0x3009
movq -0x10(%rsp), %rax
movsbl 0x4(%rax), %eax
cmpl $0x48, %eax
jne 0x3009
movl $0x11101a, -0x4(%rsp)   # imm = 0x11101A
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x31, %eax
jne 0x3040
movq -0x10(%rsp), %rax
movsbl 0x3(%rax), %eax
cmpl $0x35, %eax
jne 0x3040
movq -0x10(%rsp), %rax
movsbl 0x4(%rax), %eax
cmpl $0x46, %eax
jne 0x3040
movl $0x11101b, -0x4(%rsp)   # imm = 0x11101B
jmp 0x34a9
jmp 0x3042
cmpq $0x2, -0x18(%rsp)
jne 0x30d8
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x4f, %eax
jne 0x30d8
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
addl $-0x46, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rsp)
subl $0xd, %eax
ja 0x30d6
movq -0x38(%rsp), %rax
leaq 0x8219(%rip), %rcx      # 0xb298
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x111007, -0x4(%rsp)   # imm = 0x111007
jmp 0x34a9
movl $0x111006, -0x4(%rsp)   # imm = 0x111006
jmp 0x34a9
movl $0x11101e, -0x4(%rsp)   # imm = 0x11101E
jmp 0x34a9
movl $0x11101f, -0x4(%rsp)   # imm = 0x11101F
jmp 0x34a9
movl $0x111020, -0x4(%rsp)   # imm = 0x111020
jmp 0x34a9
movl $0x111021, -0x4(%rsp)   # imm = 0x111021
jmp 0x34a9
jmp 0x30d8
cmpq $0x3, -0x18(%rsp)
jne 0x3193
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x3193
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x5b, %eax
jne 0x3193
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x41, %eax
jl 0x3193
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x5a, %eax
jg 0x3193
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rsp)
subl $0x4, %eax
ja 0x3191
movq -0x40(%rsp), %rax
leaq 0x8189(%rip), %rcx      # 0xb2d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x11101e, -0x4(%rsp)   # imm = 0x11101E
jmp 0x34a9
movl $0x11101f, -0x4(%rsp)   # imm = 0x11101F
jmp 0x34a9
movl $0x111020, -0x4(%rsp)   # imm = 0x111020
jmp 0x34a9
movl $0x111021, -0x4(%rsp)   # imm = 0x111021
jmp 0x34a9
movl $0x111022, -0x4(%rsp)   # imm = 0x111022
jmp 0x34a9
jmp 0x3193
cmpq $0x4, -0x18(%rsp)
jne 0x3493
movq -0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x3493
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x30, %eax
jl 0x3493
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x39, %eax
jg 0x3493
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x30, %eax
jl 0x3493
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x39, %eax
jg 0x3493
movq -0x10(%rsp), %rax
movsbl 0x3(%rax), %eax
cmpl $0x7e, %eax
jne 0x3493
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x31, %eax
jne 0x3233
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x35, %eax
jne 0x3233
movl $0x111022, -0x4(%rsp)   # imm = 0x111022
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x31, %eax
jne 0x325c
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x37, %eax
jne 0x325c
movl $0x111023, -0x4(%rsp)   # imm = 0x111023
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x31, %eax
jne 0x3285
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x38, %eax
jne 0x3285
movl $0x111024, -0x4(%rsp)   # imm = 0x111024
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x31, %eax
jne 0x32ae
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x39, %eax
jne 0x32ae
movl $0x111025, -0x4(%rsp)   # imm = 0x111025
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x32d7
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x30, %eax
jne 0x32d7
movl $0x111026, -0x4(%rsp)   # imm = 0x111026
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x3300
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x31, %eax
jne 0x3300
movl $0x111027, -0x4(%rsp)   # imm = 0x111027
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x3329
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x33, %eax
jne 0x3329
movl $0x111028, -0x4(%rsp)   # imm = 0x111028
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x3352
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x34, %eax
jne 0x3352
movl $0x111029, -0x4(%rsp)   # imm = 0x111029
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x337b
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x35, %eax
jne 0x337b
movl $0x11102a, -0x4(%rsp)   # imm = 0x11102A
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x33a4
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x36, %eax
jne 0x33a4
movl $0x11102b, -0x4(%rsp)   # imm = 0x11102B
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x33cd
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x38, %eax
jne 0x33cd
movl $0x11102c, -0x4(%rsp)   # imm = 0x11102C
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x32, %eax
jne 0x33f6
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x39, %eax
jne 0x33f6
movl $0x11102d, -0x4(%rsp)   # imm = 0x11102D
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x33, %eax
jne 0x341f
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x31, %eax
jne 0x341f
movl $0x11102e, -0x4(%rsp)   # imm = 0x11102E
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x33, %eax
jne 0x3445
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x32, %eax
jne 0x3445
movl $0x11102f, -0x4(%rsp)   # imm = 0x11102F
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x33, %eax
jne 0x346b
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x33, %eax
jne 0x346b
movl $0x111030, -0x4(%rsp)   # imm = 0x111030
jmp 0x34a9
movq -0x10(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x33, %eax
jne 0x3491
movq -0x10(%rsp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x34, %eax
jne 0x3491
movl $0x111031, -0x4(%rsp)   # imm = 0x111031
jmp 0x34a9
jmp 0x3493
movq -0x10(%rsp), %rax
movq -0x18(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movl $0x110001, -0x4(%rsp)   # imm = 0x110001
movl -0x4(%rsp), %eax
retq
nop