// File: /workspace/github_c_makefile_star2_O0/neovim[P]libtermkey/driver-csi.c
// Function: parse_csi
static TermKeyResult parse_csi(TermKey *tk, size_t introlen, size_t *csi_len, long args[], size_t *nargs, unsigned long *commandp)
{
  size_t csi_end = introlen;

  while(csi_end < tk->buffcount) {
    if(CHARAT(csi_end) >= 0x40 && CHARAT(csi_end) < 0x80)
      break;
    csi_end++;
  }

  if(csi_end >= tk->buffcount)
    return TERMKEY_RES_AGAIN;

  unsigned char cmd = CHARAT(csi_end);
  *commandp = cmd;

  char present = 0;
  int argi = 0;

  size_t p = introlen;

  // See if there is an initial byte
  if(CHARAT(p) >= '<' && CHARAT(p) <= '?') {
    *commandp |= (CHARAT(p) << 8);
    p++;
  }

  // Now attempt to parse out up number;number;... separated values
  while(p < csi_end) {
    unsigned char c = CHARAT(p);

    if(c >= '0' && c <= '9') {
      if(!present) {
        args[argi] = c - '0';
        present = 1;
      }
      else {
        args[argi] = (args[argi] * 10) + c - '0';
      }
    }
    else if(c == ';') {
      if(!present)
        args[argi] = -1;
      present = 0;
      argi++;

      if(argi > 16)
        break;
    }
    else if(c >= 0x20 && c <= 0x2f) {
      *commandp |= c << 16;
      break;
    }

    p++;
  }

  if(present)
    argi++;

  *nargs = argi;
  *csi_len = csi_end + 1;

  return TERMKEY_RES_KEY;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x6a2e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x40, %eax
jl 0x6a20
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x80, %eax
jge 0x6a20
jmp 0x6a2e
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x69d4
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jb 0x6a48
movl $0x3, -0x4(%rbp)
jmp 0x6c17
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq -0x40(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x41(%rbp)
movzbl -0x41(%rbp), %eax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movb $0x0, -0x42(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq -0x50(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3c, %eax
jl 0x6af0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq -0x50(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3f, %eax
jg 0x6af0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq -0x50(%rbp), %rcx
movzbl (%rax,%rcx), %eax
shll $0x8, %eax
movslq %eax, %rcx
movq -0x38(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x6af2
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x6be7
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq -0x50(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x51(%rbp)
movzbl -0x51(%rbp), %eax
cmpl $0x30, %eax
jl 0x6b74
movzbl -0x51(%rbp), %eax
cmpl $0x39, %eax
jg 0x6b74
cmpb $0x0, -0x42(%rbp)
jne 0x6b4e
movzbl -0x51(%rbp), %eax
subl $0x30, %eax
movslq %eax, %rdx
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movb $0x1, -0x42(%rbp)
jmp 0x6b72
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
imulq $0xa, (%rax,%rcx,8), %rdx
movzbl -0x51(%rbp), %eax
addq %rax, %rdx
subq $0x30, %rdx
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x6bd6
movzbl -0x51(%rbp), %eax
cmpl $0x3b, %eax
jne 0x6baa
cmpb $0x0, -0x42(%rbp)
jne 0x6b93
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq $-0x1, (%rax,%rcx,8)
movb $0x0, -0x42(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
cmpl $0x10, -0x48(%rbp)
jle 0x6ba8
jmp 0x6be7
jmp 0x6bd4
movzbl -0x51(%rbp), %eax
cmpl $0x20, %eax
jl 0x6bd2
movzbl -0x51(%rbp), %eax
cmpl $0x2f, %eax
jg 0x6bd2
movzbl -0x51(%rbp), %eax
shll $0x10, %eax
movslq %eax, %rcx
movq -0x38(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x6be7
jmp 0x6bd4
jmp 0x6bd6
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x6af2
cmpb $0x0, -0x42(%rbp)
je 0x6bf6
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movslq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)