#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 */
float f(float);
double fabs(float);
float xpoint(float, float);
float root(float x1, float x2) {
  float x, y, y1, y2;
  y1 = f(x1);
  y2 = f(x2);
  do {
    x = xpoint(x1, x2);
    y = f(x);
    if (y * y1 > 0) {
      y1 = y;
      x1 = x;
    } else {
      x2 = x;
      y2 = y;
    }
  } while (fabs(y) >= 0.0001);
  return x;
}


x86 assembly (clang, -O0):
<root>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <f@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <f@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1050 <xpoint@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11b2 <root+0x82>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c6 <root+0x96>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11cb <root+0x9b>
movss  -0x10(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  0xe23(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1160 <root+0x30>
movss  -0xc(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<root>:
sub    $0x38,%rsp
movaps %xmm1,0x10(%rsp)
movss  %xmm0,0x8(%rsp)
call   1030 <f@plt>
movss  %xmm0,0xc(%rsp)
movaps 0x10(%rsp),%xmm0
call   1030 <f@plt>
movss  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
jmp    11b1 <root+0x81>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm4,0x8(%rsp)
movss  %xmm5,0xc(%rsp)
xorps  %xmm3,%xmm3
cmpltss %xmm1,%xmm3
movaps %xmm3,%xmm1
andnps %xmm2,%xmm1
andps  0x10(%rsp),%xmm3
orps   %xmm1,%xmm3
movaps %xmm3,0x10(%rsp)
call   1040 <fabs@plt>
ucomisd 0xe5c(%rip),%xmm0
movaps 0x10(%rsp),%xmm1
movss  0x8(%rsp),%xmm0
jb     11fa <root+0xca>
movss  %xmm0,0x8(%rsp)
movaps %xmm1,0x10(%rsp)
call   1050 <xpoint@plt>
movaps %xmm0,0x20(%rsp)
call   1030 <f@plt>
movaps 0x20(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm1
mulss  %xmm0,%xmm1
ucomiss 0xe24(%rip),%xmm1
movaps %xmm2,%xmm4
movaps %xmm0,%xmm5
ja     1170 <root+0x40>
movss  0x8(%rsp),%xmm4
movaps %xmm3,%xmm5
jmp    1170 <root+0x40>
movaps 0x20(%rsp),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define float @root(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %3
store float %1, float* %4
%9 = load float, float* %3
%10 = call float @f(float %9)
store float %10, float* %7
%11 = load float, float* %4
%12 = call float @f(float %11)
store float %12, float* %8
br label %13
13: ; preds = %30, %2
%14 = load float, float* %3
%15 = load float, float* %4
%16 = call float @xpoint(float %14, float %15)
store float %16, float* %5
%17 = load float, float* %5
%18 = call float @f(float %17)
store float %18, float* %6
%19 = load float, float* %6
%20 = load float, float* %7
%21 = fmul float %19, %20
%22 = fcmp ogt float %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %13
%24 = load float, float* %6
store float %24, float* %7
%25 = load float, float* %5
store float %25, float* %3
br label %29
26: ; preds = %13
%27 = load float, float* %5
store float %27, float* %4
%28 = load float, float* %6
store float %28, float* %8
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %29
%31 = load float, float* %6
%32 = call double @fabs(float %31)
%33 = fcmp oge double %32, 1.000000e-04
br i1 %33, label %13, label %34
34: ; preds = %30
%35 = load float, float* %5
ret float %35
}

LLVM IR (-O2):
define float @root(float %0, float %1) {
%3 = tail call float @f(float %0)
%4 = tail call float @f(float %1)
br label %5
5: ; preds = %5, %2
%6 = phi float [ %1, %2 ], [ %13, %5 ]
%7 = phi float [ %0, %2 ], [ %14, %5 ]
%8 = phi float [ %3, %2 ], [ %15, %5 ]
%9 = tail call float @xpoint(float %7, float %6)
%10 = tail call float @f(float %9)
%11 = fmul float %8, %10
%12 = fcmp ogt float %11, 0.000000e+00
%13 = select i1 %12, float %6, float %9
%14 = select i1 %12, float %9, float %7
%15 = select i1 %12, float %10, float %8
%16 = tail call double @fabs(float %10)
%17 = fcmp ult double %16, 1.000000e-04
br i1 %17, label %18, label %5
18: ; preds = %5
ret float %9
}