user: Translate the below assembly code into C programming language:

```asm
<grid_search_nn>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xa0,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %rdx,-0x68(%rbp)
  mov    %rcx,-0x70(%rbp)
  movsd  %xmm0,-0x78(%rbp)
  movsd  %xmm1,-0x80(%rbp)
  mov    %r8,-0x88(%rbp)
  mov    %r9,-0x90(%rbp)
  movl   $0x0,-0x4c(%rbp)
  mov    -0x78(%rbp),%rax
  movq   %rax,%xmm0
  call   <cos@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x78(%rbp),%rax
  movq   %rax,%xmm0
  call   <sin@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x80(%rbp),%rax
  movq   %rax,%xmm0
  call   <cos@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x80(%rbp),%rax
  movq   %rax,%xmm0
  call   <sin@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x8(%rbp)
  movsd  D19(%rip),%xmm0
  movsd  %xmm0,-0x30(%rbp)
  movq   $0x0,-0x48(%rbp)
  jmp    L136
L139:
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movsd  D19(%rip),%xmm0
  movsd  %xmm0,(%rax)
  addq   $0x1,-0x48(%rbp)
L136:
  cmpq   $0x3,-0x48(%rbp)
  jle    L139
  mov    -0x58(%rbp),%rax
  mov    %rax,-0x40(%rbp)
  jmp    L45
L93:
  mov    -0x40(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movq   %rax,%xmm0
  call   <cos@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm2
  mulsd  -0x20(%rbp),%xmm2
  movsd  %xmm2,-0x98(%rbp)
  mov    -0x40(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movq   %rax,%xmm0
  call   <cos@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm3
  mulsd  -0x10(%rbp),%xmm3
  movsd  %xmm3,-0xa0(%rbp)
  mov    -0x40(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movq   %rax,%xmm0
  call   <sin@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  mulsd  -0x8(%rbp),%xmm0
  addsd  -0xa0(%rbp),%xmm0
  mulsd  -0x98(%rbp),%xmm0
  movsd  %xmm0,-0x98(%rbp)
  mov    -0x40(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movq   %rax,%xmm0
  call   <sin@plt>
  movq   %xmm0,%rax
  movq   %rax,%xmm5
  mulsd  -0x18(%rbp),%xmm5
  movapd %xmm5,%xmm0
  movapd %xmm0,%xmm6
  addsd  -0x98(%rbp),%xmm6
  movq   %xmm6,%rax
  movq   %rax,%xmm0
  call   <acos@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x28(%rbp)
  movsd  -0x30(%rbp),%xmm0
  comisd -0x28(%rbp),%xmm0
  jbe    L138
  movq   $0x0,-0x48(%rbp)
  jmp    L132
L112:
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd -0x28(%rbp),%xmm0
  jbe    L133
  movq   $0x3,-0x38(%rbp)
  jmp    L76
L35:
  mov    -0x38(%rbp),%rax
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  mov    -0x38(%rbp),%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x68(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x38(%rbp),%rax
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x70(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x70(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  subq   $0x1,-0x38(%rbp)
L76:
  mov    -0x38(%rbp),%rax
  cmp    -0x48(%rbp),%rax
  jg     L35
  movl   $0xffffffff,-0x4c(%rbp)
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  mov    -0x40(%rbp),%rdx
  mov    %edx,(%rax)
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movsd  -0x28(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x70(%rbp),%rax
  movsd  0x18(%rax),%xmm0
  movsd  %xmm0,-0x30(%rbp)
  jmp    L138
L133:
  addq   $0x1,-0x48(%rbp)
L132:
  cmpq   $0x3,-0x48(%rbp)
  jle    L112
L138:
  addq   $0x1,-0x40(%rbp)
L45:
  mov    -0x40(%rbp),%rax
  cmp    -0x60(%rbp),%rax
  jle    L93
  movq   $0x0,-0x48(%rbp)
  jmp    L66
L74:
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  D29(%rip),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movsd  D24(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addq   $0x1,-0x48(%rbp)
L66:
  cmpq   $0x3,-0x48(%rbp)
  jle    L74
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movq   $0x0,-0x48(%rbp)
  jmp    L122
L67:
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  -0x28(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x28(%rbp)
  addq   $0x1,-0x48(%rbp)
L122:
  cmpq   $0x3,-0x48(%rbp)
  jle    L67
  movq   $0x0,-0x48(%rbp)
  jmp    L71
L106:
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  divsd  -0x28(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  addq   $0x1,-0x48(%rbp)
L71:
  cmpq   $0x3,-0x48(%rbp)
  jle    L106
  mov    -0x4c(%rbp),%eax
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D19
data_type: byte[8]
name: unpack_data
arguments: label: D29
data_type: byte[8]
name: unpack_data
arguments: label: D24
data_type: f64

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

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

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