// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %r14
movq 0x88(%rsp), %r12
movslq 0x90(%rsp), %r15
movl 0x84(%rsp), %ebx
movzbl (%r12), %eax
cmpl $0x22, %eax
je 0x4b7c
cmpl $0x27, %eax
jne 0x4c50
addq %r12, %r15
leaq 0x1(%r12), %r13
xorl %edx, %edx
movq $-0x1, %rcx
cmpb %al, 0x1(%r12)
jne 0x4bae
cmpb %al, 0x2(%r12)
jne 0x4bae
addq $0x3, %r12
movl $0x1, %edx
movq $-0x3, %rcx
movq %r12, %r13
addq %rcx, %r15
subq %r13, %r15
cmpb $0x27, %al
jne 0x4bf1
movq %r13, %rdi
movq %r15, %rsi
callq 0x1120
movq %rax, %r12
leaq 0x1(%rax), %rdi
callq *0x4548(%rip)           # 0x9118
testq %rax, %rax
je 0x4cb4
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x1190
movb $0x0, (%r15,%r12)
jmp 0x4c11
movq %rsp, %rcx
movq %r13, %rdi
movl %r15d, %esi
movl $0x50, %r8d
callq 0x436a
movq %rax, %r15
testq %rax, %rax
je 0x4ccc
movq %r15, %rdi
movl $0xa, %esi
callq 0x10d0
testq %rax, %rax
je 0x4d0c
movq %r15, %rdi
callq *0x44f0(%rip)           # 0x9120
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x164b(%rip), %rdx      # 0x628a
xorl %r15d, %r15d
movl %ebx, %ecx
xorl %eax, %eax
callq 0x10f0
jmp 0x4d0c
testl %r15d, %r15d
je 0x4c7f
callq 0x1200
movq (%rax), %rax
xorl %ecx, %ecx
movsbq (%r12,%rcx), %rdx
testb $0x8, (%rax,%rdx,2)
jne 0x4c77
movzbl %dl, %edx
cmpl $0x2d, %edx
je 0x4c77
cmpl $0x5f, %edx
jne 0x4c30
incq %rcx
cmpq %rcx, %r15
jne 0x4c5f
movq %r12, %rdi
movq %r15, %rsi
callq 0x1120
movq %rax, %rbx
leaq 0x1(%rax), %rdi
callq *0x4481(%rip)           # 0x9118
testq %rax, %rax
je 0x4cec
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1190
movb $0x0, (%r15,%rbx)
jmp 0x4d0c
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x14f7(%rip), %rdx      # 0x61ba
leaq 0x15aa(%rip), %rcx      # 0x6274
jmp 0x4d02
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x158d(%rip), %rdx      # 0x6268
xorl %r15d, %r15d
movq %rsp, %r8
movl %ebx, %ecx
xorl %eax, %eax
callq 0x10f0
jmp 0x4d0c
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x14bf(%rip), %rdx      # 0x61ba
leaq 0x157d(%rip), %rcx      # 0x627f
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x10f0
movq %r15, %rax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq