// File: /workspace/github_c_makefile_star2_O3/cktan[P]tomlc99/toml.c
// Function: toml_rtots
int toml_rtots(toml_raw_t src_, toml_timestamp_t *ret) {
  if (!src_)
    return -1;

  const char *p = src_;
  int must_parse_time = 0;

  memset(ret, 0, sizeof(*ret));

  int *year = &ret->__buffer.year;
  int *month = &ret->__buffer.month;
  int *day = &ret->__buffer.day;
  int *hour = &ret->__buffer.hour;
  int *minute = &ret->__buffer.minute;
  int *second = &ret->__buffer.second;
  int *millisec = &ret->__buffer.millisec;

  /* parse date YYYY-MM-DD */
  if (0 == scan_date(p, year, month, day)) {
    ret->year = year;
    ret->month = month;
    ret->day = day;

    p += 10;
    if (*p) {
      // parse the T or space separator
      if (*p != 'T' && *p != 't' && *p != ' ')
        return -1;
      must_parse_time = 1;
      p++;
    }
  }

  /* parse time HH:MM:SS */
  if (0 == scan_time(p, hour, minute, second)) {
    ret->hour = hour;
    ret->minute = minute;
    ret->second = second;

    /* optionally, parse millisec */
    p += 8;
    if (*p == '.') {
      p++; /* skip '.' */
      const char *qq;
      *millisec = parse_millisec(p, &qq);
      ret->millisec = millisec;
      p = qq;
    }

    if (*p) {
      /* parse and copy Z */
      char *z = ret->__buffer.z;
      ret->z = z;
      if (*p == 'Z' || *p == 'z') {
        *z++ = 'Z';
        p++;
        *z = 0;

      } else if (*p == '+' || *p == '-') {
        *z++ = *p++;

        if (!(isdigit(p[0]) && isdigit(p[1])))
          return -1;
        *z++ = *p++;
        *z++ = *p++;

        if (*p == ':') {
          *z++ = *p++;

          if (!(isdigit(p[0]) && isdigit(p[1])))
            return -1;
          *z++ = *p++;
          *z++ = *p++;
        }

        *z = 0;
      }
    }
  }
  if (*p != 0)
    return -1;

  if (must_parse_time && !ret->hour)
    return -1;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x3924
movq %rsi, %r14
movq %rdi, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rsi)
movups %xmm0, 0x40(%rsi)
movups %xmm0, 0x30(%rsi)
movups %xmm0, 0x20(%rsi)
movups %xmm0, 0x10(%rsi)
movups %xmm0, (%rsi)
movq $0x0, 0x60(%rsi)
leaq 0x4(%rsi), %r12
leaq 0x8(%rsi), %r13
movq %r12, %rdx
movq %r13, %rcx
callq 0x3a81
testl %eax, %eax
je 0x38a9
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x38ec
movq %r14, 0x28(%r14)
movq %r12, 0x30(%r14)
movq %r13, 0x38(%r14)
movzbl 0xa(%r15), %eax
cmpl $0x53, %eax
jg 0x38ca
testl %eax, %eax
je 0x38e2
cmpl $0x20, %eax
je 0x38d4
jmp 0x3924
cmpl $0x74, %eax
je 0x38d4
cmpl $0x54, %eax
jne 0x3924
addq $0xb, %r15
movl $0x0, 0x4(%rsp)
jmp 0x38ec
movb $0x1, %al
movl %eax, 0x4(%rsp)
addq $0xa, %r15
leaq 0x10(%r14), %r12
leaq 0xc(%r14), %rbp
leaq 0x14(%r14), %r13
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x3b28
testl %eax, %eax
je 0x3935
movb (%r15), %al
testb %al, %al
jne 0x3924
cmpb $0x0, 0x4(%rsp)
jne 0x3922
cmpq $0x0, 0x40(%r14)
je 0x3924
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, 0x40(%r14)
movq %r12, 0x48(%r14)
movq %r13, 0x50(%r14)
movb 0x8(%r15), %al
cmpb $0x2e, %al
jne 0x39a7
leaq 0x18(%r14), %rax
movb 0x9(%r15), %sil
addq $0x9, %r15
leal -0x30(%rsi), %edx
xorl %ecx, %ecx
cmpb $0x9, %dl
ja 0x399a
xorl %ecx, %ecx
movl $0x64, %edx
addb $-0x30, %sil
movzbl %sil, %esi
imull %edx, %esi
addl %esi, %ecx
movslq %edx, %rdx
imulq $0x66666667, %rdx, %rdx # imm = 0x66666667
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rdx
addl %esi, %edx
movb 0x1(%r15), %sil
incq %r15
leal -0x30(%rsi), %edi
cmpb $0xa, %dil
jb 0x3966
movl %ecx, 0x18(%r14)
movq %rax, 0x58(%r14)
movb (%r15), %al
jmp 0x39ab
addq $0x8, %r15
testb %al, %al
je 0x390d
leaq 0x1c(%r14), %rax
movq %rax, 0x60(%r14)
movb (%r15), %al
movzbl %al, %ecx
cmpl $0x59, %ecx
jg 0x3a55
cmpl $0x2b, %ecx
je 0x39d8
cmpl $0x2d, %ecx
jne 0x3910
movb %al, 0x1c(%r14)
callq 0x11f0
movq (%rax), %rdx
movsbq 0x1(%r15), %rcx
testb $0x8, 0x1(%rdx,%rcx,2)
je 0x3924
movsbq 0x2(%r15), %rsi
testb $0x8, 0x1(%rdx,%rsi,2)
je 0x3924
movb %cl, 0x1d(%r14)
movb 0x2(%r15), %cl
movb %cl, 0x1e(%r14)
cmpb $0x3a, 0x3(%r15)
jne 0x3a77
movb $0x3a, 0x1f(%r14)
movq (%rax), %rcx
movsbq 0x4(%r15), %rax
testb $0x8, 0x1(%rcx,%rax,2)
je 0x3924
movsbq 0x5(%r15), %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x3924
movb %al, 0x20(%r14)
movb 0x5(%r15), %cl
addq $0x6, %r15
leaq 0x22(%r14), %rax
movb %cl, 0x21(%r14)
jmp 0x3a6f
cmpl $0x7a, %ecx
je 0x3a63
cmpl $0x5a, %ecx
jne 0x3910
leaq 0x1d(%r14), %rax
movb $0x5a, 0x1c(%r14)
incq %r15
movb $0x0, (%rax)
jmp 0x390d
addq $0x3, %r15
leaq 0x1f(%r14), %rax
jmp 0x3a6f