void conserve_interp(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_i1 = (int *)malloc(1e7 * sizeof(int));
  xgrid_j1 = (int *)malloc(1e7 * sizeof(int));
  xgrid_i2 = (int *)malloc(1e7 * sizeof(int));
  xgrid_j2 = (int *)malloc(1e7 * sizeof(int));
  xgrid_area = (double *)malloc(1e7 * sizeof(double));
  dst_area = (double *)malloc(nx_dst * ny_dst * sizeof(double));
  nxgrid = create_xgrid_2dx2d_order1(&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);
  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>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%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    $0x2625a00,%edi
call   1040 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0x2625a00,%edi
call   1040 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    $0x2625a00,%edi
call   1040 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    $0x2625a00,%edi
call   1040 <malloc@plt>
mov    %rax,-0x70(%rbp)
mov    $0x4c4b400,%edi
call   1040 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x34(%rbp),%eax
imul   -0x38(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    0x10(%rbp),%r13
mov    0x18(%rbp),%r12
mov    0x20(%rbp),%r15
mov    -0x58(%rbp),%r14
mov    -0x60(%rbp),%rbx
mov    -0x68(%rbp),%r11
mov    -0x70(%rbp),%r10
mov    -0x78(%rbp),%rax
lea    -0x2c(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
mov    $0x0,%al
call   1050 <create_xgrid_2dx2d_order1@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    1269 <conserve_interp+0x139>
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    1239 <conserve_interp+0x109>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    12c2 <conserve_interp+0x192>
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    1270 <conserve_interp+0x140>
movslq -0x50(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    133a <conserve_interp+0x20a>
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    12dd <conserve_interp+0x1ad>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x34(%rbp),%ecx
imul   -0x38(%rbp),%ecx
cmp    %ecx,%eax
jge    1371 <conserve_interp+0x241>
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    1341 <conserve_interp+0x211>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    13fb <conserve_interp+0x2cb>
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    1378 <conserve_interp+0x248>
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    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<conserve_interp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r9,0x80(%rsp)
mov    %r8,0x58(%rsp)
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %edi,0x74(%rsp)
mov    %esi,0x8c(%rsp)
mov    %edx,0x70(%rsp)
mov    %ecx,0x6c(%rsp)
mov    $0x2625a00,%edi
call   1050 <malloc@plt>
mov    %rax,0x60(%rsp)
mov    $0x2625a00,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x2625a00,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x2625a00,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    $0x4c4b400,%edi
call   1050 <malloc@plt>
imul   %r15d,%ebp
mov    %rax,%r15
movslq %ebp,%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %r15,0x38(%rsp)
mov    %r13,0x48(%rsp)
mov    %r13,0x30(%rsp)
mov    %rbx,0x50(%rsp)
mov    %rbx,0x28(%rsp)
mov    %r14,0x78(%rsp)
mov    %r14,0x20(%rsp)
mov    0x60(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0xf0(%rsp),%rax
mov    %rax,0x10(%rsp)
movapd 0xe0(%rsp),%xmm0
movupd %xmm0,(%rsp)
lea    0x74(%rsp),%rdi
lea    0x8c(%rsp),%rsi
lea    0x70(%rsp),%rdx
lea    0x6c(%rsp),%rcx
mov    0x58(%rsp),%r8
mov    0x80(%rsp),%r9
xor    %eax,%eax
call   1060 <create_xgrid_2dx2d_order1@plt>
mov    %eax,%ebx
movslq 0x70(%rsp),%r13
mov    0x6c(%rsp),%eax
imul   %r13d,%eax
mov    %eax,%ebp
mov    %eax,0x58(%rsp)
test   %eax,%eax
jle    126a <conserve_interp+0x12a>
lea    0x0(,%rbp,8),%rdx
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %ebx,%r8d
test   %ebx,%ebx
mov    %r15,0xa0(%rsp)
mov    %ebx,0x80(%rsp)
mov    %rbp,0x98(%rsp)
jle    129e <conserve_interp+0x15e>
cmp    $0x1,%ebx
jne    12cc <conserve_interp+0x18c>
xor    %eax,%eax
mov    0x50(%rsp),%rdi
mov    0x48(%rsp),%rbp
jmp    132f <conserve_interp+0x1ef>
movslq %ebx,%rdi
shl    $0x3,%rdi
mov    %r8,%rbx
call   1050 <malloc@plt>
mov    %rbx,%r10
mov    %rax,%r14
mov    0x60(%rsp),%rdi
mov    0x78(%rsp),%r9
mov    0x50(%rsp),%rbx
mov    0x48(%rsp),%rbp
jmp    13e9 <conserve_interp+0x2a9>
mov    %r8d,%ecx
and    $0xfffffffe,%ecx
xor    %eax,%eax
mov    0x50(%rsp),%rdi
mov    0x48(%rsp),%rbp
xchg   %ax,%ax
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    12e0 <conserve_interp+0x1a0>
mov    %r8,0x90(%rsp)
test   $0x1,%r8b
je     135f <conserve_interp+0x21f>
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   1050 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    13cd <conserve_interp+0x28d>
xor    %eax,%eax
mov    0x60(%rsp),%rdi
mov    0x78(%rsp),%r9
mov    0x50(%rsp),%rbx
mov    0x48(%rsp),%rbp
mov    0x90(%rsp),%r10
mov    0x58(%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    13a0 <conserve_interp+0x260>
jmp    13ed <conserve_interp+0x2ad>
mov    0x60(%rsp),%rdi
mov    0x78(%rsp),%r9
mov    0x50(%rsp),%rbx
mov    0x48(%rsp),%rbp
mov    0x90(%rsp),%r10
mov    0x58(%rsp),%esi
mov    0x100(%rsp),%r15
test   %esi,%esi
jle    1429 <conserve_interp+0x2e9>
mov    0x98(%rsp),%rdx
shl    $0x3,%rdx
mov    %r15,%rdi
xor    %esi,%esi
mov    %r10,%rbx
call   1040 <memset@plt>
mov    %rbx,%r10
mov    0x48(%rsp),%rbp
mov    0x50(%rsp),%rbx
mov    0x78(%rsp),%r9
mov    0x60(%rsp),%rdi
cmpl   $0x0,0x80(%rsp)
jle    1490 <conserve_interp+0x350>
mov    0xf8(%rsp),%r8
movslq 0x74(%rsp),%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
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    1450 <conserve_interp+0x310>
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    0xa0(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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