// File: /workspace/github_c_makefile_star2_O0/neovim[P]libtermkey/termkey.c
// Function: termkey_strfkey
size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, TermKeyFormat format)
{
  size_t pos = 0;
  size_t l = 0;

  struct modnames *mods = &modnames[!!(format & TERMKEY_FORMAT_LONGMOD) +
                                    !!(format & TERMKEY_FORMAT_ALTISMETA) * 2 +
                                    !!(format & TERMKEY_FORMAT_LOWERMOD) * 4];

  int wrapbracket = (format & TERMKEY_FORMAT_WRAPBRACKET) &&
                    (key->type != TERMKEY_TYPE_UNICODE || key->modifiers != 0);

  char sep = (format & TERMKEY_FORMAT_SPACEMOD) ? ' ' : '-';

  if(format & TERMKEY_FORMAT_CARETCTRL &&
     key->type == TERMKEY_TYPE_UNICODE &&
     key->modifiers == TERMKEY_KEYMOD_CTRL) {
    long codepoint = key->code.codepoint;

    // Handle some of the special cases first
    if(codepoint >= 'a' && codepoint <= 'z') {
      l = snprintf(buffer + pos, len - pos, wrapbracket ? "<^%c>" : "^%c", (char)codepoint - 0x20);
      if(l <= 0) return pos;
      pos += l;
      return pos;
    }
    else if((codepoint >= '@' && codepoint < 'A') ||
            (codepoint > 'Z' && codepoint <= '_')) {
      l = snprintf(buffer + pos, len - pos, wrapbracket ? "<^%c>" : "^%c", (char)codepoint);
      if(l <= 0) return pos;
      pos += l;
      return pos;
    }
  }

  if(wrapbracket) {
    l = snprintf(buffer + pos, len - pos, "<");
    if(l <= 0) return pos;
    pos += l;
  }

  if(key->modifiers & TERMKEY_KEYMOD_ALT) {
    l = snprintf(buffer + pos, len - pos, "%s%c", mods->alt, sep);
    if(l <= 0) return pos;
    pos += l;
  }

  if(key->modifiers & TERMKEY_KEYMOD_CTRL) {
    l = snprintf(buffer + pos, len - pos, "%s%c", mods->ctrl, sep);
    if(l <= 0) return pos;
    pos += l;
  }

  if(key->modifiers & TERMKEY_KEYMOD_SHIFT) {
    l = snprintf(buffer + pos, len - pos, "%s%c", mods->shift, sep);
    if(l <= 0) return pos;
    pos += l;
  }

  switch(key->type) {
  case TERMKEY_TYPE_UNICODE:
    if(!key->utf8[0]) // In case of user-supplied key structures
      fill_utf8(key);
    l = snprintf(buffer + pos, len - pos, "%s", key->utf8);
    break;
  case TERMKEY_TYPE_KEYSYM:
    {
      const char *name = termkey_get_keyname(tk, key->code.sym);
      if(format & TERMKEY_FORMAT_LOWERSPACE)
        l = snprint_cameltospaces(buffer + pos, len - pos, name);
      else
        l = snprintf(buffer + pos, len - pos, "%s", name);
    }
    break;
  case TERMKEY_TYPE_FUNCTION:
    l = snprintf(buffer + pos, len - pos, "%c%d",
        (format & TERMKEY_FORMAT_LOWERSPACE ? 'f' : 'F'), key->code.number);
    break;
  case TERMKEY_TYPE_MOUSE:
    {
      TermKeyMouseEvent ev;
      int button;
      int line, col;
      termkey_interpret_mouse(tk, key, &ev, &button, &line, &col);

      l = snprintf(buffer + pos, len - pos, "Mouse%s(%d)",
          evnames[ev], button);

      if(format & TERMKEY_FORMAT_MOUSE_POS) {
        if(l <= 0) return pos;
        pos += l;

        l = snprintf(buffer + pos, len - pos, " @ (%u,%u)", col, line);
      }
    }
    break;
  case TERMKEY_TYPE_POSITION:
    l = snprintf(buffer + pos, len - pos, "Position");
    break;
  case TERMKEY_TYPE_MODEREPORT:
    {
      int initial, mode, value;
      termkey_interpret_modereport(tk, key, &initial, &mode, &value);
      if(initial)
        l = snprintf(buffer + pos, len - pos, "Mode(%c%d=%d)", initial, mode, value);
      else
        l = snprintf(buffer + pos, len - pos, "Mode(%d=%d)", mode, value);
    }
  case TERMKEY_TYPE_DCS:
    l = snprintf(buffer + pos, len - pos, "DCS");
    break;
  case TERMKEY_TYPE_OSC:
    l = snprintf(buffer + pos, len - pos, "OSC");
    break;
  case TERMKEY_TYPE_UNKNOWN_CSI:
    l = snprintf(buffer + pos, len - pos, "CSI %c", key->code.number & 0xff);
    break;
  }

  if(l <= 0) return pos;
  pos += l;

  if(wrapbracket) {
    l = snprintf(buffer + pos, len - pos, ">");
    if(l <= 0) return pos;
    pos += l;
  }

  return pos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl -0x2c(%rbp), %ecx
andl $0x4, %ecx
cmpl $0x0, %ecx
setne %cl
xorb $-0x1, %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
shll %ecx
addl %ecx, %eax
movl -0x2c(%rbp), %ecx
andl $0x20, %ecx
cmpl $0x0, %ecx
setne %cl
xorb $-0x1, %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
shll $0x2, %ecx
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x85f9(%rip), %rax      # 0xd1a0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x2c(%rbp), %ecx
andl $0x8, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x7d(%rbp)
je 0x4be4
movq -0x28(%rbp), %rcx
movb $0x1, %al
cmpl $0x0, (%rcx)
movb %al, -0x7e(%rbp)
jne 0x4bde
movq -0x28(%rbp), %rax
cmpl $0x0, 0x10(%rax)
setne %al
movb %al, -0x7e(%rbp)
movb -0x7e(%rbp), %al
movb %al, -0x7d(%rbp)
movb -0x7d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movl -0x2c(%rbp), %edx
andl $0x10, %edx
movl $0x2d, %eax
movl $0x20, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, -0x4d(%rbp)
movl -0x2c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x4d41
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x4d41
movq -0x28(%rbp), %rax
cmpl $0x4, 0x10(%rax)
jne 0x4d41
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x61, -0x58(%rbp)
jl 0x4cb8
cmpq $0x7a, -0x58(%rbp)
jg 0x4cb8
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movl -0x4c(%rbp), %ecx
leaq 0x54d5(%rip), %rdx      # 0xa13b
leaq 0x54c8(%rip), %rax      # 0xa135
cmpl $0x0, %ecx
cmovneq %rax, %rdx
movq -0x58(%rbp), %rax
movsbl %al, %ecx
subl $0x20, %ecx
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
ja 0x4c9f
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
cmpq $0x40, -0x58(%rbp)
jl 0x4cc6
cmpq $0x41, -0x58(%rbp)
jl 0x4cd4
cmpq $0x5a, -0x58(%rbp)
jle 0x4d3d
cmpq $0x5f, -0x58(%rbp)
jg 0x4d3d
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movl -0x4c(%rbp), %ecx
leaq 0x544d(%rip), %rdx      # 0xa13b
leaq 0x5440(%rip), %rax      # 0xa135
cmpl $0x0, %ecx
cmovneq %rax, %rdx
movq -0x58(%rbp), %rax
movsbl %al, %ecx
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
ja 0x4d24
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
jmp 0x4d3f
jmp 0x4d41
cmpl $0x0, -0x4c(%rbp)
je 0x4d8b
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
leaq 0x53e1(%rip), %rdx      # 0xa13f
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
ja 0x4d7f
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x4deb
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rcx
movsbl -0x4d(%rbp), %r8d
leaq 0x5383(%rip), %rdx      # 0xa141
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
ja 0x4ddf
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x4e4b
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rcx
movsbl -0x4d(%rbp), %r8d
leaq 0x5323(%rip), %rdx      # 0xa141
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
ja 0x4e3f
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4eaa
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rax
movq (%rax), %rcx
movsbl -0x4d(%rbp), %r8d
leaq 0x52c4(%rip), %rdx      # 0xa141
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
ja 0x4e9e
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
incl %eax
movl %eax, %ecx
movq %rcx, -0x88(%rbp)
subl $0x8, %eax
ja 0x51a8
movq -0x88(%rbp), %rax
leaq 0x516e(%rip), %rcx      # 0xa040
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
cmpb $0x0, 0x14(%rax)
jne 0x4eee
movq -0x28(%rbp), %rdi
callq 0x4090
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movq -0x28(%rbp), %rcx
addq $0x14, %rcx
leaq 0x54a4(%rip), %rdx      # 0xa3b1
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x51a8
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x31e0
movq %rax, -0x60(%rbp)
movl -0x2c(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x4f5f
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x5230
cltq
movq %rax, -0x40(%rbp)
jmp 0x4f87
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movq -0x60(%rbp), %rcx
leaq 0x5437(%rip), %rdx      # 0xa3b1
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x51a8
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
andl $0x40, %edx
movl $0x46, %ecx
movl $0x66, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x28(%rbp), %rax
movl 0x8(%rax), %r8d
leaq 0x5185(%rip), %rdx      # 0xa146
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x51a8
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x64(%rbp), %rdx
leaq -0x68(%rbp), %rcx
leaq -0x6c(%rbp), %r8
leaq -0x70(%rbp), %r9
callq 0x30e0
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movl -0x64(%rbp), %eax
movl %eax, %ecx
leaq 0x8254(%rip), %rax      # 0xd260
movq (%rax,%rcx,8), %rcx
movl -0x68(%rbp), %r8d
leaq 0x5130(%rip), %rdx      # 0xa14b
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x5080
cmpq $0x0, -0x40(%rbp)
ja 0x5049
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movl -0x70(%rbp), %ecx
movl -0x6c(%rbp), %r8d
leaq 0x50e4(%rip), %rdx      # 0xa157
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x51a8
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
leaq 0x50c6(%rip), %rdx      # 0xa162
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x51a8
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x74(%rbp), %rdx
leaq -0x78(%rbp), %rcx
leaq -0x7c(%rbp), %r8
callq 0x30b0
cmpl $0x0, -0x74(%rbp)
je 0x50fe
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movl -0x74(%rbp), %ecx
movl -0x78(%rbp), %r8d
movl -0x7c(%rbp), %r9d
leaq 0x507c(%rip), %rdx      # 0xa16b
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x5129
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movl -0x78(%rbp), %ecx
movl -0x7c(%rbp), %r8d
leaq 0x505d(%rip), %rdx      # 0xa179
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x512b
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
leaq 0x5043(%rip), %rdx      # 0xa185
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x51a8
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
leaq 0x5021(%rip), %rdx      # 0xa189
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
jmp 0x51a8
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
andl $0xff, %ecx
leaq 0x4ff2(%rip), %rdx      # 0xa18d
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
ja 0x51b9
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x520c
movq -0x18(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
subq -0x38(%rbp), %rsi
leaq 0x4f57(%rip), %rdx      # 0xa139
movb $0x0, %al
callq 0x3120
cltq
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
ja 0x5200
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5214
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)