#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 */
int clip_2dx2d_great_circle(double *, double *, double *, int, double *,
                            double *, double *, int, double *, double *,
                            double *);
int /*<<< orphan*/ error_handler(char *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ get_grid_great_circle_area(int const *, int const *,
                                              double const *, double const *,
                                              double *);
int /*<<< orphan*/ get_grid_great_circle_area_ug(int const *, double const *,
                                                 double const *, double *);
double const great_circle_area(int, double *, double *, double *);
int /*<<< orphan*/ latlon2xyz(int, double const *, double const *, double *,
                              double *, double *);
scalar_t__ malloc(int);
int create_xgrid_great_circle_ug(const int *nlon_in, const int *nlat_in,
                                 const int *npts_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 *l_out,
                                 double *xgrid_area, double *xgrid_clon,
                                 double *xgrid_clat) {
  int nx1, ny1, npts2, nx1p, ny1p, nxgrid, n1_in, n2_in, nv;
  int n0, n1, n2, n3, i1, j1, l2;
  double x1_in[50], y1_in[50], z1_in[50];
  double x2_in[50], y2_in[50], z2_in[50];
  double x_out[50], y_out[50], z_out[50];
  double *x1 = NULL, *y1 = NULL, *z1 = NULL;
  double *x2 = NULL, *y2 = NULL, *z2 = NULL;
  double xctrlon, xctrlat;
  double *area1, *area2, min_area;
  nx1 = *nlon_in;
  ny1 = *nlat_in;
  nv = 4;
  npts2 = *npts_out;
  nxgrid = 0;
  nx1p = nx1 + 1;
  ny1p = ny1 + 1;
  x1 = (double *)malloc(nx1p * ny1p * sizeof(double));
  y1 = (double *)malloc(nx1p * ny1p * sizeof(double));
  z1 = (double *)malloc(nx1p * ny1p * sizeof(double));
  x2 = (double *)malloc(npts2 * nv * sizeof(double));
  y2 = (double *)malloc(npts2 * nv * sizeof(double));
  z2 = (double *)malloc(npts2 * nv * sizeof(double));
  latlon2xyz(nx1p * ny1p, lon_in, lat_in, x1, y1, z1);
  latlon2xyz(npts2 * nv, lon_out, lat_out, x2, y2, z2);
  area1 = (double *)malloc(nx1 * ny1 * sizeof(double));
  area2 = (double *)malloc(npts2 * sizeof(double));
  get_grid_great_circle_area(nlon_in, nlat_in, lon_in, lat_in, area1);
  get_grid_great_circle_area_ug(npts_out, lon_out, lat_out, area2);
  n1_in = 4;
  n2_in = 4;
  for (j1 = 0; j1 < ny1; j1++)
    for (i1 = 0; i1 < nx1; i1++)
      if (mask_in[j1 * nx1 + i1] > (0.5)) {
        n0 = j1 * nx1p + i1;
        n1 = (j1 + 1) * nx1p + i1;
        n2 = (j1 + 1) * nx1p + i1 + 1;
        n3 = j1 * nx1p + i1 + 1;
        x1_in[0] = x1[n0];
        y1_in[0] = y1[n0];
        z1_in[0] = z1[n0];
        x1_in[1] = x1[n1];
        y1_in[1] = y1[n1];
        z1_in[1] = z1[n1];
        x1_in[2] = x1[n2];
        y1_in[2] = y1[n2];
        z1_in[2] = z1[n2];
        x1_in[3] = x1[n3];
        y1_in[3] = y1[n3];
        z1_in[3] = z1[n3];
        for (l2 = 0; l2 < npts2; l2++) {
          int n_in, n_out;
          double xarea;
          n0 = l2 * nv;
          n1 = l2 * nv + 1;
          n2 = l2 * nv + 2;
          n3 = l2 * nv + 3;
          x2_in[0] = x2[n0];
          y2_in[0] = y2[n0];
          z2_in[0] = z2[n0];
          x2_in[1] = x2[n1];
          y2_in[1] = y2[n1];
          z2_in[1] = z2[n1];
          x2_in[2] = x2[n2];
          y2_in[2] = y2[n2];
          z2_in[2] = z2[n2];
          x2_in[3] = x2[n3];
          y2_in[3] = y2[n3];
          z2_in[3] = z2[n3];
          if ((n_out = clip_2dx2d_great_circle(x1_in, y1_in, z1_in, n1_in,
                                               x2_in, y2_in, z2_in, n2_in,
                                               x_out, y_out, z_out)) > 0) {
            xarea = great_circle_area(n_out, x_out, y_out, z_out) *
                    mask_in[j1 * nx1 + i1];
            min_area = (area1[j1 * nx1 + i1] < area2[l2] ? area1[j1 * nx1 + i1]
                                                         : area2[l2]);
            if (xarea / min_area > (1.e-6)) {
              xgrid_area[nxgrid] = xarea;
              xgrid_clon[nxgrid] = 0;
              xgrid_clat[nxgrid] = 0;
              i_in[nxgrid] = i1;
              j_in[nxgrid] = j1;
              l_out[nxgrid] = l2;
              ++nxgrid;
              if (nxgrid > 1e6)
                error_handler(
                    "nxgrid is greater than MAXXGRID, increase MAXXGRID");
            }
          }
        }
      }
  free(area1);
  free(area2);
  free(x1);
  free(y1);
  free(z1);
  free(x2);
  free(y2);
  free(z2);
  return nxgrid;
}


x86 assembly (clang, -O0):
<create_xgrid_great_circle_ug>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xf20,%rsp
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,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movq   $0x0,-0xe98(%rbp)
movq   $0x0,-0xea0(%rbp)
movq   $0x0,-0xea8(%rbp)
movq   $0x0,-0xeb0(%rbp)
movq   $0x0,-0xeb8(%rbp)
movq   $0x0,-0xec0(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
movl   $0x4,-0x64(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%eax
imul   -0x54(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xe98(%rbp)
mov    -0x50(%rbp),%eax
imul   -0x54(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xea0(%rbp)
mov    -0x50(%rbp),%eax
imul   -0x54(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xea8(%rbp)
mov    -0x4c(%rbp),%eax
imul   -0x64(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xeb0(%rbp)
mov    -0x4c(%rbp),%eax
imul   -0x64(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xeb8(%rbp)
mov    -0x4c(%rbp),%eax
imul   -0x64(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xec0(%rbp)
mov    -0x50(%rbp),%edi
imul   -0x54(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0xe98(%rbp),%rcx
mov    -0xea0(%rbp),%r8
mov    -0xea8(%rbp),%r9
call   1070 <latlon2xyz@plt>
mov    -0x4c(%rbp),%edi
imul   -0x64(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    0x10(%rbp),%rdx
mov    -0xeb0(%rbp),%rcx
mov    -0xeb8(%rbp),%r8
mov    -0xec0(%rbp),%r9
call   1070 <latlon2xyz@plt>
mov    -0x44(%rbp),%eax
imul   -0x48(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xed8(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0xee0(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0xed8(%rbp),%r8
call   1090 <get_grid_great_circle_area@plt>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x10(%rbp),%rdx
mov    -0xee0(%rbp),%rcx
call   10a0 <get_grid_great_circle_area_ug@plt>
movl   $0x4,-0x5c(%rbp)
movl   $0x4,-0x60(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    18e0 <create_xgrid_great_circle_ug+0x760>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    18cd <create_xgrid_great_circle_ug+0x74d>
mov    0x18(%rbp),%rax
mov    -0x7c(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x78(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xc12(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    18ba <create_xgrid_great_circle_ug+0x73a>
mov    -0x7c(%rbp),%eax
imul   -0x50(%rbp),%eax
add    -0x78(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
imul   -0x50(%rbp),%eax
add    -0x78(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
imul   -0x50(%rbp),%eax
add    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
mov    -0x7c(%rbp),%eax
imul   -0x50(%rbp),%eax
add    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
mov    -0xe98(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x210(%rbp)
ff
mov    -0xea0(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x3a0(%rbp)
ff
mov    -0xea8(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x530(%rbp)
ff
mov    -0xe98(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x208(%rbp)
ff
mov    -0xea0(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x398(%rbp)
ff
mov    -0xea8(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x528(%rbp)
ff
mov    -0xe98(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x200(%rbp)
ff
mov    -0xea0(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x390(%rbp)
ff
mov    -0xea8(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x520(%rbp)
ff
mov    -0xe98(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x1f8(%rbp)
ff
mov    -0xea0(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x388(%rbp)
ff
mov    -0xea8(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x518(%rbp)
ff
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    18b5 <create_xgrid_great_circle_ug+0x735>
mov    -0x80(%rbp),%eax
imul   -0x64(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x80(%rbp),%eax
imul   -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x80(%rbp),%eax
imul   -0x64(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x70(%rbp)
mov    -0x80(%rbp),%eax
imul   -0x64(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x74(%rbp)
mov    -0xeb0(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x6c0(%rbp)
ff
mov    -0xeb8(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x850(%rbp)
ff
mov    -0xec0(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x9e0(%rbp)
ff
mov    -0xeb0(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x6b8(%rbp)
ff
mov    -0xeb8(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x848(%rbp)
ff
mov    -0xec0(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x9d8(%rbp)
ff
mov    -0xeb0(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x6b0(%rbp)
ff
mov    -0xeb8(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x840(%rbp)
ff
mov    -0xec0(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x9d0(%rbp)
ff
mov    -0xeb0(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x6a8(%rbp)
ff
mov    -0xeb8(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x838(%rbp)
ff
mov    -0xec0(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x9c8(%rbp)
ff
lea    -0x210(%rbp),%rdi
lea    -0x3a0(%rbp),%rsi
lea    -0x530(%rbp),%rdx
mov    -0x5c(%rbp),%ecx
lea    -0x6c0(%rbp),%r8
lea    -0x850(%rbp),%r9
lea    -0x9e0(%rbp),%r14
mov    -0x60(%rbp),%ebx
lea    -0xb70(%rbp),%r11
lea    -0xd00(%rbp),%r10
lea    -0xe90(%rbp),%rax
mov    %r14,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1040 <clip_2dx2d_great_circle@plt>
mov    %eax,-0xef0(%rbp)
cmp    $0x0,%eax
jle    18a2 <create_xgrid_great_circle_ug+0x722>
mov    -0xef0(%rbp),%edi
lea    -0xb70(%rbp),%rsi
lea    -0xd00(%rbp),%rdx
lea    -0xe90(%rbp),%rcx
call   1080 <great_circle_area@plt>
mov    0x18(%rbp),%rax
mov    -0x7c(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x78(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xef8(%rbp)
ff
mov    -0xed8(%rbp),%rax
mov    -0x7c(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x78(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0xee0(%rbp),%rax
movslq -0x80(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    17c3 <create_xgrid_great_circle_ug+0x643>
mov    -0xed8(%rbp),%rax
mov    -0x7c(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    -0x78(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xf00(%rbp)
ff
jmp    17db <create_xgrid_great_circle_ug+0x65b>
mov    -0xee0(%rbp),%rax
movslq -0x80(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xf00(%rbp)
ff
movsd  -0xf00(%rbp),%xmm0
ff
movsd  %xmm0,-0xee8(%rbp)
ff
movsd  -0xef8(%rbp),%xmm0
ff
divsd  -0xee8(%rbp),%xmm0
ff
movsd  0x805(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    189d <create_xgrid_great_circle_ug+0x71d>
movsd  -0xef8(%rbp),%xmm0
ff
mov    0x38(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x48(%rbp),%rax
movslq -0x58(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x78(%rbp),%edx
mov    0x20(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x7c(%rbp),%edx
mov    0x28(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x80(%rbp),%edx
mov    0x30(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
cvtsi2sdl -0x58(%rbp),%xmm0
movsd  0x78e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1898 <create_xgrid_great_circle_ug+0x718>
lea    0x785(%rip),%rdi
call   1050 <error_handler@plt>
jmp    189d <create_xgrid_great_circle_ug+0x71d>
jmp    18a2 <create_xgrid_great_circle_ug+0x722>
jmp    18a7 <create_xgrid_great_circle_ug+0x727>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    155f <create_xgrid_great_circle_ug+0x3df>
jmp    18ba <create_xgrid_great_circle_ug+0x73a>
jmp    18bf <create_xgrid_great_circle_ug+0x73f>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    13c4 <create_xgrid_great_circle_ug+0x244>
jmp    18d2 <create_xgrid_great_circle_ug+0x752>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    13b1 <create_xgrid_great_circle_ug+0x231>
mov    -0xed8(%rbp),%rdi
call   1030 <free@plt>
mov    -0xee0(%rbp),%rdi
call   1030 <free@plt>
mov    -0xe98(%rbp),%rdi
call   1030 <free@plt>
mov    -0xea0(%rbp),%rdi
call   1030 <free@plt>
mov    -0xea8(%rbp),%rdi
call   1030 <free@plt>
mov    -0xeb0(%rbp),%rdi
call   1030 <free@plt>
mov    -0xeb8(%rbp),%rdi
call   1030 <free@plt>
mov    -0xec0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%eax
add    $0xf20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_xgrid_great_circle_ug>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xec8,%rsp
mov    %r9,0x30(%rsp)
mov    %r8,0x20(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,0x28(%rsp)
movslq (%rdi),%rax
mov    %rax,0x50(%rsp)
mov    (%rsi),%ecx
mov    %rcx,0x58(%rsp)
mov    (%rdx),%ebp
add    $0x1,%rax
lea    0x1(%rcx),%r14d
mov    %rax,0x80(%rsp)
imul   %eax,%r14d
lea    0x0(,%r14,8),%ebx
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,0x40(%rsp)
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rbp,0x48(%rsp)
lea    0x0(,%rbp,4),%eax
mov    %eax,0x38(%rsp)
shl    $0x5,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %r14d,%edi
mov    0x18(%rsp),%rsi
mov    0x20(%rsp),%rdx
mov    0x40(%rsp),%rcx
mov    %r15,0x68(%rsp)
mov    %r15,%r8
mov    %r12,0x60(%rsp)
mov    %r12,%r9
call   1070 <latlon2xyz@plt>
mov    0x38(%rsp),%edi
mov    0x50(%rsp),%r14
mov    0x30(%rsp),%rsi
mov    0xf00(%rsp),%rdx
mov    %r13,0x38(%rsp)
mov    %r13,%rcx
mov    %rbx,0x78(%rsp)
mov    %rbx,%r8
mov    %rbp,0x70(%rsp)
mov    %rbp,%r9
call   1070 <latlon2xyz@plt>
mov    %r14d,%edi
mov    0x58(%rsp),%rbx
imul   %ebx,%edi
shl    $0x3,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    0x48(%rsp),%rax
lea    0x0(,%rax,8),%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    0x28(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    0x18(%rsp),%rdx
mov    0x20(%rsp),%rcx
mov    %r15,0x20(%rsp)
mov    %r15,%r8
call   1090 <get_grid_great_circle_area@plt>
mov    0x10(%rsp),%rdi
mov    0x30(%rsp),%rsi
mov    0xf00(%rsp),%rdx
mov    %r12,0x18(%rsp)
mov    %r12,%rcx
call   10a0 <get_grid_great_circle_area_ug@plt>
mov    %rbx,%rax
test   %eax,%eax
jle    170e <create_xgrid_great_circle_ug+0x58e>
mov    %r14d,%eax
mov    %rax,0xa0(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0xa10(%rsp),%r15
lea    0xba0(%rsp),%r13
lea    0xd30(%rsp),%rbx
movl   $0x0,0x10(%rsp)
jmp    1350 <create_xgrid_great_circle_ug+0x1d0>
mov    0x88(%rsp),%rcx
mov    %rcx,%rax
mov    %rcx,0x8(%rsp)
mov    0x50(%rsp),%r14
cmp    0x58(%rsp),%rcx
je     1716 <create_xgrid_great_circle_ug+0x596>
test   %r14d,%r14d
jle    16f0 <create_xgrid_great_circle_ug+0x570>
mov    0x8(%rsp),%rcx
mov    %rcx,%rax
imul   %r14,%rax
mov    %rax,0xa8(%rsp)
mov    %rcx,%rdx
mov    0x80(%rsp),%rax
imul   %rax,%rdx
mov    %rdx,0x98(%rsp)
add    $0x1,%rcx
mov    %rcx,0x88(%rsp)
imul   %rax,%rcx
mov    %rcx,0x90(%rsp)
xor    %ebp,%ebp
jmp    13b7 <create_xgrid_great_circle_ug+0x237>
mov    0x28(%rsp),%rbp
add    $0x1,%rbp
cmp    0xa0(%rsp),%rbp
je     1330 <create_xgrid_great_circle_ug+0x1b0>
mov    0xa8(%rsp),%rax
lea    (%rax,%rbp,1),%r8
mov    0xf08(%rsp),%rax
movsd  (%rax,%r8,8),%xmm0
ucomisd 0xc27(%rip),%xmm0
mov    %rbp,0x28(%rsp)
jbe    13a0 <create_xgrid_great_circle_ug+0x220>
mov    0x98(%rsp),%rax
add    %rbp,%rax
mov    0x90(%rsp),%rcx
lea    0x0(%rbp,%rcx,1),%rcx
mov    0x40(%rsp),%rdx
movsd  (%rdx,%rax,8),%xmm0
movsd  %xmm0,0x880(%rsp)
mov    0x68(%rsp),%rsi
movsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,0x6f0(%rsp)
mov    0x60(%rsp),%rdi
movsd  (%rdi,%rax,8),%xmm0
movsd  %xmm0,0x560(%rsp)
movsd  (%rdx,%rcx,8),%xmm0
movsd  %xmm0,0x888(%rsp)
movsd  (%rsi,%rcx,8),%xmm0
movsd  %xmm0,0x6f8(%rsp)
movsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x568(%rsp)
movsd  0x8(%rdx,%rcx,8),%xmm0
movsd  %xmm0,0x890(%rsp)
movsd  0x8(%rsi,%rcx,8),%xmm0
movsd  %xmm0,0x700(%rsp)
movsd  0x8(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x570(%rsp)
movsd  0x8(%rdx,%rax,8),%xmm0
movsd  %xmm0,0x898(%rsp)
movsd  0x8(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x708(%rsp)
movsd  0x8(%rdi,%rax,8),%xmm0
movsd  %xmm0,0x578(%rsp)
cmpl   $0x0,0x48(%rsp)
jle    13a0 <create_xgrid_great_circle_ug+0x220>
mov    %r8,0x30(%rsp)
mov    $0x3,%r12d
xor    %r14d,%r14d
jmp    14ec <create_xgrid_great_circle_ug+0x36c>
mov    %r13,%r15
mov    %rbx,%r13
mov    %rbp,%rbx
add    $0x1,%r14
add    $0x4,%r12
cmp    %r14,0x48(%rsp)
je     13a0 <create_xgrid_great_circle_ug+0x220>
mov    0x38(%rsp),%rax
movsd  -0x18(%rax,%r12,8),%xmm0
movsd  %xmm0,0x3d0(%rsp)
mov    0x78(%rsp),%rcx
movsd  -0x18(%rcx,%r12,8),%xmm0
movsd  %xmm0,0x240(%rsp)
mov    0x70(%rsp),%rdx
movsd  -0x18(%rdx,%r12,8),%xmm0
movsd  %xmm0,0xb0(%rsp)
movsd  -0x10(%rax,%r12,8),%xmm0
movsd  %xmm0,0x3d8(%rsp)
movsd  -0x10(%rcx,%r12,8),%xmm0
movsd  %xmm0,0x248(%rsp)
movsd  -0x10(%rdx,%r12,8),%xmm0
movsd  %xmm0,0xb8(%rsp)
movsd  -0x8(%rax,%r12,8),%xmm0
movsd  %xmm0,0x3e0(%rsp)
movsd  -0x8(%rcx,%r12,8),%xmm0
movsd  %xmm0,0x250(%rsp)
movsd  -0x8(%rdx,%r12,8),%xmm0
movsd  %xmm0,0xc0(%rsp)
movsd  (%rax,%r12,8),%xmm0
movsd  %xmm0,0x3e8(%rsp)
movsd  (%rcx,%r12,8),%xmm0
movsd  %xmm0,0x258(%rsp)
movsd  (%rdx,%r12,8),%xmm0
movsd  %xmm0,0xc8(%rsp)
sub    $0x8,%rsp
lea    0x888(%rsp),%rdi
lea    0x6f8(%rsp),%rsi
lea    0x568(%rsp),%rdx
mov    $0x4,%ecx
lea    0x3d8(%rsp),%r8
lea    0x248(%rsp),%r9
push   %r15
push   %r13
push   %rbx
push   $0x4
lea    0xd8(%rsp),%rax
push   %rax
call   1040 <clip_2dx2d_great_circle@plt>
add    $0x30,%rsp
test   %eax,%eax
jle    14d9 <create_xgrid_great_circle_ug+0x359>
mov    %eax,%edi
mov    %rbx,%rbp
mov    %rbx,%rsi
mov    %r13,%rbx
mov    %r13,%rdx
mov    %r15,%r13
mov    %r15,%rcx
call   1080 <great_circle_area@plt>
mov    0xf08(%rsp),%rax
mov    0x30(%rsp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    0x20(%rsp),%rax
movsd  (%rax,%rcx,8),%xmm1
mov    0x18(%rsp),%rax
minsd  (%rax,%r14,8),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
ucomisd 0x9ae(%rip),%xmm2
jbe    14d0 <create_xgrid_great_circle_ug+0x350>
movslq 0x10(%rsp),%rax
mov    0xf28(%rsp),%rcx
movsd  %xmm0,(%rcx,%rax,8)
mov    0xf30(%rsp),%rcx
movq   $0x0,(%rcx,%rax,8)
mov    0xf38(%rsp),%rcx
movq   $0x0,(%rcx,%rax,8)
mov    0xf10(%rsp),%rcx
mov    0x28(%rsp),%rdx
mov    %edx,(%rcx,%rax,4)
mov    0xf18(%rsp),%rcx
mov    0x8(%rsp),%rdx
mov    %edx,(%rcx,%rax,4)
mov    0xf20(%rsp),%rcx
mov    %r14d,(%rcx,%rax,4)
lea    0x1(%rax),%ecx
mov    %ecx,0x10(%rsp)
cmp    $0xf4240,%eax
jl     14d0 <create_xgrid_great_circle_ug+0x350>
lea    0x939(%rip),%rdi
call   1050 <error_handler@plt>
jmp    14d0 <create_xgrid_great_circle_ug+0x350>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x8(%rsp)
cmp    0x58(%rsp),%rcx
jne    1350 <create_xgrid_great_circle_ug+0x1d0>
jmp    1716 <create_xgrid_great_circle_ug+0x596>
movl   $0x0,0x10(%rsp)
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x40(%rsp),%rdi
call   1030 <free@plt>
mov    0x68(%rsp),%rdi
call   1030 <free@plt>
mov    0x60(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    0x78(%rsp),%rdi
call   1030 <free@plt>
mov    0x70(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%eax
add    $0xec8,%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_great_circle_ug(i32* %0, i32* %1, i32* %2, double* %3, double* %4, double* %5, double* %6, double* %7, i32* %8, i32* %9, i32* %10, double* %11, double* %12, double* %13) {
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i32*
%26 = alloca double*
%27 = alloca double*
%28 = alloca double*
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%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 [50 x double]
%46 = alloca [50 x double]
%47 = alloca [50 x double]
%48 = alloca [50 x double]
%49 = alloca [50 x double]
%50 = alloca [50 x double]
%51 = alloca [50 x double]
%52 = alloca [50 x double]
%53 = alloca [50 x double]
%54 = alloca double*
%55 = alloca double*
%56 = alloca double*
%57 = alloca double*
%58 = alloca double*
%59 = alloca double*
%60 = alloca double
%61 = alloca double
%62 = alloca double*
%63 = alloca double*
%64 = alloca double
%65 = alloca i32
%66 = alloca i32
%67 = alloca double
store i32* %0, i32** %15
store i32* %1, i32** %16
store i32* %2, i32** %17
store double* %3, double** %18
store double* %4, double** %19
store double* %5, double** %20
store double* %6, double** %21
store double* %7, double** %22
store i32* %8, i32** %23
store i32* %9, i32** %24
store i32* %10, i32** %25
store double* %11, double** %26
store double* %12, double** %27
store double* %13, double** %28
store double* null, double** %54
store double* null, double** %55
store double* null, double** %56
store double* null, double** %57
store double* null, double** %58
store double* null, double** %59
%68 = load i32*, i32** %15
%69 = load i32, i32* %68
store i32 %69, i32* %29
%70 = load i32*, i32** %16
%71 = load i32, i32* %70
store i32 %71, i32* %30
store i32 4, i32* %37
%72 = load i32*, i32** %17
%73 = load i32, i32* %72
store i32 %73, i32* %31
store i32 0, i32* %34
%74 = load i32, i32* %29
%75 = add nsw i32 %74, 1
store i32 %75, i32* %32
%76 = load i32, i32* %30
%77 = add nsw i32 %76, 1
store i32 %77, i32* %33
%78 = load i32, i32* %32
%79 = load i32, i32* %33
%80 = mul nsw i32 %78, %79
%81 = sext i32 %80 to i64
%82 = mul i64 %81, 8
%83 = trunc i64 %82 to i32
%84 = call i64 @malloc(i32 %83)
%85 = inttoptr i64 %84 to double*
store double* %85, double** %54
%86 = load i32, i32* %32
%87 = load i32, i32* %33
%88 = mul nsw i32 %86, %87
%89 = sext i32 %88 to i64
%90 = mul i64 %89, 8
%91 = trunc i64 %90 to i32
%92 = call i64 @malloc(i32 %91)
%93 = inttoptr i64 %92 to double*
store double* %93, double** %55
%94 = load i32, i32* %32
%95 = load i32, i32* %33
%96 = mul nsw i32 %94, %95
%97 = sext i32 %96 to i64
%98 = mul i64 %97, 8
%99 = trunc i64 %98 to i32
%100 = call i64 @malloc(i32 %99)
%101 = inttoptr i64 %100 to double*
store double* %101, double** %56
%102 = load i32, i32* %31
%103 = load i32, i32* %37
%104 = mul nsw i32 %102, %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
%110 = load i32, i32* %31
%111 = load i32, i32* %37
%112 = mul nsw i32 %110, %111
%113 = sext i32 %112 to i64
%114 = mul i64 %113, 8
%115 = trunc i64 %114 to i32
%116 = call i64 @malloc(i32 %115)
%117 = inttoptr i64 %116 to double*
store double* %117, double** %58
%118 = load i32, i32* %31
%119 = load i32, i32* %37
%120 = mul nsw i32 %118, %119
%121 = sext i32 %120 to i64
%122 = mul i64 %121, 8
%123 = trunc i64 %122 to i32
%124 = call i64 @malloc(i32 %123)
%125 = inttoptr i64 %124 to double*
store double* %125, double** %59
%126 = load i32, i32* %32
%127 = load i32, i32* %33
%128 = mul nsw i32 %126, %127
%129 = load double*, double** %18
%130 = load double*, double** %19
%131 = load double*, double** %54
%132 = load double*, double** %55
%133 = load double*, double** %56
%134 = call i32 @latlon2xyz(i32 %128, double* %129, double* %130, double* %131, double* %132, double* %133)
%135 = load i32, i32* %31
%136 = load i32, i32* %37
%137 = mul nsw i32 %135, %136
%138 = load double*, double** %20
%139 = load double*, double** %21
%140 = load double*, double** %57
%141 = load double*, double** %58
%142 = load double*, double** %59
%143 = call i32 @latlon2xyz(i32 %137, double* %138, double* %139, double* %140, double* %141, double* %142)
%144 = load i32, i32* %29
%145 = load i32, i32* %30
%146 = mul nsw i32 %144, %145
%147 = sext i32 %146 to i64
%148 = mul i64 %147, 8
%149 = trunc i64 %148 to i32
%150 = call i64 @malloc(i32 %149)
%151 = inttoptr i64 %150 to double*
store double* %151, double** %62
%152 = load i32, i32* %31
%153 = sext i32 %152 to i64
%154 = mul i64 %153, 8
%155 = trunc i64 %154 to i32
%156 = call i64 @malloc(i32 %155)
%157 = inttoptr i64 %156 to double*
store double* %157, double** %63
%158 = load i32*, i32** %15
%159 = load i32*, i32** %16
%160 = load double*, double** %18
%161 = load double*, double** %19
%162 = load double*, double** %62
%163 = call i32 @get_grid_great_circle_area(i32* %158, i32* %159, double* %160, double* %161, double* %162)
%164 = load i32*, i32** %17
%165 = load double*, double** %20
%166 = load double*, double** %21
%167 = load double*, double** %63
%168 = call i32 @get_grid_great_circle_area_ug(i32* %164, double* %165, double* %166, double* %167)
store i32 4, i32* %35
store i32 4, i32* %36
store i32 0, i32* %43
br label %169
169: ; preds = %492, %14
%170 = load i32, i32* %43
%171 = load i32, i32* %30
%172 = icmp slt i32 %170, %171
br i1 %172, label %173, label %495
173: ; preds = %169
store i32 0, i32* %42
br label %174
174: ; preds = %488, %173
%175 = load i32, i32* %42
%176 = load i32, i32* %29
%177 = icmp slt i32 %175, %176
br i1 %177, label %178, label %491
178: ; preds = %174
%179 = load double*, double** %22
%180 = load i32, i32* %43
%181 = load i32, i32* %29
%182 = mul nsw i32 %180, %181
%183 = load i32, i32* %42
%184 = add nsw i32 %182, %183
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds double, double* %179, i64 %185
%187 = load double, double* %186
%188 = fcmp ogt double %187, 5.000000e-01
br i1 %188, label %189, label %487
189: ; preds = %178
%190 = load i32, i32* %43
%191 = load i32, i32* %32
%192 = mul nsw i32 %190, %191
%193 = load i32, i32* %42
%194 = add nsw i32 %192, %193
store i32 %194, i32* %38
%195 = load i32, i32* %43
%196 = add nsw i32 %195, 1
%197 = load i32, i32* %32
%198 = mul nsw i32 %196, %197
%199 = load i32, i32* %42
%200 = add nsw i32 %198, %199
store i32 %200, i32* %39
%201 = load i32, i32* %43
%202 = add nsw i32 %201, 1
%203 = load i32, i32* %32
%204 = mul nsw i32 %202, %203
%205 = load i32, i32* %42
%206 = add nsw i32 %204, %205
%207 = add nsw i32 %206, 1
store i32 %207, i32* %40
%208 = load i32, i32* %43
%209 = load i32, i32* %32
%210 = mul nsw i32 %208, %209
%211 = load i32, i32* %42
%212 = add nsw i32 %210, %211
%213 = add nsw i32 %212, 1
store i32 %213, i32* %41
%214 = load double*, double** %54
%215 = load i32, i32* %38
%216 = sext i32 %215 to i64
%217 = getelementptr inbounds double, double* %214, i64 %216
%218 = load double, double* %217
%219 = getelementptr inbounds [50 x double], [50 x double]* %45, i64 0, i64 0
store double %218, double* %219
%220 = load double*, double** %55
%221 = load i32, i32* %38
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds double, double* %220, i64 %222
%224 = load double, double* %223
%225 = getelementptr inbounds [50 x double], [50 x double]* %46, i64 0, i64 0
store double %224, double* %225
%226 = load double*, double** %56
%227 = load i32, i32* %38
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds double, double* %226, i64 %228
%230 = load double, double* %229
%231 = getelementptr inbounds [50 x double], [50 x double]* %47, i64 0, i64 0
store double %230, double* %231
%232 = load double*, double** %54
%233 = load i32, i32* %39
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds double, double* %232, i64 %234
%236 = load double, double* %235
%237 = getelementptr inbounds [50 x double], [50 x double]* %45, i64 0, i64 1
store double %236, double* %237
%238 = load double*, double** %55
%239 = load i32, i32* %39
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds double, double* %238, i64 %240
%242 = load double, double* %241
%243 = getelementptr inbounds [50 x double], [50 x double]* %46, i64 0, i64 1
store double %242, double* %243
%244 = load double*, double** %56
%245 = load i32, i32* %39
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds double, double* %244, i64 %246
%248 = load double, double* %247
%249 = getelementptr inbounds [50 x double], [50 x double]* %47, i64 0, i64 1
store double %248, double* %249
%250 = load double*, double** %54
%251 = load i32, i32* %40
%252 = sext i32 %251 to i64
%253 = getelementptr inbounds double, double* %250, i64 %252
%254 = load double, double* %253
%255 = getelementptr inbounds [50 x double], [50 x double]* %45, i64 0, i64 2
store double %254, double* %255
%256 = load double*, double** %55
%257 = load i32, i32* %40
%258 = sext i32 %257 to i64
%259 = getelementptr inbounds double, double* %256, i64 %258
%260 = load double, double* %259
%261 = getelementptr inbounds [50 x double], [50 x double]* %46, i64 0, i64 2
store double %260, double* %261
%262 = load double*, double** %56
%263 = load i32, i32* %40
%264 = sext i32 %263 to i64
%265 = getelementptr inbounds double, double* %262, i64 %264
%266 = load double, double* %265
%267 = getelementptr inbounds [50 x double], [50 x double]* %47, i64 0, i64 2
store double %266, double* %267
%268 = load double*, double** %54
%269 = load i32, i32* %41
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds double, double* %268, i64 %270
%272 = load double, double* %271
%273 = getelementptr inbounds [50 x double], [50 x double]* %45, i64 0, i64 3
store double %272, double* %273
%274 = load double*, double** %55
%275 = load i32, i32* %41
%276 = sext i32 %275 to i64
%277 = getelementptr inbounds double, double* %274, i64 %276
%278 = load double, double* %277
%279 = getelementptr inbounds [50 x double], [50 x double]* %46, i64 0, i64 3
store double %278, double* %279
%280 = load double*, double** %56
%281 = load i32, i32* %41
%282 = sext i32 %281 to i64
%283 = getelementptr inbounds double, double* %280, i64 %282
%284 = load double, double* %283
%285 = getelementptr inbounds [50 x double], [50 x double]* %47, i64 0, i64 3
store double %284, double* %285
store i32 0, i32* %44
br label %286
286: ; preds = %483, %189
%287 = load i32, i32* %44
%288 = load i32, i32* %31
%289 = icmp slt i32 %287, %288
br i1 %289, label %290, label %486
290: ; preds = %286
%291 = load i32, i32* %44
%292 = load i32, i32* %37
%293 = mul nsw i32 %291, %292
store i32 %293, i32* %38
%294 = load i32, i32* %44
%295 = load i32, i32* %37
%296 = mul nsw i32 %294, %295
%297 = add nsw i32 %296, 1
store i32 %297, i32* %39
%298 = load i32, i32* %44
%299 = load i32, i32* %37
%300 = mul nsw i32 %298, %299
%301 = add nsw i32 %300, 2
store i32 %301, i32* %40
%302 = load i32, i32* %44
%303 = load i32, i32* %37
%304 = mul nsw i32 %302, %303
%305 = add nsw i32 %304, 3
store i32 %305, i32* %41
%306 = load double*, double** %57
%307 = load i32, i32* %38
%308 = sext i32 %307 to i64
%309 = getelementptr inbounds double, double* %306, i64 %308
%310 = load double, double* %309
%311 = getelementptr inbounds [50 x double], [50 x double]* %48, i64 0, i64 0
store double %310, double* %311
%312 = load double*, double** %58
%313 = load i32, i32* %38
%314 = sext i32 %313 to i64
%315 = getelementptr inbounds double, double* %312, i64 %314
%316 = load double, double* %315
%317 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
store double %316, double* %317
%318 = load double*, double** %59
%319 = load i32, i32* %38
%320 = sext i32 %319 to i64
%321 = getelementptr inbounds double, double* %318, i64 %320
%322 = load double, double* %321
%323 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
store double %322, double* %323
%324 = load double*, double** %57
%325 = load i32, i32* %39
%326 = sext i32 %325 to i64
%327 = getelementptr inbounds double, double* %324, i64 %326
%328 = load double, double* %327
%329 = getelementptr inbounds [50 x double], [50 x double]* %48, i64 0, i64 1
store double %328, double* %329
%330 = load double*, double** %58
%331 = load i32, i32* %39
%332 = sext i32 %331 to i64
%333 = getelementptr inbounds double, double* %330, i64 %332
%334 = load double, double* %333
%335 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 1
store double %334, double* %335
%336 = load double*, double** %59
%337 = load i32, i32* %39
%338 = sext i32 %337 to i64
%339 = getelementptr inbounds double, double* %336, i64 %338
%340 = load double, double* %339
%341 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 1
store double %340, double* %341
%342 = load double*, double** %57
%343 = load i32, i32* %40
%344 = sext i32 %343 to i64
%345 = getelementptr inbounds double, double* %342, i64 %344
%346 = load double, double* %345
%347 = getelementptr inbounds [50 x double], [50 x double]* %48, i64 0, i64 2
store double %346, double* %347
%348 = load double*, double** %58
%349 = load i32, i32* %40
%350 = sext i32 %349 to i64
%351 = getelementptr inbounds double, double* %348, i64 %350
%352 = load double, double* %351
%353 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 2
store double %352, double* %353
%354 = load double*, double** %59
%355 = load i32, i32* %40
%356 = sext i32 %355 to i64
%357 = getelementptr inbounds double, double* %354, i64 %356
%358 = load double, double* %357
%359 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 2
store double %358, double* %359
%360 = load double*, double** %57
%361 = load i32, i32* %41
%362 = sext i32 %361 to i64
%363 = getelementptr inbounds double, double* %360, i64 %362
%364 = load double, double* %363
%365 = getelementptr inbounds [50 x double], [50 x double]* %48, i64 0, i64 3
store double %364, double* %365
%366 = load double*, double** %58
%367 = load i32, i32* %41
%368 = sext i32 %367 to i64
%369 = getelementptr inbounds double, double* %366, i64 %368
%370 = load double, double* %369
%371 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 3
store double %370, double* %371
%372 = load double*, double** %59
%373 = load i32, i32* %41
%374 = sext i32 %373 to i64
%375 = getelementptr inbounds double, double* %372, i64 %374
%376 = load double, double* %375
%377 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 3
store double %376, double* %377
%378 = getelementptr inbounds [50 x double], [50 x double]* %45, i64 0, i64 0
%379 = getelementptr inbounds [50 x double], [50 x double]* %46, i64 0, i64 0
%380 = getelementptr inbounds [50 x double], [50 x double]* %47, i64 0, i64 0
%381 = load i32, i32* %35
%382 = getelementptr inbounds [50 x double], [50 x double]* %48, i64 0, i64 0
%383 = getelementptr inbounds [50 x double], [50 x double]* %49, i64 0, i64 0
%384 = getelementptr inbounds [50 x double], [50 x double]* %50, i64 0, i64 0
%385 = load i32, i32* %36
%386 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%387 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%388 = getelementptr inbounds [50 x double], [50 x double]* %53, i64 0, i64 0
%389 = call i32 @clip_2dx2d_great_circle(double* %378, double* %379, double* %380, i32 %381, double* %382, double* %383, double* %384, i32 %385, double* %386, double* %387, double* %388)
store i32 %389, i32* %66
%390 = icmp sgt i32 %389, 0
br i1 %390, label %391, label %482
391: ; preds = %290
%392 = load i32, i32* %66
%393 = getelementptr inbounds [50 x double], [50 x double]* %51, i64 0, i64 0
%394 = getelementptr inbounds [50 x double], [50 x double]* %52, i64 0, i64 0
%395 = getelementptr inbounds [50 x double], [50 x double]* %53, i64 0, i64 0
%396 = call double @great_circle_area(i32 %392, double* %393, double* %394, double* %395)
%397 = load double*, double** %22
%398 = load i32, i32* %43
%399 = load i32, i32* %29
%400 = mul nsw i32 %398, %399
%401 = load i32, i32* %42
%402 = add nsw i32 %400, %401
%403 = sext i32 %402 to i64
%404 = getelementptr inbounds double, double* %397, i64 %403
%405 = load double, double* %404
%406 = fmul double %396, %405
store double %406, double* %67
%407 = load double*, double** %62
%408 = load i32, i32* %43
%409 = load i32, i32* %29
%410 = mul nsw i32 %408, %409
%411 = load i32, i32* %42
%412 = add nsw i32 %410, %411
%413 = sext i32 %412 to i64
%414 = getelementptr inbounds double, double* %407, i64 %413
%415 = load double, double* %414
%416 = load double*, double** %63
%417 = load i32, i32* %44
%418 = sext i32 %417 to i64
%419 = getelementptr inbounds double, double* %416, i64 %418
%420 = load double, double* %419
%421 = fcmp olt double %415, %420
br i1 %421, label %422, label %432
422: ; preds = %391
%423 = load double*, double** %62
%424 = load i32, i32* %43
%425 = load i32, i32* %29
%426 = mul nsw i32 %424, %425
%427 = load i32, i32* %42
%428 = add nsw i32 %426, %427
%429 = sext i32 %428 to i64
%430 = getelementptr inbounds double, double* %423, i64 %429
%431 = load double, double* %430
br label %438
432: ; preds = %391
%433 = load double*, double** %63
%434 = load i32, i32* %44
%435 = sext i32 %434 to i64
%436 = getelementptr inbounds double, double* %433, i64 %435
%437 = load double, double* %436
br label %438
438: ; preds = %432, %422
%439 = phi double [ %431, %422 ], [ %437, %432 ]
store double %439, double* %64
%440 = load double, double* %67
%441 = load double, double* %64
%442 = fdiv double %440, %441
%443 = fcmp ogt double %442, 0x3EB0C6F7A0B5ED8D
br i1 %443, label %444, label %481
444: ; preds = %438
%445 = load double, double* %67
%446 = load double*, double** %26
%447 = load i32, i32* %34
%448 = sext i32 %447 to i64
%449 = getelementptr inbounds double, double* %446, i64 %448
store double %445, double* %449
%450 = load double*, double** %27
%451 = load i32, i32* %34
%452 = sext i32 %451 to i64
%453 = getelementptr inbounds double, double* %450, i64 %452
store double 0.000000e+00, double* %453
%454 = load double*, double** %28
%455 = load i32, i32* %34
%456 = sext i32 %455 to i64
%457 = getelementptr inbounds double, double* %454, i64 %456
store double 0.000000e+00, double* %457
%458 = load i32, i32* %42
%459 = load i32*, i32** %23
%460 = load i32, i32* %34
%461 = sext i32 %460 to i64
%462 = getelementptr inbounds i32, i32* %459, i64 %461
store i32 %458, i32* %462
%463 = load i32, i32* %43
%464 = load i32*, i32** %24
%465 = load i32, i32* %34
%466 = sext i32 %465 to i64
%467 = getelementptr inbounds i32, i32* %464, i64 %466
store i32 %463, i32* %467
%468 = load i32, i32* %44
%469 = load i32*, i32** %25
%470 = load i32, i32* %34
%471 = sext i32 %470 to i64
%472 = getelementptr inbounds i32, i32* %469, i64 %471
store i32 %468, i32* %472
%473 = load i32, i32* %34
%474 = add nsw i32 %473, 1
store i32 %474, i32* %34
%475 = load i32, i32* %34
%476 = sitofp i32 %475 to double
%477 = fcmp ogt double %476, 1.000000e+06
br i1 %477, label %478, label %480
478: ; preds = %444
%479 = call i32 @error_handler(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %480
480: ; preds = %478, %444
br label %481
481: ; preds = %480, %438
br label %482
482: ; preds = %481, %290
br label %483
483: ; preds = %482
%484 = load i32, i32* %44
%485 = add nsw i32 %484, 1
store i32 %485, i32* %44
br label %286
486: ; preds = %286
br label %487
487: ; preds = %486, %178
br label %488
488: ; preds = %487
%489 = load i32, i32* %42
%490 = add nsw i32 %489, 1
store i32 %490, i32* %42
br label %174
491: ; preds = %174
br label %492
492: ; preds = %491
%493 = load i32, i32* %43
%494 = add nsw i32 %493, 1
store i32 %494, i32* %43
br label %169
495: ; preds = %169
%496 = load double*, double** %62
%497 = call i32 @free(double* %496)
%498 = load double*, double** %63
%499 = call i32 @free(double* %498)
%500 = load double*, double** %54
%501 = call i32 @free(double* %500)
%502 = load double*, double** %55
%503 = call i32 @free(double* %502)
%504 = load double*, double** %56
%505 = call i32 @free(double* %504)
%506 = load double*, double** %57
%507 = call i32 @free(double* %506)
%508 = load double*, double** %58
%509 = call i32 @free(double* %508)
%510 = load double*, double** %59
%511 = call i32 @free(double* %510)
%512 = load i32, i32* %34
ret i32 %512
}

LLVM IR (-O2):
@.str = [51 x i8] c"nxgrid is greater than MAXXGRID, increase MAXXGRID\00"
define i32 @create_xgrid_great_circle_ug(i32* %0, i32* %1, i32* %2, double* %3, double* %4, double* %5, double* %6, double* nocapture %7, i32* nocapture writeonly %8, i32* nocapture writeonly %9, i32* nocapture writeonly %10, double* nocapture writeonly %11, double* nocapture writeonly %12, double* nocapture writeonly %13) {
%15 = alloca [50 x double]
%16 = alloca [50 x double]
%17 = alloca [50 x double]
%18 = alloca [50 x double]
%19 = alloca [50 x double]
%20 = alloca [50 x double]
%21 = alloca [50 x double]
%22 = alloca [50 x double]
%23 = alloca [50 x double]
%24 = bitcast [50 x double]* %15 to i8*
%25 = bitcast [50 x double]* %16 to i8*
%26 = bitcast [50 x double]* %17 to i8*
%27 = bitcast [50 x double]* %18 to i8*
%28 = bitcast [50 x double]* %19 to i8*
%29 = bitcast [50 x double]* %20 to i8*
%30 = bitcast [50 x double]* %21 to i8*
%31 = bitcast [50 x double]* %22 to i8*
%32 = bitcast [50 x double]* %23 to i8*
%33 = load i32, i32* %0
%34 = load i32, i32* %1
%35 = load i32, i32* %2
%36 = add nsw i32 %33, 1
%37 = add nsw i32 %34, 1
%38 = mul nsw i32 %37, %36
%39 = shl i32 %38, 3
%40 = tail call i64 @malloc(i32 %39)
%41 = inttoptr i64 %40 to double*
%42 = tail call i64 @malloc(i32 %39)
%43 = inttoptr i64 %42 to double*
%44 = tail call i64 @malloc(i32 %39)
%45 = inttoptr i64 %44 to double*
%46 = shl nsw i32 %35, 2
%47 = shl i32 %35, 5
%48 = tail call i64 @malloc(i32 %47)
%49 = inttoptr i64 %48 to double*
%50 = tail call i64 @malloc(i32 %47)
%51 = inttoptr i64 %50 to double*
%52 = tail call i64 @malloc(i32 %47)
%53 = inttoptr i64 %52 to double*
%54 = tail call i32 @latlon2xyz(i32 %38, double* %3, double* %4, double* %41, double* %43, double* %45)
%55 = tail call i32 @latlon2xyz(i32 %46, double* %5, double* %6, double* %49, double* %51, double* %53)
%56 = shl i32 %33, 3
%57 = mul i32 %56, %34
%58 = tail call i64 @malloc(i32 %57)
%59 = inttoptr i64 %58 to double*
%60 = shl i32 %35, 3
%61 = tail call i64 @malloc(i32 %60)
%62 = inttoptr i64 %61 to double*
%63 = tail call i32 @get_grid_great_circle_area(i32* %0, i32* %1, double* %3, double* %4, double* %59)
%64 = tail call i32 @get_grid_great_circle_area_ug(i32* %2, double* %5, double* %6, double* %62)
%65 = icmp sgt i32 %34, 0
br i1 %65, label %66, label %220
66: ; preds = %14
%67 = icmp sgt i32 %33, 0
%68 = getelementptr inbounds [50 x double], [50 x double]* %15, i64 0, i64 0
%69 = getelementptr inbounds [50 x double], [50 x double]* %16, i64 0, i64 0
%70 = getelementptr inbounds [50 x double], [50 x double]* %17, i64 0, i64 0
%71 = getelementptr inbounds [50 x double], [50 x double]* %15, i64 0, i64 1
%72 = getelementptr inbounds [50 x double], [50 x double]* %16, i64 0, i64 1
%73 = getelementptr inbounds [50 x double], [50 x double]* %17, i64 0, i64 1
%74 = getelementptr inbounds [50 x double], [50 x double]* %15, i64 0, i64 2
%75 = getelementptr inbounds [50 x double], [50 x double]* %16, i64 0, i64 2
%76 = getelementptr inbounds [50 x double], [50 x double]* %17, i64 0, i64 2
%77 = getelementptr inbounds [50 x double], [50 x double]* %15, i64 0, i64 3
%78 = getelementptr inbounds [50 x double], [50 x double]* %16, i64 0, i64 3
%79 = getelementptr inbounds [50 x double], [50 x double]* %17, i64 0, i64 3
%80 = icmp sgt i32 %35, 0
%81 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 0
%82 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 0
%83 = getelementptr inbounds [50 x double], [50 x double]* %20, i64 0, i64 0
%84 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 1
%85 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 1
%86 = getelementptr inbounds [50 x double], [50 x double]* %20, i64 0, i64 1
%87 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 2
%88 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 2
%89 = getelementptr inbounds [50 x double], [50 x double]* %20, i64 0, i64 2
%90 = getelementptr inbounds [50 x double], [50 x double]* %18, i64 0, i64 3
%91 = getelementptr inbounds [50 x double], [50 x double]* %19, i64 0, i64 3
%92 = getelementptr inbounds [50 x double], [50 x double]* %20, i64 0, i64 3
%93 = getelementptr inbounds [50 x double], [50 x double]* %21, i64 0, i64 0
%94 = getelementptr inbounds [50 x double], [50 x double]* %22, i64 0, i64 0
%95 = getelementptr inbounds [50 x double], [50 x double]* %23, i64 0, i64 0
%96 = sext i32 %33 to i64
%97 = sext i32 %36 to i64
%98 = zext i32 %34 to i64
%99 = zext i32 %33 to i64
%100 = zext i32 %35 to i64
br label %101
101: ; preds = %66, %216
%102 = phi i64 [ 0, %66 ], [ %217, %216 ]
%103 = phi i32 [ 0, %66 ], [ %218, %216 ]
br i1 %67, label %106, label %104
104: ; preds = %101
%105 = add nuw nsw i64 %102, 1
br label %216
106: ; preds = %101
%107 = mul nsw i64 %102, %96
%108 = mul nsw i64 %102, %97
%109 = add nuw nsw i64 %102, 1
%110 = mul nsw i64 %109, %97
%111 = trunc i64 %102 to i32
br label %112
112: ; preds = %106, %212
%113 = phi i64 [ 0, %106 ], [ %214, %212 ]
%114 = phi i32 [ %103, %106 ], [ %213, %212 ]
%115 = add nsw i64 %113, %107
%116 = getelementptr inbounds double, double* %7, i64 %115
%117 = load double, double* %116
%118 = fcmp ogt double %117, 5.000000e-01
br i1 %118, label %119, label %212
119: ; preds = %112
%120 = add nsw i64 %113, %108
%121 = add nsw i64 %113, %110
%122 = add nsw i64 %121, 1
%123 = add nsw i64 %120, 1
%124 = getelementptr inbounds double, double* %41, i64 %120
%125 = load double, double* %124
store double %125, double* %68
%126 = getelementptr inbounds double, double* %43, i64 %120
%127 = load double, double* %126
store double %127, double* %69
%128 = getelementptr inbounds double, double* %45, i64 %120
%129 = load double, double* %128
store double %129, double* %70
%130 = getelementptr inbounds double, double* %41, i64 %121
%131 = load double, double* %130
store double %131, double* %71
%132 = getelementptr inbounds double, double* %43, i64 %121
%133 = load double, double* %132
store double %133, double* %72
%134 = getelementptr inbounds double, double* %45, i64 %121
%135 = load double, double* %134
store double %135, double* %73
%136 = getelementptr inbounds double, double* %41, i64 %122
%137 = load double, double* %136
store double %137, double* %74
%138 = getelementptr inbounds double, double* %43, i64 %122
%139 = load double, double* %138
store double %139, double* %75
%140 = getelementptr inbounds double, double* %45, i64 %122
%141 = load double, double* %140
store double %141, double* %76
%142 = getelementptr inbounds double, double* %41, i64 %123
%143 = load double, double* %142
store double %143, double* %77
%144 = getelementptr inbounds double, double* %43, i64 %123
%145 = load double, double* %144
store double %145, double* %78
%146 = getelementptr inbounds double, double* %45, i64 %123
%147 = load double, double* %146
store double %147, double* %79
br i1 %80, label %148, label %212
148: ; preds = %119
%149 = getelementptr inbounds double, double* %59, i64 %115
%150 = trunc i64 %113 to i32
br label %151
151: ; preds = %148, %208
%152 = phi i64 [ 0, %148 ], [ %210, %208 ]
%153 = phi i32 [ %114, %148 ], [ %209, %208 ]
%154 = shl nsw i64 %152, 2
%155 = or i64 %154, 1
%156 = or i64 %154, 2
%157 = or i64 %154, 3
%158 = getelementptr inbounds double, double* %49, i64 %154
%159 = load double, double* %158
store double %159, double* %81
%160 = getelementptr inbounds double, double* %51, i64 %154
%161 = load double, double* %160
store double %161, double* %82
%162 = getelementptr inbounds double, double* %53, i64 %154
%163 = load double, double* %162
store double %163, double* %83
%164 = getelementptr inbounds double, double* %49, i64 %155
%165 = load double, double* %164
store double %165, double* %84
%166 = getelementptr inbounds double, double* %51, i64 %155
%167 = load double, double* %166
store double %167, double* %85
%168 = getelementptr inbounds double, double* %53, i64 %155
%169 = load double, double* %168
store double %169, double* %86
%170 = getelementptr inbounds double, double* %49, i64 %156
%171 = load double, double* %170
store double %171, double* %87
%172 = getelementptr inbounds double, double* %51, i64 %156
%173 = load double, double* %172
store double %173, double* %88
%174 = getelementptr inbounds double, double* %53, i64 %156
%175 = load double, double* %174
store double %175, double* %89
%176 = getelementptr inbounds double, double* %49, i64 %157
%177 = load double, double* %176
store double %177, double* %90
%178 = getelementptr inbounds double, double* %51, i64 %157
%179 = load double, double* %178
store double %179, double* %91
%180 = getelementptr inbounds double, double* %53, i64 %157
%181 = load double, double* %180
store double %181, double* %92
%182 = call i32 @clip_2dx2d_great_circle(double* %68, double* %69, double* %70, i32 4, double* %81, double* %82, double* %83, i32 4, double* %93, double* %94, double* %95)
%183 = icmp sgt i32 %182, 0
br i1 %183, label %184, label %208
184: ; preds = %151
%185 = call double @great_circle_area(i32 %182, double* %93, double* %94, double* %95)
%186 = load double, double* %116
%187 = fmul double %185, %186
%188 = load double, double* %149
%189 = getelementptr inbounds double, double* %62, i64 %152
%190 = load double, double* %189
%191 = fcmp olt double %188, %190
%192 = select i1 %191, double %188, double %190
%193 = fdiv double %187, %192
%194 = fcmp ogt double %193, 0x3EB0C6F7A0B5ED8D
br i1 %194, label %195, label %208
195: ; preds = %184
%196 = sext i32 %153 to i64
%197 = getelementptr inbounds double, double* %11, i64 %196
store double %187, double* %197
%198 = getelementptr inbounds double, double* %12, i64 %196
store double 0.000000e+00, double* %198
%199 = getelementptr inbounds double, double* %13, i64 %196
store double 0.000000e+00, double* %199
%200 = getelementptr inbounds i32, i32* %8, i64 %196
store i32 %150, i32* %200
%201 = getelementptr inbounds i32, i32* %9, i64 %196
store i32 %111, i32* %201
%202 = getelementptr inbounds i32, i32* %10, i64 %196
%203 = trunc i64 %152 to i32
store i32 %203, i32* %202
%204 = add nsw i32 %153, 1
%205 = icmp sgt i32 %153, 999999
br i1 %205, label %206, label %208
206: ; preds = %195
%207 = call i32 @error_handler(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %208
208: ; preds = %184, %206, %195, %151
%209 = phi i32 [ %204, %206 ], [ %204, %195 ], [ %153, %184 ], [ %153, %151 ]
%210 = add nuw nsw i64 %152, 1
%211 = icmp eq i64 %210, %100
br i1 %211, label %212, label %151
212: ; preds = %208, %119, %112
%213 = phi i32 [ %114, %112 ], [ %114, %119 ], [ %209, %208 ]
%214 = add nuw nsw i64 %113, 1
%215 = icmp eq i64 %214, %99
br i1 %215, label %216, label %112
216: ; preds = %212, %104
%217 = phi i64 [ %105, %104 ], [ %109, %212 ]
%218 = phi i32 [ %103, %104 ], [ %213, %212 ]
%219 = icmp eq i64 %217, %98
br i1 %219, label %220, label %101
220: ; preds = %216, %14
%221 = phi i32 [ 0, %14 ], [ %218, %216 ]
%222 = call i32 @free(double* %59)
%223 = call i32 @free(double* %62)
%224 = call i32 @free(double* %41)
%225 = call i32 @free(double* %43)
%226 = call i32 @free(double* %45)
%227 = call i32 @free(double* %49)
%228 = call i32 @free(double* %51)
%229 = call i32 @free(double* %53)
ret i32 %221
}