double qgaus(func, a, b)
double a, b;
double (*func)();
{
  int j;
  double xr, xm, dx, s;
  static double x[100 + 1];
  static double w[100 + 1];
  static int firstcall = 1;
  if (firstcall) {
    firstcall = 0;
    gauleg(-1., 1., x, w, 100);
  }
  xm = 0.5 * (b + a);
  xr = 0.5 * (b - a);
  s = 0;
  for (j = 1; j <= 100 / 2; 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    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
cmpl   $0x0,0x2efb(%rip)
je     1167 <qgaus+0x57>
movl   $0x0,0x2eeb(%rip)
movsd  0xebb(%rip),%xmm0
movsd  0xebb(%rip),%xmm1
lea    0x2eec(%rip),%rdi
lea    0x3215(%rip),%rsi
mov    $0x64,%edx
mov    $0x2,%al
call   1030 <gauleg@plt>
movsd  -0x18(%rbp),%xmm1
addsd  -0x10(%rbp),%xmm1
movsd  0xe97(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe7c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x32,-0x1c(%rbp)
jg     123f <qgaus+0x12f>
movsd  -0x28(%rbp),%xmm0
movslq -0x1c(%rbp),%rcx
lea    0x2e7a(%rip),%rax
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movslq -0x1c(%rbp),%rcx
lea    0x3195(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   *%rcx
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <qgaus+0x9c>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qgaus>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movapd %xmm0,%xmm3
mov    %rdi,%r14
cmpb   $0x0,0x356f(%rip)
jne    1174 <qgaus+0x64>
movb   $0x1,0x3566(%rip)
lea    0x2f07(%rip),%rdi
lea    0x3230(%rip),%rsi
movsd  0xeb8(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
movsd  0xeb2(%rip),%xmm1
mov    $0x64,%edx
mov    $0x2,%al
movsd  %xmm3,0x8(%rsp)
call   1030 <gauleg@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm1
movapd %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  0xe8c(%rip),%xmm0
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
subsd  %xmm3,%xmm1
mulsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
mov    $0x1,%ebx
lea    0x2e9a(%rip),%r15
lea    0x31c3(%rip),%r12
movsd  %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,0x8(%rsp)
movsd  (%r15,%rbx,8),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x20(%rsp)
movsd  (%r12,%rbx,8),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
addsd  %xmm2,%xmm0
mov    $0x1,%al
call   *%r14
movsd  %xmm0,0x28(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   *%r14
movsd  0x10(%rsp),%xmm1
addsd  0x28(%rsp),%xmm0
mulsd  0x30(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    $0x33,%rbx
jne    11c0 <qgaus+0xb0>
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@qgaus.x = internal global [101 x double] zeroinitializer
@qgaus.w = internal global [101 x double] zeroinitializer
@qgaus.firstcall = internal unnamed_addr global i1 false
define double @qgaus(double (...)* nocapture %0, double %1, double %2) {
%4 = load i1, i1* @qgaus.firstcall
br i1 %4, label %7, label %5
5: ; preds = %3
store i1 true, i1* @qgaus.firstcall
%6 = tail call i32 (double, double, double*, double*, i32, ...) bitcast (i32 (...)* @gauleg to i32 (double, double, double*, double*, i32, ...)*)(double -1.000000e+00, double 1.000000e+00, double* getelementptr inbounds ([101 x double], [101 x double]* @qgaus.x, i64 0, i64 0), double* getelementptr inbounds ([101 x double], [101 x double]* @qgaus.w, i64 0, i64 0), i32 100)
br label %7
7: ; preds = %5, %3
%8 = fadd double %1, %2
%9 = fmul double %8, 5.000000e-01
%10 = fsub double %2, %1
%11 = fmul double %10, 5.000000e-01
%12 = bitcast double (...)* %0 to double (double, ...)*
br label %13
13: ; preds = %7, %13
%14 = phi i64 [ 1, %7 ], [ %27, %13 ]
%15 = phi double [ 0.000000e+00, %7 ], [ %26, %13 ]
%16 = getelementptr inbounds [101 x double], [101 x double]* @qgaus.x, i64 0, i64 %14
%17 = load double, double* %16
%18 = fmul double %11, %17
%19 = getelementptr inbounds [101 x double], [101 x double]* @qgaus.w, i64 0, i64 %14
%20 = load double, double* %19
%21 = fadd double %9, %18
%22 = tail call double (double, ...) %12(double %21)
%23 = fsub double %9, %18
%24 = tail call double (double, ...) %12(double %23)
%25 = fadd double %22, %24
%26 = tail call double @llvm.fmuladd.f64(double %20, double %25, double %15)
%27 = add nuw nsw i64 %14, 1
%28 = icmp eq i64 %27, 51
br i1 %28, label %29, label %13
29: ; preds = %13
%30 = fmul double %11, %26
ret double %30
}