// File: /workspace/github_c_makefile_star2_O0/cktan[P]tomlc99/toml.c
// Function: normalize_key
static char *normalize_key(context_t *ctx, token_t strtok) {
  const char *sp = strtok.ptr;
  const char *sq = strtok.ptr + strtok.len;
  int lineno = strtok.lineno;
  char *ret;
  int ch = *sp;
  char ebuf[80];

  /* handle quoted string */
  if (ch == '\'' || ch == '\"') {
    /* if ''' or """, take 3 chars off front and back. Else, take 1 char off. */
    int multiline = 0;
    if (sp[1] == ch && sp[2] == ch) {
      sp += 3, sq -= 3;
      multiline = 1;
    } else
      sp++, sq--;

    if (ch == '\'') {
      /* for single quote, take it verbatim. */
      if (!(ret = STRNDUP(sp, sq - sp))) {
        e_outofmemory(ctx, FLINE);
        return 0;
      }
    } else {
      /* for double quote, we need to normalize */
      ret = norm_basic_str(sp, sq - sp, multiline, ebuf, sizeof(ebuf));
      if (!ret) {
        e_syntax(ctx, lineno, ebuf);
        return 0;
      }
    }

    /* newlines are not allowed in keys */
    if (strchr(ret, '\n')) {
      xfree(ret);
      e_badkey(ctx, lineno);
      return 0;
    }
    return ret;
  }

  /* for bare-key allow only this regex: [A-Za-z0-9_-]+ */
  const char *xp;
  for (xp = sp; xp != sq; xp++) {
    int k = *xp;
    if (isalnum(k))
      continue;
    if (k == '_' || k == '-')
      continue;
    e_badkey(ctx, lineno);
    return 0;
  }

  /* dup and return it */
  if (!(ret = STRNDUP(sp, sq - sp))) {
    e_outofmemory(ctx, FLINE);
    return 0;
  }
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
leaq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x18(%rbp)
movq 0x8(%rax), %rcx
movslq 0x10(%rax), %rdx
addq %rdx, %rcx
movq %rcx, -0x20(%rbp)
movl 0x4(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x27, -0x34(%rbp)
je 0x5a0a
cmpl $0x22, -0x34(%rbp)
jne 0x5b46
movl $0x0, -0x94(%rbp)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl -0x34(%rbp), %eax
jne 0x5a52
movq -0x18(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl -0x34(%rbp), %eax
jne 0x5a52
movq -0x18(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
addq $-0x3, %rax
movq %rax, -0x20(%rbp)
movl $0x1, -0x94(%rbp)
jmp 0x5a6a
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
cmpl $0x27, -0x34(%rbp)
jne 0x5aad
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rax
subq %rax, %rsi
callq 0x5f50
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x5aab
movq -0x10(%rbp), %rdi
leaq 0x28e3(%rip), %rsi      # 0x837c
callq 0x2910
movq $0x0, -0x8(%rbp)
jmp 0x5c09
jmp 0x5b03
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movl -0x94(%rbp), %edx
leaq -0x90(%rbp), %rcx
movl $0x50, %r8d
callq 0x4f30
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x5b01
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq -0x90(%rbp), %rdx
callq 0x3010
movq $0x0, -0x8(%rbp)
jmp 0x5c09
jmp 0x5b03
movq -0x30(%rbp), %rdi
movl $0xa, %esi
callq 0x10c0
cmpq $0x0, %rax
je 0x5b39
movq -0x30(%rbp), %rdi
callq 0x3500
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x65e0
movq $0x0, -0x8(%rbp)
jmp 0x5c09
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5c09
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x5bc9
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0xa4(%rbp)
callq 0x11d0
movq (%rax), %rax
movslq -0xa4(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x5b8b
jmp 0x5bb5
cmpl $0x5f, -0xa4(%rbp)
je 0x5b9d
cmpl $0x2d, -0xa4(%rbp)
jne 0x5b9f
jmp 0x5bb5
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x65e0
movq $0x0, -0x8(%rbp)
jmp 0x5c09
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x5b51
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rax
subq %rax, %rsi
callq 0x5f50
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x5c01
movq -0x10(%rbp), %rdi
leaq 0x2795(%rip), %rsi      # 0x8387
callq 0x2910
movq $0x0, -0x8(%rbp)
jmp 0x5c09
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)