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

```asm
<my_double2str>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  movsd  %xmm0,-0x58(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0xffffffff,-0x28(%rbp)
  movb   $0x0,-0x32(%rbp)
  movb   $0x0,-0x30(%rbp)
  movb   $0x0,-0x2f(%rbp)
  cmpq   $0x7,-0x50(%rbp)
  ja     L80
  mov    $0xffffffff,%eax
  jmp    L3
L80:
  cmpl   $0x0,-0x28(%rbp)
  jns    L318
  movl   $0x14,-0x28(%rbp)
L318:
  mov    -0x28(%rbp),%eax
  cltq
  mov    -0x50(%rbp),%rdx
  shr    %rdx
  sub    $0xa,%rdx
  cmp    %rdx,%rax
  jbe    L440
  mov    -0x50(%rbp),%rax
  shr    %rax
  sub    $0xa,%eax
  mov    %eax,-0x28(%rbp)
L440:
  movsd  -0x58(%rbp),%xmm1
  pxor   %xmm0,%xmm0
  comisd %xmm1,%xmm0
  jbe    L566
  movsd  -0x58(%rbp),%xmm0
  movq   D1(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  movb   $0x2d,-0x33(%rbp)
  jmp    L1
L566:
  movb   $0x0,-0x33(%rbp)
L1:
  cmpb   $0x0,-0x32(%rbp)
  jne    L529
  cmpl   $0x0,-0x28(%rbp)
  jle    L529
  subl   $0x1,-0x28(%rbp)
L529:
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  movsd  D49(%rip),%xmm0
  movsd  %xmm0,-0x10(%rbp)
  jmp    L51
L110:
  subl   $0x1,-0x24(%rbp)
  movsd  -0x10(%rbp),%xmm1
  movsd  D155(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
L51:
  cmpl   $0x0,-0x24(%rbp)
  jg     L110
  cmpb   $0x1,-0x32(%rbp)
  jne    L510
  movsd  -0x58(%rbp),%xmm0
  addsd  -0x10(%rbp),%xmm0
  movsd  %xmm0,-0x58(%rbp)
L510:
  movl   $0x0,-0x20(%rbp)
  mov    -0x58(%rbp),%rax
  movq   %rax,%xmm0
  call   <isnan@plt>
  test   %rax,%rax
  je     L389
  mov    -0x48(%rbp),%rax
  lea    D159(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    $0x0,%eax
  jmp    L3
L389:
  movsd  -0x58(%rbp),%xmm0
  pxor   %xmm1,%xmm1
  comisd %xmm1,%xmm0
  jbe    L146
  jmp    L251
L286:
  movsd  -0x58(%rbp),%xmm1
  movsd  D58(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  addl   $0x20,-0x20(%rbp)
L251:
  movsd  -0x58(%rbp),%xmm0
  comisd D144(%rip),%xmm0
  jb     L350
  cmpl   $0x15e,-0x20(%rbp)
  jle    L286
L350:
  jmp    L293
L450:
  movsd  -0x58(%rbp),%xmm1
  movsd  D163(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  addl   $0x8,-0x20(%rbp)
L293:
  movsd  -0x58(%rbp),%xmm0
  comisd D115(%rip),%xmm0
  jb     L347
  cmpl   $0x15e,-0x20(%rbp)
  jle    L450
L347:
  jmp    L403
L230:
  movsd  -0x58(%rbp),%xmm1
  movsd  D155(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  addl   $0x1,-0x20(%rbp)
L403:
  movsd  -0x58(%rbp),%xmm0
  comisd D86(%rip),%xmm0
  jb     L181
  cmpl   $0x15e,-0x20(%rbp)
  jle    L230
L181:
  jmp    L573
L464:
  movsd  -0x58(%rbp),%xmm1
  movsd  D115(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  subl   $0x8,-0x20(%rbp)
L573:
  movsd  -0x58(%rbp),%xmm1
  movsd  D163(%rip),%xmm0
  comisd %xmm1,%xmm0
  ja     L464
  jmp    L569
L189:
  movsd  -0x58(%rbp),%xmm1
  movsd  D86(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  subl   $0x1,-0x20(%rbp)
L569:
  movsd  -0x58(%rbp),%xmm1
  movsd  D125(%rip),%xmm0
  comisd %xmm1,%xmm0
  ja     L189
  cmpl   $0x15e,-0x20(%rbp)
  jle    L146
  cmpb   $0x2d,-0x33(%rbp)
  jne    L223
  mov    -0x48(%rbp),%rax
  lea    D11(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  jmp    L187
L223:
  mov    -0x48(%rbp),%rax
  lea    D37(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
L187:
  mov    $0x0,%eax
  jmp    L3
L146:
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  cmpb   $0x2,-0x32(%rbp)
  sete   %al
  mov    %al,-0x2e(%rbp)
  cmpb   $0x1,-0x32(%rbp)
  je     L397
  movsd  -0x58(%rbp),%xmm0
  addsd  -0x10(%rbp),%xmm0
  movsd  %xmm0,-0x58(%rbp)
  movsd  -0x58(%rbp),%xmm0
  comisd D86(%rip),%xmm0
  jb     L397
  movsd  -0x58(%rbp),%xmm1
  movsd  D155(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  addl   $0x1,-0x20(%rbp)
L397:
  cmpb   $0x0,-0x32(%rbp)
  jne    L370
  cmpb   $0x0,-0x30(%rbp)
  sete   %al
  mov    %al,-0x31(%rbp)
  cmpl   $0xfffffffc,-0x20(%rbp)
  jl     L91
  mov    -0x20(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jle    L530
L91:
  movb   $0x2,-0x32(%rbp)
  jmp    L147
L530:
  mov    -0x20(%rbp),%eax
  sub    %eax,-0x28(%rbp)
  movb   $0x1,-0x32(%rbp)
  jmp    L147
L370:
  movb   $0x0,-0x31(%rbp)
L147:
  cmpb   $0x2,-0x32(%rbp)
  jne    L227
  movl   $0x0,-0x1c(%rbp)
  jmp    L49
L227:
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
L49:
  movl   $0x0,-0x2c(%rbp)
  cmpl   $0x0,-0x28(%rbp)
  setg   %al
  or     -0x30(%rbp),%al
  or     -0x2f(%rbp),%al
  mov    %al,-0x2d(%rbp)
  cmpb   $0x0,-0x33(%rbp)
  je     L17
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl -0x33(%rbp),%edx
  mov    %dl,(%rax)
L17:
  cmpl   $0x0,-0x1c(%rbp)
  jns    L462
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x30,(%rax)
  jmp    L264
L345:
  lea    -0x2c(%rbp),%rdx
  lea    -0x58(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <getdigit@plt>
  mov    %rax,%rcx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x1c(%rbp)
L462:
  cmpl   $0x0,-0x1c(%rbp)
  jns    L345
L264:
  cmpb   $0x0,-0x2d(%rbp)
  je     L290
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x2e,(%rax)
L290:
  addl   $0x1,-0x1c(%rbp)
  jmp    L101
L258:
  cmpl   $0x0,-0x28(%rbp)
  setg   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x30,(%rax)
  subl   $0x1,-0x28(%rbp)
  addl   $0x1,-0x1c(%rbp)
L101:
  cmpl   $0x0,-0x1c(%rbp)
  js     L258
  jmp    L311
L600:
  lea    -0x2c(%rbp),%rdx
  lea    -0x58(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <getdigit@plt>
  mov    %rax,%rcx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
L311:
  mov    -0x28(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x28(%rbp)
  test   %eax,%eax
  jg     L600
  cmpb   $0x0,-0x31(%rbp)
  je     L155
  cmpb   $0x0,-0x2d(%rbp)
  je     L155
  jmp    L260
L447:
  subq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
L260:
  mov    -0x18(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  je     L447
  mov    -0x18(%rbp),%rax
  cmp    -0x48(%rbp),%rax
  seta   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x18(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L155
  cmpb   $0x0,-0x2f(%rbp)
  je     L340
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x30,(%rax)
  jmp    L155
L340:
  subq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
L155:
  cmpb   $0x0,-0x2e(%rbp)
  jne    L92
  cmpb   $0x2,-0x32(%rbp)
  jne    L315
L92:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x65,(%rax)
  cmpl   $0x0,-0x20(%rbp)
  jns    L33
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x2d,(%rax)
  negl   -0x20(%rbp)
  jmp    L358
L33:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x2b,(%rax)
L358:
  cmpl   $0x63,-0x20(%rbp)
  jle    L509
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x51eb851f,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x5,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  lea    0x30(%rax),%ecx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x51eb851f,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x5,%edx
  mov    %eax,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%edx
  imul   $0x64,%edx,%edx
  sub    %edx,%eax
  mov    %eax,-0x20(%rbp)
L509:
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  lea    0x30(%rax),%ecx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x20(%rbp),%edx
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  shr    $0x20,%rax
  sar    $0x2,%eax
  mov    %edx,%esi
  sar    $0x1f,%esi
  sub    %esi,%eax
  mov    %eax,%ecx
  mov    %ecx,%eax
  shl    $0x2,%eax
  add    %ecx,%eax
  add    %eax,%eax
  mov    %edx,%ecx
  sub    %eax,%ecx
  mov    %ecx,%eax
  lea    0x30(%rax),%ecx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
L315:
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    $0x0,%eax
L3:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L422
  call   <__stack_chk_fail@plt>
L422:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D1
datatype: f32[2]
name: unpack_data
arguments: data_tag: D49
datatype: f64
name: unpack_data
arguments: data_tag: D155
datatype: f64
name: unpack_data
arguments: data_tag: D159
datatype: string
name: unpack_data
arguments: data_tag: D58
datatype: byte[8]
name: unpack_data
arguments: data_tag: D144
datatype: f64[2]
name: unpack_data
arguments: data_tag: D163
datatype: byte[8]
name: unpack_data
arguments: data_tag: D115
datatype: f64[2]
name: unpack_data
arguments: data_tag: D86
datatype: f64[2]
name: unpack_data
arguments: data_tag: D125
datatype: f64
name: unpack_data
arguments: data_tag: D11
datatype: string
name: unpack_data
arguments: data_tag: D37
datatype: string

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

tool: D49: 0.5

tool: D155: 0.1

tool: D159: NaN

tool: {"D58": [0x33,0xa7,0xa8,0xd5,0x23,0xf6,0x49,0x39]}

tool: {"D144": [1e32,1e-8]}

tool: {"D163": [0x3a,0x8c,0x30,0xe2,0x8e,0x79,0x45,0x3e]}

tool: {"D115": [100000000.0,10.0]}

tool: {"D86": [10.0,1.0]}

tool: D125: 1

tool: D11: -Inf

tool: D37: Inf

assistant: ```c
int my_double2str(char *buf, size_t bufsize, double realvalue) {
  int precision = -1;
  char *bufpt;
  char prefix;
  char xtype = 0;
  int idx, exp, e2;
  double rounder;
  char flag_exp;
  char flag_rtz;
  char flag_dp;
  char flag_alternateform = 0;
  char flag_altform2 = 0;
  int nsd;
  if (bufsize < 8)
    return -1;
  if (precision < 0)
    precision = 20;
  if (precision > bufsize / 2 - 10)
    precision = bufsize / 2 - 10;
  if (realvalue < 0.0) {
    realvalue = -realvalue;
    prefix = '-';
  } else {
    prefix = 0;
  }
  if (xtype == 0 && precision > 0)
    precision--;
  for (idx = precision, rounder = 0.5; idx > 0; idx--, rounder *= 0.1) {
  }
  if (xtype == 1)
    realvalue += rounder;
  exp = 0;
  if (isnan(realvalue)) {
    strcpy(buf, "NaN");
    return 0;
  }
  if (realvalue > 0.0) {
    while (realvalue >= 1e32 && exp <= 350) {
      realvalue *= 1e-32;
      exp += 32;
    }
    while (realvalue >= 1e8 && exp <= 350) {
      realvalue *= 1e-8;
      exp += 8;
    }
    while (realvalue >= 10.0 && exp <= 350) {
      realvalue *= 0.1;
      exp++;
    }
    while (realvalue < 1e-8) {
      realvalue *= 1e8;
      exp -= 8;
    }
    while (realvalue < 1.0) {
      realvalue *= 10.0;
      exp--;
    }
    if (exp > 350) {
      if (prefix == '-') {
        strcpy(buf, "-Inf");
      } else {
        strcpy(buf, "Inf");
      }
      return 0;
    }
  }
  bufpt = buf;
  flag_exp = xtype == 2;
  if (xtype != 1) {
    realvalue += rounder;
    if (realvalue >= 10.0) {
      realvalue *= 0.1;
      exp++;
    }
  }
  if (xtype == 0) {
    flag_rtz = !flag_alternateform;
    if (exp < -4 || exp > precision) {
      xtype = 2;
    } else {
      precision = precision - exp;
      xtype = 1;
    }
  } else {
    flag_rtz = 0;
  }
  if (xtype == 2) {
    e2 = 0;
  } else {
    e2 = exp;
  }
  nsd = 0;
  flag_dp = (precision > 0 ? 1 : 0) | flag_alternateform | flag_altform2;
  if (prefix) {
    *(bufpt++) = prefix;
  }
  if (e2 < 0) {
    *(bufpt++) = '0';
  } else {
    for (; e2 >= 0; e2--) {
      *(bufpt++) = getdigit(&realvalue, &nsd);
    }
  }
  if (flag_dp) {
    *(bufpt++) = '.';
  }
  for (e2++; e2 < 0; precision--, e2++) {
    assert(precision > 0);
    *(bufpt++) = '0';
  }
  while ((precision--) > 0) {
    *(bufpt++) = getdigit(&realvalue, &nsd);
  }
  if (flag_rtz && flag_dp) {
    while (bufpt[-1] == '0')
      *(--bufpt) = 0;
    assert(bufpt > buf);
    if (bufpt[-1] == '.') {
      if (flag_altform2) {
        *(bufpt++) = '0';
      } else {
        *(--bufpt) = 0;
      }
    }
  }
  if (flag_exp || xtype == 2) {
    *(bufpt++) = 'e';
    if (exp < 0) {
      *(bufpt++) = '-';
      exp = -exp;
    } else {
      *(bufpt++) = '+';
    }
    if (exp >= 100) {
      *(bufpt++) = (char)((exp / 100) + '0');
      exp %= 100;
    }
    *(bufpt++) = (char)(exp / 10 + '0');
    *(bufpt++) = (char)(exp % 10 + '0');
  }
  *bufpt = 0;
  return 0;
}
```