void conserve_interp_great_circle(int nx_src, int ny_src, int nx_dst,
                                  int ny_dst, const double *x_src,
                                  const double *y_src, const double *x_dst,
                                  const double *y_dst, const double *mask_src,
                                  const double *data_src, double *data_dst) {
  int n, nxgrid;
  int *xgrid_i1, *xgrid_j1, *xgrid_i2, *xgrid_j2;
  double *xgrid_area, *dst_area, *area_frac, *xgrid_di, *xgrid_dj;
  xgrid_i1 = (int *)malloc(1e6 * sizeof(int));
  xgrid_j1 = (int *)malloc(1e6 * sizeof(int));
  xgrid_i2 = (int *)malloc(1e6 * sizeof(int));
  xgrid_j2 = (int *)malloc(1e6 * sizeof(int));
  xgrid_area = (double *)malloc(1e6 * sizeof(double));
  xgrid_di = (double *)malloc(1e6 * sizeof(double));
  xgrid_dj = (double *)malloc(1e6 * sizeof(double));
  dst_area = (double *)malloc(nx_dst * ny_dst * sizeof(double));
  nxgrid = create_xgrid_great_circle(
      &nx_src, &ny_src, &nx_dst, &ny_dst, x_src, y_src, x_dst, y_dst, mask_src,
      xgrid_i1, xgrid_j1, xgrid_i2, xgrid_j2, xgrid_area, xgrid_di, xgrid_dj);
  for (n = 0; n < nx_dst * ny_dst; n++)
    dst_area[n] = 0;
  for (n = 0; n < nxgrid; n++)
    dst_area[xgrid_j2[n] * nx_dst + xgrid_i2[n]] += xgrid_area[n];
  area_frac = (double *)malloc(nxgrid * sizeof(double));
  for (n = 0; n < nxgrid; n++)
    area_frac[n] = xgrid_area[n] / dst_area[xgrid_j2[n] * nx_dst + xgrid_i2[n]];
  for (n = 0; n < nx_dst * ny_dst; n++) {
    data_dst[n] = 0;
  }
  for (n = 0; n < nxgrid; n++) {
    data_dst[xgrid_j2[n] * nx_dst + xgrid_i2[n]] +=
        data_src[xgrid_j1[n] * nx_src + xgrid_i1[n]] * area_frac[n];
  }
  free(xgrid_i1);
  free(xgrid_j1);
  free(xgrid_i2);
  free(xgrid_j2);
  free(xgrid_area);
  free(dst_area);
  free(area_frac);
}


x86 assembly (clang, -O0):
<conserve_interp_great_circle>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x2c(%rbp)
mov    %esi,-0x30(%rbp)
mov    %edx,-0x34(%rbp)
mov    %ecx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9,-0x48(%rbp)
mov    $0x3d0900,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0x3d0900,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    $0x3d0900,%edi
call   1050 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    $0x3d0900,%edi
call   1050 <malloc@plt>
mov    %rax,-0x70(%rbp)
mov    $0x7a1200,%edi
call   1050 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    $0x7a1200,%edi
call   1050 <malloc@plt>
mov    %rax,-0x90(%rbp)
mov    $0x7a1200,%edi
call   1050 <malloc@plt>
mov    %rax,-0x98(%rbp)
mov    -0x34(%rbp),%eax
imul   -0x38(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    0x10(%rbp),%rax
mov    0x18(%rbp),%rcx
mov    %rcx,-0xa8(%rbp)
mov    0x20(%rbp),%r13
mov    -0x58(%rbp),%r12
mov    -0x60(%rbp),%r15
mov    -0x68(%rbp),%r14
mov    -0x70(%rbp),%rbx
mov    -0x78(%rbp),%r11
mov    -0x90(%rbp),%r10
mov    -0x98(%rbp),%rcx
mov    %rcx,-0xa0(%rbp)
lea    -0x2c(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
mov    %rax,(%rsp)
mov    -0xa8(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    -0xa0(%rbp),%rax
mov    %r13,0x10(%rsp)
mov    %r12,0x18(%rsp)
mov    %r15,0x20(%rsp)
mov    %r14,0x28(%rsp)
mov    %rbx,0x30(%rsp)
mov    %r11,0x38(%rsp)
mov    %r10,0x40(%rsp)
mov    %rax,0x48(%rsp)
mov    $0x0,%al
call   1040 <create_xgrid_great_circle@plt>
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x34(%rbp),%ecx
imul   -0x38(%rbp),%ecx
cmp    %ecx,%eax
jge    12bf <conserve_interp_great_circle+0x18f>
mov    -0x80(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    128f <conserve_interp_great_circle+0x15f>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    1318 <conserve_interp_great_circle+0x1e8>
mov    -0x78(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x80(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x4c(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
imul   -0x34(%rbp),%ecx
mov    -0x68(%rbp),%rdx
movslq -0x4c(%rbp),%rsi
add    (%rdx,%rsi,4),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12c6 <conserve_interp_great_circle+0x196>
movslq -0x50(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    1390 <conserve_interp_great_circle+0x260>
mov    -0x78(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x80(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x4c(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
imul   -0x34(%rbp),%ecx
mov    -0x68(%rbp),%rdx
movslq -0x4c(%rbp),%rsi
add    (%rdx,%rsi,4),%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x88(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1333 <conserve_interp_great_circle+0x203>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x34(%rbp),%ecx
imul   -0x38(%rbp),%ecx
cmp    %ecx,%eax
jge    13c7 <conserve_interp_great_circle+0x297>
mov    0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1397 <conserve_interp_great_circle+0x267>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    1451 <conserve_interp_great_circle+0x321>
mov    0x28(%rbp),%rax
mov    -0x60(%rbp),%rcx
movslq -0x4c(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
imul   -0x2c(%rbp),%ecx
mov    -0x58(%rbp),%rdx
movslq -0x4c(%rbp),%rsi
add    (%rdx,%rsi,4),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x88(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    0x30(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x4c(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
imul   -0x34(%rbp),%ecx
mov    -0x68(%rbp),%rdx
movslq -0x4c(%rbp),%rsi
add    (%rdx,%rsi,4),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13ce <conserve_interp_great_circle+0x29e>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<conserve_interp_great_circle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %r9,0x90(%rsp)
mov    %r8,0x68(%rsp)
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %edi,0x8c(%rsp)
mov    %esi,0x9c(%rsp)
mov    %edx,0x88(%rsp)
mov    %ecx,0x84(%rsp)
mov    $0x3d0900,%edi
call   1060 <malloc@plt>
mov    %rax,0x78(%rsp)
mov    $0x3d0900,%edi
call   1060 <malloc@plt>
mov    %rax,0x70(%rsp)
mov    $0x3d0900,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x3d0900,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    $0x7a1200,%edi
call   1060 <malloc@plt>
mov    %rax,0xa8(%rsp)
mov    $0x7a1200,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x7a1200,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
imul   %r12d,%ebp
movslq %ebp,%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %r15,0x48(%rsp)
mov    0xa8(%rsp),%r15
mov    %r14,0x40(%rsp)
mov    %r15,0x38(%rsp)
mov    %r13,0x58(%rsp)
mov    %r13,0x30(%rsp)
mov    %rbx,0x60(%rsp)
mov    %rbx,0x28(%rsp)
mov    0x70(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0x78(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x100(%rsp),%rax
mov    %rax,0x10(%rsp)
movapd 0xf0(%rsp),%xmm0
movupd %xmm0,(%rsp)
lea    0x8c(%rsp),%rdi
lea    0x9c(%rsp),%rsi
lea    0x88(%rsp),%rdx
lea    0x84(%rsp),%rcx
mov    0x68(%rsp),%r8
mov    0x90(%rsp),%r9
xor    %eax,%eax
call   1050 <create_xgrid_great_circle@plt>
mov    %eax,%ebx
movslq 0x88(%rsp),%r13
mov    0x84(%rsp),%eax
imul   %r13d,%eax
mov    %eax,%ebp
mov    %eax,0x68(%rsp)
test   %eax,%eax
jle    12b5 <conserve_interp_great_circle+0x175>
lea    0x0(,%rbp,8),%rdx
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %ebx,%r8d
test   %ebx,%ebx
mov    %ebx,0x90(%rsp)
mov    %rbp,0xb0(%rsp)
jle    12e1 <conserve_interp_great_circle+0x1a1>
cmp    $0x1,%ebx
jne    130f <conserve_interp_great_circle+0x1cf>
xor    %eax,%eax
mov    0x60(%rsp),%rdi
mov    0x58(%rsp),%rbp
jmp    137f <conserve_interp_great_circle+0x23f>
movslq %ebx,%rdi
shl    $0x3,%rdi
mov    %r8,%rbx
call   1060 <malloc@plt>
mov    %rbx,%r10
mov    %rax,%r14
mov    0x78(%rsp),%rdi
mov    0x70(%rsp),%r9
mov    0x60(%rsp),%rbx
mov    0x58(%rsp),%rbp
jmp    1439 <conserve_interp_great_circle+0x2f9>
mov    %r8d,%ecx
and    $0xfffffffe,%ecx
xor    %eax,%eax
mov    0x60(%rsp),%rdi
mov    0x58(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r15,%rax,8),%xmm0
movslq 0x0(%rbp,%rax,4),%rdx
imul   %r13,%rdx
movslq (%rdi,%rax,4),%rsi
add    %rdx,%rsi
addsd  (%r12,%rsi,8),%xmm0
movsd  %xmm0,(%r12,%rsi,8)
movsd  0x8(%r15,%rax,8),%xmm0
movslq 0x4(%rbp,%rax,4),%rdx
imul   %r13,%rdx
movslq 0x4(%rdi,%rax,4),%rsi
add    %rdx,%rsi
addsd  (%r12,%rsi,8),%xmm0
movsd  %xmm0,(%r12,%rsi,8)
add    $0x2,%rax
cmp    %rax,%rcx
jne    1330 <conserve_interp_great_circle+0x1f0>
mov    %r8,0xa0(%rsp)
test   $0x1,%r8b
je     13af <conserve_interp_great_circle+0x26f>
movsd  (%r15,%rax,8),%xmm0
movslq 0x0(%rbp,%rax,4),%rcx
imul   %r13,%rcx
movslq (%rdi,%rax,4),%rax
add    %rcx,%rax
addsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,(%r12,%rax,8)
movslq %ebx,%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    141d <conserve_interp_great_circle+0x2dd>
xor    %eax,%eax
mov    0x78(%rsp),%rdi
mov    0x70(%rsp),%r9
mov    0x60(%rsp),%rbx
mov    0x58(%rsp),%rbp
mov    0xa0(%rsp),%r10
mov    0x68(%rsp),%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r15,%rax,8),%xmm0
movslq 0x0(%rbp,%rax,4),%rcx
imul   %r13,%rcx
movslq (%rbx,%rax,4),%rdx
add    %rcx,%rdx
divsd  (%r12,%rdx,8),%xmm0
movsd  %xmm0,(%r14,%rax,8)
add    $0x1,%rax
cmp    %rax,%r10
jne    13f0 <conserve_interp_great_circle+0x2b0>
jmp    143d <conserve_interp_great_circle+0x2fd>
mov    0x78(%rsp),%rdi
mov    0x70(%rsp),%r9
mov    0x60(%rsp),%rbx
mov    0x58(%rsp),%rbp
mov    0xa0(%rsp),%r10
mov    0x68(%rsp),%esi
mov    0x110(%rsp),%r15
test   %esi,%esi
jle    1479 <conserve_interp_great_circle+0x339>
mov    0xb0(%rsp),%rdx
shl    $0x3,%rdx
mov    %r15,%rdi
xor    %esi,%esi
mov    %r10,%rbx
call   1040 <memset@plt>
mov    %rbx,%r10
mov    0x58(%rsp),%rbp
mov    0x60(%rsp),%rbx
mov    0x70(%rsp),%r9
mov    0x78(%rsp),%rdi
cmpl   $0x0,0x90(%rsp)
jle    14e0 <conserve_interp_great_circle+0x3a0>
mov    0x108(%rsp),%r8
movslq 0x8c(%rsp),%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
movslq (%r9,%rdx,4),%rsi
imul   %rcx,%rsi
movslq (%rdi,%rdx,4),%rax
add    %rsi,%rax
movsd  (%r8,%rax,8),%xmm0
movslq 0x0(%rbp,%rdx,4),%rsi
imul   %r13,%rsi
movslq (%rbx,%rdx,4),%rax
add    %rsi,%rax
mulsd  (%r14,%rdx,8),%xmm0
addsd  (%r15,%rax,8),%xmm0
movsd  %xmm0,(%r15,%rax,8)
add    $0x1,%rdx
cmp    %rdx,%r10
jne    14a0 <conserve_interp_great_circle+0x360>
mov    %r9,%r15
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0xa8(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @conserve_interp_great_circle(i32 %0, i32 %1, i32 %2, i32 %3, double* %4, double* %5, double* %6, double* %7, double* %8, double* nocapture %9, double* nocapture %10) {
%12 = bitcast double* %10 to i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %13
store i32 %1, i32* %14
store i32 %2, i32* %15
store i32 %3, i32* %16
%17 = tail call dereferenceable_or_null(4000000) i8* @malloc(i64 4000000)
%18 = bitcast i8* %17 to i32*
%19 = tail call dereferenceable_or_null(4000000) i8* @malloc(i64 4000000)
%20 = bitcast i8* %19 to i32*
%21 = tail call dereferenceable_or_null(4000000) i8* @malloc(i64 4000000)
%22 = bitcast i8* %21 to i32*
%23 = tail call dereferenceable_or_null(4000000) i8* @malloc(i64 4000000)
%24 = bitcast i8* %23 to i32*
%25 = tail call dereferenceable_or_null(8000000) i8* @malloc(i64 8000000)
%26 = bitcast i8* %25 to double*
%27 = tail call dereferenceable_or_null(8000000) i8* @malloc(i64 8000000)
%28 = bitcast i8* %27 to double*
%29 = tail call dereferenceable_or_null(8000000) i8* @malloc(i64 8000000)
%30 = bitcast i8* %29 to double*
%31 = mul nsw i32 %3, %2
%32 = sext i32 %31 to i64
%33 = shl nsw i64 %32, 3
%34 = tail call i8* @malloc(i64 %33)
%35 = bitcast i8* %34 to double*
%36 = call i32 (i32*, i32*, i32*, i32*, double*, double*, double*, double*, double*, i32*, i32*, i32*, i32*, double*, double*, double*, ...) bitcast (i32 (...)* @create_xgrid_great_circle to i32 (i32*, i32*, i32*, i32*, double*, double*, double*, double*, double*, i32*, i32*, i32*, i32*, double*, double*, double*, ...)*)(i32* %13, i32* %14, i32* %15, i32* %16, double* %4, double* %5, double* %6, double* %7, double* %8, i32* %18, i32* %20, i32* %22, i32* %24, double* %26, double* %28, double* %30)
%37 = load i32, i32* %15
%38 = load i32, i32* %16
%39 = mul i32 %38, %37
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %11
%42 = zext i32 %39 to i64
%43 = shl nuw nsw i64 %42, 3
br label %44
44: ; preds = %41, %11
%45 = icmp sgt i32 %36, 0
br i1 %45, label %51, label %46
46: ; preds = %44
%47 = sext i32 %36 to i64
%48 = shl nsw i64 %47, 3
%49 = call i8* @malloc(i64 %48)
%50 = bitcast i8* %49 to double*
br label %111
51: ; preds = %44
%52 = zext i32 %36 to i64
%53 = and i64 %52, 1
%54 = icmp eq i32 %36, 1
br i1 %54, label %88, label %55
55: ; preds = %51
%56 = and i64 %52, 4294967294
br label %57
57: ; preds = %57, %55
%58 = phi i64 [ 0, %55 ], [ %85, %57 ]
%59 = phi i64 [ 0, %55 ], [ %86, %57 ]
%60 = getelementptr inbounds double, double* %26, i64 %58
%61 = load double, double* %60
%62 = getelementptr inbounds i32, i32* %24, i64 %58
%63 = load i32, i32* %62
%64 = mul nsw i32 %63, %37
%65 = getelementptr inbounds i32, i32* %22, i64 %58
%66 = load i32, i32* %65
%67 = add nsw i32 %64, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %35, i64 %68
%70 = load double, double* %69
%71 = fadd double %61, %70
store double %71, double* %69
%72 = or i64 %58, 1
%73 = getelementptr inbounds double, double* %26, i64 %72
%74 = load double, double* %73
%75 = getelementptr inbounds i32, i32* %24, i64 %72
%76 = load i32, i32* %75
%77 = mul nsw i32 %76, %37
%78 = getelementptr inbounds i32, i32* %22, i64 %72
%79 = load i32, i32* %78
%80 = add nsw i32 %77, %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %35, i64 %81
%83 = load double, double* %82
%84 = fadd double %74, %83
store double %84, double* %82
%85 = add nuw nsw i64 %58, 2
%86 = add i64 %59, 2
%87 = icmp eq i64 %86, %56
br i1 %87, label %88, label %57
88: ; preds = %57, %51
%89 = phi i64 [ 0, %51 ], [ %85, %57 ]
%90 = icmp eq i64 %53, 0
br i1 %90, label %104, label %91
91: ; preds = %88
%92 = getelementptr inbounds double, double* %26, i64 %89
%93 = load double, double* %92
%94 = getelementptr inbounds i32, i32* %24, i64 %89
%95 = load i32, i32* %94
%96 = mul nsw i32 %95, %37
%97 = getelementptr inbounds i32, i32* %22, i64 %89
%98 = load i32, i32* %97
%99 = add nsw i32 %96, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %35, i64 %100
%102 = load double, double* %101
%103 = fadd double %93, %102
store double %103, double* %101
br label %104
104: ; preds = %88, %91
%105 = sext i32 %36 to i64
%106 = shl nsw i64 %105, 3
%107 = call i8* @malloc(i64 %106)
%108 = bitcast i8* %107 to double*
br i1 %45, label %109, label %111
109: ; preds = %104
%110 = zext i32 %36 to i64
br label %117
111: ; preds = %117, %46, %104
%112 = phi double* [ %50, %46 ], [ %108, %104 ], [ %108, %117 ]
%113 = phi i8* [ %49, %46 ], [ %107, %104 ], [ %107, %117 ]
br i1 %40, label %114, label %134
114: ; preds = %111
%115 = zext i32 %39 to i64
%116 = shl nuw nsw i64 %115, 3
br label %134
117: ; preds = %109, %117
%118 = phi i64 [ 0, %109 ], [ %132, %117 ]
%119 = getelementptr inbounds double, double* %26, i64 %118
%120 = load double, double* %119
%121 = getelementptr inbounds i32, i32* %24, i64 %118
%122 = load i32, i32* %121
%123 = mul nsw i32 %122, %37
%124 = getelementptr inbounds i32, i32* %22, i64 %118
%125 = load i32, i32* %124
%126 = add nsw i32 %123, %125
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %35, i64 %127
%129 = load double, double* %128
%130 = fdiv double %120, %129
%131 = getelementptr inbounds double, double* %108, i64 %118
store double %130, double* %131
%132 = add nuw nsw i64 %118, 1
%133 = icmp eq i64 %132, %110
br i1 %133, label %111, label %117
134: ; preds = %114, %111
br i1 %45, label %135, label %163
135: ; preds = %134
%136 = load i32, i32* %13
%137 = zext i32 %36 to i64
br label %138
138: ; preds = %135, %138
%139 = phi i64 [ 0, %135 ], [ %161, %138 ]
%140 = getelementptr inbounds i32, i32* %20, i64 %139
%141 = load i32, i32* %140
%142 = mul nsw i32 %136, %141
%143 = getelementptr inbounds i32, i32* %18, i64 %139
%144 = load i32, i32* %143
%145 = add nsw i32 %142, %144
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds double, double* %9, i64 %146
%148 = load double, double* %147
%149 = getelementptr inbounds double, double* %112, i64 %139
%150 = load double, double* %149
%151 = getelementptr inbounds i32, i32* %24, i64 %139
%152 = load i32, i32* %151
%153 = mul nsw i32 %152, %37
%154 = getelementptr inbounds i32, i32* %22, i64 %139
%155 = load i32, i32* %154
%156 = add nsw i32 %153, %155
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds double, double* %10, i64 %157
%159 = load double, double* %158
%160 = call double @llvm.fmuladd.f64(double %148, double %150, double %159)
store double %160, double* %158
%161 = add nuw nsw i64 %139, 1
%162 = icmp eq i64 %161, %137
br i1 %162, label %163, label %138
163: ; preds = %138, %134
ret void
}