// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
leaq 0x40(%rsp), %r12
movaps %xmm1, 0x10(%r12)
movaps %xmm0, (%r12)
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
leaq 0x20(%rsp), %r13
movaps %xmm1, 0x10(%r13)
movaps %xmm0, (%r13)
movq %r12, %rsi
callq 0x3270
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3270
movl (%r12), %ecx
movl %ecx, %eax
subl (%r13), %eax
jne 0x4c71
incl %ecx
cmpl $0x8, %ecx
ja 0x4bbb
leaq 0x24fb(%rip), %rax      # 0x7060
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl 0x48(%rsp), %eax
subl 0x28(%rsp), %eax
je 0x4bbb
jmp 0x4c71
subq %r15, %r14
shrq $0x5, %r14
movl %r14d, %eax
jmp 0x4c71
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
pushq $0x4
popq %rdx
callq 0x30d0
testl %eax, %eax
jne 0x4c71
jmp 0x4bbb
movq 0x48(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq %rcx, %rax
jne 0x4c6f
movl 0x50(%rsp), %eax
subl 0x30(%rsp), %eax
jmp 0x4c71
leaq 0x40(%rsp), %rsi
leaq 0x1c(%rsp), %r14
leaq 0x18(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x31b0
leaq 0x20(%rsp), %rsi
leaq 0xc(%rsp), %r12
leaq 0x8(%rsp), %r13
movq %rbx, %rdi
movq %r12, %rdx
movq %r13, %rcx
callq 0x31b0
movl (%r14), %eax
movl (%r15), %ecx
subl (%r13), %ecx
subl (%r12), %eax
cmovel %ecx, %eax
jmp 0x4c71
leaq 0x40(%rsp), %rsi
leaq 0x1c(%rsp), %r14
leaq 0xc(%rsp), %rcx
leaq 0x14(%rsp), %r8
movq %rbx, %rdi
movq %r14, %rdx
callq 0x30b0
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %r15
leaq 0x8(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rdx
callq 0x30b0
movl (%r14), %eax
subl (%r15), %eax
jne 0x4c71
movl 0xc(%rsp), %eax
subl 0x8(%rsp), %eax
jne 0x4c71
movl 0x14(%rsp), %eax
subl 0x10(%rsp), %eax
jmp 0x4c71
subl %ecx, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq