user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<wcshdo_format>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %edi,-0x54(%rbp)
  mov    %esi,-0x58(%rbp)
  mov    %rdx,-0x60(%rbp)
  mov    %rcx,-0x68(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x47,-0x54(%rbp)
  jne    L155
  movl   $0x66,-0x54(%rbp)
  movl   $0x0,-0x40(%rbp)
  jmp    L84
L165:
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movq   %rax,%xmm0
  call   <fabs@plt>
  test   %eax,%eax
  jle    L31
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd D34(%rip),%xmm0
  jbe    L66
L31:
  movl   $0x45,-0x54(%rbp)
  jmp    L155
L66:
  addl   $0x1,-0x40(%rbp)
L84:
  mov    -0x40(%rbp),%eax
  cmp    -0x58(%rbp),%eax
  jl     L165
L155:
  lea    -0x20(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,-0x28(%rbp)
  movl   $0xfffffc19,-0x3c(%rbp)
  movl   $0x0,-0x40(%rbp)
  jmp    L199
L128:
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  lea    -0x20(%rbp),%rax
  movq   %rdx,%xmm0
  lea    D37(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <wcsutil_double2str@plt>
  lea    -0x20(%rbp),%rax
  add    $0x10,%rax
  mov    %rax,-0x30(%rbp)
  jmp    L76
L112:
  subq   $0x1,-0x30(%rbp)
L76:
  mov    -0x28(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  jae    L166
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  je     L112
L166:
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  lea    -0x20(%rbp),%rax
  add    $0x12,%rax
  lea    -0x44(%rbp),%rdx
  lea    D52(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  mov    -0x44(%rbp),%eax
  cmp    %eax,-0x3c(%rbp)
  jge    L91
  mov    -0x44(%rbp),%eax
  mov    %eax,-0x3c(%rbp)
L91:
  addl   $0x1,-0x40(%rbp)
L199:
  mov    -0x40(%rbp),%eax
  cmp    -0x58(%rbp),%eax
  jl     L128
  lea    -0x20(%rbp),%rax
  add    $0x2,%rax
  mov    -0x28(%rbp),%rdx
  sub    %rax,%rdx
  mov    %edx,%eax
  add    $0x1,%eax
  mov    %eax,-0x34(%rbp)
  cmpl   $0x66,-0x54(%rbp)
  jne    L95
  mov    -0x3c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x34(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x38(%rbp)
  cmpl   $0x0,-0x38(%rbp)
  jg     L181
  movl   $0x1,-0x38(%rbp)
L181:
  cmpl   $0x11,-0x38(%rbp)
  jle    L85
  movl   $0x11,-0x38(%rbp)
L85:
  mov    -0x38(%rbp),%edx
  mov    -0x68(%rbp),%rax
  lea    D40(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  jmp    L149
L95:
  mov    -0x34(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x38(%rbp)
  cmpl   $0x0,-0x38(%rbp)
  jg     L35
  movl   $0x1,-0x38(%rbp)
L35:
  cmpl   $0xe,-0x38(%rbp)
  jle    L158
  movl   $0xe,-0x38(%rbp)
L158:
  cmpl   $0xd,-0x38(%rbp)
  jg     L7
  mov    -0x38(%rbp),%edx
  mov    -0x68(%rbp),%rax
  lea    D55(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  jmp    L149
L7:
  mov    -0x38(%rbp),%edx
  mov    -0x68(%rbp),%rax
  lea    D30(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
L149:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L22
  call   <__stack_chk_fail@plt>
L22:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D34
type_infered: f64
name: unpack_data
arguments: label: D37
type_infered: string
name: unpack_data
arguments: label: D52
type_infered: string
name: unpack_data
arguments: label: D40
type_infered: string
name: unpack_data
arguments: label: D55
type_infered: string
name: unpack_data
arguments: label: D30
type_infered: string

tool: D34: 1000000000000

tool: D37: %21.14E

tool: D52: %d

tool: D40: %%20.%df

tool: D55: %%20.%dE

tool: D30: %%21.%dE

assistant: ```c
void wcshdo_format(int fmt, int nval, const double val[], char *format) {
  char *cp, *cp0, cval[24];
  int i, expmax, expon, nsig, precision;
  if (fmt == 'G') {
    fmt = 'f';
    for (i = 0; i < nval; i++) {
      if (fabs(val[i]) < 1e-4 || 1e12 < val[i]) {
        fmt = 'E';
        break;
      }
    }
  }
  cp0 = cval + 2;
  expmax = -999;
  for (i = 0; i < nval; i++) {
    wcsutil_double2str(cval, "%21.14E", val[i]);
    cp = cval + 16;
    while (cp0 < cp && *cp == '0')
      cp--;
    cp0 = cp;
    sscanf(cval + 18, "%d", &expon);
    if (expmax < expon)
      expmax = expon;
  }
  nsig = cp0 - (cval + 2) + 1;
  if (fmt == 'f') {
    precision = nsig - (expmax + 1);
    if (precision < 1)
      precision = 1;
    if (17 < precision)
      precision = 17;
    sprintf(format, "%%20.%df", precision);
  } else {
    precision = nsig - 1;
    if (precision < 1)
      precision = 1;
    if (14 < precision)
      precision = 14;
    if (precision < 14) {
      sprintf(format, "%%20.%dE", precision);
    } else {
      sprintf(format, "%%21.%dE", precision);
    }
  }
}
```