user: Converte this assembly snippet into its equivalent C code:

```asm
<ambe_resample_mag>:
  endbr64
  movslq %ecx,%rax
  pxor   %xmm0,%xmm0
  pxor   %xmm5,%xmm5
  push   %r15
  cvtsi2ss %eax,%xmm0
  push   %r14
  cvtsi2ss %esi,%xmm5
  push   %r13
  push   %r12
  push   %rbp
  movaps %xmm0,%xmm1
  push   %rbx
  divss  %xmm5,%xmm1
  sub    $0x28,%rsp
  mov    %eax,0xc(%rsp)
  movss  %xmm5,0x18(%rsp)
  movss  %xmm1,0x8(%rsp)
  test   %esi,%esi
  jle    L49
  lea    -0x4(%rdx,%rax,4),%rax
  mov    %rdi,%rbp
  mov    %esi,%ebx
  mov    %rdx,%r12
  mov    %rax,0x10(%rsp)
  lea    -0x1(%rsi),%eax
  mov    %rdi,%r15
  mov    %rdi,%r14
  mov    %eax,0x1c(%rsp)
  lea    0x4(%rdi,%rax,4),%r13
  pxor   %xmm2,%xmm2
  jmp    L53
  xchg   %ax,%ax
L42:
  movss  (%r12),%xmm0
L129:
  movss  %xmm0,(%r14)
  add    $0x4,%r14
  addss  %xmm0,%xmm2
  addss  0x8(%rsp),%xmm1
  cmp    %r13,%r14
  je     L59
L53:
  movaps %xmm1,%xmm0
  movss  %xmm2,0x4(%rsp)
  movss  %xmm1,(%rsp)
  call   <floorf@plt>
  movss  (%rsp),%xmm1
  movss  0x4(%rsp),%xmm2
  test   %eax,%eax
  je     L42
  cmp    %eax,0xc(%rsp)
  jg     L44
  mov    0x10(%rsp),%rax
  movss  (%rax),%xmm0
  jmp    L129
  nopl   0x0(%rax)
L44:
  pxor   %xmm0,%xmm0
  movaps %xmm1,%xmm3
  cvtsi2ss %eax,%xmm0
  cltq
  subss  %xmm0,%xmm3
  movss  D7(%rip),%xmm0
  subss  %xmm3,%xmm0
  mulss  (%r12,%rax,4),%xmm3
  mulss  -0x4(%r12,%rax,4),%xmm0
  addss  %xmm3,%xmm0
  jmp    L129
  nopl   0x0(%rax,%rax,1)
L59:
  cmpl   $0x2,0x1c(%rsp)
  divss  0x18(%rsp),%xmm2
  jbe    L91
  mov    %ebx,%eax
  movaps %xmm2,%xmm1
  shr    $0x2,%eax
  shufps $0x0,%xmm1,%xmm1
  sub    $0x1,%eax
  shl    $0x4,%rax
  lea    0x10(%rbp,%rax,1),%rax
  nopl   0x0(%rax)
L11:
  movups (%r15),%xmm0
  add    $0x10,%r15
  subps  %xmm1,%xmm0
  movups %xmm0,-0x10(%r15)
  cmp    %rax,%r15
  jne    L11
  mov    %ebx,%edx
  and    $0xfffffffc,%edx
  mov    %edx,%eax
  cmp    %ebx,%edx
  je     L49
L118:
  sub    %edx,%ebx
  cmp    $0x1,%ebx
  je     L71
  lea    0x0(%rbp,%rdx,4),%rdx
  movaps %xmm2,%xmm1
  movq   (%rdx),%xmm0
  shufps $0xe0,%xmm1,%xmm1
  subps  %xmm1,%xmm0
  movlps %xmm0,(%rdx)
  mov    %ebx,%edx
  and    $0xfffffffe,%edx
  add    %edx,%eax
  cmp    %edx,%ebx
  je     L49
L71:
  cltq
  lea    0x0(%rbp,%rax,4),%rax
  movss  (%rax),%xmm0
  subss  %xmm2,%xmm0
  movss  %xmm0,(%rax)
L49:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L91:
  xor    %edx,%edx
  xor    %eax,%eax
  jmp    L118
```

tool_calls: name: retrieve_data
arguments: data_tag: D7
data_type: byte[4]

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

assistant: ```c
void ambe_resample_mag(float *mag_dst, int L_dst, float *mag_src, int L_src) {
  float avg, step, pos;
  int i;
  avg = 0.0f;
  step = (float)L_src / (float)L_dst;
  pos = step;
  for (i = 0; i < L_dst; i++) {
    int posi = (int)floorf(pos);
    if (posi == 0) {
      mag_dst[i] = mag_src[0];
    } else if (posi >= L_src) {
      mag_dst[i] = mag_src[L_src - 1];
    } else {
      float alpha = pos - posi;
      mag_dst[i] = mag_src[posi - 1] * (1.0f - alpha) + mag_src[posi] * alpha;
    }
    avg += mag_dst[i];
    pos += step;
  }
  avg /= L_dst;
  for (i = 0; i < L_dst; i++)
    mag_dst[i] -= avg;
}
```