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

```asm
<double_to_hex>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  movsd  %xmm0,-0x38(%rbp)
  mov    %rdi,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  pxor   %xmm0,%xmm0
  comisd -0x38(%rbp),%xmm0
  jbe    L69
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  movb   $0x2d,(%rax)
  movsd  -0x38(%rbp),%xmm0
  movq   D13(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movsd  %xmm0,-0x38(%rbp)
L69:
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  movb   $0x2e,(%rax)
  lea    -0x30(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rdi
  movq   %rax,%xmm0
  call   <frexp@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x28(%rbp)
  pxor   %xmm0,%xmm0
  ucomisd -0x28(%rbp),%xmm0
  jp     L110
  pxor   %xmm0,%xmm0
  ucomisd -0x28(%rbp),%xmm0
  jne    L60
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  movb   $0x30,(%rax)
  jmp    L48
L60:
  jmp    L110
L121:
  movsd  -0x28(%rbp),%xmm1
  movsd  D39(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movsd  -0x28(%rbp),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  mov    -0x2c(%rbp),%edx
  movslq %edx,%rdx
  lea    D16(%rip),%rcx
  movzbl (%rdx,%rcx,1),%edx
  mov    %dl,(%rax)
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x2c(%rbp),%xmm1
  movsd  -0x28(%rbp),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x28(%rbp)
L110:
  movsd  -0x28(%rbp),%xmm0
  pxor   %xmm1,%xmm1
  comisd %xmm1,%xmm0
  ja     L121
  mov    -0x30(%rbp),%eax
  test   %eax,%eax
  je     L48
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  movb   $0x78,(%rax)
  mov    -0x30(%rbp),%eax
  test   %eax,%eax
  jns    L81
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  movb   $0x2d,(%rax)
  mov    -0x30(%rbp),%eax
  neg    %eax
  mov    %eax,-0x30(%rbp)
L81:
  lea    -0x14(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  jmp    L111
L30:
  mov    -0x30(%rbp),%eax
  and    $0xf,%eax
  mov    %eax,%ecx
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movslq %ecx,%rdx
  lea    D16(%rip),%rcx
  movzbl (%rdx,%rcx,1),%edx
  mov    %dl,(%rax)
  mov    -0x30(%rbp),%eax
  sar    $0x4,%eax
  mov    %eax,-0x30(%rbp)
L111:
  mov    -0x30(%rbp),%eax
  test   %eax,%eax
  jg     L30
  jmp    L79
L98:
  subq   $0x1,-0x20(%rbp)
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  mov    -0x20(%rbp),%rdx
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
L79:
  lea    -0x14(%rbp),%rax
  cmp    %rax,-0x20(%rbp)
  ja     L98
L48:
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  movb   $0x0,(%rax)
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L77
  call   <__stack_chk_fail@plt>
L77:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D13
datatype: f32[2]
name: retrieve_data
arguments: data_label: D39
datatype: f64

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

tool: D39: 16

assistant: ```c
void double_to_hex(double value, char *s) {
  double mant;
  int expon;
  int digit;
  char *p;
  char buf[12];
  static char hex[] = "0123456789ABCDEF";
  if (value < 0) {
    *s++ = '-';
    value = -value;
  }
  *s++ = '.';
  mant = frexp(value, &expon);
  if (mant == 0.0) {
    *s++ = '0';
  } else {
    while (mant > 0.0) {
      mant *= 16.0;
      digit = (int)mant;
      *s++ = hex[digit];
      mant -= ((double)digit);
    }
    if (expon != 0) {
      *s++ = 'x';
      if (expon < 0) {
        *s++ = '-';
        expon = -expon;
      }
      p = &buf[0];
      while (expon > 0) {
        *p++ = hex[expon & 0x0F];
        expon >>= 4;
      }
      while (p > &buf[0]) {
        *s++ = *--p;
      }
    }
  }
  *s++ = '\0';
}
```