long double booles(long double (*f)(long double), long double a, long double b,
                   int n) {
  long double h = (b - a) / n;
  long double sum = 7 * (f(a) + f(b));
  while (n - 4) {
    sum += (32 * f((n - 1) * h) + 12 * f((n - 2) * h) + 32 * f((n - 3) * h) +
            14 * f((n - 4) * h));
    n = n - 4;
  }
  sum += (32 * f((n - 1) * h) + 12 * f((n - 2) * h) + 32 * f((n - 3) * h));
  return (2.0 * h / 45.0) * sum;
}


x86 assembly (clang, -O0):
<booles>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
mov    %rdi,-0x8(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
mov    %esi,-0x34(%rbp)
fldt   -0x30(%rbp)
fldt   -0x20(%rbp)
fsubrp %st,%st(1)
mov    -0x34(%rbp),%eax
mov    %eax,-0x64(%rbp)
fildl  -0x64(%rbp)
fdivrp %st,%st(1)
fstpt  -0x50(%rbp)
mov    -0x8(%rbp),%rax
fldt   -0x20(%rbp)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fstpt  -0x8c(%rbp)
mov    -0x8(%rbp),%rax
fldt   -0x30(%rbp)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fldt   -0x8c(%rbp)
faddp  %st,%st(1)
flds   0xe9c(%rip)
fmulp  %st,%st(1)
fstpt  -0x60(%rbp)
mov    -0x34(%rbp),%eax
sub    $0x4,%eax
cmp    $0x0,%eax
je     1252 <booles+0x152>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x80(%rbp)
fildl  -0x80(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fstpt  -0xbc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0xfffffffe,%ecx
mov    %ecx,-0x7c(%rbp)
fildl  -0x7c(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fldt   -0xbc(%rbp)
flds   0xe42(%rip)
fmulp  %st,%st(2)
flds   0xe3e(%rip)
fld    %st(0)
fstpt  -0xb0(%rbp)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  -0xa4(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0xfffffffd,%ecx
mov    %ecx,-0x78(%rbp)
fildl  -0x78(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fldt   -0xb0(%rbp)
fldt   -0xa4(%rbp)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x98(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0xfffffffc,%ecx
mov    %ecx,-0x74(%rbp)
fildl  -0x74(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fldt   -0x98(%rbp)
flds   0xdd8(%rip)
fmulp  %st,%st(2)
faddp  %st,%st(1)
fldt   -0x60(%rbp)
faddp  %st,%st(1)
fstpt  -0x60(%rbp)
mov    -0x34(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x34(%rbp)
jmp    1169 <booles+0x69>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x70(%rbp)
fildl  -0x70(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fstpt  -0xe0(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0xfffffffe,%ecx
mov    %ecx,-0x6c(%rbp)
fildl  -0x6c(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fldt   -0xe0(%rbp)
flds   0xd68(%rip)
fmulp  %st,%st(2)
flds   0xd64(%rip)
fld    %st(0)
fstpt  -0xd4(%rbp)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  -0xc8(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0xfffffffd,%ecx
mov    %ecx,-0x68(%rbp)
fildl  -0x68(%rbp)
fldt   -0x50(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rcx
fstpt  (%rcx)
call   *%rax
fldt   -0xd4(%rbp)
fldt   -0xc8(%rbp)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fldt   -0x60(%rbp)
faddp  %st,%st(1)
fstpt  -0x60(%rbp)
fldt   -0x50(%rbp)
fadd   %st,%st(0)
flds   0xd15(%rip)
fdivrp %st,%st(1)
fldt   -0x60(%rbp)
fmulp  %st,%st(1)
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<booles>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
fldt   0x80(%rsp)
fldt   0x90(%rsp)
fld    %st(0)
fstpt  0x3c(%rsp)
fsub   %st(1),%st
mov    %esi,0x58(%rsp)
fidivl 0x58(%rsp)
fstpt  0x24(%rsp)
fstpt  (%rsp)
call   *%rdi
fstpt  0x30(%rsp)
fldt   0x3c(%rsp)
fstpt  (%rsp)
call   *%r14
fldt   0x30(%rsp)
faddp  %st,%st(1)
fmuls  0xeb3(%rip)
add    $0xfffffffc,%ebx
fstpt  0x3c(%rsp)
je     120c <booles+0x10c>
flds   0xea8(%rip)
fstpt  0x30(%rsp)
fldt   0x24(%rsp)
fstp   %st(0)
nopw   0x0(%rax,%rax,1)
lea    0x3(%rbx),%eax
mov    %eax,0x54(%rsp)
fldt   0x24(%rsp)
fimull 0x54(%rsp)
fstpt  (%rsp)
call   *%r14
fstpt  0x18(%rsp)
lea    0x2(%rbx),%eax
mov    %eax,0x50(%rsp)
fldt   0x24(%rsp)
fimull 0x50(%rsp)
fstpt  (%rsp)
call   *%r14
fmuls  0xe60(%rip)
fldt   0x30(%rsp)
fldt   0x18(%rsp)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  0x18(%rsp)
lea    0x1(%rbx),%eax
mov    %eax,0x4c(%rsp)
fldt   0x24(%rsp)
fimull 0x4c(%rsp)
fstpt  (%rsp)
call   *%r14
fldt   0x30(%rsp)
fmulp  %st,%st(1)
fldt   0x18(%rsp)
faddp  %st,%st(1)
fstpt  0x18(%rsp)
mov    %ebx,0x48(%rsp)
fldt   0x24(%rsp)
fimull 0x48(%rsp)
fstpt  (%rsp)
call   *%r14
fmuls  0xe1b(%rip)
fldt   0x18(%rsp)
faddp  %st,%st(1)
fldt   0x3c(%rsp)
faddp  %st,%st(1)
fstpt  0x3c(%rsp)
add    $0xfffffffc,%ebx
jne    1170 <booles+0x70>
jmp    1212 <booles+0x112>
fldt   0x24(%rsp)
fstp   %st(0)
fldt   0x24(%rsp)
fmuls  0xdf4(%rip)
fstpt  (%rsp)
call   *%r14
fstpt  0x18(%rsp)
fldt   0x24(%rsp)
fadd   %st,%st(0)
fld    %st(0)
fstpt  0x30(%rsp)
fstpt  (%rsp)
call   *%r14
fmuls  0xdc6(%rip)
flds   0xdc4(%rip)
fld    %st(0)
fstpt  0x5c(%rsp)
fldt   0x18(%rsp)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpt  0x18(%rsp)
fldt   0x24(%rsp)
fstpt  (%rsp)
call   *%r14
fldt   0x5c(%rsp)
fmulp  %st,%st(1)
fldt   0x18(%rsp)
faddp  %st,%st(1)
fldt   0x3c(%rsp)
faddp  %st,%st(1)
fldt   0x30(%rsp)
fdivs  0xd98(%rip)
fmulp  %st,%st(1)
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define x86_fp80 @booles(x86_fp80 (x86_fp80)* %0, x86_fp80 %1, x86_fp80 %2, i32 %3) {
%5 = alloca x86_fp80 (x86_fp80)*
%6 = alloca x86_fp80
%7 = alloca x86_fp80
%8 = alloca i32
%9 = alloca x86_fp80
%10 = alloca x86_fp80
store x86_fp80 (x86_fp80)* %0, x86_fp80 (x86_fp80)** %5
store x86_fp80 %1, x86_fp80* %6
store x86_fp80 %2, x86_fp80* %7
store i32 %3, i32* %8
%11 = load x86_fp80, x86_fp80* %7
%12 = load x86_fp80, x86_fp80* %6
%13 = fsub x86_fp80 %11, %12
%14 = load i32, i32* %8
%15 = sitofp i32 %14 to x86_fp80
%16 = fdiv x86_fp80 %13, %15
store x86_fp80 %16, x86_fp80* %9
%17 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%18 = load x86_fp80, x86_fp80* %6
%19 = call x86_fp80 %17(x86_fp80 %18)
%20 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%21 = load x86_fp80, x86_fp80* %7
%22 = call x86_fp80 %20(x86_fp80 %21)
%23 = fadd x86_fp80 %19, %22
%24 = fmul x86_fp80 0xK4001E000000000000000, %23
store x86_fp80 %24, x86_fp80* %10
br label %25
25: ; preds = %29, %4
%26 = load i32, i32* %8
%27 = sub nsw i32 %26, 4
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %66
29: ; preds = %25
%30 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%31 = load i32, i32* %8
%32 = sub nsw i32 %31, 1
%33 = sitofp i32 %32 to x86_fp80
%34 = load x86_fp80, x86_fp80* %9
%35 = fmul x86_fp80 %33, %34
%36 = call x86_fp80 %30(x86_fp80 %35)
%37 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%38 = load i32, i32* %8
%39 = sub nsw i32 %38, 2
%40 = sitofp i32 %39 to x86_fp80
%41 = load x86_fp80, x86_fp80* %9
%42 = fmul x86_fp80 %40, %41
%43 = call x86_fp80 %37(x86_fp80 %42)
%44 = fmul x86_fp80 0xK4002C000000000000000, %43
%45 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40048000000000000000, x86_fp80 %36, x86_fp80 %44)
%46 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%47 = load i32, i32* %8
%48 = sub nsw i32 %47, 3
%49 = sitofp i32 %48 to x86_fp80
%50 = load x86_fp80, x86_fp80* %9
%51 = fmul x86_fp80 %49, %50
%52 = call x86_fp80 %46(x86_fp80 %51)
%53 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40048000000000000000, x86_fp80 %52, x86_fp80 %45)
%54 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%55 = load i32, i32* %8
%56 = sub nsw i32 %55, 4
%57 = sitofp i32 %56 to x86_fp80
%58 = load x86_fp80, x86_fp80* %9
%59 = fmul x86_fp80 %57, %58
%60 = call x86_fp80 %54(x86_fp80 %59)
%61 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK4002E000000000000000, x86_fp80 %60, x86_fp80 %53)
%62 = load x86_fp80, x86_fp80* %10
%63 = fadd x86_fp80 %62, %61
store x86_fp80 %63, x86_fp80* %10
%64 = load i32, i32* %8
%65 = sub nsw i32 %64, 4
store i32 %65, i32* %8
br label %25
66: ; preds = %25
%67 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%68 = load i32, i32* %8
%69 = sub nsw i32 %68, 1
%70 = sitofp i32 %69 to x86_fp80
%71 = load x86_fp80, x86_fp80* %9
%72 = fmul x86_fp80 %70, %71
%73 = call x86_fp80 %67(x86_fp80 %72)
%74 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%75 = load i32, i32* %8
%76 = sub nsw i32 %75, 2
%77 = sitofp i32 %76 to x86_fp80
%78 = load x86_fp80, x86_fp80* %9
%79 = fmul x86_fp80 %77, %78
%80 = call x86_fp80 %74(x86_fp80 %79)
%81 = fmul x86_fp80 0xK4002C000000000000000, %80
%82 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40048000000000000000, x86_fp80 %73, x86_fp80 %81)
%83 = load x86_fp80 (x86_fp80)*, x86_fp80 (x86_fp80)** %5
%84 = load i32, i32* %8
%85 = sub nsw i32 %84, 3
%86 = sitofp i32 %85 to x86_fp80
%87 = load x86_fp80, x86_fp80* %9
%88 = fmul x86_fp80 %86, %87
%89 = call x86_fp80 %83(x86_fp80 %88)
%90 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40048000000000000000, x86_fp80 %89, x86_fp80 %82)
%91 = load x86_fp80, x86_fp80* %10
%92 = fadd x86_fp80 %91, %90
store x86_fp80 %92, x86_fp80* %10
%93 = load x86_fp80, x86_fp80* %9
%94 = fmul x86_fp80 0xK40008000000000000000, %93
%95 = fdiv x86_fp80 %94, 0xK4004B400000000000000
%96 = load x86_fp80, x86_fp80* %10
%97 = fmul x86_fp80 %95, %96
ret x86_fp80 %97
}

LLVM IR (-O2):
define x86_fp80 @booles(x86_fp80 (x86_fp80)* nocapture %0, x86_fp80 %1, x86_fp80 %2, i32 %3) {
%5 = fsub x86_fp80 %2, %1
%6 = sitofp i32 %3 to x86_fp80
%7 = fdiv x86_fp80 %5, %6
%8 = tail call x86_fp80 %0(x86_fp80 %1)
%9 = tail call x86_fp80 %0(x86_fp80 %2)
%10 = fadd x86_fp80 %8, %9
%11 = fmul x86_fp80 %10, 0xK4001E000000000000000
%12 = add nsw i32 %3, -4
%13 = icmp eq i32 %12, 0
br i1 %13, label %40, label %14
14: ; preds = %4, %14
%15 = phi i32 [ %38, %14 ], [ %12, %4 ]
%16 = phi x86_fp80 [ %37, %14 ], [ %11, %4 ]
%17 = phi i32 [ %15, %14 ], [ %3, %4 ]
%18 = add nsw i32 %17, -1
%19 = sitofp i32 %18 to x86_fp80
%20 = fmul x86_fp80 %7, %19
%21 = tail call x86_fp80 %0(x86_fp80 %20)
%22 = add nsw i32 %17, -2
%23 = sitofp i32 %22 to x86_fp80
%24 = fmul x86_fp80 %7, %23
%25 = tail call x86_fp80 %0(x86_fp80 %24)
%26 = fmul x86_fp80 %25, 0xK4002C000000000000000
%27 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %21, x86_fp80 0xK40048000000000000000, x86_fp80 %26)
%28 = add nsw i32 %17, -3
%29 = sitofp i32 %28 to x86_fp80
%30 = fmul x86_fp80 %7, %29
%31 = tail call x86_fp80 %0(x86_fp80 %30)
%32 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %31, x86_fp80 0xK40048000000000000000, x86_fp80 %27)
%33 = sitofp i32 %15 to x86_fp80
%34 = fmul x86_fp80 %7, %33
%35 = tail call x86_fp80 %0(x86_fp80 %34)
%36 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %35, x86_fp80 0xK4002E000000000000000, x86_fp80 %32)
%37 = fadd x86_fp80 %16, %36
%38 = add nsw i32 %15, -4
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %14
40: ; preds = %14, %4
%41 = phi x86_fp80 [ %11, %4 ], [ %37, %14 ]
%42 = fmul x86_fp80 %7, 0xK4000C000000000000000
%43 = tail call x86_fp80 %0(x86_fp80 %42)
%44 = fmul x86_fp80 %7, 0xK40008000000000000000
%45 = tail call x86_fp80 %0(x86_fp80 %44)
%46 = fmul x86_fp80 %45, 0xK4002C000000000000000
%47 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %43, x86_fp80 0xK40048000000000000000, x86_fp80 %46)
%48 = tail call x86_fp80 %0(x86_fp80 %7)
%49 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %48, x86_fp80 0xK40048000000000000000, x86_fp80 %47)
%50 = fadd x86_fp80 %41, %49
%51 = fmul x86_fp80 %7, 0xK40008000000000000000
%52 = fdiv x86_fp80 %51, 0xK4004B400000000000000
%53 = fmul x86_fp80 %52, %50
ret x86_fp80 %53
}