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

```asm
<find_cals>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  mov    %ecx,-0x34(%rbp)
  mov    %r8,-0x40(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L13
L79:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  pxor   %xmm0,%xmm0
  movss  %xmm0,(%rax)
  movl   $0x0,-0x14(%rbp)
  jmp    L94
L64:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm1
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  mov    -0x14(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cltd
  idivl  -0x30(%rbp)
  mov    %edx,%eax
  cltq
  shl    $0x2,%rax
  add    %rcx,%rax
  movss  (%rax),%xmm0
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  addss  %xmm1,%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x14(%rbp)
L94:
  mov    -0x30(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  cmp    %eax,-0x14(%rbp)
  jl     L64
  mov    -0x30(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x10(%rbp)
  jmp    L69
L31:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  mov    -0x10(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %edx,%eax
  cltd
  idivl  -0x30(%rbp)
  mov    %edx,%eax
  cltq
  shl    $0x2,%rax
  add    %rcx,%rax
  movss  (%rax),%xmm1
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  subss  %xmm1,%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x10(%rbp)
L69:
  mov    -0x10(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jl     L31
  addl   $0x1,-0x18(%rbp)
L13:
  mov    -0x18(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L79
  pxor   %xmm0,%xmm0
  movss  %xmm0,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L17
L45:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  movss  -0xc(%rbp),%xmm1
  addss  %xmm1,%xmm0
  movss  %xmm0,-0xc(%rbp)
  addl   $0x1,-0x8(%rbp)
L17:
  mov    -0x8(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L45
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x2c(%rbp),%xmm1
  movss  -0xc(%rbp),%xmm0
  divss  %xmm1,%xmm0
  movss  %xmm0,-0xc(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L98
L12:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  divss  -0xc(%rbp),%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x4(%rbp)
L98:
  mov    -0x4(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L12
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void find_cals(float **tot, int nchan, int period, int phase, float *cal) {
  for (int i = 0; i < nchan; i++) {
    cal[i] = 0;
    for (int j = 0; j < period / 2; j++)
      cal[i] += tot[i][(j + phase) % period];
    for (int j = period / 2; j < period; j++)
      cal[i] -= tot[i][(j + phase) % period];
  }
  float norm = 0;
  for (int i = 0; i < nchan; i++)
    norm += cal[i];
  norm /= nchan;
  for (int i = 0; i < nchan; i++)
    cal[i] /= norm;
}
```