#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 qromb1(double (*func)(double), double a, double b) {
  void polint1(double xa[], double ya[], int n, double x, double *y,
               double *dy);
  double trapzd1(double (*func)(double), double a, double b, int n);
  void nrerror(char error_text[]);
  double ss, dss;
  double s[(20 + 1)], h[(20 + 1) + 1];
  int j;
  h[1] = 1.0;
  for (j = 1; j <= 20; j++) {
    s[j] = trapzd1(func, a, b, j);
    if (j >= 10) {
      polint1(&h[j - 10], &s[j - 10], 10, 0.0, &ss, &dss);
      if (fabs(dss) <= 1.0e-6 * fabs(ss))
        return ss;
    }
    h[j + 1] = 0.25 * h[j];
  }
  nrerror("Too many steps in routine qromb1");
  return 0.0;
}


x86 assembly (clang, -O0):
<qromb1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,-0x188(%rbp)
ff
movl   $0x1,-0x194(%rbp)
cmpl   $0x14,-0x194(%rbp)
jg     1277 <qromb1+0x147>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x194(%rbp),%esi
call   1040 <trapzd1@plt>
movslq -0x194(%rbp),%rax
movsd  %xmm0,-0xe0(%rbp,%rax,8)
ff ff
cmpl   $0xa,-0x194(%rbp)
jl     1237 <qromb1+0x107>
mov    -0x194(%rbp),%eax
sub    $0xa,%eax
cltq
lea    -0x190(%rbp),%rdi
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x194(%rbp),%eax
sub    $0xa,%eax
cltq
lea    -0xe0(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0xa,%edx
xorps  %xmm0,%xmm0
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1050 <polint1@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 <qromb1+0x102>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128b <qromb1+0x15b>
jmp    1237 <qromb1+0x107>
movslq -0x194(%rbp),%rax
movsd  0xdca(%rip),%xmm0
mulsd  -0x190(%rbp,%rax,8),%xmm0
ff ff
mov    -0x194(%rbp),%eax
add    $0x1,%eax
cltq
movsd  %xmm0,-0x190(%rbp,%rax,8)
ff ff
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    1163 <qromb1+0x33>
lea    0xdb2(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qromb1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x178,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %rdi,%r14
movabs $0x3ff0000000000000,%rax
mov    %rax,0x28(%rsp)
mov    $0x1,%ebx
mov    $0xfffffff7,%r13d
mov    $0x14,%ebp
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    11a6 <qromb1+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 <qromb1+0xf9>
mov    %r14,%rdi
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %ebx,%esi
call   1040 <trapzd1@plt>
movsd  %xmm0,0xd0(%rsp,%rbx,8)
cmp    $0xa,%rbx
jb     1180 <qromb1+0x50>
mov    %r13d,%eax
shl    $0x3,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x20,%rdi
lea    0xd0(%rsp,%rax,1),%rsi
xorpd  %xmm0,%xmm0
mov    $0xa,%edx
mov    %r15,%rcx
mov    %r12,%r8
call   1050 <polint1@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 <qromb1+0x50>
jmp    1239 <qromb1+0x109>
lea    0xdf0(%rip),%rdi
call   1030 <nrerror@plt>
xorpd  %xmm0,%xmm0
add    $0x178,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Too many steps in routine qromb1\00"
define double @qromb1(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 [21 x double]
%11 = alloca [22 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 [22 x double], [22 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, 20
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 @trapzd1(double (double)* %18, double %19, double %20, i32 %21)
%23 = load i32, i32* %12
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [21 x double], [21 x double]* %10, i64 0, i64 %24
store double %22, double* %25
%26 = load i32, i32* %12
%27 = icmp sge i32 %26, 10
br i1 %27, label %28, label %46
28: ; preds = %17
%29 = load i32, i32* %12
%30 = sub nsw i32 %29, 10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [22 x double], [22 x double]* %11, i64 0, i64 %31
%33 = load i32, i32* %12
%34 = sub nsw i32 %33, 10
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [21 x double], [21 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 0x3EB0C6F7A0B5ED8D, %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 [22 x double], [22 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 [22 x double], [22 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 = [33 x i8] c"Too many steps in routine qromb1\00"
define double @qromb1(double (double)* %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca [21 x double]
%7 = alloca [22 x double]
%8 = bitcast double* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = bitcast [21 x double]* %6 to i8*
%11 = bitcast [22 x double]* %7 to i8*
%12 = getelementptr inbounds [22 x double], [22 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 @trapzd1(double (double)* %0, double %1, double %2, i32 %15)
%17 = getelementptr inbounds [21 x double], [21 x double]* %6, i64 0, i64 %14
store double %16, double* %17
%18 = icmp ugt i64 %14, 9
br i1 %18, label %19, label %30
19: ; preds = %13
%20 = add nuw i64 %14, 4294967286
%21 = and i64 %20, 4294967295
%22 = getelementptr inbounds [22 x double], [22 x double]* %7, i64 0, i64 %21
%23 = getelementptr inbounds [21 x double], [21 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, 0x3EB0C6F7A0B5ED8D
%29 = fcmp ugt double %25, %28
br i1 %29, label %30, label %38
30: ; preds = %19, %13
%31 = getelementptr inbounds [22 x double], [22 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 [22 x double], [22 x double]* %7, i64 0, i64 %34
store double %33, double* %35
%36 = icmp eq i64 %34, 21
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
}