#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(float);
float qromb(float (*func)(float), float a, float b) {
  void polint(float xa[], float ya[], int n, float x, float *y, float *dy);
  float trapzd(float (*func)(float), float a, float b, int n);
  void nrerror(char error_text[]);
  float ss, dss;
  float s[(20 + 1)], h[(20 + 1) + 1];
  int j;
  h[1] = 1.0;
  for (j = 1; j <= 20; 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-6 * 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    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  0xe9f(%rip),%xmm0
movss  %xmm0,-0xdc(%rbp)
ff
movl   $0x1,-0xe4(%rbp)
cmpl   $0x14,-0xe4(%rbp)
jg     1294 <qromb+0x154>
mov    -0x10(%rbp),%rdi
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
mov    -0xe4(%rbp),%esi
call   1040 <trapzd@plt>
movslq -0xe4(%rbp),%rax
movss  %xmm0,-0x80(%rbp,%rax,4)
cmpl   $0x5,-0xe4(%rbp)
jl     1248 <qromb+0x108>
mov    -0xe4(%rbp),%eax
sub    $0x5,%eax
cltq
lea    -0xe0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0xe4(%rbp),%eax
sub    $0x5,%eax
cltq
lea    -0x80(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x5,%edx
xorps  %xmm0,%xmm0
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1060 <polint@plt>
movss  -0x20(%rbp),%xmm0
call   1050 <fabs@plt>
movsd  %xmm0,-0xf0(%rbp)
ff
movss  -0x1c(%rbp),%xmm0
call   1050 <fabs@plt>
movsd  -0xf0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  0xde2(%rip),%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     1243 <qromb+0x103>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a8 <qromb+0x168>
jmp    1248 <qromb+0x108>
movslq -0xe4(%rbp),%rax
movss  -0xe0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm1
movsd  0xdac(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
cltq
movss  %xmm0,-0xe0(%rbp,%rax,4)
ff ff
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1173 <qromb+0x33>
lea    0xd7d(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qromb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
mov    %rdi,%r14
movl   $0x3f800000,0x24(%rsp)
3f
mov    $0x1,%ebx
mov    $0xfffffffc,%r13d
mov    $0x14,%ebp
lea    0x8(%rsp),%r15
lea    0x14(%rsp),%r12
jmp    11b6 <qromb+0x76>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  0x20(%rsp,%rbx,4),%xmm0
mulss  0xe6a(%rip),%xmm0
movss  %xmm0,0x24(%rsp,%rbx,4)
add    $0x1,%rbx
add    $0x1,%r13
add    $0xffffffffffffffff,%rbp
je     123e <qromb+0xfe>
mov    %r14,%rdi
movss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
mov    %ebx,%esi
call   1040 <trapzd@plt>
movss  %xmm0,0x80(%rsp,%rbx,4)
cmp    $0x5,%rbx
jb     1190 <qromb+0x50>
mov    %r13d,%eax
shl    $0x2,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x20,%rdi
lea    0x80(%rsp,%rax,1),%rsi
xorpd  %xmm0,%xmm0
mov    $0x5,%edx
mov    %r15,%rcx
mov    %r12,%r8
call   1060 <polint@plt>
movss  0x14(%rsp),%xmm0
call   1050 <fabs@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x8(%rsp),%xmm0
call   1050 <fabs@plt>
mulsd  0xdd6(%rip),%xmm0
ucomisd 0x18(%rsp),%xmm0
jb     1190 <qromb+0x50>
movss  0x8(%rsp),%xmm0
jmp    124d <qromb+0x10d>
lea    0xdc7(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
add    $0xd8,%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 float @qromb(float (float)* %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float (float)*
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca [21 x float]
%11 = alloca [22 x float]
%12 = alloca i32
store float (float)* %0, float (float)** %5
store float %1, float* %6
store float %2, float* %7
%13 = getelementptr inbounds [22 x float], [22 x float]* %11, i64 0, i64 1
store float 1.000000e+00, float* %13
store i32 1, i32* %12
br label %14
14: ; preds = %58, %3
%15 = load i32, i32* %12
%16 = icmp sle i32 %15, 20
br i1 %16, label %17, label %61
17: ; preds = %14
%18 = load float (float)*, float (float)** %5
%19 = load float, float* %6
%20 = load float, float* %7
%21 = load i32, i32* %12
%22 = call float @trapzd(float (float)* %18, float %19, float %20, i32 %21)
%23 = load i32, i32* %12
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [21 x float], [21 x float]* %10, i64 0, i64 %24
store float %22, float* %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 [22 x float], [22 x float]* %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 [21 x float], [21 x float]* %10, i64 0, i64 %35
%37 = load float, float* %9
%38 = call double @fabs(float %37)
%39 = load float, float* %8
%40 = call double @fabs(float %39)
%41 = fmul double 0x3EB0C6F7A0B5ED8D, %40
%42 = fcmp ole double %38, %41
br i1 %42, label %43, label %45
43: ; preds = %28
%44 = load float, float* %8
store float %44, float* %4
br label %62
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 float], [22 x float]* %11, i64 0, i64 %48
%50 = load float, float* %49
%51 = fpext float %50 to double
%52 = fmul double 2.500000e-01, %51
%53 = fptrunc double %52 to float
%54 = load i32, i32* %12
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [22 x float], [22 x float]* %11, i64 0, i64 %56
store float %53, float* %57
br label %58
58: ; preds = %46
%59 = load i32, i32* %12
%60 = add nsw i32 %59, 1
store i32 %60, i32* %12
br label %14
61: ; preds = %14
store float 0.000000e+00, float* %4
br label %62
62: ; preds = %61, %43
%63 = load float, float* %4
ret float %63
}

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