user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<grid_search_nn>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  mov    %r9,%r14
  push   %r13
  mov    %r8,%r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  lea    0x68(%rsp),%rbp
  lea    0x60(%rsp),%rbx
  mov    %rsi,0x10(%rsp)
  movsd  %xmm0,0x8(%rsp)
  mov    %rbx,%rsi
  movapd %xmm1,%xmm0
  mov    %rbp,%rdi
  mov    %rdx,0x50(%rsp)
  call   <sincos@plt>
  movsd  0x60(%rsp),%xmm7
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  movsd  0x8(%rsp),%xmm2
  movsd  %xmm7,0x20(%rsp)
  movsd  0x68(%rsp),%xmm7
  movapd %xmm2,%xmm0
  movsd  %xmm7,0x28(%rsp)
  call   <sincos@plt>
  movsd  0x60(%rsp),%xmm7
  mov    0x10(%rsp),%rax
  movsd  D7(%rip),%xmm0
  movsd  %xmm7,0x30(%rsp)
  movsd  0x68(%rsp),%xmm7
  movsd  %xmm0,(%r12)
  movsd  %xmm7,0x38(%rsp)
  movsd  %xmm0,0x8(%r12)
  movsd  %xmm0,0x10(%r12)
  movsd  %xmm0,0x18(%r12)
  cmp    %rax,%r15
  jg     L46
  add    $0x1,%rax
  mov    %r12,0x40(%rsp)
  mov    %r13,%r12
  movl   $0x0,0x48(%rsp)
  mov    %rax,%r13
  movsd  %xmm0,0x18(%rsp)
  jmp    L37
  nopl   0x0(%rax)
L82:
  add    $0x1,%r15
  cmp    %r15,%r13
  je     L54
L37:
  movsd  (%r12,%r15,8),%xmm0
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <sincos@plt>
  movsd  0x60(%rsp),%xmm2
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  movsd  0x68(%rsp),%xmm1
  movsd  (%r14,%r15,8),%xmm0
  movsd  %xmm2,0x10(%rsp)
  movsd  %xmm1,0x8(%rsp)
  call   <sincos@plt>
  movsd  0x20(%rsp),%xmm0
  movsd  0x28(%rsp),%xmm3
  mulsd  0x60(%rsp),%xmm0
  movsd  0x10(%rsp),%xmm2
  mulsd  0x68(%rsp),%xmm3
  movsd  0x8(%rsp),%xmm1
  mulsd  0x30(%rsp),%xmm2
  mulsd  0x38(%rsp),%xmm1
  addsd  %xmm3,%xmm0
  mulsd  %xmm2,%xmm0
  addsd  %xmm1,%xmm0
  call   <acos@plt>
  movsd  0x18(%rsp),%xmm6
  comisd %xmm0,%xmm6
  jbe    L82
  mov    0x40(%rsp),%r8
  xor    %ecx,%ecx
  movsd  (%r8),%xmm1
  comisd %xmm0,%xmm1
  ja     L40
L9:
  add    $0x1,%rcx
  add    $0x8,%r8
  cmp    $0x4,%rcx
  je     L82
  movsd  (%r8),%xmm1
  comisd %xmm0,%xmm1
  jbe    L9
L40:
  cmp    $0x3,%rcx
  je     L85
  lea    0x1(%rcx),%r10
  mov    0x50(%rsp),%rdi
  mov    $0x3,%r11d
  mov    %r8,0x58(%rsp)
  sub    %rcx,%r11
  lea    0x0(,%r10,4),%rax
  mov    %rcx,0x18(%rsp)
  lea    0x0(,%r11,4),%rdx
  lea    -0x4(%rdi,%rax,1),%rsi
  add    %rax,%rdi
  movsd  %xmm0,0x48(%rsp)
  mov    %r10,0x10(%rsp)
  mov    %r11,0x8(%rsp)
  call   <memmove@plt>
  mov    0x10(%rsp),%r10
  mov    0x40(%rsp),%rax
  mov    0x8(%rsp),%r11
  shl    $0x3,%r10
  lea    0x0(,%r11,8),%rdx
  lea    -0x8(%rax,%r10,1),%rsi
  lea    (%rax,%r10,1),%rdi
  call   <memmove@plt>
  mov    0x18(%rsp),%rcx
  movsd  0x48(%rsp),%xmm0
  mov    0x58(%rsp),%r8
L85:
  mov    0x50(%rsp),%rax
  movsd  %xmm0,(%r8)
  movl   $0xffffffff,0x48(%rsp)
  mov    %r15d,(%rax,%rcx,4)
  mov    0x40(%rsp),%rax
  add    $0x1,%r15
  movsd  0x18(%rax),%xmm7
  movsd  %xmm7,0x18(%rsp)
  cmp    %r15,%r13
  jne    L37
  cs nopw 0x0(%rax,%rax,1)
L54:
  mov    0x40(%rsp),%r12
  movsd  (%r12),%xmm0
L28:
  movsd  D15(%rip),%xmm3
  mov    %r12,%rax
  lea    0x20(%r12),%rcx
  mov    %r12,%rdx
  movsd  D18(%rip),%xmm2
L35:
  addsd  %xmm3,%xmm0
  movapd %xmm2,%xmm1
  add    $0x8,%rdx
  divsd  %xmm0,%xmm1
  movsd  %xmm1,-0x8(%rdx)
  cmp    %rcx,%rdx
  je     L8
  movsd  (%rdx),%xmm0
  jmp    L35
  cs nopw 0x0(%rax,%rax,1)
L8:
  pxor   %xmm1,%xmm1
  addsd  (%r12),%xmm1
  addsd  0x8(%r12),%xmm1
  addsd  0x10(%r12),%xmm1
  addsd  0x18(%r12),%xmm1
L127:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rcx
  jne    L127
  mov    0x48(%rsp),%eax
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L46:
  movl   $0x0,0x48(%rsp)
  jmp    L28
```

tool_calls: name: retrieve_data
arguments: tag: D7
type_guessed: byte[8]
name: retrieve_data
arguments: tag: D15
type_guessed: byte[8]
name: retrieve_data
arguments: tag: D18
type_guessed: f64

tool: {"D7": [0x40,0x8c,0xb5,0x78,0x1d,0xaf,0x15,0x44]}

tool: {"D15": [0x9b,0x2b,0xa1,0x86,0x9b,0x84,0x06,0x3d]}

tool: D18: 1

assistant: ```c
int grid_search_nn(long min_add, long max_add, int *restrict nbr_add, double *restrict nbr_dist, double plat, double plon, const double *restrict src_center_lat, const double *restrict src_center_lon) {
  int search_result = 0;
  long n, srch_add;
  long i;
  double dist_min, distance;
  double coslat_dst = cos(plat);
  double sinlat_dst = sin(plat);
  double coslon_dst = cos(plon);
  double sinlon_dst = sin(plon);
  dist_min = 1.e+20;
  for (n = 0; n < 4; ++n)
    nbr_dist[n] = 1.e+20;
  for (srch_add = min_add; srch_add <= max_add; ++srch_add) {
    distance = acos(coslat_dst * cos(src_center_lat[srch_add]) * (coslon_dst * cos(src_center_lon[srch_add]) + sinlon_dst * sin(src_center_lon[srch_add])) + sinlat_dst * sin(src_center_lat[srch_add]));
    if (distance < dist_min) {
      for (n = 0; n < 4; ++n) {
        if (distance < nbr_dist[n]) {
          for (i = 3; i > n; --i) {
            nbr_add[i] = nbr_add[i - 1];
            nbr_dist[i] = nbr_dist[i - 1];
          }
          search_result = -1;
          nbr_add[n] = srch_add;
          nbr_dist[n] = distance;
          dist_min = nbr_dist[3];
          break;
        }
      }
    }
  }
  for (n = 0; n < 4; ++n)
    nbr_dist[n] = 1.0 / (nbr_dist[n] + 1.e-14);
  distance = 0.0;
  for (n = 0; n < 4; ++n)
    distance += nbr_dist[n];
  for (n = 0; n < 4; ++n)
    nbr_dist[n] /= distance;
  return (search_result);
}
```