float qgaus(float (*func)(float), float a, float b) {
  int j;
  float xr, xm, dx, s;
  static float x[] = {0.0,          0.1488743389, 0.4333953941,
                      0.6794095682, 0.8650633666, 0.9739065285};
  static float w[] = {0.0,          0.2955242247, 0.2692667193,
                      0.2190863625, 0.1494513491, 0.0666713443};
  xm = 0.5 * (b + a);
  xr = 0.5 * (b - a);
  s = 0;
  for (j = 1; j <= 5; j++) {
    dx = xr * x[j];
    s += w[j] * ((*func)(xm + dx) + (*func)(xm - dx));
  }
  return s *= xr;
}


x86 assembly (clang, -O0):
<qgaus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xed4(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xeb1(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jg     11fa <qgaus+0xfa>
movss  -0x18(%rbp),%xmm0
movslq -0x14(%rbp),%rcx
lea    0x2eab(%rip),%rax
mulss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x20(%rbp)
movslq -0x14(%rbp),%rcx
lea    0x2eb6(%rip),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
call   *%rax
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movss  -0x1c(%rbp),%xmm0
subss  -0x20(%rbp),%xmm0
call   *%rax
movss  -0x2c(%rbp),%xmm2
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
addss  %xmm1,%xmm2
movss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <qgaus+0x6b>
movss  -0x18(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qgaus>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movaps %xmm0,%xmm3
addss  %xmm1,%xmm3
movss  0xee9(%rip),%xmm2
mulss  %xmm2,%xmm3
movss  %xmm3,0x14(%rsp)
subss  %xmm0,%xmm1
mulss  %xmm1,%xmm2
movss  %xmm2,0x1c(%rsp)
movss  0xecd(%rip),%xmm1
mulss  %xmm2,%xmm1
movss  %xmm1,0xc(%rsp)
movaps %xmm3,%xmm0
addss  %xmm1,%xmm0
call   *%rdi
movss  %xmm0,0x10(%rsp)
movss  0x14(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
call   *%rbx
addss  0x10(%rsp),%xmm0
mulss  0xe9c(%rip),%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xe8b(%rip),%xmm1
mulss  0x1c(%rsp),%xmm1
movss  %xmm1,0x18(%rsp)
movss  0x14(%rsp),%xmm0
addss  %xmm1,%xmm0
call   *%rbx
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm0
subss  0x18(%rsp),%xmm0
call   *%rbx
addss  0xc(%rsp),%xmm0
mulss  0xe55(%rip),%xmm0
addss  0x10(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xe45(%rip),%xmm1
mulss  0x1c(%rsp),%xmm1
movss  %xmm1,0x18(%rsp)
movss  0x14(%rsp),%xmm0
addss  %xmm1,%xmm0
call   *%rbx
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm0
subss  0x18(%rsp),%xmm0
call   *%rbx
addss  0xc(%rsp),%xmm0
mulss  0xe0f(%rip),%xmm0
addss  0x10(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xdff(%rip),%xmm1
mulss  0x1c(%rsp),%xmm1
movss  %xmm1,0x18(%rsp)
movss  0x14(%rsp),%xmm0
addss  %xmm1,%xmm0
call   *%rbx
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm0
subss  0x18(%rsp),%xmm0
call   *%rbx
addss  0xc(%rsp),%xmm0
mulss  0xdc9(%rip),%xmm0
addss  0x10(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xdb9(%rip),%xmm1
mulss  0x1c(%rsp),%xmm1
movss  %xmm1,0x18(%rsp)
movss  0x14(%rsp),%xmm0
addss  %xmm1,%xmm0
call   *%rbx
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm0
subss  0x18(%rsp),%xmm0
call   *%rbx
addss  0xc(%rsp),%xmm0
mulss  0xd83(%rip),%xmm0
addss  0x10(%rsp),%xmm0
mulss  0x1c(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@qgaus.x = internal global [6 x float] [float 0.000000e+00, float 0x3FC30E5080000000, float 0x3FDBBCC000000000, float 0x3FE5BDB920000000, float 0x3FEBAE9960000000, float 0x3FEF2A3E00000000]
@qgaus.w = internal global [6 x float] [float 0.000000e+00, float 0x3FD2E9DE80000000, float 0x3FD13BAA80000000, float 0x3FCC0B05A0000000, float 0x3FC32138C0000000, float 0x3FB1115F80000000]
define float @qgaus(float (float)* %0, float %1, float %2) {
%4 = alloca float (float)*
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store float (float)* %0, float (float)** %4
store float %1, float* %5
store float %2, float* %6
%12 = load float, float* %6
%13 = load float, float* %5
%14 = fadd float %12, %13
%15 = fpext float %14 to double
%16 = fmul double 5.000000e-01, %15
%17 = fptrunc double %16 to float
store float %17, float* %9
%18 = load float, float* %6
%19 = load float, float* %5
%20 = fsub float %18, %19
%21 = fpext float %20 to double
%22 = fmul double 5.000000e-01, %21
%23 = fptrunc double %22 to float
store float %23, float* %8
store float 0.000000e+00, float* %11
store i32 1, i32* %7
br label %24
24: ; preds = %51, %3
%25 = load i32, i32* %7
%26 = icmp sle i32 %25, 5
br i1 %26, label %27, label %54
27: ; preds = %24
%28 = load float, float* %8
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [6 x float], [6 x float]* @qgaus.x, i64 0, i64 %30
%32 = load float, float* %31
%33 = fmul float %28, %32
store float %33, float* %10
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [6 x float], [6 x float]* @qgaus.w, i64 0, i64 %35
%37 = load float, float* %36
%38 = load float (float)*, float (float)** %4
%39 = load float, float* %9
%40 = load float, float* %10
%41 = fadd float %39, %40
%42 = call float %38(float %41)
%43 = load float (float)*, float (float)** %4
%44 = load float, float* %9
%45 = load float, float* %10
%46 = fsub float %44, %45
%47 = call float %43(float %46)
%48 = fadd float %42, %47
%49 = load float, float* %11
%50 = call float @llvm.fmuladd.f32(float %37, float %48, float %49)
store float %50, float* %11
br label %51
51: ; preds = %27
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %24
54: ; preds = %24
%55 = load float, float* %8
%56 = load float, float* %11
%57 = fmul float %56, %55
store float %57, float* %11
ret float %57
}

LLVM IR (-O2):
define float @qgaus(float (float)* nocapture %0, float %1, float %2) {
%4 = fadd float %1, %2
%5 = fmul float %4, 5.000000e-01
%6 = fsub float %2, %1
%7 = fmul float %6, 5.000000e-01
%8 = fmul float %7, 0x3FC30E5080000000
%9 = fadd float %5, %8
%10 = tail call float %0(float %9)
%11 = fsub float %5, %8
%12 = tail call float %0(float %11)
%13 = fadd float %10, %12
%14 = tail call float @llvm.fmuladd.f32(float %13, float 0x3FD2E9DE80000000, float 0.000000e+00)
%15 = fmul float %7, 0x3FDBBCC000000000
%16 = fadd float %5, %15
%17 = tail call float %0(float %16)
%18 = fsub float %5, %15
%19 = tail call float %0(float %18)
%20 = fadd float %17, %19
%21 = tail call float @llvm.fmuladd.f32(float %20, float 0x3FD13BAA80000000, float %14)
%22 = fmul float %7, 0x3FE5BDB920000000
%23 = fadd float %5, %22
%24 = tail call float %0(float %23)
%25 = fsub float %5, %22
%26 = tail call float %0(float %25)
%27 = fadd float %24, %26
%28 = tail call float @llvm.fmuladd.f32(float %27, float 0x3FCC0B05A0000000, float %21)
%29 = fmul float %7, 0x3FEBAE9960000000
%30 = fadd float %5, %29
%31 = tail call float %0(float %30)
%32 = fsub float %5, %29
%33 = tail call float %0(float %32)
%34 = fadd float %31, %33
%35 = tail call float @llvm.fmuladd.f32(float %34, float 0x3FC32138C0000000, float %28)
%36 = fmul float %7, 0x3FEF2A3E00000000
%37 = fadd float %5, %36
%38 = tail call float %0(float %37)
%39 = fsub float %5, %36
%40 = tail call float %0(float %39)
%41 = fadd float %38, %40
%42 = tail call float @llvm.fmuladd.f32(float %41, float 0x3FB1115F80000000, float %35)
%43 = fmul float %7, %42
ret float %43
}