#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);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ polint(float *, float *, int, double, float *, float *);
int /*<<< orphan*/ stderr;
float trapzd(float (*)(float), float, float, int);
float qromb(float (*func)(float), float a, float b) {
  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];
  }
  fprintf(stderr, "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   1030 <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   1040 <fabs@plt>
movsd  %xmm0,-0xf0(%rbp)
ff
movss  -0x1c(%rbp),%xmm0
call   1040 <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    12b1 <qromb+0x171>
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>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    0xd74(%rip),%rsi
call   1050 <fprintf@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   1030 <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   1040 <fabs@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x8(%rsp),%xmm0
call   1040 <fabs@plt>
mulsd  0xdd6(%rip),%xmm0
ucomisd 0x18(%rsp),%xmm0
jb     1190 <qromb+0x50>
movss  0x8(%rsp),%xmm0
jmp    1256 <qromb+0x116>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
call   1050 <fprintf@plt>
xorps  %xmm0,%xmm0
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.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 = %59, %3
%15 = load i32, i32* %12
%16 = icmp sle i32 %15, 20
br i1 %16, label %17, label %62
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 %47
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 = call i32 @polint(float* %32, float* %36, i32 5, double 0.000000e+00, float* %8, float* %9)
%38 = load float, float* %9
%39 = call double @fabs(float %38)
%40 = load float, float* %8
%41 = call double @fabs(float %40)
%42 = fmul double 0x3EB0C6F7A0B5ED8D, %41
%43 = fcmp ole double %39, %42
br i1 %43, label %44, label %46
44: ; preds = %28
%45 = load float, float* %8
store float %45, float* %4
br label %65
46: ; preds = %28
br label %47
47: ; preds = %46, %17
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [22 x float], [22 x float]* %11, i64 0, i64 %49
%51 = load float, float* %50
%52 = fpext float %51 to double
%53 = fmul double 2.500000e-01, %52
%54 = fptrunc double %53 to float
%55 = load i32, i32* %12
%56 = add nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [22 x float], [22 x float]* %11, i64 0, i64 %57
store float %54, float* %58
br label %59
59: ; preds = %47
%60 = load i32, i32* %12
%61 = add nsw i32 %60, 1
store i32 %61, i32* %12
br label %14
62: ; preds = %14
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store float 0.000000e+00, float* %4
br label %65
65: ; preds = %62, %44
%66 = load float, float* %4
ret float %66
}

LLVM IR (-O2):
@stderr = global i32 0
@.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, %33
%14 = phi i64 [ 1, %3 ], [ %37, %33 ]
%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 %33
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 = call i32 @polint(float* %22, float* %23, i32 5, double 0.000000e+00, float* %4, float* %5)
%25 = load float, float* %5
%26 = call double @fabs(float %25)
%27 = load float, float* %4
%28 = call double @fabs(float %27)
%29 = fmul double %28, 0x3EB0C6F7A0B5ED8D
%30 = fcmp ugt double %26, %29
br i1 %30, label %33, label %31
31: ; preds = %19
%32 = load float, float* %4
br label %43
33: ; preds = %19, %13
%34 = getelementptr inbounds [22 x float], [22 x float]* %7, i64 0, i64 %14
%35 = load float, float* %34
%36 = fmul float %35, 2.500000e-01
%37 = add nuw nsw i64 %14, 1
%38 = getelementptr inbounds [22 x float], [22 x float]* %7, i64 0, i64 %37
store float %36, float* %38
%39 = icmp eq i64 %37, 21
br i1 %39, label %40, label %13
40: ; preds = %33
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %40, %31
%44 = phi float [ %32, %31 ], [ 0.000000e+00, %40 ]
ret float %44
}