#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) + 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;
    }
    s[j + 1] = s[j];
    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     12b2 <qromb+0x172>
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
jbe    1243 <qromb+0x103>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12c6 <qromb+0x186>
jmp    1248 <qromb+0x108>
movslq -0xe4(%rbp),%rax
movss  -0x80(%rbp,%rax,4),%xmm0
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
cltq
movss  %xmm0,-0x80(%rbp,%rax,4)
movslq -0xe4(%rbp),%rax
movss  -0xe0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm1
movsd  0xd8e(%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    0xd5f(%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,%r12
movl   $0x3f800000,0x24(%rsp)
3f
mov    $0x1,%ebx
mov    $0xfffffffc,%r13d
mov    $0x14,%ebp
lea    0x8(%rsp),%r14
lea    0x14(%rsp),%r15
jmp    11bf <qromb+0x7f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  %xmm0,0x84(%rsp,%rbx,4)
movss  0x20(%rsp,%rbx,4),%xmm0
mulss  0xe61(%rip),%xmm0
movss  %xmm0,0x24(%rsp,%rbx,4)
add    $0x1,%rbx
add    $0x1,%r13
add    $0xffffffffffffffff,%rbp
je     1248 <qromb+0x108>
mov    %r12,%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
xorps  %xmm0,%xmm0
mov    $0x5,%edx
mov    %r14,%rcx
mov    %r15,%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  0xdce(%rip),%xmm0
ucomisd 0x18(%rsp),%xmm0
ja     1259 <qromb+0x119>
movss  0x80(%rsp,%rbx,4),%xmm0
jmp    1190 <qromb+0x50>
lea    0xdbd(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
jmp    125f <qromb+0x11f>
movss  0x8(%rsp),%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 [22 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 = %66, %3
%15 = load i32, i32* %12
%16 = icmp sle i32 %15, 20
br i1 %16, label %17, label %69
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 [22 x float], [22 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 [22 x float], [22 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 olt 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 %70
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]* %10, i64 0, i64 %48
%50 = load float, float* %49
%51 = load i32, i32* %12
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [22 x float], [22 x float]* %10, i64 0, i64 %53
store float %50, float* %54
%55 = load i32, i32* %12
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [22 x float], [22 x float]* %11, i64 0, i64 %56
%58 = load float, float* %57
%59 = fpext float %58 to double
%60 = fmul double 2.500000e-01, %59
%61 = fptrunc double %60 to float
%62 = load i32, i32* %12
%63 = add nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [22 x float], [22 x float]* %11, i64 0, i64 %64
store float %61, float* %65
br label %66
66: ; preds = %46
%67 = load i32, i32* %12
%68 = add nsw i32 %67, 1
store i32 %68, i32* %12
br label %14
69: ; preds = %14
store float 0.000000e+00, float* %4
br label %70
70: ; preds = %69, %43
%71 = load float, float* %4
ret float %71
}

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 [22 x float]
%7 = alloca [22 x float]
%8 = bitcast float* %4 to i8*
%9 = bitcast float* %5 to i8*
%10 = bitcast [22 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, %34
%14 = phi i64 [ 1, %3 ], [ %36, %34 ]
%15 = trunc i64 %14 to i32
%16 = call float @trapzd(float (float)* %0, float %1, float %2, i32 %15)
%17 = getelementptr inbounds [22 x float], [22 x float]* %6, i64 0, i64 %14
store float %16, float* %17
%18 = icmp ugt i64 %14, 4
br i1 %18, label %19, label %34
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 [22 x float], [22 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 olt double %25, %28
br i1 %29, label %32, label %30
30: ; preds = %19
%31 = load float, float* %17
br label %34
32: ; preds = %19
%33 = load float, float* %4
br label %44
34: ; preds = %30, %13
%35 = phi float [ %31, %30 ], [ %16, %13 ]
%36 = add nuw nsw i64 %14, 1
%37 = getelementptr inbounds [22 x float], [22 x float]* %6, i64 0, i64 %36
store float %35, float* %37
%38 = getelementptr inbounds [22 x float], [22 x float]* %7, i64 0, i64 %14
%39 = load float, float* %38
%40 = fmul float %39, 2.500000e-01
%41 = getelementptr inbounds [22 x float], [22 x float]* %7, i64 0, i64 %36
store float %40, float* %41
%42 = icmp eq i64 %36, 21
br i1 %42, label %43, label %13
43: ; preds = %34
br label %44
44: ; preds = %43, %32
%45 = phi float [ %33, %32 ], [ 0.000000e+00, %43 ]
ret float %45
}