#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 */
scalar_t__ fabs(double);
double stub1(double);
double stub2(double);
double stub3(double);
double stub4(double);
int zbrac(double (*func)(double), double *x1, double *x2) {
  void nrerror(char error_text[]);
  int j;
  double f1, f2;
  if (*x1 == *x2)
    nrerror("Bad initial range in zbrac");
  f1 = (*func)(*x1);
  f2 = (*func)(*x2);
  for (j = 1; j <= 50; j++) {
    if (f1 * f2 < 0.0)
      return 1;
    if (fabs(f1) < fabs(f2))
      f1 = (*func)(*x1 += 1.6 * (*x1 - *x2));
    else
      f2 = (*func)(*x2 += 1.6 * (*x2 - *x1));
  }
  return 0;
}


x86 assembly (clang, -O0):
<zbrac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
ucomisd (%rax),%xmm0
jne    115c <zbrac+0x3c>
jp     115c <zbrac+0x3c>
lea    0xeb1(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  (%rcx),%xmm0
call   *%rax
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rcx),%xmm0
call   *%rax
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x32,-0x24(%rbp)
jg     1264 <zbrac+0x144>
movsd  -0x30(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11b6 <zbrac+0x96>
movl   $0x1,-0x4(%rbp)
jmp    126b <zbrac+0x14b>
movsd  -0x30(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %rax,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jge    121a <zbrac+0xfa>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  (%rcx),%xmm0
mov    -0x20(%rbp),%rcx
subsd  (%rcx),%xmm0
mov    -0x18(%rbp),%rcx
movsd  (%rcx),%xmm1
movsd  0xdfe(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx)
call   *%rax
movsd  %xmm0,-0x30(%rbp)
jmp    1251 <zbrac+0x131>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rcx),%xmm0
mov    -0x18(%rbp),%rcx
subsd  (%rcx),%xmm0
mov    -0x20(%rbp),%rcx
movsd  (%rcx),%xmm1
movsd  0xdc2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx)
call   *%rax
movsd  %xmm0,-0x38(%rbp)
jmp    1256 <zbrac+0x136>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1189 <zbrac+0x69>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zbrac>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
movsd  (%rsi),%xmm0
ucomisd (%rdx),%xmm0
jne    1152 <zbrac+0x32>
jp     1152 <zbrac+0x32>
lea    0xec8(%rip),%rdi
call   1030 <nrerror@plt>
movsd  (%r14),%xmm0
call   *%r15
movsd  %xmm0,(%rsp)
movsd  (%r12),%xmm0
call   *%r15
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm3
mov    $0x32,%ebp
jmp    11b2 <zbrac+0x92>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r12),%xmm1
movapd %xmm1,%xmm0
subsd  (%r14),%xmm0
mulsd  0xe69(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r12)
call   *%r15
movapd %xmm0,%xmm3
movsd  (%rsp),%xmm2
add    $0xffffffff,%ebp
je     121d <zbrac+0xfd>
movapd %xmm2,%xmm0
mulsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1221 <zbrac+0x101>
movapd %xmm2,%xmm0
movsd  %xmm2,(%rsp)
movsd  %xmm3,0x8(%rsp)
call   1040 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1040 <fabs@plt>
cmp    %rax,%rbx
jge    1180 <zbrac+0x60>
movsd  (%r14),%xmm1
movapd %xmm1,%xmm0
subsd  (%r12),%xmm0
mulsd  0xdfe(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
call   *%r15
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm3
add    $0xffffffff,%ebp
jne    11b2 <zbrac+0x92>
xor    %eax,%eax
jmp    1226 <zbrac+0x106>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Bad initial range in zbrac\00"
define i32 @zbrac(double (double)* %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double (double)*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store double (double)* %0, double (double)** %5
store double* %1, double** %6
store double* %2, double** %7
%11 = load double*, double** %6
%12 = load double, double* %11
%13 = load double*, double** %7
%14 = load double, double* %13
%15 = fcmp oeq double %12, %14
br i1 %15, label %16, label %17
16: ; preds = %3
br label %17
17: ; preds = %16, %3
%18 = load double (double)*, double (double)** %5
%19 = load double*, double** %6
%20 = load double, double* %19
%21 = call double %18(double %20)
store double %21, double* %9
%22 = load double (double)*, double (double)** %5
%23 = load double*, double** %7
%24 = load double, double* %23
%25 = call double %22(double %24)
store double %25, double* %10
store i32 1, i32* %8
br label %26
26: ; preds = %64, %17
%27 = load i32, i32* %8
%28 = icmp sle i32 %27, 50
br i1 %28, label %29, label %67
29: ; preds = %26
%30 = load double, double* %9
%31 = load double, double* %10
%32 = fmul double %30, %31
%33 = fcmp olt double %32, 0.000000e+00
br i1 %33, label %34, label %35
34: ; preds = %29
store i32 1, i32* %4
br label %68
35: ; preds = %29
%36 = load double, double* %9
%37 = call i64 @fabs(double %36)
%38 = load double, double* %10
%39 = call i64 @fabs(double %38)
%40 = icmp slt i64 %37, %39
br i1 %40, label %41, label %52
41: ; preds = %35
%42 = load double (double)*, double (double)** %5
%43 = load double*, double** %6
%44 = load double, double* %43
%45 = load double*, double** %7
%46 = load double, double* %45
%47 = fsub double %44, %46
%48 = load double*, double** %6
%49 = load double, double* %48
%50 = call double @llvm.fmuladd.f64(double 1.600000e+00, double %47, double %49)
store double %50, double* %48
%51 = call double %42(double %50)
store double %51, double* %9
br label %63
52: ; preds = %35
%53 = load double (double)*, double (double)** %5
%54 = load double*, double** %7
%55 = load double, double* %54
%56 = load double*, double** %6
%57 = load double, double* %56
%58 = fsub double %55, %57
%59 = load double*, double** %7
%60 = load double, double* %59
%61 = call double @llvm.fmuladd.f64(double 1.600000e+00, double %58, double %60)
store double %61, double* %59
%62 = call double %53(double %61)
store double %62, double* %10
br label %63
63: ; preds = %52, %41
br label %64
64: ; preds = %63
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
br label %26
67: ; preds = %26
store i32 0, i32* %4
br label %68
68: ; preds = %67, %34
%69 = load i32, i32* %4
ret i32 %69
}

LLVM IR (-O2):
@.str = [27 x i8] c"Bad initial range in zbrac\00"
define i32 @zbrac(double (double)* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = load double, double* %1
%5 = load double, double* %2
%6 = fcmp oeq double %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
tail call void @nrerror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = load double, double* %1
br label %9
9: ; preds = %7, %3
%10 = phi double [ %8, %7 ], [ %4, %3 ]
%11 = tail call double %0(double %10)
%12 = load double, double* %2
%13 = tail call double %0(double %12)
br label %14
14: ; preds = %9, %36
%15 = phi double [ %13, %9 ], [ %38, %36 ]
%16 = phi double [ %11, %9 ], [ %37, %36 ]
%17 = phi i32 [ 1, %9 ], [ %39, %36 ]
%18 = fmul double %16, %15
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %41, label %20
20: ; preds = %14
%21 = tail call i64 @fabs(double %16)
%22 = tail call i64 @fabs(double %15)
%23 = icmp slt i64 %21, %22
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load double, double* %1
%26 = load double, double* %2
%27 = fsub double %25, %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double 1.600000e+00, double %25)
store double %28, double* %1
%29 = tail call double %0(double %28)
br label %36
30: ; preds = %20
%31 = load double, double* %2
%32 = load double, double* %1
%33 = fsub double %31, %32
%34 = tail call double @llvm.fmuladd.f64(double %33, double 1.600000e+00, double %31)
store double %34, double* %2
%35 = tail call double %0(double %34)
br label %36
36: ; preds = %24, %30
%37 = phi double [ %29, %24 ], [ %16, %30 ]
%38 = phi double [ %15, %24 ], [ %35, %30 ]
%39 = add nuw nsw i32 %17, 1
%40 = icmp eq i32 %39, 51
br i1 %40, label %41, label %14
41: ; preds = %36, %14
%42 = phi i32 [ 1, %14 ], [ 0, %36 ]
ret i32 %42
}