#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 f(float);
double fabs(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *);
int main() {
  float a, b, c;
  printf("Enter interval [a,b] : ");
  scanf("%f %f", &a, &b);
  do {
    c = (a + b) / 2;
    if (f(c) * f(a) < 0)
      b = c;
    else if (f(c) * f(a) > 0)
      a = c;
    else
      break;
  } while (fabs(b - a) > 0.0000001);
  printf("Result: %f", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  0xe7d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
mov    %eax,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <f@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
cmp    $0x0,%eax
jge    11c3 <main+0x83>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1204 <main+0xc4>
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
mov    %eax,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <f@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
cmp    $0x0,%eax
jle    11fa <main+0xba>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11ff <main+0xbf>
jmp    122a <main+0xea>
jmp    1204 <main+0xc4>
jmp    1209 <main+0xc9>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
call   1050 <fabs@plt>
movsd  0xde8(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1171 <main+0x31>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1060 <scanf@plt>
jmp    118f <main+0x4f>
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0xc(%rsp)
movss  0x4(%rsp),%xmm1
subss  %xmm1,%xmm0
call   1050 <fabs@plt>
ucomisd 0xe7b(%rip),%xmm0
jbe    11f5 <main+0xb5>
movss  0x4(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
mulss  0xe5d(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
call   1030 <f@plt>
mov    %eax,%ebx
movss  0x4(%rsp),%xmm0
call   1030 <f@plt>
movss  0x8(%rsp),%xmm0
imul   %ebx,%eax
test   %eax,%eax
js     1170 <main+0x30>
call   1030 <f@plt>
mov    %eax,%ebx
movss  0x4(%rsp),%xmm0
call   1030 <f@plt>
imul   %ebx,%eax
test   %eax,%eax
jle    11f5 <main+0xb5>
movss  0x8(%rsp),%xmm1
movss  %xmm1,0x4(%rsp)
movss  0xc(%rsp),%xmm0
jmp    117c <main+0x3c>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Enter interval [a,b] : \00"
@.str.1 = [6 x i8] c"%f %f\00"
@.str.2 = [11 x i8] c"Result: %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3)
br label %7
7: ; preds = %32, %0
%8 = load float, float* %2
%9 = load float, float* %3
%10 = fadd float %8, %9
%11 = fdiv float %10, 2.000000e+00
store float %11, float* %4
%12 = load float, float* %4
%13 = call i32 @f(float %12)
%14 = load float, float* %2
%15 = call i32 @f(float %14)
%16 = mul nsw i32 %13, %15
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %7
%19 = load float, float* %4
store float %19, float* %3
br label %31
20: ; preds = %7
%21 = load float, float* %4
%22 = call i32 @f(float %21)
%23 = load float, float* %2
%24 = call i32 @f(float %23)
%25 = mul nsw i32 %22, %24
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = load float, float* %4
store float %28, float* %2
br label %30
29: ; preds = %20
br label %38
30: ; preds = %27
br label %31
31: ; preds = %30, %18
br label %32
32: ; preds = %31
%33 = load float, float* %3
%34 = load float, float* %2
%35 = fsub float %33, %34
%36 = call double @fabs(float %35)
%37 = fcmp ogt double %36, 0x3E7AD7F29ABCAF48
br i1 %37, label %7, label %38
38: ; preds = %32, %29
%39 = load float, float* %4
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Enter interval [a,b] : \00"
@.str.1 = [6 x i8] c"%f %f\00"
@.str.2 = [11 x i8] c"Result: %f\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2)
br label %7
7: ; preds = %27, %0
%8 = load float, float* %1
%9 = load float, float* %2
%10 = fadd float %8, %9
%11 = fmul float %10, 5.000000e-01
%12 = call i32 @f(float %11)
%13 = load float, float* %1
%14 = call i32 @f(float %13)
%15 = mul nsw i32 %14, %12
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %7
store float %11, float* %2
%18 = load float, float* %1
br label %27
19: ; preds = %7
%20 = call i32 @f(float %11)
%21 = load float, float* %1
%22 = call i32 @f(float %21)
%23 = mul nsw i32 %22, %20
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %19
store float %11, float* %1
%26 = load float, float* %2
br label %27
27: ; preds = %17, %25
%28 = phi float [ %18, %17 ], [ %11, %25 ]
%29 = phi float [ %11, %17 ], [ %26, %25 ]
%30 = fsub float %29, %28
%31 = call double @fabs(float %30)
%32 = fcmp ogt double %31, 0x3E7AD7F29ABCAF48
br i1 %32, label %7, label %33
33: ; preds = %19, %27
%34 = fpext float %11 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %34)
ret i32 0
}