#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 */
int /*<<< orphan*/ f(double);
int /*<<< orphan*/ isSmallNumber(int /*<<< orphan*/);
double middleOf(double, double);
scalar_t__ sameSign(int /*<<< orphan*/, int /*<<< orphan*/);
double findRootBetween(double a, double b) {
  double l = a, u = b;
  while (!isSmallNumber(f(middleOf(l, u)))) {
    if (sameSign(f(middleOf(l, u)), f(u)))
      u = middleOf(l, u);
    else
      l = middleOf(l, u);
  }
  return middleOf(l, u);
}


x86 assembly (clang, -O0):
<findRootBetween>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <middleOf@plt>
call   1040 <f@plt>
mov    %eax,%edi
call   1060 <isSmallNumber@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1196 <findRootBetween+0x56>
jmp    11fd <findRootBetween+0xbd>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <middleOf@plt>
call   1040 <f@plt>
mov    %eax,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <f@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1050 <sameSign@plt>
cmp    $0x0,%rax
je     11e4 <findRootBetween+0xa4>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <middleOf@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    11f8 <findRootBetween+0xb8>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <middleOf@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1166 <findRootBetween+0x26>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <middleOf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findRootBetween>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <middleOf@plt>
call   1040 <f@plt>
mov    %eax,%edi
call   1060 <isSmallNumber@plt>
test   %eax,%eax
je     11bd <findRootBetween+0x7d>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
add    $0x20,%rsp
pop    %rbx
jmp    1030 <middleOf@plt>
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
call   1030 <middleOf@plt>
call   1040 <f@plt>
mov    %eax,%edi
call   1060 <isSmallNumber@plt>
test   %eax,%eax
jne    1172 <findRootBetween+0x32>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <middleOf@plt>
call   1040 <f@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
call   1040 <f@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <sameSign@plt>
mov    %rax,%rbx
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <middleOf@plt>
movaps %xmm0,%xmm1
test   %rbx,%rbx
jne    1190 <findRootBetween+0x50>
movaps %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
jmp    119c <findRootBetween+0x5c>

LLVM IR (-O0):
define double @findRootBetween(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store double %1, double* %4
%7 = load double, double* %3
store double %7, double* %5
%8 = load double, double* %4
store double %8, double* %6
br label %9
9: ; preds = %34, %2
%10 = load double, double* %5
%11 = load double, double* %6
%12 = call double @middleOf(double %10, double %11)
%13 = call i32 @f(double %12)
%14 = call i32 @isSmallNumber(i32 %13)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %35
17: ; preds = %9
%18 = load double, double* %5
%19 = load double, double* %6
%20 = call double @middleOf(double %18, double %19)
%21 = call i32 @f(double %20)
%22 = load double, double* %6
%23 = call i32 @f(double %22)
%24 = call i64 @sameSign(i32 %21, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %17
%27 = load double, double* %5
%28 = load double, double* %6
%29 = call double @middleOf(double %27, double %28)
store double %29, double* %6
br label %34
30: ; preds = %17
%31 = load double, double* %5
%32 = load double, double* %6
%33 = call double @middleOf(double %31, double %32)
store double %33, double* %5
br label %34
34: ; preds = %30, %26
br label %9
35: ; preds = %9
%36 = load double, double* %5
%37 = load double, double* %6
%38 = call double @middleOf(double %36, double %37)
ret double %38
}

LLVM IR (-O2):
define double @findRootBetween(double %0, double %1) {
%3 = tail call double @middleOf(double %0, double %1)
%4 = tail call i32 @f(double %3)
%5 = tail call i32 @isSmallNumber(i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %2, %7
%8 = phi double [ %17, %7 ], [ %1, %2 ]
%9 = phi double [ %16, %7 ], [ %0, %2 ]
%10 = tail call double @middleOf(double %9, double %8)
%11 = tail call i32 @f(double %10)
%12 = tail call i32 @f(double %8)
%13 = tail call i64 @sameSign(i32 %11, i32 %12)
%14 = icmp eq i64 %13, 0
%15 = tail call double @middleOf(double %9, double %8)
%16 = select i1 %14, double %15, double %9
%17 = select i1 %14, double %8, double %15
%18 = tail call double @middleOf(double %16, double %17)
%19 = tail call i32 @f(double %18)
%20 = tail call i32 @isSmallNumber(i32 %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %7, label %22
22: ; preds = %7, %2
%23 = phi double [ %0, %2 ], [ %16, %7 ]
%24 = phi double [ %1, %2 ], [ %17, %7 ]
%25 = tail call double @middleOf(double %23, double %24)
ret double %25
}