#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);
int /*<<< orphan*/ nrerror(char *);
double qromb(double (*funcd)(), double es, double Wind, double AirDens,
             double ZO, double EactAir, double F, double hsalt, double phi_r,
             double ushear, double Zrh, double a, double b) {
  void polint(double xa[], double ya[], int n, double x, double *y, double *dy);
  double trapzd(double (*funcd)(), double es, double Wind, double AirDens,
                double ZO, double EactAir, double F, double hsalt, double phi_r,
                double ushear, double Zrh, double a, double b, int n);
  double ss, dss;
  double s[100 + 1], h[100 + 2];
  int j;
  h[1] = 1.0;
  for (j = 1; j <= 100; j++) {
    s[j] = trapzd(funcd, es, Wind, AirDens, ZO, EactAir, F, hsalt, phi_r,
                  ushear, Zrh, 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    $0x6f0,%rsp
movsd  0x28(%rbp),%xmm8
movsd  0x20(%rbp),%xmm8
movsd  0x18(%rbp),%xmm8
movsd  0x10(%rbp),%xmm8
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
movsd  %xmm5,-0x40(%rbp)
movsd  %xmm6,-0x48(%rbp)
movsd  %xmm7,-0x50(%rbp)
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,-0x6b8(%rbp)
ff
movl   $0x1,-0x6c4(%rbp)
cmpl   $0x64,-0x6c4(%rbp)
jg     12fe <qromb+0x1ce>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
movsd  -0x48(%rbp),%xmm6
movsd  -0x50(%rbp),%xmm7
movsd  0x10(%rbp),%xmm11
movsd  0x18(%rbp),%xmm10
movsd  0x20(%rbp),%xmm9
movsd  0x28(%rbp),%xmm8
mov    -0x6c4(%rbp),%esi
movsd  %xmm11,(%rsp)
movsd  %xmm10,0x8(%rsp)
movsd  %xmm9,0x10(%rsp)
movsd  %xmm8,0x18(%rsp)
call   1040 <trapzd@plt>
movslq -0x6c4(%rbp),%rax
movsd  %xmm0,-0x390(%rbp,%rax,8)
ff ff
cmpl   $0x5,-0x6c4(%rbp)
jl     12be <qromb+0x18e>
mov    -0x6c4(%rbp),%eax
sub    $0x5,%eax
cltq
lea    -0x6c0(%rbp),%rdi
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x6c4(%rbp),%eax
sub    $0x5,%eax
cltq
lea    -0x390(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x5,%edx
xorps  %xmm0,%xmm0
lea    -0x58(%rbp),%rcx
lea    -0x60(%rbp),%r8
call   1050 <polint@plt>
movsd  -0x60(%rbp),%xmm1
movaps 0xda0(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm2
movaps 0xd90(%rip),%xmm0
pand   %xmm0,%xmm2
movsd  0xd6c(%rip),%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     12b9 <qromb+0x189>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1312 <qromb+0x1e2>
jmp    12be <qromb+0x18e>
movslq -0x6c4(%rbp),%rax
movsd  0xd43(%rip),%xmm0
mulsd  -0x6c0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x6c4(%rbp),%eax
add    $0x1,%eax
cltq
movsd  %xmm0,-0x6c0(%rbp,%rax,8)
ff ff
mov    -0x6c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c4(%rbp)
jmp    1199 <qromb+0x69>
lea    0xd2b(%rip),%rdi
call   1030 <nrerror@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x6f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qromb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x6c8,%rsp
movsd  %xmm7,0x58(%rsp)
movsd  %xmm6,0x50(%rsp)
movsd  %xmm5,0x48(%rsp)
movsd  %xmm4,0x40(%rsp)
movsd  %xmm3,0x38(%rsp)
movsd  %xmm2,0x30(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %rdi,%r14
movabs $0x3ff0000000000000,%rax
mov    %rax,0x78(%rsp)
mov    $0x1,%ebx
mov    $0xfffffffc,%r13d
mov    $0x64,%ebp
lea    0x68(%rsp),%r15
lea    0x60(%rsp),%r12
jmp    11c6 <qromb+0x96>
nop
movsd  0x70(%rsp,%rbx,8),%xmm0
mulsd  0xe6a(%rip),%xmm0
movsd  %xmm0,0x78(%rsp,%rbx,8)
add    $0x1,%rbx
add    $0x1,%r13
add    $0xffffffffffffffff,%rbp
je     12ad <qromb+0x17d>
movsd  0x718(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x710(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x708(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x700(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
movsd  0x40(%rsp),%xmm4
movsd  0x48(%rsp),%xmm5
movsd  0x50(%rsp),%xmm6
movsd  0x58(%rsp),%xmm7
mov    %ebx,%esi
call   1040 <trapzd@plt>
movsd  %xmm0,0x3a0(%rsp,%rbx,8)
cmp    $0x5,%rbx
jb     11a0 <qromb+0x70>
mov    %r13d,%eax
shl    $0x3,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x70,%rdi
lea    0x3a0(%rsp,%rax,1),%rsi
xorpd  %xmm0,%xmm0
mov    $0x5,%edx
mov    %r15,%rcx
mov    %r12,%r8
call   1050 <polint@plt>
movsd  0x60(%rsp),%xmm1
movapd 0xd79(%rip),%xmm3
andpd  %xmm3,%xmm1
movsd  0x68(%rsp),%xmm0
movapd %xmm0,%xmm2
andpd  %xmm3,%xmm2
mulsd  0xd6f(%rip),%xmm2
ucomisd %xmm1,%xmm2
jb     11a0 <qromb+0x70>
jmp    12bd <qromb+0x18d>
lea    0xd6c(%rip),%rdi
call   1030 <nrerror@plt>
xorpd  %xmm0,%xmm0
add    $0x6c8,%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 (...)* %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10, double %11, double %12) {
%14 = alloca double
%15 = alloca double (...)*
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca [101 x double]
%31 = alloca [102 x double]
%32 = alloca i32
store double (...)* %0, double (...)** %15
store double %1, double* %16
store double %2, double* %17
store double %3, double* %18
store double %4, double* %19
store double %5, double* %20
store double %6, double* %21
store double %7, double* %22
store double %8, double* %23
store double %9, double* %24
store double %10, double* %25
store double %11, double* %26
store double %12, double* %27
%33 = getelementptr inbounds [102 x double], [102 x double]* %31, i64 0, i64 1
store double 1.000000e+00, double* %33
store i32 1, i32* %32
br label %34
34: ; preds = %86, %13
%35 = load i32, i32* %32
%36 = icmp sle i32 %35, 100
br i1 %36, label %37, label %89
37: ; preds = %34
%38 = load double (...)*, double (...)** %15
%39 = load double, double* %16
%40 = load double, double* %17
%41 = load double, double* %18
%42 = load double, double* %19
%43 = load double, double* %20
%44 = load double, double* %21
%45 = load double, double* %22
%46 = load double, double* %23
%47 = load double, double* %24
%48 = load double, double* %25
%49 = load double, double* %26
%50 = load double, double* %27
%51 = load i32, i32* %32
%52 = call double @trapzd(double (...)* %38, double %39, double %40, double %41, double %42, double %43, double %44, double %45, double %46, double %47, double %48, double %49, double %50, i32 %51)
%53 = load i32, i32* %32
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [101 x double], [101 x double]* %30, i64 0, i64 %54
store double %52, double* %55
%56 = load i32, i32* %32
%57 = icmp sge i32 %56, 5
br i1 %57, label %58, label %76
58: ; preds = %37
%59 = load i32, i32* %32
%60 = sub nsw i32 %59, 5
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [102 x double], [102 x double]* %31, i64 0, i64 %61
%63 = load i32, i32* %32
%64 = sub nsw i32 %63, 5
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [101 x double], [101 x double]* %30, i64 0, i64 %65
%67 = load double, double* %29
%68 = call double @llvm.fabs.f64(double %67)
%69 = load double, double* %28
%70 = call double @llvm.fabs.f64(double %69)
%71 = fmul double 0x3EB0C6F7A0B5ED8D, %70
%72 = fcmp ole double %68, %71
br i1 %72, label %73, label %75
73: ; preds = %58
%74 = load double, double* %28
store double %74, double* %14
br label %91
75: ; preds = %58
br label %76
76: ; preds = %75, %37
%77 = load i32, i32* %32
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [102 x double], [102 x double]* %31, i64 0, i64 %78
%80 = load double, double* %79
%81 = fmul double 2.500000e-01, %80
%82 = load i32, i32* %32
%83 = add nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [102 x double], [102 x double]* %31, i64 0, i64 %84
store double %81, double* %85
br label %86
86: ; preds = %76
%87 = load i32, i32* %32
%88 = add nsw i32 %87, 1
store i32 %88, i32* %32
br label %34
89: ; preds = %34
%90 = call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %14
br label %91
91: ; preds = %89, %73
%92 = load double, double* %14
ret double %92
}

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