#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);
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 * f(b) - b * f(a)) / (f(b) - f(a));
    if (f(c) * f(a) < 0)
      b = c;
    else if (f(c) * f(a) > 0)
      a = c;
    else
      break;
  } while (fabs(b - a) > 0.000001);
  printf("Result: %f", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <f@plt>
movss  -0x28(%rbp),%xmm1
movss  -0x24(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x20(%rbp),%xmm0
mulss  %xmm3,%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <f@plt>
movss  -0x1c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x18(%rbp),%xmm0
subss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <f@plt>
movss  -0x14(%rbp),%xmm1
mulss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    123e <main+0xfe>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1288 <main+0x148>
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <f@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
mulss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    127e <main+0x13e>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1283 <main+0x143>
jmp    12ae <main+0x16e>
jmp    1288 <main+0x148>
jmp    128d <main+0x14d>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
call   1050 <fabs@plt>
movsd  0xd5c(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1171 <main+0x31>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd68(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1060 <scanf@plt>
jmp    1199 <main+0x59>
nopw   0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm1
subss  %xmm1,%xmm0
call   1050 <fabs@plt>
ucomisd 0xe6d(%rip),%xmm0
jbe    1289 <main+0x149>
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <f@plt>
movss  %xmm0,0x4(%rsp)
movss  0x10(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <f@plt>
mulss  0x14(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
mulss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <f@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <f@plt>
movss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
call   1030 <f@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <f@plt>
mulss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1170 <main+0x30>
movss  0x4(%rsp),%xmm0
call   1030 <f@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <f@plt>
mulss  0x8(%rsp),%xmm0
ucomiss 0xd98(%rip),%xmm0
jbe    1289 <main+0x149>
movss  0x4(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
movss  0x10(%rsp),%xmm0
jmp    1182 <main+0x42>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd90(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
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 = %43, %0
%8 = load float, float* %2
%9 = load float, float* %3
%10 = call float @f(float %9)
%11 = load float, float* %3
%12 = load float, float* %2
%13 = call float @f(float %12)
%14 = fmul float %11, %13
%15 = fneg float %14
%16 = call float @llvm.fmuladd.f32(float %8, float %10, float %15)
%17 = load float, float* %3
%18 = call float @f(float %17)
%19 = load float, float* %2
%20 = call float @f(float %19)
%21 = fsub float %18, %20
%22 = fdiv float %16, %21
store float %22, float* %4
%23 = load float, float* %4
%24 = call float @f(float %23)
%25 = load float, float* %2
%26 = call float @f(float %25)
%27 = fmul float %24, %26
%28 = fcmp olt float %27, 0.000000e+00
br i1 %28, label %29, label %31
29: ; preds = %7
%30 = load float, float* %4
store float %30, float* %3
br label %42
31: ; preds = %7
%32 = load float, float* %4
%33 = call float @f(float %32)
%34 = load float, float* %2
%35 = call float @f(float %34)
%36 = fmul float %33, %35
%37 = fcmp ogt float %36, 0.000000e+00
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = load float, float* %4
store float %39, float* %2
br label %41
40: ; preds = %31
br label %49
41: ; preds = %38
br label %42
42: ; preds = %41, %29
br label %43
43: ; preds = %42
%44 = load float, float* %3
%45 = load float, float* %2
%46 = fsub float %44, %45
%47 = call double @fabs(float %46)
%48 = fcmp ogt double %47, 0x3EB0C6F7A0B5ED8D
br i1 %48, label %7, label %49
49: ; preds = %43, %40
%50 = load float, float* %4
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %51)
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 = %38, %0
%8 = load float, float* %1
%9 = load float, float* %2
%10 = call float @f(float %9)
%11 = load float, float* %2
%12 = load float, float* %1
%13 = call float @f(float %12)
%14 = fneg float %11
%15 = fmul float %13, %14
%16 = call float @llvm.fmuladd.f32(float %8, float %10, float %15)
%17 = load float, float* %2
%18 = call float @f(float %17)
%19 = load float, float* %1
%20 = call float @f(float %19)
%21 = fsub float %18, %20
%22 = fdiv float %16, %21
%23 = call float @f(float %22)
%24 = load float, float* %1
%25 = call float @f(float %24)
%26 = fmul float %23, %25
%27 = fcmp olt float %26, 0.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %7
store float %22, float* %2
%29 = load float, float* %1
br label %38
30: ; preds = %7
%31 = call float @f(float %22)
%32 = load float, float* %1
%33 = call float @f(float %32)
%34 = fmul float %31, %33
%35 = fcmp ogt float %34, 0.000000e+00
br i1 %35, label %36, label %44
36: ; preds = %30
store float %22, float* %1
%37 = load float, float* %2
br label %38
38: ; preds = %28, %36
%39 = phi float [ %29, %28 ], [ %22, %36 ]
%40 = phi float [ %22, %28 ], [ %37, %36 ]
%41 = fsub float %40, %39
%42 = call double @fabs(float %41)
%43 = fcmp ogt double %42, 0x3EB0C6F7A0B5ED8D
br i1 %43, label %7, label %44
44: ; preds = %30, %38
%45 = fpext float %22 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %45)
ret i32 0
}