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

```asm
<lhs_imp_dist>:
  endbr64
  push   %r15
  mov    %edi,%r15d
  push   %r14
  push   %r13
  mov    %edi,%r13d
  push   %r12
  imul   %esi,%r13d
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  lea    0x0(,%r13,4),%edi
  sub    $0xc8,%rsp
  mov    %edx,0x1c(%rsp)
  mov    %rcx,0xa0(%rsp)
  mov    %r8,0x80(%rsp)
  call   <malloc@plt>
  mov    %rax,0x88(%rsp)
  test   %rax,%rax
  je     L417
  mov    0x1c(%rsp),%ebp
  mov    %ebp,%r14d
  imul   %ebx,%r14d
  lea    0x0(,%r14,4),%edi
  call   <malloc@plt>
  mov    %rax,0x20(%rsp)
  test   %rax,%rax
  je     L417
  mov    %ebp,%edi
  imul   %r15d,%edi
  imul   %ebx,%edi
  shl    $0x2,%edi
  call   <malloc@plt>
  mov    %rax,0x90(%rsp)
  test   %rax,%rax
  je     L417
  pxor   %xmm0,%xmm0
  movsd  D56(%rip),%xmm1
  pxor   %xmm7,%xmm7
  cvtsi2sd %r15d,%xmm0
  cvtsi2sd %ebx,%xmm7
  divsd  %xmm0,%xmm1
  movapd %xmm7,%xmm0
  movsd  %xmm7,0x40(%rsp)
  call   <pow@plt>
  movsd  0x40(%rsp),%xmm7
  lea    -0x1(%rbx),%r9d
  divsd  %xmm0,%xmm7
  movsd  %xmm7,0x58(%rsp)
  test   %r15d,%r15d
  jle    L242
  mov    %r13d,%eax
  lea    -0x1(%r15),%edx
  mov    %r15d,0x8(%rsp)
  mov    0x80(%rsp),%rdi
  sub    %r15d,%eax
  mov    %r9d,%r15d
  cltq
  lea    (%rdi,%rax,8),%r12
  add    %rdx,%rax
  lea    0x8(%rdi,%rax,8),%rbp
L319:
  mov    0xa0(%rsp),%rdx
  mov    %ebx,%esi
  mov    $0x1,%edi
  add    $0x8,%r12
  call   <int_uniform@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  %xmm0,-0x8(%r12)
  cmp    %rbp,%r12
  jne    L319
  mov    %r15d,%r9d
  mov    0x8(%rsp),%r15d
  test   %ebx,%ebx
  jle    L174
L77:
  mov    0x88(%rsp),%rax
  xor    %esi,%esi
  xor    %edx,%edx
  lea    -0x1(%r15),%r8d
  lea    0x4(%rax),%rdi
L286:
  add    $0x1,%edx
  test   %r15d,%r15d
  jle    L298
  mov    0x88(%rsp),%rax
  movslq %esi,%rcx
  lea    (%rax,%rcx,4),%rax
  add    %r8,%rcx
  lea    (%rdi,%rcx,4),%rcx
  cs nopw 0x0(%rax,%rax,1)
L293:
  mov    %edx,(%rax)
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L293
L298:
  add    %r15d,%esi
  cmp    %edx,%ebx
  jne    L286
  test   %r15d,%r15d
  jle    L176
L174:
  mov    %r13d,%eax
  mov    0x80(%rsp),%rdi
  mov    %r15d,%esi
  xor    %edx,%edx
  sub    %r15d,%eax
  cltq
  lea    (%rdi,%rax,8),%rcx
L81:
  cvttsd2si (%rcx,%rdx,8),%eax
  mov    0x88(%rsp),%rdi
  sub    $0x1,%eax
  imul   %r15d,%eax
  add    %edx,%eax
  add    $0x1,%rdx
  cltq
  mov    %ebx,(%rdi,%rax,4)
  cmp    %rsi,%rdx
  jne    L81
L176:
  cmp    $0x1,%r9d
  jle    L69
  mov    0x1c(%rsp),%edi
  movslq %r15d,%rcx
  mov    %r9d,%r13d
  mov    %r15d,%ebp
  mov    %ebx,0x98(%rsp)
  lea    0x0(,%rcx,4),%r12
  mov    %edi,%eax
  sub    %edi,%r14d
  imul   %r9d,%eax
  mov    %r14d,0x38(%rsp)
  imul   %r15d,%edi
  sub    $0x1,%eax
  mov    %eax,0x3c(%rsp)
  imul   %r15d,%eax
  mov    %edi,0xa8(%rsp)
  mov    %eax,0x9c(%rsp)
  movslq %r9d,%rax
  shl    $0x2,%rax
  mov    %rax,0x68(%rsp)
  lea    -0x2(%rbx),%eax
  imul   %r15d,%eax
  mov    %eax,0x48(%rsp)
  mov    %r15d,%eax
  neg    %eax
  cltq
  shl    $0x2,%rax
  mov    %rax,0x70(%rsp)
  mov    0x90(%rsp),%rax
  neg    %rax
  add    %rax,%rax
  mov    %rax,0x78(%rsp)
L186:
  test   %ebp,%ebp
  jle    L394
  mov    0x88(%rsp),%rdi
  mov    %ebp,0x4c(%rsp)
  mov    %r13d,%r14d
  mov    0x90(%rsp),%rax
  movslq 0x9c(%rsp),%rdx
  movl   $0x0,0x8(%rsp)
  mov    %rdi,0x10(%rsp)
  mov    0xa0(%rsp),%r13
  sub    %rdi,%rax
  mov    0x20(%rsp),%rdi
  lea    (%rax,%rdx,4),%rax
  mov    %rax,0x60(%rsp)
  movslq 0x3c(%rsp),%rax
  lea    (%rdi,%rax,4),%rax
  mov    %rax,0x50(%rsp)
  nopw   0x0(%rax,%rax,1)
L56:
  mov    0x1c(%rsp),%ecx
  mov    0x20(%rsp),%r10
  xor    %edi,%edi
  test   %ecx,%ecx
  jle    L142
  mov    0x10(%rsp),%r8
  mov    0x68(%rsp),%r9
  mov    0x1c(%rsp),%r11d
  xchg   %ax,%ax
L126:
  mov    %r10,%rcx
  mov    %r8,%rdx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L257:
  mov    (%rdx),%esi
  add    $0x1,%eax
  add    %r12,%rdx
  add    $0x4,%rcx
  mov    %esi,-0x4(%rcx)
  cmp    %r14d,%eax
  jl     L257
  add    $0x1,%edi
  add    %r9,%r10
  cmp    %edi,%r11d
  jne    L126
L142:
  mov    0x3c(%rsp),%eax
  mov    0x10(%rsp),%rbx
  mov    0x50(%rsp),%rbp
  add    0x60(%rsp),%rbx
  mov    %eax,%r15d
  test   %eax,%eax
  js     L367
  mov    %r14d,0x28(%rsp)
  mov    %rbx,%r14
  mov    0x20(%rsp),%rbx
  mov    %r12,0x30(%rsp)
  mov    %rbp,%r12
  mov    0x70(%rsp),%rbp
  nopl   0x0(%rax,%rax,1)
L35:
  mov    %r13,%rdx
  mov    %r15d,%esi
  xor    %edi,%edi
  sub    $0x1,%r15d
  call   <int_uniform@plt>
  sub    $0x4,%r12
  cltq
  lea    (%rbx,%rax,4),%rax
  mov    (%rax),%edx
  mov    %edx,(%r14)
  mov    0x4(%r12),%edx
  add    %rbp,%r14
  mov    %edx,(%rax)
  cmp    $0xffffffff,%r15d
  jne    L35
  mov    0x28(%rsp),%r14d
  mov    0x30(%rsp),%r12
L367:
  addl   $0x1,0x8(%rsp)
  mov    0x8(%rsp),%eax
  addq   $0x4,0x10(%rsp)
  cmp    %eax,0x4c(%rsp)
  jne    L56
  mov    0x38(%rsp),%eax
  mov    0x4c(%rsp),%ebp
  mov    %r14d,%r13d
  test   %eax,%eax
  jle    L88
L197:
  mov    D20(%rip),%rax
  mov    %r12,0x8(%rsp)
  xor    %r8d,%r8d
  xor    %r11d,%r11d
  mov    0x90(%rsp),%r10
  mov    0x98(%rsp),%r15d
  xor    %ecx,%ecx
  mov    %r13d,%r9d
  mov    0x80(%rsp),%rdi
  movq   %rax,%xmm3
  nopw   0x0(%rax,%rax,1)
L4:
  cmp    %r9d,%r15d
  jle    L194
  mov    0x48(%rsp),%eax
  lea    -0x1(%rbp),%edx
  mov    %r9d,%r12d
  lea    0x0(%rbp,%rax,1),%r14d
  movslq %r8d,%rax
  add    %rax,%rdx
  lea    (%r10,%rax,4),%rsi
  neg    %rax
  lea    0x4(%r10,%rdx,4),%rbx
  mov    D20(%rip),%rdx
  movq   %rdx,%xmm2
  mov    0x78(%rsp),%rdx
  lea    (%rdx,%rax,8),%r13
  nopw   0x0(%rax,%rax,1)
L206:
  pxor   %xmm1,%xmm1
  test   %ebp,%ebp
  jle    L291
  movslq %r14d,%rax
  pxor   %xmm1,%xmm1
  lea    0x0(%r13,%rax,8),%rdx
  mov    %rsi,%rax
  add    %rdi,%rdx
  nopw   0x0(%rax,%rax,1)
L87:
  pxor   %xmm0,%xmm0
  cvtsi2sdl (%rax),%xmm0
  subsd  (%rdx,%rax,2),%xmm0
  add    $0x4,%rax
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  cmp    %rax,%rbx
  jne    L87
  pxor   %xmm4,%xmm4
  ucomisd %xmm1,%xmm4
  ja     L276
L291:
  sqrtsd %xmm1,%xmm1
L258:
  minsd  %xmm2,%xmm1
  add    $0x1,%r12d
  add    %ebp,%r14d
  movapd %xmm1,%xmm2
  cmp    %r12d,%r15d
  jne    L206
L172:
  subsd  0x58(%rsp),%xmm2
  andpd  D32(%rip),%xmm2
  comisd %xmm2,%xmm3
  minsd  %xmm3,%xmm2
  cmova  %r11d,%ecx
  movapd %xmm2,%xmm3
  add    $0x1,%r11d
  add    %ebp,%r8d
  cmp    0x38(%rsp),%r11d
  jl     L4
  mov    0x8(%rsp),%r12
  mov    %r9d,%r13d
  test   %ebp,%ebp
  jle    L292
  mov    %ecx,%eax
  imul   %ebp,%eax
L312:
  mov    0x90(%rsp),%rdi
  cltq
  lea    -0x1(%r13),%r8d
  lea    (%rdi,%rax,4),%rdx
  movslq 0x48(%rsp),%rax
  mov    0x80(%rsp),%rdi
  lea    (%rdi,%rax,8),%rsi
  xor    %eax,%eax
  xchg   %ax,%ax
L359:
  pxor   %xmm0,%xmm0
  add    $0x4,%rdx
  cvtsi2sdl -0x4(%rdx),%xmm0
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%ebp
  jg     L359
  mov    0x88(%rsp),%r11
  mov    0x48(%rsp),%ebx
  xor    %edi,%edi
  mov    0x98(%rsp),%ecx
  mov    0x80(%rsp),%r13
  mov    %r11,%r9
  nopw   0x0(%rax,%rax,1)
L3:
  test   %ecx,%ecx
  jle    L465
  lea    (%rdi,%rbx,1),%eax
  xor    %edx,%edx
  cltq
  movsd  0x0(%r13,%rax,8),%xmm1
  lea    (%r11,%rax,4),%r10
  mov    %r9,%rax
  nopl   0x0(%rax)
L399:
  pxor   %xmm0,%xmm0
  cvtsi2sdl (%rax),%xmm0
  ucomisd %xmm1,%xmm0
  jp     L112
  jne    L112
  mov    (%r10),%esi
  mov    %esi,(%rax)
L112:
  add    $0x1,%edx
  add    %r12,%rax
  cmp    %edx,%ecx
  jne    L399
L465:
  add    $0x1,%edi
  add    $0x4,%r9
  cmp    %edi,%ebp
  jg     L3
L202:
  mov    0x1c(%rsp),%edi
  subq   $0x4,0x68(%rsp)
  mov    %r8d,%r13d
  sub    %edi,0x38(%rsp)
  sub    %edi,0x3c(%rsp)
  mov    0xa8(%rsp),%edi
  sub    %ebp,0x48(%rsp)
  sub    %edi,0x9c(%rsp)
  cmp    $0x1,%r8d
  jne    L186
  mov    0x98(%rsp),%ebx
  mov    %ebp,%r15d
L69:
  test   %r15d,%r15d
  jle    L333
  mov    0x88(%rsp),%rdi
  mov    %r15d,%edx
  lea    (%rdi,%rdx,4),%rcx
  mov    %rdi,%rax
  neg    %rdi
  mov    %rdi,%rdx
  mov    0x80(%rsp),%rdi
  lea    (%rdi,%rdx,2),%rdx
L250:
  pxor   %xmm0,%xmm0
  cvtsi2sdl (%rax),%xmm0
  movsd  %xmm0,(%rdx,%rax,2)
  add    $0x4,%rax
  cmp    %rax,%rcx
  jne    L250
L333:
  test   %ebx,%ebx
  jle    L205
  mov    0x80(%rsp),%rax
  xor    %esi,%esi
  xor    %ecx,%ecx
  lea    -0x1(%r15),%r8d
  lea    0x8(%rax),%rdi
L352:
  test   %r15d,%r15d
  jle    L129
  mov    0x80(%rsp),%rax
  movslq %esi,%rdx
  lea    (%rax,%rdx,8),%rax
  add    %r8,%rdx
  lea    (%rdi,%rdx,8),%rdx
  nopw   0x0(%rax,%rax,1)
L239:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  divsd  0x40(%rsp),%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L239
L129:
  add    $0x1,%ecx
  add    %r15d,%esi
  cmp    %ecx,%ebx
  jne    L352
L205:
  mov    0x88(%rsp),%rdi
  call   <free@plt>
  mov    0x20(%rsp),%rdi
  call   <free@plt>
  mov    0x90(%rsp),%rdi
  add    $0xc8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10a0 <free@plt>
L417:
  add    $0xc8,%rsp
  lea    D4(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <tprintf@plt>
L194:
  mov    D20(%rip),%rax
  movq   %rax,%xmm2
  jmp    L172
L394:
  mov    0x38(%rsp),%edx
  test   %edx,%edx
  jg     L197
L292:
  lea    -0x1(%r13),%r8d
  jmp    L202
L88:
  xor    %eax,%eax
  jmp    L312
L276:
  movapd %xmm1,%xmm0
  mov    %rdi,0xb8(%rsp)
  mov    %rsi,0xb0(%rsp)
  mov    %r8d,0xac(%rsp)
  mov    %r11d,0x60(%rsp)
  mov    %ecx,0x50(%rsp)
  mov    %r9d,0x4c(%rsp)
  mov    %r10,0x30(%rsp)
  movsd  %xmm2,0x28(%rsp)
  movsd  %xmm3,0x10(%rsp)
  call   <sqrt@plt>
  mov    0x60(%rsp),%r11d
  mov    0x50(%rsp),%ecx
  mov    0x4c(%rsp),%r9d
  mov    0x30(%rsp),%r10
  movapd %xmm0,%xmm1
  mov    0xb8(%rsp),%rdi
  mov    0xb0(%rsp),%rsi
  mov    0xac(%rsp),%r8d
  movsd  0x28(%rsp),%xmm2
  movsd  0x10(%rsp),%xmm3
  jmp    L258
L242:
  test   %ebx,%ebx
  jg     L77
  jmp    L176
```

tool_calls: name: retrieve_data
arguments: data_label: D56
type_infered: f64
name: retrieve_data
arguments: data_label: D20
type_infered: f64
name: retrieve_data
arguments: data_label: D32
type_infered: qword[2]
name: retrieve_data
arguments: data_label: D4
type_infered: string

tool: D56: 1

tool: D20: 1e+30

tool: {"D32": [0x7fffffffffffffff,0x0000000000000000]}

tool: D4: Not enough memory!


assistant: ```c
void lhs_imp_dist(int nvar, int npoint, int d, int *seed, double x_int[]) {
  int *avail, best, count, i, j, k, *list, *point, point_index;
  double dist, min_all, min_can, opt;
  if ((avail = (int *)malloc(nvar * npoint * sizeof(int))) == NULL) {
    tprintf("Not enough memory!\n");
    return;
  }
  if ((list = (int *)malloc(d * npoint * sizeof(int))) == NULL) {
    tprintf("Not enough memory!\n");
    return;
  }
  if ((point = (int *)malloc(nvar * d * npoint * sizeof(int))) == NULL) {
    tprintf("Not enough memory!\n");
    return;
  }
  opt = ((double)npoint) / pow((double)npoint, (double)(1.0 / (double)nvar));
  for (i = 0; i < nvar; i++)
    x_int[i + (npoint - 1) * nvar] = (double)int_uniform(1, npoint, seed);
  for (j = 0; j < npoint; j++)
    for (i = 0; i < nvar; i++)
      avail[i + j * nvar] = j + 1;
  for (i = 0; i < nvar; i++)
    avail[i + (((int)x_int[i + (npoint - 1) * nvar]) - 1) * nvar] = npoint;
  for (count = npoint - 1; 2 <= count; count--) {
    for (i = 0; i < nvar; i++) {
      for (k = 0; k < d; k++)
        for (j = 0; j < count; j++)
          list[j + k * count] = avail[i + j * nvar];
      for (k = count * d - 1; 0 <= k; k--) {
        point_index = int_uniform(0, k, seed);
        point[i + k * nvar] = list[point_index];
        list[point_index] = list[k];
      }
    }
    min_all = 1e30;
    best = 0;
    for (k = 0; k < d * count; k++) {
      min_can = 1e30;
      for (j = count; j < npoint; j++) {
        dist = 0.0;
        for (i = 0; i < nvar; i++)
          dist += (point[i + k * nvar] - x_int[i + j * nvar]) * (point[i + k * nvar] - x_int[i + j * nvar]);
        dist = sqrt(dist);
        if (dist < min_can)
          min_can = dist;
      }
      if (fabs(min_can - opt) < min_all) {
        min_all = fabs(min_can - opt);
        best = k;
      }
    }
    for (i = 0; i < nvar; i++)
      x_int[i + (count - 1) * nvar] = point[i + best * nvar];
    for (i = 0; i < nvar; i++)
      for (j = 0; j < npoint; j++)
        if (avail[i + j * nvar] == x_int[i + (count - 1) * nvar])
          avail[i + j * nvar] = avail[i + (count - 1) * nvar];
  }
  for (i = 0; i < nvar; i++)
    x_int[i + 0 * nvar] = avail[i + 0 * nvar];
  for (j = 0; j < npoint; j++)
    for (i = 0; i < nvar; i++)
      x_int[i + j * nvar] /= (double)npoint;
  free(avail);
  free(list);
  free(point);
}
```