user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<grid_search_nn>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,%rbx
  mov    %rsi,(%rsp)
  mov    %rdx,0x40(%rsp)
  mov    %rcx,%r14
  movsd  %xmm0,0x8(%rsp)
  movapd %xmm1,%xmm0
  mov    %r8,%r12
  mov    %r9,%r15
  lea    0x58(%rsp),%r13
  lea    0x50(%rsp),%rbp
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <sincos@plt>
  movsd  0x50(%rsp),%xmm4
  movsd  %xmm4,0x28(%rsp)
  movsd  0x58(%rsp),%xmm5
  movsd  %xmm5,0x30(%rsp)
  mov    %rbp,%rsi
  mov    %r13,%rdi
  movsd  0x8(%rsp),%xmm0
  call   <sincos@plt>
  movsd  0x50(%rsp),%xmm7
  movsd  %xmm7,0x18(%rsp)
  movsd  0x58(%rsp),%xmm4
  movsd  %xmm4,0x20(%rsp)
  movsd  D24(%rip),%xmm0
  movsd  %xmm0,(%r14)
  movsd  %xmm0,0x8(%r14)
  movsd  %xmm0,0x10(%r14)
  movsd  %xmm0,0x18(%r14)
  mov    (%rsp),%rax
  cmp    %rax,%rbx
  jg     L70
  add    $0x1,%rax
  mov    %rax,0x38(%rsp)
  movsd  %xmm0,0x10(%rsp)
  movl   $0x0,0x4c(%rsp)
  mov    %r13,%rbp
  jmp    L22
L104:
  cmp    $0x2,%rax
  jg     L109
  mov    $0x3,%edx
L90:
  mov    0x40(%rsp),%r10
  mov    -0x4(%r10,%rdx,4),%edi
  mov    %edi,(%r10,%rdx,4)
  movsd  -0x8(%r14,%rdx,8),%xmm1
  movsd  %xmm1,(%r14,%rdx,8)
  sub    $0x1,%rdx
  cmp    %rax,%rdx
  jne    L90
L109:
  mov    0x40(%rsp),%rax
  mov    %ebx,(%rax,%rsi,4)
  movsd  %xmm0,(%rcx)
  movsd  0x18(%r14),%xmm7
  movsd  %xmm7,0x10(%rsp)
  movl   $0xffffffff,0x4c(%rsp)
L34:
  add    $0x1,%rbx
  cmp    0x38(%rsp),%rbx
  je     L98
L22:
  lea    0x50(%rsp),%r13
  movsd  (%r12,%rbx,8),%xmm0
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <sincos@plt>
  movsd  0x50(%rsp),%xmm4
  movsd  %xmm4,(%rsp)
  movsd  0x58(%rsp),%xmm5
  movsd  %xmm5,0x8(%rsp)
  movsd  (%r15,%rbx,8),%xmm0
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <sincos@plt>
  movsd  0x28(%rsp),%xmm0
  mulsd  0x50(%rsp),%xmm0
  movsd  0x30(%rsp),%xmm6
  mulsd  0x58(%rsp),%xmm6
  addsd  %xmm6,%xmm0
  movsd  (%rsp),%xmm1
  mulsd  0x18(%rsp),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  0x8(%rsp),%xmm1
  mulsd  0x20(%rsp),%xmm1
  addsd  %xmm1,%xmm0
  call   <acos@plt>
  movsd  0x10(%rsp),%xmm3
  comisd %xmm0,%xmm3
  jbe    L34
  mov    %r14,%rdx
  mov    $0x0,%eax
L103:
  mov    %rax,%rsi
  mov    %rdx,%rcx
  movsd  (%rdx),%xmm1
  comisd %xmm0,%xmm1
  ja     L104
  add    $0x1,%rax
  add    $0x8,%rdx
  cmp    $0x4,%rax
  jne    L103
  jmp    L34
L70:
  movl   $0x0,0x4c(%rsp)
L98:
  mov    %r14,%rax
  lea    0x20(%r14),%rcx
  mov    %r14,%rdx
  movsd  D9(%rip),%xmm3
  movsd  D1(%rip),%xmm2
L102:
  movapd %xmm3,%xmm1
  addsd  (%rdx),%xmm1
  movapd %xmm2,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx)
  add    $0x8,%rdx
  cmp    %rcx,%rdx
  jne    L102
  pxor   %xmm1,%xmm1
  addsd  (%r14),%xmm1
  addsd  0x8(%r14),%xmm1
  addsd  0x10(%r14),%xmm1
  addsd  0x18(%r14),%xmm1
L49:
  movsd  (%rax),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rcx,%rax
  jne    L49
  mov    0x4c(%rsp),%eax
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: read_data
arguments: label: D24
type_guessed: byte[8]
name: read_data
arguments: label: D9
type_guessed: byte[8]
name: read_data
arguments: label: D1
type_guessed: f64

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

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

tool: D1: 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);
}
```