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

```asm
<double_to_ieee_80>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  movapd %xmm0,%xmm2
  movsd  %xmm0,0x8(%rsp)
  mov    %rdi,%rbx
  pxor   %xmm0,%xmm0
  mov    $0x0,%ebp
  comisd %xmm2,%xmm0
  ja     L43
L7:
  movsd  0x8(%rsp),%xmm3
  ucomisd D40(%rip),%xmm3
  jp     L16
  jne    L16
  mov    $0x0,%eax
  mov    $0x0,%r12d
  mov    $0x0,%r13d
L42:
  shl    $0x7,%ebp
  mov    %r13d,%edx
  sar    $0x8,%dx
  or     %edx,%ebp
  mov    %bpl,(%rbx)
  mov    %r13b,0x1(%rbx)
  mov    %r12d,%edx
  shr    $0x18,%edx
  mov    %dl,0x2(%rbx)
  mov    %r12d,%edx
  shr    $0x10,%edx
  mov    %dl,0x3(%rbx)
  mov    %r12d,%ecx
  movzbl %ch,%ecx
  mov    %cl,0x4(%rbx)
  mov    %r12b,0x5(%rbx)
  mov    %eax,%edx
  shr    $0x18,%edx
  mov    %dl,0x6(%rbx)
  mov    %eax,%edx
  shr    $0x10,%edx
  mov    %dl,0x7(%rbx)
  movzbl %ah,%ecx
  mov    %cl,0x8(%rbx)
  mov    %al,0x9(%rbx)
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L43:
  xorpd  D21(%rip),%xmm2
  movsd  %xmm2,0x8(%rsp)
  mov    $0x1,%ebp
  jmp    L7
L16:
  movsd  0x8(%rsp),%xmm0
  call   <log@plt>
  divsd  D69(%rip),%xmm0
  addsd  D36(%rip),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,%r13d
  cwtl
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  D44(%rip),%xmm1
  subsd  %xmm0,%xmm1
  movsd  D56(%rip),%xmm0
  call   <pow@plt>
  movapd %xmm0,%xmm4
  mulsd  0x8(%rsp),%xmm4
  movq   %xmm4,%r14
  movapd %xmm4,%xmm0
  call   <myDoubleToUlong@plt>
  mov    %eax,%r12d
  mov    %eax,%edi
  call   <myUlongToDouble@plt>
  pxor   %xmm1,%xmm1
  cvtsi2sd %rax,%xmm1
  movq   %r14,%xmm0
  subsd  %xmm1,%xmm0
  mulsd  D8(%rip),%xmm0
  call   <myDoubleToUlong@plt>
  jmp    L42
```

tool_calls: name: read_data
arguments: data_tag: D40
type: f64
name: read_data
arguments: data_tag: D21
type: byte[16]
name: read_data
arguments: data_tag: D69
type: byte[8]
name: read_data
arguments: data_tag: D36
type: f64
name: read_data
arguments: data_tag: D44
type: byte[8]
name: read_data
arguments: data_tag: D56
type: f64
name: read_data
arguments: data_tag: D8
type: byte[8]

tool: D40: 0

tool: {"D21": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: {"D69": [0xef,0x39,0xfa,0xfe,0x42,0x2e,0xe6,0x3f]}

tool: D36: 16383

tool: {"D44": [0x00,0x00,0x00,0x00,0x80,0x07,0xd0,0x40]}

tool: D56: 2

tool: {"D8": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x41]}

assistant: ```c
void double_to_ieee_80(double val, unsigned char *p) {
  unsigned char sign = 0;
  short exp = 0;
  unsigned int mant1 = 0;
  unsigned int mant0 = 0;
  if (val < 0.0) {
    sign = 1;
    val = -val;
  }
  if (val != 0.0) {
    exp = (short)(log(val) / log(2.0) + 16383.0);
    val *= pow(2.0, 31.0 + 16383.0 - (double)exp);
    mant1 = myDoubleToUlong(val);
    val -= myUlongToDouble(mant1);
    val *= pow(2.0, 32.0);
    mant0 = myDoubleToUlong(val);
  }
  *p++ = ((sign << 7) | (exp >> 8));
  *p++ = 0xFF & exp;
  *p++ = 0xFF & (mant1 >> 24);
  *p++ = 0xFF & (mant1 >> 16);
  *p++ = 0xFF & (mant1 >> 8);
  *p++ = 0xFF & (mant1);
  *p++ = 0xFF & (mant0 >> 24);
  *p++ = 0xFF & (mant0 >> 16);
  *p++ = 0xFF & (mant0 >> 8);
  *p++ = 0xFF & (mant0);
}
```