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

```asm
<runtest>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %edi,%r13d
  movsd  %xmm0,0x8(%rsp)
  mov    %esi,%r12d
  mov    %edx,%r14d
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %edi,%xmm0
  movsd  %xmm1,(%rsp)
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%ebx
  mov    %ebx,0x28(%rsp)
  lea    0x3e8(%rbx),%eax
  mov    %eax,0x18(%rsp)
  lea    0x190(,%rdi,4),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %rax,0x38(%rsp)
  lea    0x1130(,%rbx,4),%edi
  call   <malloc@plt>
  mov    %rax,0x30(%rsp)
  mov    %r14d,%ecx
  mov    %r12d,%edx
  movsd  (%rsp),%xmm1
  movsd  0x8(%rsp),%xmm0
  mov    %r13d,%esi
  lea    D132(%rip),%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  test   %r13d,%r13d
  jle    L295
  mov    $0x0,%ebx
L19:
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  divsd  0x8(%rsp),%xmm0
  cvttsd2si %xmm0,%edi
  call   <sin@plt>
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x0(%rbp)
  add    $0x1,%ebx
  add    $0x4,%rbp
  cmp    %ebx,%r13d
  jne    L19
L295:
  movslq %r13d,%rdx
  shl    $0x2,%rdx
  mov    0x38(%rsp),%rcx
  lea    (%rdx,%rcx,1),%rax
  lea    0x190(%rcx,%rdx,1),%rdx
  movss  D150(%rip),%xmm0
L123:
  movss  %xmm0,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L123
  mov    0x28(%rsp),%esi
  cmp    $0xfffffbb5,%esi
  jl     L205
  mov    0x30(%rsp),%rcx
  mov    %rcx,%rax
  lea    0x44b(%rsi),%edx
  lea    0x4(%rcx,%rdx,4),%rdx
  movss  D150(%rip),%xmm0
L134:
  movss  %xmm0,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L134
L205:
  movsd  (%rsp),%xmm1
  movapd %xmm1,%xmm0
  mov    $0x1,%edi
  call   <resample_open@plt>
  mov    %rax,0x10(%rsp)
  mov    %rax,%rdi
  call   <resample_get_filter_width@plt>
  mov    %eax,0x40(%rsp)
  mov    $0x0,%ebp
  mov    $0x0,%r15d
  lea    0x54(%rsp),%rax
  mov    %rax,0x20(%rsp)
L117:
  mov    %r13d,%eax
  sub    %ebp,%eax
  movslq %r15d,%rdx
  cmp    %r12d,%eax
  setle  %cl
  movzbl %cl,%ecx
  cmovg  %r12d,%eax
  mov    %eax,%esi
  movslq %ebp,%rax
  mov    0x38(%rsp),%rdi
  lea    (%rdi,%rax,4),%rdi
  sub    $0x8,%rsp
  mov    0x20(%rsp),%eax
  sub    %r15d,%eax
  cmp    %r14d,%eax
  cmovg  %r14d,%eax
  push   %rax
  mov    0x40(%rsp),%rbx
  lea    (%rbx,%rdx,4),%r9
  mov    0x30(%rsp),%r8
  mov    %esi,%edx
  mov    %rdi,%rsi
  movsd  0x10(%rsp),%xmm0
  mov    0x20(%rsp),%rdi
  call   <resample_process@plt>
  mov    %eax,%ebx
  mov    %ebp,%eax
  add    0x64(%rsp),%eax
  mov    %eax,%ebp
  add    $0x10,%rsp
  test   %ebx,%ebx
  js     L208
  add    %ebx,%r15d
  test   %ebx,%ebx
  jne    L117
  cmp    %eax,%r13d
  jne    L117
  mov    0x10(%rsp),%rdi
  call   <resample_close@plt>
  jmp    L93
L301:
  mov    %r15d,%esi
  lea    D25(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x38(%rsp),%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  jmp    L268
L81:
  mov    %r15d,%edx
  mov    0x28(%rsp),%esi
  lea    D10(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L47
L228:
  add    $0x1,%r15d
L113:
  movsd  0x10(%rsp),%xmm3
  addsd  0x20(%rsp),%xmm3
  movsd  %xmm3,0x10(%rsp)
  movsd  0x28(%rsp),%xmm0
  mulsd  %xmm0,%xmm0
  addsd  0x18(%rsp),%xmm0
  movsd  %xmm0,0x18(%rsp)
  add    $0x1,%ebx
  add    $0x4,%r12
  cmp    %ebx,%r13d
  je     L320
L20:
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  divsd  0x8(%rsp),%xmm0
  divsd  (%rsp),%xmm0
  cvttsd2si %xmm0,%r14d
  mov    %r14d,%edi
  call   <sin@plt>
  pxor   %xmm2,%xmm2
  cvtss2sd (%r12),%xmm2
  movsd  %xmm2,0x40(%rsp)
  subsd  %xmm2,%xmm0
  movsd  %xmm0,0x28(%rsp)
  andpd  D81(%rip),%xmm0
  movsd  %xmm0,0x20(%rsp)
  comisd D13(%rip),%xmm0
  jbe    L113
  test   %r15d,%r15d
  jne    L228
  mov    %r14d,%edi
  call   <sin@plt>
  movsd  0x40(%rsp),%xmm1
  mov    %ebx,%esi
  lea    D27(%rip),%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  jmp    L228
L320:
  mov    %r15d,0x20(%rsp)
  mov    0x4c(%rsp),%r15d
  mov    $0x0,%r12d
  mov    $0x0,%ebx
  lea    D3(%rip),%r14
  jmp    L223
L273:
  test   %r12d,%r12d
  je     L99
L29:
  add    $0x1,%r12d
L66:
  add    $0x1,%ebx
  add    $0x4,%rbp
  cmp    %ebx,%r13d
  je     L40
L223:
  pxor   %xmm0,%xmm0
  cvtss2sd 0x0(%rbp),%xmm0
  movsd  D166(%rip),%xmm5
  comisd %xmm0,%xmm5
  ja     L273
  comisd D120(%rip),%xmm0
  jbe    L66
  jmp    L273
L99:
  mov    %ebx,%esi
  mov    %r14,%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  jmp    L29
L40:
  cmp    $0x1,%r12d
  jg     L34
L26:
  mov    0x20(%rsp),%r14d
  test   %r14d,%r14d
  jg     L206
L291:
  pxor   %xmm0,%xmm0
  cvtsi2sd %r13d,%xmm0
  movsd  0x10(%rsp),%xmm7
  divsd  %xmm0,%xmm7
  movq   %xmm7,%rbx
  movsd  0x18(%rsp),%xmm1
  divsd  %xmm0,%xmm1
  pxor   %xmm0,%xmm0
  ucomisd %xmm1,%xmm0
  ja     L69
  sqrtsd %xmm1,%xmm1
L94:
  movq   %rbx,%xmm0
  mov    %r15d,%esi
  lea    D156(%rip),%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  mov    0x38(%rsp),%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
L268:
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L218
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L34:
  mov    %r12d,%esi
  lea    D124(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L26
L206:
  lea    -0x1(%r15),%ebx
  movslq %ebx,%rax
  mov    0x30(%rsp),%rcx
  pxor   %xmm7,%xmm7
  cvtss2sd (%rcx,%rax,4),%xmm7
  movq   %xmm7,%rbp
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  divsd  0x8(%rsp),%xmm0
  divsd  (%rsp),%xmm0
  cvttsd2si %xmm0,%edi
  call   <sin@plt>
  movq   %rbp,%xmm1
  mov    %ebx,%esi
  lea    D143(%rip),%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  mov    %r14d,%esi
  lea    D48(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L291
L12:
  pxor   %xmm6,%xmm6
  movsd  %xmm6,0x10(%rsp)
  movsd  %xmm6,0x18(%rsp)
  jmp    L291
L69:
  movapd %xmm1,%xmm0
  call   <sqrt@plt>
  movapd %xmm0,%xmm1
  jmp    L94
L208:
  mov    0x10(%rsp),%rdi
  call   <resample_close@plt>
  mov    %ebx,%esi
  lea    D137(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L93:
  test   %r15d,%r15d
  jle    L301
  movsd  (%rsp),%xmm6
  movapd %xmm6,%xmm0
  addsd  %xmm6,%xmm0
  addsd  D6(%rip),%xmm0
  cvttsd2si %xmm0,%ecx
  mov    %r15d,%edx
  sub    0x28(%rsp),%edx
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  cmp    %eax,%ecx
  jl     L81
L47:
  mov    %r15d,%r13d
  sub    0x40(%rsp),%r13d
  test   %r13d,%r13d
  jle    L12
  mov    0x30(%rsp),%r12
  mov    %r12,%rbp
  mov    $0x0,%eax
  mov    $0x0,%ebx
  pxor   %xmm4,%xmm4
  movsd  %xmm4,0x18(%rsp)
  movsd  %xmm4,0x10(%rsp)
  mov    %r15d,0x4c(%rsp)
  mov    %eax,%r15d
  jmp    L20
L218:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D132
data_type: string
name: read_data
arguments: data_tag: D150
data_type: byte[4]
name: read_data
arguments: data_tag: D25
data_type: string
name: read_data
arguments: data_tag: D10
data_type: string
name: read_data
arguments: data_tag: D81
data_type: qword[2]
name: read_data
arguments: data_tag: D13
data_type: f64[2]
name: read_data
arguments: data_tag: D27
data_type: string
name: read_data
arguments: data_tag: D3
data_type: string
name: read_data
arguments: data_tag: D166
data_type: byte[8]
name: read_data
arguments: data_tag: D120
data_type: f64[2]
name: read_data
arguments: data_tag: D156
data_type: string
name: read_data
arguments: data_tag: D124
data_type: string
name: read_data
arguments: data_tag: D143
data_type: string
name: read_data
arguments: data_tag: D48
data_type: string
name: read_data
arguments: data_tag: D137
data_type: string
name: read_data
arguments: data_tag: D6
data_type: f64

tool: D132: -- srclen: %d sin freq: %.1f factor: %.3f srcblk: %d dstblk: %d


tool: {"D150": [0x00,0x00,0xc6,0xc2]}

tool: D25: Error: resample_process returned %d samples


tool: D10:    Expected ~%d, got %d samples out


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

tool: {"D13": [0.05,-1.01]}

tool: D27:    First error at i=%d: expected %.3f, got %.3f


tool: D3:    Error at i=%d: value is %.3f


tool: {"D166": [0x29,0x5c,0x8f,0xc2,0xf5,0x28,0xf0,0xbf]}

tool: {"D120": [1.01,null]}

tool: D156:    Out: %d samples  Avg err: %f RMS err: %f


tool: D124:    At least %d samples were out of range


tool: D143:    i=%d:  expected %.3f, got %.3f


tool: D48:    At least %d samples had significant error.


tool: D137: Error: resample_process returned an error: %d


tool: D6: 1

assistant: ```c
void runtest(int srclen, double freq, double factor, int srcblocksize, int dstblocksize) {
  int expectedlen = (int)(srclen * factor);
  int dstlen = expectedlen + 1000;
  float *src = (float *)malloc((srclen + 100) * sizeof(float));
  float *dst = (float *)malloc((dstlen + 100) * sizeof(float));
  void *handle;
  double sum, sumsq, err, rmserr;
  int i, out, o, srcused, errcount, rangecount;
  int statlen, srcpos, lendiff;
  int fwidth;
  printf("-- srclen: %d sin freq: %.1f factor: %.3f srcblk: %d dstblk: %d\n", srclen, freq, factor, srcblocksize, dstblocksize);
  for (i = 0; i < srclen; i++)
    src[i] = sin(i / freq);
  for (i = srclen; i < srclen + 100; i++)
    src[i] = -99.0;
  for (i = 0; i < dstlen + 100; i++)
    dst[i] = -99.0;
  handle = resample_open(1, factor, factor);
  fwidth = resample_get_filter_width(handle);
  out = 0;
  srcpos = 0;
  for (;;) {
    int srcBlock = (srclen - srcpos) < (srcblocksize) ? (srclen - srcpos) : (srcblocksize);
    int lastFlag = (srcBlock == srclen - srcpos);
    o = resample_process(handle, factor, &src[srcpos], srcBlock, lastFlag, &srcused, &dst[out], (dstlen - out) < (dstblocksize) ? (dstlen - out) : (dstblocksize));
    srcpos += srcused;
    if (o >= 0)
      out += o;
    if (o < 0 || (o == 0 && srcpos == srclen))
      break;
  }
  resample_close(handle);
  if (o < 0) {
    printf("Error: resample_process returned an error: %d\n", o);
  }
  if (out <= 0) {
    printf("Error: resample_process returned %d samples\n", out);
    free(src);
    free(dst);
    return;
  }
  lendiff = abs(out - expectedlen);
  if (lendiff > (int)(2 * factor + 1.0)) {
    printf("   Expected ~%d, got %d samples out\n", expectedlen, out);
  }
  sum = 0.0;
  sumsq = 0.0;
  errcount = 0.0;
  statlen = out - fwidth;
  for (i = 0; i < statlen; i++) {
    double diff = sin((i / freq) / factor) - dst[i];
    if (fabs(diff) > 0.05) {
      if (errcount == 0)
        printf("   First error at i=%d: expected %.3f, got %.3f\n", i, sin((i / freq) / factor), dst[i]);
      errcount++;
    }
    sum += fabs(diff);
    sumsq += diff * diff;
  }
  rangecount = 0;
  for (i = 0; i < statlen; i++) {
    if (dst[i] < -1.01 || dst[i] > 1.01) {
      if (rangecount == 0)
        printf("   Error at i=%d: value is %.3f\n", i, dst[i]);
      rangecount++;
    }
  }
  if (rangecount > 1)
    printf("   At least %d samples were out of range\n", rangecount);
  if (errcount > 0) {
    i = out - 1;
    printf("   i=%d:  expected %.3f, got %.3f\n", i, sin((i / freq) / factor), dst[i]);
    printf("   At least %d samples had significant error.\n", errcount);
  }
  err = sum / statlen;
  rmserr = sqrt(sumsq / statlen);
  printf("   Out: %d samples  Avg err: %f RMS err: %f\n", out, err, rmserr);
  free(src);
  free(dst);
}
```