user: What is the c source code of the assembly code below:

```asm
<grid_search_reg2d_nn>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %rdi,%r12
  mov    %rsi,0x68(%rsp)
  mov    %rdx,%r15
  mov    %rcx,%r14
  movsd  %xmm0,0x20(%rsp)
  movsd  %xmm1,0x18(%rsp)
  mov    %r8,0x38(%rsp)
  mov    %r9,%r13
  lea    0x88(%rsp),%rbp
  lea    0x80(%rsp),%rbx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  movapd %xmm1,%xmm0
  call   <sincos@plt>
  movsd  0x80(%rsp),%xmm2
  movsd  %xmm2,0x8(%rsp)
  movsd  0x88(%rsp),%xmm3
  movsd  %xmm3,0x10(%rsp)
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  movsd  0x20(%rsp),%xmm0
  call   <sincos@plt>
  movsd  0x80(%rsp),%xmm2
  movsd  %xmm2,0x40(%rsp)
  movsd  0x88(%rsp),%xmm3
  movsd  %xmm3,0x48(%rsp)
  movsd  D75(%rip),%xmm0
  movsd  %xmm0,(%r14)
  movsd  %xmm0,0x8(%r14)
  movsd  %xmm0,0x10(%r14)
  movsd  %xmm0,0x18(%r14)
  mov    0x68(%rsp),%rax
  lea    -0x1(%rax),%rsi
  mov    %rsi,0x50(%rsp)
  movsd  0x18(%rsp),%xmm3
  comisd 0x0(%r13),%xmm3
  jb     L62
  movsd  -0x8(%r13,%r12,8),%xmm0
  comisd %xmm3,%xmm0
  jb     L171
  mov    0x38(%rsp),%rcx
  movsd  (%rcx),%xmm0
  movsd  -0x8(%rcx,%rax,8),%xmm1
  comisd %xmm0,%xmm1
  jbe    L12
  comisd 0x20(%rsp),%xmm0
  jae    L147
  sub    $0x2,%rax
  mov    %rax,0x20(%rsp)
  jmp    L188
L12:
  movsd  0x20(%rsp),%xmm3
  comisd %xmm0,%xmm3
  jae    L147
  mov    0x68(%rsp),%rax
  sub    $0x2,%rax
  mov    %rax,0x20(%rsp)
  jmp    L188
L62:
  movq   $0x0,0x20(%rsp)
L188:
  mov    %r12,0x30(%rsp)
  lea    0x0(,%r12,8),%rbp
  mov    %rbp,%rcx
  mov    $0x2f,%edx
  lea    D12(%rip),%rsi
  lea    D64(%rip),%rdi
  mov    $0x0,%eax
  call   <Malloc@plt>
  mov    %eax,0x70(%rsp)
  cltq
  mov    %rax,0x78(%rsp)
  test   %r12,%r12
  jle    L178
L119:
  movslq 0x70(%rsp),%rbx
  mov    %rbx,0x18(%rsp)
  add    %rbx,%rbp
  lea    0x88(%rsp),%rax
  mov    %r12,0x28(%rsp)
  mov    %rax,%r12
L82:
  lea    0x80(%rsp),%rsi
  mov    %r13,%rax
  sub    0x18(%rsp),%rax
  movsd  (%rax,%rbx,1),%xmm0
  mov    %r12,%rdi
  call   <sincos@plt>
  movsd  0x8(%rsp),%xmm0
  mulsd  0x80(%rsp),%xmm0
  movsd  0x10(%rsp),%xmm1
  mulsd  0x88(%rsp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rbx)
  add    $0x8,%rbx
  cmp    %rbp,%rbx
  jne    L82
  mov    0x28(%rsp),%r12
L178:
  mov    0x50(%rsp),%rcx
  cmp    %rcx,0x20(%rsp)
  jg     L139
L37:
  mov    0x20(%rsp),%rax
  imul   0x30(%rsp),%rax
  mov    %rax,0x28(%rsp)
  mov    0x50(%rsp),%rax
  add    $0x1,%rax
  mov    %rax,0x50(%rsp)
  movsd  D75(%rip),%xmm2
  movsd  %xmm2,0x18(%rsp)
  movl   $0x0,0x74(%rsp)
  lea    0x88(%rsp),%rax
  mov    %rax,0x58(%rsp)
  lea    0x80(%rsp),%rax
  mov    %rax,0x60(%rsp)
  jmp    L204
L171:
  movq   $0x0,0x20(%rsp)
  jmp    L188
L128:
  movsd  0x8(%rsp),%xmm0
  mulsd  0x0(%rbp),%xmm0
  addsd  0x10(%rsp),%xmm0
  call   <acos@plt>
  movsd  0x18(%rsp),%xmm5
  comisd %xmm0,%xmm5
  ja     L263
L102:
  add    $0x1,%rbx
  add    $0x8,%rbp
  cmp    %rbx,%r12
  je     L74
L192:
  test   %r13d,%r13d
  je     L128
  cmp    $0x1,%rbx
  jle    L128
  lea    -0x2(%r12),%rax
  cmp    %rbx,%rax
  jle    L128
  jmp    L102
L263:
  mov    %r14,%rdx
  mov    $0x0,%eax
L150:
  mov    %rax,%rsi
  mov    %rdx,%rcx
  movsd  (%rdx),%xmm1
  comisd %xmm0,%xmm1
  ja     L103
  add    $0x1,%rax
  add    $0x8,%rdx
  cmp    $0x4,%rax
  jne    L150
  jmp    L102
L103:
  cmp    $0x2,%rax
  jg     L266
  mov    $0x3,%edx
L187:
  mov    -0x4(%r15,%rdx,4),%edi
  mov    %edi,(%r15,%rdx,4)
  movsd  -0x8(%r14,%rdx,8),%xmm1
  movsd  %xmm1,(%r14,%rdx,8)
  sub    $0x1,%rdx
  cmp    %rax,%rdx
  jne    L187
L266:
  mov    0x28(%rsp),%eax
  add    %ebx,%eax
  mov    %eax,(%r15,%rsi,4)
  movsd  %xmm0,(%rcx)
  movsd  0x18(%r14),%xmm2
  movsd  %xmm2,0x18(%rsp)
  movl   $0xffffffff,0x74(%rsp)
  jmp    L102
L74:
  addq   $0x1,0x20(%rsp)
  mov    0x20(%rsp),%rax
  mov    0x30(%rsp),%rcx
  add    %rcx,0x28(%rsp)
  cmp    0x50(%rsp),%rax
  je     L93
L204:
  mov    0x38(%rsp),%rax
  mov    0x20(%rsp),%rbx
  movsd  (%rax,%rbx,8),%xmm0
  mov    0x60(%rsp),%rsi
  mov    0x58(%rsp),%rdi
  call   <sincos@plt>
  movsd  0x40(%rsp),%xmm6
  mulsd  0x80(%rsp),%xmm6
  movsd  %xmm6,0x8(%rsp)
  movsd  0x48(%rsp),%xmm7
  mulsd  0x88(%rsp),%xmm7
  movsd  %xmm7,0x10(%rsp)
  mov    $0x0,%r13d
  cmp    $0x1,%rbx
  jle    L2
  mov    0x68(%rsp),%rax
  sub    $0x2,%rax
  cmp    %rbx,%rax
  setg   %r13b
  movzbl %r13b,%r13d
L2:
  test   %r12,%r12
  jle    L74
  movslq 0x70(%rsp),%rbp
  mov    $0x0,%ebx
  jmp    L192
L139:
  movl   $0x0,0x74(%rsp)
L93:
  mov    0x78(%rsp),%rcx
  mov    $0x59,%edx
  lea    D12(%rip),%rsi
  lea    D64(%rip),%rdi
  mov    $0x0,%eax
  call   <Free@plt>
  mov    %r14,%rax
  lea    0x20(%r14),%rcx
  mov    %r14,%rdx
  movsd  D54(%rip),%xmm3
  movsd  D83(%rip),%xmm2
L179:
  movapd %xmm3,%xmm1
  addsd  (%rdx),%xmm1
  movapd %xmm2,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx)
  add    $0x8,%rdx
  cmp    %rcx,%rdx
  jne    L179
  pxor   %xmm1,%xmm1
  addsd  (%r14),%xmm1
  addsd  0x8(%r14),%xmm1
  addsd  0x10(%r14),%xmm1
  addsd  0x18(%r14),%xmm1
L121:
  movsd  (%rax),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rcx,%rax
  jne    L121
  mov    0x74(%rsp),%eax
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L147:
  mov    %r12,0x30(%rsp)
  lea    0x0(,%r12,8),%rbp
  mov    %rbp,%rcx
  mov    $0x2f,%edx
  lea    D12(%rip),%rsi
  lea    D64(%rip),%rdi
  mov    $0x0,%eax
  call   <Malloc@plt>
  mov    %eax,0x70(%rsp)
  cltq
  mov    %rax,0x78(%rsp)
  movq   $0x1,0x50(%rsp)
  movq   $0x0,0x20(%rsp)
  test   %r12,%r12
  jg     L119
  jmp    L37
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D75
datatype: byte[8]
name: extract_symbolic_data
arguments: data_tag: D12
datatype: string
name: extract_symbolic_data
arguments: data_tag: D64
datatype: string
name: extract_symbolic_data
arguments: data_tag: D54
datatype: byte[8]
name: extract_symbolic_data
arguments: data_tag: D83
datatype: f64

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

tool: D12: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AZed/cdo/refs/heads/master/src/remap_search_reg2d.c

tool: D64: grid_search_reg2d_nn

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

tool: D83: 1

assistant: ```c
int grid_search_reg2d_nn(long nx, long ny, 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;
  long ii, jj;
  long jjskip;
  double coslat, sinlat;
  double dist_min, distance;
  double *sincoslon;
  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;
  long jjf = 0, jjl = ny - 1;
  if (plon >= src_center_lon[0] && plon <= src_center_lon[nx - 1]) {
    if (src_center_lat[0] < src_center_lat[ny - 1]) {
      if (plat <= src_center_lat[0]) {
        jjf = 0;
        jjl = 1;
      } else {
        jjf = ny - 2;
        jjl = ny - 1;
      }
    } else {
      if (plat >= src_center_lat[0]) {
        jjf = 0;
        jjl = 1;
      } else {
        jjf = ny - 2;
        jjl = ny - 1;
      }
    }
  }
  sincoslon = (double *)Malloc(__func__, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AZed/cdo/refs/heads/master/src/remap_search_reg2d.c", 47, (nx * sizeof(double)));
  for (ii = 0; ii < nx; ++ii)
    sincoslon[ii] = coslon_dst * cos(src_center_lon[ii]) + sinlon_dst * sin(src_center_lon[ii]);
  for (jj = jjf; jj <= jjl; ++jj) {
    coslat = coslat_dst * cos(src_center_lat[jj]);
    sinlat = sinlat_dst * sin(src_center_lat[jj]);
    jjskip = jj > 1 && jj < (ny - 2);
    for (ii = 0; ii < nx; ++ii) {
      if (jjskip && ii > 1 && ii < (nx - 2))
        continue;
      srch_add = jj * nx + ii;
      distance = acos(coslat * sincoslon[ii] + sinlat);
      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;
          }
        }
      }
    }
  }
  Free(__func__, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AZed/cdo/refs/heads/master/src/remap_search_reg2d.c", 89, (sincoslon));
  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);
}
```