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

```asm
<grisu3_parse_double>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    %rdx,%r12
  movq   $0x0,(%rdx)
  lea    0x3e9(%rdi),%rdi
  cmp    $0x3e8,%esi
  jg     L502
  movslq %esi,%rsi
  lea    0x1(%rbp,%rsi,1),%rdi
L502:
  cmp    %rbp,%rdi
  je     L150
  mov    %rbp,%rdx
  mov    $0x0,%r11d
  cmpb   $0x2d,0x0(%rbp)
  je     L670
L767:
  movzbl (%rdx),%ecx
  cmp    $0x30,%cl
  je     L274
  lea    -0x31(%rcx),%eax
  cmp    $0x8,%al
  ja     L673
  lea    0x1(%rdx),%rbx
  movsbl %cl,%ecx
  sub    $0x30,%ecx
L29:
  cmp    %rdi,%rbx
  je     L142
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  movslq %eax,%r10
  imul   $0x66666667,%r10,%r10
  sar    $0x22,%r10
  sar    $0x1f,%eax
  sub    %eax,%r10d
  mov    %rbx,%rsi
L669:
  movzbl (%rsi),%eax
  lea    -0x30(%rax),%edx
  cmp    $0x9,%dl
  ja     L243
  cmp    %ecx,%r10d
  jle    L231
  add    $0x1,%rsi
  lea    (%rcx,%rcx,4),%edx
  movsbl %al,%eax
  lea    -0x30(%rax,%rdx,2),%ecx
  cmp    %rsi,%rdi
  jne    L669
  mov    $0x0,%eax
  jmp    L334
L670:
  lea    0x1(%rbp),%rdx
  cmp    %rdx,%rdi
  je     L267
  mov    $0x1,%r11d
  jmp    L767
L274:
  lea    0x1(%rdx),%rbx
  mov    $0x0,%eax
  cmp    %rbx,%rdi
  je     L334
  movzbl 0x1(%rdx),%eax
  or     $0x20,%eax
  cmp    $0x78,%al
  je     L850
L561:
  cmpb   $0x30,(%rbx)
  jne    L55
  add    $0x1,%rbx
  cmp    %rbx,%rdi
  jne    L561
  mov    $0x0,%eax
  jmp    L334
L850:
  mov    %r12,%rcx
  mov    %r11d,%edx
  mov    %rdi,%rsi
  mov    %rbx,%rdi
  call   <grisu3_parse_hex_fp@plt>
  cmp    %rax,%rbx
  cmove  %rbp,%rax
  jmp    L334
L55:
  mov    $0x0,%ecx
  jmp    L29
L673:
  test   %r11d,%r11d
  mov    $0x0,%eax
  cmove  %rbp,%rax
  jmp    L334
L231:
  cmp    $0x34,%al
  setg   %al
  movzbl %al,%eax
  add    %eax,%ecx
  mov    $0x1,%edx
  jmp    L728
L243:
  mov    $0x0,%edx
L728:
  mov    %rsi,%r13
  sub    %rbx,%r13
  mov    %r13d,%r9d
  cmp    %rsi,%rdi
  je     L44
  mov    $0x0,%r8d
L62:
  cmpb   $0x30,(%rsi)
  jne    L678
  add    $0x1,%r8d
  add    $0x1,%rsi
  cmp    %rsi,%rdi
  jne    L62
  mov    $0x0,%eax
  jmp    L334
L44:
  mov    $0x0,%eax
  jmp    L334
L678:
  cmp    %rsi,%rdi
  je     L694
  movzbl (%rsi),%eax
  sub    $0x31,%eax
  cmp    $0x8,%al
  jbe    L810
L508:
  cmpb   $0x2e,(%rsi)
  je     L101
L618:
  add    %r9d,%r8d
L460:
  movzbl (%rsi),%r10d
  or     $0x20,%r10d
  mov    $0x0,%eax
  cmp    $0x65,%r10b
  jne    L389
  mov    %rdi,%rax
  sub    %rsi,%rax
  cmp    $0x1,%rax
  jle    L540
  movzbl 0x1(%rsi),%eax
  cmp    $0x2b,%al
  je     L273
  cmp    $0x2d,%al
  je     L330
  add    $0x1,%rsi
  mov    $0x0,%ebx
L399:
  movzbl (%rsi),%eax
  lea    -0x30(%rax),%r10d
  cmp    $0x9,%r10b
  ja     L161
  add    $0x1,%rsi
  movsbl %al,%eax
  sub    $0x30,%eax
  cmp    %rsi,%rdi
  jne    L853
L284:
  test   %ebx,%ebx
  jne    L14
  mov    $0x0,%eax
  jmp    L334
L810:
  add    $0x1,%r8d
  add    $0x1,%rsi
  mov    $0x0,%eax
  cmp    %rsi,%rdi
  je     L334
L701:
  movzbl (%rsi),%eax
  sub    $0x30,%eax
  cmp    $0x9,%al
  ja     L791
  add    $0x1,%r8d
  add    $0x1,%rsi
  cmp    %rsi,%rdi
  jne    L701
  mov    $0x0,%eax
  jmp    L334
L791:
  cmp    %rsi,%rdi
  je     L506
  mov    $0x1,%edx
  jmp    L508
L101:
  lea    0x1(%rsi),%rbx
  movzbl 0x1(%rsi),%eax
  sub    $0x30,%eax
  cmp    $0x9,%al
  ja     L394
  mov    %rbx,%rsi
  mov    $0x0,%eax
  cmp    %rbx,%rdi
  je     L334
L801:
  movzbl (%rsi),%eax
  lea    -0x30(%rax),%r9d
  cmp    $0x9,%r9b
  ja     L832
  cmp    %ecx,%r10d
  jle    L474
  add    $0x1,%rsi
  lea    (%rcx,%rcx,4),%ecx
  movsbl %al,%eax
  lea    -0x30(%rax,%rcx,2),%ecx
  sub    $0x1,%r8d
  cmp    %rsi,%rdi
  jne    L801
  mov    $0x0,%eax
  jmp    L334
L474:
  test   %edx,%edx
  jne    L832
  cmp    $0x34,%al
  setg   %al
  movzbl %al,%eax
  add    %eax,%ecx
  mov    $0x1,%edx
L832:
  mov    %rsi,%r9
  sub    %rbx,%r9
  add    %r13d,%r9d
  cmp    %rsi,%rdi
  je     L110
L247:
  cmpb   $0x30,(%rsi)
  jne    L441
  add    $0x1,%r8d
  add    $0x1,%rsi
  cmp    %rsi,%rdi
  jne    L247
  mov    $0x0,%eax
  jmp    L334
L110:
  mov    $0x0,%eax
  jmp    L334
L441:
  cmp    %rsi,%rdi
  je     L277
  movzbl (%rsi),%eax
  sub    $0x31,%eax
  cmp    $0x8,%al
  ja     L618
  add    $0x1,%rsi
  mov    $0x0,%eax
  cmp    %rsi,%rdi
  je     L334
L294:
  movzbl (%rsi),%eax
  sub    $0x30,%eax
  cmp    $0x9,%al
  ja     L591
  add    $0x1,%rsi
  cmp    %rsi,%rdi
  jne    L294
  mov    $0x0,%eax
  jmp    L334
L591:
  add    %r9d,%r8d
  cmp    %rsi,%rdi
  je     L580
  mov    $0x1,%edx
  jmp    L460
L273:
  add    $0x2,%rsi
  cmp    %rsi,%rdi
  je     L818
  mov    $0x0,%ebx
  jmp    L399
L330:
  add    $0x2,%rsi
  cmp    %rsi,%rdi
  je     L278
  mov    $0x1,%ebx
  jmp    L399
L601:
  add    $0x1,%rsi
  cmp    %rsi,%rdi
  je     L284
L853:
  movzbl (%rsi),%r10d
  lea    -0x30(%r10),%r13d
  cmp    $0x9,%r13b
  ja     L45
  cmp    $0x7fff,%eax
  jg     L601
  lea    (%rax,%rax,4),%eax
  movsbl %r10b,%r10d
  lea    -0x30(%r10,%rax,2),%eax
  jmp    L601
L45:
  test   %ebx,%ebx
  je     L389
L14:
  neg    %eax
L389:
  add    %eax,%r8d
  cmp    %rsi,%rdi
  je     L155
  push   %r12
  push   %rdx
  mov    %r11d,%edx
  mov    %rbp,%rdi
  call   <grisu3_encode_double@plt>
  add    $0x10,%rsp
L334:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L150:
  mov    %rbp,%rax
  jmp    L334
L267:
  mov    $0x0,%eax
  jmp    L334
L142:
  mov    $0x0,%eax
  jmp    L334
L694:
  mov    $0x0,%eax
  jmp    L334
L506:
  mov    $0x0,%eax
  jmp    L334
L394:
  mov    $0x0,%eax
  jmp    L334
L277:
  mov    $0x0,%eax
  jmp    L334
L580:
  mov    $0x0,%eax
  jmp    L334
L540:
  mov    $0x0,%eax
  jmp    L334
L818:
  mov    $0x0,%eax
  jmp    L334
L278:
  mov    $0x0,%eax
  jmp    L334
L161:
  mov    $0x0,%eax
  jmp    L334
L155:
  mov    $0x0,%eax
  jmp    L334
```

assistant: ```c
const char *grisu3_parse_double(const char *buf, int len, double *result) {
  const char *mark, *k, *end;
  int sign = 0, esign = 0;
  uint64_t fraction = 0;
  int exponent = 0;
  int ee = 0;
  int fraction_exp = 0;
  int ulp_half_error = 0;
  *result = 0.0;
  end = buf + len + 1;
  if (len > 1000) {
    end = buf + 1000 + 1;
  }
  if (buf == end) {
    return buf;
  }
  mark = buf;
  if (*buf == '-') {
    ++buf;
    sign = 1;
    if (buf == end) {
      return 0;
    }
  }
  if (*buf == '0') {
    ++buf;
    if (buf != end && (*buf | 0x20) == 'x') {
      k = grisu3_parse_hex_fp(buf, end, sign, result);
      if (k == buf) {
        return mark;
      }
      return k;
    }
    while (buf != end && *buf == '0') {
      ++buf;
    }
  } else {
    if (*buf < '1' || *buf > '9') {
      return sign ? 0 : mark;
    }
    fraction = *buf++ - '0';
  }
  k = buf;
  while (buf != end && *buf >= '0' && *buf <= '9') {
    if (fraction >= UINT64_MAX / 10) {
      fraction += *buf >= '5';
      ulp_half_error = 1;
      break;
    }
    fraction = fraction * 10 + *buf++ - '0';
  }
  fraction_exp = (int)(buf - k);
  while (buf != end && *buf == '0') {
    ++exponent;
    ++buf;
  }
  if (buf != end && *buf >= '1' && *buf <= '9') {
    ulp_half_error = 1;
    ++exponent;
    ++buf;
    while (buf != end && *buf >= '0' && *buf <= '9') {
      ++exponent;
      ++buf;
    }
  }
  if (buf != end && *buf == '.') {
    ++buf;
    k = buf;
    if (*buf < '0' || *buf > '9') {
      return 0;
    }
    while (buf != end && *buf >= '0' && *buf <= '9') {
      if (fraction >= UINT64_MAX / 10) {
        if (!ulp_half_error) {
          fraction += *buf >= '5';
          ulp_half_error = 1;
        }
        break;
      }
      fraction = fraction * 10 + *buf++ - '0';
      --exponent;
    }
    fraction_exp += (int)(buf - k);
    while (buf != end && *buf == '0') {
      ++exponent;
      ++buf;
    }
    if (buf != end && *buf >= '1' && *buf <= '9') {
      ulp_half_error = 1;
      ++buf;
      while (buf != end && *buf >= '0' && *buf <= '9') {
        ++buf;
      }
    }
  }
  exponent += fraction_exp;
  if (buf != end && (*buf | 0x20) == 'e') {
    if (end - buf < 2) {
      return 0;
    }
    ++buf;
    if (*buf == '+') {
      ++buf;
      if (buf == end) {
        return 0;
      }
    } else if (*buf == '-') {
      esign = 1;
      ++buf;
      if (buf == end) {
        return 0;
      }
    }
    if (*buf < '0' || *buf > '9') {
      return 0;
    }
    ee = *buf++ - '0';
    while (buf != end && *buf >= '0' && *buf <= '9') {
      if (ee <= 0x7fff) {
        ee = ee * 10 + *buf - '0';
      }
      ++buf;
    }
  }
  exponent = exponent + (esign ? -ee : ee);
  if (buf == end) {
    return 0;
  }
  return grisu3_encode_double(mark, buf, sign, fraction, exponent, fraction_exp, ulp_half_error, result);
}
```