#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 abs(float);
float func(float);
float fpoint() {
  int l = 0, u = 10;
  float mid, f;
  while (l < u) {
    mid = (l + (u - l)) / 2;
    f = func(mid);
    if (abs(f - mid) < 1e-20)
      return mid;
    else {
      if (f > mid)
        u = mid - 1;
      else
        l = mid + 1;
    }
  }
}


x86 assembly (clang, -O0):
<fpoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11eb <fpoint+0xcb>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
call   1040 <func@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
call   1030 <abs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe78(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a1 <fpoint+0x81>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11eb <fpoint+0xcb>
movss  -0x14(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11cd <fpoint+0xad>
movss  -0x10(%rbp),%xmm0
movss  0xe4b(%rip),%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
jmp    11e1 <fpoint+0xc1>
movss  0xe33(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
jmp    11e6 <fpoint+0xc6>
jmp    1136 <fpoint+0x16>
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fpoint>:
push   %rbp
push   %rbx
push   %rax
mov    $0xa,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%rsp)
call   1040 <func@plt>
movss  %xmm0,0x4(%rsp)
subss  (%rsp),%xmm0
call   1030 <abs@plt>
movss  (%rsp),%xmm0
test   %eax,%eax
jle    1194 <fpoint+0x74>
movss  0x4(%rsp),%xmm1
ucomiss %xmm0,%xmm1
movaps %xmm0,%xmm1
addss  0xe89(%rip),%xmm1
cvttss2si %xmm1,%eax
movaps %xmm0,%xmm1
addss  0xe7e(%rip),%xmm1
cvttss2si %xmm1,%ecx
cmova  %eax,%ebx
cmovbe %ecx,%ebp
cmp    %ebx,%ebp
jl     1130 <fpoint+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float @fpoint() {
%1 = alloca float
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 0, i32* %2
store i32 10, i32* %3
br label %6
6: ; preds = %41, %0
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %42
10: ; preds = %6
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = sub nsw i32 %12, %13
%15 = add nsw i32 %11, %14
%16 = sdiv i32 %15, 2
%17 = sitofp i32 %16 to float
store float %17, float* %4
%18 = load float, float* %4
%19 = call float @func(float %18)
store float %19, float* %5
%20 = load float, float* %5
%21 = load float, float* %4
%22 = fsub float %20, %21
%23 = call i32 @abs(float %22)
%24 = sitofp i32 %23 to double
%25 = fcmp olt double %24, 0x3BC79CA10C924223
br i1 %25, label %26, label %28
26: ; preds = %10
%27 = load float, float* %4
store float %27, float* %1
br label %42
28: ; preds = %10
%29 = load float, float* %5
%30 = load float, float* %4
%31 = fcmp ogt float %29, %30
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load float, float* %4
%34 = fsub float %33, 1.000000e+00
%35 = fptosi float %34 to i32
store i32 %35, i32* %3
br label %40
36: ; preds = %28
%37 = load float, float* %4
%38 = fadd float %37, 1.000000e+00
%39 = fptosi float %38 to i32
store i32 %39, i32* %2
br label %40
40: ; preds = %36, %32
br label %41
41: ; preds = %40
br label %6
42: ; preds = %26, %6
%43 = load float, float* %1
ret float %43
}

LLVM IR (-O2):
define float @fpoint() {
br label %1
1: ; preds = %0, %10
%2 = phi i32 [ 0, %0 ], [ %17, %10 ]
%3 = phi i32 [ 10, %0 ], [ %16, %10 ]
%4 = sdiv i32 %3, 2
%5 = sitofp i32 %4 to float
%6 = tail call float @func(float %5)
%7 = fsub float %6, %5
%8 = tail call i32 @abs(float %7)
%9 = icmp slt i32 %8, 1
br i1 %9, label %19, label %10
10: ; preds = %1
%11 = fcmp ogt float %6, %5
%12 = fadd float %5, -1.000000e+00
%13 = fptosi float %12 to i32
%14 = fadd float %5, 1.000000e+00
%15 = fptosi float %14 to i32
%16 = select i1 %11, i32 %13, i32 %3
%17 = select i1 %11, i32 %2, i32 %15
%18 = icmp slt i32 %17, %16
br i1 %18, label %1, label %19
19: ; preds = %10, %1
ret float %5
}