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

```asm
<si_sprintf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xf0,%rsp
  mov    %rdi,-0xd8(%rbp)
  movsd  %xmm0,-0xe0(%rbp)
  mov    %esi,-0xe4(%rbp)
  mov    %edx,-0xe8(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movb   $0x23,-0xc5(%rbp)
  movq   $0x0,-0xb0(%rbp)
  mov    -0xe8(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  sete   %al
  movzbl %al,%eax
  mov    %eax,-0xc0(%rbp)
  mov    -0xe8(%rbp),%eax
  and    $0x2,%eax
  mov    %eax,-0xbc(%rbp)
  cmpl   $0x0,-0xbc(%rbp)
  je     L74
  movsd  D186(%rip),%xmm0
  jmp    L577
L74:
  movsd  D22(%rip),%xmm0
L577:
  movsd  %xmm0,-0xa0(%rbp)
  cmpl   $0x1,-0xe4(%rbp)
  setg   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  cmpl   $0x18,-0xe4(%rbp)
  setle  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  pxor   %xmm0,%xmm0
  comisd -0xe0(%rbp),%xmm0
  jbe    L305
  mov    -0xd8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0xd8(%rbp)
  movb   $0x2d,(%rax)
  subl   $0x1,-0xe4(%rbp)
  movsd  -0xe0(%rbp),%xmm0
  movq   D282(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movsd  %xmm0,-0xe0(%rbp)
  jmp    L488
L305:
  mov    -0xe8(%rbp),%eax
  and    $0x4,%eax
  test   %eax,%eax
  je     L488
  mov    -0xd8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0xd8(%rbp)
  movb   $0x2b,(%rax)
  subl   $0x1,-0xe4(%rbp)
L488:
  mov    -0xe4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0xd8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  pxor   %xmm0,%xmm0
  ucomisd -0xe0(%rbp),%xmm0
  jp     L141
  pxor   %xmm0,%xmm0
  ucomisd -0xe0(%rbp),%xmm0
  jne    L141
  mov    -0xe4(%rbp),%edx
  mov    -0xd8(%rbp),%rax
  mov    D78(%rip),%rcx
  movq   %rcx,%xmm0
  lea    D246(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  jmp    L474
L141:
  mov    -0xe0(%rbp),%rax
  movq   %rax,%xmm0
  call   <isnan@plt>
  test   %rax,%rax
  je     L382
  lea    D162(%rip),%rax
  mov    %rax,-0xb0(%rbp)
  jmp    L474
L382:
  mov    -0xe0(%rbp),%rax
  movq   %rax,%xmm0
  call   <isfinite@plt>
  test   %eax,%eax
  jne    L419
  lea    D188(%rip),%rax
  mov    %rax,-0xb0(%rbp)
  jmp    L474
L419:
  movsd  -0xa0(%rbp),%xmm1
  movsd  D25(%rip),%xmm0
  mulsd  %xmm0,%xmm1
  movsd  -0xe0(%rbp),%xmm0
  comisd %xmm1,%xmm0
  ja     L146
  movsd  -0xa0(%rbp),%xmm1
  movsd  D54(%rip),%xmm0
  mulsd  %xmm0,%xmm1
  movsd  -0xe0(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jbe    L420
  cmpl   $0x3,-0xe4(%rbp)
  je     L146
L420:
  movsd  -0xa0(%rbp),%xmm1
  movsd  D207(%rip),%xmm0
  mulsd  %xmm0,%xmm1
  movsd  -0xe0(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jbe    L283
  cmpl   $0x2,-0xe4(%rbp)
  je     L146
L283:
  movsd  D20(%rip),%xmm0
  divsd  -0xa0(%rbp),%xmm0
  comisd -0xe0(%rbp),%xmm0
  jbe    L198
  cmpl   $0x0,-0xc0(%rbp)
  je     L198
L146:
  mov    -0xe0(%rbp),%rcx
  mov    -0xe4(%rbp),%edx
  lea    -0x70(%rbp),%rax
  movq   %rcx,%xmm0
  lea    D289(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x70(%rbp),%rax
  mov    $0x65,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x78(%rbp)
  cmpq   $0x0,-0x78(%rbp)
  je     L348
  jmp    L399
L413:
  mov    -0x78(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x78(%rbp),%rax
  lea    0x3(%rax),%rcx
  mov    -0x78(%rbp),%rax
  add    $0x2,%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
L399:
  mov    -0x78(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  je     L413
  mov    -0x78(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0xb8(%rbp)
  mov    -0xb8(%rbp),%eax
  cmp    -0xe4(%rbp),%eax
  jg     L348
  mov    -0xe4(%rbp),%eax
  sub    -0xb8(%rbp),%eax
  mov    %eax,%edx
  lea    -0x70(%rbp),%rcx
  mov    -0xd8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0xe4(%rbp),%eax
  cltq
  mov    -0xb8(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  mov    %rax,%rcx
  mov    -0xd8(%rbp),%rax
  add    %rax,%rcx
  mov    -0xb8(%rbp),%edx
  mov    -0x78(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0xe0(%rbp)
L348:
  pxor   %xmm0,%xmm0
  ucomisd -0xe0(%rbp),%xmm0
  jp     L384
  pxor   %xmm0,%xmm0
  ucomisd -0xe0(%rbp),%xmm0
  je     L83
L384:
  movsd  D22(%rip),%xmm0
  comisd -0xe0(%rbp),%xmm0
  jbe    L138
  lea    D77(%rip),%rax
  jmp    L8
L138:
  lea    D254(%rip),%rax
L8:
  mov    %rax,-0xb0(%rbp)
  jmp    L83
L198:
  movsd  D82(%rip),%xmm0
  comisd -0xe0(%rbp),%xmm0
  jbe    L147
  cmpl   $0x0,-0xc0(%rbp)
  je     L147
  lea    D100(%rip),%rax
  mov    %rax,-0x98(%rbp)
  cmpl   $0x3,-0xe4(%rbp)
  jle    L34
  movsd  D57(%rip),%xmm0
  jmp    L493
L34:
  movsd  D257(%rip),%xmm0
L493:
  movsd  %xmm0,-0x90(%rbp)
  movl   $0x0,-0xc4(%rbp)
  jmp    L193
L551:
  movsd  -0xe0(%rbp),%xmm1
  movsd  D105(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0xe0(%rbp)
  addl   $0x1,-0xc4(%rbp)
L193:
  mov    -0xc4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x98(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L394
  movsd  -0x90(%rbp),%xmm0
  comisd -0xe0(%rbp),%xmm0
  ja     L551
L394:
  mov    -0xc4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x98(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0xc5(%rbp)
  jmp    L474
L147:
  movsd  D22(%rip),%xmm0
  movsd  %xmm0,-0xa8(%rbp)
  movl   $0x0,-0xc4(%rbp)
  jmp    L69
L108:
  movsd  -0xa8(%rbp),%xmm1
  movsd  D190(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0xa8(%rbp)
  addl   $0x1,-0xc4(%rbp)
L69:
  movsd  -0xa8(%rbp),%xmm0
  movsd  D142(%rip),%xmm2
  movapd %xmm0,%xmm1
  subsd  %xmm2,%xmm1
  movsd  -0xe0(%rbp),%xmm0
  comisd %xmm1,%xmm0
  ja     L108
  mov    -0xc4(%rbp),%eax
  cmp    -0xe4(%rbp),%eax
  jle    L474
  lea    D87(%rip),%rax
  mov    %rax,-0x88(%rbp)
  cmpl   $0x3,-0xe4(%rbp)
  jle    L566
  movsd  D218(%rip),%xmm0
  jmp    L334
L566:
  movsd  D233(%rip),%xmm0
L334:
  movsd  %xmm0,-0x80(%rbp)
  movl   $0x0,-0xc4(%rbp)
  jmp    L208
L116:
  movsd  -0xe0(%rbp),%xmm0
  movsd  D105(%rip),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0xe0(%rbp)
  addl   $0x1,-0xc4(%rbp)
L208:
  movsd  -0xe0(%rbp),%xmm0
  comisd -0x80(%rbp),%xmm0
  jbe    L504
  mov    -0xc4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L116
L504:
  mov    -0xc4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0xc5(%rbp)
  jmp    L474
L83:
  nop
L474:
  cmpb   $0x0,-0xc5(%rbp)
  je     L171
  cmpq   $0x0,-0xb0(%rbp)
  je     L207
L171:
  mov    -0xe4(%rbp),%edx
  mov    -0xd8(%rbp),%rax
  mov    $0x21,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  cmpq   $0x0,-0xb0(%rbp)
  je     L36
  mov    -0xe4(%rbp),%eax
  mov    $0x4,%edx
  cmp    %edx,%eax
  cmovg  %edx,%eax
  mov    %eax,-0xb4(%rbp)
  mov    -0xe4(%rbp),%eax
  sub    -0xb4(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  movslq %eax,%rdx
  mov    -0xd8(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0xb4(%rbp),%edx
  mov    -0xb0(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  jmp    L36
L207:
  pxor   %xmm0,%xmm0
  ucomisd -0xe0(%rbp),%xmm0
  jp     L73
  pxor   %xmm0,%xmm0
  ucomisd -0xe0(%rbp),%xmm0
  je     L36
L73:
  cmpb   $0x23,-0xc5(%rbp)
  je     L480
  subl   $0x1,-0xe4(%rbp)
  mov    -0xe4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0xd8(%rbp),%rax
  add    %rax,%rdx
  movzbl -0xc5(%rbp),%eax
  mov    %al,(%rdx)
L480:
  mov    -0xe0(%rbp),%rcx
  mov    -0xe4(%rbp),%edx
  lea    -0x70(%rbp),%rax
  movq   %rcx,%xmm0
  lea    D168(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  movzbl -0x70(%rbp),%eax
  cmp    $0x30,%al
  jne    L243
  lea    -0x70(%rbp),%rax
  add    $0x1,%rax
  mov    -0xe4(%rbp),%edx
  mov    -0xd8(%rbp),%rcx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  jmp    L541
L243:
  mov    -0xe4(%rbp),%edx
  lea    -0x70(%rbp),%rcx
  mov    -0xd8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
L541:
  cmpl   $0x1,-0xe4(%rbp)
  jne    L36
  movsd  -0xe0(%rbp),%xmm0
  comisd D56(%rip),%xmm0
  ja     L386
  jmp    L36
L386:
  mov    -0xd8(%rbp),%rax
  movb   $0x21,(%rax)
  jmp    L36
L36:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L403
  call   <__stack_chk_fail@plt>
L403:
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D186
data_type: byte[8]
name: read_data
arguments: label: D22
data_type: f64
name: read_data
arguments: label: D282
data_type: f32[2]
name: read_data
arguments: label: D78
data_type: f32[2]
name: read_data
arguments: label: D246
data_type: string
name: read_data
arguments: label: D162
data_type: string
name: read_data
arguments: label: D188
data_type: string
name: read_data
arguments: label: D25
data_type: byte[8]
name: read_data
arguments: label: D54
data_type: byte[8]
name: read_data
arguments: label: D207
data_type: byte[8]
name: read_data
arguments: label: D20
data_type: byte[8]
name: read_data
arguments: label: D289
data_type: string
name: read_data
arguments: label: D77
data_type: string
name: read_data
arguments: label: D254
data_type: string
name: read_data
arguments: label: D82
data_type: byte[8]
name: read_data
arguments: label: D100
data_type: string
name: read_data
arguments: label: D57
data_type: byte[8]
name: read_data
arguments: label: D257
data_type: byte[8]
name: read_data
arguments: label: D105
data_type: f64
name: read_data
arguments: label: D190
data_type: f64
name: read_data
arguments: label: D142
data_type: byte[8]
name: read_data
arguments: label: D87
data_type: string
name: read_data
arguments: label: D218
data_type: f64
name: read_data
arguments: label: D233
data_type: f64
name: read_data
arguments: label: D168
data_type: string
name: read_data
arguments: label: D56
data_type: f64

tool: {"D186": [0xc0,0xfd,0xdd,0x76,0xd2,0x61,0x85,0x4a]}

tool: D22: 1

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

tool: {"D78": [0.0,0.0]}

tool: D246: %*d

tool: D162: NaN!

tool: D188: inf!

tool: {"D25": [0x76,0x03,0xaa,0x83,0x68,0xd5,0x89,0x45]}

tool: {"D54": [0xd6,0xfe,0x8d,0xac,0xa9,0x8d,0x54,0x45]}

tool: {"D207": [0x44,0x32,0x0b,0x8a,0x54,0x71,0x20,0x45]}

tool: {"D20": [0x3e,0xec,0x31,0x1b,0x47,0x89,0xf3,0x3a]}

tool: D289: %.*e

tool: D77: Low!

tool: D254: Huge

tool: {"D82": [0xba,0x49,0x0c,0x02,0x2b,0x87,0x86,0x3f]}

tool: D100:  munpfazyxwvtsrqoljihgedcb

tool: {"D57": [0xb3,0xea,0x73,0xb5,0x15,0xfb,0xef,0x3f]}

tool: {"D257": [0x35,0xef,0x38,0x45,0x47,0x72,0xb9,0x3f]}

tool: D105: 1000

tool: D190: 10

tool: {"D142": [0x33,0x33,0x33,0x33,0x33,0x33,0xe3,0x3f]}

tool: D87:  kMGTPEZYXWVUSRQONLJIHFDCBA

tool: D218: 999.4

tool: D233: 99.4

tool: D168: %.*f

tool: D56: 9.4

assistant: ```c
void si_sprintf(char *buff, double ival, int n_places, const int flags) {
  int i;
  char prefix = '#';
  const char *err_msg = NULL;
  const bool use_si_prefixes = !(flags & 1);
  const bool use_extended_prefixes = (flags & 2);
  const double extender = (use_extended_prefixes ? 1e+51 : 1);
  assert(n_places > 1);
  assert(n_places < 25);
  if (ival < 0.) {
    *buff++ = '-';
    n_places--;
    ival = -ival;
  } else if (flags & 4) {
    *buff++ = '+';
    n_places--;
  }
  buff[n_places] = '\0';
  if (!ival)
    sprintf(buff, "%*d", n_places, 0);
  else if (isnan(ival))
    err_msg = "NaN!";
  else if (!isfinite(ival))
    err_msg = "inf!";
  else if (ival > 999.39e+24 * extender || (ival > 99.39e+24 * extender && n_places == 3) || (ival > 9.939e+24 * extender && n_places == 2) || (ival < 1.01e-24 / extender && use_si_prefixes)) {
    char tbuff[100], *tptr;
    int len;
    sprintf(tbuff, "%.*e", n_places, ival);
    tptr = strchr(tbuff, 'e');
    if (tptr) {
      while (tptr[2] == '0')
        memmove(tptr + 2, tptr + 3, strlen(tptr + 2));
      len = strlen(tptr);
      if (len <= n_places) {
        memcpy(buff, tbuff, n_places - len);
        memcpy(buff + n_places - len, tptr, len);
        ival = 0.;
      }
    }
    if (ival)
      err_msg = (ival < 1. ? "Low!" : "Huge");
  } else if (ival < .011 && use_si_prefixes) {
    const char *lower_prefixes = " munpfazyxwvtsrqoljihgedcb";
    const double limit = (n_places > 3 ? .9994 : .0994);
    for (i = 0; lower_prefixes[i] && ival < limit; i++)
      ival *= 1000.;
    prefix = lower_prefixes[i];
  } else {
    double top_val = 1.;
    for (i = 0; ival > top_val - .6; i++)
      top_val *= 10.;
    if (i > n_places) {
      const char *prefixes = " kMGTPEZYXWVUSRQONLJIHFDCBA";
      const double limit = (n_places > 3 ? 999.4 : 99.4);
      for (i = 0; ival > limit && prefixes[i]; i++)
        ival /= 1000.;
      prefix = prefixes[i];
    }
  }
  if (!prefix || err_msg) {
    memset(buff, '!', n_places);
    if (err_msg) {
      const int len = (n_places > 4 ? 4 : n_places);
      memcpy(buff + (n_places - len) / 2, err_msg, len);
    }
  } else if (ival) {
    char tbuff[100];
    if (prefix != '#') {
      n_places--;
      buff[n_places] = prefix;
    }
    sprintf(tbuff, "%.*f", n_places, ival);
    if (*tbuff == '0')
      memcpy(buff, tbuff + 1, n_places);
    else
      memcpy(buff, tbuff, n_places);
    if (n_places == 1 && ival > 9.4)
      *buff = '!';
  }
}
```