// File: /workspace/github_c_makefile_star2_O3/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 0x48b6
cmpl $0x27, %eax
jne 0x498a
addq %r12, %r15
leaq 0x1(%r12), %r13
xorl %edx, %edx
movq $-0x1, %rcx
cmpb %al, 0x1(%r12)
jne 0x48e8
cmpb %al, 0x2(%r12)
jne 0x48e8
addq $0x3, %r12
movl $0x1, %edx
movq $-0x3, %rcx
movq %r12, %r13
addq %rcx, %r15
subq %r13, %r15
cmpb $0x27, %al
jne 0x492b
movq %r13, %rdi
movq %r15, %rsi
callq 0x1110
movq %rax, %r12
leaq 0x1(%rax), %rdi
callq *0x4806(%rip)           # 0x9110
testq %rax, %rax
je 0x49ee
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x1180
movb $0x0, (%r15,%r12)
jmp 0x494b
movq %rsp, %rcx
movq %r13, %rdi
movl %r15d, %esi
movl $0x50, %r8d
callq 0x415a
movq %rax, %r15
testq %rax, %rax
je 0x4a06
movq %r15, %rdi
movl $0xa, %esi
callq 0x10c0
testq %rax, %rax
je 0x4a46
movq %r15, %rdi
callq *0x47ae(%rip)           # 0x9118
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x1935(%rip), %rdx      # 0x62ae
xorl %r15d, %r15d
movl %ebx, %ecx
xorl %eax, %eax
callq 0x10e0
jmp 0x4a46
testl %r15d, %r15d
je 0x49b9
callq 0x11f0
movq (%rax), %rax
xorl %ecx, %ecx
movsbq (%r12,%rcx), %rdx
testb $0x8, (%rax,%rdx,2)
jne 0x49b1
movzbl %dl, %edx
cmpl $0x2d, %edx
je 0x49b1
cmpl $0x5f, %edx
jne 0x496a
incq %rcx
cmpq %rcx, %r15
jne 0x4999
movq %r12, %rdi
movq %r15, %rsi
callq 0x1110
movq %rax, %rbx
leaq 0x1(%rax), %rdi
callq *0x473f(%rip)           # 0x9110
testq %rax, %rax
je 0x4a26
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1180
movb $0x0, (%r15,%rbx)
jmp 0x4a46
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x17e1(%rip), %rdx      # 0x61de
leaq 0x1894(%rip), %rcx      # 0x6298
jmp 0x4a3c
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x1877(%rip), %rdx      # 0x628c
xorl %r15d, %r15d
movq %rsp, %r8
movl %ebx, %ecx
xorl %eax, %eax
callq 0x10e0
jmp 0x4a46
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x17a9(%rip), %rdx      # 0x61de
leaq 0x1867(%rip), %rcx      # 0x62a3
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x10e0
movq %r15, %rax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq