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

```asm
<CkNNStochasticProximityEmbedding>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r12
  push   %rbx
  sub    $0xa0,%rsp
  mov    %rdi,-0x88(%rbp)
  mov    %rsi,-0x90(%rbp)
  mov    %edx,-0x94(%rbp)
  mov    %ecx,-0x98(%rbp)
  mov    %r8d,-0x9c(%rbp)
  movsd  %xmm0,-0xa8(%rbp)
  movsd  %xmm1,-0xb0(%rbp)
  mov    %r9d,-0xa0(%rbp)
  movl   $0x0,-0x60(%rbp)
  movl   $0x0,-0x5c(%rbp)
  movl   $0x0,-0x58(%rbp)
  movl   $0x0,-0x54(%rbp)
  movl   $0x0,-0x50(%rbp)
  movl   $0x0,-0x4c(%rbp)
  movl   $0x0,-0x48(%rbp)
  movl   $0x0,-0x44(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x38(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x30(%rbp)
  movsd  -0xa8(%rbp),%xmm0
  movsd  %xmm0,-0x40(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x28(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x20(%rbp)
  mov    $0x0,%edi
  call   <time@plt>
  mov    %rax,%r12
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %eax,%ebx
  mov    $0x0,%eax
  call   <getpid@plt>
  imul   %ebx,%eax
  cltq
  add    %r12,%rax
  mov    %rax,%rdi
  call   <srand@plt>
  mov    -0x94(%rbp),%edx
  mov    -0x98(%rbp),%ecx
  mov    -0x88(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <nearest_neighbours@plt>
  mov    %rax,-0x18(%rbp)
  movl   $0x0,-0x74(%rbp)
  jmp    L138
L35:
  mov    $0x0,%eax
  call   <rand@plt>
  mov    %eax,%edx
  mov    -0x74(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x90(%rbp),%rax
  add    %rcx,%rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x74(%rbp)
L138:
  mov    -0x98(%rbp),%eax
  imul   -0x9c(%rbp),%eax
  cmp    %eax,-0x74(%rbp)
  jl     L35
  movl   $0x0,-0x70(%rbp)
  jmp    L48
L8:
  movl   $0x0,-0x6c(%rbp)
  jmp    L105
L29:
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idivl  -0x98(%rbp)
  mov    %edx,-0x60(%rbp)
  mov    -0x94(%rbp),%eax
  mov    %eax,-0x68(%rbp)
  jmp    L75
L15:
  mov    -0x68(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x5c(%rbp)
  mov    -0x9c(%rbp),%ecx
  mov    -0x5c(%rbp),%edx
  mov    -0x60(%rbp),%esi
  mov    -0x90(%rbp),%rax
  mov    %rax,%rdi
  call   <ed@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x5c(%rbp),%edx
  mov    -0x60(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <trmIndex@plt>
  lea    0x0(,%rax,8),%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x30(%rbp)
  movsd  -0x38(%rbp),%xmm0
  comisd -0x30(%rbp),%xmm0
  jbe    L77
  mov    -0x60(%rbp),%eax
  imul   -0x9c(%rbp),%eax
  mov    %eax,-0x54(%rbp)
  mov    -0x5c(%rbp),%eax
  imul   -0x9c(%rbp),%eax
  mov    %eax,-0x50(%rbp)
  movsd  -0x40(%rbp),%xmm1
  movsd  D25(%rip),%xmm0
  mulsd  %xmm0,%xmm1
  movsd  -0x30(%rbp),%xmm0
  subsd  -0x38(%rbp),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  -0x38(%rbp),%xmm2
  movsd  D22(%rip),%xmm1
  addsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movl   $0x0,-0x64(%rbp)
  jmp    L109
L135:
  mov    -0x54(%rbp),%edx
  mov    -0x64(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4c(%rbp)
  mov    -0x50(%rbp),%edx
  mov    -0x64(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x48(%rbp)
  mov    -0x4c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x4c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x48(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm2
  subsd  %xmm2,%xmm0
  mulsd  -0x28(%rbp),%xmm0
  mov    -0x4c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x48(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x48(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x4c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm2
  subsd  %xmm2,%xmm0
  mulsd  -0x28(%rbp),%xmm0
  mov    -0x48(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x64(%rbp)
L109:
  mov    -0x64(%rbp),%eax
  cmp    -0x9c(%rbp),%eax
  jl     L135
L77:
  addl   $0x1,-0x68(%rbp)
L75:
  mov    -0x60(%rbp),%eax
  add    $0x1,%eax
  imul   -0x94(%rbp),%eax
  cmp    %eax,-0x68(%rbp)
  jl     L15
  addl   $0x1,-0x6c(%rbp)
L105:
  mov    -0x6c(%rbp),%eax
  cmp    0x10(%rbp),%eax
  jl     L29
  mov    -0x70(%rbp),%eax
  cltd
  idivl  0x18(%rbp)
  mov    %edx,%eax
  test   %eax,%eax
  jne    L52
  cmpl   $0x0,-0x70(%rbp)
  je     L52
  cmpl   $0x0,0x18(%rbp)
  jle    L52
  mov    -0x98(%rbp),%ecx
  mov    -0x9c(%rbp),%edx
  mov    -0x90(%rbp),%rsi
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <stress@plt>
  movq   %xmm0,%rax
  movsd  -0x40(%rbp),%xmm0
  mov    -0x70(%rbp),%edx
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  mov    %edx,%esi
  lea    D16(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L52:
  movsd  -0xa8(%rbp),%xmm0
  subsd  -0xb0(%rbp),%xmm0
  mov    -0xa0(%rbp),%eax
  sub    $0x1,%eax
  pxor   %xmm2,%xmm2
  cvtsi2sd %eax,%xmm2
  movapd %xmm0,%xmm1
  divsd  %xmm2,%xmm1
  movsd  -0x40(%rbp),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x40(%rbp)
  addl   $0x1,-0x70(%rbp)
L48:
  mov    -0x70(%rbp),%eax
  cmp    -0xa0(%rbp),%eax
  jl     L8
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x98(%rbp),%ecx
  mov    -0x9c(%rbp),%edx
  mov    -0x90(%rbp),%rsi
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <stress@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  add    $0xa0,%rsp
  pop    %rbx
  pop    %r12
  pop    %rbp
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D25
type_infered: f64
name: disassemble_data
arguments: tag: D22
type_infered: byte[8]
name: disassemble_data
arguments: tag: D16
type_infered: string

tool: D25: 0.5

tool: {"D22": [0x3a,0x8c,0x30,0xe2,0x8e,0x79,0x45,0x3e]}

tool: D16: Cycle %d - Residual stress: %.3f, lambda %.3f


assistant: ```c
double CkNNStochasticProximityEmbedding(double *s, double *d_coords, int kn, int nelem, int dim, double maxlam, double minlam, int ncycle, int nstep, int stressfreq) {
  int *tmp;
  int *neighbours;
  int a = 0, b = 0, idx = 0, idxa = 0, idxb = 0, idxak = 0, idxbk = 0, idxab = 0;
  double dab = 0.0, rab = 0.0;
  double lam = maxlam;
  double t = 0.0;
  double finalstress = 0.0;
  srand(time(NULL) + getpid() * getpid());
  neighbours = nearest_neighbours(s, nelem, kn);
  for (int i = 0; i < nelem * dim; i++) {
    d_coords[i] = (double)rand();
  }
  for (int i = 0; i < ncycle; i++) {
    for (int j = 0; j < nstep; j++) {
      a = rand() % nelem;
      for (int k = kn; k < (a + 1) * kn; k++) {
        b = neighbours[k];
        dab = ed(d_coords, a, b, dim);
        rab = s[trmIndex(a, b)];
        if (dab > rab) {
          idxa = a * dim;
          idxb = b * dim;
          t = lam * 0.5 * (rab - dab) / (dab + 1e-8);
          for (int k = 0; k < dim; k++) {
            idxak = idxa + k;
            idxbk = idxb + k;
            d_coords[idxak] = d_coords[idxak] + t * (d_coords[idxak] - d_coords[idxbk]);
            d_coords[idxbk] = d_coords[idxbk] + t * (d_coords[idxbk] - d_coords[idxak]);
          }
        }
      }
    }
    if (i % stressfreq == 0 && i != 0 && stressfreq > 0)
      printf("Cycle %d - Residual stress: %.3f, lambda %.3f\n", i, stress(s, d_coords, dim, nelem), lam);
    lam = lam - (maxlam - minlam) / (double)(ncycle - 1);
  }
  free(neighbours);
  return (stress(s, d_coords, dim, nelem));
}
```