#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 fabs(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *);
int main() {
  float x0, x1, x2, fx0, fx1, fx2;
  do {
    printf("enter x1 & x2 :");
    scanf("%f,%f", &x1, &x2);
    fx1 = x1 * ((2 * x1 - 4) * x1 + 3) - 6;
    fx2 = x2 * ((2 * x2 - 4) * x2 + 3) - 6;
  } while (fx1 * fx2 > 0);
  do {
    x0 = (x1 + x2) / 2;
    fx0 = x0 * ((2 * x0 - 4) * x0 + 3) - 6;
    if ((fx0 * fx1) < 0) {
      x2 = x0;
      fx2 = fx0;
    } else {
      x1 = x0;
      fx1 = fx0;
    }
  } while (fabs(fx0) >= 1e-5);
  printf("x = %6.2f\n", x0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xe91(%rip),%xmm2
addss  %xmm2,%xmm1
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xe78(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xe64(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xe4d(%rip),%xmm2
addss  %xmm2,%xmm1
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xe34(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xe20(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
ja     113f <main+0xf>
jmp    1204 <main+0xd4>
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  0xdf6(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xdd3(%rip),%xmm2
addss  %xmm2,%xmm1
movss  -0x8(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xdba(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xda6(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm1
mulss  -0x18(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    1292 <main+0x162>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    12a6 <main+0x176>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    12ab <main+0x17b>
movss  -0x14(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xd4f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1204 <main+0xd4>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd53(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xf02(%rip),%r14
lea    0xf0b(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm2
movaps %xmm0,%xmm1
unpcklps %xmm2,%xmm1
movaps %xmm1,%xmm3
addps  %xmm1,%xmm3
addps  0xe69(%rip),%xmm3
mulps  %xmm1,%xmm3
addps  0xe6f(%rip),%xmm3
mulps  %xmm1,%xmm3
addps  0xe75(%rip),%xmm3
movaps %xmm3,%xmm1
shufps $0x55,%xmm3,%xmm1
mulss  %xmm3,%xmm1
ucomiss 0xe83(%rip),%xmm1
ja     1160 <main+0x30>
jmp    11e1 <main+0xb1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm2
movaps 0x10(%rsp),%xmm3
addss  %xmm0,%xmm2
mulss  0xe43(%rip),%xmm2
movaps %xmm2,%xmm0
addss  %xmm2,%xmm0
addss  0xe38(%rip),%xmm0
mulss  %xmm2,%xmm0
addss  0xe30(%rip),%xmm0
mulss  %xmm2,%xmm0
addss  0xe28(%rip),%xmm0
movaps %xmm3,%xmm1
mulss  %xmm0,%xmm1
xorps  %xmm4,%xmm4
ucomiss %xmm1,%xmm4
movaps %xmm2,0x20(%rsp)
jbe    1240 <main+0x110>
movaps %xmm3,0x10(%rsp)
movss  %xmm2,0x8(%rsp)
jmp    124e <main+0x11e>
cs nopw 0x0(%rax,%rax,1)
nop
movss  %xmm2,0xc(%rsp)
movaps %xmm0,%xmm1
movaps %xmm0,0x10(%rsp)
call   1040 <fabs@plt>
test   %eax,%eax
jg     11d0 <main+0xa0>
movaps 0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"enter x1 & x2 :\00"
@.str.1 = [6 x i8] c"%f,%f\00"
@.str.2 = [11 x i8] c"x = %6.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
br label %8
8: ; preds = %23, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %3, float* %4)
%11 = load float, float* %3
%12 = load float, float* %3
%13 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %12, float -4.000000e+00)
%14 = load float, float* %3
%15 = call float @llvm.fmuladd.f32(float %13, float %14, float 3.000000e+00)
%16 = call float @llvm.fmuladd.f32(float %11, float %15, float -6.000000e+00)
store float %16, float* %6
%17 = load float, float* %4
%18 = load float, float* %4
%19 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %18, float -4.000000e+00)
%20 = load float, float* %4
%21 = call float @llvm.fmuladd.f32(float %19, float %20, float 3.000000e+00)
%22 = call float @llvm.fmuladd.f32(float %17, float %21, float -6.000000e+00)
store float %22, float* %7
br label %23
23: ; preds = %8
%24 = load float, float* %6
%25 = load float, float* %7
%26 = fmul float %24, %25
%27 = fcmp ogt float %26, 0.000000e+00
br i1 %27, label %8, label %28
28: ; preds = %23
br label %29
29: ; preds = %51, %28
%30 = load float, float* %3
%31 = load float, float* %4
%32 = fadd float %30, %31
%33 = fdiv float %32, 2.000000e+00
store float %33, float* %2
%34 = load float, float* %2
%35 = load float, float* %2
%36 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %35, float -4.000000e+00)
%37 = load float, float* %2
%38 = call float @llvm.fmuladd.f32(float %36, float %37, float 3.000000e+00)
%39 = call float @llvm.fmuladd.f32(float %34, float %38, float -6.000000e+00)
store float %39, float* %5
%40 = load float, float* %5
%41 = load float, float* %6
%42 = fmul float %40, %41
%43 = fcmp olt float %42, 0.000000e+00
br i1 %43, label %44, label %47
44: ; preds = %29
%45 = load float, float* %2
store float %45, float* %4
%46 = load float, float* %5
store float %46, float* %7
br label %50
47: ; preds = %29
%48 = load float, float* %2
store float %48, float* %3
%49 = load float, float* %5
store float %49, float* %6
br label %50
50: ; preds = %47, %44
br label %51
51: ; preds = %50
%52 = load float, float* %5
%53 = call i32 @fabs(float %52)
%54 = sitofp i32 %53 to double
%55 = fcmp oge double %54, 1.000000e-05
br i1 %55, label %29, label %56
56: ; preds = %51
%57 = load float, float* %2
%58 = fpext float %57 to double
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"enter x1 & x2 :\00"
@.str.1 = [6 x i8] c"%f,%f\00"
@.str.2 = [11 x i8] c"x = %6.2f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
br label %5
5: ; preds = %5, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2)
%8 = load float, float* %1
%9 = load float, float* %2
%10 = insertelement <2 x float> poison, float %8, i64 0
%11 = insertelement <2 x float> %10, float %9, i64 1
%12 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %11, <2 x float> <float 2.000000e+00, float 2.000000e+00>, <2 x float> <float -4.000000e+00, float -4.000000e+00>)
%13 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %12, <2 x float> %11, <2 x float> <float 3.000000e+00, float 3.000000e+00>)
%14 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %11, <2 x float> %13, <2 x float> <float -6.000000e+00, float -6.000000e+00>)
%15 = shufflevector <2 x float> %14, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%16 = fmul <2 x float> %14, %15
%17 = extractelement <2 x float> %16, i64 0
%18 = fcmp ogt float %17, 0.000000e+00
br i1 %18, label %5, label %19
19: ; preds = %5
%20 = extractelement <2 x float> %14, i64 0
br label %21
21: ; preds = %19, %38
%22 = phi float [ %40, %38 ], [ %9, %19 ]
%23 = phi float [ %39, %38 ], [ %8, %19 ]
%24 = phi float [ %35, %38 ], [ %20, %19 ]
%25 = fadd float %23, %22
%26 = fmul float %25, 5.000000e-01
%27 = call float @llvm.fmuladd.f32(float %26, float 2.000000e+00, float -4.000000e+00)
%28 = call float @llvm.fmuladd.f32(float %27, float %26, float 3.000000e+00)
%29 = call float @llvm.fmuladd.f32(float %26, float %28, float -6.000000e+00)
%30 = fmul float %24, %29
%31 = fcmp olt float %30, 0.000000e+00
br i1 %31, label %32, label %33
32: ; preds = %21
store float %26, float* %2
br label %34
33: ; preds = %21
store float %26, float* %1
br label %34
34: ; preds = %32, %33
%35 = phi float [ %24, %32 ], [ %29, %33 ]
%36 = call i32 @fabs(float %29)
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load float, float* %1
%40 = load float, float* %2
br label %21
41: ; preds = %34
%42 = fpext float %26 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %42)
ret i32 0
}