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

```asm
<tonum>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%r12
  mov    %esi,%ebp
  mov    %rdx,%r14
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x18(%rsp)
  movq   $0x0,0x20(%rsp)
  cmp    $0x1,%esi
  je     L166
  jle    L227
  mov    D27(%rip),%r13
  cmpb   $0x2d,(%rdi)
  je     L207
L232:
  lea    0x10(%rsp),%rcx
  mov    $0x0,%edx
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <readsigned@plt>
  mov    %eax,%ebx
  movsd  0x10(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  comisd %xmm0,%xmm1
  ja     L117
L14:
  cmp    %ebx,%ebp
  jle    L111
  movslq %ebx,%rax
  cmpb   $0x2e,(%r12,%rax,1)
  je     L48
  test   %ebx,%ebx
  je     L180
  mov    $0x0,%r15d
L158:
  movslq %ebx,%rax
  movzbl (%r12,%rax,1),%eax
  and    $0xffffffdf,%eax
  cmp    $0x45,%al
  je     L125
L202:
  neg    %r15d
  pxor   %xmm0,%xmm0
  cvtsi2sd %r15d,%xmm0
  call   <decpow@plt>
  mulsd  0x18(%rsp),%xmm0
  addsd  0x10(%rsp),%xmm0
  movq   %r13,%xmm2
  mulsd  %xmm0,%xmm2
  movsd  %xmm2,0x8(%rsp)
  movsd  0x20(%rsp),%xmm0
  call   <decpow@plt>
  mulsd  0x8(%rsp),%xmm0
  movsd  %xmm0,(%r14)
  cmp    %ebx,%ebp
  setle  %bl
  movzbl %bl,%ebx
L180:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L53
  mov    %ebx,%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L166:
  movzbl (%rdi),%eax
  lea    -0x2d(%rax),%edx
  cmp    $0x1,%dl
  jbe    L168
  cmp    $0x2b,%al
  je     L168
  mov    D27(%rip),%r13
  jmp    L232
L207:
  cmpb   $0x2d,0x1(%rdi)
  je     L232
  add    $0x1,%r12
  sub    $0x1,%ebp
  mov    D37(%rip),%r13
  jmp    L232
L227:
  mov    D27(%rip),%r13
  jmp    L232
L117:
  xorpd  D17(%rip),%xmm0
  movsd  %xmm0,0x10(%rsp)
  mov    D37(%rip),%r13
  jmp    L14
L48:
  lea    0x1(%rbx),%r15d
  lea    0x18(%rsp),%rcx
  mov    $0xa,%r8d
  mov    %r15d,%edx
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <readint@plt>
  mov    %eax,%ebx
  sub    %r15d,%eax
  mov    %eax,%r15d
  test   %ebx,%ebx
  je     L180
  cmp    %ebp,%ebx
  jl     L158
  jmp    L202
L125:
  lea    0x1(%rbx),%eax
  lea    0x20(%rsp),%rcx
  mov    %eax,0x8(%rsp)
  mov    %eax,%edx
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <readsigned@plt>
  mov    %eax,%ebx
  cmp    %eax,0x8(%rsp)
  jne    L202
  mov    $0x0,%ebx
  jmp    L180
L168:
  mov    $0x0,%ebx
  jmp    L180
L111:
  mov    $0x0,%r15d
  test   %ebx,%ebx
  je     L180
  jmp    L202
L53:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D27
datatype: f64
name: disassemble_data
arguments: data_label: D37
datatype: f32[2]
name: disassemble_data
arguments: data_label: D17
datatype: f32[4]

tool: D27: 1

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

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

assistant: ```c
int tonum(unsigned char *s, int len, double *result) {
  int i = 0, fraclen = 0;
  double sgn = 1, val, frac = 0, exp = 0;
  if (len == 1 && (*s == '.' || *s == '-' || *s == '+'))
    return 0;
  if (len > 1 && s[0] == '-' && s[1] != '-') {
    sgn = -1;
    s++;
    len--;
  }
  i = readsigned(s, len, i, &val);
  if (val < 0) {
    sgn = -1;
    val = -val;
  }
  if (i < len && s[i] == '.') {
    i++;
    fraclen = readint(s, len, i, &frac, 10) - i;
    i += fraclen;
  }
  if (i == 0)
    return 0;
  if (i < len && (s[i] == 'e' || s[i] == 'E')) {
    int i0 = i + 1;
    i = readsigned(s, len, i + 1, &exp);
    if (i == i0)
      return 0;
  }
  *result = sgn * (val + frac * decpow(-fraclen)) * decpow(exp);
  if (i < len)
    return 0;
  return 1;
}
```