user: Converte this assembly snippet into its equivalent C code:

```asm
<por_write_double_to_buffer>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movsd  %xmm0,0x8(%rsp)
  call   <isnan@plt>
  movsd  0x8(%rsp),%xmm1
  test   %rax,%rax
  je     L93
  mov    $0x2e2a,%eax
  mov    $0x2,%edx
  mov    %ax,(%rbx)
  mov    $0x2,%eax
L230:
  movb   $0x0,(%rbx,%rdx,1)
L188:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L204
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L93:
  movapd %xmm1,%xmm0
  movsd  %xmm1,0x8(%rsp)
  call   <isinf@plt>
  movsd  0x8(%rsp),%xmm1
  test   %rax,%rax
  mov    %rax,%r12
  je     L149
  pxor   %xmm0,%xmm0
  comisd %xmm1,%xmm0
  ja     L25
  mov    %rbx,%r9
  mov    $0x5,%edx
  mov    $0x5,%eax
  mov    $0x4,%ecx
  mov    $0x3,%esi
  mov    $0x2,%edi
  mov    $0x1,%r8d
L61:
  movb   $0x31,(%r9)
  movb   $0x2b,(%rbx,%r8,1)
  movb   $0x54,(%rbx,%rdi,1)
  movb   $0x54,(%rbx,%rsi,1)
  movb   $0x2f,(%rbx,%rcx,1)
  jmp    L230
  nopl   0x0(%rax,%rax,1)
L25:
  movb   $0x2d,(%rbx)
  lea    0x1(%rbx),%r9
  mov    $0x6,%edx
  mov    $0x6,%eax
  mov    $0x5,%ecx
  mov    $0x4,%esi
  mov    $0x3,%edi
  mov    $0x2,%r8d
  jmp    L61
L149:
  movapd %xmm1,%xmm0
  lea    0x20(%rsp),%r14
  movsd  %xmm1,0x8(%rsp)
  andpd  D0(%rip),%xmm0
  mov    %r14,%rdi
  call   <modf@plt>
  movsd  0x8(%rsp),%xmm1
  pxor   %xmm3,%xmm3
  cvttsd2si 0x20(%rsp),%r8d
  comisd %xmm1,%xmm3
  ja     L168
  mov    %rbx,%rdi
  xor    %ecx,%ecx
  xor    %r15d,%r15d
L15:
  test   %r8d,%r8d
  je     L128
  pxor   %xmm4,%xmm4
  ucomisd %xmm4,%xmm0
  jp     L275
  jne    L275
  movslq %r8d,%rax
  mov    %r8d,%esi
  imul   $0xffffffff88888889,%rax,%rdx
  sar    $0x1f,%esi
  shr    $0x20,%rdx
  add    %r8d,%edx
  sar    $0x4,%edx
  sub    %esi,%edx
  mov    %r8d,%esi
  imul   $0x1e,%edx,%edx
  sub    %edx,%esi
  mov    %esi,0x1c(%rsp)
  je     L21
L275:
  movl   $0x0,0x1c(%rsp)
  nopl   (%rax)
L271:
  mov    %r13,%rsi
  mov    %r8d,%edx
  movsd  %xmm0,0x8(%rsp)
  sub    %rcx,%rsi
  call   <por_write_base30_integer@plt>
  movsd  0x8(%rsp),%xmm0
  pxor   %xmm6,%xmm6
  lea    (%rax,%r15,1),%edx
  movslq %eax,%r12
  ucomisd %xmm6,%xmm0
  movslq %edx,%rcx
  lea    0x1(%rdx),%edi
  mov    %edx,%eax
  mov    %edi,0x18(%rsp)
  lea    (%rbx,%rcx,1),%rsi
  jp     L71
  jne    L71
  mov    %edx,0x18(%rsp)
L231:
  mov    0x1c(%rsp),%edx
  test   %edx,%edx
  je     L234
  movslq 0x18(%rsp),%r15
  mov    %r13,%rsi
  lea    0x1(%r15),%ebp
  movb   $0x2b,(%rbx,%r15,1)
  movslq %ebp,%rdi
  sub    %rdi,%rsi
  add    %rbx,%rdi
  call   <por_write_base30_integer@plt>
  add    %ebp,%eax
  movslq %eax,%rdx
L85:
  add    $0x1,%eax
  movb   $0x2f,(%rbx,%rdx,1)
  movslq %eax,%rdx
  jmp    L230
  nopl   0x0(%rax,%rax,1)
L259:
  imul   $0xeeeeeeef,%eax,%eax
  add    $0x8888888,%eax
  ror    %eax
  cmp    $0x8888888,%eax
  ja     L271
  movslq %r8d,%rax
L21:
  imul   $0xffffffff88888889,%rax,%rax
  mov    %r8d,%edx
  addl   $0x1,0x1c(%rsp)
  sar    $0x1f,%edx
  shr    $0x20,%rax
  add    %r8d,%eax
  sar    $0x4,%eax
  sub    %edx,%eax
  mov    %eax,%r8d
  jne    L259
  jmp    L271
  nopl   0x0(%rax,%rax,1)
L71:
  movb   $0x2e,(%rsi)
  cmp    %rbp,%r12
  jge    L231
L187:
  mov    %r12,%r15
  lea    0x2(%rax),%r12d
  sub    %r15,%rcx
  sub    %r15d,%r12d
  lea    (%rbx,%rcx,1),%rax
  mov    %rax,0x10(%rsp)
  jmp    L148
  nopl   0x0(%rax)
L252:
  lea    (%r12,%r15,1),%eax
  movsd  %xmm0,0x8(%rsp)
  add    $0x1,%r15
  mov    %eax,0x18(%rsp)
  call   <por_encode_base30_digit@plt>
  mov    0x10(%rsp),%rcx
  movsd  0x8(%rsp),%xmm0
  pxor   %xmm2,%xmm2
  mov    %al,(%r15,%rcx,1)
  ucomisd %xmm2,%xmm0
  mov    $0x1,%ecx
  setp   %al
  cmovne %ecx,%eax
  test   %al,%al
  je     L231
  cmp    %r15,%rbp
  jle    L231
L148:
  mulsd  D18(%rip),%xmm0
  mov    %r14,%rdi
  call   <modf@plt>
  cvttsd2si 0x20(%rsp),%edi
  test   %edi,%edi
  jns    L252
  mov    $0xffffffff,%eax
  jmp    L188
  xchg   %ax,%ax
L128:
  pxor   %xmm5,%xmm5
  lea    0x1(%r15),%eax
  add    $0x2,%r15d
  movb   $0x30,(%rdi)
  ucomisd %xmm5,%xmm0
  movslq %eax,%rdx
  mov    %rdx,%rcx
  lea    (%rbx,%rdx,1),%rsi
  jp     L225
  je     L85
L225:
  movb   $0x2e,(%rsi)
  test   %rbp,%rbp
  jle    L6
  movl   $0x0,0x1c(%rsp)
  jmp    L187
  nopw   0x0(%rax,%rax,1)
L168:
  movb   $0x2d,(%rbx)
  lea    0x1(%rbx),%rdi
  mov    $0x1,%ecx
  mov    $0x1,%r15d
  jmp    L15
  nopw   0x0(%rax,%rax,1)
L234:
  movslq 0x18(%rsp),%rdx
  mov    %rdx,%rax
  jmp    L85
L204:
  call   <__stack_chk_fail@plt>
L6:
  movslq %r15d,%rdx
  mov    %rdx,%rax
  jmp    L85
```

tool_calls: name: retrieve_data
arguments: tag: D0
data_type: qword[2]
name: retrieve_data
arguments: tag: D18
data_type: f32[2]

tool: {"D0": [0x7fffffffffffffff,0x0000000000000000]}

tool: {"D18": [0.0,2.96875]}

assistant: ```c
ssize_t por_write_double_to_buffer(char *string, size_t buffer_len, double value, long precision) {
  int offset = 0;
  if (isnan(value)) {
    string[offset++] = '*';
    string[offset++] = '.';
  } else if (isinf(value)) {
    if (value < 0.0) {
      string[offset++] = '-';
    }
    string[offset++] = '1';
    string[offset++] = '+';
    string[offset++] = 'T';
    string[offset++] = 'T';
    string[offset++] = '/';
  } else {
    long integers_printed = 0;
    double integer_part;
    double fraction = modf(fabs(value), &integer_part);
    int64_t integer = integer_part;
    int64_t exponent = 0;
    if (value < 0.0) {
      string[offset++] = '-';
    }
    if (integer == 0) {
      string[offset++] = '0';
    } else {
      while (fraction == 0 && integer != 0 && (integer % 30) == 0) {
        integer /= 30;
        exponent++;
      }
      integers_printed = por_write_base30_integer(&string[offset], buffer_len - offset, integer);
      offset += integers_printed;
    }
    if (fraction) {
      string[offset++] = '.';
    }
    while (fraction && integers_printed < precision) {
      fraction = modf(fraction * 30, &integer_part);
      integer = integer_part;
      if (integer < 0) {
        return -1;
      } else {
        string[offset++] = por_encode_base30_digit(integer);
      }
      integers_printed++;
    }
    if (exponent) {
      string[offset++] = '+';
      offset += por_write_base30_integer(&string[offset], buffer_len - offset, exponent);
    }
    string[offset++] = '/';
  }
  string[offset] = '\0';
  return offset;
}
```