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

```asm
<crypto_scalarmult_curve25519_ref>:
  endbr64
  push   %r13
  pxor   %xmm3,%xmm3
  pxor   %xmm0,%xmm0
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x1b8,%rsp
  movdqu (%rdx),%xmm1
  movdqu 0x10(%rsi),%xmm6
  mov    %fs:0x28,%rax
  mov    %rax,0x1a8(%rsp)
  xor    %eax,%eax
  movdqu (%rsi),%xmm5
  mov    %rsp,%r13
  lea    0x80(%rsp),%r12
  movdqa %xmm1,%xmm2
  punpckhbw %xmm3,%xmm1
  movaps %xmm6,0x190(%rsp)
  movzbl 0x19f(%rsp),%eax
  punpcklbw %xmm3,%xmm2
  lea    0x180(%rsp),%rsi
  mov    %r13,%rdi
  movaps %xmm5,0x180(%rsp)
  movdqa %xmm2,%xmm4
  punpckhwd %xmm0,%xmm2
  and    $0x7f,%eax
  andb   $0xf8,0x180(%rsp)
  movaps %xmm2,0x10(%rsp)
  movdqa %xmm1,%xmm2
  punpckhwd %xmm0,%xmm1
  punpcklwd %xmm0,%xmm4
  movaps %xmm1,0x30(%rsp)
  movdqu 0x10(%rdx),%xmm1
  punpcklwd %xmm0,%xmm2
  or     $0x40,%eax
  movaps %xmm2,0x20(%rsp)
  lea    0x100(%rsp),%rbp
  movdqa %xmm1,%xmm2
  punpckhbw %xmm3,%xmm1
  movaps %xmm4,(%rsp)
  punpcklbw %xmm3,%xmm2
  mov    %al,0x19f(%rsp)
  movdqa %xmm2,%xmm3
  punpckhwd %xmm0,%xmm2
  movaps %xmm2,0x50(%rsp)
  movdqa %xmm1,%xmm2
  punpcklwd %xmm0,%xmm3
  punpckhwd %xmm0,%xmm1
  punpcklwd %xmm0,%xmm2
  movaps %xmm3,0x40(%rsp)
  movaps %xmm2,0x60(%rsp)
  movaps %xmm1,0x70(%rsp)
  call   <mainloop@plt>
  mov    %r12,%rsi
  mov    %r12,%rdi
  call   <recip@plt>
  mov    %r12,%rdx
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <mult@plt>
  mov    %rbp,%rdi
  call   <freeze@plt>
  movdqa 0x100(%rsp),%xmm0
  movdqa %xmm0,%xmm1
  punpcklwd 0x110(%rsp),%xmm0
  punpckhwd 0x110(%rsp),%xmm1
  movdqa %xmm0,%xmm2
  punpcklwd %xmm1,%xmm0
  punpckhwd %xmm1,%xmm2
  movdqa 0x120(%rsp),%xmm1
  punpcklwd %xmm2,%xmm0
  movdqa %xmm1,%xmm2
  punpcklwd 0x130(%rsp),%xmm1
  punpckhwd 0x130(%rsp),%xmm2
  movdqa %xmm1,%xmm3
  punpcklwd %xmm2,%xmm1
  punpckhwd %xmm2,%xmm3
  movdqa D7(%rip),%xmm2
  punpcklwd %xmm3,%xmm1
  pand   %xmm2,%xmm1
  pand   %xmm2,%xmm0
  packuswb %xmm1,%xmm0
  movups %xmm0,(%rbx)
  movdqa 0x140(%rsp),%xmm0
  movdqa %xmm0,%xmm1
  punpcklwd 0x150(%rsp),%xmm0
  punpckhwd 0x150(%rsp),%xmm1
  movdqa %xmm0,%xmm3
  punpcklwd %xmm1,%xmm0
  punpckhwd %xmm1,%xmm3
  movdqa 0x160(%rsp),%xmm1
  punpcklwd %xmm3,%xmm0
  movdqa %xmm1,%xmm3
  pand   %xmm2,%xmm0
  punpcklwd 0x170(%rsp),%xmm1
  punpckhwd 0x170(%rsp),%xmm3
  movdqa %xmm1,%xmm4
  punpckhwd %xmm3,%xmm4
  punpcklwd %xmm3,%xmm1
  punpcklwd %xmm4,%xmm1
  pand   %xmm1,%xmm2
  packuswb %xmm2,%xmm0
  movups %xmm0,0x10(%rbx)
  mov    0x1a8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x1b8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D7
datatype: byte[16]

tool: {"D7": [0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00]}

assistant: ```c
int crypto_scalarmult_curve25519_ref(unsigned char *q, const unsigned char *n, const unsigned char *p) {
  unsigned int work[96];
  unsigned char e[32];
  unsigned int i;
  for (i = 0; i < 32; ++i)
    e[i] = n[i];
  e[0] &= 248;
  e[31] &= 127;
  e[31] |= 64;
  for (i = 0; i < 32; ++i)
    work[i] = p[i];
  mainloop(work, e);
  recip(work + 32, work + 32);
  mult(work + 64, work, work + 32);
  freeze(work + 64);
  for (i = 0; i < 32; ++i)
    q[i] = work[64 + i];
  return 0;
}
```