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);
}


x86 assembly (clang, -O0):
<grid_search_reg2d_nn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xe2c(%rip),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movq   $0x0,-0x50(%rbp)
cmpq   $0x4,-0x50(%rbp)
jge    1215 <grid_search_reg2d_nn+0xc5>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  0xe01(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11e4 <grid_search_reg2d_nn+0x94>
movq   $0x0,-0xc8(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0xd0(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x40(%rbp),%rax
ucomisd (%rax),%xmm0
jb     1330 <grid_search_reg2d_nn+0x1e0>
movsd  -0x30(%rbp),%xmm1
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1330 <grid_search_reg2d_nn+0x1e0>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    12da <grid_search_reg2d_nn+0x18a>
movsd  -0x28(%rbp),%xmm1
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     12b7 <grid_search_reg2d_nn+0x167>
movq   $0x0,-0xc8(%rbp)
movq   $0x1,-0xd0(%rbp)
jmp    12d5 <grid_search_reg2d_nn+0x185>
mov    -0x10(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0xc8(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0xd0(%rbp)
jmp    132b <grid_search_reg2d_nn+0x1db>
movsd  -0x28(%rbp),%xmm0
mov    -0x38(%rbp),%rax
ucomisd (%rax),%xmm0
jb     1308 <grid_search_reg2d_nn+0x1b8>
movq   $0x0,-0xc8(%rbp)
movq   $0x1,-0xd0(%rbp)
jmp    1326 <grid_search_reg2d_nn+0x1d6>
mov    -0x10(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0xc8(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0xd0(%rbp)
jmp    132b <grid_search_reg2d_nn+0x1db>
jmp    1330 <grid_search_reg2d_nn+0x1e0>
mov    -0x8(%rbp),%rcx
shl    $0x3,%rcx
lea    0xcd9(%rip),%rdi
lea    0xce7(%rip),%rsi
mov    $0x2f,%edx
mov    $0x0,%al
call   1030 <Malloc@plt>
cltq
mov    %rax,-0xa0(%rbp)
movq   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    1405 <grid_search_reg2d_nn+0x2b5>
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xd8(%rbp)
ff
mov    -0x40(%rbp),%rax
mov    -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
movsd  %xmm0,-0xe8(%rbp)
ff
mov    -0x40(%rbp),%rax
mov    -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <sin@plt>
movsd  -0xe8(%rbp),%xmm1
ff
movsd  -0xe0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xd8(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0xa0(%rbp),%rax
mov    -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1363 <grid_search_reg2d_nn+0x213>
mov    -0xc8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
cmp    -0xd0(%rbp),%rax
jg     168a <grid_search_reg2d_nn+0x53a>
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x100(%rbp)
ff
mov    -0x38(%rbp),%rax
mov    -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x100(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xf8(%rbp)
ff
mov    -0x38(%rbp),%rax
mov    -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xf8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
xor    %eax,%eax
cmpq   $0x1,-0x70(%rbp)
mov    %al,-0xe9(%rbp)
jle    14bb <grid_search_reg2d_nn+0x36b>
mov    -0x70(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
setl   %al
mov    %al,-0xe9(%rbp)
mov    -0xe9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    %rax,-0x78(%rbp)
movq   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    1674 <grid_search_reg2d_nn+0x524>
cmpq   $0x0,-0x78(%rbp)
je     1512 <grid_search_reg2d_nn+0x3c2>
cmpq   $0x1,-0x68(%rbp)
jle    1512 <grid_search_reg2d_nn+0x3c2>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jge    1512 <grid_search_reg2d_nn+0x3c2>
jmp    1663 <grid_search_reg2d_nn+0x513>
mov    -0x70(%rbp),%rax
imul   -0x8(%rbp),%rax
add    -0x68(%rbp),%rax
mov    %rax,-0x58(%rbp)
movsd  -0x80(%rbp),%xmm0
mov    -0xa0(%rbp),%rax
mov    -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x88(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <acos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x90(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    165e <grid_search_reg2d_nn+0x50e>
movq   $0x0,-0x50(%rbp)
cmpq   $0x4,-0x50(%rbp)
jge    1659 <grid_search_reg2d_nn+0x509>
movsd  -0x98(%rbp),%xmm1
ff
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1643 <grid_search_reg2d_nn+0x4f3>
movq   $0x3,-0x60(%rbp)
mov    -0x60(%rbp),%rax
cmp    -0x50(%rbp),%rax
jle    1600 <grid_search_reg2d_nn+0x4b0>
mov    -0x18(%rbp),%rax
mov    -0x60(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x60(%rbp)
jmp    15a9 <grid_search_reg2d_nn+0x459>
movl   $0xffffffff,-0x44(%rbp)
mov    -0x58(%rbp),%rax
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movsd  -0x98(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    1659 <grid_search_reg2d_nn+0x509>
jmp    1648 <grid_search_reg2d_nn+0x4f8>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1577 <grid_search_reg2d_nn+0x427>
jmp    165e <grid_search_reg2d_nn+0x50e>
jmp    1663 <grid_search_reg2d_nn+0x513>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    14d4 <grid_search_reg2d_nn+0x384>
jmp    1679 <grid_search_reg2d_nn+0x529>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    1410 <grid_search_reg2d_nn+0x2c0>
mov    -0xa0(%rbp),%rcx
lea    0x980(%rip),%rdi
lea    0x98e(%rip),%rsi
mov    $0x59,%edx
mov    $0x0,%al
call   1060 <Free@plt>
movq   $0x0,-0x50(%rbp)
cmpq   $0x4,-0x50(%rbp)
jge    16fd <grid_search_reg2d_nn+0x5ad>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  0x942(%rip),%xmm1
addsd  (%rax,%rcx,8),%xmm1
movsd  0x92d(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    16b3 <grid_search_reg2d_nn+0x563>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movq   $0x0,-0x50(%rbp)
cmpq   $0x4,-0x50(%rbp)
jge    1749 <grid_search_reg2d_nn+0x5f9>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1710 <grid_search_reg2d_nn+0x5c0>
movq   $0x0,-0x50(%rbp)
cmpq   $0x4,-0x50(%rbp)
jge    178b <grid_search_reg2d_nn+0x63b>
movsd  -0x98(%rbp),%xmm1
ff
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1751 <grid_search_reg2d_nn+0x601>
mov    -0x44(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_search_reg2d_nn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%r15
mov    %r8,0x68(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %rcx,%r12
mov    %rdx,0x80(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r13
call   1070 <cos@plt>
movsd  %xmm0,0x78(%rsp)
movsd  0x20(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x70(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movsd  0x8(%rsp),%xmm2
movaps 0xe35(%rip),%xmm1
movups %xmm1,(%r12)
movups %xmm1,0x10(%r12)
mov    %rbx,%rax
mov    %rbx,0x28(%rsp)
lea    -0x1(%rbx),%rax
mov    %rax,0x48(%rsp)
movsd  (%r15),%xmm1
movsd  %xmm1,0x10(%rsp)
ucomisd %xmm1,%xmm2
movsd  %xmm0,0x18(%rsp)
jb     120f <grid_search_reg2d_nn+0xbf>
movsd  -0x8(%r15,%r13,8),%xmm1
ucomisd %xmm2,%xmm1
jae    165f <grid_search_reg2d_nn+0x50f>
xor    %ebx,%ebx
lea    0x0(,%r13,8),%rcx
lea    0xe18(%rip),%rdi
lea    0xe26(%rip),%rsi
xor    %eax,%eax
mov    %rax,0x60(%rsp)
mov    $0x2f,%edx
xor    %eax,%eax
call   1030 <Malloc@plt>
movslq %eax,%r14
test   %r13,%r13
jle    13a9 <grid_search_reg2d_nn+0x259>
movsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x30(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
cmp    $0x1,%r13
je     13a9 <grid_search_reg2d_nn+0x259>
lea    -0x1(%r13),%rax
mov    %rax,0x50(%rsp)
mov    $0x1,%ebp
cmp    $0x2,%r13
je     1360 <grid_search_reg2d_nn+0x210>
mov    0x50(%rsp),%rax
and    $0xfffffffffffffffe,%rax
neg    %rax
mov    %rax,0x58(%rsp)
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r15,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x30(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbp,8)
movsd  0x8(%r15,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movsd  0x18(%rsp),%xmm2
movsd  0x30(%rsp),%xmm1
mulsd  %xmm2,%xmm0
movsd  0x8(%rsp),%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm3,0x8(%r14,%rbp,8)
mov    0x58(%rsp),%rax
add    %rbp,%rax
add    $0x2,%rax
add    $0x2,%rbp
cmp    $0x1,%rax
jne    12c0 <grid_search_reg2d_nn+0x170>
testb  $0x1,0x50(%rsp)
je     13a9 <grid_search_reg2d_nn+0x259>
movsd  (%r15,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbp,8)
mov    %r14,0x20(%rsp)
cmp    0x48(%rsp),%rbx
jle    1471 <grid_search_reg2d_nn+0x321>
movsd  0xc6f(%rip),%xmm0
movapd %xmm0,0x30(%rsp)
lea    0xc6a(%rip),%rdi
lea    0xc78(%rip),%rsi
mov    $0x59,%edx
mov    0x20(%rsp),%rcx
xor    %eax,%eax
call   1060 <Free@plt>
movupd (%r12),%xmm0
movapd 0xc1c(%rip),%xmm1
addpd  %xmm1,%xmm0
movapd 0xc20(%rip),%xmm2
movapd %xmm2,%xmm3
divpd  %xmm0,%xmm3
movsd  0x10(%r12),%xmm0
unpcklpd 0x30(%rsp),%xmm0
addpd  %xmm1,%xmm0
divpd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
addsd  %xmm1,%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm3
movupd %xmm3,(%r12)
divpd  %xmm0,%xmm2
movupd %xmm2,0x10(%r12)
mov    0x60(%rsp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
addq   $0xfffffffffffffffe,0x28(%rsp)
lea    -0x2(%r13),%r14
lea    0x18(%r12),%rax
mov    %rax,0x50(%rsp)
mov    %rbx,%rax
imul   %r13,%rax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x60(%rsp)
movsd  0xb90(%rip),%xmm0
movapd %xmm0,0x30(%rsp)
jmp    14c9 <grid_search_reg2d_nn+0x379>
nopl   0x0(%rax,%rax,1)
mov    0x58(%rsp),%rcx
lea    0x1(%rcx),%rbx
add    %r13,0x10(%rsp)
cmp    0x48(%rsp),%rcx
je     13c7 <grid_search_reg2d_nn+0x277>
mov    0x68(%rsp),%rax
movsd  (%rax,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1070 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
cmp    $0x2,%rbx
setge  %bpl
cmp    0x28(%rsp),%rbx
setl   %al
test   %r13,%r13
mov    %rbx,0x58(%rsp)
jle    14b0 <grid_search_reg2d_nn+0x360>
movapd %xmm0,%xmm3
and    %al,%bpl
movsd  0x18(%rsp),%xmm2
mulsd  0x78(%rsp),%xmm2
mulsd  0x70(%rsp),%xmm3
xor    %r15d,%r15d
movsd  %xmm2,0x18(%rsp)
movsd  %xmm3,0x8(%rsp)
jmp    1573 <grid_search_reg2d_nn+0x423>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp),%rdx
add    %r15d,%edx
mov    %edx,(%rbx,%rax,4)
movsd  %xmm0,(%rcx)
movsd  0x18(%r12),%xmm0
movapd %xmm0,0x30(%rsp)
mov    $0xffffffff,%eax
mov    %rax,0x60(%rsp)
add    $0x1,%r15
cmp    %r15,%r13
je     14b0 <grid_search_reg2d_nn+0x360>
cmp    $0x2,%r15
setae  %al
and    %bpl,%al
cmp    $0x1,%al
jne    1586 <grid_search_reg2d_nn+0x436>
cmp    %r14,%r15
jl     1566 <grid_search_reg2d_nn+0x416>
mov    0x20(%rsp),%rax
movsd  (%rax,%r15,8),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
call   1040 <acos@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
mov    0x80(%rsp),%rbx
movapd 0x30(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1566 <grid_search_reg2d_nn+0x416>
movsd  (%r12),%xmm1
mov    $0x1,%dl
ucomisd %xmm0,%xmm1
jbe    15d3 <grid_search_reg2d_nn+0x483>
mov    $0x1,%sil
xor    %eax,%eax
jmp    160b <grid_search_reg2d_nn+0x4bb>
movsd  0x8(%r12),%xmm1
ucomisd %xmm0,%xmm1
jbe    15e7 <grid_search_reg2d_nn+0x497>
mov    $0x1,%eax
jmp    1609 <grid_search_reg2d_nn+0x4b9>
movsd  0x10(%r12),%xmm1
mov    $0x3,%eax
ucomisd %xmm0,%xmm1
mov    0x50(%rsp),%rcx
jbe    1540 <grid_search_reg2d_nn+0x3f0>
mov    $0x2,%eax
xor    %edx,%edx
xor    %esi,%esi
lea    (%r12,%rax,8),%rcx
mov    0x8(%rbx),%edi
mov    %edi,0xc(%rbx)
movsd  0x10(%r12),%xmm1
movsd  %xmm1,0x18(%r12)
test   %dl,%dl
je     1540 <grid_search_reg2d_nn+0x3f0>
mov    0x4(%rbx),%edx
mov    %edx,0x8(%rbx)
movsd  0x8(%r12),%xmm1
movsd  %xmm1,0x10(%r12)
test   %sil,%sil
je     1540 <grid_search_reg2d_nn+0x3f0>
mov    (%rbx),%edx
mov    %edx,0x4(%rbx)
movsd  (%r12),%xmm1
movsd  %xmm1,0x8(%r12)
jmp    1540 <grid_search_reg2d_nn+0x3f0>
mov    0x68(%rsp),%rax
movsd  (%rax),%xmm0
mov    0x28(%rsp),%rcx
movsd  -0x8(%rax,%rcx,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    1692 <grid_search_reg2d_nn+0x542>
ucomisd 0x20(%rsp),%xmm0
jb     169e <grid_search_reg2d_nn+0x54e>
mov    $0x1,%eax
mov    %rax,0x48(%rsp)
xor    %ebx,%ebx
jmp    1211 <grid_search_reg2d_nn+0xc1>
movsd  0x20(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jae    1681 <grid_search_reg2d_nn+0x531>
mov    0x28(%rsp),%rax
lea    -0x2(%rax),%rbx
jmp    1211 <grid_search_reg2d_nn+0xc1>

LLVM IR (-O0):
@__func__.grid_search_reg2d_nn = [21 x i8] c"grid_search_reg2d_nn\00"
@.str = [142 x i8] c"/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\00"
define i32 @grid_search_reg2d_nn(i64 %0, i64 %1, i32* noalias %2, double* noalias %3, double %4, double %5, double* noalias %6, double* noalias %7) {
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32*
%12 = alloca double*
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca double*
%17 = alloca i32
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
%22 = alloca i64
%23 = alloca i64
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double*
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
%33 = alloca i64
%34 = alloca i64
store i64 %0, i64* %9
store i64 %1, i64* %10
store i32* %2, i32** %11
store double* %3, double** %12
store double %4, double* %13
store double %5, double* %14
store double* %6, double** %15
store double* %7, double** %16
store i32 0, i32* %17
%35 = load double, double* %13
%36 = call double @cos(double %35)
store double %36, double* %29
%37 = load double, double* %13
%38 = call double @sin(double %37)
store double %38, double* %30
%39 = load double, double* %14
%40 = call double @cos(double %39)
store double %40, double* %31
%41 = load double, double* %14
%42 = call double @sin(double %41)
store double %42, double* %32
store double 1.000000e+20, double* %26
store i64 0, i64* %18
br label %43
43: ; preds = %50, %8
%44 = load i64, i64* %18
%45 = icmp slt i64 %44, 4
br i1 %45, label %46, label %53
46: ; preds = %43
%47 = load double*, double** %12
%48 = load i64, i64* %18
%49 = getelementptr inbounds double, double* %47, i64 %48
store double 1.000000e+20, double* %49
br label %50
50: ; preds = %46
%51 = load i64, i64* %18
%52 = add nsw i64 %51, 1
store i64 %52, i64* %18
br label %43
53: ; preds = %43
store i64 0, i64* %33
%54 = load i64, i64* %10
%55 = sub nsw i64 %54, 1
store i64 %55, i64* %34
%56 = load double, double* %14
%57 = load double*, double** %16
%58 = getelementptr inbounds double, double* %57, i64 0
%59 = load double, double* %58
%60 = fcmp oge double %56, %59
br i1 %60, label %61, label %106
61: ; preds = %53
%62 = load double, double* %14
%63 = load double*, double** %16
%64 = load i64, i64* %9
%65 = sub nsw i64 %64, 1
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = fcmp ole double %62, %67
br i1 %68, label %69, label %106
69: ; preds = %61
%70 = load double*, double** %15
%71 = getelementptr inbounds double, double* %70, i64 0
%72 = load double, double* %71
%73 = load double*, double** %15
%74 = load i64, i64* %10
%75 = sub nsw i64 %74, 1
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = fcmp olt double %72, %77
br i1 %78, label %79, label %92
79: ; preds = %69
%80 = load double, double* %13
%81 = load double*, double** %15
%82 = getelementptr inbounds double, double* %81, i64 0
%83 = load double, double* %82
%84 = fcmp ole double %80, %83
br i1 %84, label %85, label %86
85: ; preds = %79
store i64 0, i64* %33
store i64 1, i64* %34
br label %91
86: ; preds = %79
%87 = load i64, i64* %10
%88 = sub nsw i64 %87, 2
store i64 %88, i64* %33
%89 = load i64, i64* %10
%90 = sub nsw i64 %89, 1
store i64 %90, i64* %34
br label %91
91: ; preds = %86, %85
br label %105
92: ; preds = %69
%93 = load double, double* %13
%94 = load double*, double** %15
%95 = getelementptr inbounds double, double* %94, i64 0
%96 = load double, double* %95
%97 = fcmp oge double %93, %96
br i1 %97, label %98, label %99
98: ; preds = %92
store i64 0, i64* %33
store i64 1, i64* %34
br label %104
99: ; preds = %92
%100 = load i64, i64* %10
%101 = sub nsw i64 %100, 2
store i64 %101, i64* %33
%102 = load i64, i64* %10
%103 = sub nsw i64 %102, 1
store i64 %103, i64* %34
br label %104
104: ; preds = %99, %98
br label %105
105: ; preds = %104, %91
br label %106
106: ; preds = %105, %61, %53
%107 = load i64, i64* %9
%108 = mul i64 %107, 8
%109 = call i32 (i8*, i8*, i32, i64, ...) bitcast (i32 (...)* @Malloc to i32 (i8*, i8*, i32, i64, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.grid_search_reg2d_nn, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str, i64 0, i64 0), i32 47, i64 %108)
%110 = sext i32 %109 to i64
%111 = inttoptr i64 %110 to double*
store double* %111, double** %28
store i64 0, i64* %21
br label %112
112: ; preds = %134, %106
%113 = load i64, i64* %21
%114 = load i64, i64* %9
%115 = icmp slt i64 %113, %114
br i1 %115, label %116, label %137
116: ; preds = %112
%117 = load double, double* %31
%118 = load double*, double** %16
%119 = load i64, i64* %21
%120 = getelementptr inbounds double, double* %118, i64 %119
%121 = load double, double* %120
%122 = call double @cos(double %121)
%123 = load double, double* %32
%124 = load double*, double** %16
%125 = load i64, i64* %21
%126 = getelementptr inbounds double, double* %124, i64 %125
%127 = load double, double* %126
%128 = call double @sin(double %127)
%129 = fmul double %123, %128
%130 = call double @llvm.fmuladd.f64(double %117, double %122, double %129)
%131 = load double*, double** %28
%132 = load i64, i64* %21
%133 = getelementptr inbounds double, double* %131, i64 %132
store double %130, double* %133
br label %134
134: ; preds = %116
%135 = load i64, i64* %21
%136 = add nsw i64 %135, 1
store i64 %136, i64* %21
br label %112
137: ; preds = %112
%138 = load i64, i64* %33
store i64 %138, i64* %22
br label %139
139: ; preds = %261, %137
%140 = load i64, i64* %22
%141 = load i64, i64* %34
%142 = icmp sle i64 %140, %141
br i1 %142, label %143, label %264
143: ; preds = %139
%144 = load double, double* %29
%145 = load double*, double** %15
%146 = load i64, i64* %22
%147 = getelementptr inbounds double, double* %145, i64 %146
%148 = load double, double* %147
%149 = call double @cos(double %148)
%150 = fmul double %144, %149
store double %150, double* %24
%151 = load double, double* %30
%152 = load double*, double** %15
%153 = load i64, i64* %22
%154 = getelementptr inbounds double, double* %152, i64 %153
%155 = load double, double* %154
%156 = call double @sin(double %155)
%157 = fmul double %151, %156
store double %157, double* %25
%158 = load i64, i64* %22
%159 = icmp sgt i64 %158, 1
br i1 %159, label %160, label %165
160: ; preds = %143
%161 = load i64, i64* %22
%162 = load i64, i64* %10
%163 = sub nsw i64 %162, 2
%164 = icmp slt i64 %161, %163
br label %165
165: ; preds = %160, %143
%166 = phi i1 [ false, %143 ], [ %164, %160 ]
%167 = zext i1 %166 to i32
%168 = sext i32 %167 to i64
store i64 %168, i64* %23
store i64 0, i64* %21
br label %169
169: ; preds = %257, %165
%170 = load i64, i64* %21
%171 = load i64, i64* %9
%172 = icmp slt i64 %170, %171
br i1 %172, label %173, label %260
173: ; preds = %169
%174 = load i64, i64* %23
%175 = icmp ne i64 %174, 0
br i1 %175, label %176, label %185
176: ; preds = %173
%177 = load i64, i64* %21
%178 = icmp sgt i64 %177, 1
br i1 %178, label %179, label %185
179: ; preds = %176
%180 = load i64, i64* %21
%181 = load i64, i64* %9
%182 = sub nsw i64 %181, 2
%183 = icmp slt i64 %180, %182
br i1 %183, label %184, label %185
184: ; preds = %179
br label %257
185: ; preds = %179, %176, %173
%186 = load i64, i64* %22
%187 = load i64, i64* %9
%188 = mul nsw i64 %186, %187
%189 = load i64, i64* %21
%190 = add nsw i64 %188, %189
store i64 %190, i64* %19
%191 = load double, double* %24
%192 = load double*, double** %28
%193 = load i64, i64* %21
%194 = getelementptr inbounds double, double* %192, i64 %193
%195 = load double, double* %194
%196 = load double, double* %25
%197 = call double @llvm.fmuladd.f64(double %191, double %195, double %196)
%198 = call double @acos(double %197)
store double %198, double* %27
%199 = load double, double* %27
%200 = load double, double* %26
%201 = fcmp olt double %199, %200
br i1 %201, label %202, label %256
202: ; preds = %185
store i64 0, i64* %18
br label %203
203: ; preds = %252, %202
%204 = load i64, i64* %18
%205 = icmp slt i64 %204, 4
br i1 %205, label %206, label %255
206: ; preds = %203
%207 = load double, double* %27
%208 = load double*, double** %12
%209 = load i64, i64* %18
%210 = getelementptr inbounds double, double* %208, i64 %209
%211 = load double, double* %210
%212 = fcmp olt double %207, %211
br i1 %212, label %213, label %251
213: ; preds = %206
store i64 3, i64* %20
br label %214
214: ; preds = %235, %213
%215 = load i64, i64* %20
%216 = load i64, i64* %18
%217 = icmp sgt i64 %215, %216
br i1 %217, label %218, label %238
218: ; preds = %214
%219 = load i32*, i32** %11
%220 = load i64, i64* %20
%221 = sub nsw i64 %220, 1
%222 = getelementptr inbounds i32, i32* %219, i64 %221
%223 = load i32, i32* %222
%224 = load i32*, i32** %11
%225 = load i64, i64* %20
%226 = getelementptr inbounds i32, i32* %224, i64 %225
store i32 %223, i32* %226
%227 = load double*, double** %12
%228 = load i64, i64* %20
%229 = sub nsw i64 %228, 1
%230 = getelementptr inbounds double, double* %227, i64 %229
%231 = load double, double* %230
%232 = load double*, double** %12
%233 = load i64, i64* %20
%234 = getelementptr inbounds double, double* %232, i64 %233
store double %231, double* %234
br label %235
235: ; preds = %218
%236 = load i64, i64* %20
%237 = add nsw i64 %236, -1
store i64 %237, i64* %20
br label %214
238: ; preds = %214
store i32 -1, i32* %17
%239 = load i64, i64* %19
%240 = trunc i64 %239 to i32
%241 = load i32*, i32** %11
%242 = load i64, i64* %18
%243 = getelementptr inbounds i32, i32* %241, i64 %242
store i32 %240, i32* %243
%244 = load double, double* %27
%245 = load double*, double** %12
%246 = load i64, i64* %18
%247 = getelementptr inbounds double, double* %245, i64 %246
store double %244, double* %247
%248 = load double*, double** %12
%249 = getelementptr inbounds double, double* %248, i64 3
%250 = load double, double* %249
store double %250, double* %26
br label %255
251: ; preds = %206
br label %252
252: ; preds = %251
%253 = load i64, i64* %18
%254 = add nsw i64 %253, 1
store i64 %254, i64* %18
br label %203
255: ; preds = %238, %203
br label %256
256: ; preds = %255, %185
br label %257
257: ; preds = %256, %184
%258 = load i64, i64* %21
%259 = add nsw i64 %258, 1
store i64 %259, i64* %21
br label %169
260: ; preds = %169
br label %261
261: ; preds = %260
%262 = load i64, i64* %22
%263 = add nsw i64 %262, 1
store i64 %263, i64* %22
br label %139
264: ; preds = %139
%265 = load double*, double** %28
%266 = call i32 (i8*, i8*, i32, double*, ...) bitcast (i32 (...)* @Free to i32 (i8*, i8*, i32, double*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.grid_search_reg2d_nn, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str, i64 0, i64 0), i32 89, double* %265)
store i64 0, i64* %18
br label %267
267: ; preds = %280, %264
%268 = load i64, i64* %18
%269 = icmp slt i64 %268, 4
br i1 %269, label %270, label %283
270: ; preds = %267
%271 = load double*, double** %12
%272 = load i64, i64* %18
%273 = getelementptr inbounds double, double* %271, i64 %272
%274 = load double, double* %273
%275 = fadd double %274, 0x3D06849B86A12B9B
%276 = fdiv double 1.000000e+00, %275
%277 = load double*, double** %12
%278 = load i64, i64* %18
%279 = getelementptr inbounds double, double* %277, i64 %278
store double %276, double* %279
br label %280
280: ; preds = %270
%281 = load i64, i64* %18
%282 = add nsw i64 %281, 1
store i64 %282, i64* %18
br label %267
283: ; preds = %267
store double 0.000000e+00, double* %27
store i64 0, i64* %18
br label %284
284: ; preds = %294, %283
%285 = load i64, i64* %18
%286 = icmp slt i64 %285, 4
br i1 %286, label %287, label %297
287: ; preds = %284
%288 = load double*, double** %12
%289 = load i64, i64* %18
%290 = getelementptr inbounds double, double* %288, i64 %289
%291 = load double, double* %290
%292 = load double, double* %27
%293 = fadd double %292, %291
store double %293, double* %27
br label %294
294: ; preds = %287
%295 = load i64, i64* %18
%296 = add nsw i64 %295, 1
store i64 %296, i64* %18
br label %284
297: ; preds = %284
store i64 0, i64* %18
br label %298
298: ; preds = %308, %297
%299 = load i64, i64* %18
%300 = icmp slt i64 %299, 4
br i1 %300, label %301, label %311
301: ; preds = %298
%302 = load double, double* %27
%303 = load double*, double** %12
%304 = load i64, i64* %18
%305 = getelementptr inbounds double, double* %303, i64 %304
%306 = load double, double* %305
%307 = fdiv double %306, %302
store double %307, double* %305
br label %308
308: ; preds = %301
%309 = load i64, i64* %18
%310 = add nsw i64 %309, 1
store i64 %310, i64* %18
br label %298
311: ; preds = %298
%312 = load i32, i32* %17
ret i32 %312
}

LLVM IR (-O2):
@__func__.grid_search_reg2d_nn = [21 x i8] c"grid_search_reg2d_nn\00"
@.str = [142 x i8] c"/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\00"
define i32 @grid_search_reg2d_nn(i64 %0, i64 %1, i32* noalias nocapture %2, double* noalias nocapture %3, double %4, double %5, double* noalias nocapture %6, double* noalias nocapture %7) {
%9 = tail call double @cos(double %4)
%10 = tail call double @sin(double %4)
%11 = tail call double @cos(double %5)
%12 = tail call double @sin(double %5)
%13 = getelementptr inbounds double, double* %3, i64 1
%14 = bitcast double* %3 to <2 x double>*
store <2 x double> <double 1.000000e+20, double 1.000000e+20>, <2 x double>* %14
%15 = getelementptr inbounds double, double* %3, i64 2
%16 = getelementptr inbounds double, double* %3, i64 3
%17 = bitcast double* %15 to <2 x double>*
store <2 x double> <double 1.000000e+20, double 1.000000e+20>, <2 x double>* %17
%18 = add nsw i64 %1, -1
%19 = load double, double* %7
%20 = fcmp ugt double %19, %5
br i1 %20, label %39, label %21
21: ; preds = %8
%22 = add nsw i64 %0, -1
%23 = getelementptr inbounds double, double* %7, i64 %22
%24 = load double, double* %23
%25 = fcmp ult double %24, %5
br i1 %25, label %39, label %26
26: ; preds = %21
%27 = load double, double* %6
%28 = getelementptr inbounds double, double* %6, i64 %18
%29 = load double, double* %28
%30 = fcmp olt double %27, %29
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = fcmp ult double %27, %4
br i1 %32, label %33, label %39
33: ; preds = %31
%34 = add nsw i64 %1, -2
br label %39
35: ; preds = %26
%36 = fcmp ugt double %27, %4
br i1 %36, label %37, label %39
37: ; preds = %35
%38 = add nsw i64 %1, -2
br label %39
39: ; preds = %35, %31, %33, %37, %21, %8
%40 = phi i64 [ %34, %33 ], [ %38, %37 ], [ 0, %21 ], [ 0, %8 ], [ 0, %31 ], [ 0, %35 ]
%41 = phi i64 [ %18, %33 ], [ %18, %37 ], [ %18, %21 ], [ %18, %8 ], [ 1, %31 ], [ 1, %35 ]
%42 = shl i64 %0, 3
%43 = tail call i32 (i8*, i8*, i32, i64, ...) bitcast (i32 (...)* @Malloc to i32 (i8*, i8*, i32, i64, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.grid_search_reg2d_nn, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str, i64 0, i64 0), i32 47, i64 %42)
%44 = sext i32 %43 to i64
%45 = inttoptr i64 %44 to double*
%46 = icmp sgt i64 %0, 0
br i1 %46, label %47, label %70
47: ; preds = %39
%48 = tail call double @cos(double %19)
%49 = tail call double @sin(double %19)
%50 = fmul double %12, %49
%51 = tail call double @llvm.fmuladd.f64(double %11, double %48, double %50)
store double %51, double* %45
%52 = icmp eq i64 %0, 1
br i1 %52, label %70, label %53
53: ; preds = %47
%54 = add i64 %0, -1
%55 = and i64 %54, 1
%56 = icmp eq i64 %0, 2
br i1 %56, label %59, label %57
57: ; preds = %53
%58 = and i64 %54, -2
br label %86
59: ; preds = %86, %53
%60 = phi i64 [ 1, %53 ], [ %104, %86 ]
%61 = icmp eq i64 %55, 0
br i1 %61, label %70, label %62
62: ; preds = %59
%63 = getelementptr inbounds double, double* %7, i64 %60
%64 = load double, double* %63
%65 = tail call double @cos(double %64)
%66 = tail call double @sin(double %64)
%67 = fmul double %12, %66
%68 = tail call double @llvm.fmuladd.f64(double %11, double %65, double %67)
%69 = getelementptr inbounds double, double* %45, i64 %60
store double %68, double* %69
br label %70
70: ; preds = %62, %59, %47, %39
%71 = icmp sgt i64 %40, %41
br i1 %71, label %179, label %72
72: ; preds = %70
%73 = add nsw i64 %1, -2
%74 = add nsw i64 %0, -2
%75 = getelementptr inbounds double, double* %3, i64 3
%76 = getelementptr inbounds i32, i32* %2, i64 2
%77 = getelementptr inbounds i32, i32* %2, i64 3
%78 = getelementptr inbounds double, double* %3, i64 2
%79 = getelementptr inbounds double, double* %3, i64 3
%80 = getelementptr inbounds i32, i32* %2, i64 1
%81 = getelementptr inbounds i32, i32* %2, i64 2
%82 = getelementptr inbounds double, double* %3, i64 1
%83 = getelementptr inbounds double, double* %3, i64 2
%84 = getelementptr inbounds i32, i32* %2, i64 1
%85 = getelementptr inbounds double, double* %3, i64 1
br label %107
86: ; preds = %86, %57
%87 = phi i64 [ 1, %57 ], [ %104, %86 ]
%88 = phi i64 [ 0, %57 ], [ %105, %86 ]
%89 = getelementptr inbounds double, double* %7, i64 %87
%90 = load double, double* %89
%91 = tail call double @cos(double %90)
%92 = tail call double @sin(double %90)
%93 = fmul double %12, %92
%94 = tail call double @llvm.fmuladd.f64(double %11, double %91, double %93)
%95 = getelementptr inbounds double, double* %45, i64 %87
store double %94, double* %95
%96 = add nuw nsw i64 %87, 1
%97 = getelementptr inbounds double, double* %7, i64 %96
%98 = load double, double* %97
%99 = tail call double @cos(double %98)
%100 = tail call double @sin(double %98)
%101 = fmul double %12, %100
%102 = tail call double @llvm.fmuladd.f64(double %11, double %99, double %101)
%103 = getelementptr inbounds double, double* %45, i64 %96
store double %102, double* %103
%104 = add nuw nsw i64 %87, 2
%105 = add i64 %88, 2
%106 = icmp eq i64 %105, %58
br i1 %106, label %59, label %86
107: ; preds = %72, %173
%108 = phi double [ 1.000000e+20, %72 ], [ %174, %173 ]
%109 = phi i32 [ 0, %72 ], [ %176, %173 ]
%110 = phi i64 [ %40, %72 ], [ %177, %173 ]
%111 = phi double [ 1.000000e+20, %72 ], [ %175, %173 ]
%112 = getelementptr inbounds double, double* %6, i64 %110
%113 = load double, double* %112
%114 = tail call double @cos(double %113)
%115 = fmul double %9, %114
%116 = tail call double @sin(double %113)
%117 = fmul double %10, %116
%118 = icmp sgt i64 %110, 1
%119 = icmp slt i64 %110, %73
%120 = select i1 %118, i1 %119, i1 false
br i1 %46, label %121, label %173
121: ; preds = %107
%122 = mul nsw i64 %110, %0
br label %123
123: ; preds = %121, %167
%124 = phi double [ %108, %121 ], [ %168, %167 ]
%125 = phi i32 [ %109, %121 ], [ %170, %167 ]
%126 = phi i64 [ 0, %121 ], [ %171, %167 ]
%127 = phi double [ %111, %121 ], [ %169, %167 ]
%128 = icmp ugt i64 %126, 1
%129 = select i1 %120, i1 %128, i1 false
%130 = icmp slt i64 %126, %74
%131 = select i1 %129, i1 %130, i1 false
br i1 %131, label %167, label %132
132: ; preds = %123
%133 = add nsw i64 %126, %122
%134 = getelementptr inbounds double, double* %45, i64 %126
%135 = load double, double* %134
%136 = tail call double @llvm.fmuladd.f64(double %115, double %135, double %117)
%137 = tail call double @acos(double %136)
%138 = fcmp olt double %137, %127
br i1 %138, label %139, label %167
139: ; preds = %132
%140 = load double, double* %3
%141 = fcmp olt double %137, %140
br i1 %141, label %142, label %161
142: ; preds = %164, %161, %139
%143 = phi i1 [ false, %164 ], [ true, %161 ], [ true, %139 ]
%144 = phi i1 [ false, %164 ], [ false, %161 ], [ true, %139 ]
%145 = phi i64 [ 2, %164 ], [ 1, %161 ], [ 0, %139 ]
%146 = getelementptr inbounds double, double* %3, i64 %145
%147 = load i32, i32* %76
store i32 %147, i32* %77
%148 = load double, double* %78
store double %148, double* %79
br i1 %143, label %149, label %155
149: ; preds = %142
%150 = load i32, i32* %80
store i32 %150, i32* %81
%151 = load double, double* %82
store double %151, double* %83
br i1 %144, label %152, label %155
152: ; preds = %149
%153 = load i32, i32* %2
store i32 %153, i32* %84
%154 = load double, double* %3
store double %154, double* %85
br label %155
155: ; preds = %142, %149, %152, %164
%156 = phi double* [ %75, %164 ], [ %146, %152 ], [ %146, %149 ], [ %146, %142 ]
%157 = phi i64 [ 3, %164 ], [ %145, %152 ], [ %145, %149 ], [ %145, %142 ]
%158 = trunc i64 %133 to i32
%159 = getelementptr inbounds i32, i32* %2, i64 %157
store i32 %158, i32* %159
store double %137, double* %156
%160 = load double, double* %16
br label %167
161: ; preds = %139
%162 = load double, double* %13
%163 = fcmp olt double %137, %162
br i1 %163, label %142, label %164
164: ; preds = %161
%165 = load double, double* %15
%166 = fcmp olt double %137, %165
br i1 %166, label %142, label %155
167: ; preds = %123, %132, %155
%168 = phi double [ %160, %155 ], [ %124, %132 ], [ %124, %123 ]
%169 = phi double [ %160, %155 ], [ %127, %132 ], [ %127, %123 ]
%170 = phi i32 [ -1, %155 ], [ %125, %132 ], [ %125, %123 ]
%171 = add nuw nsw i64 %126, 1
%172 = icmp eq i64 %171, %0
br i1 %172, label %173, label %123
173: ; preds = %167, %107
%174 = phi double [ %108, %107 ], [ %168, %167 ]
%175 = phi double [ %111, %107 ], [ %169, %167 ]
%176 = phi i32 [ %109, %107 ], [ %170, %167 ]
%177 = add i64 %110, 1
%178 = icmp eq i64 %110, %41
br i1 %178, label %179, label %107
179: ; preds = %173, %70
%180 = phi double [ 1.000000e+20, %70 ], [ %174, %173 ]
%181 = phi i32 [ 0, %70 ], [ %176, %173 ]
%182 = tail call i32 (i8*, i8*, i32, double*, ...) bitcast (i32 (...)* @Free to i32 (i8*, i8*, i32, double*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.grid_search_reg2d_nn, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str, i64 0, i64 0), i32 89, double* %45)
%183 = bitcast double* %3 to <2 x double>*
%184 = load <2 x double>, <2 x double>* %183
%185 = fadd <2 x double> %184, <double 0x3D06849B86A12B9B, double 0x3D06849B86A12B9B>
%186 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %185
%187 = load double, double* %15
%188 = insertelement <2 x double> poison, double %187, i64 0
%189 = insertelement <2 x double> %188, double %180, i64 1
%190 = fadd <2 x double> %189, <double 0x3D06849B86A12B9B, double 0x3D06849B86A12B9B>
%191 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %190
%192 = extractelement <2 x double> %186, i64 0
%193 = fadd double %192, 0.000000e+00
%194 = extractelement <2 x double> %186, i64 1
%195 = fadd double %193, %194
%196 = extractelement <2 x double> %191, i64 0
%197 = fadd double %195, %196
%198 = extractelement <2 x double> %191, i64 1
%199 = fadd double %197, %198
%200 = insertelement <2 x double> poison, double %199, i64 0
%201 = shufflevector <2 x double> %200, <2 x double> poison, <2 x i32> zeroinitializer
%202 = fdiv <2 x double> %186, %201
%203 = bitcast double* %3 to <2 x double>*
store <2 x double> %202, <2 x double>* %203
%204 = fdiv <2 x double> %191, %201
%205 = bitcast double* %15 to <2 x double>*
store <2 x double> %204, <2 x double>* %205
ret i32 %181
}