// File: /workspace/github_c_makefile_star2_O1/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 0x433f
movq %rsi, %rbx
movq %rdi, %r15
movzbl (%rdi), %r14d
callq 0x10c0
cmpl $0x27, %r14d
je 0x4175
cmpl $0x22, %r14d
jne 0x433f
cmpb 0x1(%r15), %r14b
jne 0x41e1
cmpb 0x2(%r15), %r14b
jne 0x41e1
cltq
cmpq $0x6, %rax
jl 0x433f
leaq (%r15,%rax), %rsi
addq $-0x3, %rsi
cmpb %r14b, (%rsi)
jne 0x433f
addq %r15, %rax
cmpb %r14b, -0x2(%rax)
jne 0x433f
cmpb %r14b, -0x1(%rax)
jne 0x433f
leaq 0x3(%r15), %rdi
movzbl (%rdi), %eax
movl $0x1, %edx
cmpl $0xd, %eax
je 0x4350
cmpl $0xa, %eax
jne 0x435d
addq $0x4, %r15
movl $0x0, 0x4(%rsp)
jmp 0x420a
cltq
cmpq $0x2, %rax
jl 0x433f
cmpb %r14b, -0x1(%r15,%rax)
jne 0x433f
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, %r14b
jne 0x42f1
movslq %esi, %rdx
addq %rdi, %rdx
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rdi, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
leal -0xa(%r14), %eax
cltq
cmpq %rax, %rbp
jl 0x42a8
leal 0x32(%r14), %r13d
movslq %r13d, %rdi
callq *0x4ece(%rip)           # 0x9118
testq %rax, %rax
je 0x4270
movq %rax, %r12
testq %r15, %r15
je 0x4273
movslq %r14d, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1190
movq %r15, %rdi
callq *0x4eb2(%rip)           # 0x9120
jmp 0x4273
xorl %r12d, %r12d
movq %r12, %rax
testq %r12, %r12
jne 0x428f
testq %r15, %r15
je 0x4289
movq %r15, %rdi
callq *0x4e97(%rip)           # 0x9120
movl %r14d, %r13d
movq %r15, %rax
movl %r13d, %r14d
movq %rax, %r15
testq %r12, %r12
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rdx
je 0x4331
leaq (%rdi,%rbp), %rax
cmpq %rdx, %rax
jae 0x4328
movsbl (%rax), %r12d
cmpl $0x9, %r12d
jb 0x42d0
leal -0xa(%r12), %eax
cmpb $0x16, %al
setae %al
cmpb $0x7f, %r12b
setne %cl
testb %al, %cl
jne 0x42e5
cmpb $0x0, 0x4(%rsp)
jne 0x4300
movzbl %r12b, %eax
cmpl $0xa, %eax
je 0x42e5
cmpl $0xd, %eax
jne 0x4300
movb %r12b, (%r15,%rbp)
incq %rbp
jmp 0x4232
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x436a
movq %rax, %r15
jmp 0x4334
testq %r15, %r15
je 0x430e
movq %r15, %rdi
callq *0x4e12(%rip)           # 0x9120
leaq 0x2304(%rip), %rdx      # 0x6619
xorl %r15d, %r15d
xorl %edi, %edi
xorl %esi, %esi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x10f0
jmp 0x4334
movl %ebp, %eax
movb $0x0, (%r15,%rax)
jmp 0x4334
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 0x420d