int create_xgrid_2dx1d_order2(const int *nlon_in, const int *nlat_in,
                              const int *nlon_out, const int *nlat_out,
                              const double *lon_in, const double *lat_in,
                              const double *lon_out, const double *lat_out,
                              const double *mask_in, int *i_in, int *j_in,
                              int *i_out, int *j_out, double *xgrid_area,
                              double *xgrid_clon, double *xgrid_clat) {
  int nx1, ny1, nx2, ny2, nx1p, nx2p;
  int i1, j1, i2, j2, nxgrid, n;
  double ll_lon, ll_lat, ur_lon, ur_lat, x_in[50], y_in[50], x_out[50],
      y_out[50];
  double *tmpx, *tmpy;
  double *area_in, *area_out, min_area;
  double lon_in_avg;
  nx1 = *nlon_in;
  ny1 = *nlat_in;
  nx2 = *nlon_out;
  ny2 = *nlat_out;
  nxgrid = 0;
  nx1p = nx1 + 1;
  nx2p = nx2 + 1;
  area_in = (double *)malloc(nx1 * ny1 * sizeof(double));
  area_out = (double *)malloc(nx2 * ny2 * sizeof(double));
  tmpx = (double *)malloc((nx2 + 1) * (ny2 + 1) * sizeof(double));
  tmpy = (double *)malloc((nx2 + 1) * (ny2 + 1) * sizeof(double));
  for (j2 = 0; j2 <= ny2; j2++)
    for (i2 = 0; i2 <= nx2; i2++) {
      tmpx[j2 * nx2p + i2] = lon_out[i2];
      tmpy[j2 * nx2p + i2] = lat_out[j2];
    }
  get_grid_area(nlon_in, nlat_in, lon_in, lat_in, area_in);
  get_grid_area(nlon_out, nlat_out, tmpx, tmpy, area_out);
  free(tmpx);
  free(tmpy);
  for (j2 = 0; j2 < ny2; j2++)
    for (i2 = 0; i2 < nx2; i2++) {
      ll_lon = lon_out[i2];
      ll_lat = lat_out[j2];
      ur_lon = lon_out[i2 + 1];
      ur_lat = lat_out[j2 + 1];
      for (j1 = 0; j1 < ny1; j1++)
        for (i1 = 0; i1 < nx1; i1++)
          if (mask_in[j1 * nx1 + i1] > (0.5)) {
            int n_in, n_out;
            double xarea;
            y_in[0] = lat_in[j1 * nx1p + i1];
            y_in[1] = lat_in[j1 * nx1p + i1 + 1];
            y_in[2] = lat_in[(j1 + 1) * nx1p + i1 + 1];
            y_in[3] = lat_in[(j1 + 1) * nx1p + i1];
            if ((y_in[0] <= ll_lat) && (y_in[1] <= ll_lat) &&
                (y_in[2] <= ll_lat) && (y_in[3] <= ll_lat))
              continue;
            if ((y_in[0] >= ur_lat) && (y_in[1] >= ur_lat) &&
                (y_in[2] >= ur_lat) && (y_in[3] >= ur_lat))
              continue;
            x_in[0] = lon_in[j1 * nx1p + i1];
            x_in[1] = lon_in[j1 * nx1p + i1 + 1];
            x_in[2] = lon_in[(j1 + 1) * nx1p + i1 + 1];
            x_in[3] = lon_in[(j1 + 1) * nx1p + i1];
            n_in = fix_lon(x_in, y_in, 4, (ll_lon + ur_lon) / 2);
            lon_in_avg = avgval_double(n_in, x_in);
            if ((n_out = clip(x_in, y_in, n_in, ll_lon, ll_lat, ur_lon, ur_lat,
                              x_out, y_out)) > 0) {
              xarea = poly_area(x_out, y_out, n_out) * mask_in[j1 * nx1 + i1];
              min_area = (area_in[j1 * nx1 + i1] < area_out[j2 * nx2 + i2]
                              ? area_in[j1 * nx1 + i1]
                              : area_out[j2 * nx2 + i2]);
              if (xarea / min_area > (1.e-6)) {
                xgrid_area[nxgrid] = xarea;
                xgrid_clon[nxgrid] =
                    poly_ctrlon(x_out, y_out, n_out, lon_in_avg);
                xgrid_clat[nxgrid] = poly_ctrlat(x_out, y_out, n_out);
                i_in[nxgrid] = i1;
                j_in[nxgrid] = j1;
                i_out[nxgrid] = i2;
                j_out[nxgrid] = j2;
                ++nxgrid;
                if (nxgrid > 1e7)
                  error_handler(
                      "nxgrid is greater than MAXXGRID, increase MAXXGRID");
              }
            }
          }
    }
  free(area_in);
  free(area_out);
  return nxgrid;
}


x86 assembly (clang, -O0):
<create_xgrid_2dx1d_order2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x710,%rsp
mov    0x58(%rbp),%rax
mov    0x50(%rbp),%rax
mov    0x48(%rbp),%rax
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x34(%rbp),%eax
imul   -0x38(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x6d8(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x40(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x6e0(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x6c8(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    -0x40(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x6d0(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x40(%rbp),%eax
jg     1333 <create_xgrid_2dx1d_order2+0x193>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     1320 <create_xgrid_2dx1d_order2+0x180>
mov    0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x6c8(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x6d0(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12ba <create_xgrid_2dx1d_order2+0x11a>
jmp    1325 <create_xgrid_2dx1d_order2+0x185>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    12a7 <create_xgrid_2dx1d_order2+0x107>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x6d8(%rbp),%r8
mov    $0x0,%al
call   10c0 <get_grid_area@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x6c8(%rbp),%rdx
mov    -0x6d0(%rbp),%rcx
mov    -0x6e0(%rbp),%r8
mov    $0x0,%al
call   10c0 <get_grid_area@plt>
mov    -0x6c8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x6d0(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    18d7 <create_xgrid_2dx1d_order2+0x737>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    18c4 <create_xgrid_2dx1d_order2+0x724>
mov    0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    18b1 <create_xgrid_2dx1d_order2+0x711>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    189e <create_xgrid_2dx1d_order2+0x6fe>
mov    0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xbb7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    188b <create_xgrid_2dx1d_order2+0x6eb>
mov    -0x30(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x3a0(%rbp)
ff
mov    -0x30(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x398(%rbp)
ff
mov    -0x30(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x390(%rbp)
ff
mov    -0x30(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x388(%rbp)
ff
movsd  -0x3a0(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1538 <create_xgrid_2dx1d_order2+0x398>
movsd  -0x398(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1538 <create_xgrid_2dx1d_order2+0x398>
movsd  -0x390(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1538 <create_xgrid_2dx1d_order2+0x398>
movsd  -0x388(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1538 <create_xgrid_2dx1d_order2+0x398>
jmp    1890 <create_xgrid_2dx1d_order2+0x6f0>
movsd  -0x3a0(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jb     1589 <create_xgrid_2dx1d_order2+0x3e9>
movsd  -0x398(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jb     1589 <create_xgrid_2dx1d_order2+0x3e9>
movsd  -0x390(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jb     1589 <create_xgrid_2dx1d_order2+0x3e9>
movsd  -0x388(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jb     1589 <create_xgrid_2dx1d_order2+0x3e9>
jmp    1890 <create_xgrid_2dx1d_order2+0x6f0>
mov    -0x28(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x210(%rbp)
ff
mov    -0x28(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x208(%rbp)
ff
mov    -0x28(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x200(%rbp)
ff
mov    -0x28(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x1f8(%rbp)
ff
lea    -0x210(%rbp),%rdi
lea    -0x3a0(%rbp),%rsi
movsd  -0x68(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  0x9db(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0x4,%edx
mov    $0x1,%al
call   1080 <fix_lon@plt>
mov    %eax,-0x6f4(%rbp)
mov    -0x6f4(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x0,%al
call   1090 <avgval_double@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x6f0(%rbp)
ff
lea    -0x210(%rbp),%rdi
lea    -0x3a0(%rbp),%rsi
mov    -0x6f4(%rbp),%edx
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
movsd  -0x80(%rbp),%xmm3
lea    -0x530(%rbp),%rcx
lea    -0x6c0(%rbp),%r8
mov    $0x4,%al
call   1040 <clip@plt>
mov    %eax,-0x6f8(%rbp)
cmp    $0x0,%eax
jle    1886 <create_xgrid_2dx1d_order2+0x6e6>
lea    -0x530(%rbp),%rdi
lea    -0x6c0(%rbp),%rsi
mov    -0x6f8(%rbp),%edx
mov    $0x0,%al
call   1060 <poly_area@plt>
cvtsi2sd %eax,%xmm0
mov    0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x700(%rbp)
ff
mov    -0x6d8(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x6e0(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    174e <create_xgrid_2dx1d_order2+0x5ae>
mov    -0x6d8(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x708(%rbp)
ff
jmp    176f <create_xgrid_2dx1d_order2+0x5cf>
mov    -0x6e0(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x708(%rbp)
ff
movsd  -0x708(%rbp),%xmm0
ff
movsd  %xmm0,-0x6e8(%rbp)
ff
movsd  -0x700(%rbp),%xmm0
ff
divsd  -0x6e8(%rbp),%xmm0
ff
movsd  0x879(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1881 <create_xgrid_2dx1d_order2+0x6e1>
movsd  -0x700(%rbp),%xmm0
ff
mov    0x48(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
lea    -0x530(%rbp),%rdi
lea    -0x6c0(%rbp),%rsi
mov    -0x6f8(%rbp),%edx
movsd  -0x6f0(%rbp),%xmm0
ff
mov    $0x1,%al
call   10a0 <poly_ctrlon@plt>
cvtsi2sd %eax,%xmm0
mov    0x50(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
lea    -0x530(%rbp),%rdi
lea    -0x6c0(%rbp),%rsi
mov    -0x6f8(%rbp),%edx
mov    $0x0,%al
call   1070 <poly_ctrlat@plt>
cvtsi2sd %eax,%xmm0
mov    0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%edx
mov    0x28(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x50(%rbp),%edx
mov    0x30(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x54(%rbp),%edx
mov    0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x58(%rbp),%edx
mov    0x40(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp),%xmm0
movsd  0x7b4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    187c <create_xgrid_2dx1d_order2+0x6dc>
lea    0x7ab(%rip),%rdi
mov    $0x0,%al
call   1050 <error_handler@plt>
jmp    1881 <create_xgrid_2dx1d_order2+0x6e1>
jmp    1886 <create_xgrid_2dx1d_order2+0x6e6>
jmp    188b <create_xgrid_2dx1d_order2+0x6eb>
jmp    1890 <create_xgrid_2dx1d_order2+0x6f0>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    141f <create_xgrid_2dx1d_order2+0x27f>
jmp    18a3 <create_xgrid_2dx1d_order2+0x703>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    140c <create_xgrid_2dx1d_order2+0x26c>
jmp    18b6 <create_xgrid_2dx1d_order2+0x716>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    13a7 <create_xgrid_2dx1d_order2+0x207>
jmp    18c9 <create_xgrid_2dx1d_order2+0x729>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1394 <create_xgrid_2dx1d_order2+0x1f4>
mov    -0x6d8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x6e0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x5c(%rbp),%eax
add    $0x710,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_xgrid_2dx1d_order2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x788,%rsp
mov    %r9,0x68(%rsp)
mov    %r8,0xe0(%rsp)
mov    %rdi,0x80(%rsp)
movslq (%rdi),%rdi
mov    %rsi,0x88(%rsp)
mov    (%rsi),%eax
mov    %rdx,0x10(%rsp)
movslq (%rdx),%rbx
mov    %ebx,%edx
mov    %rdx,0xc8(%rsp)
mov    %rcx,0x28(%rsp)
mov    (%rcx),%ebp
lea    0x1(%rbx),%r15
mov    %rax,0xe8(%rsp)
mov    %rdi,0xd8(%rsp)
imul   %edi,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x70(%rsp)
mov    %ebp,%eax
mov    %rbx,0xd0(%rsp)
imul   %ebx,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x78(%rsp)
lea    0x1(%rbp),%r14d
mov    %r14d,%eax
mov    %r15,0x18(%rsp)
imul   %r15d,%eax
movslq %eax,%rbx
shl    $0x3,%rbx
mov    %rbx,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x48(%rsp)
mov    %rbx,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x38(%rsp)
mov    %rbp,0xc0(%rsp)
test   %ebp,%ebp
js     1484 <create_xgrid_2dx1d_order2+0x2d4>
mov    0x18(%rsp),%rax
mov    %eax,%ebx
lea    0x0(,%rbx,8),%rcx
mov    %rcx,0xa0(%rsp)
mov    %r14d,%ecx
mov    %rcx,0xa8(%rsp)
mov    %ebx,%ecx
and    $0xfffffffc,%ecx
mov    %rcx,0x40(%rsp)
add    $0xfffffffffffffffc,%rcx
mov    %rcx,0x98(%rsp)
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %ecx,%r13d
and    $0x3,%r13d
and    $0xfffffffffffffffc,%rcx
mov    %rcx,0xf0(%rsp)
mov    0x38(%rsp),%rbp
lea    0x70(%rbp),%r14
shl    $0x3,%rax
mov    %rax,0x30(%rsp)
mov    %rbp,%rdx
add    $0x10,%rdx
mov    %r13,0x90(%rsp)
shl    $0x5,%r13
xor    %r15d,%r15d
mov    0x18(%rsp),%r12
jmp    1330 <create_xgrid_2dx1d_order2+0x180>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15
mov    0x30(%rsp),%rax
add    %rax,%r14
add    %rax,%rdx
add    %rax,%rbp
cmp    0xa8(%rsp),%r15
je     1484 <create_xgrid_2dx1d_order2+0x2d4>
cmpl   $0x0,0xc8(%rsp)
js     1310 <create_xgrid_2dx1d_order2+0x160>
mov    %rdx,0xb0(%rsp)
mov    %r12d,%eax
imul   %r15d,%eax
cltq
mov    0x48(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x7c8(%rsp),%rax
movsd  (%rax,%r15,8),%xmm0
movapd %xmm0,0x50(%rsp)
mov    0x7c0(%rsp),%rsi
mov    0xa0(%rsp),%rdx
call   1070 <memcpy@plt>
cmp    $0x4,%r12d
jae    13a0 <create_xgrid_2dx1d_order2+0x1f0>
xor    %eax,%eax
mov    0xb0(%rsp),%rdx
movapd 0x50(%rsp),%xmm1
jmp    1470 <create_xgrid_2dx1d_order2+0x2c0>
nopl   0x0(%rax,%rax,1)
movapd 0x50(%rsp),%xmm1
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
cmpq   $0xc,0x98(%rsp)
jae    13c5 <create_xgrid_2dx1d_order2+0x215>
xor    %eax,%eax
mov    0xb0(%rsp),%rdx
jmp    1421 <create_xgrid_2dx1d_order2+0x271>
mov    0xf0(%rsp),%rcx
xor    %eax,%eax
mov    0xb0(%rsp),%rdx
nopw   0x0(%rax,%rax,1)
movupd %xmm0,-0x70(%r14,%rax,8)
movupd %xmm0,-0x60(%r14,%rax,8)
movupd %xmm0,-0x50(%r14,%rax,8)
movupd %xmm0,-0x40(%r14,%rax,8)
movupd %xmm0,-0x30(%r14,%rax,8)
movupd %xmm0,-0x20(%r14,%rax,8)
movupd %xmm0,-0x10(%r14,%rax,8)
movupd %xmm0,(%r14,%rax,8)
add    $0x10,%rax
add    $0xfffffffffffffffc,%rcx
jne    13e0 <create_xgrid_2dx1d_order2+0x230>
cmpq   $0x0,0x90(%rsp)
je     1454 <create_xgrid_2dx1d_order2+0x2a4>
lea    (%rdx,%rax,8),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd %xmm0,-0x10(%rax,%rcx,1)
movupd %xmm0,(%rax,%rcx,1)
add    $0x20,%rcx
cmp    %rcx,%r13
jne    1440 <create_xgrid_2dx1d_order2+0x290>
mov    0x40(%rsp),%rcx
mov    %rcx,%rax
cmp    %rbx,%rcx
je     1310 <create_xgrid_2dx1d_order2+0x160>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm1,0x0(%rbp,%rax,8)
add    $0x1,%rax
cmp    %rax,%rbx
jne    1470 <create_xgrid_2dx1d_order2+0x2c0>
jmp    1310 <create_xgrid_2dx1d_order2+0x160>
movl   $0x0,0xc(%rsp)
mov    0x80(%rsp),%rdi
mov    0x88(%rsp),%rsi
mov    0xe0(%rsp),%rdx
mov    0x68(%rsp),%rcx
mov    0x70(%rsp),%r8
xor    %eax,%eax
call   10d0 <get_grid_area@plt>
mov    0x10(%rsp),%rdi
mov    0x28(%rsp),%rsi
mov    0x48(%rsp),%rbx
mov    %rbx,%rdx
mov    0x38(%rsp),%rbp
mov    %rbp,%rcx
mov    0x78(%rsp),%r8
xor    %eax,%eax
call   10d0 <get_grid_area@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
cmpl   $0x0,0xc0(%rsp)
mov    0xd8(%rsp),%rcx
mov    0xd0(%rsp),%rdx
jle    1a2e <create_xgrid_2dx1d_order2+0x87e>
mov    %ecx,%edi
lea    0x1(%rcx),%rax
mov    %rax,0x120(%rsp)
mov    0x68(%rsp),%rax
add    $0x8,%rax
mov    %rax,0x118(%rsp)
lea    0x0(,%rcx,8),%rax
mov    %rax,0x110(%rsp)
movsd  0xac0(%rip),%xmm4
lea    0x5f0(%rsp),%r15
lea    0x460(%rsp),%r13
xor    %eax,%eax
mov    %rax,0x20(%rsp)
movl   $0x0,0xc(%rsp)
mov    %rdi,0x28(%rsp)
jmp    158e <create_xgrid_2dx1d_order2+0x3de>
cs nopw 0x0(%rax,%rax,1)
mov    0x100(%rsp),%rsi
mov    %rsi,%rax
mov    %rsi,0x20(%rsp)
cmp    0xc0(%rsp),%rsi
je     1a2e <create_xgrid_2dx1d_order2+0x87e>
test   %edx,%edx
jle    1a20 <create_xgrid_2dx1d_order2+0x870>
mov    0x20(%rsp),%rax
lea    0x1(%rax),%rsi
mov    %rsi,0x100(%rsp)
imul   %rdx,%rax
mov    %rax,0x108(%rsp)
xor    %ebp,%ebp
jmp    15ca <create_xgrid_2dx1d_order2+0x41a>
nopw   0x0(%rax,%rax,1)
cmp    0xc8(%rsp),%rbp
je     1570 <create_xgrid_2dx1d_order2+0x3c0>
mov    %rbp,%rbx
add    $0x1,%rbp
cmpl   $0x0,0xe8(%rsp)
jle    15c0 <create_xgrid_2dx1d_order2+0x410>
mov    0x7c0(%rsp),%rax
movsd  (%rax,%rbx,8),%xmm0
movsd  0x8(%rax,%rbx,8),%xmm1
mov    0x7c8(%rsp),%rax
mov    0x20(%rsp),%rsi
movsd  (%rax,%rsi,8),%xmm5
movsd  0x8(%rax,%rsi,8),%xmm2
movsd  %xmm0,0x98(%rsp)
movsd  %xmm1,0x90(%rsp)
addsd  %xmm1,%xmm0
mulsd  %xmm4,%xmm0
movsd  %xmm0,0x38(%rsp)
mov    0x108(%rsp),%rax
mov    %rbx,0x130(%rsp)
add    %rbx,%rax
mov    %rax,0x80(%rsp)
movapd %xmm2,0xf0(%rsp)
unpcklpd %xmm2,%xmm2
movapd %xmm2,0xb0(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    %rbp,0x128(%rsp)
movsd  %xmm5,0x50(%rsp)
jmp    16a6 <create_xgrid_2dx1d_order2+0x4f6>
xchg   %ax,%ax
mov    0x138(%rsp),%rsi
mov    %rsi,%rax
mov    %rsi,0x10(%rsp)
mov    0xd8(%rsp),%rcx
mov    0xd0(%rsp),%rdx
mov    0x128(%rsp),%rbp
cmp    0xe8(%rsp),%rsi
je     15c0 <create_xgrid_2dx1d_order2+0x410>
test   %ecx,%ecx
jle    1a00 <create_xgrid_2dx1d_order2+0x850>
mov    0x10(%rsp),%rax
mov    %rax,%rbp
imul   %rcx,%rbp
mov    %rax,%rcx
mov    0x120(%rsp),%rsi
imul   %rsi,%rcx
lea    0x1(%rax),%rdx
mov    %rdx,0x138(%rsp)
imul   %rsi,%rdx
mov    0x118(%rsp),%rsi
lea    (%rsi,%rdx,8),%rbx
mov    0xe0(%rsp),%rsi
lea    (%rsi,%rdx,8),%rdx
mov    %rdx,0x48(%rsp)
mov    0x68(%rsp),%rdx
lea    (%rdx,%rcx,8),%rdx
lea    (%rsi,%rcx,8),%rcx
mov    %rcx,0xa0(%rsp)
mov    0x7d0(%rsp),%rcx
lea    (%rcx,%rbp,8),%r12
imul   0x110(%rsp),%rax
add    0x70(%rsp),%rax
mov    %rax,0x88(%rsp)
xor    %ebp,%ebp
mov    %rbx,0x30(%rsp)
mov    %rdx,0x18(%rsp)
mov    %r12,0x40(%rsp)
jmp    176d <create_xgrid_2dx1d_order2+0x5bd>
mov    0x28(%rsp),%rdi
movsd  0x8b3(%rip),%xmm4
movsd  0x50(%rsp),%xmm5
mov    0x30(%rsp),%rbx
mov    0x18(%rsp),%rdx
nopl   (%rax)
add    $0x1,%rbp
cmp    %rbp,%rdi
je     1670 <create_xgrid_2dx1d_order2+0x4c0>
movsd  (%r12,%rbp,8),%xmm0
ucomisd %xmm4,%xmm0
jbe    1760 <create_xgrid_2dx1d_order2+0x5b0>
movupd (%rdx,%rbp,8),%xmm0
movapd %xmm0,0x140(%rsp)
movsd  (%rbx,%rbp,8),%xmm1
movsd  %xmm1,0x150(%rsp)
movsd  -0x8(%rbx,%rbp,8),%xmm2
movsd  %xmm2,0x158(%rsp)
ucomisd %xmm0,%xmm5
jb     17c4 <create_xgrid_2dx1d_order2+0x614>
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
ucomisd %xmm3,%xmm5
jb     17c4 <create_xgrid_2dx1d_order2+0x614>
ucomisd %xmm1,%xmm5
jb     17c4 <create_xgrid_2dx1d_order2+0x614>
ucomisd %xmm2,%xmm5
jae    1760 <create_xgrid_2dx1d_order2+0x5b0>
unpcklpd %xmm2,%xmm1
movapd 0xb0(%rsp),%xmm3
movapd %xmm3,%xmm2
cmpnlepd %xmm0,%xmm2
movapd %xmm3,%xmm0
cmpnlepd %xmm1,%xmm0
shufps $0x88,%xmm0,%xmm2
pslld  $0x1f,%xmm2
movmskps %xmm2,%eax
test   %eax,%eax
je     1760 <create_xgrid_2dx1d_order2+0x5b0>
mov    0xa0(%rsp),%rax
movups (%rax,%rbp,8),%xmm0
movaps %xmm0,0x2d0(%rsp)
mov    0x48(%rsp),%rax
movups (%rax,%rbp,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movaps %xmm0,0x2e0(%rsp)
lea    0x2d0(%rsp),%r14
mov    %r14,%rdi
mov    %r13,%r12
mov    %r15,%r13
lea    0x140(%rsp),%r15
mov    %r15,%rsi
mov    $0x4,%edx
movsd  0x38(%rsp),%xmm0
mov    $0x1,%al
call   1090 <fix_lon@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <avgval_double@plt>
mov    %eax,0xa8(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%r15
mov    %r12,%r13
mov    %ebx,%edx
movsd  0x98(%rsp),%xmm0
movsd  0x50(%rsp),%xmm1
movsd  0x90(%rsp),%xmm2
movapd 0xf0(%rsp),%xmm3
mov    %r15,%rcx
mov    %r12,%r8
mov    $0x4,%al
call   1040 <clip@plt>
test   %eax,%eax
jle    19ca <create_xgrid_2dx1d_order2+0x81a>
mov    %eax,%r14d
mov    %r15,%rdi
mov    %r13,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <poly_area@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov    0x40(%rsp),%r12
mulsd  (%r12,%rbp,8),%xmm1
mov    0x88(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
mov    0x78(%rsp),%rax
mov    0x80(%rsp),%rcx
minsd  (%rax,%rcx,8),%xmm0
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
ucomisd 0x70e(%rip),%xmm2
jbe    1740 <create_xgrid_2dx1d_order2+0x590>
xorps  %xmm0,%xmm0
cvtsi2sdl 0xa8(%rsp),%xmm0
movslq 0xc(%rsp),%rbx
mov    0x7f8(%rsp),%rax
movsd  %xmm1,(%rax,%rbx,8)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
mov    $0x1,%al
call   10b0 <poly_ctrlon@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x800(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,8)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1080 <poly_ctrlat@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x808(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,8)
mov    0x7d8(%rsp),%rax
mov    %ebp,(%rax,%rbx,4)
mov    0x7e0(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
mov    0x7e8(%rsp),%rax
mov    0x130(%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
mov    0x7f0(%rsp),%rax
mov    0x20(%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
lea    0x1(%rbx),%eax
mov    %eax,0xc(%rsp)
cmp    $0x989680,%ebx
jl     1740 <create_xgrid_2dx1d_order2+0x590>
lea    0x652(%rip),%rdi
xor    %eax,%eax
call   1050 <error_handler@plt>
jmp    1740 <create_xgrid_2dx1d_order2+0x590>
mov    0x28(%rsp),%rdi
movsd  0x629(%rip),%xmm4
movsd  0x50(%rsp),%xmm5
mov    0x30(%rsp),%rbx
mov    0x18(%rsp),%rdx
mov    0x40(%rsp),%r12
jmp    1760 <create_xgrid_2dx1d_order2+0x5b0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rsi
add    $0x1,%rsi
mov    %rsi,%rax
mov    %rsi,0x10(%rsp)
jmp    1698 <create_xgrid_2dx1d_order2+0x4e8>
cs nopw 0x0(%rax,%rax,1)
mov    0x20(%rsp),%rsi
add    $0x1,%rsi
jmp    1578 <create_xgrid_2dx1d_order2+0x3c8>
mov    0x70(%rsp),%rdi
call   1030 <free@plt>
mov    0x78(%rsp),%rdi
call   1030 <free@plt>
mov    0xc(%rsp),%eax
add    $0x788,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"nxgrid is greater than MAXXGRID, increase MAXXGRID\00"
define i32 @create_xgrid_2dx1d_order2(i32* %0, i32* %1, i32* %2, i32* %3, double* %4, double* %5, double* %6, double* %7, double* %8, i32* %9, i32* %10, i32* %11, i32* %12, double* %13, double* %14, double* %15) {
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca double*
%22 = alloca double*
%23 = alloca double*
%24 = alloca double*
%25 = alloca double*
%26 = alloca i32*
%27 = alloca i32*
%28 = alloca i32*
%29 = alloca i32*
%30 = alloca double*
%31 = alloca double*
%32 = alloca double*
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
%38 = alloca i32
%39 = alloca i32
%40 = alloca i32
%41 = alloca i32
%42 = alloca i32
%43 = alloca i32
%44 = alloca i32
%45 = alloca double
%46 = alloca double
%47 = alloca double
%48 = alloca double
%49 = alloca [50 x double]
%50 = alloca [50 x double]
%51 = alloca [50 x double]
%52 = alloca [50 x double]
%53 = alloca double*
%54 = alloca double*
%55 = alloca double*
%56 = alloca double*
%57 = alloca double
%58 = alloca double
%59 = alloca i32
%60 = alloca i32
%61 = alloca double
store i32* %0, i32** %17
store i32* %1, i32** %18
store i32* %2, i32** %19
store i32* %3, i32** %20
store double* %4, double** %21
store double* %5, double** %22
store double* %6, double** %23
store double* %7, double** %24
store double* %8, double** %25
store i32* %9, i32** %26
store i32* %10, i32** %27
store i32* %11, i32** %28
store i32* %12, i32** %29
store double* %13, double** %30
store double* %14, double** %31
store double* %15, double** %32
%62 = load i32*, i32** %17
%63 = load i32, i32* %62
store i32 %63, i32* %33
%64 = load i32*, i32** %18
%65 = load i32, i32* %64
store i32 %65, i32* %34
%66 = load i32*, i32** %19
%67 = load i32, i32* %66
store i32 %67, i32* %35
%68 = load i32*, i32** %20
%69 = load i32, i32* %68
store i32 %69, i32* %36
store i32 0, i32* %43
%70 = load i32, i32* %33
%71 = add nsw i32 %70, 1
store i32 %71, i32* %37
%72 = load i32, i32* %35
%73 = add nsw i32 %72, 1
store i32 %73, i32* %38
%74 = load i32, i32* %33
%75 = load i32, i32* %34
%76 = mul nsw i32 %74, %75
%77 = sext i32 %76 to i64
%78 = mul i64 %77, 8
%79 = call i8* @malloc(i64 %78)
%80 = bitcast i8* %79 to double*
store double* %80, double** %55
%81 = load i32, i32* %35
%82 = load i32, i32* %36
%83 = mul nsw i32 %81, %82
%84 = sext i32 %83 to i64
%85 = mul i64 %84, 8
%86 = call i8* @malloc(i64 %85)
%87 = bitcast i8* %86 to double*
store double* %87, double** %56
%88 = load i32, i32* %35
%89 = add nsw i32 %88, 1
%90 = load i32, i32* %36
%91 = add nsw i32 %90, 1
%92 = mul nsw i32 %89, %91
%93 = sext i32 %92 to i64
%94 = mul i64 %93, 8
%95 = call i8* @malloc(i64 %94)
%96 = bitcast i8* %95 to double*
store double* %96, double** %53
%97 = load i32, i32* %35
%98 = add nsw i32 %97, 1
%99 = load i32, i32* %36
%100 = add nsw i32 %99, 1
%101 = mul nsw i32 %98, %100
%102 = sext i32 %101 to i64
%103 = mul i64 %102, 8
%104 = call i8* @malloc(i64 %103)
%105 = bitcast i8* %104 to double*
store double* %105, double** %54
store i32 0, i32* %42
br label %106
106: ; preds = %146, %16
%107 = load i32, i32* %42
%108 = load i32, i32* %36
%109 = icmp sle i32 %107, %108
br i1 %109, label %110, label %149
110: ; preds = %106
store i32 0, i32* %41
br label %111
111: ; preds = %142, %110
%112 = load i32, i32* %41
%113 = load i32, i32* %35
%114 = icmp sle i32 %112, %113
br i1 %114, label %115, label %145
115: ; preds = %111
%116 = load double*, double** %23
%117 = load i32, i32* %41
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds double, double* %116, i64 %118
%120 = load double, double* %119
%121 = load double*, double** %53
%122 = load i32, i32* %42
%123 = load i32, i32* %38
%124 = mul nsw i32 %122, %123
%125 = load i32, i32* %41
%126 = add nsw i32 %124, %125
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %121, i64 %127
store double %120, double* %128
%129 = load double*, double** %24
%130 = load i32, i32* %42
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds double, double* %129, i64 %131
%133 = load double, double* %132
%134 = load double*, double** %54
%135 = load i32, i32* %42
%136 = load i32, i32* %38
%137 = mul nsw i32 %135, %136
%138 = load i32, i32* %41
%139 = add nsw i32 %137, %138
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds double, double* %134, i64 %140
store double %133, double* %141
br label %142
142: ; preds = %115
%143 = load i32, i32* %41
%144 = add nsw i32 %143, 1
store i32 %144, i32* %41
br label %111
145: ; preds = %111
br label %146
146: ; preds = %145
%147 = load i32, i32* %42
%148 = add nsw i32 %147, 1
store i32 %148, i32* %42
br label %106
149: ; preds = %106
%150 = load i32*, i32** %17
%151 = load i32*, i32** %18
%152 = load double*, double** %21
%153 = load double*, double** %22
%154 = load double*, double** %55
%155 = call i32 (i32*, i32*, double*, double*, double*, ...) bitcast (i32 (...)* @get_grid_area to i32 (i32*, i32*, double*, double*, double*, ...)*)(i32* %150, i32* %151, double* %152, double* %153, double* %154)
%156 = load i32*, i32** %19
%157 = load i32*, i32** %20
%158 = load double*, double** %53
%159 = load double*, double** %54
%160 = load double*, double** %56
%161 = call i32 (i32*, i32*, double*, double*, double*, ...) bitcast (i32 (...)* @get_grid_area to i32 (i32*, i32*, double*, double*, double*, ...)*)(i32* %156, i32* %157, double* %158, double* %159, double* %160)
%162 = load double*, double** %53
%163 = bitcast double* %162 to i8*
%164 = load double*, double** %54
%165 = bitcast double* %164 to i8*
store i32 0, i32* %42
br label %166
166: ; preds = %500, %149
%167 = load i32, i32* %42
%168 = load i32, i32* %36
%169 = icmp slt i32 %167, %168
br i1 %169, label %170, label %503
170: ; preds = %166
store i32 0, i32* %41
br label %171
171: ; preds = %496, %170
%172 = load i32, i32* %41
%173 = load i32, i32* %35
%174 = icmp slt i32 %172, %173
br i1 %174, label %175, label %499
175: ; preds = %171
%176 = load double*, double** %23
%177 = load i32, i32* %41
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds double, double* %176, i64 %178
%180 = load double, double* %179
store double %180, double* %45
%181 = load double*, double** %24
%182 = load i32, i32* %42
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %181, i64 %183
%185 = load double, double* %184
store double %185, double* %46
%186 = load double*, double** %23
%187 = load i32, i32* %41
%188 = add nsw i32 %187, 1
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds double, double* %186, i64 %189
%191 = load double, double* %190
store double %191, double* %47
%192 = load double*, double** %24
%193 = load i32, i32* %42
%194 = add nsw i32 %193, 1
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds double, double* %192, i64 %195
%197 = load double, double* %196
store double %197, double* %48
store i32 0, i32* %40
br label %198
198: ; preds = %492, %175
%199 = load i32, i32* %40
%200 = load i32, i32* %34
%201 = icmp slt i32 %199, %200
br i1 %201, label %202, label %495
202: ; preds = %198
store i32 0, i32* %39
br label %203
203: ; preds = %488, %202
%204 = load i32, i32* %39
%205 = load i32, i32* %33
%206 = icmp slt i32 %204, %205
br i1 %206, label %207, label %491
207: ; preds = %203
%208 = load double*, double** %25
%209 = load i32, i32* %40
%210 = load i32, i32* %33
%211 = mul nsw i32 %209, %210
%212 = load i32, i32* %39
%213 = add nsw i32 %211, %212
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds double, double* %208, i64 %214
%216 = load double, double* %215
%217 = fcmp ogt double %216, 5.000000e-01
br i1 %217, label %218, label %487
218: ; preds = %207
%219 = load double*, double** %22
%220 = load i32, i32* %40
%221 = load i32, i32* %37
%222 = mul nsw i32 %220, %221
%223 = load i32, i32* %39
%224 = add nsw i32 %222, %223
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds double, double* %219, i64 %225
%227 = load double, double* %226
%228 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
store double %227, double* %228
%229 = load double*, double** %22
%230 = load i32, i32* %40
%231 = load i32, i32* %37
%232 = mul nsw i32 %230, %231
%233 = load i32, i32* %39
%234 = add nsw i32 %232, %233
%235 = add nsw i32 %234, 1
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds double, double* %229, i64 %236
%238 = load double, double* %237
%239 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 1
store double %238, double* %239
%240 = load double*, double** %22
%241 = load i32, i32* %40
%242 = add nsw i32 %241, 1
%243 = load i32, i32* %37
%244 = mul nsw i32 %242, %243
%245 = load i32, i32* %39
%246 = add nsw i32 %244, %245
%247 = add nsw i32 %246, 1
%248 = sext i32 %247 to i64
%249 = getelementptr inbounds double, double* %240, i64 %248
%250 = load double, double* %249
%251 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 2
store double %250, double* %251
%252 = load double*, double** %22
%253 = load i32, i32* %40
%254 = add nsw i32 %253, 1
%255 = load i32, i32* %37
%256 = mul nsw i32 %254, %255
%257 = load i32, i32* %39
%258 = add nsw i32 %256, %257
%259 = sext i32 %258 to i64
%260 = getelementptr inbounds double, double* %252, i64 %259
%261 = load double, double* %260
%262 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 3
store double %261, double* %262
%263 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%264 = load double, double* %263
%265 = load double, double* %46
%266 = fcmp ole double %264, %265
br i1 %266, label %267, label %283
267: ; preds = %218
%268 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 1
%269 = load double, double* %268
%270 = load double, double* %46
%271 = fcmp ole double %269, %270
br i1 %271, label %272, label %283
272: ; preds = %267
%273 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 2
%274 = load double, double* %273
%275 = load double, double* %46
%276 = fcmp ole double %274, %275
br i1 %276, label %277, label %283
277: ; preds = %272
%278 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 3
%279 = load double, double* %278
%280 = load double, double* %46
%281 = fcmp ole double %279, %280
br i1 %281, label %282, label %283
282: ; preds = %277
br label %488
283: ; preds = %277, %272, %267, %218
%284 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%285 = load double, double* %284
%286 = load double, double* %48
%287 = fcmp oge double %285, %286
br i1 %287, label %288, label %304
288: ; preds = %283
%289 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 1
%290 = load double, double* %289
%291 = load double, double* %48
%292 = fcmp oge double %290, %291
br i1 %292, label %293, label %304
293: ; preds = %288
%294 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 2
%295 = load double, double* %294
%296 = load double, double* %48
%297 = fcmp oge double %295, %296
br i1 %297, label %298, label %304
298: ; preds = %293
%299 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 3
%300 = load double, double* %299
%301 = load double, double* %48
%302 = fcmp oge double %300, %301
br i1 %302, label %303, label %304
303: ; preds = %298
br label %488
304: ; preds = %298, %293, %288, %283
%305 = load double*, double** %21
%306 = load i32, i32* %40
%307 = load i32, i32* %37
%308 = mul nsw i32 %306, %307
%309 = load i32, i32* %39
%310 = add nsw i32 %308, %309
%311 = sext i32 %310 to i64
%312 = getelementptr inbounds double, double* %305, i64 %311
%313 = load double, double* %312
%314 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
store double %313, double* %314
%315 = load double*, double** %21
%316 = load i32, i32* %40
%317 = load i32, i32* %37
%318 = mul nsw i32 %316, %317
%319 = load i32, i32* %39
%320 = add nsw i32 %318, %319
%321 = add nsw i32 %320, 1
%322 = sext i32 %321 to i64
%323 = getelementptr inbounds double, double* %315, i64 %322
%324 = load double, double* %323
%325 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 1
store double %324, double* %325
%326 = load double*, double** %21
%327 = load i32, i32* %40
%328 = add nsw i32 %327, 1
%329 = load i32, i32* %37
%330 = mul nsw i32 %328, %329
%331 = load i32, i32* %39
%332 = add nsw i32 %330, %331
%333 = add nsw i32 %332, 1
%334 = sext i32 %333 to i64
%335 = getelementptr inbounds double, double* %326, i64 %334
%336 = load double, double* %335
%337 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 2
store double %336, double* %337
%338 = load double*, double** %21
%339 = load i32, i32* %40
%340 = add nsw i32 %339, 1
%341 = load i32, i32* %37
%342 = mul nsw i32 %340, %341
%343 = load i32, i32* %39
%344 = add nsw i32 %342, %343
%345 = sext i32 %344 to i64
%346 = getelementptr inbounds double, double* %338, i64 %345
%347 = load double, double* %346
%348 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 3
store double %347, double* %348
%349 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
%350 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%351 = load double, double* %45
%352 = load double, double* %47
%353 = fadd double %351, %352
%354 = fdiv double %353, 2.000000e+00
%355 = call i32 (double*, double*, i32, double, ...) bitcast (i32 (...)* @fix_lon to i32 (double*, double*, i32, double, ...)*)(double* %349, double* %350, i32 4, double %354)
store i32 %355, i32* %59
%356 = load i32, i32* %59
%357 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
%358 = call i32 (i32, double*, ...) bitcast (i32 (...)* @avgval_double to i32 (i32, double*, ...)*)(i32 %356, double* %357)
%359 = sitofp i32 %358 to double
store double %359, double* %58
%360 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
%361 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%362 = load i32, i32* %59
%363 = load double, double* %45
%364 = load double, double* %46
%365 = load double, double* %47
%366 = load double, double* %48
%367 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%368 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%369 = call i32 (double*, double*, i32, double, double, double, double, double*, double*, ...) bitcast (i32 (...)* @clip to i32 (double*, double*, i32, double, double, double, double, double*, double*, ...)*)(double* %360, double* %361, i32 %362, double %363, double %364, double %365, double %366, double* %367, double* %368)
store i32 %369, i32* %60
%370 = icmp sgt i32 %369, 0
br i1 %370, label %371, label %486
371: ; preds = %304
%372 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%373 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%374 = load i32, i32* %60
%375 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @poly_area to i32 (double*, double*, i32, ...)*)(double* %372, double* %373, i32 %374)
%376 = sitofp i32 %375 to double
%377 = load double*, double** %25
%378 = load i32, i32* %40
%379 = load i32, i32* %33
%380 = mul nsw i32 %378, %379
%381 = load i32, i32* %39
%382 = add nsw i32 %380, %381
%383 = sext i32 %382 to i64
%384 = getelementptr inbounds double, double* %377, i64 %383
%385 = load double, double* %384
%386 = fmul double %376, %385
store double %386, double* %61
%387 = load double*, double** %55
%388 = load i32, i32* %40
%389 = load i32, i32* %33
%390 = mul nsw i32 %388, %389
%391 = load i32, i32* %39
%392 = add nsw i32 %390, %391
%393 = sext i32 %392 to i64
%394 = getelementptr inbounds double, double* %387, i64 %393
%395 = load double, double* %394
%396 = load double*, double** %56
%397 = load i32, i32* %42
%398 = load i32, i32* %35
%399 = mul nsw i32 %397, %398
%400 = load i32, i32* %41
%401 = add nsw i32 %399, %400
%402 = sext i32 %401 to i64
%403 = getelementptr inbounds double, double* %396, i64 %402
%404 = load double, double* %403
%405 = fcmp olt double %395, %404
br i1 %405, label %406, label %416
406: ; preds = %371
%407 = load double*, double** %55
%408 = load i32, i32* %40
%409 = load i32, i32* %33
%410 = mul nsw i32 %408, %409
%411 = load i32, i32* %39
%412 = add nsw i32 %410, %411
%413 = sext i32 %412 to i64
%414 = getelementptr inbounds double, double* %407, i64 %413
%415 = load double, double* %414
br label %426
416: ; preds = %371
%417 = load double*, double** %56
%418 = load i32, i32* %42
%419 = load i32, i32* %35
%420 = mul nsw i32 %418, %419
%421 = load i32, i32* %41
%422 = add nsw i32 %420, %421
%423 = sext i32 %422 to i64
%424 = getelementptr inbounds double, double* %417, i64 %423
%425 = load double, double* %424
br label %426
426: ; preds = %416, %406
%427 = phi double [ %415, %406 ], [ %425, %416 ]
store double %427, double* %57
%428 = load double, double* %61
%429 = load double, double* %57
%430 = fdiv double %428, %429
%431 = fcmp ogt double %430, 0x3EB0C6F7A0B5ED8D
br i1 %431, label %432, label %485
432: ; preds = %426
%433 = load double, double* %61
%434 = load double*, double** %30
%435 = load i32, i32* %43
%436 = sext i32 %435 to i64
%437 = getelementptr inbounds double, double* %434, i64 %436
store double %433, double* %437
%438 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%439 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%440 = load i32, i32* %60
%441 = load double, double* %58
%442 = call i32 (double*, double*, i32, double, ...) bitcast (i32 (...)* @poly_ctrlon to i32 (double*, double*, i32, double, ...)*)(double* %438, double* %439, i32 %440, double %441)
%443 = sitofp i32 %442 to double
%444 = load double*, double** %31
%445 = load i32, i32* %43
%446 = sext i32 %445 to i64
%447 = getelementptr inbounds double, double* %444, i64 %446
store double %443, double* %447
%448 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%449 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%450 = load i32, i32* %60
%451 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @poly_ctrlat to i32 (double*, double*, i32, ...)*)(double* %448, double* %449, i32 %450)
%452 = sitofp i32 %451 to double
%453 = load double*, double** %32
%454 = load i32, i32* %43
%455 = sext i32 %454 to i64
%456 = getelementptr inbounds double, double* %453, i64 %455
store double %452, double* %456
%457 = load i32, i32* %39
%458 = load i32*, i32** %26
%459 = load i32, i32* %43
%460 = sext i32 %459 to i64
%461 = getelementptr inbounds i32, i32* %458, i64 %460
store i32 %457, i32* %461
%462 = load i32, i32* %40
%463 = load i32*, i32** %27
%464 = load i32, i32* %43
%465 = sext i32 %464 to i64
%466 = getelementptr inbounds i32, i32* %463, i64 %465
store i32 %462, i32* %466
%467 = load i32, i32* %41
%468 = load i32*, i32** %28
%469 = load i32, i32* %43
%470 = sext i32 %469 to i64
%471 = getelementptr inbounds i32, i32* %468, i64 %470
store i32 %467, i32* %471
%472 = load i32, i32* %42
%473 = load i32*, i32** %29
%474 = load i32, i32* %43
%475 = sext i32 %474 to i64
%476 = getelementptr inbounds i32, i32* %473, i64 %475
store i32 %472, i32* %476
%477 = load i32, i32* %43
%478 = add nsw i32 %477, 1
store i32 %478, i32* %43
%479 = load i32, i32* %43
%480 = sitofp i32 %479 to double
%481 = fcmp ogt double %480, 1.000000e+07
br i1 %481, label %482, label %484
482: ; preds = %432
%483 = call i32 (i8*, ...) bitcast (i32 (...)* @error_handler to i32 (i8*, ...)*)(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %484
484: ; preds = %482, %432
br label %485
485: ; preds = %484, %426
br label %486
486: ; preds = %485, %304
br label %487
487: ; preds = %486, %207
br label %488
488: ; preds = %487, %303, %282
%489 = load i32, i32* %39
%490 = add nsw i32 %489, 1
store i32 %490, i32* %39
br label %203
491: ; preds = %203
br label %492
492: ; preds = %491
%493 = load i32, i32* %40
%494 = add nsw i32 %493, 1
store i32 %494, i32* %40
br label %198
495: ; preds = %198
br label %496
496: ; preds = %495
%497 = load i32, i32* %41
%498 = add nsw i32 %497, 1
store i32 %498, i32* %41
br label %171
499: ; preds = %171
br label %500
500: ; preds = %499
%501 = load i32, i32* %42
%502 = add nsw i32 %501, 1
store i32 %502, i32* %42
br label %166
503: ; preds = %166
%504 = load double*, double** %55
%505 = bitcast double* %504 to i8*
%506 = load double*, double** %56
%507 = bitcast double* %506 to i8*
%508 = load i32, i32* %43
ret i32 %508
}

LLVM IR (-O2):
@.str = [51 x i8] c"nxgrid is greater than MAXXGRID, increase MAXXGRID\00"
define i32 @create_xgrid_2dx1d_order2(i32* %0, i32* %1, i32* %2, i32* %3, double* %4, double* %5, double* nocapture %6, double* nocapture %7, double* nocapture %8, i32* nocapture writeonly %9, i32* nocapture writeonly %10, i32* nocapture writeonly %11, i32* nocapture writeonly %12, double* nocapture writeonly %13, double* nocapture writeonly %14, double* nocapture writeonly %15) {
%17 = bitcast double* %6 to i8*
%18 = alloca [50 x double]
%19 = alloca [50 x double]
%20 = alloca [50 x double]
%21 = alloca [50 x double]
%22 = bitcast [50 x double]* %18 to i8*
%23 = bitcast [50 x double]* %19 to i8*
%24 = bitcast [50 x double]* %20 to i8*
%25 = bitcast [50 x double]* %21 to i8*
%26 = load i32, i32* %0
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = add nsw i32 %26, 1
%31 = add nsw i32 %28, 1
%32 = mul nsw i32 %27, %26
%33 = sext i32 %32 to i64
%34 = shl nsw i64 %33, 3
%35 = tail call i8* @malloc(i64 %34)
%36 = bitcast i8* %35 to double*
%37 = mul nsw i32 %29, %28
%38 = sext i32 %37 to i64
%39 = shl nsw i64 %38, 3
%40 = tail call i8* @malloc(i64 %39)
%41 = bitcast i8* %40 to double*
%42 = add i32 %29, 1
%43 = mul nsw i32 %42, %31
%44 = sext i32 %43 to i64
%45 = shl nsw i64 %44, 3
%46 = tail call i8* @malloc(i64 %45)
%47 = bitcast i8* %46 to double*
%48 = tail call i8* @malloc(i64 %45)
%49 = bitcast i8* %48 to double*
%50 = icmp slt i32 %29, 0
br i1 %50, label %138, label %51
51: ; preds = %16
%52 = icmp slt i32 %28, 0
%53 = zext i32 %31 to i64
%54 = shl nuw nsw i64 %53, 3
%55 = sext i32 %31 to i64
%56 = zext i32 %42 to i64
%57 = and i64 %53, 4294967292
%58 = add nsw i64 %57, -4
%59 = lshr exact i64 %58, 2
%60 = add nuw nsw i64 %59, 1
%61 = icmp ult i32 %31, 4
%62 = and i64 %53, 4294967292
%63 = and i64 %60, 3
%64 = icmp ult i64 %58, 12
%65 = and i64 %60, 9223372036854775804
%66 = icmp eq i64 %63, 0
%67 = icmp eq i64 %62, %53
br label %68
68: ; preds = %51, %135
%69 = phi i64 [ 0, %51 ], [ %136, %135 ]
br i1 %52, label %135, label %70
70: ; preds = %68
%71 = trunc i64 %69 to i32
%72 = mul i32 %31, %71
%73 = sext i32 %72 to i64
%74 = shl nsw i64 %73, 3
%75 = getelementptr i8, i8* %46, i64 %74
%76 = mul nsw i64 %69, %55
%77 = getelementptr inbounds double, double* %7, i64 %69
%78 = load double, double* %77
br i1 %61, label %127, label %79
79: ; preds = %70
%80 = insertelement <2 x double> poison, double %78, i64 0
%81 = shufflevector <2 x double> %80, <2 x double> poison, <2 x i32> zeroinitializer
%82 = insertelement <2 x double> poison, double %78, i64 0
%83 = shufflevector <2 x double> %82, <2 x double> poison, <2 x i32> zeroinitializer
br i1 %64, label %113, label %84
84: ; preds = %79, %84
%85 = phi i64 [ %110, %84 ], [ 0, %79 ]
%86 = phi i64 [ %111, %84 ], [ 0, %79 ]
%87 = add nsw i64 %85, %76
%88 = getelementptr inbounds double, double* %49, i64 %87
%89 = bitcast double* %88 to <2 x double>*
store <2 x double> %81, <2 x double>* %89
%90 = getelementptr inbounds double, double* %88, i64 2
%91 = bitcast double* %90 to <2 x double>*
store <2 x double> %83, <2 x double>* %91
%92 = or i64 %85, 4
%93 = add nsw i64 %92, %76
%94 = getelementptr inbounds double, double* %49, i64 %93
%95 = bitcast double* %94 to <2 x double>*
store <2 x double> %81, <2 x double>* %95
%96 = getelementptr inbounds double, double* %94, i64 2
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> %83, <2 x double>* %97
%98 = or i64 %85, 8
%99 = add nsw i64 %98, %76
%100 = getelementptr inbounds double, double* %49, i64 %99
%101 = bitcast double* %100 to <2 x double>*
store <2 x double> %81, <2 x double>* %101
%102 = getelementptr inbounds double, double* %100, i64 2
%103 = bitcast double* %102 to <2 x double>*
store <2 x double> %83, <2 x double>* %103
%104 = or i64 %85, 12
%105 = add nsw i64 %104, %76
%106 = getelementptr inbounds double, double* %49, i64 %105
%107 = bitcast double* %106 to <2 x double>*
store <2 x double> %81, <2 x double>* %107
%108 = getelementptr inbounds double, double* %106, i64 2
%109 = bitcast double* %108 to <2 x double>*
store <2 x double> %83, <2 x double>* %109
%110 = add nuw i64 %85, 16
%111 = add nuw i64 %86, 4
%112 = icmp eq i64 %111, %65
br i1 %112, label %113, label %84
113: ; preds = %84, %79
%114 = phi i64 [ 0, %79 ], [ %110, %84 ]
br i1 %66, label %126, label %115
115: ; preds = %113, %115
%116 = phi i64 [ %123, %115 ], [ %114, %113 ]
%117 = phi i64 [ %124, %115 ], [ 0, %113 ]
%118 = add nsw i64 %116, %76
%119 = getelementptr inbounds double, double* %49, i64 %118
%120 = bitcast double* %119 to <2 x double>*
store <2 x double> %81, <2 x double>* %120
%121 = getelementptr inbounds double, double* %119, i64 2
%122 = bitcast double* %121 to <2 x double>*
store <2 x double> %83, <2 x double>* %122
%123 = add nuw i64 %116, 4
%124 = add i64 %117, 1
%125 = icmp eq i64 %124, %63
br i1 %125, label %126, label %115
126: ; preds = %115, %113
br i1 %67, label %135, label %127
127: ; preds = %70, %126
%128 = phi i64 [ 0, %70 ], [ %62, %126 ]
br label %129
129: ; preds = %127, %129
%130 = phi i64 [ %133, %129 ], [ %128, %127 ]
%131 = add nsw i64 %130, %76
%132 = getelementptr inbounds double, double* %49, i64 %131
store double %78, double* %132
%133 = add nuw nsw i64 %130, 1
%134 = icmp eq i64 %133, %53
br i1 %134, label %135, label %129
135: ; preds = %129, %126, %68
%136 = add nuw nsw i64 %69, 1
%137 = icmp eq i64 %136, %56
br i1 %137, label %138, label %68
138: ; preds = %135, %16
%139 = tail call i32 (i32*, i32*, double*, double*, double*, ...) bitcast (i32 (...)* @get_grid_area to i32 (i32*, i32*, double*, double*, double*, ...)*)(i32* %0, i32* %1, double* %4, double* %5, double* %36)
%140 = tail call i32 (i32*, i32*, double*, double*, double*, ...) bitcast (i32 (...)* @get_grid_area to i32 (i32*, i32*, double*, double*, double*, ...)*)(i32* %2, i32* %3, double* %47, double* %49, double* %41)
tail call void @free(i8* %46)
tail call void @free(i8* %48)
%141 = icmp sgt i32 %29, 0
br i1 %141, label %142, label %296
142: ; preds = %138
%143 = icmp sgt i32 %28, 0
%144 = icmp sgt i32 %27, 0
%145 = icmp sgt i32 %26, 0
%146 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 0
%147 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 2
%148 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 3
%149 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 0
%150 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 2
%151 = getelementptr inbounds [50 x double], [50 x double]* %20, i64 0, i64 0
%152 = getelementptr inbounds [50 x double], [50 x double]* %21, i64 0, i64 0
%153 = sext i32 %26 to i64
%154 = sext i32 %30 to i64
%155 = sext i32 %28 to i64
%156 = zext i32 %29 to i64
%157 = zext i32 %28 to i64
%158 = zext i32 %27 to i64
%159 = zext i32 %26 to i64
%160 = bitcast [50 x double]* %19 to <2 x double>*
%161 = bitcast [50 x double]* %18 to <2 x double>*
%162 = bitcast double* %150 to <2 x double>*
br label %163
163: ; preds = %142, %292
%164 = phi i64 [ 0, %142 ], [ %293, %292 ]
%165 = phi i32 [ 0, %142 ], [ %294, %292 ]
br i1 %143, label %168, label %166
166: ; preds = %163
%167 = add nuw nsw i64 %164, 1
br label %292
168: ; preds = %163
%169 = getelementptr inbounds double, double* %7, i64 %164
%170 = add nuw nsw i64 %164, 1
%171 = getelementptr inbounds double, double* %7, i64 %170
%172 = mul nsw i64 %164, %155
%173 = trunc i64 %164 to i32
br label %177
174: ; preds = %288, %177
%175 = phi i32 [ %179, %177 ], [ %290, %288 ]
%176 = icmp eq i64 %183, %157
br i1 %176, label %292, label %177
177: ; preds = %168, %174
%178 = phi i64 [ 0, %168 ], [ %183, %174 ]
%179 = phi i32 [ %165, %168 ], [ %175, %174 ]
%180 = getelementptr inbounds double, double* %6, i64 %178
%181 = load double, double* %180
%182 = load double, double* %169
%183 = add nuw nsw i64 %178, 1
%184 = getelementptr inbounds double, double* %6, i64 %183
%185 = load double, double* %184
%186 = load double, double* %171
br i1 %144, label %187, label %174
187: ; preds = %177
%188 = fadd double %181, %185
%189 = fmul double %188, 5.000000e-01
%190 = add nsw i64 %178, %172
%191 = getelementptr inbounds double, double* %41, i64 %190
%192 = trunc i64 %178 to i32
%193 = insertelement <4 x double> poison, double %186, i64 0
%194 = shufflevector <4 x double> %193, <4 x double> poison, <4 x i32> zeroinitializer
br label %195
195: ; preds = %187, %288
%196 = phi i64 [ 0, %187 ], [ %289, %288 ]
%197 = phi i32 [ %179, %187 ], [ %290, %288 ]
br i1 %145, label %200, label %198
198: ; preds = %195
%199 = add nuw nsw i64 %196, 1
br label %288
200: ; preds = %195
%201 = mul nsw i64 %196, %153
%202 = mul nsw i64 %196, %154
%203 = add nuw nsw i64 %196, 1
%204 = mul nsw i64 %203, %154
%205 = trunc i64 %196 to i32
br label %206
206: ; preds = %200, %284
%207 = phi i64 [ 0, %200 ], [ %286, %284 ]
%208 = phi i32 [ %197, %200 ], [ %285, %284 ]
%209 = add nsw i64 %207, %201
%210 = getelementptr inbounds double, double* %8, i64 %209
%211 = load double, double* %210
%212 = fcmp ogt double %211, 5.000000e-01
br i1 %212, label %213, label %284
213: ; preds = %206
%214 = add nsw i64 %207, %202
%215 = getelementptr inbounds double, double* %5, i64 %214
%216 = bitcast double* %215 to <2 x double>*
%217 = load <2 x double>, <2 x double>* %216
store <2 x double> %217, <2 x double>* %160
%218 = add nsw i64 %207, %204
%219 = add nsw i64 %218, 1
%220 = getelementptr inbounds double, double* %5, i64 %219
%221 = load double, double* %220
store double %221, double* %147
%222 = getelementptr inbounds double, double* %5, i64 %218
%223 = load double, double* %222
store double %223, double* %148
%224 = extractelement <2 x double> %217, i64 0
%225 = fcmp ugt double %224, %182
%226 = extractelement <2 x double> %217, i64 1
%227 = fcmp ugt double %226, %182
%228 = select i1 %225, i1 true, i1 %227
%229 = fcmp ugt double %221, %182
%230 = select i1 %228, i1 true, i1 %229
%231 = fcmp ugt double %223, %182
%232 = select i1 %230, i1 true, i1 %231
br i1 %232, label %233, label %284
233: ; preds = %213
%234 = shufflevector <2 x double> %217, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%235 = insertelement <4 x double> %234, double %221, i64 2
%236 = insertelement <4 x double> %235, double %223, i64 3
%237 = fcmp ult <4 x double> %236, %194
%238 = freeze <4 x i1> %237
%239 = bitcast <4 x i1> %238 to i4
%240 = icmp eq i4 %239, 0
br i1 %240, label %284, label %241
241: ; preds = %233
%242 = getelementptr inbounds double, double* %4, i64 %214
%243 = bitcast double* %242 to <2 x double>*
%244 = load <2 x double>, <2 x double>* %243
store <2 x double> %244, <2 x double>* %161
%245 = getelementptr inbounds double, double* %4, i64 %218
%246 = bitcast double* %245 to <2 x double>*
%247 = load <2 x double>, <2 x double>* %246
%248 = shufflevector <2 x double> %247, <2 x double> poison, <2 x i32> <i32 1, i32 0>
store <2 x double> %248, <2 x double>* %162
%249 = call i32 (double*, double*, i32, double, ...) bitcast (i32 (...)* @fix_lon to i32 (double*, double*, i32, double, ...)*)(double* %149, double* %146, i32 4, double %189)
%250 = call i32 (i32, double*, ...) bitcast (i32 (...)* @avgval_double to i32 (i32, double*, ...)*)(i32 %249, double* %149)
%251 = sitofp i32 %250 to double
%252 = call i32 (double*, double*, i32, double, double, double, double, double*, double*, ...) bitcast (i32 (...)* @clip to i32 (double*, double*, i32, double, double, double, double, double*, double*, ...)*)(double* %149, double* %146, i32 %249, double %181, double %182, double %185, double %186, double* %151, double* %152)
%253 = icmp sgt i32 %252, 0
br i1 %253, label %254, label %284
254: ; preds = %241
%255 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @poly_area to i32 (double*, double*, i32, ...)*)(double* %151, double* %152, i32 %252)
%256 = sitofp i32 %255 to double
%257 = load double, double* %210
%258 = fmul double %257, %256
%259 = getelementptr inbounds double, double* %36, i64 %209
%260 = load double, double* %259
%261 = load double, double* %191
%262 = fcmp olt double %260, %261
%263 = select i1 %262, double %260, double %261
%264 = fdiv double %258, %263
%265 = fcmp ogt double %264, 0x3EB0C6F7A0B5ED8D
br i1 %265, label %266, label %284
266: ; preds = %254
%267 = sext i32 %208 to i64
%268 = getelementptr inbounds double, double* %13, i64 %267
store double %258, double* %268
%269 = call i32 (double*, double*, i32, double, ...) bitcast (i32 (...)* @poly_ctrlon to i32 (double*, double*, i32, double, ...)*)(double* %151, double* %152, i32 %252, double %251)
%270 = sitofp i32 %269 to double
%271 = getelementptr inbounds double, double* %14, i64 %267
store double %270, double* %271
%272 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @poly_ctrlat to i32 (double*, double*, i32, ...)*)(double* %151, double* %152, i32 %252)
%273 = sitofp i32 %272 to double
%274 = getelementptr inbounds double, double* %15, i64 %267
store double %273, double* %274
%275 = getelementptr inbounds i32, i32* %9, i64 %267
%276 = trunc i64 %207 to i32
store i32 %276, i32* %275
%277 = getelementptr inbounds i32, i32* %10, i64 %267
store i32 %205, i32* %277
%278 = getelementptr inbounds i32, i32* %11, i64 %267
store i32 %192, i32* %278
%279 = getelementptr inbounds i32, i32* %12, i64 %267
store i32 %173, i32* %279
%280 = add nsw i32 %208, 1
%281 = icmp sgt i32 %208, 9999999
br i1 %281, label %282, label %284
282: ; preds = %266
%283 = call i32 (i8*, ...) bitcast (i32 (...)* @error_handler to i32 (i8*, ...)*)(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %284
284: ; preds = %213, %233, %254, %282, %266, %241, %206
%285 = phi i32 [ %208, %206 ], [ %208, %213 ], [ %208, %233 ], [ %280, %282 ], [ %280, %266 ], [ %208, %254 ], [ %208, %241 ]
%286 = add nuw nsw i64 %207, 1
%287 = icmp eq i64 %286, %159
br i1 %287, label %288, label %206
288: ; preds = %284, %198
%289 = phi i64 [ %199, %198 ], [ %203, %284 ]
%290 = phi i32 [ %197, %198 ], [ %285, %284 ]
%291 = icmp eq i64 %289, %158
br i1 %291, label %174, label %195
292: ; preds = %174, %166
%293 = phi i64 [ %167, %166 ], [ %170, %174 ]
%294 = phi i32 [ %165, %166 ], [ %175, %174 ]
%295 = icmp eq i64 %293, %156
br i1 %295, label %296, label %163
296: ; preds = %292, %138
%297 = phi i32 [ 0, %138 ], [ %294, %292 ]
ret i32 %297
}