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

```asm
<distance_to_hclip>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x78,%rsp
  mov    %r8,0x28(%rsp)
  lea    0x48(%rsp),%rdx
  lea    0x4c(%rsp),%rcx
  movss  %xmm0,0x1c(%rsp)
  lea    0x44(%rsp),%rsi
  sub    $0x8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x70(%rsp)
  xor    %eax,%eax
  lea    0x60(%rsp),%rax
  push   %rax
  lea    0x64(%rsp),%r9
  lea    0x60(%rsp),%r8
  call   <vis5d_get_sizePRIME@plt>
  pxor   %xmm4,%xmm4
  pxor   %xmm5,%xmm5
  movss  D8(%rip),%xmm3
  cvtsi2ss %r12d,%xmm4
  cvtsi2ss %ebx,%xmm5
  mov    $0x1,%ebx
  lea    -0x1(%rbx),%r13d
  movss  %xmm4,0x1c(%rsp)
  movss  %xmm5,0x28(%rsp)
  pop    %rax
  pop    %rdx
  lea    0x3c(%rsp),%rax
  movss  0x1c(%rsp),%xmm2
  lea    0x5c(%rsp),%r12
  movss  %xmm3,0x8(%rsp)
  mov    %rax,0x10(%rsp)
  lea    0x64(%rsp),%r9
  lea    0x60(%rsp),%r15
  lea    0x40(%rsp),%r14
  cmp    $0x3,%ebx
  je     L100
L82:
  cmp    $0x3,%r13d
  je     L89
  cmp    $0x1,%r13d
  je     L71
  mov    0x48(%rsp),%eax
  pxor   %xmm1,%xmm1
  pxor   %xmm0,%xmm0
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r15,%r8
  mov    %r12,%rcx
  mov    %ebp,%edi
  sub    $0x1,%eax
  mov    %r9,0x20(%rsp)
  cvtsi2ss %eax,%xmm1
  movss  %xmm2,0x1c(%rsp)
  call   <vis5d_gridPRIME_to_xyzPRIME@plt>
  mov    0x10(%rsp),%rdx
  mov    %r14,%rcx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <vis5d_project@plt>
  movss  0x3c(%rsp),%xmm0
  mov    0x20(%rsp),%r9
  subss  0xc(%rsp),%xmm0
  movss  0x40(%rsp),%xmm1
  subss  0x18(%rsp),%xmm1
  movss  0x8(%rsp),%xmm4
  movss  0x1c(%rsp),%xmm2
  mulss  %xmm0,%xmm0
  mulss  %xmm1,%xmm1
  addss  %xmm1,%xmm0
  comiss %xmm0,%xmm4
  jae    L5
  nopw   0x0(%rax,%rax,1)
L48:
  cmp    $0x4,%ebx
  je     L1
L62:
  add    $0x1,%ebx
  lea    -0x1(%rbx),%r13d
  cmp    $0x3,%ebx
  jne    L82
L100:
  mov    0x44(%rsp),%eax
  pxor   %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  sub    $0x1,%eax
  cvtsi2ss %eax,%xmm0
  jmp    L34
  cs nopw 0x0(%rax,%rax,1)
L71:
  mov    0x44(%rsp),%eax
  pxor   %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  sub    $0x1,%eax
  cvtsi2ss %eax,%xmm0
  mov    0x48(%rsp),%eax
  sub    $0x1,%eax
  cvtsi2ss %eax,%xmm1
L34:
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r15,%r8
  mov    %r12,%rcx
  mov    %ebp,%edi
  mov    %r9,0x20(%rsp)
  movss  %xmm2,0x1c(%rsp)
  call   <vis5d_gridPRIME_to_xyzPRIME@plt>
  mov    0x10(%rsp),%rdx
  mov    %r14,%rcx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <vis5d_project@plt>
  movss  0x3c(%rsp),%xmm0
  mov    0x20(%rsp),%r9
  subss  0xc(%rsp),%xmm0
  movss  0x40(%rsp),%xmm1
  subss  0x18(%rsp),%xmm1
  movss  0x8(%rsp),%xmm6
  movss  0x1c(%rsp),%xmm2
  mulss  %xmm0,%xmm0
  mulss  %xmm1,%xmm1
  addss  %xmm1,%xmm0
  comiss %xmm0,%xmm6
  jb     L62
L5:
  mov    0x28(%rsp),%rax
  movss  %xmm0,0x8(%rsp)
  mov    %r13d,(%rax)
  jmp    L48
  nopl   (%rax)
L89:
  pxor   %xmm1,%xmm1
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r15,%r8
  movaps %xmm1,%xmm0
  mov    %r12,%rcx
  mov    %ebp,%edi
  mov    %r9,0x20(%rsp)
  movss  %xmm2,0x1c(%rsp)
  call   <vis5d_gridPRIME_to_xyzPRIME@plt>
  mov    0x10(%rsp),%rdx
  mov    %r14,%rcx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <vis5d_project@plt>
  movss  0x3c(%rsp),%xmm0
  mov    0x20(%rsp),%r9
  subss  0xc(%rsp),%xmm0
  movss  0x40(%rsp),%xmm1
  subss  0x18(%rsp),%xmm1
  movss  0x8(%rsp),%xmm3
  movss  0x1c(%rsp),%xmm2
  mulss  %xmm0,%xmm0
  mulss  %xmm1,%xmm1
  addss  %xmm1,%xmm0
  comiss %xmm0,%xmm3
  jae    L5
L1:
  movss  0x8(%rsp),%xmm3
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L9
  add    $0x78,%rsp
  movaps %xmm3,%xmm0
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L9:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D8
datatype: f32

tool: D8: 1000000

assistant: ```c
float distance_to_hclip(int index, int curx, int cury, int num, float level, int *corner) {
  float cx, cy, px, py;
  float dist, neardist, p[3];
  float r, c;
  int i;
  int Nr, Nc, Nl, LowLev, MaxNlVar, WindNl, WindLow;
  vis5d_get_sizePRIME(index, &Nr, &Nc, &Nl, &LowLev, &WindNl, &WindLow);
  neardist = 1000000.0;
  cx = (float)curx;
  cy = (float)cury;
  for (i = 0; i < 4; i++) {
    switch (i) {
    case 0:
      r = 0.0;
      c = (float)(Nc - 1);
      break;
    case 1:
      r = (float)(Nr - 1);
      c = (float)(Nc - 1);
      break;
    case 2:
      r = (float)(Nr - 1);
      c = 0.0;
      break;
    case 3:
      r = 0.0;
      c = 0.0;
      break;
    }
    vis5d_gridPRIME_to_xyzPRIME(index, 0, 0, r, c, level, &p[0], &p[1], &p[2]);
    vis5d_project(index, p, &px, &py);
    dist = (px - cx) * (px - cx) + (py - cy) * (py - cy);
    if (dist <= neardist) {
      neardist = dist;
      *corner = i;
    }
  }
  return neardist;
}
```