user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<resample>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %rdi,%r13
  lea    D7(%rip),%rdi
  push   %r12
  mov    %r8d,%r12d
  push   %rbp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x58,%rsp
  mov    0x90(%rsp),%rax
  mov    %esi,0x38(%rsp)
  lea    D20(%rip),%rsi
  mov    %r9d,0x3c(%rsp)
  mov    %rax,0x30(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  test   %rax,%rax
  je     L132
  pxor   %xmm6,%xmm6
  pxor   %xmm0,%xmm0
  pxor   %xmm5,%xmm5
  mov    %rax,%rbp
  cvtsi2sd %r12d,%xmm0
  xor    %r12d,%r12d
  cvtsi2sd %ebx,%xmm6
  cvtsi2sd %r14d,%xmm5
  divsd  %xmm0,%xmm6
  movsd  %xmm5,0x28(%rsp)
  test   %r14d,%r14d
  jle    L134
  movslq 0x38(%rsp),%r8
  pxor   %xmm4,%xmm4
  xor    %r14d,%r14d
  lea    0x47(%rsp),%rbx
  movsd  D18(%rip),%xmm2
  movapd %xmm4,%xmm5
  movapd %xmm4,%xmm3
  movapd %xmm4,%xmm1
  lea    0x0(%r13,%r8,1),%r15
  jmp    L6
  nopl   0x0(%rax)
L70:
  cvttsd2si %xmm5,%eax
  add    0x38(%rsp),%eax
  pxor   %xmm0,%xmm0
  cltq
  movzbl 0x0(%r13,%rax,1),%eax
  add    $0xffffff80,%eax
  cvtsi2sd %eax,%xmm0
L109:
  movsd  %xmm5,0x20(%rsp)
  add    $0x1,%r12d
  movsd  %xmm1,0x18(%rsp)
  movsd  %xmm6,0x10(%rsp)
  movsd  %xmm3,0x8(%rsp)
  movsd  %xmm0,(%rsp)
  call   <round@plt>
  mov    %rbp,%rcx
  mov    $0x1,%edx
  mov    %rbx,%rdi
  mov    $0x1,%esi
  mov    %al,0x47(%rsp)
  call   <fwrite@plt>
  movsd  0x10(%rsp),%xmm6
  pxor   %xmm4,%xmm4
  movsd  0x20(%rsp),%xmm5
  movsd  0x28(%rsp),%xmm7
  mov    D18(%rip),%rax
  addsd  %xmm6,%xmm5
  movsd  (%rsp),%xmm0
  movsd  0x8(%rsp),%xmm3
  movsd  0x18(%rsp),%xmm1
  movq   %rax,%xmm2
  comisd %xmm5,%xmm7
  jbe    L90
L6:
  comisd %xmm2,%xmm6
  jb     L70
  comisd %xmm1,%xmm4
  movapd %xmm4,%xmm0
  jbe    L178
  movapd %xmm1,%xmm7
  mulsd  %xmm3,%xmm7
  subsd  %xmm7,%xmm0
L178:
  addsd  %xmm6,%xmm1
  lea    0x1(%r14),%eax
  cltq
  comisd %xmm4,%xmm1
  ja     L53
  jmp    L108
  nopl   (%rax)
L112:
  subsd  %xmm2,%xmm1
  add    $0x1,%rax
  addsd  %xmm3,%xmm0
  comisd %xmm4,%xmm1
  jbe    L108
L53:
  movzbl -0x1(%r15,%rax,1),%edx
  pxor   %xmm3,%xmm3
  mov    %eax,%r14d
  add    $0xffffff80,%edx
  comisd %xmm2,%xmm1
  cvtsi2sd %edx,%xmm3
  jae    L112
  movapd %xmm3,%xmm7
  add    $0x1,%rax
  mulsd  %xmm1,%xmm7
  subsd  %xmm2,%xmm1
  comisd %xmm4,%xmm1
  addsd  %xmm7,%xmm0
  ja     L53
L108:
  divsd  %xmm6,%xmm0
  jmp    L109
  nopw   0x0(%rax,%rax,1)
L90:
  mov    0x3c(%rsp),%ecx
  cmp    $0x1,%ecx
  jle    L134
  lea    -0x1(%rcx),%eax
  mov    %ecx,%r13d
  and    %r12d,%eax
  sub    %eax,%r13d
  cmp    %r13d,%ecx
  je     L134
  pxor   %xmm1,%xmm1
  movapd %xmm0,%xmm6
  cvtsi2sd %r13d,%xmm1
  divsd  %xmm1,%xmm6
  movsd  %xmm6,0x8(%rsp)
  test   %r13d,%r13d
  jle    L134
  xor    %r14d,%r14d
  nopl   0x0(%rax)
L110:
  subsd  0x8(%rsp),%xmm0
  add    $0x1,%r14d
  movsd  %xmm0,(%rsp)
  call   <round@plt>
  mov    %rbp,%rcx
  mov    $0x1,%edx
  mov    %rbx,%rdi
  mov    $0x1,%esi
  mov    %al,0x47(%rsp)
  call   <fwrite@plt>
  cmp    %r14d,%r13d
  movsd  (%rsp),%xmm0
  jne    L110
  add    %r13d,%r12d
L134:
  mov    0x30(%rsp),%rcx
  mov    %r12d,%edx
  mov    %rbp,%rdi
  xor    %esi,%esi
  call   <inEx@plt>
  mov    %rbp,%rdi
  mov    %rax,%r12
  call   <fclose@plt>
L22:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L139
  add    $0x58,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L132:
  lea    D23(%rip),%rdi
  xor    %r12d,%r12d
  call   <printf@plt>
  jmp    L22
L139:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D7
type_guessed: string
name: extract_symbolic_data
arguments: label: D20
type_guessed: string
name: extract_symbolic_data
arguments: label: D18
type_guessed: f32[2]
name: extract_symbolic_data
arguments: label: D23
type_guessed: string

tool: D7: tmp.bin

tool: D20: wb+

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

tool: D23: Error: cannot open file tmp.bin


assistant: ```c
unsigned char *resample(unsigned char *data, int offset, int len, int inputRate, int outputRate, int align, int *outSize) {
  FILE *f = fopen("tmp.bin", "wb+");
  if (f == NULL) {
    printf("Error: cannot open file tmp.bin\n");
    return NULL;
  }
  const double step = (double)inputRate / (double)outputRate;
  double value;
  double lastSample;
  double sample = 0;
  unsigned char byte;
  double dOff;
  int off;
  int outOff;
  value = 0;
  lastSample = 0;
  off = 0;
  outOff = 0;
  for (dOff = 0; dOff < len; dOff += step) {
    sample = 0;
    if (step >= 1) {
      if (value < 0)
        sample += lastSample * -value;
      value += step;
      while (value > 0) {
        lastSample = (data[off + offset] & 0xFF) - 0x80;
        off++;
        if (value >= 1)
          sample += lastSample;
        else
          sample += lastSample * value;
        value--;
      }
      sample /= step;
    } else {
      sample = (data[(int)dOff + offset] & 0xFF) - 0x80;
    }
    byte = round(sample);
    fwrite(&byte, 1, 1, f);
    outOff++;
  }
  if (align > 1) {
    const int mask = align - 1;
    const int size = align - (outOff & mask);
    if (size != align) {
      double reduce = sample / size;
      int i;
      for (i = 0; i < size; i++) {
        sample -= reduce;
        byte = round(sample);
        fwrite(&byte, 1, 1, f);
        outOff++;
      }
    }
  }
  unsigned char *result = inEx(f, 0, outOff, outSize);
  fclose(f);
  return result;
}
```