// File: /workspace/github_c_makefile_star2_O0/neovim[P]libtermkey/termkey.c
// Function: termkey_keycmp
int termkey_keycmp(TermKey *tk, const TermKeyKey *key1p, const TermKeyKey *key2p)
{
  /* Copy the key structs since we'll be modifying them */
  TermKeyKey key1 = *key1p, key2 = *key2p;

  termkey_canonicalise(tk, &key1);
  termkey_canonicalise(tk, &key2);

  if(key1.type != key2.type)
    return key1.type - key2.type;

  switch(key1.type) {
    case TERMKEY_TYPE_UNICODE:
      if(key1.code.codepoint != key2.code.codepoint)
        return key1.code.codepoint - key2.code.codepoint;
      break;
    case TERMKEY_TYPE_KEYSYM:
      if(key1.code.sym != key2.code.sym)
        return key1.code.sym - key2.code.sym;
      break;
    case TERMKEY_TYPE_FUNCTION:
    case TERMKEY_TYPE_UNKNOWN_CSI:
      if(key1.code.number != key2.code.number)
        return key1.code.number - key2.code.number;
      break;
    case TERMKEY_TYPE_MOUSE:
      {
        int cmp = strncmp(key1.code.mouse, key2.code.mouse, 4);
        if(cmp != 0)
          return cmp;
      }
      break;
    case TERMKEY_TYPE_POSITION:
      {
        int line1, col1, line2, col2;
        termkey_interpret_position(tk, &key1, &line1, &col1);
        termkey_interpret_position(tk, &key2, &line2, &col2);
        if(line1 != line2)
          return line1 - line2;
        return col1 - col2;
      }
      break;
    case TERMKEY_TYPE_DCS:
    case TERMKEY_TYPE_OSC:
      return key1p - key2p;
    case TERMKEY_TYPE_MODEREPORT:
      {
        int initial1, initial2, mode1, mode2, value1, value2;
        termkey_interpret_modereport(tk, &key1, &initial1, &mode1, &value1);
        termkey_interpret_modereport(tk, &key2, &initial2, &mode2, &value2);
        if(initial1 != initial2)
          return initial1 - initial2;
        if(mode1 != mode2)
          return mode1 - mode2;
        return value1 - value2;
      }
  }

  return key1.modifiers - key2.modifiers;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x60(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x32a0
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x32a0
movl -0x40(%rbp), %eax
cmpl -0x60(%rbp), %eax
je 0x5c7d
movl -0x40(%rbp), %eax
subl -0x60(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
movl -0x40(%rbp), %eax
incl %eax
movl %eax, %ecx
movq %rcx, -0x98(%rbp)
subl $0x8, %eax
ja 0x5e10
movq -0x98(%rbp), %rax
leaq 0x43c2(%rip), %rcx      # 0xa064
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x38(%rbp), %rax
cmpq -0x58(%rbp), %rax
je 0x5cc5
movq -0x38(%rbp), %rax
subq -0x58(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x5e19
jmp 0x5e10
movl -0x38(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x5ce0
movl -0x38(%rbp), %eax
subl -0x58(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
jmp 0x5e10
movl -0x38(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x5cfb
movl -0x38(%rbp), %eax
subl -0x58(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
jmp 0x5e10
leaq -0x40(%rbp), %rdi
addq $0x8, %rdi
leaq -0x60(%rbp), %rsi
addq $0x8, %rsi
movl $0x4, %edx
callq 0x30d0
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0x5d2e
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
jmp 0x5e10
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0x6c(%rbp), %rcx
callq 0x31b0
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x70(%rbp), %rdx
leaq -0x74(%rbp), %rcx
callq 0x31b0
movl -0x68(%rbp), %eax
cmpl -0x70(%rbp), %eax
je 0x5d73
movl -0x68(%rbp), %eax
subl -0x70(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
movl -0x6c(%rbp), %eax
subl -0x74(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
sarq $0x5, %rax
movl %eax, -0x4(%rbp)
jmp 0x5e19
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x78(%rbp), %rdx
leaq -0x80(%rbp), %rcx
leaq -0x88(%rbp), %r8
callq 0x30b0
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x7c(%rbp), %rdx
leaq -0x84(%rbp), %rcx
leaq -0x8c(%rbp), %r8
callq 0x30b0
movl -0x78(%rbp), %eax
cmpl -0x7c(%rbp), %eax
je 0x5de6
movl -0x78(%rbp), %eax
subl -0x7c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
movl -0x80(%rbp), %eax
cmpl -0x84(%rbp), %eax
je 0x5dff
movl -0x80(%rbp), %eax
subl -0x84(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
movl -0x88(%rbp), %eax
subl -0x8c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5e19
movl -0x30(%rbp), %eax
subl -0x50(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)