#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_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 > 1e6)
                  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
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x6c8(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x40(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
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
cltq
shl    $0x3,%rax
mov    %eax,%edi
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
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x6e8(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x38(%rbp),%eax
jg     1337 <create_xgrid_1dx2d_order2+0x197>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jg     1324 <create_xgrid_1dx2d_order2+0x184>
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    12be <create_xgrid_1dx2d_order2+0x11e>
jmp    1329 <create_xgrid_1dx2d_order2+0x189>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12ab <create_xgrid_1dx2d_order2+0x10b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x6e0(%rbp),%rdx
mov    -0x6e8(%rbp),%rcx
mov    -0x6c8(%rbp),%r8
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
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    18b9 <create_xgrid_1dx2d_order2+0x719>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    18a6 <create_xgrid_1dx2d_order2+0x706>
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    1893 <create_xgrid_1dx2d_order2+0x6f3>
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    188e <create_xgrid_1dx2d_order2+0x6ee>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    187b <create_xgrid_1dx2d_order2+0x6db>
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    186d <create_xgrid_1dx2d_order2+0x6cd>
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    186d <create_xgrid_1dx2d_order2+0x6cd>
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
call   1080 <fix_lon@plt>
mov    %eax,-0x6ec(%rbp)
mov    -0x6ec(%rbp),%edi
lea    -0x210(%rbp),%rsi
call   1090 <avgval_double@plt>
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
call   1040 <clip@plt>
mov    %eax,-0x6f0(%rbp)
cmp    $0x0,%eax
jle    1868 <create_xgrid_1dx2d_order2+0x6c8>
lea    -0x530(%rbp),%rdi
lea    -0x6c0(%rbp),%rsi
mov    -0x6f0(%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,-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    173e <create_xgrid_1dx2d_order2+0x59e>
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    175f <create_xgrid_1dx2d_order2+0x5bf>
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  0x889(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1863 <create_xgrid_1dx2d_order2+0x6c3>
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
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    -0x6f0(%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_1dx2d_order2+0x6be>
lea    0x7c7(%rip),%rdi
call   1050 <error_handler@plt>
jmp    1863 <create_xgrid_1dx2d_order2+0x6c3>
jmp    1868 <create_xgrid_1dx2d_order2+0x6c8>
jmp    186d <create_xgrid_1dx2d_order2+0x6cd>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1447 <create_xgrid_1dx2d_order2+0x2a7>
jmp    1880 <create_xgrid_1dx2d_order2+0x6e0>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1434 <create_xgrid_1dx2d_order2+0x294>
jmp    1893 <create_xgrid_1dx2d_order2+0x6f3>
jmp    1898 <create_xgrid_1dx2d_order2+0x6f8>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13a7 <create_xgrid_1dx2d_order2+0x207>
jmp    18ab <create_xgrid_1dx2d_order2+0x70b>
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    $0x768,%rsp
mov    %r9,0x30(%rsp)
mov    %r8,0x20(%rsp)
mov    %rcx,%rbp
mov    %rdi,0x78(%rsp)
movslq (%rdi),%rax
mov    %eax,%ecx
mov    %rcx,0xd0(%rsp)
mov    %rsi,0x80(%rsp)
mov    (%rsi),%r15d
mov    %rdx,0x88(%rsp)
movslq (%rdx),%rbx
mov    %rbp,0x10(%rsp)
mov    0x0(%rbp),%ebp
lea    0x1(%rax),%r12d
mov    %rax,0xe0(%rsp)
mov    %eax,%edi
imul   %r15d,%edi
shl    $0x3,%edi
call   10b0 <malloc@plt>
mov    %rax,0x90(%rsp)
mov    %rbp,0xe8(%rsp)
mov    %ebp,%edi
mov    %rbx,0xd8(%rsp)
imul   %ebx,%edi
shl    $0x3,%edi
call   10b0 <malloc@plt>
mov    %rax,0x70(%rsp)
lea    0x1(%r15),%r14d
mov    %r12d,%ebx
imul   %r14d,%ebx
shl    $0x3,%ebx
mov    %ebx,%edi
call   10b0 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %ebx,%edi
call   10b0 <malloc@plt>
mov    %rax,0x60(%rsp)
mov    %r15,0xc8(%rsp)
test   %r15d,%r15d
js     15d5 <create_xgrid_1dx2d_order2+0x435>
movslq %r12d,%r12
mov    %r14d,%r14d
mov    %r12d,%r15d
mov    0x20(%rsp),%rax
lea    (%rax,%r15,8),%rax
mov    %rax,0x40(%rsp)
mov    %r15d,%eax
and    $0xfffffffc,%eax
mov    %rax,0xa0(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x98(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x28(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x38(%rsp)
mov    %r15,%rax
neg    %rax
mov    %rax,0xa8(%rsp)
mov    0x60(%rsp),%rsi
lea    0x30(%rsi),%rdi
lea    0x0(,%r12,8),%rdx
mov    0x8(%rsp),%rax
lea    0x30(%rax),%rbx
lea    0x8(%rax),%rcx
lea    0x8(%rsi),%r9
xor    %r8d,%r8d
mov    %r12,0xf0(%rsp)
mov    %r14,0x58(%rsp)
mov    %rdx,0x18(%rsp)
jmp    1319 <create_xgrid_1dx2d_order2+0x179>
nopl   (%rax)
add    $0x1,%r8
add    %rdx,%rdi
add    %rdx,%rbx
add    %rdx,%rcx
add    %rdx,%r9
cmp    %r14,%r8
je     15d5 <create_xgrid_1dx2d_order2+0x435>
cmpl   $0x0,0xd0(%rsp)
js     1300 <create_xgrid_1dx2d_order2+0x160>
mov    %r8,%r10
imul   %r12,%r10
cmp    $0x4,%r12d
jae    13d0 <create_xgrid_1dx2d_order2+0x230>
xor    %eax,%eax
mov    %rax,%rbp
test   $0x1,%r15b
je     1374 <create_xgrid_1dx2d_order2+0x1d4>
mov    0x20(%rsp),%rsi
movsd  (%rsi,%rax,8),%xmm0
add    %rax,%r10
mov    0x8(%rsp),%rsi
movsd  %xmm0,(%rsi,%r10,8)
mov    0x30(%rsp),%rsi
movsd  (%rsi,%r8,8),%xmm0
mov    0x60(%rsp),%rsi
movsd  %xmm0,(%rsi,%r10,8)
mov    %rax,%rbp
or     $0x1,%rbp
not    %rax
cmp    0xa8(%rsp),%rax
mov    0x30(%rsp),%rax
mov    0x20(%rsp),%rsi
je     1300 <create_xgrid_1dx2d_order2+0x160>
nop
movsd  (%rsi,%rbp,8),%xmm0
movsd  %xmm0,-0x8(%rcx,%rbp,8)
movsd  (%rax,%r8,8),%xmm0
movsd  %xmm0,-0x8(%r9,%rbp,8)
movsd  0x8(%rsi,%rbp,8),%xmm0
movsd  %xmm0,(%rcx,%rbp,8)
movsd  (%rax,%r8,8),%xmm0
movsd  %xmm0,(%r9,%rbp,8)
add    $0x2,%rbp
cmp    %rbp,%r15
jne    1390 <create_xgrid_1dx2d_order2+0x1f0>
jmp    1300 <create_xgrid_1dx2d_order2+0x160>
nopl   (%rax)
lea    (%r10,%r15,1),%rax
mov    0x8(%rsp),%rdx
lea    (%rdx,%r10,8),%rbp
lea    (%rdx,%rax,8),%rsi
mov    0x60(%rsp),%rdx
lea    (%rdx,%r10,8),%r11
lea    (%rdx,%rax,8),%r12
mov    0x30(%rsp),%rax
lea    (%rax,%r8,8),%rdx
lea    (%rax,%r8,8),%r14
add    $0x8,%r14
cmp    %r12,%rbp
setb   0xc0(%rsp)
cmp    %rsi,%r11
setb   0x50(%rsp)
mov    0x40(%rsp),%rax
cmp    %rax,%rbp
setb   0xb8(%rsp)
mov    0x20(%rsp),%r13
cmp    %r13,%rsi
seta   0x48(%rsp)
cmp    %r14,%rbp
setb   %bpl
cmp    %rsi,%rdx
setb   0xb0(%rsp)
cmp    %rax,%r11
setb   %sil
cmp    %r13,%r12
seta   %r13b
cmp    %r14,%r11
setb   %r11b
cmp    %r12,%rdx
setb   %dl
mov    0x50(%rsp),%al
test   %al,0xc0(%rsp)
jne    15bc <create_xgrid_1dx2d_order2+0x41c>
mov    0x48(%rsp),%al
and    %al,0xb8(%rsp)
mov    0xf0(%rsp),%r12
mov    0x58(%rsp),%r14
jne    159a <create_xgrid_1dx2d_order2+0x3fa>
and    0xb0(%rsp),%bpl
jne    159a <create_xgrid_1dx2d_order2+0x3fa>
and    %r13b,%sil
jne    159a <create_xgrid_1dx2d_order2+0x3fa>
mov    $0x0,%eax
and    %dl,%r11b
mov    0x18(%rsp),%rdx
jne    1336 <create_xgrid_1dx2d_order2+0x196>
cmpq   $0x0,0x98(%rsp)
je     15a6 <create_xgrid_1dx2d_order2+0x406>
mov    0x30(%rsp),%rsi
movsd  (%rsi,%r8,8),%xmm0
unpcklpd %xmm0,%xmm0
mov    0x38(%rsp),%rax
xor    %r11d,%r11d
mov    0x20(%rsp),%rbp
movups 0x0(%rbp,%r11,8),%xmm1
movups 0x10(%rbp,%r11,8),%xmm2
movups %xmm1,-0x30(%rbx,%r11,8)
movups %xmm2,-0x20(%rbx,%r11,8)
movupd %xmm0,-0x30(%rdi,%r11,8)
movupd %xmm0,-0x20(%rdi,%r11,8)
movupd 0x20(%rbp,%r11,8),%xmm1
movupd 0x30(%rbp,%r11,8),%xmm2
movupd %xmm1,-0x10(%rbx,%r11,8)
movupd %xmm2,(%rbx,%r11,8)
movupd %xmm0,-0x10(%rdi,%r11,8)
movupd %xmm0,(%rdi,%r11,8)
add    $0x8,%r11
add    $0xfffffffffffffffe,%rax
jne    14e0 <create_xgrid_1dx2d_order2+0x340>
testb  $0x1,0x28(%rsp)
je     157c <create_xgrid_1dx2d_order2+0x3dc>
movups 0x0(%rbp,%r11,8),%xmm0
movupd 0x10(%rbp,%r11,8),%xmm1
add    %r10,%r11
mov    0x8(%rsp),%rax
movups %xmm0,(%rax,%r11,8)
movupd %xmm1,0x10(%rax,%r11,8)
movsd  (%rsi,%r8,8),%xmm0
unpcklpd %xmm0,%xmm0
mov    0x60(%rsp),%rax
movupd %xmm0,(%rax,%r11,8)
movupd %xmm0,0x10(%rax,%r11,8)
mov    0xa0(%rsp),%rsi
mov    %rsi,%rax
cmp    %r15,%rsi
mov    0x18(%rsp),%rdx
je     1300 <create_xgrid_1dx2d_order2+0x160>
jmp    1336 <create_xgrid_1dx2d_order2+0x196>
xor    %eax,%eax
mov    0x18(%rsp),%rdx
jmp    1336 <create_xgrid_1dx2d_order2+0x196>
xor    %r11d,%r11d
mov    0x30(%rsp),%rsi
mov    0x20(%rsp),%rbp
testb  $0x1,0x28(%rsp)
jne    153f <create_xgrid_1dx2d_order2+0x39f>
jmp    157c <create_xgrid_1dx2d_order2+0x3dc>
xor    %eax,%eax
mov    0xf0(%rsp),%r12
mov    0x58(%rsp),%r14
mov    0x18(%rsp),%rdx
jmp    1336 <create_xgrid_1dx2d_order2+0x196>
mov    0x78(%rsp),%rdi
mov    0x80(%rsp),%rsi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdx
mov    0x60(%rsp),%r14
mov    %r14,%rcx
mov    0x90(%rsp),%r8
call   10c0 <get_grid_area@plt>
mov    0x88(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x7a0(%rsp),%rdx
mov    0x7a8(%rsp),%r12
mov    %r12,%rcx
mov    0x70(%rsp),%r8
call   10c0 <get_grid_area@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
cmpl   $0x0,0xc8(%rsp)
jle    1b04 <create_xgrid_1dx2d_order2+0x964>
mov    0xd8(%rsp),%rsi
mov    %esi,%edi
lea    0x1(%rsi),%rax
mov    %rax,0x118(%rsp)
lea    0x8(%r12),%rax
mov    %rax,0x110(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
lea    0x5d0(%rsp),%r14
lea    0x440(%rsp),%r13
movl   $0x0,0x38(%rsp)
mov    0xe0(%rsp),%r9
mov    %rdi,0x40(%rsp)
jmp    16bf <create_xgrid_1dx2d_order2+0x51f>
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdx
add    $0x1,%rdx
mov    %rdx,%rax
mov    %rdx,0x10(%rsp)
cmp    0xc8(%rsp),%rdx
je     1b0c <create_xgrid_1dx2d_order2+0x96c>
test   %r9d,%r9d
jle    16a0 <create_xgrid_1dx2d_order2+0x500>
mov    0x10(%rsp),%rax
mov    %rax,%r8
imul   %r9,%r8
lea    0x1(%rax),%rdx
xor    %ecx,%ecx
mov    %rdx,0x78(%rsp)
mov    %r8,0x100(%rsp)
jmp    1704 <create_xgrid_1dx2d_order2+0x564>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rax,%rcx
cmp    0xd0(%rsp),%rax
je     16a9 <create_xgrid_1dx2d_order2+0x509>
lea    (%rcx,%r8,1),%rbx
mov    0x7b0(%rsp),%rax
mov    %rbx,0x98(%rsp)
movsd  (%rax,%rbx,8),%xmm0
ucomisd 0x8db(%rip),%xmm0
jbe    16f0 <create_xgrid_1dx2d_order2+0x550>
lea    0x1(%rcx),%rax
cmpl   $0x0,0xe8(%rsp)
jle    16f7 <create_xgrid_1dx2d_order2+0x557>
mov    %rax,0x108(%rsp)
mov    0x20(%rsp),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    %rcx,0x88(%rsp)
movsd  0x8(%rax,%rcx,8),%xmm1
mov    0x30(%rsp),%r8
mov    0x10(%rsp),%rax
movsd  (%r8,%rax,8),%xmm4
movsd  0x8(%r8,%rax,8),%xmm2
movsd  %xmm0,0xa8(%rsp)
movsd  %xmm1,0x18(%rsp)
addsd  %xmm1,%xmm0
mulsd  0x879(%rip),%xmm0
movsd  %xmm0,0x58(%rsp)
movapd %xmm2,0xf0(%rsp)
unpcklpd %xmm2,%xmm2
movapd %xmm2,0x60(%rsp)
xor    %eax,%eax
mov    %rax,0x28(%rsp)
movsd  %xmm4,0x8(%rsp)
jmp    17eb <create_xgrid_1dx2d_order2+0x64b>
nop
mov    0x80(%rsp),%rcx
mov    %rcx,%rax
mov    %rcx,0x28(%rsp)
mov    0x7a8(%rsp),%r12
mov    0xe0(%rsp),%r9
mov    0xd8(%rsp),%rsi
mov    0x78(%rsp),%rdx
cmp    0xe8(%rsp),%rcx
je     1aef <create_xgrid_1dx2d_order2+0x94f>
test   %esi,%esi
jle    1ad0 <create_xgrid_1dx2d_order2+0x930>
mov    0x28(%rsp),%rdx
mov    %rdx,%rax
mov    0x118(%rsp),%rbx
imul   %rbx,%rax
lea    0x1(%rdx),%rcx
mov    %rcx,0x80(%rsp)
imul   %rbx,%rcx
imul   %rsi,%rdx
mov    0x70(%rsp),%rsi
lea    (%rsi,%rdx,8),%rdx
mov    %rdx,0xa0(%rsp)
mov    0x110(%rsp),%rdx
lea    (%rdx,%rcx,8),%rsi
mov    0x7a0(%rsp),%rdx
lea    (%rdx,%rcx,8),%rcx
mov    %rcx,0xb8(%rsp)
lea    (%r12,%rax,8),%rcx
lea    (%rdx,%rax,8),%rax
mov    %rax,0xb0(%rsp)
xor    %r12d,%r12d
mov    %rsi,0x50(%rsp)
mov    %rcx,0x48(%rsp)
jmp    1892 <create_xgrid_1dx2d_order2+0x6f2>
nopl   0x0(%rax,%rax,1)
mov    0x40(%rsp),%rdi
movsd  0x8(%rsp),%xmm4
mov    0x50(%rsp),%rsi
mov    0x48(%rsp),%rcx
add    $0x1,%r12
cmp    %r12,%rdi
je     17b0 <create_xgrid_1dx2d_order2+0x610>
movupd (%rcx,%r12,8),%xmm0
movapd %xmm0,0x120(%rsp)
movsd  (%rsi,%r12,8),%xmm1
movsd  %xmm1,0x130(%rsp)
movsd  -0x8(%rsi,%r12,8),%xmm2
movsd  %xmm2,0x138(%rsp)
ucomisd %xmm0,%xmm4
jb     18e0 <create_xgrid_1dx2d_order2+0x740>
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
ucomisd %xmm3,%xmm4
jb     18e0 <create_xgrid_1dx2d_order2+0x740>
ucomisd %xmm1,%xmm4
jb     18e0 <create_xgrid_1dx2d_order2+0x740>
ucomisd %xmm2,%xmm4
jae    1885 <create_xgrid_1dx2d_order2+0x6e5>
unpcklpd %xmm2,%xmm1
movapd 0x60(%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     1885 <create_xgrid_1dx2d_order2+0x6e5>
mov    0xb0(%rsp),%rax
movups (%rax,%r12,8),%xmm0
movaps %xmm0,0x2b0(%rsp)
mov    0xb8(%rsp),%rax
movups (%rax,%r12,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movaps %xmm0,0x2c0(%rsp)
lea    0x2b0(%rsp),%r15
mov    %r15,%rdi
lea    0x120(%rsp),%rbp
mov    %rbp,%rsi
mov    $0x4,%edx
movsd  0x58(%rsp),%xmm0
call   1080 <fix_lon@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r15,%rsi
call   1090 <avgval_double@plt>
movsd  %xmm0,0xc0(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
movsd  0xa8(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movapd 0xf0(%rsp),%xmm3
mov    %r14,%rcx
mov    %r13,%r8
call   1040 <clip@plt>
test   %eax,%eax
jle    1870 <create_xgrid_1dx2d_order2+0x6d0>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1060 <poly_area@plt>
mov    0x7b0(%rsp),%rax
mov    0x98(%rsp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x90(%rsp),%rax
movsd  (%rax,%rcx,8),%xmm1
mov    0xa0(%rsp),%rax
minsd  (%rax,%r12,8),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
ucomisd 0x607(%rip),%xmm2
jbe    1870 <create_xgrid_1dx2d_order2+0x6d0>
movslq 0x38(%rsp),%r15
mov    0x7d8(%rsp),%rax
movsd  %xmm0,(%rax,%r15,8)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
movsd  0xc0(%rsp),%xmm0
call   10a0 <poly_ctrlon@plt>
mov    0x7e0(%rsp),%rax
movsd  %xmm0,(%rax,%r15,8)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1070 <poly_ctrlat@plt>
mov    0x7e8(%rsp),%rax
movsd  %xmm0,(%rax,%r15,8)
mov    0x7b8(%rsp),%rax
mov    0x88(%rsp),%rcx
mov    %ecx,(%rax,%r15,4)
mov    0x7c0(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    %ecx,(%rax,%r15,4)
mov    0x7c8(%rsp),%rax
mov    %r12d,(%rax,%r15,4)
mov    0x7d0(%rsp),%rax
mov    0x28(%rsp),%rcx
mov    %ecx,(%rax,%r15,4)
lea    0x1(%r15),%eax
mov    %eax,0x38(%rsp)
cmp    $0xf4240,%r15d
jl     1870 <create_xgrid_1dx2d_order2+0x6d0>
lea    0x559(%rip),%rdi
call   1050 <error_handler@plt>
jmp    1870 <create_xgrid_1dx2d_order2+0x6d0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x28(%rsp)
cmp    0xe8(%rsp),%rcx
jne    17eb <create_xgrid_1dx2d_order2+0x64b>
mov    0x100(%rsp),%r8
mov    0x108(%rsp),%rax
jmp    16f7 <create_xgrid_1dx2d_order2+0x557>
movl   $0x0,0x38(%rsp)
mov    0x90(%rsp),%rdi
call   1030 <free@plt>
mov    0x70(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%eax
add    $0x768,%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 = trunc i64 %78 to i32
%80 = call i64 @malloc(i32 %79)
%81 = inttoptr i64 %80 to double*
store double* %81, double** %53
%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** %54
%90 = load i32, i32* %33
%91 = add nsw i32 %90, 1
%92 = load i32, i32* %34
%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** %56
%100 = load i32, i32* %33
%101 = add nsw i32 %100, 1
%102 = load i32, i32* %34
%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** %57
store i32 0, i32* %40
br label %110
110: ; preds = %150, %16
%111 = load i32, i32* %40
%112 = load i32, i32* %34
%113 = icmp sle i32 %111, %112
br i1 %113, label %114, label %153
114: ; preds = %110
store i32 0, i32* %39
br label %115
115: ; preds = %146, %114
%116 = load i32, i32* %39
%117 = load i32, i32* %33
%118 = icmp sle i32 %116, %117
br i1 %118, label %119, label %149
119: ; preds = %115
%120 = load double*, double** %21
%121 = load i32, i32* %39
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %120, i64 %122
%124 = load double, double* %123
%125 = load double*, double** %56
%126 = load i32, i32* %40
%127 = load i32, i32* %37
%128 = mul nsw i32 %126, %127
%129 = load i32, i32* %39
%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** %22
%134 = load i32, i32* %40
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds double, double* %133, i64 %135
%137 = load double, double* %136
%138 = load double*, double** %57
%139 = load i32, i32* %40
%140 = load i32, i32* %37
%141 = mul nsw i32 %139, %140
%142 = load i32, i32* %39
%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* %39
%148 = add nsw i32 %147, 1
store i32 %148, i32* %39
br label %115
149: ; preds = %115
br label %150
150: ; preds = %149
%151 = load i32, i32* %40
%152 = add nsw i32 %151, 1
store i32 %152, i32* %40
br label %110
153: ; preds = %110
%154 = load i32*, i32** %17
%155 = load i32*, i32** %18
%156 = load double*, double** %56
%157 = load double*, double** %57
%158 = load double*, double** %53
%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** %23
%163 = load double*, double** %24
%164 = load double*, double** %54
%165 = call i32 @get_grid_area(i32* %160, i32* %161, double* %162, double* %163, double* %164)
%166 = load double*, double** %56
%167 = call i32 @free(double* %166)
%168 = load double*, double** %57
%169 = call i32 @free(double* %168)
store i32 0, i32* %40
br label %170
170: ; preds = %500, %153
%171 = load i32, i32* %40
%172 = load i32, i32* %34
%173 = icmp slt i32 %171, %172
br i1 %173, label %174, label %503
174: ; preds = %170
store i32 0, i32* %39
br label %175
175: ; preds = %496, %174
%176 = load i32, i32* %39
%177 = load i32, i32* %33
%178 = icmp slt i32 %176, %177
br i1 %178, label %179, label %499
179: ; preds = %175
%180 = load double*, double** %25
%181 = load i32, i32* %40
%182 = load i32, i32* %33
%183 = mul nsw i32 %181, %182
%184 = load i32, i32* %39
%185 = add nsw i32 %183, %184
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds double, double* %180, i64 %186
%188 = load double, double* %187
%189 = fcmp ogt double %188, 5.000000e-01
br i1 %189, label %190, label %495
190: ; preds = %179
%191 = load double*, double** %21
%192 = load i32, i32* %39
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds double, double* %191, i64 %193
%195 = load double, double* %194
store double %195, double* %45
%196 = load double*, double** %22
%197 = load i32, i32* %40
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds double, double* %196, i64 %198
%200 = load double, double* %199
store double %200, double* %46
%201 = load double*, double** %21
%202 = load i32, i32* %39
%203 = add nsw i32 %202, 1
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds double, double* %201, i64 %204
%206 = load double, double* %205
store double %206, double* %47
%207 = load double*, double** %22
%208 = load i32, i32* %40
%209 = add nsw i32 %208, 1
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds double, double* %207, i64 %210
%212 = load double, double* %211
store double %212, double* %48
store i32 0, i32* %42
br label %213
213: ; preds = %491, %190
%214 = load i32, i32* %42
%215 = load i32, i32* %36
%216 = icmp slt i32 %214, %215
br i1 %216, label %217, label %494
217: ; preds = %213
store i32 0, i32* %41
br label %218
218: ; preds = %487, %217
%219 = load i32, i32* %41
%220 = load i32, i32* %35
%221 = icmp slt i32 %219, %220
br i1 %221, label %222, label %490
222: ; preds = %218
%223 = load double*, double** %24
%224 = load i32, i32* %42
%225 = load i32, i32* %38
%226 = mul nsw i32 %224, %225
%227 = load i32, i32* %41
%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** %24
%234 = load i32, i32* %42
%235 = load i32, i32* %38
%236 = mul nsw i32 %234, %235
%237 = load i32, i32* %41
%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** %24
%245 = load i32, i32* %42
%246 = add nsw i32 %245, 1
%247 = load i32, i32* %38
%248 = mul nsw i32 %246, %247
%249 = load i32, i32* %41
%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** %24
%257 = load i32, i32* %42
%258 = add nsw i32 %257, 1
%259 = load i32, i32* %38
%260 = mul nsw i32 %258, %259
%261 = load i32, i32* %41
%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 %487
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 %487
308: ; preds = %302, %297, %292, %287
%309 = load double*, double** %23
%310 = load i32, i32* %42
%311 = load i32, i32* %38
%312 = mul nsw i32 %310, %311
%313 = load i32, i32* %41
%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** %23
%320 = load i32, i32* %42
%321 = load i32, i32* %38
%322 = mul nsw i32 %320, %321
%323 = load i32, i32* %41
%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** %23
%331 = load i32, i32* %42
%332 = add nsw i32 %331, 1
%333 = load i32, i32* %38
%334 = mul nsw i32 %332, %333
%335 = load i32, i32* %41
%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** %23
%343 = load i32, i32* %42
%344 = add nsw i32 %343, 1
%345 = load i32, i32* %38
%346 = mul nsw i32 %344, %345
%347 = load i32, i32* %41
%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* %58
%360 = load i32, i32* %58
%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* %61
%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* %58
%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* %59
%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* %59
%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* %60
%389 = load double*, double** %53
%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** %54
%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** %53
%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** %54
%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* %55
%430 = load double, double* %60
%431 = load double, double* %55
%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* %60
%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* %59
%443 = load double, double* %61
%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* %59
%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, %307, %286
%488 = load i32, i32* %41
%489 = add nsw i32 %488, 1
store i32 %489, i32* %41
br label %218
490: ; preds = %218
br label %491
491: ; preds = %490
%492 = load i32, i32* %42
%493 = add nsw i32 %492, 1
store i32 %493, i32* %42
br label %213
494: ; preds = %213
br label %495
495: ; preds = %494, %179
br label %496
496: ; preds = %495
%497 = load i32, i32* %39
%498 = add nsw i32 %497, 1
store i32 %498, i32* %39
br label %175
499: ; preds = %175
br label %500
500: ; preds = %499
%501 = load i32, i32* %40
%502 = add nsw i32 %501, 1
store i32 %502, i32* %40
br label %170
503: ; preds = %170
%504 = load double*, double** %53
%505 = call i32 @free(double* %504)
%506 = load double*, double** %54
%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_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 = 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 i32 %25, 1
%30 = add nsw 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 %26, 1
%40 = shl i32 %29, 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 %26, 0
br i1 %46, label %208, label %47
47: ; preds = %16
%48 = icmp slt i32 %25, 0
%49 = sext i32 %29 to i64
%50 = zext i32 %39 to i64
%51 = zext i32 %29 to i64
%52 = getelementptr double, double* %4, 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 %29, 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* %5, i64 %68
%76 = add nuw i64 %68, 1
%77 = getelementptr double, double* %5, i64 %76
br i1 %48, label %205, label %78
78: ; preds = %67
%79 = mul nsw i64 %68, %49
%80 = getelementptr inbounds double, double* %5, 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, %4
%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, %4
%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* %4, 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* %4, 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* %4, 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* %4, 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* %4, 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* %4, 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* %43, double* %45, double* %34)
%210 = tail call i32 @get_grid_area(i32* %2, i32* %3, double* %6, double* %7, double* %38)
%211 = tail call i32 @free(double* %43)
%212 = tail call i32 @free(double* %45)
%213 = icmp sgt i32 %26, 0
br i1 %213, label %214, label %367
214: ; preds = %208
%215 = icmp sgt i32 %25, 0
%216 = icmp sgt i32 %28, 0
%217 = icmp sgt i32 %27, 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 %30 to i64
%226 = sext i32 %27 to i64
%227 = sext i32 %25 to i64
%228 = zext i32 %26 to i64
%229 = zext i32 %25 to i64
%230 = zext i32 %28 to i64
%231 = zext i32 %27 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, %363
%236 = phi i64 [ 0, %214 ], [ %364, %363 ]
%237 = phi i32 [ 0, %214 ], [ %365, %363 ]
br i1 %215, label %240, label %238
238: ; preds = %235
%239 = add nuw nsw i64 %236, 1
br label %363
240: ; preds = %235
%241 = mul nsw i64 %236, %227
%242 = getelementptr inbounds double, double* %5, i64 %236
%243 = add nuw nsw i64 %236, 1
%244 = getelementptr inbounds double, double* %5, i64 %243
%245 = trunc i64 %236 to i32
br label %246
246: ; preds = %240, %359
%247 = phi i64 [ 0, %240 ], [ %360, %359 ]
%248 = phi i32 [ %237, %240 ], [ %361, %359 ]
%249 = add nsw i64 %247, %241
%250 = getelementptr inbounds double, double* %8, i64 %249
%251 = load double, double* %250
%252 = fcmp ogt double %251, 5.000000e-01
br i1 %252, label %255, label %253
253: ; preds = %246
%254 = add nuw nsw i64 %247, 1
br label %359
255: ; preds = %246
%256 = getelementptr inbounds double, double* %4, i64 %247
%257 = load double, double* %256
%258 = load double, double* %242
%259 = add nuw nsw i64 %247, 1
%260 = getelementptr inbounds double, double* %4, i64 %259
%261 = load double, double* %260
%262 = load double, double* %244
br i1 %216, label %263, label %359
263: ; preds = %255
%264 = fadd double %257, %261
%265 = fmul double %264, 5.000000e-01
%266 = getelementptr inbounds double, double* %34, i64 %249
%267 = trunc i64 %247 to i32
%268 = insertelement <4 x double> poison, double %262, i64 0
%269 = shufflevector <4 x double> %268, <4 x double> poison, <4 x i32> zeroinitializer
br label %270
270: ; preds = %263, %355
%271 = phi i64 [ 0, %263 ], [ %356, %355 ]
%272 = phi i32 [ %248, %263 ], [ %357, %355 ]
br i1 %217, label %275, label %273
273: ; preds = %270
%274 = add nuw nsw i64 %271, 1
br label %355
275: ; preds = %270
%276 = mul nsw i64 %271, %225
%277 = add nuw nsw i64 %271, 1
%278 = mul nsw i64 %277, %225
%279 = mul nsw i64 %271, %226
%280 = trunc i64 %271 to i32
br label %281
281: ; preds = %275, %351
%282 = phi i64 [ 0, %275 ], [ %353, %351 ]
%283 = phi i32 [ %272, %275 ], [ %352, %351 ]
%284 = add nsw i64 %282, %276
%285 = getelementptr inbounds double, double* %7, i64 %284
%286 = bitcast double* %285 to <2 x double>*
%287 = load <2 x double>, <2 x double>* %286
store <2 x double> %287, <2 x double>* %232
%288 = add nsw i64 %282, %278
%289 = add nsw i64 %288, 1
%290 = getelementptr inbounds double, double* %7, i64 %289
%291 = load double, double* %290
store double %291, double* %219
%292 = getelementptr inbounds double, double* %7, i64 %288
%293 = load double, double* %292
store double %293, double* %220
%294 = extractelement <2 x double> %287, i64 0
%295 = fcmp ugt double %294, %258
%296 = extractelement <2 x double> %287, i64 1
%297 = fcmp ugt double %296, %258
%298 = select i1 %295, i1 true, i1 %297
%299 = fcmp ugt double %291, %258
%300 = select i1 %298, i1 true, i1 %299
%301 = fcmp ugt double %293, %258
%302 = select i1 %300, i1 true, i1 %301
br i1 %302, label %303, label %351
303: ; preds = %281
%304 = shufflevector <2 x double> %287, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%305 = insertelement <4 x double> %304, double %291, i64 2
%306 = insertelement <4 x double> %305, double %293, i64 3
%307 = fcmp ult <4 x double> %306, %269
%308 = freeze <4 x i1> %307
%309 = bitcast <4 x i1> %308 to i4
%310 = icmp eq i4 %309, 0
br i1 %310, label %351, label %311
311: ; preds = %303
%312 = getelementptr inbounds double, double* %6, i64 %284
%313 = bitcast double* %312 to <2 x double>*
%314 = load <2 x double>, <2 x double>* %313
store <2 x double> %314, <2 x double>* %233
%315 = getelementptr inbounds double, double* %6, i64 %288
%316 = bitcast double* %315 to <2 x double>*
%317 = load <2 x double>, <2 x double>* %316
%318 = shufflevector <2 x double> %317, <2 x double> poison, <2 x i32> <i32 1, i32 0>
store <2 x double> %318, <2 x double>* %234
%319 = call i32 @fix_lon(double* %221, double* %218, i32 4, double %265)
%320 = call double @avgval_double(i32 %319, double* %221)
%321 = call i32 @clip(double* %221, double* %218, i32 %319, double %257, double %258, double %261, double %262, double* %223, double* %224)
%322 = icmp sgt i32 %321, 0
br i1 %322, label %323, label %351
323: ; preds = %311
%324 = call double @poly_area(double* %223, double* %224, i32 %321)
%325 = load double, double* %250
%326 = fmul double %324, %325
%327 = load double, double* %266
%328 = add nsw i64 %282, %279
%329 = getelementptr inbounds double, double* %38, i64 %328
%330 = load double, double* %329
%331 = fcmp olt double %327, %330
%332 = select i1 %331, double %327, double %330
%333 = fdiv double %326, %332
%334 = fcmp ogt double %333, 0x3EB0C6F7A0B5ED8D
br i1 %334, label %335, label %351
335: ; preds = %323
%336 = sext i32 %283 to i64
%337 = getelementptr inbounds double, double* %13, i64 %336
store double %326, double* %337
%338 = call double @poly_ctrlon(double* %223, double* %224, i32 %321, double %320)
%339 = getelementptr inbounds double, double* %14, i64 %336
store double %338, double* %339
%340 = call double @poly_ctrlat(double* %223, double* %224, i32 %321)
%341 = getelementptr inbounds double, double* %15, i64 %336
store double %340, double* %341
%342 = getelementptr inbounds i32, i32* %9, i64 %336
store i32 %267, i32* %342
%343 = getelementptr inbounds i32, i32* %10, i64 %336
store i32 %245, i32* %343
%344 = getelementptr inbounds i32, i32* %11, i64 %336
%345 = trunc i64 %282 to i32
store i32 %345, i32* %344
%346 = getelementptr inbounds i32, i32* %12, i64 %336
store i32 %280, i32* %346
%347 = add nsw i32 %283, 1
%348 = icmp sgt i32 %283, 999999
br i1 %348, label %349, label %351
349: ; preds = %335
%350 = call i32 @error_handler(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %351
351: ; preds = %311, %335, %349, %323, %303, %281
%352 = phi i32 [ %283, %281 ], [ %283, %303 ], [ %347, %349 ], [ %347, %335 ], [ %283, %323 ], [ %283, %311 ]
%353 = add nuw nsw i64 %282, 1
%354 = icmp eq i64 %353, %231
br i1 %354, label %355, label %281
355: ; preds = %351, %273
%356 = phi i64 [ %274, %273 ], [ %277, %351 ]
%357 = phi i32 [ %272, %273 ], [ %352, %351 ]
%358 = icmp eq i64 %356, %230
br i1 %358, label %359, label %270
359: ; preds = %355, %253, %255
%360 = phi i64 [ %254, %253 ], [ %259, %255 ], [ %259, %355 ]
%361 = phi i32 [ %248, %253 ], [ %248, %255 ], [ %357, %355 ]
%362 = icmp eq i64 %360, %229
br i1 %362, label %363, label %246
363: ; preds = %359, %238
%364 = phi i64 [ %239, %238 ], [ %243, %359 ]
%365 = phi i32 [ %237, %238 ], [ %361, %359 ]
%366 = icmp eq i64 %364, %228
br i1 %366, label %367, label %235
367: ; preds = %363, %208
%368 = phi i32 [ 0, %208 ], [ %365, %363 ]
%369 = call i32 @free(double* %34)
%370 = call i32 @free(double* %38)
ret i32 %368
}