#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double fabs(double);
double qromb(double (*func)(double), double a, double b) {
  void polint(double xa[], double ya[], int n, double x, double *y, double *dy);
  double trapzd(double (*func)(double), double a, double b, int n);
  void nrerror(char error_text[]);
  double ss, dss;
  double s[(40 + 1)], h[(40 + 1) + 1];
  int j;
  h[1] = 1.0;
  for (j = 1; j <= 40; j++) {
    s[j] = trapzd(func, a, b, j);
    if (j >= 5) {
      polint(&h[j - 5], &s[j - 5], 5, 0.0, &ss, &dss);
      if (fabs(dss) <= 1.0e-8 * fabs(ss))
        return ss;
    }
    h[j + 1] = 0.25 * h[j];
  }
  nrerror("Too many steps in routine qromb");
  return 0.0;
}


x86 assembly (clang, -O0):
<qromb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2e0,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,-0x2c8(%rbp)
ff
movl   $0x1,-0x2d4(%rbp)
cmpl   $0x28,-0x2d4(%rbp)
jg     1277 <qromb+0x147>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x2d4(%rbp),%esi
call   1040 <trapzd@plt>
movslq -0x2d4(%rbp),%rax
movsd  %xmm0,-0x180(%rbp,%rax,8)
ff ff
cmpl   $0x5,-0x2d4(%rbp)
jl     1237 <qromb+0x107>
mov    -0x2d4(%rbp),%eax
sub    $0x5,%eax
cltq
lea    -0x2d0(%rbp),%rdi
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x2d4(%rbp),%eax
sub    $0x5,%eax
cltq
lea    -0x180(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x5,%edx
xorps  %xmm0,%xmm0
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1050 <polint@plt>
movsd  -0x30(%rbp),%xmm1
movaps 0xe27(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm2
movaps 0xe17(%rip),%xmm0
pand   %xmm0,%xmm2
movsd  0xdf3(%rip),%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     1232 <qromb+0x102>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128b <qromb+0x15b>
jmp    1237 <qromb+0x107>
movslq -0x2d4(%rbp),%rax
movsd  0xdca(%rip),%xmm0
mulsd  -0x2d0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2d4(%rbp),%eax
add    $0x1,%eax
cltq
movsd  %xmm0,-0x2d0(%rbp,%rax,8)
ff ff
mov    -0x2d4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2d4(%rbp)
jmp    1163 <qromb+0x33>
lea    0xdb2(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x2e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qromb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2b8,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %rdi,%r14
movabs $0x3ff0000000000000,%rax
mov    %rax,0x28(%rsp)
mov    $0x1,%ebx
mov    $0xfffffffc,%r13d
mov    $0x28,%ebp
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    11a6 <qromb+0x76>
nopw   0x0(%rax,%rax,1)
movsd  0x20(%rsp,%rbx,8),%xmm0
mulsd  0xe8a(%rip),%xmm0
movsd  %xmm0,0x28(%rsp,%rbx,8)
add    $0x1,%rbx
add    $0x1,%r13
add    $0xffffffffffffffff,%rbp
je     1229 <qromb+0xf9>
mov    %r14,%rdi
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %ebx,%esi
call   1040 <trapzd@plt>
movsd  %xmm0,0x170(%rsp,%rbx,8)
cmp    $0x5,%rbx
jb     1180 <qromb+0x50>
mov    %r13d,%eax
shl    $0x3,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x20,%rdi
lea    0x170(%rsp,%rax,1),%rsi
xorpd  %xmm0,%xmm0
mov    $0x5,%edx
mov    %r15,%rcx
mov    %r12,%r8
call   1050 <polint@plt>
movsd  0x10(%rsp),%xmm1
movapd 0xdfd(%rip),%xmm3
andpd  %xmm3,%xmm1
movsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm2
andpd  %xmm3,%xmm2
mulsd  0xdf3(%rip),%xmm2
ucomisd %xmm1,%xmm2
jb     1180 <qromb+0x50>
jmp    1239 <qromb+0x109>
lea    0xdf0(%rip),%rdi
call   1030 <nrerror@plt>
xorpd  %xmm0,%xmm0
add    $0x2b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Too many steps in routine qromb\00"
define double @qromb(double (double)* %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double (double)*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca [41 x double]
%11 = alloca [42 x double]
%12 = alloca i32
store double (double)* %0, double (double)** %5
store double %1, double* %6
store double %2, double* %7
%13 = getelementptr inbounds [42 x double], [42 x double]* %11, i64 0, i64 1
store double 1.000000e+00, double* %13
store i32 1, i32* %12
br label %14
14: ; preds = %56, %3
%15 = load i32, i32* %12
%16 = icmp sle i32 %15, 40
br i1 %16, label %17, label %59
17: ; preds = %14
%18 = load double (double)*, double (double)** %5
%19 = load double, double* %6
%20 = load double, double* %7
%21 = load i32, i32* %12
%22 = call double @trapzd(double (double)* %18, double %19, double %20, i32 %21)
%23 = load i32, i32* %12
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [41 x double], [41 x double]* %10, i64 0, i64 %24
store double %22, double* %25
%26 = load i32, i32* %12
%27 = icmp sge i32 %26, 5
br i1 %27, label %28, label %46
28: ; preds = %17
%29 = load i32, i32* %12
%30 = sub nsw i32 %29, 5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [42 x double], [42 x double]* %11, i64 0, i64 %31
%33 = load i32, i32* %12
%34 = sub nsw i32 %33, 5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [41 x double], [41 x double]* %10, i64 0, i64 %35
%37 = load double, double* %9
%38 = call double @llvm.fabs.f64(double %37)
%39 = load double, double* %8
%40 = call double @llvm.fabs.f64(double %39)
%41 = fmul double 1.000000e-08, %40
%42 = fcmp ole double %38, %41
br i1 %42, label %43, label %45
43: ; preds = %28
%44 = load double, double* %8
store double %44, double* %4
br label %60
45: ; preds = %28
br label %46
46: ; preds = %45, %17
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [42 x double], [42 x double]* %11, i64 0, i64 %48
%50 = load double, double* %49
%51 = fmul double 2.500000e-01, %50
%52 = load i32, i32* %12
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [42 x double], [42 x double]* %11, i64 0, i64 %54
store double %51, double* %55
br label %56
56: ; preds = %46
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
br label %14
59: ; preds = %14
store double 0.000000e+00, double* %4
br label %60
60: ; preds = %59, %43
%61 = load double, double* %4
ret double %61
}

LLVM IR (-O2):
@.str = [32 x i8] c"Too many steps in routine qromb\00"
define double @qromb(double (double)* %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca [41 x double]
%7 = alloca [42 x double]
%8 = bitcast double* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = bitcast [41 x double]* %6 to i8*
%11 = bitcast [42 x double]* %7 to i8*
%12 = getelementptr inbounds [42 x double], [42 x double]* %7, i64 0, i64 1
store double 1.000000e+00, double* %12
br label %13
13: ; preds = %3, %30
%14 = phi i64 [ 1, %3 ], [ %34, %30 ]
%15 = trunc i64 %14 to i32
%16 = call double @trapzd(double (double)* %0, double %1, double %2, i32 %15)
%17 = getelementptr inbounds [41 x double], [41 x double]* %6, i64 0, i64 %14
store double %16, double* %17
%18 = icmp ugt i64 %14, 4
br i1 %18, label %19, label %30
19: ; preds = %13
%20 = add nuw i64 %14, 4294967291
%21 = and i64 %20, 4294967295
%22 = getelementptr inbounds [42 x double], [42 x double]* %7, i64 0, i64 %21
%23 = getelementptr inbounds [41 x double], [41 x double]* %6, i64 0, i64 %21
%24 = load double, double* %5
%25 = call double @llvm.fabs.f64(double %24)
%26 = load double, double* %4
%27 = call double @llvm.fabs.f64(double %26)
%28 = fmul double %27, 1.000000e-08
%29 = fcmp ugt double %25, %28
br i1 %29, label %30, label %38
30: ; preds = %19, %13
%31 = getelementptr inbounds [42 x double], [42 x double]* %7, i64 0, i64 %14
%32 = load double, double* %31
%33 = fmul double %32, 2.500000e-01
%34 = add nuw nsw i64 %14, 1
%35 = getelementptr inbounds [42 x double], [42 x double]* %7, i64 0, i64 %34
store double %33, double* %35
%36 = icmp eq i64 %34, 41
br i1 %36, label %37, label %13
37: ; preds = %30
br label %38
38: ; preds = %19, %37
%39 = phi double [ 0.000000e+00, %37 ], [ %26, %19 ]
ret double %39
}