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

```asm
<ComputeFirstMoment4D>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    0x8(%r8),%r15d
  mov    %rdx,-0x18(%rsp)
  mov    %rcx,-0x28(%rsp)
  mov    %r8,-0x40(%rsp)
  mov    %r9d,-0x60(%rsp)
  test   %r15d,%r15d
  jle    L164
  mov    %r9d,%eax
  mov    %r15d,%edi
  neg    %r9d
  mov    0x4(%r8),%ebx
  lea    (%rax,%rax,1),%edx
  mov    %r9d,%r12d
  sub    %eax,%edi
  mov    %r9d,-0x38(%rsp)
  mov    %eax,%r9d
  lea    0x1(%rdx),%eax
  mov    %ebx,-0x5c(%rsp)
  lea    (%r15,%r15,1),%r14d
  mov    %eax,-0x58(%rsp)
  lea    0x2(%r9,%r9,1),%eax
  mov    %rsi,%rbp
  imul   %edx,%eax
  mov    %edi,-0x2c(%rsp)
  mov    %r13,-0x8(%rsp)
  mov    %r14d,%r13d
  mov    %r12d,%r14d
  add    $0x1,%eax
  mov    %eax,-0x10(%rsp)
  lea    -0x1(%rbx,%rbx,1),%eax
  mov    %eax,-0xc(%rsp)
L26:
  mov    -0x5c(%rsp),%edi
  test   %edi,%edi
  jle    L214
  mov    -0x40(%rsp),%rax
  mov    %edi,%r11d
  mov    -0x60(%rsp),%esi
  mov    (%rax),%ebx
  lea    (%r14,%rsi,1),%eax
  sub    %esi,%edi
  mov    %edi,-0x34(%rsp)
  imul   %ebx,%r11d
  lea    -0x1(%rbx,%rbx,1),%r12d
  imul   %r11d,%eax
  mov    %eax,-0x54(%rsp)
  mov    -0x58(%rsp),%eax
  lea    (%rax,%r14,1),%r10d
  mov    -0x38(%rsp),%eax
  mov    %eax,-0x78(%rsp)
  lea    -0x1(%rbx),%eax
  mov    %eax,-0x20(%rsp)
L204:
  test   %ebx,%ebx
  jle    L72
  mov    -0x60(%rsp),%eax
  mov    -0x28(%rsp),%rdi
  movq   $0x0,-0x70(%rsp)
  lea    0x1(%rax),%r9d
  mov    -0x20(%rsp),%eax
  mov    %rax,-0x48(%rsp)
  mov    -0x58(%rsp),%eax
  add    -0x78(%rsp),%eax
  mov    %eax,-0x30(%rsp)
  movslq -0x54(%rsp),%rax
  lea    (%rdi,%rax,4),%rax
  mov    %rax,-0x50(%rsp)
L188:
  mov    -0x78(%rsp),%eax
  pxor   %xmm0,%xmm0
  movl   $0x0,-0x68(%rsp)
  mov    -0x38(%rsp),%edi
  movaps %xmm0,%xmm1
  mov    %eax,-0x74(%rsp)
  cmp    %edi,-0x60(%rsp)
  jl     L3
L110:
  mov    -0x74(%rsp),%edi
  mov    -0xc(%rsp),%edx
  mov    -0x70(%rsp),%r8d
  mov    %edi,%eax
  neg    %eax
  cmovs  %edi,%eax
  sub    %eax,%edx
  cmp    -0x5c(%rsp),%eax
  cmovge %edx,%eax
  sub    -0x60(%rsp),%r8d
  imul   %ebx,%eax
  mov    %eax,%edi
L159:
  mov    %r8d,%ecx
  mov    %r12d,%eax
  mov    %r14d,%edx
  neg    %ecx
  cmovs  %r8d,%ecx
  sub    %ecx,%eax
  cmp    %ebx,%ecx
  cmovge %eax,%ecx
  cs nopw 0x0(%rax,%rax,1)
L15:
  mov    %edx,%eax
  mov    %r13d,%esi
  neg    %eax
  cmovs  %edx,%eax
  sub    %eax,%esi
  sub    $0x1,%esi
  cmp    %r15d,%eax
  cmovge %esi,%eax
  add    $0x1,%edx
  imul   %r11d,%eax
  add    %edi,%eax
  add    %ecx,%eax
  cltq
  addss  0x0(%rbp,%rax,4),%xmm0
  cmp    %r10d,%edx
  jne    L15
  add    $0x1,%r8d
  cmp    %r9d,%r8d
  jne    L159
  addl   $0x1,-0x74(%rsp)
  mov    -0x10(%rsp),%edi
  mov    -0x74(%rsp),%eax
  add    %edi,-0x68(%rsp)
  cmp    -0x30(%rsp),%eax
  jne    L110
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x68(%rsp),%xmm1
L3:
  divss  %xmm1,%xmm0
  mov    -0x50(%rsp),%rax
  mov    -0x70(%rsp),%rdi
  add    $0x1,%r9d
  movss  %xmm0,(%rax,%rdi,4)
  lea    0x1(%rdi),%rax
  cmp    -0x48(%rsp),%rdi
  je     L72
  mov    %rax,-0x70(%rsp)
  jmp    L188
L72:
  addl   $0x1,-0x78(%rsp)
  mov    -0x78(%rsp),%eax
  add    %ebx,-0x54(%rsp)
  cmp    -0x34(%rsp),%eax
  jne    L204
L214:
  add    $0x1,%r14d
  cmp    -0x2c(%rsp),%r14d
  jne    L26
  mov    -0x8(%rsp),%r13
L164:
  mov    -0x40(%rsp),%rax
  mov    0xc(%rax),%eax
  mov    %eax,-0x2c(%rsp)
  test   %eax,%eax
  jle    L236
  mov    -0x60(%rsp),%eax
  mov    %r15d,%edi
  movl   $0x0,-0x48(%rsp)
  lea    (%r15,%r15,1),%r14d
  mov    %eax,%ebx
  lea    (%rax,%rax,1),%edx
  neg    %ebx
  mov    %ebx,-0x30(%rsp)
  mov    %eax,%ebx
  lea    0x1(%rdx),%eax
  mov    %eax,-0x10(%rsp)
  lea    0x2(%rbx,%rbx,1),%eax
  sub    %ebx,%edi
  imul   %edx,%eax
  mov    %edi,-0x8(%rsp)
  add    $0x1,%eax
  mov    %eax,-0x38(%rsp)
  mov    %r15d,%eax
  mov    %r14d,%r15d
  mov    %eax,%r14d
L12:
  test   %r14d,%r14d
  jle    L195
  mov    -0x40(%rsp),%rax
  mov    -0x30(%rsp),%r12d
  mov    0x4(%rax),%eax
  mov    %eax,-0x70(%rsp)
  lea    -0x1(%rax,%rax,1),%eax
  mov    %eax,-0x54(%rsp)
L100:
  mov    -0x70(%rsp),%eax
  test   %eax,%eax
  jle    L235
  mov    -0x40(%rsp),%rbx
  mov    -0x60(%rsp),%edi
  mov    %r14d,%r8d
  movl   $0x0,-0x50(%rsp)
  mov    (%rbx),%ebx
  imul   %ebx,%eax
  imul   %eax,%r8d
  mov    %eax,%ebp
  lea    (%r12,%rdi,1),%eax
  imul   %ebp,%eax
  imul   -0x48(%rsp),%r8d
  mov    %eax,-0x34(%rsp)
  mov    -0x10(%rsp),%eax
  lea    (%r12,%rax,1),%r9d
  lea    0x1(%rdi),%eax
  mov    %eax,-0xc(%rsp)
  lea    -0x1(%rbx,%rbx,1),%eax
  mov    %eax,-0x78(%rsp)
L56:
  test   %ebx,%ebx
  jle    L38
  lea    -0x1(%rbx),%eax
  movslq -0x34(%rsp),%rdx
  mov    -0x18(%rsp),%rdi
  movq   $0x0,-0x68(%rsp)
  mov    %rax,-0x28(%rsp)
  movslq %r8d,%rax
  add    %rdx,%rax
  lea    (%rdi,%rax,4),%rax
  mov    -0x50(%rsp),%edi
  mov    %rax,-0x20(%rsp)
  mov    -0xc(%rsp),%eax
  mov    %eax,%r11d
  add    %edi,%eax
  mov    %eax,-0x58(%rsp)
L53:
  mov    -0x50(%rsp),%eax
  mov    -0x60(%rsp),%edi
  pxor   %xmm0,%xmm0
  movl   $0x0,-0x5c(%rsp)
  movaps %xmm0,%xmm1
  sub    %edi,%eax
  mov    %eax,-0x74(%rsp)
  mov    -0x30(%rsp),%eax
  cmp    %eax,%edi
  jl     L140
  nopl   0x0(%rax,%rax,1)
L225:
  mov    -0x74(%rsp),%edi
  mov    -0x54(%rsp),%edx
  mov    -0x68(%rsp),%r10d
  mov    %edi,%eax
  neg    %eax
  cmovs  %edi,%eax
  sub    %eax,%edx
  cmp    -0x70(%rsp),%eax
  mov    %edx,%edi
  cmovl  %eax,%edi
  sub    -0x60(%rsp),%r10d
  imul   %ebx,%edi
  nopw   0x0(%rax,%rax,1)
L202:
  mov    %r10d,%esi
  mov    -0x78(%rsp),%eax
  mov    %r12d,%edx
  neg    %esi
  cmovs  %r10d,%esi
  sub    %esi,%eax
  cmp    %esi,%ebx
  cmovle %eax,%esi
  nopw   0x0(%rax,%rax,1)
L161:
  mov    %edx,%eax
  mov    %r15d,%ecx
  neg    %eax
  cmovs  %edx,%eax
  sub    %eax,%ecx
  sub    $0x1,%ecx
  cmp    %r14d,%eax
  cmovge %ecx,%eax
  add    $0x1,%edx
  imul   %ebp,%eax
  add    %edi,%eax
  add    %esi,%eax
  add    %r8d,%eax
  cltq
  addss  0x0(%r13,%rax,4),%xmm0
  cmp    %r9d,%edx
  jne    L161
  add    $0x1,%r10d
  cmp    %r10d,%r11d
  jne    L202
  addl   $0x1,-0x74(%rsp)
  mov    -0x38(%rsp),%edi
  mov    -0x74(%rsp),%eax
  add    %edi,-0x5c(%rsp)
  cmp    %eax,-0x58(%rsp)
  jne    L225
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x5c(%rsp),%xmm1
L140:
  divss  %xmm1,%xmm0
  mov    -0x20(%rsp),%rax
  mov    -0x68(%rsp),%rdi
  add    $0x1,%r11d
  movss  %xmm0,(%rax,%rdi,4)
  lea    0x1(%rdi),%rax
  cmp    %rdi,-0x28(%rsp)
  je     L38
  mov    %rax,-0x68(%rsp)
  jmp    L53
L38:
  addl   $0x1,-0x50(%rsp)
  mov    -0x50(%rsp),%eax
  add    %ebx,-0x34(%rsp)
  cmp    -0x70(%rsp),%eax
  jne    L56
L235:
  add    $0x1,%r12d
  cmp    %r12d,-0x8(%rsp)
  jne    L100
L195:
  addl   $0x1,-0x48(%rsp)
  mov    -0x48(%rsp),%eax
  cmp    %eax,-0x2c(%rsp)
  jne    L12
L236:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void ComputeFirstMoment4D(float *ima, float *atlas, float *means, float *Ameans, const int *dims, int f) {
  int indice = 0;
  int i, j, k, t;
  int ii, jj, kk;
  int ni, nj, nk;
  float mean = 0.0;
  float Amean = 0.0;
  for (k = 0; k < dims[2]; k++) {
    for (i = 0; i < dims[1]; i++) {
      for (j = 0; j < dims[0]; j++) {
        Amean = 0;
        indice = 0;
        for (ii = -f; ii <= f; ii++) {
          for (jj = -f; jj <= f; jj++) {
            for (kk = -f; kk <= f; kk++) {
              ni = i + ii;
              nj = j + jj;
              nk = k + kk;
              if (ni < 0)
                ni = -ni;
              if (nj < 0)
                nj = -nj;
              if (nk < 0)
                nk = -nk;
              if (ni >= dims[1])
                ni = 2 * dims[1] - ni - 1;
              if (nj >= dims[0])
                nj = 2 * dims[0] - nj - 1;
              if (nk >= dims[2])
                nk = 2 * dims[2] - nk - 1;
              Amean = Amean + atlas[nk * (dims[0] * dims[1]) + (ni * dims[0]) + nj];
              indice = indice + 1;
            }
          }
        }
        Amean = Amean / indice;
        Ameans[k * (dims[0] * dims[1]) + (i * dims[0]) + j] = Amean;
      }
    }
  }
  for (t = 0; t < dims[3]; t++) {
    for (k = 0; k < dims[2]; k++) {
      for (i = 0; i < dims[1]; i++) {
        for (j = 0; j < dims[0]; j++) {
          mean = 0;
          indice = 0;
          for (ii = -f; ii <= f; ii++) {
            for (jj = -f; jj <= f; jj++) {
              for (kk = -f; kk <= f; kk++) {
                ni = i + ii;
                nj = j + jj;
                nk = k + kk;
                if (ni < 0)
                  ni = -ni;
                if (nj < 0)
                  nj = -nj;
                if (nk < 0)
                  nk = -nk;
                if (ni >= dims[1])
                  ni = 2 * dims[1] - ni - 1;
                if (nj >= dims[0])
                  nj = 2 * dims[0] - nj - 1;
                if (nk >= dims[2])
                  nk = 2 * dims[2] - nk - 1;
                mean = mean + ima[t * (dims[0] * dims[1] * dims[2]) + (nk * (dims[0] * dims[1]) + (ni * dims[0]) + nj)];
                indice = indice + 1;
              }
            }
          }
          mean = mean / indice;
          means[t * (dims[0] * dims[1] * dims[2]) + (k * (dims[0] * dims[1]) + (i * dims[0]) + j)] = mean;
        }
      }
    }
  }
}
```