double trapizoidalRule2D(double (*f)(double, double), double a, double b,
                         double c, double d, int n, int m) {
  int i, j;
  double sum[6], h, k, integral = 0, x, y;
  h = (b - a) / (double)m;
  k = (d - c) / (double)n;
  for (i = 0; i < 6; i++)
    sum[i] = 0;
  sum[0] = f(a, c) + f(b, c) + f(a, d) + f(b, d);
  for (i = 1; i < m; i++) {
    x = a + (i * h);
    sum[1] += f(x, c);
    sum[2] += f(x, d);
  }
  for (j = 1; j < n; j++) {
    y = c + (j * k);
    sum[3] += f(a, y);
    sum[4] += f(b, y);
  }
  for (i = 1; i < 5; i++)
    sum[i] *= 2;
  for (i = 1; i < m; i++) {
    for (j = 1; j < n; j++) {
      x = a + (i * h);
      y = c + (j * k);
      sum[5] += f(x, y);
    }
  }
  sum[5] *= 4;
  for (i = 0; i < 6; i++)
    integral += sum[i];
  integral = ((h * k) / 4) * integral;
  return integral;
}


x86 assembly (clang, -O0):
<trapizoidalRule2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %edx,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x6,-0x34(%rbp)
jge    1190 <trapizoidalRule2D+0x90>
movslq -0x34(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp,%rax,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116b <trapizoidalRule2D+0x6b>
mov    -0x8(%rbp),%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0xb0(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1294 <trapizoidalRule2D+0x194>
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x20(%rbp),%xmm1
call   *%rax
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x28(%rbp),%xmm1
call   *%rax
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1221 <trapizoidalRule2D+0x121>
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    130e <trapizoidalRule2D+0x20e>
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x38(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x98(%rbp),%xmm1
ff
call   *%rax
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x98(%rbp),%xmm1
ff
call   *%rax
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    129b <trapizoidalRule2D+0x19b>
movl   $0x1,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    1345 <trapizoidalRule2D+0x245>
movslq -0x34(%rbp),%rax
movsd  0xcdd(%rip),%xmm0
mulsd  -0x70(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x70(%rbp,%rax,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1315 <trapizoidalRule2D+0x215>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    13ea <trapizoidalRule2D+0x2ea>
movl   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    13d7 <trapizoidalRule2D+0x2d7>
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x38(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x98(%rbp),%xmm1
ff
call   *%rax
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    135f <trapizoidalRule2D+0x25f>
jmp    13dc <trapizoidalRule2D+0x2dc>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    134c <trapizoidalRule2D+0x24c>
movsd  0xc0e(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x6,-0x34(%rbp)
jge    1435 <trapizoidalRule2D+0x335>
movslq -0x34(%rbp),%rax
movsd  -0x70(%rbp,%rax,8),%xmm0
addsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1403 <trapizoidalRule2D+0x303>
movsd  -0x78(%rbp),%xmm0
mulsd  -0x80(%rbp),%xmm0
movsd  0xbb9(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trapizoidalRule2D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %edx,%r15d
mov    %esi,%r14d
movsd  %xmm3,0x30(%rsp)
movsd  %xmm1,(%rsp)
mov    %rdi,%rbx
movapd %xmm1,%xmm4
movapd %xmm0,%xmm1
movsd  %xmm0,0x18(%rsp)
subsd  %xmm0,%xmm4
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
divsd  %xmm0,%xmm4
movsd  %xmm4,0x48(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
movsd  %xmm0,0x70(%rsp)
movapd %xmm3,%xmm0
movsd  %xmm2,0x28(%rsp)
subsd  %xmm2,%xmm0
movsd  %xmm0,0x20(%rsp)
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
call   *%rdi
movsd  %xmm0,0x90(%rsp)
movsd  (%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
call   *%rbx
movsd  %xmm0,0x88(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
call   *%rbx
movsd  %xmm0,0x80(%rsp)
movsd  (%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
call   *%rbx
movsd  %xmm0,0x78(%rsp)
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
cmp    $0x2,%r15d
jl     1249 <trapizoidalRule2D+0x149>
lea    -0x1(%r15),%ebp
xorpd  %xmm1,%xmm1
movsd  0xe26(%rip),%xmm0
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x10(%rsp)
movapd %xmm1,0x60(%rsp)
mulsd  0x48(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm1
call   *%rbx
movapd %xmm0,0x50(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
call   *%rbx
movapd 0x60(%rsp),%xmm1
movapd 0x50(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
addpd  %xmm2,%xmm1
addsd  0xdc4(%rip),%xmm0
add    $0xffffffff,%ebp
jne    11e0 <trapizoidalRule2D+0xe0>
addpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
movapd %xmm1,0x60(%rsp)
movsd  0x20(%rsp),%xmm2
divsd  0x70(%rsp),%xmm2
cmp    $0x2,%r14d
movsd  %xmm2,0x20(%rsp)
jl     12e7 <trapizoidalRule2D+0x1e7>
lea    -0x1(%r14),%ebp
xorpd  %xmm0,%xmm0
movsd  0xd85(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x10(%rsp)
movapd %xmm0,0x30(%rsp)
mulsd  %xmm2,%xmm1
addsd  0x28(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   *%rbx
movaps %xmm0,0x50(%rsp)
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movapd 0x50(%rsp),%xmm3
unpcklpd %xmm0,%xmm3
movapd 0x30(%rsp),%xmm0
addpd  %xmm3,%xmm0
addsd  0xd22(%rip),%xmm1
add    $0xffffffff,%ebp
jne    1280 <trapizoidalRule2D+0x180>
addpd  %xmm0,%xmm0
movapd %xmm0,0x30(%rsp)
xorpd  %xmm4,%xmm4
cmp    $0x2,%r15d
movsd  0x48(%rsp),%xmm0
jl     13ae <trapizoidalRule2D+0x2ae>
lea    -0x1(%r14),%r12d
mov    $0x1,%r13d
movsd  0xced(%rip),%xmm1
xorpd  %xmm4,%xmm4
movapd %xmm1,%xmm3
jmp    1338 <trapizoidalRule2D+0x238>
nopl   (%rax)
movsd  (%rsp),%xmm3
addsd  %xmm1,%xmm3
add    $0x1,%r13d
cmp    %r15d,%r13d
movsd  0x48(%rsp),%xmm0
je     13ae <trapizoidalRule2D+0x2ae>
cmp    $0x2,%r14d
movsd  %xmm3,(%rsp)
jl     1320 <trapizoidalRule2D+0x220>
mulsd  %xmm0,%xmm3
addsd  0x18(%rsp),%xmm3
movsd  %xmm3,0x8(%rsp)
mov    %r12d,%ebp
movapd %xmm1,%xmm0
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x50(%rsp)
movsd  %xmm4,0x10(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  0x28(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
call   *%rbx
movsd  0xc76(%rip),%xmm1
movsd  0x10(%rsp),%xmm4
movsd  0x20(%rsp),%xmm2
addsd  %xmm0,%xmm4
movsd  0x50(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0xffffffff,%ebp
jne    1360 <trapizoidalRule2D+0x260>
jmp    1320 <trapizoidalRule2D+0x220>
movsd  0x90(%rsp),%xmm1
addsd  0x88(%rsp),%xmm1
addsd  0x80(%rsp),%xmm1
addsd  0x78(%rsp),%xmm1
mulsd  0xc31(%rip),%xmm4
addsd  0xc39(%rip),%xmm1
movapd 0x60(%rsp),%xmm3
addsd  %xmm3,%xmm1
unpckhpd %xmm3,%xmm3
addsd  %xmm1,%xmm3
movapd 0x30(%rsp),%xmm1
addsd  %xmm1,%xmm3
unpckhpd %xmm1,%xmm1
addsd  %xmm3,%xmm1
addsd  %xmm4,%xmm1
mulsd  %xmm0,%xmm2
mulsd  0xbfd(%rip),%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @trapizoidalRule2D(double (double, double)* nocapture %0, double %1, double %2, double %3, double %4, i32 %5, i32 %6) {
%8 = fsub double %2, %1
%9 = sitofp i32 %6 to double
%10 = fdiv double %8, %9
%11 = sitofp i32 %5 to double
%12 = fsub double %4, %3
%13 = fdiv double %12, %11
%14 = tail call double %0(double %1, double %3)
%15 = tail call double %0(double %2, double %3)
%16 = tail call double %0(double %1, double %4)
%17 = tail call double %0(double %2, double %4)
%18 = icmp sgt i32 %6, 1
br i1 %18, label %24, label %21
19: ; preds = %24
%20 = fmul <2 x double> %33, <double 2.000000e+00, double 2.000000e+00>
br label %21
21: ; preds = %19, %7
%22 = phi <2 x double> [ %20, %19 ], [ zeroinitializer, %7 ]
%23 = icmp sgt i32 %5, 1
br i1 %23, label %40, label %38
24: ; preds = %7, %24
%25 = phi i32 [ %34, %24 ], [ 1, %7 ]
%26 = phi <2 x double> [ %33, %24 ], [ zeroinitializer, %7 ]
%27 = sitofp i32 %25 to double
%28 = tail call double @llvm.fmuladd.f64(double %27, double %10, double %1)
%29 = tail call double %0(double %28, double %3)
%30 = tail call double %0(double %28, double %4)
%31 = insertelement <2 x double> poison, double %29, i64 0
%32 = insertelement <2 x double> %31, double %30, i64 1
%33 = fadd <2 x double> %32, %26
%34 = add nuw nsw i32 %25, 1
%35 = icmp eq i32 %34, %6
br i1 %35, label %19, label %24
36: ; preds = %40
%37 = fmul <2 x double> %49, <double 2.000000e+00, double 2.000000e+00>
br label %38
38: ; preds = %36, %21
%39 = phi <2 x double> [ %37, %36 ], [ zeroinitializer, %21 ]
br i1 %18, label %52, label %71
40: ; preds = %21, %40
%41 = phi i32 [ %50, %40 ], [ 1, %21 ]
%42 = phi <2 x double> [ %49, %40 ], [ zeroinitializer, %21 ]
%43 = sitofp i32 %41 to double
%44 = tail call double @llvm.fmuladd.f64(double %43, double %13, double %3)
%45 = tail call double %0(double %1, double %44)
%46 = tail call double %0(double %2, double %44)
%47 = insertelement <2 x double> poison, double %45, i64 0
%48 = insertelement <2 x double> %47, double %46, i64 1
%49 = fadd <2 x double> %48, %42
%50 = add nuw nsw i32 %41, 1
%51 = icmp eq i32 %50, %5
br i1 %51, label %36, label %40
52: ; preds = %38, %67
%53 = phi double [ %68, %67 ], [ 0.000000e+00, %38 ]
%54 = phi i32 [ %69, %67 ], [ 1, %38 ]
br i1 %23, label %55, label %67
55: ; preds = %52
%56 = sitofp i32 %54 to double
%57 = tail call double @llvm.fmuladd.f64(double %56, double %10, double %1)
br label %58
58: ; preds = %55, %58
%59 = phi double [ %53, %55 ], [ %64, %58 ]
%60 = phi i32 [ 1, %55 ], [ %65, %58 ]
%61 = sitofp i32 %60 to double
%62 = tail call double @llvm.fmuladd.f64(double %61, double %13, double %3)
%63 = tail call double %0(double %57, double %62)
%64 = fadd double %63, %59
%65 = add nuw nsw i32 %60, 1
%66 = icmp eq i32 %65, %5
br i1 %66, label %67, label %58
67: ; preds = %58, %52
%68 = phi double [ %53, %52 ], [ %64, %58 ]
%69 = add nuw nsw i32 %54, 1
%70 = icmp eq i32 %69, %6
br i1 %70, label %71, label %52
71: ; preds = %67, %38
%72 = phi double [ 0.000000e+00, %38 ], [ %68, %67 ]
%73 = fadd double %14, %15
%74 = fadd double %73, %16
%75 = fadd double %74, %17
%76 = fmul double %72, 4.000000e+00
%77 = fadd double %75, 0.000000e+00
%78 = extractelement <2 x double> %22, i64 0
%79 = fadd double %77, %78
%80 = extractelement <2 x double> %22, i64 1
%81 = fadd double %79, %80
%82 = extractelement <2 x double> %39, i64 0
%83 = fadd double %81, %82
%84 = extractelement <2 x double> %39, i64 1
%85 = fadd double %83, %84
%86 = fadd double %85, %76
%87 = fmul double %13, %10
%88 = fmul double %87, 2.500000e-01
%89 = fmul double %88, %86
ret double %89
}