#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__ fuzzyEquals(double, double);
double getValue(double *, size_t, double);
double getXRange(double *equation, size_t degree, double a, double b) {
  double mid = (a + b) / 2.0;
  if (getValue(equation, degree, mid) == 0.0 || fuzzyEquals(a, b))
    return mid;
  if (getValue(equation, degree, a) * getValue(equation, degree, mid) < 0.0)
    return getXRange(equation, degree, a, mid);
  return getXRange(equation, degree, mid, b);
}


x86 assembly (clang, -O0):
<getXRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xea4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x30(%rbp),%xmm0
call   1040 <getValue@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    118f <getXRange+0x5f>
jp     118f <getXRange+0x5f>
jmp    11a8 <getXRange+0x78>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1050 <fuzzyEquals@plt>
cmp    $0x0,%rax
je     11b7 <getXRange+0x87>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1233 <getXRange+0x103>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
call   1040 <getValue@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x30(%rbp),%xmm0
call   1040 <getValue@plt>
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1217 <getXRange+0xe7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1030 <getXRange@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1233 <getXRange+0x103>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <getXRange@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getXRange>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movapd %xmm0,0x20(%rsp)
movsd  %xmm1,(%rsp)
addsd  %xmm1,%xmm0
mulsd  0xebc(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
call   1030 <getValue@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1168 <getXRange+0x48>
jp     1168 <getXRange+0x48>
movaps 0x10(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret
movsd  (%rsp),%xmm1
jmp    11c8 <getXRange+0xa8>
nop
movsd  %xmm2,0x8(%rsp)
cmpltsd %xmm1,%xmm0
movapd 0x20(%rsp),%xmm1
andpd  %xmm0,%xmm1
andnpd 0x10(%rsp),%xmm0
orpd   %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movapd %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  0xe5b(%rip),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
movapd %xmm0,0x10(%rsp)
call   1030 <getValue@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
jne    11c8 <getXRange+0xa8>
jnp    115b <getXRange+0x3b>
movaps 0x20(%rsp),%xmm0
movsd  %xmm1,(%rsp)
call   1040 <fuzzyEquals@plt>
test   %rax,%rax
jne    115b <getXRange+0x3b>
mov    %rbx,%rdi
mov    %r14,%rsi
movaps 0x20(%rsp),%xmm0
call   1030 <getValue@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
movapd 0x10(%rsp),%xmm0
call   1030 <getValue@plt>
mulsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
movapd 0x10(%rsp),%xmm2
ja     1170 <getXRange+0x50>
movsd  (%rsp),%xmm2
jmp    1170 <getXRange+0x50>

LLVM IR (-O0):
define double @getXRange(double* %0, i64 %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca i64
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %6
store i64 %1, i64* %7
store double %2, double* %8
store double %3, double* %9
%11 = load double, double* %8
%12 = load double, double* %9
%13 = fadd double %11, %12
%14 = fdiv double %13, 2.000000e+00
store double %14, double* %10
%15 = load double*, double** %6
%16 = load i64, i64* %7
%17 = load double, double* %10
%18 = call double @getValue(double* %15, i64 %16, double %17)
%19 = fcmp oeq double %18, 0.000000e+00
br i1 %19, label %25, label %20
20: ; preds = %4
%21 = load double, double* %8
%22 = load double, double* %9
%23 = call i64 @fuzzyEquals(double %21, double %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20, %4
%26 = load double, double* %10
store double %26, double* %5
br label %50
27: ; preds = %20
%28 = load double*, double** %6
%29 = load i64, i64* %7
%30 = load double, double* %8
%31 = call double @getValue(double* %28, i64 %29, double %30)
%32 = load double*, double** %6
%33 = load i64, i64* %7
%34 = load double, double* %10
%35 = call double @getValue(double* %32, i64 %33, double %34)
%36 = fmul double %31, %35
%37 = fcmp olt double %36, 0.000000e+00
br i1 %37, label %38, label %44
38: ; preds = %27
%39 = load double*, double** %6
%40 = load i64, i64* %7
%41 = load double, double* %8
%42 = load double, double* %10
%43 = call double @getXRange(double* %39, i64 %40, double %41, double %42)
store double %43, double* %5
br label %50
44: ; preds = %27
%45 = load double*, double** %6
%46 = load i64, i64* %7
%47 = load double, double* %10
%48 = load double, double* %9
%49 = call double @getXRange(double* %45, i64 %46, double %47, double %48)
store double %49, double* %5
br label %50
50: ; preds = %44, %38, %25
%51 = load double, double* %5
ret double %51
}

LLVM IR (-O2):
define double @getXRange(double* %0, i64 %1, double %2, double %3) {
%5 = fadd double %2, %3
%6 = fmul double %5, 5.000000e-01
%7 = tail call double @getValue(double* %0, i64 %1, double %6)
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %26, label %9
9: ; preds = %4, %15
%10 = phi double [ %23, %15 ], [ %6, %4 ]
%11 = phi double [ %21, %15 ], [ %3, %4 ]
%12 = phi double [ %20, %15 ], [ %2, %4 ]
%13 = tail call i64 @fuzzyEquals(double %12, double %11)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %9
%16 = tail call double @getValue(double* %0, i64 %1, double %12)
%17 = tail call double @getValue(double* %0, i64 %1, double %10)
%18 = fmul double %16, %17
%19 = fcmp olt double %18, 0.000000e+00
%20 = select i1 %19, double %12, double %10
%21 = select i1 %19, double %10, double %11
%22 = fadd double %20, %21
%23 = fmul double %22, 5.000000e-01
%24 = tail call double @getValue(double* %0, i64 %1, double %23)
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %26, label %9
26: ; preds = %9, %15, %4
%27 = phi double [ %6, %4 ], [ %23, %15 ], [ %10, %9 ]
ret double %27
}