int create_xgrid_1dx2d_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 *area_in, *area_out, min_area;
  double *tmpx, *tmpy;
  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((nx1 + 1) * (ny1 + 1) * sizeof(double));
  tmpy = (double *)malloc((nx1 + 1) * (ny1 + 1) * sizeof(double));
  for (j1 = 0; j1 <= ny1; j1++)
    for (i1 = 0; i1 <= nx1; i1++) {
      tmpx[j1 * nx1p + i1] = lon_in[i1];
      tmpy[j1 * nx1p + i1] = lat_in[j1];
    }
  get_grid_area(nlon_in, nlat_in, tmpx, tmpy, area_in);
  get_grid_area(nlon_out, nlat_out, lon_out, lat_out, area_out);
  free(tmpx);
  free(tmpy);
  for (j1 = 0; j1 < ny1; j1++)
    for (i1 = 0; i1 < nx1; i1++)
      if (mask_in[j1 * nx1 + i1] > (0.5)) {
        ll_lon = lon_in[i1];
        ll_lat = lat_in[j1];
        ur_lon = lon_in[i1 + 1];
        ur_lat = lat_in[j1 + 1];
        for (j2 = 0; j2 < ny2; j2++)
          for (i2 = 0; i2 < nx2; i2++) {
            int n_in, n_out;
            double xarea, lon_in_avg;
            y_in[0] = lat_out[j2 * nx2p + i2];
            y_in[1] = lat_out[j2 * nx2p + i2 + 1];
            y_in[2] = lat_out[(j2 + 1) * nx2p + i2 + 1];
            y_in[3] = lat_out[(j2 + 1) * nx2p + i2];
            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_out[j2 * nx2p + i2];
            x_in[1] = lon_out[j2 * nx2p + i2 + 1];
            x_in[2] = lon_out[(j2 + 1) * nx2p + i2 + 1];
            x_in[3] = lon_out[(j2 + 1) * nx2p + i2];
            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_1dx2d_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,-0x6c8(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x40(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x6d0(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x6e0(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x6e8(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x38(%rbp),%eax
jg     1333 <create_xgrid_1dx2d_order2+0x193>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jg     1320 <create_xgrid_1dx2d_order2+0x180>
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x6e0(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x6e8(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12ba <create_xgrid_1dx2d_order2+0x11a>
jmp    1325 <create_xgrid_1dx2d_order2+0x185>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12a7 <create_xgrid_1dx2d_order2+0x107>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x6e0(%rbp),%rdx
mov    -0x6e8(%rbp),%rcx
mov    -0x6c8(%rbp),%r8
mov    $0x0,%al
call   10c0 <get_grid_area@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x10(%rbp),%rdx
mov    0x18(%rbp),%rcx
mov    -0x6d0(%rbp),%r8
mov    $0x0,%al
call   10c0 <get_grid_area@plt>
mov    -0x6e0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x6e8(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    18d7 <create_xgrid_1dx2d_order2+0x737>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    18c4 <create_xgrid_1dx2d_order2+0x724>
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  0xc2f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    18b1 <create_xgrid_1dx2d_order2+0x711>
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    18ac <create_xgrid_1dx2d_order2+0x70c>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1899 <create_xgrid_1dx2d_order2+0x6f9>
mov    0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x3a0(%rbp)
ff
mov    0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x398(%rbp)
ff
mov    0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x390(%rbp)
ff
mov    0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%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_1dx2d_order2+0x398>
movsd  -0x398(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1538 <create_xgrid_1dx2d_order2+0x398>
movsd  -0x390(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1538 <create_xgrid_1dx2d_order2+0x398>
movsd  -0x388(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1538 <create_xgrid_1dx2d_order2+0x398>
jmp    188b <create_xgrid_1dx2d_order2+0x6eb>
movsd  -0x3a0(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jb     1589 <create_xgrid_1dx2d_order2+0x3e9>
movsd  -0x398(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jb     1589 <create_xgrid_1dx2d_order2+0x3e9>
movsd  -0x390(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jb     1589 <create_xgrid_1dx2d_order2+0x3e9>
movsd  -0x388(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jb     1589 <create_xgrid_1dx2d_order2+0x3e9>
jmp    188b <create_xgrid_1dx2d_order2+0x6eb>
mov    0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x210(%rbp)
ff
mov    0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x208(%rbp)
ff
mov    0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x200(%rbp)
ff
mov    0x10(%rbp),%rax
mov    -0x58(%rbp),%ecx
add    $0x1,%ecx
imul   -0x48(%rbp),%ecx
add    -0x54(%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,-0x6ec(%rbp)
mov    -0x6ec(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x0,%al
call   1090 <avgval_double@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x700(%rbp)
ff
lea    -0x210(%rbp),%rdi
lea    -0x3a0(%rbp),%rsi
mov    -0x6ec(%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,-0x6f0(%rbp)
cmp    $0x0,%eax
jle    1886 <create_xgrid_1dx2d_order2+0x6e6>
lea    -0x530(%rbp),%rdi
lea    -0x6c0(%rbp),%rsi
mov    -0x6f0(%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,-0x6f8(%rbp)
ff
mov    -0x6c8(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x6d0(%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_1dx2d_order2+0x5ae>
mov    -0x6c8(%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_1dx2d_order2+0x5cf>
mov    -0x6d0(%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,-0x6d8(%rbp)
ff
movsd  -0x6f8(%rbp),%xmm0
ff
divsd  -0x6d8(%rbp),%xmm0
ff
movsd  0x879(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1881 <create_xgrid_1dx2d_order2+0x6e1>
movsd  -0x6f8(%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    -0x6f0(%rbp),%edx
movsd  -0x700(%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    -0x6f0(%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_1dx2d_order2+0x6dc>
lea    0x7ab(%rip),%rdi
mov    $0x0,%al
call   1050 <error_handler@plt>
jmp    1881 <create_xgrid_1dx2d_order2+0x6e1>
jmp    1886 <create_xgrid_1dx2d_order2+0x6e6>
jmp    188b <create_xgrid_1dx2d_order2+0x6eb>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1447 <create_xgrid_1dx2d_order2+0x2a7>
jmp    189e <create_xgrid_1dx2d_order2+0x6fe>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1434 <create_xgrid_1dx2d_order2+0x294>
jmp    18b1 <create_xgrid_1dx2d_order2+0x711>
jmp    18b6 <create_xgrid_1dx2d_order2+0x716>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13a7 <create_xgrid_1dx2d_order2+0x207>
jmp    18c9 <create_xgrid_1dx2d_order2+0x729>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1394 <create_xgrid_1dx2d_order2+0x1f4>
mov    -0x6c8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x6d0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x5c(%rbp),%eax
add    $0x710,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_xgrid_1dx2d_order2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x788,%rsp
mov    %r9,0xc8(%rsp)
mov    %r8,0xc0(%rsp)
mov    %rdi,0x10(%rsp)
movslq (%rdi),%rdi
mov    %edi,%eax
mov    %rax,0xd0(%rsp)
mov    %rsi,0x68(%rsp)
mov    (%rsi),%r15d
mov    %rdx,0x18(%rsp)
movslq (%rdx),%rbx
mov    %rcx,0x70(%rsp)
mov    (%rcx),%ebp
lea    0x1(%rdi),%r12
mov    %r15d,%eax
mov    %rdi,0xd8(%rsp)
imul   %edi,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x60(%rsp)
mov    %rbp,0xe8(%rsp)
mov    %ebp,%eax
mov    %rbx,0xe0(%rsp)
imul   %ebx,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x58(%rsp)
lea    0x1(%r15),%r14d
mov    %r14d,%eax
mov    %r12,0x38(%rsp)
imul   %r12d,%eax
movslq %eax,%rbx
shl    $0x3,%rbx
mov    %rbx,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %rbx,%rdi
call   10c0 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    %r15,0xb8(%rsp)
test   %r15d,%r15d
js     1484 <create_xgrid_1dx2d_order2+0x2d4>
mov    0x38(%rsp),%rax
mov    %eax,%ebx
lea    0x0(,%rbx,8),%rcx
mov    %rcx,0x90(%rsp)
mov    %r14d,%ecx
mov    %rcx,0x98(%rsp)
mov    %ebx,%ecx
and    $0xfffffffc,%ecx
mov    %rcx,0x88(%rsp)
add    $0xfffffffffffffffc,%rcx
mov    %rcx,0x80(%rsp)
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %ecx,%r13d
and    $0x3,%r13d
and    $0xfffffffffffffffc,%rcx
mov    %rcx,0x78(%rsp)
mov    0x20(%rsp),%rbp
lea    0x70(%rbp),%r14
shl    $0x3,%rax
mov    %rax,0x30(%rsp)
mov    %rbp,%rdx
add    $0x10,%rdx
mov    %r13,0xf0(%rsp)
shl    $0x5,%r13
xor    %r15d,%r15d
mov    0x38(%rsp),%r12
jmp    1330 <create_xgrid_1dx2d_order2+0x180>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
mov    0x30(%rsp),%rax
add    %rax,%r14
add    %rax,%rdx
add    %rax,%rbp
cmp    0x98(%rsp),%r15
je     1484 <create_xgrid_1dx2d_order2+0x2d4>
cmpl   $0x0,0xd0(%rsp)
js     1310 <create_xgrid_1dx2d_order2+0x160>
mov    %rdx,0xa0(%rsp)
mov    %r12d,%eax
imul   %r15d,%eax
cltq
mov    0x28(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0xc8(%rsp),%rax
movsd  (%rax,%r15,8),%xmm0
movapd %xmm0,0x40(%rsp)
mov    0xc0(%rsp),%rsi
mov    0x90(%rsp),%rdx
call   1070 <memcpy@plt>
cmp    $0x4,%r12d
jae    13a0 <create_xgrid_1dx2d_order2+0x1f0>
xor    %eax,%eax
mov    0xa0(%rsp),%rdx
movapd 0x40(%rsp),%xmm1
jmp    1470 <create_xgrid_1dx2d_order2+0x2c0>
nopl   0x0(%rax,%rax,1)
movapd 0x40(%rsp),%xmm1
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
cmpq   $0xc,0x80(%rsp)
jae    13c5 <create_xgrid_1dx2d_order2+0x215>
xor    %eax,%eax
mov    0xa0(%rsp),%rdx
jmp    1421 <create_xgrid_1dx2d_order2+0x271>
mov    0x78(%rsp),%rcx
xor    %eax,%eax
mov    0xa0(%rsp),%rdx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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_1dx2d_order2+0x230>
cmpq   $0x0,0xf0(%rsp)
je     1454 <create_xgrid_1dx2d_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_1dx2d_order2+0x290>
mov    0x88(%rsp),%rcx
mov    %rcx,%rax
cmp    %rbx,%rcx
je     1310 <create_xgrid_1dx2d_order2+0x160>
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x0(%rbp,%rax,8)
add    $0x1,%rax
cmp    %rax,%rbx
jne    1470 <create_xgrid_1dx2d_order2+0x2c0>
jmp    1310 <create_xgrid_1dx2d_order2+0x160>
movl   $0x0,0xc(%rsp)
mov    0x10(%rsp),%rdi
mov    0x68(%rsp),%rsi
mov    0x28(%rsp),%rbx
mov    %rbx,%rdx
mov    0x20(%rsp),%rbp
mov    %rbp,%rcx
mov    0x60(%rsp),%r8
xor    %eax,%eax
call   10d0 <get_grid_area@plt>
mov    0x18(%rsp),%rdi
mov    0x70(%rsp),%rsi
mov    0x7c0(%rsp),%rdx
mov    0x7c8(%rsp),%rcx
mov    0x58(%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,0xb8(%rsp)
mov    0xd8(%rsp),%rcx
jle    1a22 <create_xgrid_1dx2d_order2+0x872>
mov    0xe0(%rsp),%rax
mov    %eax,%esi
lea    0x1(%rax),%rdx
mov    %rdx,0x120(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x118(%rsp)
mov    0x7c8(%rsp),%rax
add    $0x8,%rax
mov    %rax,0x110(%rsp)
lea    0x5f0(%rsp),%r13
lea    0x460(%rsp),%r15
xor    %eax,%eax
mov    %rax,0x10(%rsp)
movl   $0x0,0xc(%rsp)
mov    %rsi,0x20(%rsp)
jmp    1576 <create_xgrid_1dx2d_order2+0x3c6>
xchg   %ax,%ax
mov    %rdi,%rax
mov    %rdi,0x10(%rsp)
cmp    0xb8(%rsp),%rdi
je     1a22 <create_xgrid_1dx2d_order2+0x872>
test   %ecx,%ecx
jle    1a00 <create_xgrid_1dx2d_order2+0x850>
mov    0x10(%rsp),%rax
mov    %rax,%rdx
imul   %rcx,%rdx
lea    0x1(%rax),%rdi
xor    %ebp,%ebp
mov    %rdi,0x128(%rsp)
mov    %rdx,0x100(%rsp)
jmp    15c4 <create_xgrid_1dx2d_order2+0x414>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbp
mov    %rbp,%rax
mov    %rax,%rbp
cmp    0xd0(%rsp),%rax
je     1560 <create_xgrid_1dx2d_order2+0x3b0>
lea    (%rdx,%rbp,1),%r14
mov    0x7d0(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
ucomisd 0xa22(%rip),%xmm0
jbe    15b0 <create_xgrid_1dx2d_order2+0x400>
lea    0x1(%rbp),%rax
cmpl   $0x0,0xe8(%rsp)
jle    15b7 <create_xgrid_1dx2d_order2+0x407>
mov    %rax,0x108(%rsp)
mov    0xc0(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
mov    %rbp,0x138(%rsp)
movsd  0x8(%rax,%rbp,8),%xmm1
mov    0xc8(%rsp),%rax
mov    0x10(%rsp),%rdx
movsd  (%rax,%rdx,8),%xmm4
movsd  0x8(%rax,%rdx,8),%xmm2
movsd  %xmm0,0x88(%rsp)
movsd  %xmm1,0x80(%rsp)
addsd  %xmm1,%xmm0
mulsd  0x9b9(%rip),%xmm0
movsd  %xmm0,0x78(%rsp)
movapd %xmm2,0xf0(%rsp)
unpcklpd %xmm2,%xmm2
movapd %xmm2,0xa0(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
mov    %r14,0x68(%rsp)
movsd  %xmm4,0x40(%rsp)
jmp    16ae <create_xgrid_1dx2d_order2+0x4fe>
nopw   0x0(%rax,%rax,1)
mov    0x130(%rsp),%rdx
mov    %rdx,%rax
mov    %rdx,0x18(%rsp)
mov    0xd8(%rsp),%rcx
mov    0x128(%rsp),%rdi
cmp    0xe8(%rsp),%rdx
je     19df <create_xgrid_1dx2d_order2+0x82f>
cmpl   $0x0,0xe0(%rsp)
jle    19c0 <create_xgrid_1dx2d_order2+0x810>
mov    0x18(%rsp),%rdi
mov    %rdi,%rax
mov    0x120(%rsp),%rdx
imul   %rdx,%rax
lea    0x1(%rdi),%rcx
mov    %rcx,0x130(%rsp)
imul   %rdx,%rcx
imul   0x118(%rsp),%rdi
add    0x58(%rsp),%rdi
mov    %rdi,0x70(%rsp)
mov    0x110(%rsp),%rdx
lea    (%rdx,%rcx,8),%rdi
mov    0x7c0(%rsp),%rdx
lea    (%rdx,%rcx,8),%rcx
mov    %rcx,0x38(%rsp)
mov    0x7c8(%rsp),%rcx
lea    (%rcx,%rax,8),%rcx
lea    (%rdx,%rax,8),%rax
mov    %rax,0x90(%rsp)
xor    %ebp,%ebp
mov    %rdi,0x30(%rsp)
mov    %rcx,0x28(%rsp)
jmp    1762 <create_xgrid_1dx2d_order2+0x5b2>
cs nopw 0x0(%rax,%rax,1)
mov    0x20(%rsp),%rsi
movsd  0x40(%rsp),%xmm4
mov    0x30(%rsp),%rdi
mov    0x28(%rsp),%rcx
add    $0x1,%rbp
cmp    %rbp,%rsi
je     1680 <create_xgrid_1dx2d_order2+0x4d0>
movupd (%rcx,%rbp,8),%xmm0
movapd %xmm0,0x140(%rsp)
movsd  (%rdi,%rbp,8),%xmm1
movsd  %xmm1,0x150(%rsp)
movsd  -0x8(%rdi,%rbp,8),%xmm2
movsd  %xmm2,0x158(%rsp)
ucomisd %xmm0,%xmm4
jb     17ad <create_xgrid_1dx2d_order2+0x5fd>
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
ucomisd %xmm3,%xmm4
jb     17ad <create_xgrid_1dx2d_order2+0x5fd>
ucomisd %xmm1,%xmm4
jb     17ad <create_xgrid_1dx2d_order2+0x5fd>
ucomisd %xmm2,%xmm4
jae    1755 <create_xgrid_1dx2d_order2+0x5a5>
unpcklpd %xmm2,%xmm1
movapd 0xa0(%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     1755 <create_xgrid_1dx2d_order2+0x5a5>
mov    0x90(%rsp),%rax
movups (%rax,%rbp,8),%xmm0
movaps %xmm0,0x2d0(%rsp)
mov    0x38(%rsp),%rax
movups (%rax,%rbp,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movaps %xmm0,0x2e0(%rsp)
lea    0x2d0(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%r14
mov    %r13,%r15
lea    0x140(%rsp),%r13
mov    %r13,%rsi
mov    $0x4,%edx
movsd  0x78(%rsp),%xmm0
mov    $0x1,%al
call   1090 <fix_lon@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   10a0 <avgval_double@plt>
mov    %eax,0x98(%rsp)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%r13
mov    %r14,%r15
mov    %ebx,%edx
movsd  0x88(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x80(%rsp),%xmm2
movapd 0xf0(%rsp),%xmm3
mov    %r13,%rcx
mov    %r14,%r8
mov    $0x4,%al
call   1040 <clip@plt>
test   %eax,%eax
jle    1740 <create_xgrid_1dx2d_order2+0x590>
mov    %eax,%r12d
mov    %r13,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <poly_area@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov    0x7d0(%rsp),%rax
mov    0x68(%rsp),%r14
mulsd  (%rax,%r14,8),%xmm1
mov    0x60(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
mov    0x70(%rsp),%rax
minsd  (%rax,%rbp,8),%xmm0
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
ucomisd 0x727(%rip),%xmm2
jbe    1740 <create_xgrid_1dx2d_order2+0x590>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x98(%rsp),%xmm0
movslq 0xc(%rsp),%rbx
mov    0x7f8(%rsp),%rax
movsd  %xmm1,(%rax,%rbx,8)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12d,%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    %r13,%rdi
mov    %r15,%rsi
mov    %r12d,%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    0x138(%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
mov    0x7e0(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
mov    0x7e8(%rsp),%rax
mov    %ebp,(%rax,%rbx,4)
mov    0x7f0(%rsp),%rax
mov    0x18(%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
lea    0x1(%rbx),%eax
mov    %eax,0xc(%rsp)
cmp    $0x989680,%ebx
jl     1740 <create_xgrid_1dx2d_order2+0x590>
lea    0x66b(%rip),%rdi
xor    %eax,%eax
call   1050 <error_handler@plt>
jmp    1740 <create_xgrid_1dx2d_order2+0x590>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rdx
add    $0x1,%rdx
mov    %rdx,%rax
mov    %rdx,0x18(%rsp)
cmp    0xe8(%rsp),%rdx
jne    16ae <create_xgrid_1dx2d_order2+0x4fe>
mov    0x100(%rsp),%rdx
mov    0x108(%rsp),%rax
jmp    15b7 <create_xgrid_1dx2d_order2+0x407>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp),%rdx
add    $0x1,%rdx
mov    %rdx,%rax
mov    %rdx,0x10(%rsp)
mov    %rdx,%rdi
cmp    0xb8(%rsp),%rdi
jne    1576 <create_xgrid_1dx2d_order2+0x3c6>
mov    0x60(%rsp),%rdi
call   1030 <free@plt>
mov    0x58(%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_1dx2d_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 i32
%59 = alloca i32
%60 = alloca double
%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** %53
%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** %54
%88 = load i32, i32* %33
%89 = add nsw i32 %88, 1
%90 = load i32, i32* %34
%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** %56
%97 = load i32, i32* %33
%98 = add nsw i32 %97, 1
%99 = load i32, i32* %34
%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** %57
store i32 0, i32* %40
br label %106
106: ; preds = %146, %16
%107 = load i32, i32* %40
%108 = load i32, i32* %34
%109 = icmp sle i32 %107, %108
br i1 %109, label %110, label %149
110: ; preds = %106
store i32 0, i32* %39
br label %111
111: ; preds = %142, %110
%112 = load i32, i32* %39
%113 = load i32, i32* %33
%114 = icmp sle i32 %112, %113
br i1 %114, label %115, label %145
115: ; preds = %111
%116 = load double*, double** %21
%117 = load i32, i32* %39
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds double, double* %116, i64 %118
%120 = load double, double* %119
%121 = load double*, double** %56
%122 = load i32, i32* %40
%123 = load i32, i32* %37
%124 = mul nsw i32 %122, %123
%125 = load i32, i32* %39
%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** %22
%130 = load i32, i32* %40
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds double, double* %129, i64 %131
%133 = load double, double* %132
%134 = load double*, double** %57
%135 = load i32, i32* %40
%136 = load i32, i32* %37
%137 = mul nsw i32 %135, %136
%138 = load i32, i32* %39
%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* %39
%144 = add nsw i32 %143, 1
store i32 %144, i32* %39
br label %111
145: ; preds = %111
br label %146
146: ; preds = %145
%147 = load i32, i32* %40
%148 = add nsw i32 %147, 1
store i32 %148, i32* %40
br label %106
149: ; preds = %106
%150 = load i32*, i32** %17
%151 = load i32*, i32** %18
%152 = load double*, double** %56
%153 = load double*, double** %57
%154 = load double*, double** %53
%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** %23
%159 = load double*, double** %24
%160 = load double*, double** %54
%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** %56
%163 = bitcast double* %162 to i8*
%164 = load double*, double** %57
%165 = bitcast double* %164 to i8*
store i32 0, i32* %40
br label %166
166: ; preds = %500, %149
%167 = load i32, i32* %40
%168 = load i32, i32* %34
%169 = icmp slt i32 %167, %168
br i1 %169, label %170, label %503
170: ; preds = %166
store i32 0, i32* %39
br label %171
171: ; preds = %496, %170
%172 = load i32, i32* %39
%173 = load i32, i32* %33
%174 = icmp slt i32 %172, %173
br i1 %174, label %175, label %499
175: ; preds = %171
%176 = load double*, double** %25
%177 = load i32, i32* %40
%178 = load i32, i32* %33
%179 = mul nsw i32 %177, %178
%180 = load i32, i32* %39
%181 = add nsw i32 %179, %180
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds double, double* %176, i64 %182
%184 = load double, double* %183
%185 = fcmp ogt double %184, 5.000000e-01
br i1 %185, label %186, label %495
186: ; preds = %175
%187 = load double*, double** %21
%188 = load i32, i32* %39
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds double, double* %187, i64 %189
%191 = load double, double* %190
store double %191, double* %45
%192 = load double*, double** %22
%193 = load i32, i32* %40
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds double, double* %192, i64 %194
%196 = load double, double* %195
store double %196, double* %46
%197 = load double*, double** %21
%198 = load i32, i32* %39
%199 = add nsw i32 %198, 1
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds double, double* %197, i64 %200
%202 = load double, double* %201
store double %202, double* %47
%203 = load double*, double** %22
%204 = load i32, i32* %40
%205 = add nsw i32 %204, 1
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds double, double* %203, i64 %206
%208 = load double, double* %207
store double %208, double* %48
store i32 0, i32* %42
br label %209
209: ; preds = %491, %186
%210 = load i32, i32* %42
%211 = load i32, i32* %36
%212 = icmp slt i32 %210, %211
br i1 %212, label %213, label %494
213: ; preds = %209
store i32 0, i32* %41
br label %214
214: ; preds = %487, %213
%215 = load i32, i32* %41
%216 = load i32, i32* %35
%217 = icmp slt i32 %215, %216
br i1 %217, label %218, label %490
218: ; preds = %214
%219 = load double*, double** %24
%220 = load i32, i32* %42
%221 = load i32, i32* %38
%222 = mul nsw i32 %220, %221
%223 = load i32, i32* %41
%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** %24
%230 = load i32, i32* %42
%231 = load i32, i32* %38
%232 = mul nsw i32 %230, %231
%233 = load i32, i32* %41
%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** %24
%241 = load i32, i32* %42
%242 = add nsw i32 %241, 1
%243 = load i32, i32* %38
%244 = mul nsw i32 %242, %243
%245 = load i32, i32* %41
%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** %24
%253 = load i32, i32* %42
%254 = add nsw i32 %253, 1
%255 = load i32, i32* %38
%256 = mul nsw i32 %254, %255
%257 = load i32, i32* %41
%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 %487
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 %487
304: ; preds = %298, %293, %288, %283
%305 = load double*, double** %23
%306 = load i32, i32* %42
%307 = load i32, i32* %38
%308 = mul nsw i32 %306, %307
%309 = load i32, i32* %41
%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** %23
%316 = load i32, i32* %42
%317 = load i32, i32* %38
%318 = mul nsw i32 %316, %317
%319 = load i32, i32* %41
%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** %23
%327 = load i32, i32* %42
%328 = add nsw i32 %327, 1
%329 = load i32, i32* %38
%330 = mul nsw i32 %328, %329
%331 = load i32, i32* %41
%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** %23
%339 = load i32, i32* %42
%340 = add nsw i32 %339, 1
%341 = load i32, i32* %38
%342 = mul nsw i32 %340, %341
%343 = load i32, i32* %41
%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* %58
%356 = load i32, i32* %58
%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* %61
%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* %58
%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* %59
%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* %59
%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* %60
%387 = load double*, double** %53
%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** %54
%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** %53
%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** %54
%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* %55
%428 = load double, double* %60
%429 = load double, double* %55
%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* %60
%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* %59
%441 = load double, double* %61
%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* %59
%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, %303, %282
%488 = load i32, i32* %41
%489 = add nsw i32 %488, 1
store i32 %489, i32* %41
br label %214
490: ; preds = %214
br label %491
491: ; preds = %490
%492 = load i32, i32* %42
%493 = add nsw i32 %492, 1
store i32 %493, i32* %42
br label %209
494: ; preds = %209
br label %495
495: ; preds = %494, %175
br label %496
496: ; preds = %495
%497 = load i32, i32* %39
%498 = add nsw i32 %497, 1
store i32 %498, i32* %39
br label %171
499: ; preds = %171
br label %500
500: ; preds = %499
%501 = load i32, i32* %40
%502 = add nsw i32 %501, 1
store i32 %502, i32* %40
br label %166
503: ; preds = %166
%504 = load double*, double** %53
%505 = bitcast double* %504 to i8*
%506 = load double*, double** %54
%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_1dx2d_order2(i32* %0, i32* %1, i32* %2, i32* %3, double* nocapture %4, double* nocapture %5, double* %6, double* %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* %4 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 %27, 1
%43 = mul nsw i32 %42, %30
%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 %27, 0
br i1 %50, label %138, label %51
51: ; preds = %16
%52 = icmp slt i32 %26, 0
%53 = zext i32 %30 to i64
%54 = shl nuw nsw i64 %53, 3
%55 = sext i32 %30 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 %30, 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 %30, %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* %5, 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* %47, double* %49, 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* %6, double* %7, double* %41)
tail call void @free(i8* %46)
tail call void @free(i8* %48)
%141 = icmp sgt i32 %27, 0
br i1 %141, label %142, label %299
142: ; preds = %138
%143 = icmp sgt i32 %26, 0
%144 = icmp sgt i32 %29, 0
%145 = icmp sgt i32 %28, 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 %31 to i64
%154 = sext i32 %28 to i64
%155 = sext i32 %26 to i64
%156 = zext i32 %27 to i64
%157 = zext i32 %26 to i64
%158 = zext i32 %29 to i64
%159 = zext i32 %28 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, %295
%164 = phi i64 [ 0, %142 ], [ %296, %295 ]
%165 = phi i32 [ 0, %142 ], [ %297, %295 ]
br i1 %143, label %168, label %166
166: ; preds = %163
%167 = add nuw nsw i64 %164, 1
br label %295
168: ; preds = %163
%169 = mul nsw i64 %164, %155
%170 = getelementptr inbounds double, double* %5, i64 %164
%171 = add nuw nsw i64 %164, 1
%172 = getelementptr inbounds double, double* %5, i64 %171
%173 = trunc i64 %164 to i32
br label %174
174: ; preds = %168, %291
%175 = phi i64 [ 0, %168 ], [ %292, %291 ]
%176 = phi i32 [ %165, %168 ], [ %293, %291 ]
%177 = add nsw i64 %175, %169
%178 = getelementptr inbounds double, double* %8, i64 %177
%179 = load double, double* %178
%180 = fcmp ogt double %179, 5.000000e-01
br i1 %180, label %183, label %181
181: ; preds = %174
%182 = add nuw nsw i64 %175, 1
br label %291
183: ; preds = %174
%184 = getelementptr inbounds double, double* %4, i64 %175
%185 = load double, double* %184
%186 = load double, double* %170
%187 = add nuw nsw i64 %175, 1
%188 = getelementptr inbounds double, double* %4, i64 %187
%189 = load double, double* %188
%190 = load double, double* %172
br i1 %144, label %191, label %291
191: ; preds = %183
%192 = fadd double %185, %189
%193 = fmul double %192, 5.000000e-01
%194 = getelementptr inbounds double, double* %36, i64 %177
%195 = trunc i64 %175 to i32
%196 = insertelement <4 x double> poison, double %190, i64 0
%197 = shufflevector <4 x double> %196, <4 x double> poison, <4 x i32> zeroinitializer
br label %198
198: ; preds = %191, %287
%199 = phi i64 [ 0, %191 ], [ %288, %287 ]
%200 = phi i32 [ %176, %191 ], [ %289, %287 ]
br i1 %145, label %203, label %201
201: ; preds = %198
%202 = add nuw nsw i64 %199, 1
br label %287
203: ; preds = %198
%204 = mul nsw i64 %199, %153
%205 = add nuw nsw i64 %199, 1
%206 = mul nsw i64 %205, %153
%207 = mul nsw i64 %199, %154
%208 = trunc i64 %199 to i32
br label %209
209: ; preds = %203, %283
%210 = phi i64 [ 0, %203 ], [ %285, %283 ]
%211 = phi i32 [ %200, %203 ], [ %284, %283 ]
%212 = add nsw i64 %210, %204
%213 = getelementptr inbounds double, double* %7, i64 %212
%214 = bitcast double* %213 to <2 x double>*
%215 = load <2 x double>, <2 x double>* %214
store <2 x double> %215, <2 x double>* %160
%216 = add nsw i64 %210, %206
%217 = add nsw i64 %216, 1
%218 = getelementptr inbounds double, double* %7, i64 %217
%219 = load double, double* %218
store double %219, double* %147
%220 = getelementptr inbounds double, double* %7, i64 %216
%221 = load double, double* %220
store double %221, double* %148
%222 = extractelement <2 x double> %215, i64 0
%223 = fcmp ugt double %222, %186
%224 = extractelement <2 x double> %215, i64 1
%225 = fcmp ugt double %224, %186
%226 = select i1 %223, i1 true, i1 %225
%227 = fcmp ugt double %219, %186
%228 = select i1 %226, i1 true, i1 %227
%229 = fcmp ugt double %221, %186
%230 = select i1 %228, i1 true, i1 %229
br i1 %230, label %231, label %283
231: ; preds = %209
%232 = shufflevector <2 x double> %215, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%233 = insertelement <4 x double> %232, double %219, i64 2
%234 = insertelement <4 x double> %233, double %221, i64 3
%235 = fcmp ult <4 x double> %234, %197
%236 = freeze <4 x i1> %235
%237 = bitcast <4 x i1> %236 to i4
%238 = icmp eq i4 %237, 0
br i1 %238, label %283, label %239
239: ; preds = %231
%240 = getelementptr inbounds double, double* %6, i64 %212
%241 = bitcast double* %240 to <2 x double>*
%242 = load <2 x double>, <2 x double>* %241
store <2 x double> %242, <2 x double>* %161
%243 = getelementptr inbounds double, double* %6, i64 %216
%244 = bitcast double* %243 to <2 x double>*
%245 = load <2 x double>, <2 x double>* %244
%246 = shufflevector <2 x double> %245, <2 x double> poison, <2 x i32> <i32 1, i32 0>
store <2 x double> %246, <2 x double>* %162
%247 = call i32 (double*, double*, i32, double, ...) bitcast (i32 (...)* @fix_lon to i32 (double*, double*, i32, double, ...)*)(double* %149, double* %146, i32 4, double %193)
%248 = call i32 (i32, double*, ...) bitcast (i32 (...)* @avgval_double to i32 (i32, double*, ...)*)(i32 %247, double* %149)
%249 = sitofp i32 %248 to double
%250 = 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 %247, double %185, double %186, double %189, double %190, double* %151, double* %152)
%251 = icmp sgt i32 %250, 0
br i1 %251, label %252, label %283
252: ; preds = %239
%253 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @poly_area to i32 (double*, double*, i32, ...)*)(double* %151, double* %152, i32 %250)
%254 = sitofp i32 %253 to double
%255 = load double, double* %178
%256 = fmul double %255, %254
%257 = load double, double* %194
%258 = add nsw i64 %210, %207
%259 = getelementptr inbounds double, double* %41, i64 %258
%260 = load double, double* %259
%261 = fcmp olt double %257, %260
%262 = select i1 %261, double %257, double %260
%263 = fdiv double %256, %262
%264 = fcmp ogt double %263, 0x3EB0C6F7A0B5ED8D
br i1 %264, label %265, label %283
265: ; preds = %252
%266 = sext i32 %211 to i64
%267 = getelementptr inbounds double, double* %13, i64 %266
store double %256, double* %267
%268 = call i32 (double*, double*, i32, double, ...) bitcast (i32 (...)* @poly_ctrlon to i32 (double*, double*, i32, double, ...)*)(double* %151, double* %152, i32 %250, double %249)
%269 = sitofp i32 %268 to double
%270 = getelementptr inbounds double, double* %14, i64 %266
store double %269, double* %270
%271 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @poly_ctrlat to i32 (double*, double*, i32, ...)*)(double* %151, double* %152, i32 %250)
%272 = sitofp i32 %271 to double
%273 = getelementptr inbounds double, double* %15, i64 %266
store double %272, double* %273
%274 = getelementptr inbounds i32, i32* %9, i64 %266
store i32 %195, i32* %274
%275 = getelementptr inbounds i32, i32* %10, i64 %266
store i32 %173, i32* %275
%276 = getelementptr inbounds i32, i32* %11, i64 %266
%277 = trunc i64 %210 to i32
store i32 %277, i32* %276
%278 = getelementptr inbounds i32, i32* %12, i64 %266
store i32 %208, i32* %278
%279 = add nsw i32 %211, 1
%280 = icmp sgt i32 %211, 9999999
br i1 %280, label %281, label %283
281: ; preds = %265
%282 = 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 %283
283: ; preds = %239, %265, %281, %252, %231, %209
%284 = phi i32 [ %211, %209 ], [ %211, %231 ], [ %279, %281 ], [ %279, %265 ], [ %211, %252 ], [ %211, %239 ]
%285 = add nuw nsw i64 %210, 1
%286 = icmp eq i64 %285, %159
br i1 %286, label %287, label %209
287: ; preds = %283, %201
%288 = phi i64 [ %202, %201 ], [ %205, %283 ]
%289 = phi i32 [ %200, %201 ], [ %284, %283 ]
%290 = icmp eq i64 %288, %158
br i1 %290, label %291, label %198
291: ; preds = %287, %181, %183
%292 = phi i64 [ %182, %181 ], [ %187, %183 ], [ %187, %287 ]
%293 = phi i32 [ %176, %181 ], [ %176, %183 ], [ %289, %287 ]
%294 = icmp eq i64 %292, %157
br i1 %294, label %295, label %174
295: ; preds = %291, %166
%296 = phi i64 [ %167, %166 ], [ %171, %291 ]
%297 = phi i32 [ %165, %166 ], [ %293, %291 ]
%298 = icmp eq i64 %296, %156
br i1 %298, label %299, label %163
299: ; preds = %295, %138
%300 = phi i32 [ 0, %138 ], [ %297, %295 ]
ret i32 %300
}