user: Please show me the C implementation that matches the assembly code listed below:

```asm
<composite_waveform>:
  endbr64
  push   %r15
  mov    %rcx,%r10
  push   %r14
  mov    %rdx,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %r9d,0x70(%rsp)
  movsd  %xmm0,0x30(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x88(%rsp)
  xor    %eax,%eax
  lea    (%rdi,%rsi,8),%rax
  mov    %rax,0x28(%rsp)
  mov    (%rax),%rax
  mulsd  (%rax),%xmm0
  comisd D40(%rip),%xmm0
  jae    L279
  cvttsd2si %xmm0,%rcx
L4:
  mov    %rcx,%rdi
  mov    $0x8,%esi
  mov    %r10,0x8(%rsp)
  mov    %rcx,(%rsp)
  movsd  %xmm1,0x10(%rsp)
  call   <calloc@plt>
  mov    (%rsp),%rcx
  mov    0x8(%rsp),%r10
  test   %rax,%rax
  movsd  0x10(%rsp),%xmm1
  mov    %rax,%r11
  je     L263
  mov    (%r10),%rax
  mov    %rax,0x20(%rsp)
  mov    0x28(%rsp),%rax
  mov    (%rax),%rax
  movsd  0x8(%rax),%xmm0
  xorpd  D61(%rip),%xmm0
  comisd D40(%rip),%xmm0
  jae    L130
  cvttsd2si %xmm0,%rax
  mov    %rax,0x38(%rsp)
L131:
  cmpq   $0x0,0x38(%rsp)
  je     L35
  mov    0x20(%rsp),%rdi
  lea    0x10(%r11),%rsi
  lea    -0x1(%rcx),%rdx
  mov    %rcx,%r15
  mov    %rcx,%r8
  mov    %r14,0x68(%rsp)
  lea    0x0(,%rdi,8),%rbx
  lea    (%r14,%rbx,1),%rax
  cmp    %rax,%rsi
  lea    0x10(%r14,%rdi,8),%rsi
  setbe  %al
  cmp    %rsi,%r11
  setae  %sil
  or     %esi,%eax
  cmp    $0x1,%rdx
  seta   %sil
  shr    %r15
  and    $0xfffffffffffffffe,%r8
  sub    %r11,%rbx
  and    %eax,%esi
  shl    $0x4,%r15
  add    %r14,%rbx
  mov    %r8,0x60(%rsp)
  mov    %sil,0x76(%rsp)
  mov    %rdi,%rsi
  add    %rcx,%rdi
  add    %r11,%r15
  add    %r8,%rsi
  mov    %rdi,0x48(%rsp)
  cmp    $0x1,%rcx
  lea    (%r11,%r8,8),%rbp
  lea    -0x8(%r14,%rdi,8),%rdi
  lea    (%r14,%rsi,8),%r12
  mov    %rdi,0x58(%rsp)
  lea    (%r11,%rdx,8),%rdi
  setne  %dl
  lea    (%r11,%rcx,8),%rsi
  and    %eax,%edx
  lea    0x80(%rsp),%rax
  mov    %rsi,0x78(%rsp)
  xor    %r9d,%r9d
  mov    %rdi,0x50(%rsp)
  mov    %r9,%r14
  mov    %dl,0x77(%rsp)
  mov    %rax,0x40(%rsp)
  cs nopw 0x0(%rax,%rax,1)
L19:
  mov    0x28(%rsp),%rax
  mov    0x70(%rsp),%r8d
  mov    %r11,%rsi
  mov    %r10,0x18(%rsp)
  mov    0x40(%rsp),%rdx
  mov    %rcx,0x8(%rsp)
  mov    (%rax,%r14,8),%r13
  mov    %r11,(%rsp)
  movsd  %xmm1,0x10(%rsp)
  movsd  0x48(%r13),%xmm0
  mov    %r13,%rdi
  movq   $0x0,0x80(%rsp)
  movsd  %xmm0,0x8(%r13)
  movsd  0x30(%rsp),%xmm0
  call   <simple_waveform@plt>
  mov    (%rsp),%r11
  mov    0x8(%rsp),%rcx
  cmp    $0xffffffff,%eax
  movsd  0x10(%rsp),%xmm1
  mov    0x18(%rsp),%r10
  je     L431
  mov    0x20(%rsp),%rax
  mov    %rax,(%r10)
  cvttsd2si 0x50(%r13),%eax
  cmp    $0x3,%eax
  je     L92
  jg     L438
  cmp    $0x1,%eax
  je     L398
  cmp    $0x2,%eax
  jne    L456
  test   %rcx,%rcx
  je     L66
  cmpb   $0x0,0x77(%rsp)
  mov    %r11,%rax
  je     L275
  pxor   %xmm2,%xmm2
  nopl   0x0(%rax,%rax,1)
L284:
  movupd (%rbx,%rax,1),%xmm0
  movupd (%rax),%xmm5
  mulpd  %xmm5,%xmm0
  movups %xmm0,(%rbx,%rax,1)
  add    $0x10,%rax
  movups %xmm2,-0x10(%rax)
  cmp    %rax,%r15
  jne    L284
  unpckhpd %xmm0,%xmm0
  cmp    0x60(%rsp),%rcx
  je     L316
  movsd  (%r12),%xmm0
  mulsd  0x0(%rbp),%xmm0
  movsd  %xmm0,(%r12)
  movq   $0x0,0x0(%rbp)
L316:
  mov    0x48(%rsp),%rax
  mov    %rax,(%r10)
  mov    0x58(%rsp),%rax
  movsd  %xmm0,(%rax)
  mov    0x50(%rsp),%rax
  movq   $0x0,(%rax)
L66:
  add    $0x1,%r14
  cmp    %r14,0x38(%rsp)
  jne    L19
L35:
  mov    %r11,%rdi
  call   <free@plt>
  mov    0x38(%rsp),%r8d
L174:
  mov    0x88(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L484
  add    $0x98,%rsp
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L279:
  subsd  D40(%rip),%xmm0
  cvttsd2si %xmm0,%rcx
  btc    $0x3f,%rcx
  jmp    L4
  nopw   0x0(%rax,%rax,1)
L130:
  subsd  D40(%rip),%xmm0
  cvttsd2si %xmm0,%rax
  btc    $0x3f,%rax
  mov    %rax,0x38(%rsp)
  jmp    L131
  nopl   0x0(%rax)
L438:
  cmp    $0x4,%eax
  jne    L456
  mov    0x20(%rsp),%rax
  mov    %r11,%rdx
  test   %rcx,%rcx
  je     L66
  mov    0x48(%rsp),%rsi
  mov    0x68(%rsp),%r9
  jmp    L159
  cs nopw 0x0(%rax,%rax,1)
L216:
  add    $0x1,%rax
  add    $0x8,%rdx
  movsd  -0x8(%r9,%rax,8),%xmm0
  mov    %rax,(%r10)
  divsd  %xmm2,%xmm0
  movsd  %xmm0,-0x8(%r9,%rax,8)
  movq   $0x0,-0x8(%rdx)
  cmp    %rsi,%rax
  je     L66
L159:
  movsd  (%rdx),%xmm2
  pxor   %xmm3,%xmm3
  ucomisd %xmm3,%xmm2
  jp     L216
  jne    L216
  mov    0x70(%rsp),%esi
  lea    D77(%rip),%rdi
  call   <error@plt>
  mov    $0xffffffff,%r8d
  jmp    L174
  nopl   0x0(%rax)
L92:
  test   %rcx,%rcx
  je     L66
  cmpb   $0x0,0x76(%rsp)
  mov    %r11,%rax
  je     L67
  pxor   %xmm2,%xmm2
  nopl   0x0(%rax,%rax,1)
L181:
  movupd (%rbx,%rax,1),%xmm0
  movupd (%rax),%xmm6
  subpd  %xmm6,%xmm0
  movups %xmm0,(%rbx,%rax,1)
  add    $0x10,%rax
  movups %xmm2,-0x10(%rax)
  cmp    %rax,%r15
  jne    L181
  unpckhpd %xmm0,%xmm0
  cmp    0x60(%rsp),%rcx
  je     L316
  movsd  (%r12),%xmm0
  subsd  0x0(%rbp),%xmm0
  movsd  %xmm0,(%r12)
  movq   $0x0,0x0(%rbp)
  jmp    L316
  nopl   0x0(%rax,%rax,1)
L456:
  test   %rcx,%rcx
  je     L66
  cmpb   $0x0,0x76(%rsp)
  mov    %r11,%rax
  je     L12
  pxor   %xmm2,%xmm2
  nopl   0x0(%rax,%rax,1)
L476:
  movupd (%rbx,%rax,1),%xmm0
  movupd (%rax),%xmm7
  addpd  %xmm7,%xmm0
  movups %xmm0,(%rbx,%rax,1)
  add    $0x10,%rax
  movups %xmm2,-0x10(%rax)
  cmp    %rax,%r15
  jne    L476
  unpckhpd %xmm0,%xmm0
  cmp    0x60(%rsp),%rcx
  je     L316
  movsd  0x0(%rbp),%xmm0
  addsd  (%r12),%xmm0
  movsd  %xmm0,(%r12)
  movq   $0x0,0x0(%rbp)
  jmp    L316
  nopl   0x0(%rax,%rax,1)
L398:
  test   %rcx,%rcx
  je     L66
  cmpb   $0x0,0x76(%rsp)
  mov    %r11,%rax
  je     L133
  pxor   %xmm2,%xmm2
  nopl   0x0(%rax,%rax,1)
L214:
  movupd (%rbx,%rax,1),%xmm0
  movupd (%rax),%xmm4
  addpd  %xmm4,%xmm0
  movups %xmm0,(%rbx,%rax,1)
  add    $0x10,%rax
  movups %xmm2,-0x10(%rax)
  cmp    %rax,%r15
  jne    L214
  unpckhpd %xmm0,%xmm0
  cmp    0x60(%rsp),%rcx
  je     L316
  movsd  (%r12),%xmm0
  addsd  0x0(%rbp),%xmm0
  movsd  %xmm0,(%r12)
  movq   $0x0,0x0(%rbp)
  jmp    L316
  nopl   0x0(%rax,%rax,1)
L431:
  mov    0x70(%rsp),%esi
  lea    D49(%rip),%rdi
  mov    %eax,(%rsp)
  call   <error@plt>
  mov    (%rsp),%r8d
  jmp    L174
  nopl   0x0(%rax)
L67:
  mov    0x78(%rsp),%rdx
  nopl   (%rax)
L401:
  movsd  (%rbx,%rax,1),%xmm0
  subsd  (%rax),%xmm0
  movsd  %xmm0,(%rbx,%rax,1)
  add    $0x8,%rax
  movq   $0x0,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L401
  jmp    L316
  nopl   0x0(%rax)
L133:
  mov    0x78(%rsp),%rdx
  nopl   (%rax)
L144:
  movsd  (%rbx,%rax,1),%xmm0
  addsd  (%rax),%xmm0
  movsd  %xmm0,(%rbx,%rax,1)
  add    $0x8,%rax
  movq   $0x0,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L144
  jmp    L316
  nopl   0x0(%rax)
L12:
  mov    0x78(%rsp),%rdx
  nopl   (%rax)
L141:
  movsd  (%rbx,%rax,1),%xmm0
  addsd  (%rax),%xmm0
  movsd  %xmm0,(%rbx,%rax,1)
  add    $0x8,%rax
  movq   $0x0,-0x8(%rax)
  cmp    %rax,%rdx
  jne    L141
  jmp    L316
  nopl   0x0(%rax)
L275:
  mov    0x78(%rsp),%rdx
  nopl   (%rax)
L17:
  movsd  (%rbx,%rax,1),%xmm0
  mulsd  (%rax),%xmm0
  movsd  %xmm0,(%rbx,%rax,1)
  add    $0x8,%rax
  movq   $0x0,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L17
  jmp    L316
L263:
  mov    0x70(%rsp),%esi
  lea    D0(%rip),%rdi
  call   <error@plt>
  mov    $0xffffffff,%r8d
  jmp    L174
L484:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D40
data_type: f32[4]
name: unpack_data
arguments: data_label: D61
data_type: f32[4]
name: unpack_data
arguments: data_label: D77
data_type: string
name: unpack_data
arguments: data_label: D49
data_type: string
name: unpack_data
arguments: data_label: D0
data_type: string

tool: {"D40": [0.0,448.0,0.0,0.0]}

tool: {"D61": [0.0,-0.0,0.0,0.0]}

tool: D77: zero division!

tool: D49: simple_wav returned -1 inside composite_wav.

tool: D0: Unable to allocate memory for <out_temp> !

assistant: ```c
int composite_waveform(double **parsed_data, uint current_line, double *output, uint *index, uint N, double srate, double dt, int verbose) {
  uint i, Ni, line = 0, index_old, myindex, howmany;
  double *out_temp, *vector;
  int return_code;
  Ni = (uint)(parsed_data[current_line][0] * srate);
  out_temp = (double *)calloc(Ni, sizeof(double));
  if (out_temp == NULL) {
    error("Unable to allocate memory for <out_temp> !", verbose);
    return -1;
  }
  index_old = (*index);
  howmany = (uint)(-parsed_data[current_line][1]);
  for (line = 0; line < howmany; line++) {
    myindex = 0;
    vector = parsed_data[current_line + line];
    vector[1] = vector[9];
    return_code = simple_waveform(vector, out_temp, &myindex, Ni, srate, dt, verbose);
    if (return_code == -1) {
      error("simple_wav returned -1 inside composite_wav.", verbose);
      return -1;
    }
    (*index) = index_old;
    switch ((int)vector[10]) {
    case 1:
      for (i = 0; i < Ni; i++) {
        output[(*index)++] += out_temp[i];
        out_temp[i] = 0.;
      }
      break;
    case 2:
      for (i = 0; i < Ni; i++) {
        output[(*index)++] *= out_temp[i];
        out_temp[i] = 0.;
      }
      break;
    case 3:
      for (i = 0; i < Ni; i++) {
        output[(*index)++] -= out_temp[i];
        out_temp[i] = 0.;
      }
      break;
    case 4:
      for (i = 0; i < Ni; i++) {
        if (out_temp[i] == 0) {
          error("zero division!", verbose);
          return -1;
        }
        output[(*index)++] /= out_temp[i];
        out_temp[i] = 0.;
      }
      break;
    default:
      for (i = 0; i < Ni; i++) {
        output[(*index)++] += out_temp[i];
        out_temp[i] = 0.;
      }
      break;
    }
  }
  free(out_temp);
  return howmany;
}
```