// File: /workspace/github_c_makefile_star2_O0/cktan[P]tomlc99/toml.c
// Function: toml_rtod_ex
int toml_rtod_ex(toml_raw_t src, double *ret_, char *buf, int buflen) {
  if (!src)
    return -1;

  char *p = buf;
  char *q = p + buflen;
  const char *s = src;
  double dummy;
  double *ret = ret_ ? ret_ : &dummy;

  /* allow +/- */
  if (s[0] == '+' || s[0] == '-')
    *p++ = *s++;

  /* disallow +_1.00 */
  if (s[0] == '_')
    return -1;

  /* decimal point, if used, must be surrounded by at least one digit on each
   * side */
  {
    char *dot = strchr(s, '.');
    if (dot) {
      if (dot == s || !isdigit(dot[-1]) || !isdigit(dot[1]))
        return -1;
    }
  }

  /* zero must be followed by . or 'e', or NUL */
  if (s[0] == '0' && s[1] && !strchr("eE.", s[1]))
    return -1;

  /* just strip underscores and pass to strtod */
  while (*s && p < q) {
    int ch = *s++;
    if (ch == '_') {
      // disallow '__'
      if (s[0] == '_')
        return -1;
      // disallow last char '_'
      if (s[0] == 0)
        return -1;
      continue; /* skip _ */
    }
    *p++ = ch;
  }
  if (*s || p == q)
    return -1; /* reached end of string or buffer is full? */

  /* cap with NUL */
  *p = 0;

  /* Run strtod on buf to get the value */
  char *endp;
  errno = 0;
  *ret = strtod(buf, &endp);
  return (errno || *endp) ? -1 : 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x491d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b70
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x494d
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x4957
leaq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x4957
movq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
je 0x4977
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x4999
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movb (%rax), %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x49b1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b70
movq -0x40(%rbp), %rdi
movl $0x2e, %esi
callq 0x10c0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x4a24
movq -0x58(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x4a16
callq 0x11d0
movq (%rax), %rax
movq -0x58(%rbp), %rcx
movsbl -0x1(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x4a16
callq 0x11d0
movq (%rax), %rax
movq -0x58(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x4a22
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b70
jmp 0x4a24
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x4a63
movq -0x40(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0x4a63
movq -0x40(%rbp), %rax
movsbl 0x1(%rax), %esi
leaq 0x3872(%rip), %rdi      # 0x82be
callq 0x10c0
cmpq $0x0, %rax
jne 0x4a63
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b70
jmp 0x4a65
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x71(%rbp)
je 0x4a84
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
setb %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x4a8d
jmp 0x4af5
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movsbl (%rax), %eax
movl %eax, -0x5c(%rbp)
cmpl $0x5f, -0x5c(%rbp)
jne 0x4ada
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x4ac0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b70
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4ad8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b70
jmp 0x4a65
movl -0x5c(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
jmp 0x4a65
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4b0b
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x4b14
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4b70
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
callq 0x1050
movl $0x0, (%rax)
movq -0x20(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1090
movq -0x50(%rbp), %rax
movsd %xmm0, (%rax)
callq 0x1050
movq %rax, %rcx
movb $0x1, %al
cmpl $0x0, (%rcx)
movb %al, -0x72(%rbp)
jne 0x4b5d
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x72(%rbp)
movb -0x72(%rbp), %dl
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)