user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<ComputeFirstMoment4D>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r15
  mov    %rdx,-0x18(%rsp)
  mov    %rcx,-0x28(%rsp)
  mov    %r8,-0x48(%rsp)
  mov    %r9d,-0x50(%rsp)
  cmpl   $0x0,0x8(%r8)
  jle    L143
  mov    %r9d,%ebx
  neg    %ebx
  mov    %ebx,%r14d
  mov    %ebx,-0x20(%rsp)
  mov    %ebx,-0x2c(%rsp)
  mov    %r9d,%ebx
  lea    0x2(%r9,%r9,1),%eax
  imul   %r9d,%eax
  movl   $0x0,-0x58(%rsp)
  add    $0x1,%ebx
  mov    %ebx,-0x34(%rsp)
  lea    0x1(%rax,%rax,1),%eax
  mov    %eax,-0xc(%rsp)
  mov    %rdi,-0x8(%rsp)
  mov    %rsi,%r15
  jmp    L126
L4:
  mov    -0x2c(%rsp),%ebx
  cmp    %ebx,-0x50(%rsp)
  jl     L295
  mov    -0x48(%rsp),%rbx
  mov    0x4(%rbx),%eax
  mov    %eax,-0x30(%rsp)
  mov    0x8(%rbx),%r8d
  lea    (%r8,%r8,1),%r10d
  mov    %eax,%r9d
  imul   %r12d,%r9d
  mov    -0x38(%rsp),%ebx
  mov    %ebx,-0x4c(%rsp)
  pxor   %xmm0,%xmm0
  movl   $0x0,-0x3c(%rsp)
  lea    -0x1(%rax,%rax,1),%eax
  mov    %eax,-0x1c(%rsp)
  lea    -0x1(%r12,%r12,1),%ebx
L171:
  mov    -0x4c(%rsp),%edi
  mov    %edi,%eax
  neg    %eax
  cmovs  %edi,%eax
  mov    -0x1c(%rsp),%edx
  sub    %eax,%edx
  mov    -0x40(%rsp),%r11d
  sub    -0x50(%rsp),%r11d
  cmp    %eax,-0x30(%rsp)
  cmovle %edx,%eax
  imul   %r12d,%eax
  mov    %eax,%edi
L293:
  mov    %r11d,%ecx
  neg    %ecx
  cmovs  %r11d,%ecx
  mov    %ebx,%eax
  sub    %ecx,%eax
  cmp    %r12d,%ecx
  cmovge %eax,%ecx
  mov    %r14d,%edx
L105:
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  mov    %r10d,%esi
  sub    %eax,%esi
  sub    $0x1,%esi
  cmp    %r8d,%eax
  cmovge %esi,%eax
  imul   %r9d,%eax
  add    %edi,%eax
  add    %ecx,%eax
  cltq
  addss  (%r15,%rax,4),%xmm0
  add    $0x1,%edx
  cmp    %r13d,%edx
  jne    L105
  add    $0x1,%r11d
  cmp    %ebp,%r11d
  jne    L293
  mov    -0xc(%rsp),%edi
  add    %edi,-0x3c(%rsp)
  addl   $0x1,-0x4c(%rsp)
  mov    -0x4c(%rsp),%eax
  cmp    -0x10(%rsp),%eax
  jne    L171
L73:
  mov    -0x48(%rsp),%rdi
  mov    %r12d,%eax
  imul   0x4(%rdi),%eax
  imul   -0x58(%rsp),%eax
  imul   -0x54(%rsp),%r12d
  add    %r12d,%eax
  mov    -0x40(%rsp),%ebx
  add    %ebx,%eax
  cltq
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x3c(%rsp),%xmm1
  divss  %xmm1,%xmm0
  mov    -0x28(%rsp),%rsi
  movss  %xmm0,(%rsi,%rax,4)
  add    $0x1,%ebx
  mov    %ebx,-0x40(%rsp)
  mov    (%rdi),%r12d
  add    $0x1,%ebp
  cmp    %ebx,%r12d
  jg     L4
L69:
  addl   $0x1,-0x54(%rsp)
  mov    -0x54(%rsp),%eax
  addl   $0x1,-0x38(%rsp)
  mov    -0x48(%rsp),%rbx
  cmp    %eax,0x4(%rbx)
  jle    L131
L207:
  mov    -0x48(%rsp),%rax
  mov    (%rax),%r12d
  mov    -0x34(%rsp),%ebx
  mov    %ebx,%ebp
  movl   $0x0,-0x40(%rsp)
  mov    -0x54(%rsp),%eax
  add    %ebx,%eax
  mov    %eax,-0x10(%rsp)
  test   %r12d,%r12d
  jg     L4
  jmp    L69
L295:
  pxor   %xmm0,%xmm0
  movl   $0x0,-0x3c(%rsp)
  jmp    L73
L131:
  addl   $0x1,-0x58(%rsp)
  mov    -0x58(%rsp),%eax
  add    $0x1,%r14d
  mov    -0x48(%rsp),%rbx
  cmp    %eax,0x8(%rbx)
  jle    L219
L126:
  mov    -0x20(%rsp),%eax
  mov    %eax,-0x38(%rsp)
  movl   $0x0,-0x54(%rsp)
  mov    -0x58(%rsp),%r13d
  add    -0x34(%rsp),%r13d
  mov    -0x48(%rsp),%rax
  cmpl   $0x0,0x4(%rax)
  jg     L207
  jmp    L131
L219:
  mov    -0x8(%rsp),%r15
L143:
  mov    -0x48(%rsp),%rax
  cmpl   $0x0,0xc(%rax)
  jle    L208
  mov    -0x50(%rsp),%eax
  mov    %eax,%ebx
  neg    %ebx
  mov    %ebx,-0x10(%rsp)
  mov    %eax,%ebx
  lea    0x2(%rax,%rax,1),%eax
  imul   %ebx,%eax
  movl   $0x0,-0x20(%rsp)
  add    $0x1,%ebx
  mov    %ebx,-0x1c(%rsp)
  lea    0x1(%rax,%rax,1),%eax
  mov    %eax,-0x30(%rsp)
  jmp    L39
L35:
  mov    -0x50(%rsp),%ebx
  mov    -0x10(%rsp),%eax
  cmp    %eax,%ebx
  jl     L309
  mov    -0x48(%rsp),%rdi
  mov    0x4(%rdi),%eax
  mov    %eax,-0x3c(%rsp)
  mov    0x8(%rdi),%r9d
  lea    (%r9,%r9,1),%r11d
  mov    %eax,%r10d
  imul   %r12d,%r10d
  mov    %r9d,%r8d
  imul   %r10d,%r8d
  imul   -0x20(%rsp),%r8d
  mov    -0x2c(%rsp),%edi
  sub    %ebx,%edi
  mov    %edi,-0x54(%rsp)
  pxor   %xmm0,%xmm0
  movl   $0x0,-0x40(%rsp)
  lea    -0x1(%rax,%rax,1),%eax
  mov    %eax,-0x38(%rsp)
  lea    -0x1(%r12,%r12,1),%eax
  mov    %eax,-0x58(%rsp)
L14:
  mov    -0x54(%rsp),%ebx
  mov    %ebx,%eax
  neg    %eax
  cmovs  %ebx,%eax
  mov    -0x38(%rsp),%edx
  sub    %eax,%edx
  mov    -0x4c(%rsp),%ebx
  sub    -0x50(%rsp),%ebx
  cmp    -0x3c(%rsp),%eax
  mov    %edx,%edi
  cmovl  %eax,%edi
  imul   %r12d,%edi
L53:
  mov    %ebx,%eax
  neg    %eax
  cmovs  %ebx,%eax
  mov    -0x58(%rsp),%esi
  sub    %eax,%esi
  cmp    %r12d,%eax
  cmovl  %eax,%esi
  mov    %r15d,%edx
L185:
  mov    %edx,%eax
  neg    %eax
  cmovs  %edx,%eax
  mov    %r11d,%ecx
  sub    %eax,%ecx
  sub    $0x1,%ecx
  cmp    %eax,%r9d
  cmovle %ecx,%eax
  imul   %r10d,%eax
  add    %edi,%eax
  add    %esi,%eax
  add    %r8d,%eax
  cltq
  addss  (%r14,%rax,4),%xmm0
  add    $0x1,%edx
  cmp    %r13d,%edx
  jne    L185
  add    $0x1,%ebx
  cmp    %ebp,%ebx
  jne    L53
  mov    -0x30(%rsp),%ebx
  add    %ebx,-0x40(%rsp)
  addl   $0x1,-0x54(%rsp)
  mov    -0x54(%rsp),%eax
  cmp    -0x34(%rsp),%eax
  jne    L14
L84:
  mov    -0x48(%rsp),%rdi
  mov    %r12d,%edx
  imul   0x4(%rdi),%edx
  mov    -0x28(%rsp),%eax
  imul   %edx,%eax
  imul   -0x2c(%rsp),%r12d
  add    %r12d,%eax
  mov    -0x4c(%rsp),%ebx
  add    %ebx,%eax
  imul   0x8(%rdi),%edx
  imul   -0x20(%rsp),%edx
  add    %edx,%eax
  cltq
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x40(%rsp),%xmm1
  divss  %xmm1,%xmm0
  mov    -0x18(%rsp),%rsi
  movss  %xmm0,(%rsi,%rax,4)
  add    $0x1,%ebx
  mov    %ebx,-0x4c(%rsp)
  mov    (%rdi),%r12d
  add    $0x1,%ebp
  cmp    %ebx,%r12d
  jg     L35
L142:
  addl   $0x1,-0x2c(%rsp)
  mov    -0x2c(%rsp),%eax
  mov    -0x48(%rsp),%rbx
  cmp    %eax,0x4(%rbx)
  jle    L214
L213:
  mov    -0x48(%rsp),%rax
  mov    (%rax),%r12d
  mov    -0x1c(%rsp),%eax
  mov    %eax,%ebp
  movl   $0x0,-0x4c(%rsp)
  add    -0x2c(%rsp),%eax
  mov    %eax,-0x34(%rsp)
  test   %r12d,%r12d
  jg     L35
  jmp    L142
L309:
  pxor   %xmm0,%xmm0
  movl   $0x0,-0x40(%rsp)
  jmp    L84
L214:
  addl   $0x1,-0x28(%rsp)
  mov    -0x28(%rsp),%eax
  add    $0x1,%r15d
  mov    -0x48(%rsp),%rbx
  cmp    %eax,0x8(%rbx)
  jle    L198
L125:
  movl   $0x0,-0x2c(%rsp)
  mov    -0x28(%rsp),%r13d
  add    -0x1c(%rsp),%r13d
  mov    -0x48(%rsp),%rax
  cmpl   $0x0,0x4(%rax)
  jg     L213
  jmp    L214
L198:
  mov    %r14,%r15
L10:
  addl   $0x1,-0x20(%rsp)
  mov    -0x20(%rsp),%eax
  mov    -0x48(%rsp),%rbx
  cmp    %eax,0xc(%rbx)
  jle    L208
L39:
  mov    -0x48(%rsp),%rax
  cmpl   $0x0,0x8(%rax)
  jle    L10
  mov    -0x50(%rsp),%r14d
  neg    %r14d
  movl   $0x0,-0x28(%rsp)
  mov    %r15,%rax
  mov    %r14d,%r15d
  mov    %rax,%r14
  jmp    L125
L208:
  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;
        }
      }
    }
  }
}
```