// File: /workspace/github_c_makefile_star2_O3/cktan[P]tomlc99/toml.c
// Function: toml_rtos
int toml_rtos(toml_raw_t src, char **ret) {
  int multiline = 0;
  const char *sp;
  const char *sq;

  *ret = 0;
  if (!src)
    return -1;

  // for strings, first char must be a s-quote or d-quote
  int qchar = src[0];
  int srclen = strlen(src);
  if (!(qchar == '\'' || qchar == '"')) {
    return -1;
  }

  // triple quotes?
  if (qchar == src[1] && qchar == src[2]) {
    multiline = 1;         // triple-quote implies multiline
    sp = src + 3;          // first char after quote
    sq = src + srclen - 3; // first char of ending quote

    if (!(sp <= sq && sq[0] == qchar && sq[1] == qchar && sq[2] == qchar)) {
      // last 3 chars in src must be qchar
      return -1;
    }

    /* skip new line immediate after qchar */
    if (sp[0] == '\n')
      sp++;
    else if (sp[0] == '\r' && sp[1] == '\n')
      sp += 2;

  } else {
    sp = src + 1;          // first char after quote
    sq = src + srclen - 1; // ending quote
    if (!(sp <= sq && *sq == qchar)) {
      /* last char in src must be qchar */
      return -1;
    }
  }

  // at this point:
  //     sp points to first valid char after quote.
  //     sq points to one char beyond last valid char.
  //     string len is (sq - sp).
  if (qchar == '\'') {
    *ret = norm_lit_str(sp, sq - sp, multiline, 0, 0);
  } else {
    *ret = norm_basic_str(sp, sq - sp, multiline, 0, 0);
  }

  return *ret ? 0 : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq $0x0, (%rsi)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x412f
movq %rsi, %rbx
movq %rdi, %r15
movzbl (%rdi), %r12d
callq 0x10b0
cmpl $0x27, %r12d
je 0x3f53
cmpl $0x22, %r12d
jne 0x412f
cmpb 0x1(%r15), %r12b
jne 0x3fbf
cmpb 0x2(%r15), %r12b
jne 0x3fbf
cltq
cmpq $0x6, %rax
jl 0x412f
leaq (%r15,%rax), %rsi
addq $-0x3, %rsi
cmpb %r12b, (%rsi)
jne 0x412f
addq %r15, %rax
cmpb %r12b, -0x2(%rax)
jne 0x412f
cmpb %r12b, -0x1(%rax)
jne 0x412f
leaq 0x3(%r15), %rdi
movzbl (%rdi), %eax
movl $0x1, %edx
cmpl $0xd, %eax
je 0x4140
cmpl $0xa, %eax
jne 0x414d
addq $0x4, %r15
movl $0x0, 0x4(%rsp)
jmp 0x3fe8
cltq
cmpq $0x2, %rax
jl 0x412f
cmpb %r12b, -0x1(%r15,%rax)
jne 0x412f
leaq (%r15,%rax), %rsi
decq %rsi
incq %r15
xorl %edx, %edx
movb $0x1, %al
movl %eax, 0x4(%rsp)
movq %r15, %rdi
subq %rdi, %rsi
cmpb $0x27, %r12b
jne 0x40c4
movq %rbx, 0x8(%rsp)
movslq %esi, %rdx
addq %rdi, %rdx
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r12d, %r12d
movq %rdx, 0x10(%rsp)
leal -0xa(%r14), %eax
cltq
cmpq %rax, %rbp
jge 0x4020
movq %r12, %r15
jmp 0x407a
movq %rdi, %rbx
leal 0x32(%r14), %r13d
movslq %r13d, %rdi
callq *0x50e0(%rip)           # 0x9110
movq %rax, %r15
testq %rax, %rax
sete %al
testq %r12, %r12
sete %cl
orb %al, %cl
je 0x4058
movl %r13d, %r14d
testq %r15, %r15
movq %rbx, %rdi
movq 0x10(%rsp), %rdx
jne 0x407a
jmp 0x410e
movslq %r14d, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x1180
movq %r12, %rdi
callq *0x50a9(%rip)           # 0x9118
movl %r13d, %r14d
movq %rbx, %rdi
movq 0x10(%rsp), %rdx
leaq (%rdi,%rbp), %rax
cmpq %rdx, %rax
jae 0x4100
movzbl (%rax), %r12d
cmpl $0x9, %r12d
jb 0x40a2
leal -0xa(%r12), %eax
cmpb $0x16, %al
setae %al
cmpb $0x7f, %r12b
setne %cl
testb %al, %cl
jne 0x40b5
cmpb $0x0, 0x4(%rsp)
jne 0x40d3
cmpl $0xa, %r12d
je 0x40b5
cmpl $0xd, %r12d
jne 0x40d3
movb %r12b, (%r15,%rbp)
incq %rbp
movq %r15, %r12
jmp 0x4010
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x415a
movq %rax, %r15
jmp 0x4124
testq %r15, %r15
movq 0x8(%rsp), %rbx
je 0x40e6
movq %r15, %rdi
callq *0x5032(%rip)           # 0x9118
leaq 0x2550(%rip), %rdx      # 0x663d
xorl %r15d, %r15d
xorl %edi, %edi
xorl %esi, %esi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x10e0
jmp 0x4124
movl %ebp, %eax
movb $0x0, (%r15,%rax)
movq 0x8(%rsp), %rbx
jmp 0x4124
testq %r12, %r12
movq 0x8(%rsp), %rbx
je 0x4121
movq %r12, %rdi
callq *0x4ff7(%rip)           # 0x9118
xorl %r15d, %r15d
movq %r15, (%rbx)
xorl %ebp, %ebp
cmpq $0x1, %r15
sbbl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0xa, 0x4(%r15)
leaq 0x5(%r15), %rax
cmoveq %rax, %rdi
movl $0x0, 0x4(%rsp)
jmp 0x3feb