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

  char buf[100];
  char *p = buf;
  char *q = p + sizeof(buf);
  const char *s = src;
  int base = 0;
  int64_t dummy;
  int64_t *ret = ret_ ? ret_ : &dummy;

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

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

  /* if 0* ... */
  if ('0' == s[0]) {
    switch (s[1]) {
    case 'x':
      base = 16;
      s += 2;
      break;
    case 'o':
      base = 8;
      s += 2;
      break;
    case 'b':
      base = 2;
      s += 2;
      break;
    case '\0':
      return *ret = 0, 0;
    default:
      /* ensure no other digits after it */
      if (s[1])
        return -1;
    }
  }

  /* just strip underscores and pass to strtoll */
  while (*s && p < q) {
    int ch = *s++;
    if (ch == '_') {
      // disallow '__'
      if (s[0] == '_')
        return -1;
      // numbers cannot end with '_'
      if (s[0] == '\0')
        return -1;
      continue; /* skip _ */
    }
    *p++ = ch;
  }

  // if not at end-of-string or we ran out of buffer ...
  if (*s || p == q)
    return -1;

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x45c6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x48e1
leaq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
addq $0x64, %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0x9c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x460c
movq -0x18(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x461c
leaq -0xa8(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x461c
movq -0xc8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
je 0x4648
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x4676
movq -0x98(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x98(%rbp)
movb (%rax), %cl
movq -0x88(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
movb %cl, (%rax)
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x4691
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x48e1
movq -0x98(%rbp), %rax
movsbl (%rax), %ecx
movl $0x30, %eax
cmpl %ecx, %eax
jne 0x477b
movq -0x98(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, -0xcc(%rbp)
testl %eax, %eax
je 0x4744
jmp 0x46c3
movl -0xcc(%rbp), %eax
subl $0x62, %eax
je 0x4726
jmp 0x46d0
movl -0xcc(%rbp), %eax
subl $0x6f, %eax
je 0x4708
jmp 0x46dd
movl -0xcc(%rbp), %eax
subl $0x78, %eax
jne 0x475e
jmp 0x46ea
movl $0x10, -0x9c(%rbp)
movq -0x98(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x98(%rbp)
jmp 0x4779
movl $0x8, -0x9c(%rbp)
movq -0x98(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x98(%rbp)
jmp 0x4779
movl $0x2, -0x9c(%rbp)
movq -0x98(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x98(%rbp)
jmp 0x4779
movq -0xb0(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x48e1
movq -0x98(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0x4777
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x48e1
jmp 0x4779
jmp 0x477b
jmp 0x477d
movq -0x98(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xcd(%rbp)
je 0x47ab
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
setb %al
movb %al, -0xcd(%rbp)
movb -0xcd(%rbp), %al
testb $0x1, %al
jne 0x47ba
jmp 0x4840
movq -0x98(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x98(%rbp)
movsbl (%rax), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x5f, -0xb4(%rbp)
jne 0x481c
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x47fc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x48e1
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4817
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x48e1
jmp 0x477d
movl -0xb4(%rbp), %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
movb %cl, (%rax)
jmp 0x477d
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x485f
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
jne 0x4868
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x48e1
movq -0x88(%rbp), %rax
movb $0x0, (%rax)
callq 0x1050
movl $0x0, (%rax)
leaq -0x80(%rbp), %rdi
movl -0x9c(%rbp), %edx
leaq -0xc0(%rbp), %rsi
callq 0x1140
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movq %rcx, (%rax)
callq 0x1050
movq %rax, %rcx
movb $0x1, %al
cmpl $0x0, (%rcx)
movb %al, -0xce(%rbp)
jne 0x48cb
movq -0xc0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0xce(%rbp)
movb -0xce(%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 $0xd0, %rsp
popq %rbp
retq
nopl (%rax)