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

```asm
<calculate_diffusion>:
  endbr64
  push   %r15
  mov    %rcx,%rax
  mov    %rdi,%r10
  push   %r14
  imul   %rcx,%rax
  mov    %rcx,%r14
  push   %r13
  push   %r12
  mov    %r9,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x48,%rsp
  mov    %r8,0x20(%rsp)
  mov    0x80(%rsp),%r13
  mov    %rax,0x10(%rsp)
  test   %rax,%rax
  je     L70
  lea    0x0(,%rax,8),%r15
  lea    (%rsi,%r15,1),%rax
  cmp    %rax,%rdx
  jae    L145
  lea    (%rdx,%r15,1),%rax
  cmp    %rax,%rsi
  jb     L127
L145:
  mov    %r15,%rdx
  xor    %esi,%esi
  mov    %rbx,%rdi
  mov    %r10,0x8(%rsp)
  call   <memset@plt>
  mov    %r15,%rdx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    0x8(%rsp),%r10
L70:
  cmpq   $0x0,0x20(%rsp)
  jle    L169
  cmp    $0x1,%r14
  jne    L71
  mov    0x20(%rsp),%rax
  lea    (%r10,%rax,8),%rcx
  nopl   0x0(%rax,%rax,1)
L42:
  mov    (%r12),%rax
  add    $0x8,%r10
  add    $0x1,%rax
  mov    %rax,(%r12)
  add    %rax,0x0(%r13)
  addq   $0x1,(%rbx)
  mov    -0x8(%r10),%rax
  movq   $0x0,(%rbx,%rax,8)
  mov    -0x8(%r10),%rax
  mov    (%rbx),%rdx
  add    %rdx,0x0(%rbp,%rax,8)
  cmp    %rcx,%r10
  jne    L42
L169:
  add    $0x48,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L127:
  xor    %eax,%eax
L181:
  movq   $0x0,(%rbx,%rax,8)
  movq   $0x0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    0x10(%rsp),%rax
  jne    L181
  jmp    L70
L71:
  mov    0x10(%rsp),%rdi
  mov    %r14,%r9
  mov    %r10,0x18(%rsp)
  lea    0x0(,%r14,8),%r15
  shr    %r9
  lea    -0x1(%r14),%rsi
  mov    %r12,0x38(%rsp)
  lea    (%r10,%r15,1),%r11
  mov    %rdi,%rax
  and    $0xfffffffffffffffe,%rdi
  shl    $0x4,%r9
  movq   $0x0,0x8(%rsp)
  shr    %rax
  mov    %rdi,0x30(%rsp)
  movdqa D6(%rip),%xmm1
  mov    %r14,%rdi
  shl    $0x4,%rax
  mov    %r13,0x80(%rsp)
  and    $0xfffffffffffffffe,%rdi
  mov    %rsi,%r13
  add    %rbx,%rax
  mov    %rax,%r12
L150:
  mov    0x38(%rsp),%rsi
  mov    (%rsi),%rax
  mov    %rax,0x28(%rsp)
  add    $0x1,%rax
  mov    %rax,(%rsi)
  mov    0x80(%rsp),%rsi
  add    %rax,(%rsi)
  mov    0x10(%rsp),%rax
  test   %rax,%rax
  je     L144
  cmp    $0x1,%rax
  je     L27
  mov    %rbx,%rax
  nopl   0x0(%rax)
L173:
  movdqu (%rax),%xmm0
  add    $0x10,%rax
  paddq  %xmm1,%xmm0
  movups %xmm0,-0x10(%rax)
  cmp    %r12,%rax
  jne    L173
  mov    0x30(%rsp),%rax
  cmp    %rax,0x10(%rsp)
  je     L144
L152:
  addq   $0x1,(%rbx,%rax,8)
L144:
  test   %r14,%r14
  jle    L121
  mov    0x18(%rsp),%rax
  xor    %edx,%edx
  xchg   %ax,%ax
L67:
  mov    (%rax),%rcx
  add    $0x8,%rax
  add    %rdx,%rcx
  add    %r14,%rdx
  movq   $0x0,(%rbx,%rcx,8)
  cmp    %r11,%rax
  jne    L67
  mov    0x18(%rsp),%r10
  mov    %rbx,%rsi
  xor    %r8d,%r8d
  nopl   (%rax)
L149:
  mov    (%r10),%rdx
  imul   %r14,%rdx
  lea    0x0(%rbp,%rdx,8),%rcx
  cmp    $0x1,%r13
  jbe    L178
  lea    0x8(%rsi),%rax
  cmp    %rax,%rcx
  je     L178
  xor    %eax,%eax
  nopl   (%rax)
L221:
  movdqu (%rsi,%rax,1),%xmm0
  movdqu (%rcx,%rax,1),%xmm2
  paddq  %xmm2,%xmm0
  movups %xmm0,(%rcx,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%r9
  jne    L221
  lea    (%rsi,%r15,1),%rcx
  cmp    %r14,%rdi
  je     L87
  lea    (%rdx,%rdi,1),%rax
  lea    (%r8,%rdi,1),%rdx
  mov    (%rbx,%rdx,8),%rdx
  add    %rdx,0x0(%rbp,%rax,8)
L87:
  add    $0x8,%r10
  mov    %rcx,%rsi
  add    %r14,%r8
  cmp    %r11,%r10
  jne    L149
L121:
  addq   $0x1,0x8(%rsp)
  add    %r15,%r11
  mov    0x8(%rsp),%rax
  add    %r15,0x18(%rsp)
  cmp    %rax,0x20(%rsp)
  jne    L150
  jmp    L169
  nop
L178:
  mov    %rcx,%rax
  lea    (%rsi,%r15,1),%rcx
  nopw   0x0(%rax,%rax,1)
L165:
  mov    (%rsi),%rdx
  add    $0x8,%rsi
  add    %rdx,(%rax)
  add    $0x8,%rax
  cmp    %rcx,%rsi
  jne    L165
  jmp    L87
L27:
  xor    %eax,%eax
  jmp    L152
```

tool_calls: name: extract_symbolic_data
arguments: tag: D6
type_guessed: byte[16]

tool: {"D6": [0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

assistant: ```c
int calculate_diffusion(long int *const paths, long int *diffusion, long int *rdiff, long int nreplicas, long int ntimes, long int *maxelapsed, long int *maxelapsed_cum) {
  long int p, p1, p2, r, t, i, telapsed;
  long int *positions;
  for (i = 0; i < nreplicas * nreplicas; ++i) {
    rdiff[i] = 0;
    diffusion[i] = 0;
  }
  for (t = 0; t < ntimes; ++t) {
    *maxelapsed += 1;
    *maxelapsed_cum += *maxelapsed;
    for (i = 0; i < nreplicas * nreplicas; ++i)
      rdiff[i] += 1;
    positions = &paths[t * nreplicas];
    for (r = 0; r < nreplicas; ++r) {
      p = positions[r];
      rdiff[r * nreplicas + p] = 0;
    }
    for (r = 0; r < nreplicas; ++r) {
      p1 = positions[r];
      for (p2 = 0; p2 < nreplicas; ++p2) {
        telapsed = rdiff[r * nreplicas + p2];
        diffusion[p1 * nreplicas + p2] += telapsed;
      }
    }
  }
  return 0;
}
```