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

```asm
<colavg>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  movss  %xmm0,-0x4c(%rbp)
  mov    %rcx,-0x58(%rbp)
  mov    %r8d,-0x50(%rbp)
  movsd  %xmm1,-0x60(%rbp)
  movsd  %xmm2,-0x68(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L1
L26:
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movq   %rax,%xmm0
  call   <calc_density@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movq   %rax,%xmm0
  call   <calc_density@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x20(%rbp)
  movsd  -0x28(%rbp),%xmm1
  movsd  D6(%rip),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movsd  -0x20(%rbp),%xmm1
  movsd  D6(%rip),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x20(%rbp)
  pxor   %xmm0,%xmm0
  cvtsd2ss -0x60(%rbp),%xmm0
  movss  %xmm0,-0x2c(%rbp)
  cmpl   $0x0,-0x30(%rbp)
  jne    L22
  pxor   %xmm0,%xmm0
  cvtsd2ss -0x68(%rbp),%xmm0
  movss  %xmm0,-0x2c(%rbp)
L22:
  pxor   %xmm2,%xmm2
  cvtss2sd -0x4c(%rbp),%xmm2
  movsd  D10(%rip),%xmm0
  movapd %xmm0,%xmm1
  subsd  %xmm2,%xmm1
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm0,%xmm1
  pxor   %xmm0,%xmm0
  cvtss2sd -0x2c(%rbp),%xmm0
  mulsd  %xmm1,%xmm0
  movapd %xmm0,%xmm1
  mulsd  -0x28(%rbp),%xmm1
  pxor   %xmm2,%xmm2
  cvtss2sd -0x4c(%rbp),%xmm2
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm0,%xmm2
  pxor   %xmm0,%xmm0
  cvtss2sd -0x2c(%rbp),%xmm0
  mulsd  %xmm2,%xmm0
  mulsd  -0x20(%rbp),%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm3,%xmm3
  cvtss2sd -0x4c(%rbp),%xmm3
  movsd  D10(%rip),%xmm1
  movapd %xmm1,%xmm2
  subsd  %xmm3,%xmm2
  pxor   %xmm1,%xmm1
  cvtss2sd -0x2c(%rbp),%xmm1
  mulsd  %xmm2,%xmm1
  movapd %xmm1,%xmm2
  mulsd  -0x28(%rbp),%xmm2
  movss  -0x4c(%rbp),%xmm1
  mulss  -0x2c(%rbp),%xmm1
  cvtss2sd %xmm1,%xmm1
  mulsd  -0x20(%rbp),%xmm1
  addsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x18(%rbp)
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  -0x18(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x30(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x58(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rbx
  movq   %rax,%xmm0
  call   <calc_density@plt>
  movq   %xmm0,%rax
  mov    %rax,(%rbx)
  addl   $0x1,-0x30(%rbp)
L1:
  mov    -0x30(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jl     L26
  nop
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D6
type: f64
name: extract_symbolic_data
arguments: data_tag: D10
type: f64

tool: D6: 1000

tool: D10: 1

assistant: ```c
void colavg(double *finaltemp, double *T, double *Ti, float lakeprv, double *density, int numnod, double dz, double surfdz) {
  int j;
  double water_densityw, water_densityi;
  double temp;
  float z;
  for (j = 0; j < numnod; j++) {
    water_densityw = calc_density(T[j]);
    water_densityi = calc_density(Ti[j]);
    water_densityw = water_densityw + 1000.;
    water_densityi = water_densityi + 1000.;
    z = dz;
    if (j == 0)
      z = surfdz;
    temp = ((1. - lakeprv) * T[j] * z * water_densityw + lakeprv * Ti[j] * z * water_densityi) / ((1. - lakeprv) * z * water_densityw + lakeprv * z * water_densityi);
    finaltemp[j] = temp;
    density[j] = calc_density(finaltemp[j]);
  }
}
```