#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 */
double fabs(float);
int /*<<< orphan*/ printf(char *, float);
void main() {
  float x1 = 1, x2 = 10, x;
  float y1, y2, y, max;
  float getmiddle(float, float);
  float getval(float);
  do {
    x = getmiddle(x1, x2);
    y = getval(x);
    y1 = getval(x1);
    y2 = getval(x2);
    if ((y * y1 > 0))
      x1 = x;
    if ((y * y2 > 0))
      x2 = x;
  } while (fabs(y) > 0.0001);
  printf("A root of equation is %8.4f", x);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  0xeb4(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xea3(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1060 <getmiddle@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <getval@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <getval@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <getval@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11c3 <main+0x83>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11e3 <main+0xa3>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11e8 <main+0xa8>
movss  -0x18(%rbp),%xmm0
call   1050 <fabs@plt>
movsd  0xe0e(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1162 <main+0x22>
movss  -0xc(%rbp),%xmm0
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
movss  0xeb4(%rip),%xmm0
movss  0xeb0(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movaps %xmm0,0x10(%rsp)
movaps %xmm1,0x20(%rsp)
call   1060 <getmiddle@plt>
movaps %xmm0,0x30(%rsp)
call   1030 <getval@plt>
movss  %xmm0,0xc(%rsp)
movaps 0x10(%rsp),%xmm0
call   1030 <getval@plt>
movss  %xmm0,0x8(%rsp)
movaps 0x20(%rsp),%xmm0
call   1030 <getval@plt>
movss  0xc(%rsp),%xmm2
movss  0x8(%rsp),%xmm1
mulss  %xmm2,%xmm1
xorps  %xmm4,%xmm4
cmpltss %xmm1,%xmm4
movaps %xmm4,%xmm1
movaps 0x30(%rsp),%xmm3
andps  %xmm3,%xmm1
andnps 0x10(%rsp),%xmm4
orps   %xmm1,%xmm4
movaps %xmm4,0x10(%rsp)
mulss  %xmm2,%xmm0
xorps  %xmm4,%xmm4
cmpltss %xmm0,%xmm4
movaps %xmm4,%xmm0
andps  %xmm3,%xmm0
andnps 0x20(%rsp),%xmm4
orps   %xmm0,%xmm4
movaps %xmm4,0x20(%rsp)
movaps %xmm2,%xmm0
call   1050 <fabs@plt>
ucomisd 0xe10(%rip),%xmm0
movaps 0x20(%rsp),%xmm1
movaps 0x10(%rsp),%xmm0
ja     1160 <main+0x20>
lea    0xe01(%rip),%rdi
movaps 0x30(%rsp),%xmm0
add    $0x48,%rsp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"A root of equation is %8.4f\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float 1.000000e+00, float* %1
store float 1.000000e+01, float* %2
br label %8
8: ; preds = %32, %0
%9 = load float, float* %1
%10 = load float, float* %2
%11 = call float @getmiddle(float %9, float %10)
store float %11, float* %3
%12 = load float, float* %3
%13 = call float @getval(float %12)
store float %13, float* %6
%14 = load float, float* %1
%15 = call float @getval(float %14)
store float %15, float* %4
%16 = load float, float* %2
%17 = call float @getval(float %16)
store float %17, float* %5
%18 = load float, float* %6
%19 = load float, float* %4
%20 = fmul float %18, %19
%21 = fcmp ogt float %20, 0.000000e+00
br i1 %21, label %22, label %24
22: ; preds = %8
%23 = load float, float* %3
store float %23, float* %1
br label %24
24: ; preds = %22, %8
%25 = load float, float* %6
%26 = load float, float* %5
%27 = fmul float %25, %26
%28 = fcmp ogt float %27, 0.000000e+00
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = load float, float* %3
store float %30, float* %2
br label %31
31: ; preds = %29, %24
br label %32
32: ; preds = %31
%33 = load float, float* %6
%34 = call double @fabs(float %33)
%35 = fcmp ogt double %34, 1.000000e-04
br i1 %35, label %8, label %36
36: ; preds = %32
%37 = load float, float* %3
%38 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), float %37)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"A root of equation is %8.4f\00"
define void @main() {
br label %1
1: ; preds = %1, %0
%2 = phi float [ 1.000000e+01, %0 ], [ %13, %1 ]
%3 = phi float [ 1.000000e+00, %0 ], [ %10, %1 ]
%4 = tail call float @getmiddle(float %3, float %2)
%5 = tail call float @getval(float %4)
%6 = tail call float @getval(float %3)
%7 = tail call float @getval(float %2)
%8 = fmul float %5, %6
%9 = fcmp ogt float %8, 0.000000e+00
%10 = select i1 %9, float %4, float %3
%11 = fmul float %5, %7
%12 = fcmp ogt float %11, 0.000000e+00
%13 = select i1 %12, float %4, float %2
%14 = tail call double @fabs(float %5)
%15 = fcmp ogt double %14, 1.000000e-04
br i1 %15, label %1, label %16
16: ; preds = %1
%17 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), float %4)
ret void
}