user: Please show me the C implementation that matches the assembly code listed below:

```asm
<todate_>:
  endbr64
  push   %rbp
  mov    %rdi,%r8
  mov    %rsi,%rdi
  mov    %rcx,%rbp
  push   %rbx
  mov    %rdi,%rcx
  mov    %rdx,%rbx
  sub    $0x28,%rsp
  mov    (%r8),%esi
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    D17(%rip),%rax
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0xc(%rsp)
  mov    %rax,(%rdx)
  mov    %rdi,%rax
  mov    $0xffffffff,%edx
  movl   $0x0,0x8(%rsp)
  movl   $0x0,0x4(%rsp)
  movl   $0x0,(%rsp)
  movl   $0x0,0x14(%rsp)
  jmp    L308
  nop
L132:
  add    $0x1,%rax
  add    $0x1,%edx
  cmpb   $0x0,-0x1(%rax)
  je     L91
L308:
  cmp    %edx,%esi
  jg     L132
L91:
  movslq %edx,%rsi
  lea    -0x1(%rdx),%eax
  lea    0x1(%rdx),%r9d
  mov    %edx,%edx
  lea    -0x1(%rsi),%r8
  sub    $0x2,%rsi
  cltq
  sub    %r9,%r8
  sub    %rdx,%rsi
  jmp    L142
  nop
L27:
  cmpb   $0x20,(%rdi,%rax,1)
  mov    %eax,%edx
  jne    L251
  sub    $0x1,%rax
  cmp    %rsi,%rax
  je     L152
L142:
  cmp    %r8,%rax
  jne    L27
L152:
  mov    $0xffffffff,%edx
L251:
  mov    $0xffffffff,%eax
  jmp    L254
  nopw   0x0(%rax,%rax,1)
L32:
  add    $0x1,%rcx
  add    $0x1,%eax
  cmpb   $0x20,-0x1(%rcx)
  jne    L59
L254:
  cmp    %edx,%eax
  jle    L32
L59:
  sub    %eax,%edx
  lea    0x1(%rdx),%ecx
  cmp    $0x7,%edx
  je     L110
  cmp    $0x7,%ecx
  jne    L347
  cmp    $0x1,%eax
  jne    L347
L110:
  cmpb   $0x2f,0x2(%rdi)
  jne    L127
  cmpb   $0x2f,0x5(%rdi)
  je     L333
L347:
  cmp    $0xa,%ecx
  je     L178
  cmp    $0x12,%ecx
  jle    L127
  cmpb   $0x2d,0x4(%rdi)
  je     L343
L127:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L50
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L343:
  cmpb   $0x2d,0x7(%rdi)
  jne    L127
  cmpb   $0x54,0xa(%rdi)
  jne    L127
  cmpb   $0x3a,0xd(%rdi)
  jne    L127
  cmpb   $0x3a,0x10(%rdi)
  jne    L127
  lea    0x14(%rsp),%rax
  lea    0x4(%rsp),%rcx
  mov    %rsp,%rdx
  push   %rax
  lea    D53(%rip),%rsi
  lea    0x18(%rsp),%rax
  push   %rax
  xor    %eax,%eax
  lea    0x1c(%rsp),%r9
  lea    0x18(%rsp),%r8
  call   <sscanf@plt>
  pop    %rax
  pop    %rdx
  jmp    L115
  nopl   0x0(%rax,%rax,1)
L178:
  cmpb   $0x2d,0x4(%rdi)
  jne    L127
  cmpb   $0x2d,0x7(%rdi)
  jne    L127
  lea    0x4(%rsp),%rcx
  mov    %rsp,%rdx
  lea    0x8(%rsp),%r8
  xor    %eax,%eax
  lea    D64(%rip),%rsi
  call   <sscanf@plt>
  jmp    L115
L333:
  lea    0x4(%rsp),%rcx
  lea    0x8(%rsp),%rdx
  mov    %rsp,%r8
  xor    %eax,%eax
  lea    D27(%rip),%rsi
  call   <sscanf@plt>
  mov    0x0(%rbp),%ecx
  test   %ecx,%ecx
  je     L276
  mov    0x8(%rsp),%eax
  mov    0x4(%rsp),%edx
  mov    %eax,0x4(%rsp)
  mov    %edx,0x8(%rsp)
L276:
  addl   $0x76c,(%rsp)
L115:
  movss  0x14(%rsp),%xmm0
  comiss D9(%rip),%xmm0
  jae    L127
  mov    0x10(%rsp),%ecx
  cmp    $0x3b,%ecx
  jg     L127
  mov    0xc(%rsp),%esi
  cmp    $0x17,%esi
  jg     L127
  mov    0x4(%rsp),%eax
  cmp    $0xc,%eax
  jg     L127
  mov    (%rsp),%r9d
  lea    -0x1(%rax),%edx
  lea    D31(%rip),%rdi
  movslq %edx,%rdx
  mov    (%rdi,%rdx,4),%r8d
  imul   $0xc28f5c29,%r9d,%edx
  add    $0x51eb850,%edx
  mov    %edx,%edi
  ror    $0x4,%edi
  cmp    $0xa3d70a,%edi
  jbe    L313
  test   $0x3,%r9b
  jne    L341
  ror    $0x2,%edx
  cmp    $0x28f5c28,%edx
  jbe    L341
L313:
  add    $0x1,%r8d
L341:
  mov    0x8(%rsp),%edi
  cmp    %r8d,%edi
  jg     L127
  cvtss2sd %xmm0,%xmm0
  lea    -0xe(%rax),%r8d
  pxor   %xmm1,%xmm1
  pxor   %xmm2,%xmm2
  movsd  D19(%rip),%xmm3
  movslq %r8d,%rdx
  cvtsi2sd %ecx,%xmm1
  sar    $0x1f,%r8d
  imul   $0x2aaaaaab,%rdx,%rdx
  divsd  %xmm3,%xmm0
  sar    $0x21,%rdx
  sub    %r8d,%edx
  lea    0x0(,%rdx,4),%r10d
  mov    %edx,%r8d
  sub    %r10d,%r8d
  lea    0x12c0(%r9,%rdx,1),%r10d
  imul   $0x5b5,%r10d,%r10d
  lea    -0x2(%rax,%r8,4),%r8d
  imul   $0x16f,%r8d,%r8d
  movslq %r8d,%rax
  sar    $0x1f,%r8d
  imul   $0x2aaaaaab,%rax,%rax
  sar    $0x21,%rax
  sub    %r8d,%eax
  test   %r10d,%r10d
  lea    0x3(%r10),%r8d
  cmovns %r10d,%r8d
  sar    $0x2,%r8d
  add    %r8d,%eax
  lea    0x1324(%r9,%rdx,1),%r8d
  movslq %r8d,%rdx
  sar    $0x1f,%r8d
  imul   $0x51eb851f,%rdx,%rdx
  sar    $0x25,%rdx
  sub    %r8d,%edx
  lea    (%rdx,%rdx,2),%r8d
  test   %r8d,%r8d
  lea    0x3(%r8),%edx
  addsd  %xmm1,%xmm0
  cmovns %r8d,%edx
  pxor   %xmm1,%xmm1
  cvtsi2sd %esi,%xmm1
  sar    $0x2,%edx
  divsd  %xmm3,%xmm0
  sub    %edx,%eax
  lea    -0x251c4c(%rdi,%rax,1),%eax
  cvtsi2sd %eax,%xmm2
  addsd  %xmm1,%xmm0
  divsd  D72(%rip),%xmm0
  addsd  %xmm0,%xmm2
  movsd  %xmm2,(%rbx)
  jmp    L127
L50:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D17
datatype: f32[2]
name: read_data
arguments: data_tag: D53
datatype: string
name: read_data
arguments: data_tag: D64
datatype: string
name: read_data
arguments: data_tag: D27
datatype: string
name: read_data
arguments: data_tag: D9
datatype: f32
name: read_data
arguments: data_tag: D31
datatype: string
name: read_data
arguments: data_tag: D19
datatype: f32[2]
name: read_data
arguments: data_tag: D72
datatype: f64

tool: {"D17": [0.0,-1.875]}

tool: D53: %d-%d-%dT%d:%d:%f

tool: D64: %d-%d-%d

tool: D27: %d/%d/%d

tool: D9: 60

tool: D31: 

tool: {"D19": [0.0,3.21875]}

tool: D72: 24

assistant: ```c
void todate_(slen, sdate, ddate, oldfits) int *slen;
char *sdate;
double *ddate;
int *oldfits;
{
  static int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int first, last, len;
  int yr, mon, day, hr, min, mday, mjd, csize, tmp;
  float secs;
  yr = mon = day = hr = min = 0;
  secs = 0.0;
  *ddate = -1.0;
  first = last = -1;
  while (last < *slen && sdate[++last] != '\0')
    ;
  while (last >= 0 && sdate[--last] == ' ' && last >= 0)
    ;
  while (first <= last && sdate[++first] == ' ')
    ;
  len = last - first + 1;
  if ((len == 8 || (len == 7 && first == 1)) && sdate[2] == '/' && sdate[5] == '/') {
    sscanf(sdate, "%d/%d/%d", &day, &mon, &yr);
    if (*oldfits) {
      tmp = day;
      day = mon;
      mon = tmp;
    }
    yr += 1900;
  } else if (len == 10 && sdate[4] == '-' && sdate[7] == '-') {
    sscanf(sdate, "%d-%d-%d", &yr, &mon, &day);
  } else if (len >= 19 && sdate[4] == '-' && sdate[7] == '-' && sdate[10] == 'T' && sdate[13] == ':' && sdate[16] == ':') {
    sscanf(sdate, "%d-%d-%dT%d:%d:%f", &yr, &mon, &day, &hr, &min, &secs);
  } else {
    return;
  }
  if (secs >= 60.0 || min >= 60 || hr >= 24 || mon > 12)
    return;
  mday = days[mon - 1];
  if ((yr % 400 == 0) || ((yr % 4 == 0) && (yr % 100 != 0)))
    mday++;
  if (day > mday)
    return;
  mjd = (1461 * (yr + 4800 + (mon - 14) / 12)) / 4 + (367 * (mon - 2 - 12 * ((mon - 14) / 12))) / 12 - (3 * ((yr + 4900 + (mon - 14) / 12) / 100)) / 4 + day - 32075;
  mjd = mjd - 2400001;
  *ddate = mjd + (hr + (min + secs / 60.0) / 60.0) / 24.0;
}
```