user: 请从给定的汇编指令推导出C源代码：

```asm
<grd_bipolar_prewinder>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xf8,%rsp
  movss  %xmm1,0x1c(%rsp)
  movss  %xmm2,0x2c(%rsp)
  movss  %xmm3,0x18(%rsp)
  movss  %xmm4,0x38(%rsp)
  movss  %xmm5,0x3c(%rsp)
  movss  %xmm6,0x40(%rsp)
  mov    %rdi,0x48(%rsp)
  mov    %rsi,0x58(%rsp)
  mov    %rdx,0x60(%rsp)
  mov    %rcx,0x50(%rsp)
  mov    %r8,0x68(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  pxor   %xmm1,%xmm1
  cvtss2sd %xmm2,%xmm1
  movsd  D17(%rip),%xmm2
  mulsd  %xmm2,%xmm1
  pxor   %xmm6,%xmm6
  cvtsd2ss %xmm1,%xmm6
  movss  %xmm6,0x30(%rsp)
  cvtss2sd %xmm0,%xmm0
  mulsd  %xmm2,%xmm0
  pxor   %xmm6,%xmm6
  cvtsd2ss %xmm0,%xmm6
  movss  %xmm6,0x34(%rsp)
  movl   $0x32,0x44(%rsp)
  mov    $0x0,%ebp
  jmp    L198
L39:
  mov    0x78(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  movl   $0x0,0x84(%rsp)
  mov    0x78(%rsp),%edx
  test   %edx,%edx
  jle    L184
  mov    $0x0,%eax
L89:
  movslq %eax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movss  %xmm0,0x0(%rbp,%rdx,4)
  mov    0x84(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x84(%rsp)
  mov    0x78(%rsp),%edx
  cmp    %edx,%eax
  jl     L89
L184:
  mov    %ebx,%r9d
  mov    0x8(%rsp),%r8
  mov    %r12,%rcx
  mov    0x90(%rsp),%rsi
  mov    %rbp,%rdi
  call   <interpolatefloats@plt>
  mov    0x78(%rsp),%esi
  mov    0x8(%rsp),%rdi
  call   <sumfloats@plt>
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  mulss  0x24(%rsp),%xmm0
  pxor   %xmm4,%xmm4
  ucomiss %xmm4,%xmm0
  jp     L91
  jne    L91
L148:
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,0x10(%rsp)
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    %ebx,%edx
  mov    0x10(%rsp),%rsi
  mov    0x8(%rsp),%rdi
  call   <diffArray@plt>
  mov    %ebx,%edx
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <diffArray@plt>
  shl    $0x2,%r15
  mov    0x10(%rsp),%rax
  movl   $0x0,-0x4(%rax,%r15,1)
  movl   $0x0,-0x4(%r12,%r15,1)
  movss  D29(%rip),%xmm0
  divss  0x18(%rsp),%xmm0
  cvttss2si %xmm0,%edx
  mov    %ebx,%ecx
  pxor   %xmm0,%xmm0
  mov    %r12,%rsi
  mov    %rax,%rdi
  call   <scalecomplex@plt>
  mov    %ebx,%edx
  mov    %r12,%rsi
  mov    0x10(%rsp),%rdi
  call   <maxMagnitude@plt>
  movss  %xmm0,0x20(%rsp)
  mov    %ebx,%edx
  mov    %r13,%rsi
  mov    0x8(%rsp),%rdi
  call   <maxMagnitude@plt>
  movss  %xmm0,0x28(%rsp)
  movss  0x20(%rsp),%xmm7
  comiss 0x2c(%rsp),%xmm7
  ja     L79
L38:
  movss  0x28(%rsp),%xmm4
  comiss 0x1c(%rsp),%xmm4
  ja     L27
L51:
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    %r12,%rdi
  call   <free@plt>
  mov    0x88(%rsp),%rdi
  call   <free@plt>
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    0x98(%rsp),%rdi
  call   <free@plt>
  mov    0xa0(%rsp),%rdi
  call   <free@plt>
  mov    0xa8(%rsp),%rdi
  call   <free@plt>
  mov    0xb0(%rsp),%rdi
  call   <free@plt>
  mov    0xb8(%rsp),%rdi
  call   <free@plt>
  mov    0xc0(%rsp),%rdi
  call   <free@plt>
  mov    0xc8(%rsp),%rdi
  call   <free@plt>
  mov    0xd0(%rsp),%rdi
  call   <free@plt>
  mov    0xd8(%rsp),%rdi
  call   <free@plt>
  mov    0xe0(%rsp),%rdi
  call   <free@plt>
  movss  0x2c(%rsp),%xmm6
  mulss  D84(%rip),%xmm6
  movss  %xmm6,0x10(%rsp)
  comiss 0x20(%rsp),%xmm6
  jb     L29
  movss  0x1c(%rsp),%xmm0
  mulss  D84(%rip),%xmm0
  comiss 0x28(%rsp),%xmm0
  jae    L119
L29:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  subl   $0x1,0x44(%rsp)
  je     L119
L198:
  lea    0x84(%rsp),%r12
  lea    0xa0(%rsp),%rcx
  lea    0x98(%rsp),%rdx
  lea    0x90(%rsp),%rsi
  lea    0x88(%rsp),%rdi
  mov    %r12,%r9
  lea    0x78(%rsp),%r8
  movss  0x18(%rsp),%xmm3
  movss  0x38(%rsp),%xmm2
  movss  0x30(%rsp),%xmm1
  movss  0x34(%rsp),%xmm0
  call   <grd_trapezoid@plt>
  movslq 0x78(%rsp),%rdx
  mov    0xa0(%rsp),%rax
  mov    -0x4(%rax,%rdx,4),%ebx
  mov    D111(%rip),%rax
  movq   %rax,%xmm0
  call   <sqrt@plt>
  add    $0x1,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movd   %ebx,%xmm0
  divss  %xmm1,%xmm0
  movss  0x40(%rsp),%xmm2
  movaps %xmm2,%xmm4
  divss  %xmm0,%xmm4
  movd   %xmm4,%ebx
  lea    0xc0(%rsp),%rcx
  lea    0xb8(%rsp),%rdx
  lea    0xb0(%rsp),%rsi
  lea    0xa8(%rsp),%rdi
  lea    0x7c(%rsp),%r8
  movss  0x18(%rsp),%xmm3
  movaps %xmm4,%xmm1
  movss  0x1c(%rsp),%xmm0
  call   <grd_rampup@plt>
  movss  D63(%rip),%xmm5
  mulss  0x18(%rsp),%xmm5
  movss  %xmm5,0x24(%rsp)
  mov    0x7c(%rsp),%esi
  mov    0xb0(%rsp),%rdi
  call   <sumfloats@plt>
  lea    0xe0(%rsp),%rcx
  lea    0xd8(%rsp),%rdx
  lea    0xd0(%rsp),%rsi
  lea    0xc8(%rsp),%rdi
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  mulss  0x24(%rsp),%xmm0
  mov    %r12,%r9
  lea    0x80(%rsp),%r8
  movss  0x18(%rsp),%xmm3
  movss  0x3c(%rsp),%xmm2
  subss  %xmm0,%xmm2
  movd   %ebx,%xmm1
  movss  0x1c(%rsp),%xmm0
  call   <grd_trapezoid@plt>
  mov    0x80(%rsp),%ebx
  add    0x7c(%rsp),%ebx
  sub    $0x1,%ebx
  movslq %ebx,%r15
  lea    0x0(,%rbx,4),%r14d
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    0x80(%rsp),%eax
  lea    0x0(,%rax,4),%edx
  mov    0xd0(%rsp),%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  mov    0x7c(%rsp),%eax
  lea    -0x4(,%rax,4),%edx
  mov    0xb0(%rsp),%rax
  lea    0x4(%rax),%rsi
  movslq 0x80(%rsp),%rax
  lea    0x0(%r13,%rax,4),%rdi
  call   <memcpy@plt>
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  movl   $0x0,0x84(%rsp)
  test   %ebx,%ebx
  jle    L136
  mov    $0x0,%eax
  pxor   %xmm2,%xmm2
  cvtsi2ss %ebx,%xmm2
  subss  D29(%rip),%xmm2
L202:
  movslq %eax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x78(%rsp),%xmm0
  subss  D29(%rip),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  mulss  %xmm1,%xmm0
  divss  %xmm2,%xmm0
  movss  %xmm0,(%r12,%rdx,4)
  mov    0x84(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x84(%rsp)
  cmp    %ebx,%eax
  jl     L202
L136:
  test   %rbp,%rbp
  je     L39
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L39
L91:
  movss  0x38(%rsp),%xmm1
  divss  %xmm0,%xmm1
  movaps %xmm1,%xmm0
  call   <fabs@plt>
  mov    %eax,%edx
  mov    0x78(%rsp),%esi
  mov    0x8(%rsp),%rdi
  call   <scalefloats@plt>
  jmp    L148
L79:
  movss  0x2c(%rsp),%xmm0
  divss  %xmm7,%xmm0
  movss  0x30(%rsp),%xmm4
  mulss  %xmm0,%xmm4
  movss  %xmm4,0x30(%rsp)
  cvtss2sd %xmm0,%xmm0
  lea    D25(%rip),%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  jmp    L38
L27:
  movss  0x1c(%rsp),%xmm0
  divss  %xmm4,%xmm0
  movss  0x34(%rsp),%xmm5
  mulss  %xmm0,%xmm5
  movss  %xmm5,0x34(%rsp)
  cvtss2sd %xmm0,%xmm0
  lea    D58(%rip),%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  jmp    L51
L119:
  movss  0x20(%rsp),%xmm6
  comiss 0x10(%rsp),%xmm6
  ja     L64
  movss  0x1c(%rsp),%xmm0
  mulss  D84(%rip),%xmm0
  movss  0x28(%rsp),%xmm6
  comiss %xmm0,%xmm6
  jbe    L123
L64:
  lea    D86(%rip),%rdi
  call   <puts@plt>
L123:
  lea    0x0(,%rbx,8),%ebp
  mov    %ebp,%edi
  call   <malloc@plt>
  mov    0x48(%rsp),%rcx
  mov    %rax,(%rcx)
  mov    %ebp,%edi
  call   <malloc@plt>
  mov    0x58(%rsp),%r12
  mov    %rax,(%r12)
  mov    %ebp,%edi
  call   <malloc@plt>
  mov    0x60(%rsp),%rsi
  mov    %rax,(%rsi)
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    0x50(%rsp),%rsi
  mov    %rax,(%rsi)
  mov    %r14d,%edx
  mov    0x8(%rsp),%rsi
  mov    (%r12),%rdi
  call   <memcpy@plt>
  mov    %r15,%rax
  add    (%r12),%rax
  mov    %rax,%rdi
  mov    %r14d,%edx
  mov    %r13,%rsi
  call   <memcpy@plt>
  mov    0x48(%rsp),%rcx
  mov    (%rcx),%rbp
  add    %rbp,%r15
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    0x8(%rsp),%rdi
  call   <cumulativeSum@plt>
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %r13,%rdi
  call   <cumulativeSum@plt>
  cvttss2si 0x24(%rsp),%edx
  mov    %ebx,%ecx
  pxor   %xmm0,%xmm0
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <scalecomplex@plt>
  movl   $0x0,0x84(%rsp)
  test   %ebx,%ebx
  jle    L140
  mov    $0x0,%eax
  mov    0x50(%rsp),%rsi
L128:
  movslq %eax,%rcx
  mov    (%rsi),%rdx
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  mulss  0x18(%rsp),%xmm0
  movss  %xmm0,(%rdx,%rcx,4)
  mov    0x84(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x84(%rsp)
  cmp    %ebx,%eax
  jl     L128
L140:
  mov    0x68(%rsp),%rax
  mov    %ebx,(%rax)
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L111
  add    $0xf8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L111:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D17
datatype: byte[8]
name: extract_symbolic_data
arguments: data_tag: D29
datatype: byte[4]
name: extract_symbolic_data
arguments: data_tag: D84
datatype: byte[4]
name: extract_symbolic_data
arguments: data_tag: D111
datatype: f64
name: extract_symbolic_data
arguments: data_tag: D63
datatype: byte[4]
name: extract_symbolic_data
arguments: data_tag: D25
datatype: string
name: extract_symbolic_data
arguments: data_tag: D58
datatype: string
name: extract_symbolic_data
arguments: data_tag: D86
datatype: string

tool: {"D17": [0x5c,0x8f,0xc2,0xf5,0x28,0x5c,0xef,0x3f]}

tool: {"D29": [0x00,0x00,0x80,0x3f]}

tool: {"D84": [0x47,0x03,0x80,0x3f]}

tool: D111: 2

tool: {"D63": [0x00,0x08,0x85,0x45]}

tool: D25: bipolar_prewinder: scaling Sx by %.3f


tool: D58: bipolar_prewinder: scaling Gx by %.3f


tool: D86: bipolar_prewinder: not enough iterations

assistant: ```c
void grd_bipolar_prewinder(float gradMax, float gradMaxSys, float slewMax, float T, float kxpre, float kypre, float Gtgt, float **ktraj, float **grad, float **slew, float **time, int *N) {
  float *gxdep = NULL, *gydep = NULL;
  float *kxdep, *gxdep1, *sxdep, *txdep;
  int len_gxdep;
  float t1;
  float rSMAX_gy;
  float *kydepR, *gydepR, *sydepR, *tydepR;
  int NydepR;
  float adepR;
  float *kydepT, *gydepT, *sydepT, *tydepT;
  int NydepT;
  int len_gydep;
  float *interpvec;
  float adepx;
  float sMax;
  float gMax;
  float sscale;
  float gscale;
  float *slewx = NULL, *slewy = NULL;
  float *ktrajx = NULL, *ktrajy = NULL;
  int n;
  float *tempfloats = NULL;
  float errlevel = 0.0001f;
  int iter;
  float rSMAX_gx = .98 * slewMax;
  float rGMAX_gx = .98 * gradMax;
  for (iter = 0; iter < 50; iter++) {
    grd_trapezoid(rGMAX_gx, rSMAX_gx, kxpre, T, &kxdep, &gxdep1, &sxdep, &txdep, &len_gxdep, &n);
    t1 = txdep[len_gxdep - 1] / (1 + sqrt(2.0));
    rSMAX_gy = Gtgt / t1;
    grd_rampup(gradMaxSys, rSMAX_gy, Gtgt, T, &kydepR, &gydepR, &sydepR, &tydepR, &NydepR);
    adepR = 4257 * T * sumfloats(gydepR, NydepR);
    grd_trapezoid(gradMaxSys, rSMAX_gy, -adepR + kypre, T, &kydepT, &gydepT, &sydepT, &tydepT, &NydepT, &n);
    len_gydep = NydepR + NydepT - 1;
    gydep = (float *)malloc(len_gydep * sizeof(float));
    memcpy(gydep, gydepT, NydepT * sizeof(float));
    memcpy(&gydep[NydepT], &gydepR[1], (NydepR - 1) * sizeof(float));
    interpvec = (float *)malloc(len_gydep * sizeof(float));
    gxdep = (float *)malloc(len_gydep * sizeof(float));
    for (n = 0; n < len_gydep; n++)
      interpvec[n] = n * (len_gxdep - 1.0f) / (len_gydep - 1.0f);
    if (tempfloats != NULL)
      free(tempfloats);
    tempfloats = (float *)malloc(len_gxdep * sizeof(float));
    for (n = 0; n < len_gxdep; n++)
      tempfloats[n] = n;
    interpolatefloats(tempfloats, gxdep1, len_gxdep, interpvec, gxdep, len_gydep);
    adepx = 4257 * T * sumfloats(gxdep, len_gxdep);
    if (adepx)
      scalefloats(gxdep, len_gxdep, fabs(kxpre / adepx));
    slewx = (float *)malloc(len_gydep * sizeof(float));
    slewy = (float *)malloc(len_gydep * sizeof(float));
    diffArray(gxdep, slewx, len_gydep);
    diffArray(gydep, slewy, len_gydep);
    slewx[len_gydep - 1] = 0;
    slewy[len_gydep - 1] = 0;
    scalecomplex(slewx, slewy, 1.0f / T, 0.0f, len_gydep);
    sMax = maxMagnitude(slewx, slewy, len_gydep);
    gMax = maxMagnitude(gxdep, gydep, len_gydep);
    if (sMax > slewMax) {
      sscale = slewMax / sMax;
      rSMAX_gx = rSMAX_gx * sscale;
      if (1)
        printf("bipolar_prewinder: scaling Sx by %.3f\n", sscale);
    }
    if (gMax > gradMaxSys) {
      gscale = gradMaxSys / gMax;
      rGMAX_gx = rGMAX_gx * gscale;
      if (1)
        printf("bipolar_prewinder: scaling Gx by %.3f\n", gscale);
    }
    free(slewx);
    free(slewy);
    free(kxdep);
    free(gxdep1);
    free(sxdep);
    free(txdep);
    free(kydepR);
    free(gydepR);
    free(sydepR);
    free(tydepR);
    free(kydepT);
    free(gydepT);
    free(sydepT);
    free(tydepT);
    if (sMax <= (1 + errlevel) * slewMax && gMax <= (1 + errlevel) * gradMaxSys)
      break;
    else {
      free(gxdep);
      free(gydep);
    }
  }
  if (sMax > (1 + errlevel) * slewMax || gMax > (1 + errlevel) * gradMaxSys)
    printf("bipolar_prewinder: not enough iterations\n");
  *ktraj = (float *)malloc(2 * len_gydep * sizeof(float));
  *grad = (float *)malloc(2 * len_gydep * sizeof(float));
  *slew = (float *)malloc(2 * len_gydep * sizeof(float));
  *time = (float *)malloc(len_gydep * sizeof(float));
  memcpy(*grad, gxdep, len_gydep * sizeof(float));
  memcpy(&(*grad)[len_gydep], gydep, len_gydep * sizeof(float));
  ktrajx = *ktraj;
  ktrajy = &(*ktraj)[len_gydep];
  cumulativeSum(gxdep, ktrajx, len_gydep);
  cumulativeSum(gydep, ktrajy, len_gydep);
  scalecomplex(ktrajx, ktrajy, 4257 * T, 0.0f, len_gydep);
  for (n = 0; n < len_gydep; n++)
    (*time)[n] = n * T;
  *N = len_gydep;
  return;
}
```