#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double avgval_double(int, double *);
int clip(double *, double *, int, double, double, double, double, double *,
         double *);
int /*<<< orphan*/ error_handler(char *);
int fix_lon(double *, double *, int, double);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ get_grid_area(int const *, int const *, double const *,
                                 double const *, double *);
scalar_t__ malloc(int);
double const poly_area(double *, double *, int);
double poly_ctrlat(double *, double *, int);
double poly_ctrlon(double *, double *, int, double);
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;
  int n_in, n_out;
  double xarea;
  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)) {
            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 > 1e6)
                  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
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x6d8(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x40(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
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
cltq
shl    $0x3,%rax
mov    %eax,%edi
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
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x6d0(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x40(%rbp),%eax
jg     1337 <create_xgrid_2dx1d_order2+0x197>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     1324 <create_xgrid_2dx1d_order2+0x184>
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    12be <create_xgrid_2dx1d_order2+0x11e>
jmp    1329 <create_xgrid_2dx1d_order2+0x189>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    12ab <create_xgrid_2dx1d_order2+0x10b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x6d8(%rbp),%r8
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
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    18b9 <create_xgrid_2dx1d_order2+0x719>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    18a6 <create_xgrid_2dx1d_order2+0x706>
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    1893 <create_xgrid_2dx1d_order2+0x6f3>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1880 <create_xgrid_2dx1d_order2+0x6e0>
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    186d <create_xgrid_2dx1d_order2+0x6cd>
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    1872 <create_xgrid_2dx1d_order2+0x6d2>
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    1872 <create_xgrid_2dx1d_order2+0x6d2>
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
call   1080 <fix_lon@plt>
mov    %eax,-0x6f4(%rbp)
mov    -0x6f4(%rbp),%edi
lea    -0x210(%rbp),%rsi
call   1090 <avgval_double@plt>
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
call   1040 <clip@plt>
mov    %eax,-0x6f8(%rbp)
cmp    $0x0,%eax
jle    1868 <create_xgrid_2dx1d_order2+0x6c8>
lea    -0x530(%rbp),%rdi
lea    -0x6c0(%rbp),%rsi
mov    -0x6f8(%rbp),%edx
call   1060 <poly_area@plt>
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    173e <create_xgrid_2dx1d_order2+0x59e>
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    175f <create_xgrid_2dx1d_order2+0x5bf>
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  0x889(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1863 <create_xgrid_2dx1d_order2+0x6c3>
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
call   10a0 <poly_ctrlon@plt>
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
call   1070 <poly_ctrlat@plt>
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  0x7d0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    185e <create_xgrid_2dx1d_order2+0x6be>
lea    0x7c7(%rip),%rdi
call   1050 <error_handler@plt>
jmp    1863 <create_xgrid_2dx1d_order2+0x6c3>
jmp    1868 <create_xgrid_2dx1d_order2+0x6c8>
jmp    186d <create_xgrid_2dx1d_order2+0x6cd>
jmp    1872 <create_xgrid_2dx1d_order2+0x6d2>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    141f <create_xgrid_2dx1d_order2+0x27f>
jmp    1885 <create_xgrid_2dx1d_order2+0x6e5>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    140c <create_xgrid_2dx1d_order2+0x26c>
jmp    1898 <create_xgrid_2dx1d_order2+0x6f8>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    13a7 <create_xgrid_2dx1d_order2+0x207>
jmp    18ab <create_xgrid_2dx1d_order2+0x70b>
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    $0x778,%rsp
mov    %r9,0xe0(%rsp)
mov    %r8,0xd8(%rsp)
mov    0x7b8(%rsp),%rbp
mov    0x7b0(%rsp),%rbx
mov    %rdi,0x70(%rsp)
movslq (%rdi),%rax
mov    %rsi,(%rsp)
mov    (%rsi),%esi
mov    %rdx,0x78(%rsp)
movslq (%rdx),%r15
mov    %r15d,%edx
mov    %rdx,0xc0(%rsp)
mov    %rcx,0x80(%rsp)
mov    (%rcx),%r13d
lea    0x1(%r15),%r14d
mov    %rsi,0xe8(%rsp)
mov    %esi,%edi
mov    %rax,0xd0(%rsp)
imul   %eax,%edi
shl    $0x3,%edi
call   10b0 <malloc@plt>
mov    %rax,0x68(%rsp)
mov    %r15,0xc8(%rsp)
mov    %r15d,%edi
imul   %r13d,%edi
shl    $0x3,%edi
call   10b0 <malloc@plt>
mov    %rax,0x88(%rsp)
lea    0x1(%r13),%r15d
mov    %r14d,%r12d
imul   %r15d,%r12d
shl    $0x3,%r12d
mov    %r12d,%edi
call   10b0 <malloc@plt>
mov    %rax,0x50(%rsp)
mov    %r12d,%edi
call   10b0 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %r13,0xb8(%rsp)
test   %r13d,%r13d
js     15e5 <create_xgrid_2dx1d_order2+0x445>
movslq %r14d,%rdi
mov    %r15d,%r11d
mov    %edi,%edx
lea    (%rbx,%rdx,8),%rax
mov    %rax,0xf0(%rsp)
mov    %edx,%eax
and    $0xfffffffc,%eax
mov    %rax,0x28(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x98(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x90(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x20(%rsp)
mov    %rdx,%rax
neg    %rax
mov    %rax,0xa0(%rsp)
mov    0x10(%rsp),%rcx
lea    0x30(%rcx),%rsi
lea    0x0(,%rdi,8),%rax
mov    %rax,0x18(%rsp)
mov    0x50(%rsp),%rax
lea    0x30(%rax),%r14
lea    0x8(%rax),%r15
lea    0x8(%rcx),%r10
xor    %r8d,%r8d
mov    %rdi,0x8(%rsp)
mov    %r11,0x40(%rsp)
jmp    132e <create_xgrid_2dx1d_order2+0x18e>
nopl   0x0(%rax)
add    $0x1,%r8
mov    0x18(%rsp),%rax
add    %rax,%rsi
add    %rax,%r14
add    %rax,%r15
add    %rax,%r10
cmp    %r11,%r8
je     15e5 <create_xgrid_2dx1d_order2+0x445>
cmpl   $0x0,0xc0(%rsp)
js     1310 <create_xgrid_2dx1d_order2+0x170>
mov    %r8,%r9
imul   %rdi,%r9
cmp    $0x4,%edi
jae    13e0 <create_xgrid_2dx1d_order2+0x240>
xor    %eax,%eax
mov    %rax,%rcx
test   $0x1,%dl
je     137e <create_xgrid_2dx1d_order2+0x1de>
movsd  (%rbx,%rax,8),%xmm0
add    %rax,%r9
mov    0x50(%rsp),%rcx
movsd  %xmm0,(%rcx,%r9,8)
movsd  0x0(%rbp,%r8,8),%xmm0
mov    0x10(%rsp),%rcx
movsd  %xmm0,(%rcx,%r9,8)
mov    %rax,%rcx
or     $0x1,%rcx
not    %rax
cmp    0xa0(%rsp),%rax
je     1310 <create_xgrid_2dx1d_order2+0x170>
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%r15,%rcx,8)
movsd  0x0(%rbp,%r8,8),%xmm0
movsd  %xmm0,-0x8(%r10,%rcx,8)
movsd  0x8(%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%r15,%rcx,8)
movsd  0x0(%rbp,%r8,8),%xmm0
movsd  %xmm0,(%r10,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%rdx
jne    1390 <create_xgrid_2dx1d_order2+0x1f0>
jmp    1310 <create_xgrid_2dx1d_order2+0x170>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%r9,%rdx,1),%rax
mov    0x50(%rsp),%r12
lea    (%r12,%r9,8),%rcx
lea    (%r12,%rax,8),%r12
mov    0x10(%rsp),%r13
lea    0x0(%r13,%r9,8),%rdi
lea    0x0(%r13,%rax,8),%r13
lea    0x0(,%r8,8),%r11
add    %rbp,%r11
lea    0x8(%rbp,%r8,8),%rbp
cmp    %r13,%rcx
setb   0x38(%rsp)
cmp    %r12,%rdi
setb   0xb0(%rsp)
mov    0xf0(%rsp),%rax
cmp    %rax,%rcx
setb   0x30(%rsp)
cmp    %rbx,%r12
seta   0xa8(%rsp)
cmp    %rbp,%rcx
setb   %cl
cmp    %r12,%r11
setb   %r12b
cmp    %rax,%rdi
setb   %al
cmp    %rbx,%r13
seta   0x48(%rsp)
cmp    %rbp,%rdi
setb   %dil
cmp    %r13,%r11
setb   %r13b
mov    0xb0(%rsp),%bl
test   %bl,0x38(%rsp)
jne    15c4 <create_xgrid_2dx1d_order2+0x424>
mov    0xa8(%rsp),%bl
and    %bl,0x30(%rsp)
mov    0x7b8(%rsp),%rbp
mov    0x7b0(%rsp),%rbx
mov    0x40(%rsp),%r11
jne    15a9 <create_xgrid_2dx1d_order2+0x409>
and    %r12b,%cl
jne    15a9 <create_xgrid_2dx1d_order2+0x409>
and    0x48(%rsp),%al
jne    15a9 <create_xgrid_2dx1d_order2+0x409>
mov    $0x0,%eax
and    %r13b,%dil
mov    0x8(%rsp),%rdi
jne    134a <create_xgrid_2dx1d_order2+0x1aa>
cmpq   $0x0,0x98(%rsp)
je     15b5 <create_xgrid_2dx1d_order2+0x415>
movsd  0x0(%rbp,%r8,8),%xmm0
unpcklpd %xmm0,%xmm0
mov    0x20(%rsp),%rcx
xor    %r11d,%r11d
cs nopw 0x0(%rax,%rax,1)
movups (%rbx,%r11,8),%xmm1
movups 0x10(%rbx,%r11,8),%xmm2
movups %xmm1,-0x30(%r14,%r11,8)
movups %xmm2,-0x20(%r14,%r11,8)
movupd %xmm0,-0x30(%rsi,%r11,8)
movupd %xmm0,-0x20(%rsi,%r11,8)
movupd 0x20(%rbx,%r11,8),%xmm1
movupd 0x30(%rbx,%r11,8),%xmm2
movupd %xmm1,-0x10(%r14,%r11,8)
movupd %xmm2,(%r14,%r11,8)
movupd %xmm0,-0x10(%rsi,%r11,8)
movupd %xmm0,(%rsi,%r11,8)
add    $0x8,%r11
add    $0xfffffffffffffffe,%rcx
jne    14f0 <create_xgrid_2dx1d_order2+0x350>
testb  $0x1,0x90(%rsp)
01
je     158e <create_xgrid_2dx1d_order2+0x3ee>
movups (%rbx,%r11,8),%xmm0
movupd 0x10(%rbx,%r11,8),%xmm1
add    %r9,%r11
mov    0x50(%rsp),%rax
movups %xmm0,(%rax,%r11,8)
movupd %xmm1,0x10(%rax,%r11,8)
movsd  0x0(%rbp,%r8,8),%xmm0
unpcklpd %xmm0,%xmm0
mov    0x10(%rsp),%rax
movupd %xmm0,(%rax,%r11,8)
movupd %xmm0,0x10(%rax,%r11,8)
mov    0x28(%rsp),%rcx
mov    %rcx,%rax
cmp    %rdx,%rcx
mov    0x40(%rsp),%r11
je     1310 <create_xgrid_2dx1d_order2+0x170>
jmp    134a <create_xgrid_2dx1d_order2+0x1aa>
xor    %eax,%eax
mov    0x8(%rsp),%rdi
jmp    134a <create_xgrid_2dx1d_order2+0x1aa>
xor    %r11d,%r11d
testb  $0x1,0x90(%rsp)
01
jne    1551 <create_xgrid_2dx1d_order2+0x3b1>
jmp    158e <create_xgrid_2dx1d_order2+0x3ee>
xor    %eax,%eax
mov    0x7b8(%rsp),%rbp
mov    0x7b0(%rsp),%rbx
mov    0x8(%rsp),%rdi
mov    0x40(%rsp),%r11
jmp    134a <create_xgrid_2dx1d_order2+0x1aa>
mov    0x70(%rsp),%rdi
mov    (%rsp),%rsi
mov    0xd8(%rsp),%rdx
mov    0xe0(%rsp),%rbp
mov    %rbp,%rcx
mov    0x68(%rsp),%r8
call   10c0 <get_grid_area@plt>
mov    0x78(%rsp),%rdi
mov    0x80(%rsp),%rsi
mov    0x50(%rsp),%rbx
mov    %rbx,%rdx
mov    0x10(%rsp),%r14
mov    %r14,%rcx
mov    0x88(%rsp),%r8
call   10c0 <get_grid_area@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
cmpl   $0x0,0xb8(%rsp)
jle    1b2d <create_xgrid_2dx1d_order2+0x98d>
mov    0xd0(%rsp),%rcx
mov    %ecx,%edi
lea    0x1(%rcx),%rax
mov    %rax,0x120(%rsp)
lea    0x8(%rbp),%rax
mov    %rax,0x118(%rsp)
xor    %eax,%eax
mov    %rax,(%rsp)
movsd  0x97d(%rip),%xmm4
lea    0x5e0(%rsp),%r12
lea    0x450(%rsp),%r14
movl   $0x0,0x20(%rsp)
mov    0xc8(%rsp),%r9
mov    %rdi,0x28(%rsp)
jmp    16cd <create_xgrid_2dx1d_order2+0x52d>
nopw   0x0(%rax,%rax,1)
mov    0x108(%rsp),%rsi
mov    %rsi,%rax
mov    %rsi,(%rsp)
cmp    0xb8(%rsp),%rsi
je     1b35 <create_xgrid_2dx1d_order2+0x995>
test   %r9d,%r9d
jle    1b20 <create_xgrid_2dx1d_order2+0x980>
mov    (%rsp),%rax
lea    0x1(%rax),%rsi
mov    %rsi,0x108(%rsp)
imul   %r9,%rax
mov    %rax,0x110(%rsp)
xor    %esi,%esi
jmp    170a <create_xgrid_2dx1d_order2+0x56a>
cs nopw 0x0(%rax,%rax,1)
cmp    0xc0(%rsp),%rsi
je     16b0 <create_xgrid_2dx1d_order2+0x510>
mov    %rsi,%rdx
add    $0x1,%rsi
cmpl   $0x0,0xe8(%rsp)
jle    1700 <create_xgrid_2dx1d_order2+0x560>
mov    0x7b0(%rsp),%rax
movsd  (%rax,%rdx,8),%xmm0
movsd  0x8(%rax,%rdx,8),%xmm1
mov    0x7b8(%rsp),%r8
mov    (%rsp),%rax
movsd  (%r8,%rax,8),%xmm5
movsd  0x8(%r8,%rax,8),%xmm2
movsd  %xmm0,0xa0(%rsp)
movsd  %xmm1,0x40(%rsp)
addsd  %xmm1,%xmm0
mulsd  %xmm4,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x110(%rsp),%rax
mov    %rdx,0x70(%rsp)
add    %rdx,%rax
mov    %rax,0x90(%rsp)
movapd %xmm2,0xf0(%rsp)
unpcklpd %xmm2,%xmm2
movapd %xmm2,0x50(%rsp)
xor    %edx,%edx
mov    %rsi,0x128(%rsp)
movsd  %xmm5,0x18(%rsp)
jmp    17e6 <create_xgrid_2dx1d_order2+0x646>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x78(%rsp),%rax
mov    %rax,%rdx
mov    0xe0(%rsp),%rbp
mov    0xd0(%rsp),%rcx
mov    0xc8(%rsp),%r9
mov    0x128(%rsp),%rsi
cmp    0xe8(%rsp),%rax
je     1700 <create_xgrid_2dx1d_order2+0x560>
test   %ecx,%ecx
jle    1b10 <create_xgrid_2dx1d_order2+0x970>
mov    %rdx,%rax
imul   %rcx,%rax
mov    %rdx,%rcx
mov    0x120(%rsp),%rsi
imul   %rsi,%rcx
mov    %rdx,0x80(%rsp)
add    $0x1,%rdx
mov    %rdx,0x78(%rsp)
imul   %rsi,%rdx
mov    0x118(%rsp),%rsi
lea    (%rsi,%rdx,8),%rbx
mov    0xd8(%rsp),%rsi
lea    (%rsi,%rdx,8),%rdx
mov    %rdx,0xb0(%rsp)
lea    0x0(%rbp,%rcx,8),%rdx
lea    (%rsi,%rcx,8),%rcx
mov    %rcx,0xa8(%rsp)
mov    0x7c0(%rsp),%rcx
lea    (%rcx,%rax,8),%rbp
mov    0x68(%rsp),%rcx
lea    (%rcx,%rax,8),%rax
mov    %rax,0x98(%rsp)
xor    %r15d,%r15d
mov    %rbx,0x38(%rsp)
mov    %rdx,0x30(%rsp)
mov    %rbp,0x48(%rsp)
jmp    18ad <create_xgrid_2dx1d_order2+0x70d>
movsd  0x77d(%rip),%xmm4
mov    0x28(%rsp),%rdi
movsd  0x18(%rsp),%xmm5
mov    0x38(%rsp),%rbx
mov    0x30(%rsp),%rdx
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r15,%rdi
je     17b0 <create_xgrid_2dx1d_order2+0x610>
movsd  0x0(%rbp,%r15,8),%xmm0
ucomisd %xmm4,%xmm0
jbe    18a0 <create_xgrid_2dx1d_order2+0x700>
movupd (%rdx,%r15,8),%xmm0
movapd %xmm0,0x130(%rsp)
movsd  (%rbx,%r15,8),%xmm1
movsd  %xmm1,0x140(%rsp)
movsd  -0x8(%rbx,%r15,8),%xmm2
movsd  %xmm2,0x148(%rsp)
ucomisd %xmm0,%xmm5
jb     1908 <create_xgrid_2dx1d_order2+0x768>
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
ucomisd %xmm3,%xmm5
jb     1908 <create_xgrid_2dx1d_order2+0x768>
ucomisd %xmm1,%xmm5
jb     1908 <create_xgrid_2dx1d_order2+0x768>
ucomisd %xmm2,%xmm5
jae    18a0 <create_xgrid_2dx1d_order2+0x700>
unpcklpd %xmm2,%xmm1
movapd 0x50(%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     18a0 <create_xgrid_2dx1d_order2+0x700>
mov    0xa8(%rsp),%rax
movups (%rax,%r15,8),%xmm0
movaps %xmm0,0x2c0(%rsp)
mov    0xb0(%rsp),%rax
movups (%rax,%r15,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movaps %xmm0,0x2d0(%rsp)
lea    0x2c0(%rsp),%rbp
mov    %rbp,%rdi
lea    0x130(%rsp),%r13
mov    %r13,%rsi
mov    $0x4,%edx
movsd  0x8(%rsp),%xmm0
call   1080 <fix_lon@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %rbp,%rsi
call   1090 <avgval_double@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
movsd  0xa0(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x40(%rsp),%xmm2
movapd 0xf0(%rsp),%xmm3
mov    %r12,%rcx
mov    %r14,%r8
call   1040 <clip@plt>
test   %eax,%eax
jle    1adc <create_xgrid_2dx1d_order2+0x93c>
mov    %eax,%r13d
mov    %r12,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <poly_area@plt>
mov    0x48(%rsp),%rbp
mulsd  0x0(%rbp,%r15,8),%xmm0
mov    0x98(%rsp),%rax
movsd  (%rax,%r15,8),%xmm1
mov    0x88(%rsp),%rax
mov    0x90(%rsp),%rcx
minsd  (%rax,%rcx,8),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
ucomisd 0x5e2(%rip),%xmm2
jbe    187b <create_xgrid_2dx1d_order2+0x6db>
movslq 0x20(%rsp),%rbx
mov    0x7e8(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,8)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
movsd  0x10(%rsp),%xmm0
call   10a0 <poly_ctrlon@plt>
mov    0x7f0(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,8)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1070 <poly_ctrlat@plt>
mov    0x7f8(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,8)
mov    0x7c8(%rsp),%rax
mov    %r15d,(%rax,%rbx,4)
mov    0x7d0(%rsp),%rax
mov    0x80(%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
mov    0x7d8(%rsp),%rax
mov    0x70(%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
mov    0x7e0(%rsp),%rax
mov    (%rsp),%rcx
mov    %ecx,(%rax,%rbx,4)
lea    0x1(%rbx),%eax
mov    %eax,0x20(%rsp)
cmp    $0xf4240,%ebx
jl     187b <create_xgrid_2dx1d_order2+0x6db>
lea    0x53e(%rip),%rdi
call   1050 <error_handler@plt>
jmp    187b <create_xgrid_2dx1d_order2+0x6db>
movsd  0x51c(%rip),%xmm4
mov    0x28(%rsp),%rdi
movsd  0x18(%rsp),%xmm5
mov    0x38(%rsp),%rbx
mov    0x30(%rsp),%rdx
mov    0x48(%rsp),%rbp
jmp    18a0 <create_xgrid_2dx1d_order2+0x700>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rdx
mov    %rdx,%rax
jmp    17d8 <create_xgrid_2dx1d_order2+0x638>
nopl   0x0(%rax)
mov    (%rsp),%rsi
add    $0x1,%rsi
jmp    16b8 <create_xgrid_2dx1d_order2+0x518>
movl   $0x0,0x20(%rsp)
mov    0x68(%rsp),%rdi
call   1030 <free@plt>
mov    0x88(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%eax
add    $0x778,%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 = trunc i64 %78 to i32
%80 = call i64 @malloc(i32 %79)
%81 = inttoptr i64 %80 to double*
store double* %81, double** %55
%82 = load i32, i32* %35
%83 = load i32, i32* %36
%84 = mul nsw i32 %82, %83
%85 = sext i32 %84 to i64
%86 = mul i64 %85, 8
%87 = trunc i64 %86 to i32
%88 = call i64 @malloc(i32 %87)
%89 = inttoptr i64 %88 to double*
store double* %89, double** %56
%90 = load i32, i32* %35
%91 = add nsw i32 %90, 1
%92 = load i32, i32* %36
%93 = add nsw i32 %92, 1
%94 = mul nsw i32 %91, %93
%95 = sext i32 %94 to i64
%96 = mul i64 %95, 8
%97 = trunc i64 %96 to i32
%98 = call i64 @malloc(i32 %97)
%99 = inttoptr i64 %98 to double*
store double* %99, double** %53
%100 = load i32, i32* %35
%101 = add nsw i32 %100, 1
%102 = load i32, i32* %36
%103 = add nsw i32 %102, 1
%104 = mul nsw i32 %101, %103
%105 = sext i32 %104 to i64
%106 = mul i64 %105, 8
%107 = trunc i64 %106 to i32
%108 = call i64 @malloc(i32 %107)
%109 = inttoptr i64 %108 to double*
store double* %109, double** %54
store i32 0, i32* %42
br label %110
110: ; preds = %150, %16
%111 = load i32, i32* %42
%112 = load i32, i32* %36
%113 = icmp sle i32 %111, %112
br i1 %113, label %114, label %153
114: ; preds = %110
store i32 0, i32* %41
br label %115
115: ; preds = %146, %114
%116 = load i32, i32* %41
%117 = load i32, i32* %35
%118 = icmp sle i32 %116, %117
br i1 %118, label %119, label %149
119: ; preds = %115
%120 = load double*, double** %23
%121 = load i32, i32* %41
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %120, i64 %122
%124 = load double, double* %123
%125 = load double*, double** %53
%126 = load i32, i32* %42
%127 = load i32, i32* %38
%128 = mul nsw i32 %126, %127
%129 = load i32, i32* %41
%130 = add nsw i32 %128, %129
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds double, double* %125, i64 %131
store double %124, double* %132
%133 = load double*, double** %24
%134 = load i32, i32* %42
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds double, double* %133, i64 %135
%137 = load double, double* %136
%138 = load double*, double** %54
%139 = load i32, i32* %42
%140 = load i32, i32* %38
%141 = mul nsw i32 %139, %140
%142 = load i32, i32* %41
%143 = add nsw i32 %141, %142
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %138, i64 %144
store double %137, double* %145
br label %146
146: ; preds = %119
%147 = load i32, i32* %41
%148 = add nsw i32 %147, 1
store i32 %148, i32* %41
br label %115
149: ; preds = %115
br label %150
150: ; preds = %149
%151 = load i32, i32* %42
%152 = add nsw i32 %151, 1
store i32 %152, i32* %42
br label %110
153: ; preds = %110
%154 = load i32*, i32** %17
%155 = load i32*, i32** %18
%156 = load double*, double** %21
%157 = load double*, double** %22
%158 = load double*, double** %55
%159 = call i32 @get_grid_area(i32* %154, i32* %155, double* %156, double* %157, double* %158)
%160 = load i32*, i32** %19
%161 = load i32*, i32** %20
%162 = load double*, double** %53
%163 = load double*, double** %54
%164 = load double*, double** %56
%165 = call i32 @get_grid_area(i32* %160, i32* %161, double* %162, double* %163, double* %164)
%166 = load double*, double** %53
%167 = call i32 @free(double* %166)
%168 = load double*, double** %54
%169 = call i32 @free(double* %168)
store i32 0, i32* %42
br label %170
170: ; preds = %500, %153
%171 = load i32, i32* %42
%172 = load i32, i32* %36
%173 = icmp slt i32 %171, %172
br i1 %173, label %174, label %503
174: ; preds = %170
store i32 0, i32* %41
br label %175
175: ; preds = %496, %174
%176 = load i32, i32* %41
%177 = load i32, i32* %35
%178 = icmp slt i32 %176, %177
br i1 %178, label %179, label %499
179: ; preds = %175
%180 = load double*, double** %23
%181 = load i32, i32* %41
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds double, double* %180, i64 %182
%184 = load double, double* %183
store double %184, double* %45
%185 = load double*, double** %24
%186 = load i32, i32* %42
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds double, double* %185, i64 %187
%189 = load double, double* %188
store double %189, double* %46
%190 = load double*, double** %23
%191 = load i32, i32* %41
%192 = add nsw i32 %191, 1
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds double, double* %190, i64 %193
%195 = load double, double* %194
store double %195, double* %47
%196 = load double*, double** %24
%197 = load i32, i32* %42
%198 = add nsw i32 %197, 1
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds double, double* %196, i64 %199
%201 = load double, double* %200
store double %201, double* %48
store i32 0, i32* %40
br label %202
202: ; preds = %492, %179
%203 = load i32, i32* %40
%204 = load i32, i32* %34
%205 = icmp slt i32 %203, %204
br i1 %205, label %206, label %495
206: ; preds = %202
store i32 0, i32* %39
br label %207
207: ; preds = %488, %206
%208 = load i32, i32* %39
%209 = load i32, i32* %33
%210 = icmp slt i32 %208, %209
br i1 %210, label %211, label %491
211: ; preds = %207
%212 = load double*, double** %25
%213 = load i32, i32* %40
%214 = load i32, i32* %33
%215 = mul nsw i32 %213, %214
%216 = load i32, i32* %39
%217 = add nsw i32 %215, %216
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds double, double* %212, i64 %218
%220 = load double, double* %219
%221 = fcmp ogt double %220, 5.000000e-01
br i1 %221, label %222, label %487
222: ; preds = %211
%223 = load double*, double** %22
%224 = load i32, i32* %40
%225 = load i32, i32* %37
%226 = mul nsw i32 %224, %225
%227 = load i32, i32* %39
%228 = add nsw i32 %226, %227
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds double, double* %223, i64 %229
%231 = load double, double* %230
%232 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
store double %231, double* %232
%233 = load double*, double** %22
%234 = load i32, i32* %40
%235 = load i32, i32* %37
%236 = mul nsw i32 %234, %235
%237 = load i32, i32* %39
%238 = add nsw i32 %236, %237
%239 = add nsw i32 %238, 1
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds double, double* %233, i64 %240
%242 = load double, double* %241
%243 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 1
store double %242, double* %243
%244 = load double*, double** %22
%245 = load i32, i32* %40
%246 = add nsw i32 %245, 1
%247 = load i32, i32* %37
%248 = mul nsw i32 %246, %247
%249 = load i32, i32* %39
%250 = add nsw i32 %248, %249
%251 = add nsw i32 %250, 1
%252 = sext i32 %251 to i64
%253 = getelementptr inbounds double, double* %244, i64 %252
%254 = load double, double* %253
%255 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 2
store double %254, double* %255
%256 = load double*, double** %22
%257 = load i32, i32* %40
%258 = add nsw i32 %257, 1
%259 = load i32, i32* %37
%260 = mul nsw i32 %258, %259
%261 = load i32, i32* %39
%262 = add nsw i32 %260, %261
%263 = sext i32 %262 to i64
%264 = getelementptr inbounds double, double* %256, i64 %263
%265 = load double, double* %264
%266 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 3
store double %265, double* %266
%267 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%268 = load double, double* %267
%269 = load double, double* %46
%270 = fcmp ole double %268, %269
br i1 %270, label %271, label %287
271: ; preds = %222
%272 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 1
%273 = load double, double* %272
%274 = load double, double* %46
%275 = fcmp ole double %273, %274
br i1 %275, label %276, label %287
276: ; preds = %271
%277 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 2
%278 = load double, double* %277
%279 = load double, double* %46
%280 = fcmp ole double %278, %279
br i1 %280, label %281, label %287
281: ; preds = %276
%282 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 3
%283 = load double, double* %282
%284 = load double, double* %46
%285 = fcmp ole double %283, %284
br i1 %285, label %286, label %287
286: ; preds = %281
br label %488
287: ; preds = %281, %276, %271, %222
%288 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%289 = load double, double* %288
%290 = load double, double* %48
%291 = fcmp oge double %289, %290
br i1 %291, label %292, label %308
292: ; preds = %287
%293 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 1
%294 = load double, double* %293
%295 = load double, double* %48
%296 = fcmp oge double %294, %295
br i1 %296, label %297, label %308
297: ; preds = %292
%298 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 2
%299 = load double, double* %298
%300 = load double, double* %48
%301 = fcmp oge double %299, %300
br i1 %301, label %302, label %308
302: ; preds = %297
%303 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 3
%304 = load double, double* %303
%305 = load double, double* %48
%306 = fcmp oge double %304, %305
br i1 %306, label %307, label %308
307: ; preds = %302
br label %488
308: ; preds = %302, %297, %292, %287
%309 = load double*, double** %21
%310 = load i32, i32* %40
%311 = load i32, i32* %37
%312 = mul nsw i32 %310, %311
%313 = load i32, i32* %39
%314 = add nsw i32 %312, %313
%315 = sext i32 %314 to i64
%316 = getelementptr inbounds double, double* %309, i64 %315
%317 = load double, double* %316
%318 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
store double %317, double* %318
%319 = load double*, double** %21
%320 = load i32, i32* %40
%321 = load i32, i32* %37
%322 = mul nsw i32 %320, %321
%323 = load i32, i32* %39
%324 = add nsw i32 %322, %323
%325 = add nsw i32 %324, 1
%326 = sext i32 %325 to i64
%327 = getelementptr inbounds double, double* %319, i64 %326
%328 = load double, double* %327
%329 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 1
store double %328, double* %329
%330 = load double*, double** %21
%331 = load i32, i32* %40
%332 = add nsw i32 %331, 1
%333 = load i32, i32* %37
%334 = mul nsw i32 %332, %333
%335 = load i32, i32* %39
%336 = add nsw i32 %334, %335
%337 = add nsw i32 %336, 1
%338 = sext i32 %337 to i64
%339 = getelementptr inbounds double, double* %330, i64 %338
%340 = load double, double* %339
%341 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 2
store double %340, double* %341
%342 = load double*, double** %21
%343 = load i32, i32* %40
%344 = add nsw i32 %343, 1
%345 = load i32, i32* %37
%346 = mul nsw i32 %344, %345
%347 = load i32, i32* %39
%348 = add nsw i32 %346, %347
%349 = sext i32 %348 to i64
%350 = getelementptr inbounds double, double* %342, i64 %349
%351 = load double, double* %350
%352 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 3
store double %351, double* %352
%353 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
%354 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%355 = load double, double* %45
%356 = load double, double* %47
%357 = fadd double %355, %356
%358 = fdiv double %357, 2.000000e+00
%359 = call i32 @fix_lon(double* %353, double* %354, i32 4, double %358)
store i32 %359, i32* %59
%360 = load i32, i32* %59
%361 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
%362 = call double @avgval_double(i32 %360, double* %361)
store double %362, double* %58
%363 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
%364 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%365 = load i32, i32* %59
%366 = load double, double* %45
%367 = load double, double* %46
%368 = load double, double* %47
%369 = load double, double* %48
%370 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%371 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%372 = call i32 @clip(double* %363, double* %364, i32 %365, double %366, double %367, double %368, double %369, double* %370, double* %371)
store i32 %372, i32* %60
%373 = icmp sgt i32 %372, 0
br i1 %373, label %374, label %486
374: ; preds = %308
%375 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%376 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%377 = load i32, i32* %60
%378 = call double @poly_area(double* %375, double* %376, i32 %377)
%379 = load double*, double** %25
%380 = load i32, i32* %40
%381 = load i32, i32* %33
%382 = mul nsw i32 %380, %381
%383 = load i32, i32* %39
%384 = add nsw i32 %382, %383
%385 = sext i32 %384 to i64
%386 = getelementptr inbounds double, double* %379, i64 %385
%387 = load double, double* %386
%388 = fmul double %378, %387
store double %388, double* %61
%389 = load double*, double** %55
%390 = load i32, i32* %40
%391 = load i32, i32* %33
%392 = mul nsw i32 %390, %391
%393 = load i32, i32* %39
%394 = add nsw i32 %392, %393
%395 = sext i32 %394 to i64
%396 = getelementptr inbounds double, double* %389, i64 %395
%397 = load double, double* %396
%398 = load double*, double** %56
%399 = load i32, i32* %42
%400 = load i32, i32* %35
%401 = mul nsw i32 %399, %400
%402 = load i32, i32* %41
%403 = add nsw i32 %401, %402
%404 = sext i32 %403 to i64
%405 = getelementptr inbounds double, double* %398, i64 %404
%406 = load double, double* %405
%407 = fcmp olt double %397, %406
br i1 %407, label %408, label %418
408: ; preds = %374
%409 = load double*, double** %55
%410 = load i32, i32* %40
%411 = load i32, i32* %33
%412 = mul nsw i32 %410, %411
%413 = load i32, i32* %39
%414 = add nsw i32 %412, %413
%415 = sext i32 %414 to i64
%416 = getelementptr inbounds double, double* %409, i64 %415
%417 = load double, double* %416
br label %428
418: ; preds = %374
%419 = load double*, double** %56
%420 = load i32, i32* %42
%421 = load i32, i32* %35
%422 = mul nsw i32 %420, %421
%423 = load i32, i32* %41
%424 = add nsw i32 %422, %423
%425 = sext i32 %424 to i64
%426 = getelementptr inbounds double, double* %419, i64 %425
%427 = load double, double* %426
br label %428
428: ; preds = %418, %408
%429 = phi double [ %417, %408 ], [ %427, %418 ]
store double %429, double* %57
%430 = load double, double* %61
%431 = load double, double* %57
%432 = fdiv double %430, %431
%433 = fcmp ogt double %432, 0x3EB0C6F7A0B5ED8D
br i1 %433, label %434, label %485
434: ; preds = %428
%435 = load double, double* %61
%436 = load double*, double** %30
%437 = load i32, i32* %43
%438 = sext i32 %437 to i64
%439 = getelementptr inbounds double, double* %436, i64 %438
store double %435, double* %439
%440 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%441 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%442 = load i32, i32* %60
%443 = load double, double* %58
%444 = call double @poly_ctrlon(double* %440, double* %441, i32 %442, double %443)
%445 = load double*, double** %31
%446 = load i32, i32* %43
%447 = sext i32 %446 to i64
%448 = getelementptr inbounds double, double* %445, i64 %447
store double %444, double* %448
%449 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%450 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%451 = load i32, i32* %60
%452 = call double @poly_ctrlat(double* %449, double* %450, i32 %451)
%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+06
br i1 %481, label %482, label %484
482: ; preds = %434
%483 = call i32 @error_handler(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %484
484: ; preds = %482, %434
br label %485
485: ; preds = %484, %428
br label %486
486: ; preds = %485, %308
br label %487
487: ; preds = %486, %211
br label %488
488: ; preds = %487, %307, %286
%489 = load i32, i32* %39
%490 = add nsw i32 %489, 1
store i32 %490, i32* %39
br label %207
491: ; preds = %207
br label %492
492: ; preds = %491
%493 = load i32, i32* %40
%494 = add nsw i32 %493, 1
store i32 %494, i32* %40
br label %202
495: ; preds = %202
br label %496
496: ; preds = %495
%497 = load i32, i32* %41
%498 = add nsw i32 %497, 1
store i32 %498, i32* %41
br label %175
499: ; preds = %175
br label %500
500: ; preds = %499
%501 = load i32, i32* %42
%502 = add nsw i32 %501, 1
store i32 %502, i32* %42
br label %170
503: ; preds = %170
%504 = load double*, double** %55
%505 = call i32 @free(double* %504)
%506 = load double*, double** %56
%507 = call i32 @free(double* %506)
%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 = alloca [50 x double]
%18 = alloca [50 x double]
%19 = alloca [50 x double]
%20 = alloca [50 x double]
%21 = bitcast [50 x double]* %17 to i8*
%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 = load i32, i32* %0
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = add nsw i32 %25, 1
%30 = add i32 %27, 1
%31 = shl i32 %25, 3
%32 = mul i32 %31, %26
%33 = tail call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to double*
%35 = shl i32 %27, 3
%36 = mul i32 %35, %28
%37 = tail call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to double*
%39 = add i32 %28, 1
%40 = shl i32 %30, 3
%41 = mul i32 %40, %39
%42 = tail call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to double*
%44 = tail call i64 @malloc(i32 %41)
%45 = inttoptr i64 %44 to double*
%46 = icmp slt i32 %28, 0
br i1 %46, label %208, label %47
47: ; preds = %16
%48 = icmp slt i32 %27, 0
%49 = sext i32 %30 to i64
%50 = zext i32 %39 to i64
%51 = zext i32 %30 to i64
%52 = getelementptr double, double* %6, i64 %51
%53 = and i64 %51, 4294967292
%54 = add nsw i64 %53, -4
%55 = lshr exact i64 %54, 2
%56 = add nuw nsw i64 %55, 1
%57 = icmp ult i32 %30, 4
%58 = and i64 %51, 4294967292
%59 = and i64 %56, 1
%60 = icmp eq i64 %54, 0
%61 = and i64 %56, 9223372036854775806
%62 = icmp eq i64 %59, 0
%63 = icmp eq i64 %58, %51
%64 = and i64 %51, 1
%65 = icmp eq i64 %64, 0
%66 = sub nsw i64 0, %51
br label %67
67: ; preds = %47, %205
%68 = phi i64 [ 0, %47 ], [ %206, %205 ]
%69 = mul i64 %68, %49
%70 = getelementptr double, double* %43, i64 %69
%71 = add i64 %69, %51
%72 = getelementptr double, double* %43, i64 %71
%73 = getelementptr double, double* %45, i64 %69
%74 = getelementptr double, double* %45, i64 %71
%75 = getelementptr double, double* %7, i64 %68
%76 = add nuw i64 %68, 1
%77 = getelementptr double, double* %7, i64 %76
br i1 %48, label %205, label %78
78: ; preds = %67
%79 = mul nsw i64 %68, %49
%80 = getelementptr inbounds double, double* %7, i64 %68
br i1 %57, label %174, label %81
81: ; preds = %78
%82 = icmp ult double* %70, %74
%83 = icmp ult double* %73, %72
%84 = and i1 %82, %83
%85 = icmp ult double* %70, %52
%86 = icmp ugt double* %72, %6
%87 = and i1 %85, %86
%88 = or i1 %84, %87
%89 = icmp ult double* %70, %77
%90 = icmp ult double* %75, %72
%91 = and i1 %89, %90
%92 = or i1 %88, %91
%93 = icmp ult double* %73, %52
%94 = icmp ugt double* %74, %6
%95 = and i1 %93, %94
%96 = or i1 %92, %95
%97 = icmp ult double* %73, %77
%98 = icmp ult double* %75, %74
%99 = and i1 %97, %98
%100 = or i1 %96, %99
br i1 %100, label %174, label %101
101: ; preds = %81
br i1 %60, label %150, label %102
102: ; preds = %101
%103 = load double, double* %80
%104 = insertelement <2 x double> poison, double %103, i64 0
%105 = shufflevector <2 x double> %104, <2 x double> poison, <2 x i32> zeroinitializer
%106 = insertelement <2 x double> poison, double %103, i64 0
%107 = shufflevector <2 x double> %106, <2 x double> poison, <2 x i32> zeroinitializer
%108 = load double, double* %80
%109 = insertelement <2 x double> poison, double %108, i64 0
%110 = shufflevector <2 x double> %109, <2 x double> poison, <2 x i32> zeroinitializer
%111 = insertelement <2 x double> poison, double %108, i64 0
%112 = shufflevector <2 x double> %111, <2 x double> poison, <2 x i32> zeroinitializer
br label %113
113: ; preds = %113, %102
%114 = phi i64 [ 0, %102 ], [ %147, %113 ]
%115 = phi i64 [ 0, %102 ], [ %148, %113 ]
%116 = getelementptr inbounds double, double* %6, i64 %114
%117 = bitcast double* %116 to <2 x double>*
%118 = load <2 x double>, <2 x double>* %117
%119 = getelementptr inbounds double, double* %116, i64 2
%120 = bitcast double* %119 to <2 x double>*
%121 = load <2 x double>, <2 x double>* %120
%122 = add nsw i64 %114, %79
%123 = getelementptr inbounds double, double* %43, i64 %122
%124 = bitcast double* %123 to <2 x double>*
store <2 x double> %118, <2 x double>* %124
%125 = getelementptr inbounds double, double* %123, i64 2
%126 = bitcast double* %125 to <2 x double>*
store <2 x double> %121, <2 x double>* %126
%127 = getelementptr inbounds double, double* %45, i64 %122
%128 = bitcast double* %127 to <2 x double>*
store <2 x double> %105, <2 x double>* %128
%129 = getelementptr inbounds double, double* %127, i64 2
%130 = bitcast double* %129 to <2 x double>*
store <2 x double> %107, <2 x double>* %130
%131 = or i64 %114, 4
%132 = getelementptr inbounds double, double* %6, i64 %131
%133 = bitcast double* %132 to <2 x double>*
%134 = load <2 x double>, <2 x double>* %133
%135 = getelementptr inbounds double, double* %132, i64 2
%136 = bitcast double* %135 to <2 x double>*
%137 = load <2 x double>, <2 x double>* %136
%138 = add nsw i64 %131, %79
%139 = getelementptr inbounds double, double* %43, i64 %138
%140 = bitcast double* %139 to <2 x double>*
store <2 x double> %134, <2 x double>* %140
%141 = getelementptr inbounds double, double* %139, i64 2
%142 = bitcast double* %141 to <2 x double>*
store <2 x double> %137, <2 x double>* %142
%143 = getelementptr inbounds double, double* %45, i64 %138
%144 = bitcast double* %143 to <2 x double>*
store <2 x double> %110, <2 x double>* %144
%145 = getelementptr inbounds double, double* %143, i64 2
%146 = bitcast double* %145 to <2 x double>*
store <2 x double> %112, <2 x double>* %146
%147 = add nuw i64 %114, 8
%148 = add i64 %115, 2
%149 = icmp eq i64 %148, %61
br i1 %149, label %150, label %113
150: ; preds = %113, %101
%151 = phi i64 [ 0, %101 ], [ %147, %113 ]
br i1 %62, label %173, label %152
152: ; preds = %150
%153 = getelementptr inbounds double, double* %6, i64 %151
%154 = bitcast double* %153 to <2 x double>*
%155 = load <2 x double>, <2 x double>* %154
%156 = getelementptr inbounds double, double* %153, i64 2
%157 = bitcast double* %156 to <2 x double>*
%158 = load <2 x double>, <2 x double>* %157
%159 = add nsw i64 %151, %79
%160 = getelementptr inbounds double, double* %43, i64 %159
%161 = bitcast double* %160 to <2 x double>*
store <2 x double> %155, <2 x double>* %161
%162 = getelementptr inbounds double, double* %160, i64 2
%163 = bitcast double* %162 to <2 x double>*
store <2 x double> %158, <2 x double>* %163
%164 = load double, double* %80
%165 = insertelement <2 x double> poison, double %164, i64 0
%166 = shufflevector <2 x double> %165, <2 x double> poison, <2 x i32> zeroinitializer
%167 = insertelement <2 x double> poison, double %164, i64 0
%168 = shufflevector <2 x double> %167, <2 x double> poison, <2 x i32> zeroinitializer
%169 = getelementptr inbounds double, double* %45, i64 %159
%170 = bitcast double* %169 to <2 x double>*
store <2 x double> %166, <2 x double>* %170
%171 = getelementptr inbounds double, double* %169, i64 2
%172 = bitcast double* %171 to <2 x double>*
store <2 x double> %168, <2 x double>* %172
br label %173
173: ; preds = %150, %152
br i1 %63, label %205, label %174
174: ; preds = %81, %78, %173
%175 = phi i64 [ 0, %81 ], [ 0, %78 ], [ %58, %173 ]
%176 = xor i64 %175, -1
br i1 %65, label %185, label %177
177: ; preds = %174
%178 = getelementptr inbounds double, double* %6, i64 %175
%179 = load double, double* %178
%180 = add nsw i64 %175, %79
%181 = getelementptr inbounds double, double* %43, i64 %180
store double %179, double* %181
%182 = load double, double* %80
%183 = getelementptr inbounds double, double* %45, i64 %180
store double %182, double* %183
%184 = or i64 %175, 1
br label %185
185: ; preds = %177, %174
%186 = phi i64 [ %175, %174 ], [ %184, %177 ]
%187 = icmp eq i64 %176, %66
br i1 %187, label %205, label %188
188: ; preds = %185, %188
%189 = phi i64 [ %203, %188 ], [ %186, %185 ]
%190 = getelementptr inbounds double, double* %6, i64 %189
%191 = load double, double* %190
%192 = add nsw i64 %189, %79
%193 = getelementptr inbounds double, double* %43, i64 %192
store double %191, double* %193
%194 = load double, double* %80
%195 = getelementptr inbounds double, double* %45, i64 %192
store double %194, double* %195
%196 = add nuw nsw i64 %189, 1
%197 = getelementptr inbounds double, double* %6, i64 %196
%198 = load double, double* %197
%199 = add nsw i64 %196, %79
%200 = getelementptr inbounds double, double* %43, i64 %199
store double %198, double* %200
%201 = load double, double* %80
%202 = getelementptr inbounds double, double* %45, i64 %199
store double %201, double* %202
%203 = add nuw nsw i64 %189, 2
%204 = icmp eq i64 %203, %51
br i1 %204, label %205, label %188
205: ; preds = %185, %188, %173, %67
%206 = add nuw nsw i64 %68, 1
%207 = icmp eq i64 %206, %50
br i1 %207, label %208, label %67
208: ; preds = %205, %16
%209 = tail call i32 @get_grid_area(i32* %0, i32* %1, double* %4, double* %5, double* %34)
%210 = tail call i32 @get_grid_area(i32* %2, i32* %3, double* %43, double* %45, double* %38)
%211 = tail call i32 @free(double* %43)
%212 = tail call i32 @free(double* %45)
%213 = icmp sgt i32 %28, 0
br i1 %213, label %214, label %364
214: ; preds = %208
%215 = icmp sgt i32 %27, 0
%216 = icmp sgt i32 %26, 0
%217 = icmp sgt i32 %25, 0
%218 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 0
%219 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 2
%220 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 3
%221 = getelementptr inbounds [50 x double], [50 x double]* %17, i64 0, i64 0
%222 = getelementptr inbounds [50 x double], [50 x double]* %17, i64 0, i64 2
%223 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 0
%224 = getelementptr inbounds [50 x double], [50 x double]* %20, i64 0, i64 0
%225 = sext i32 %25 to i64
%226 = sext i32 %29 to i64
%227 = sext i32 %27 to i64
%228 = zext i32 %28 to i64
%229 = zext i32 %27 to i64
%230 = zext i32 %26 to i64
%231 = zext i32 %25 to i64
%232 = bitcast [50 x double]* %18 to <2 x double>*
%233 = bitcast [50 x double]* %17 to <2 x double>*
%234 = bitcast double* %222 to <2 x double>*
br label %235
235: ; preds = %214, %360
%236 = phi i64 [ 0, %214 ], [ %361, %360 ]
%237 = phi i32 [ 0, %214 ], [ %362, %360 ]
br i1 %215, label %240, label %238
238: ; preds = %235
%239 = add nuw nsw i64 %236, 1
br label %360
240: ; preds = %235
%241 = getelementptr inbounds double, double* %7, i64 %236
%242 = add nuw nsw i64 %236, 1
%243 = getelementptr inbounds double, double* %7, i64 %242
%244 = mul nsw i64 %236, %227
%245 = trunc i64 %236 to i32
br label %249
246: ; preds = %356, %249
%247 = phi i32 [ %251, %249 ], [ %358, %356 ]
%248 = icmp eq i64 %255, %229
br i1 %248, label %360, label %249
249: ; preds = %240, %246
%250 = phi i64 [ 0, %240 ], [ %255, %246 ]
%251 = phi i32 [ %237, %240 ], [ %247, %246 ]
%252 = getelementptr inbounds double, double* %6, i64 %250
%253 = load double, double* %252
%254 = load double, double* %241
%255 = add nuw nsw i64 %250, 1
%256 = getelementptr inbounds double, double* %6, i64 %255
%257 = load double, double* %256
%258 = load double, double* %243
br i1 %216, label %259, label %246
259: ; preds = %249
%260 = fadd double %253, %257
%261 = fmul double %260, 5.000000e-01
%262 = add nsw i64 %250, %244
%263 = getelementptr inbounds double, double* %38, i64 %262
%264 = trunc i64 %250 to i32
%265 = insertelement <4 x double> poison, double %258, i64 0
%266 = shufflevector <4 x double> %265, <4 x double> poison, <4 x i32> zeroinitializer
br label %267
267: ; preds = %259, %356
%268 = phi i64 [ 0, %259 ], [ %357, %356 ]
%269 = phi i32 [ %251, %259 ], [ %358, %356 ]
br i1 %217, label %272, label %270
270: ; preds = %267
%271 = add nuw nsw i64 %268, 1
br label %356
272: ; preds = %267
%273 = mul nsw i64 %268, %225
%274 = mul nsw i64 %268, %226
%275 = add nuw nsw i64 %268, 1
%276 = mul nsw i64 %275, %226
%277 = trunc i64 %268 to i32
br label %278
278: ; preds = %272, %352
%279 = phi i64 [ 0, %272 ], [ %354, %352 ]
%280 = phi i32 [ %269, %272 ], [ %353, %352 ]
%281 = add nsw i64 %279, %273
%282 = getelementptr inbounds double, double* %8, i64 %281
%283 = load double, double* %282
%284 = fcmp ogt double %283, 5.000000e-01
br i1 %284, label %285, label %352
285: ; preds = %278
%286 = add nsw i64 %279, %274
%287 = getelementptr inbounds double, double* %5, i64 %286
%288 = bitcast double* %287 to <2 x double>*
%289 = load <2 x double>, <2 x double>* %288
store <2 x double> %289, <2 x double>* %232
%290 = add nsw i64 %279, %276
%291 = add nsw i64 %290, 1
%292 = getelementptr inbounds double, double* %5, i64 %291
%293 = load double, double* %292
store double %293, double* %219
%294 = getelementptr inbounds double, double* %5, i64 %290
%295 = load double, double* %294
store double %295, double* %220
%296 = extractelement <2 x double> %289, i64 0
%297 = fcmp ugt double %296, %254
%298 = extractelement <2 x double> %289, i64 1
%299 = fcmp ugt double %298, %254
%300 = select i1 %297, i1 true, i1 %299
%301 = fcmp ugt double %293, %254
%302 = select i1 %300, i1 true, i1 %301
%303 = fcmp ugt double %295, %254
%304 = select i1 %302, i1 true, i1 %303
br i1 %304, label %305, label %352
305: ; preds = %285
%306 = shufflevector <2 x double> %289, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%307 = insertelement <4 x double> %306, double %293, i64 2
%308 = insertelement <4 x double> %307, double %295, i64 3
%309 = fcmp ult <4 x double> %308, %266
%310 = freeze <4 x i1> %309
%311 = bitcast <4 x i1> %310 to i4
%312 = icmp eq i4 %311, 0
br i1 %312, label %352, label %313
313: ; preds = %305
%314 = getelementptr inbounds double, double* %4, i64 %286
%315 = bitcast double* %314 to <2 x double>*
%316 = load <2 x double>, <2 x double>* %315
store <2 x double> %316, <2 x double>* %233
%317 = getelementptr inbounds double, double* %4, i64 %290
%318 = bitcast double* %317 to <2 x double>*
%319 = load <2 x double>, <2 x double>* %318
%320 = shufflevector <2 x double> %319, <2 x double> poison, <2 x i32> <i32 1, i32 0>
store <2 x double> %320, <2 x double>* %234
%321 = call i32 @fix_lon(double* %221, double* %218, i32 4, double %261)
%322 = call double @avgval_double(i32 %321, double* %221)
%323 = call i32 @clip(double* %221, double* %218, i32 %321, double %253, double %254, double %257, double %258, double* %223, double* %224)
%324 = icmp sgt i32 %323, 0
br i1 %324, label %325, label %352
325: ; preds = %313
%326 = call double @poly_area(double* %223, double* %224, i32 %323)
%327 = load double, double* %282
%328 = fmul double %326, %327
%329 = getelementptr inbounds double, double* %34, i64 %281
%330 = load double, double* %329
%331 = load double, double* %263
%332 = fcmp olt double %330, %331
%333 = select i1 %332, double %330, double %331
%334 = fdiv double %328, %333
%335 = fcmp ogt double %334, 0x3EB0C6F7A0B5ED8D
br i1 %335, label %336, label %352
336: ; preds = %325
%337 = sext i32 %280 to i64
%338 = getelementptr inbounds double, double* %13, i64 %337
store double %328, double* %338
%339 = call double @poly_ctrlon(double* %223, double* %224, i32 %323, double %322)
%340 = getelementptr inbounds double, double* %14, i64 %337
store double %339, double* %340
%341 = call double @poly_ctrlat(double* %223, double* %224, i32 %323)
%342 = getelementptr inbounds double, double* %15, i64 %337
store double %341, double* %342
%343 = getelementptr inbounds i32, i32* %9, i64 %337
%344 = trunc i64 %279 to i32
store i32 %344, i32* %343
%345 = getelementptr inbounds i32, i32* %10, i64 %337
store i32 %277, i32* %345
%346 = getelementptr inbounds i32, i32* %11, i64 %337
store i32 %264, i32* %346
%347 = getelementptr inbounds i32, i32* %12, i64 %337
store i32 %245, i32* %347
%348 = add nsw i32 %280, 1
%349 = icmp sgt i32 %280, 999999
br i1 %349, label %350, label %352
350: ; preds = %336
%351 = call i32 @error_handler(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %352
352: ; preds = %305, %285, %278, %325, %350, %336, %313
%353 = phi i32 [ %348, %350 ], [ %348, %336 ], [ %280, %325 ], [ %280, %313 ], [ %280, %278 ], [ %280, %285 ], [ %280, %305 ]
%354 = add nuw nsw i64 %279, 1
%355 = icmp eq i64 %354, %231
br i1 %355, label %356, label %278
356: ; preds = %352, %270
%357 = phi i64 [ %271, %270 ], [ %275, %352 ]
%358 = phi i32 [ %269, %270 ], [ %353, %352 ]
%359 = icmp eq i64 %357, %230
br i1 %359, label %246, label %267
360: ; preds = %246, %238
%361 = phi i64 [ %239, %238 ], [ %242, %246 ]
%362 = phi i32 [ %237, %238 ], [ %247, %246 ]
%363 = icmp eq i64 %361, %228
br i1 %363, label %364, label %235
364: ; preds = %360, %208
%365 = phi i32 [ 0, %208 ], [ %362, %360 ]
%366 = call i32 @free(double* %34)
%367 = call i32 @free(double* %38)
ret i32 %365
}