void bcugrid(double *x, double *y, double **ff, double **y1_grid,
             double **y2_grid, double **y12_grid, int n1, int n2) {
  int i, j;
  for (i = 1; i < n1 - 1; i++) {
    for (j = 1; j < n2; j++) {
      y1_grid[i][j] = (ff[i + 1][j] - ff[i - 1][j]) / (x[i + 1] - x[i - 1]);
    }
  }
  for (i = 1; i < n1 - 1; i++) {
    for (j = 1; j < n2; j++) {
      y2_grid[i][j] = (ff[i][j + 1] - ff[i][j - 1]) / (y[j + 1] - y[j - 1]);
    }
  }
  for (i = 1; i < n1 - 1; i++) {
    for (j = 1; j < n2; j++) {
      y12_grid[i][j] =
          (y1_grid[i][j + 1] - y1_grid[i][j - 1]) / (y[j + 1] - y[j - 1]);
    }
  }
}


x86 assembly (clang, -O0):
<bcugrid>:
push   %rbp
mov    %rsp,%rbp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11df <bcugrid+0xdf>
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    11cc <bcugrid+0xcc>
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1141 <bcugrid+0x41>
jmp    11d1 <bcugrid+0xd1>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1129 <bcugrid+0x29>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    129c <bcugrid+0x19c>
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    1289 <bcugrid+0x189>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11fe <bcugrid+0xfe>
jmp    128e <bcugrid+0x18e>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11e6 <bcugrid+0xe6>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1359 <bcugrid+0x259>
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    1346 <bcugrid+0x246>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12bb <bcugrid+0x1bb>
jmp    134b <bcugrid+0x24b>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12a3 <bcugrid+0x1a3>
pop    %rbp
ret

x86 assembly (clang, -O2):
<bcugrid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,-0x20(%rsp)
mov    %rcx,-0x38(%rsp)
mov    %rdx,-0x30(%rsp)
mov    0x38(%rsp),%eax
cmp    $0x3,%eax
jl     15b3 <bcugrid+0x4b3>
mov    %r8,-0x50(%rsp)
mov    0x40(%rsp),%r11d
add    $0xffffffff,%eax
mov    %eax,%r13d
mov    %r11d,%eax
lea    -0x1(%rax),%rcx
mov    %rcx,%r14
and    $0xfffffffffffffffe,%r14
mov    %rcx,-0x60(%rsp)
or     $0x1,%rcx
mov    %rcx,-0x28(%rsp)
mov    %rax,%rcx
neg    %rcx
mov    %rcx,-0x18(%rsp)
mov    $0x1,%r12d
xor    %ebp,%ebp
mov    %r13,-0x58(%rsp)
jmp    117d <bcugrid+0x7d>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %r13,%r12
je     1337 <bcugrid+0x237>
mov    %r12,%r15
add    $0x1,%r12
cmp    $0x2,%r11d
jl     1170 <bcugrid+0x70>
mov    -0x30(%rsp),%rcx
mov    (%rcx,%r12,8),%r9
mov    -0x8(%rcx,%r15,8),%r8
mov    -0x38(%rsp),%rcx
mov    (%rcx,%r15,8),%r10
mov    $0x1,%ebx
cmpq   $0x2,-0x60(%rsp)
jb     12a0 <bcugrid+0x1a0>
lea    (%rdi,%rbp,8),%rcx
mov    %rcx,-0x8(%rsp)
lea    (%rdi,%rbp,8),%rcx
add    $0x18,%rcx
mov    %rcx,-0x10(%rsp)
lea    0x8(%r10),%r11
lea    (%r10,%rax,8),%rdx
lea    0x8(%r9),%rcx
mov    %rcx,-0x40(%rsp)
lea    (%r9,%rax,8),%r13
lea    0x8(%r8),%rcx
mov    %rcx,-0x48(%rsp)
lea    (%r8,%rax,8),%rcx
cmp    %r13,%r11
setb   -0x61(%rsp)
cmp    %rdx,-0x40(%rsp)
setb   -0x40(%rsp)
cmp    %rcx,%r11
setb   %cl
cmp    %rdx,-0x48(%rsp)
setb   -0x48(%rsp)
cmp    -0x10(%rsp),%r11
setb   %r13b
cmp    %rdx,-0x8(%rsp)
setb   %r11b
mov    -0x40(%rsp),%dl
test   %dl,-0x61(%rsp)
jne    1288 <bcugrid+0x188>
and    -0x48(%rsp),%cl
jne    1288 <bcugrid+0x188>
and    %r11b,%r13b
mov    0x40(%rsp),%r11d
mov    -0x58(%rsp),%r13
jne    12a0 <bcugrid+0x1a0>
movsd  (%rdi,%r12,8),%xmm0
subsd  -0x8(%rdi,%r15,8),%xmm0
unpcklpd %xmm0,%xmm0
xor    %ecx,%ecx
movupd 0x8(%r9,%rcx,8),%xmm1
movupd 0x8(%r8,%rcx,8),%xmm2
subpd  %xmm2,%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x8(%r10,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r14
jne    1250 <bcugrid+0x150>
mov    -0x28(%rsp),%rbx
cmp    %r14,-0x60(%rsp)
je     1170 <bcugrid+0x70>
jmp    12a0 <bcugrid+0x1a0>
mov    0x40(%rsp),%r11d
mov    -0x58(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rcx
test   $0x1,%al
jne    12ce <bcugrid+0x1ce>
movsd  (%r9,%rbx,8),%xmm0
subsd  (%r8,%rbx,8),%xmm0
movsd  (%rdi,%r12,8),%xmm1
subsd  -0x8(%rdi,%r15,8),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r10,%rbx,8)
lea    0x1(%rbx),%rcx
not    %rbx
cmp    -0x18(%rsp),%rbx
je     1170 <bcugrid+0x70>
nopl   0x0(%rax)
movsd  (%r9,%rcx,8),%xmm0
subsd  (%r8,%rcx,8),%xmm0
movsd  (%rdi,%r12,8),%xmm1
subsd  -0x8(%rdi,%r15,8),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r10,%rcx,8)
movsd  0x8(%r9,%rcx,8),%xmm0
subsd  0x8(%r8,%rcx,8),%xmm0
movsd  (%rdi,%r12,8),%xmm1
subsd  -0x8(%rdi,%r15,8),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%r10,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%rax
jne    12e0 <bcugrid+0x1e0>
jmp    1170 <bcugrid+0x70>
mov    0x38(%rsp),%ecx
cmp    $0x3,%ecx
mov    -0x50(%rsp),%r10
jl     15b3 <bcugrid+0x4b3>
lea    0x1(%rax),%r12
lea    (%rsi,%rax,8),%r8
add    $0x8,%r8
mov    -0x60(%rsp),%r9
or     $0x1,%r9
mov    $0x1,%edi
jmp    137d <bcugrid+0x27d>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rdi
cmp    %r13,%rdi
je     1479 <bcugrid+0x379>
cmp    $0x2,%r11d
jl     1370 <bcugrid+0x270>
mov    -0x30(%rsp),%rcx
mov    (%rcx,%rdi,8),%rbp
mov    (%r10,%rdi,8),%rcx
mov    $0x1,%ebx
cmpq   $0x2,-0x60(%rsp)
jae    13d0 <bcugrid+0x2d0>
nopl   (%rax)
movsd  0x8(%rbp,%rbx,8),%xmm0
subsd  -0x8(%rbp,%rbx,8),%xmm0
movsd  0x8(%rsi,%rbx,8),%xmm1
subsd  -0x8(%rsi,%rbx,8),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx,%rbx,8)
lea    0x1(%rbx),%rdx
mov    %rdx,%rbx
cmp    %rdx,%rax
jne    13a0 <bcugrid+0x2a0>
jmp    1370 <bcugrid+0x270>
nop
lea    0x8(%rcx),%r11
lea    (%rcx,%rax,8),%r10
lea    0x0(,%r12,8),%rdx
add    %rbp,%rdx
cmp    %rdx,%r11
setb   %r15b
cmp    %r10,%rbp
setb   %r13b
cmp    %r8,%r11
setb   %dl
cmp    %rsi,%r10
seta   %r10b
test   %r13b,%r15b
jne    1465 <bcugrid+0x365>
and    %r10b,%dl
mov    0x40(%rsp),%r11d
mov    -0x58(%rsp),%r13
mov    -0x50(%rsp),%r10
jne    13a0 <bcugrid+0x2a0>
xor    %ebx,%ebx
nopl   0x0(%rax)
movupd 0x0(%rbp,%rbx,8),%xmm0
movupd 0x10(%rbp,%rbx,8),%xmm1
subpd  %xmm0,%xmm1
movupd (%rsi,%rbx,8),%xmm0
movupd 0x10(%rsi,%rbx,8),%xmm2
subpd  %xmm0,%xmm2
divpd  %xmm2,%xmm1
movupd %xmm1,0x8(%rcx,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r14
jne    1420 <bcugrid+0x320>
mov    %r9,%rbx
cmp    %r14,-0x60(%rsp)
jne    13a0 <bcugrid+0x2a0>
jmp    1370 <bcugrid+0x270>
mov    0x40(%rsp),%r11d
mov    -0x58(%rsp),%r13
mov    -0x50(%rsp),%r10
jmp    13a0 <bcugrid+0x2a0>
mov    0x38(%rsp),%ecx
cmp    $0x3,%ecx
jl     15b3 <bcugrid+0x4b3>
mov    -0x60(%rsp),%r9
or     $0x1,%r9
mov    $0x1,%edi
jmp    14ad <bcugrid+0x3ad>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rdi
cmp    %r13,%rdi
je     15b3 <bcugrid+0x4b3>
cmp    $0x2,%r11d
jl     14a0 <bcugrid+0x3a0>
mov    -0x38(%rsp),%rcx
mov    (%rcx,%rdi,8),%rcx
mov    -0x20(%rsp),%rdx
mov    (%rdx,%rdi,8),%rbp
mov    $0x1,%edx
cmpq   $0x2,-0x60(%rsp)
jae    1510 <bcugrid+0x410>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x8(%rcx,%rdx,8),%xmm0
subsd  -0x8(%rcx,%rdx,8),%xmm0
movsd  0x8(%rsi,%rdx,8),%xmm1
subsd  -0x8(%rsi,%rdx,8),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp,%rdx,8)
lea    0x1(%rdx),%rbx
mov    %rbx,%rdx
cmp    %rbx,%rax
jne    14e0 <bcugrid+0x3e0>
jmp    14a0 <bcugrid+0x3a0>
lea    0x8(%rbp),%r11
lea    0x0(,%rax,8),%r10
add    %rbp,%r10
lea    (%rcx,%r12,8),%rbx
cmp    %rbx,%r11
setb   %r15b
cmp    %r10,%rcx
setb   %r13b
cmp    %r8,%r11
setb   %bl
cmp    %rsi,%r10
seta   %r10b
test   %r13b,%r15b
jne    15a4 <bcugrid+0x4a4>
and    %r10b,%bl
mov    0x40(%rsp),%r11d
mov    -0x58(%rsp),%r13
jne    14e0 <bcugrid+0x3e0>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd (%rcx,%rdx,8),%xmm0
movupd 0x10(%rcx,%rdx,8),%xmm1
subpd  %xmm0,%xmm1
movupd (%rsi,%rdx,8),%xmm0
movupd 0x10(%rsi,%rdx,8),%xmm2
subpd  %xmm0,%xmm2
divpd  %xmm2,%xmm1
movupd %xmm1,0x8(%rbp,%rdx,8)
add    $0x2,%rdx
cmp    %rdx,%r14
jne    1560 <bcugrid+0x460>
mov    %r9,%rdx
cmp    %r14,-0x60(%rsp)
jne    14e0 <bcugrid+0x3e0>
jmp    14a0 <bcugrid+0x3a0>
mov    0x40(%rsp),%r11d
mov    -0x58(%rsp),%r13
jmp    14e0 <bcugrid+0x3e0>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @bcugrid(double* nocapture %0, double* nocapture %1, double** nocapture %2, double** nocapture %3, double** nocapture %4, double** nocapture %5, i32 %6, i32 %7) {
%9 = add i32 %6, -1
%10 = icmp sgt i32 %6, 2
br i1 %10, label %11, label %278
11: ; preds = %8
%12 = icmp sgt i32 %7, 1
%13 = zext i32 %9 to i64
%14 = zext i32 %7 to i64
%15 = add nsw i64 %14, -1
%16 = icmp ult i64 %15, 2
%17 = and i64 %15, -2
%18 = or i64 %15, 1
%19 = icmp eq i64 %15, %17
%20 = and i64 %14, 1
%21 = icmp eq i64 %20, 0
%22 = sub nsw i64 0, %14
br label %23
23: ; preds = %11, %135
%24 = phi i64 [ 0, %11 ], [ %137, %135 ]
%25 = phi i64 [ 1, %11 ], [ %29, %135 ]
%26 = getelementptr double, double* %0, i64 %24
%27 = add i64 %24, 3
%28 = getelementptr double, double* %0, i64 %27
%29 = add nuw nsw i64 %25, 1
br i1 %12, label %30, label %135
30: ; preds = %23
%31 = getelementptr inbounds double*, double** %2, i64 %29
%32 = load double*, double** %31
%33 = add nsw i64 %25, -1
%34 = getelementptr inbounds double*, double** %2, i64 %33
%35 = load double*, double** %34
%36 = getelementptr inbounds double, double* %0, i64 %29
%37 = getelementptr inbounds double, double* %0, i64 %33
%38 = getelementptr inbounds double*, double** %3, i64 %25
%39 = load double*, double** %38
br i1 %16, label %80, label %40
40: ; preds = %30
%41 = getelementptr double, double* %39, i64 1
%42 = getelementptr double, double* %39, i64 %14
%43 = getelementptr double, double* %32, i64 1
%44 = getelementptr double, double* %32, i64 %14
%45 = getelementptr double, double* %35, i64 1
%46 = getelementptr double, double* %35, i64 %14
%47 = icmp ult double* %41, %44
%48 = icmp ult double* %43, %42
%49 = and i1 %47, %48
%50 = icmp ult double* %41, %46
%51 = icmp ult double* %45, %42
%52 = and i1 %50, %51
%53 = or i1 %49, %52
%54 = icmp ult double* %41, %28
%55 = icmp ult double* %26, %42
%56 = and i1 %54, %55
%57 = or i1 %53, %56
br i1 %57, label %80, label %58
58: ; preds = %40
%59 = load double, double* %36
%60 = load double, double* %37
%61 = fsub double %59, %60
%62 = insertelement <2 x double> poison, double %61, i64 0
%63 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> zeroinitializer
br label %64
64: ; preds = %64, %58
%65 = phi i64 [ 0, %58 ], [ %77, %64 ]
%66 = or i64 %65, 1
%67 = getelementptr inbounds double, double* %32, i64 %66
%68 = bitcast double* %67 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = getelementptr inbounds double, double* %35, i64 %66
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = fsub <2 x double> %69, %72
%74 = fdiv <2 x double> %73, %63
%75 = getelementptr inbounds double, double* %39, i64 %66
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %74, <2 x double>* %76
%77 = add nuw i64 %65, 2
%78 = icmp eq i64 %77, %17
br i1 %78, label %79, label %64
79: ; preds = %64
br i1 %19, label %135, label %80
80: ; preds = %40, %30, %79
%81 = phi i64 [ 1, %40 ], [ 1, %30 ], [ %18, %79 ]
%82 = xor i64 %81, -1
br i1 %21, label %83, label %95
83: ; preds = %80
%84 = getelementptr inbounds double, double* %32, i64 %81
%85 = load double, double* %84
%86 = getelementptr inbounds double, double* %35, i64 %81
%87 = load double, double* %86
%88 = fsub double %85, %87
%89 = load double, double* %36
%90 = load double, double* %37
%91 = fsub double %89, %90
%92 = fdiv double %88, %91
%93 = getelementptr inbounds double, double* %39, i64 %81
store double %92, double* %93
%94 = add nuw nsw i64 %81, 1
br label %95
95: ; preds = %83, %80
%96 = phi i64 [ %81, %80 ], [ %94, %83 ]
%97 = icmp eq i64 %82, %22
br i1 %97, label %135, label %110
98: ; preds = %135
br i1 %10, label %99, label %278
99: ; preds = %98
%100 = icmp sgt i32 %7, 1
%101 = zext i32 %9 to i64
%102 = zext i32 %7 to i64
%103 = add nuw nsw i64 %14, 1
%104 = getelementptr double, double* %1, i64 %103
%105 = add nsw i64 %14, -1
%106 = icmp ult i64 %105, 2
%107 = and i64 %105, -2
%108 = or i64 %105, 1
%109 = icmp eq i64 %105, %107
br label %138
110: ; preds = %95, %110
%111 = phi i64 [ %133, %110 ], [ %96, %95 ]
%112 = getelementptr inbounds double, double* %32, i64 %111
%113 = load double, double* %112
%114 = getelementptr inbounds double, double* %35, i64 %111
%115 = load double, double* %114
%116 = fsub double %113, %115
%117 = load double, double* %36
%118 = load double, double* %37
%119 = fsub double %117, %118
%120 = fdiv double %116, %119
%121 = getelementptr inbounds double, double* %39, i64 %111
store double %120, double* %121
%122 = add nuw nsw i64 %111, 1
%123 = getelementptr inbounds double, double* %32, i64 %122
%124 = load double, double* %123
%125 = getelementptr inbounds double, double* %35, i64 %122
%126 = load double, double* %125
%127 = fsub double %124, %126
%128 = load double, double* %36
%129 = load double, double* %37
%130 = fsub double %128, %129
%131 = fdiv double %127, %130
%132 = getelementptr inbounds double, double* %39, i64 %122
store double %131, double* %132
%133 = add nuw nsw i64 %111, 2
%134 = icmp eq i64 %133, %14
br i1 %134, label %135, label %110
135: ; preds = %95, %110, %79, %23
%136 = icmp eq i64 %29, %13
%137 = add i64 %24, 1
br i1 %136, label %98, label %23
138: ; preds = %99, %211
%139 = phi i64 [ 1, %99 ], [ %212, %211 ]
br i1 %100, label %140, label %211
140: ; preds = %138
%141 = getelementptr inbounds double*, double** %2, i64 %139
%142 = load double*, double** %141
%143 = getelementptr inbounds double*, double** %4, i64 %139
%144 = load double*, double** %143
br i1 %106, label %180, label %145
145: ; preds = %140
%146 = getelementptr double, double* %144, i64 1
%147 = getelementptr double, double* %144, i64 %14
%148 = getelementptr double, double* %142, i64 %103
%149 = icmp ult double* %146, %148
%150 = icmp ult double* %142, %147
%151 = and i1 %149, %150
%152 = icmp ult double* %146, %104
%153 = icmp ugt double* %147, %1
%154 = and i1 %152, %153
%155 = or i1 %151, %154
br i1 %155, label %180, label %156
156: ; preds = %145, %156
%157 = phi i64 [ %177, %156 ], [ 0, %145 ]
%158 = or i64 %157, 1
%159 = add i64 %157, 2
%160 = getelementptr inbounds double, double* %142, i64 %159
%161 = bitcast double* %160 to <2 x double>*
%162 = load <2 x double>, <2 x double>* %161
%163 = getelementptr inbounds double, double* %142, i64 %157
%164 = bitcast double* %163 to <2 x double>*
%165 = load <2 x double>, <2 x double>* %164
%166 = fsub <2 x double> %162, %165
%167 = getelementptr inbounds double, double* %1, i64 %159
%168 = bitcast double* %167 to <2 x double>*
%169 = load <2 x double>, <2 x double>* %168
%170 = getelementptr inbounds double, double* %1, i64 %157
%171 = bitcast double* %170 to <2 x double>*
%172 = load <2 x double>, <2 x double>* %171
%173 = fsub <2 x double> %169, %172
%174 = fdiv <2 x double> %166, %173
%175 = getelementptr inbounds double, double* %144, i64 %158
%176 = bitcast double* %175 to <2 x double>*
store <2 x double> %174, <2 x double>* %176
%177 = add nuw i64 %157, 2
%178 = icmp eq i64 %177, %107
br i1 %178, label %179, label %156
179: ; preds = %156
br i1 %109, label %211, label %180
180: ; preds = %145, %140, %179
%181 = phi i64 [ 1, %145 ], [ 1, %140 ], [ %108, %179 ]
br label %194
182: ; preds = %211
br i1 %10, label %183, label %278
183: ; preds = %182
%184 = icmp sgt i32 %7, 1
%185 = zext i32 %9 to i64
%186 = zext i32 %7 to i64
%187 = add nuw nsw i64 %14, 1
%188 = getelementptr double, double* %1, i64 %187
%189 = add nsw i64 %14, -1
%190 = icmp ult i64 %189, 2
%191 = and i64 %189, -2
%192 = or i64 %189, 1
%193 = icmp eq i64 %189, %191
br label %214
194: ; preds = %180, %194
%195 = phi i64 [ %196, %194 ], [ %181, %180 ]
%196 = add nuw nsw i64 %195, 1
%197 = getelementptr inbounds double, double* %142, i64 %196
%198 = load double, double* %197
%199 = add nsw i64 %195, -1
%200 = getelementptr inbounds double, double* %142, i64 %199
%201 = load double, double* %200
%202 = fsub double %198, %201
%203 = getelementptr inbounds double, double* %1, i64 %196
%204 = load double, double* %203
%205 = getelementptr inbounds double, double* %1, i64 %199
%206 = load double, double* %205
%207 = fsub double %204, %206
%208 = fdiv double %202, %207
%209 = getelementptr inbounds double, double* %144, i64 %195
store double %208, double* %209
%210 = icmp eq i64 %196, %102
br i1 %210, label %211, label %194
211: ; preds = %194, %179, %138
%212 = add nuw nsw i64 %139, 1
%213 = icmp eq i64 %212, %101
br i1 %213, label %182, label %138
214: ; preds = %183, %275
%215 = phi i64 [ 1, %183 ], [ %276, %275 ]
br i1 %184, label %216, label %275
216: ; preds = %214
%217 = getelementptr inbounds double*, double** %3, i64 %215
%218 = load double*, double** %217
%219 = getelementptr inbounds double*, double** %5, i64 %215
%220 = load double*, double** %219
br i1 %190, label %256, label %221
221: ; preds = %216
%222 = getelementptr double, double* %220, i64 1
%223 = getelementptr double, double* %220, i64 %14
%224 = getelementptr double, double* %218, i64 %187
%225 = icmp ult double* %222, %224
%226 = icmp ult double* %218, %223
%227 = and i1 %225, %226
%228 = icmp ult double* %222, %188
%229 = icmp ugt double* %223, %1
%230 = and i1 %228, %229
%231 = or i1 %227, %230
br i1 %231, label %256, label %232
232: ; preds = %221, %232
%233 = phi i64 [ %253, %232 ], [ 0, %221 ]
%234 = or i64 %233, 1
%235 = add i64 %233, 2
%236 = getelementptr inbounds double, double* %218, i64 %235
%237 = bitcast double* %236 to <2 x double>*
%238 = load <2 x double>, <2 x double>* %237
%239 = getelementptr inbounds double, double* %218, i64 %233
%240 = bitcast double* %239 to <2 x double>*
%241 = load <2 x double>, <2 x double>* %240
%242 = fsub <2 x double> %238, %241
%243 = getelementptr inbounds double, double* %1, i64 %235
%244 = bitcast double* %243 to <2 x double>*
%245 = load <2 x double>, <2 x double>* %244
%246 = getelementptr inbounds double, double* %1, i64 %233
%247 = bitcast double* %246 to <2 x double>*
%248 = load <2 x double>, <2 x double>* %247
%249 = fsub <2 x double> %245, %248
%250 = fdiv <2 x double> %242, %249
%251 = getelementptr inbounds double, double* %220, i64 %234
%252 = bitcast double* %251 to <2 x double>*
store <2 x double> %250, <2 x double>* %252
%253 = add nuw i64 %233, 2
%254 = icmp eq i64 %253, %191
br i1 %254, label %255, label %232
255: ; preds = %232
br i1 %193, label %275, label %256
256: ; preds = %221, %216, %255
%257 = phi i64 [ 1, %221 ], [ 1, %216 ], [ %192, %255 ]
br label %258
258: ; preds = %256, %258
%259 = phi i64 [ %260, %258 ], [ %257, %256 ]
%260 = add nuw nsw i64 %259, 1
%261 = getelementptr inbounds double, double* %218, i64 %260
%262 = load double, double* %261
%263 = add nsw i64 %259, -1
%264 = getelementptr inbounds double, double* %218, i64 %263
%265 = load double, double* %264
%266 = fsub double %262, %265
%267 = getelementptr inbounds double, double* %1, i64 %260
%268 = load double, double* %267
%269 = getelementptr inbounds double, double* %1, i64 %263
%270 = load double, double* %269
%271 = fsub double %268, %270
%272 = fdiv double %266, %271
%273 = getelementptr inbounds double, double* %220, i64 %259
store double %272, double* %273
%274 = icmp eq i64 %260, %186
br i1 %274, label %275, label %258
275: ; preds = %258, %255, %214
%276 = add nuw nsw i64 %215, 1
%277 = icmp eq i64 %276, %185
br i1 %277, label %278, label %214
278: ; preds = %275, %8, %98, %182
ret void
}