#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 f(double);
double mod(double);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  double lowerPoint = 0;
  double upperPoint = 3.14159265;
  double root;
  double tempRoot = 3 * 3.14159265;
  int i = 0;
  printf("i\tlowerpoint\tupperpoint\troot\t\t|root-temproot|\n");
  while (1) {
    root = ((lowerPoint * f(upperPoint)) - (upperPoint * f(lowerPoint))) /
           (f(upperPoint) - f(lowerPoint));
    if (f(root) == 0 || mod(root - tempRoot) < 0.0000001)
      break;
    if (f(lowerPoint) * f(root) < 0)
      upperPoint = root;
    else
      lowerPoint = root;
    printf("%d\t%lf\t%f\t%f\t%f\n", i++, lowerPoint, upperPoint, root,
           mod(root - tempRoot));
    tempRoot = root;
  }
  printf("Final Answer:%f", root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <f@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <f@plt>
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <f@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <f@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <f@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1235 <main+0x105>
jp     1235 <main+0x105>
jmp    1259 <main+0x129>
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1030 <mod@plt>
movaps %xmm0,%xmm1
movsd  0xdc1(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    125e <main+0x12e>
jmp    1311 <main+0x1e1>
movsd  -0x10(%rbp),%xmm0
call   1040 <f@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <f@plt>
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    129c <main+0x16c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12a6 <main+0x176>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1030 <mod@plt>
mov    -0x7c(%rbp),%esi
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x68(%rbp),%xmm0
lea    0xd4c(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1179 <main+0x49>
movsd  -0x20(%rbp),%xmm0
lea    0xd3b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xef2(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0xe9c(%rip),%xmm0
lea    0xead(%rip),%r14
xorps  %xmm1,%xmm1
movaps %xmm1,0x30(%rsp)
jmp    11e2 <main+0xa2>
nopl   (%rax)
movsd  %xmm3,0x8(%rsp)
cmpltsd %xmm1,%xmm0
movapd 0x30(%rsp),%xmm1
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm0,%xmm1
movapd %xmm1,0x30(%rsp)
lea    0x1(%rbx),%ebp
movaps 0x40(%rsp),%xmm0
call   1030 <mod@plt>
movaps %xmm0,%xmm3
mov    %r14,%rdi
mov    %ebx,%esi
movaps 0x30(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movaps 0x10(%rsp),%xmm2
mov    $0x4,%al
call   1060 <printf@plt>
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movsd  %xmm1,0x28(%rsp)
mov    %ebp,%ebx
movsd  %xmm0,0x8(%rsp)
call   1050 <f@plt>
movaps %xmm0,0x10(%rsp)
movapd 0x30(%rsp),%xmm0
call   1050 <f@plt>
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm0
movapd 0x10(%rsp),%xmm1
mulsd  0x30(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm2,%xmm0
call   1050 <f@plt>
movsd  %xmm0,0x40(%rsp)
movapd 0x30(%rsp),%xmm0
call   1050 <f@plt>
movsd  0x40(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd 0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
call   1050 <f@plt>
ucomisd 0xdba(%rip),%xmm0
jne    1262 <main+0x122>
jnp    12cb <main+0x18b>
movapd 0x10(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
movapd %xmm0,0x40(%rsp)
call   1030 <mod@plt>
movsd  0xd8f(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     12cb <main+0x18b>
movaps 0x30(%rsp),%xmm0
call   1050 <f@plt>
movsd  %xmm0,0x28(%rsp)
movapd 0x10(%rsp),%xmm0
call   1050 <f@plt>
mulsd  0x28(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm3
ja     1180 <main+0x40>
movsd  0x8(%rsp),%xmm3
jmp    1180 <main+0x40>
lea    0xd5f(%rip),%rdi
movaps 0x10(%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"i\09lowerpoint\09upperpoint\09root\09\09|root-temproot|\0A\00"
@.str.1 = [17 x i8] c"%d\09%lf\09%f\09%f\09%f\0A\00"
@.str.2 = [16 x i8] c"Final Answer:%f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 0x400921FB53C8D4F1, double* %3
store double 0x4022D97C7ED69FB5, double* %5
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %0, %45
%9 = load double, double* %2
%10 = load double, double* %3
%11 = call double @f(double %10)
%12 = load double, double* %3
%13 = load double, double* %2
%14 = call double @f(double %13)
%15 = fmul double %12, %14
%16 = fneg double %15
%17 = call double @llvm.fmuladd.f64(double %9, double %11, double %16)
%18 = load double, double* %3
%19 = call double @f(double %18)
%20 = load double, double* %2
%21 = call double @f(double %20)
%22 = fsub double %19, %21
%23 = fdiv double %17, %22
store double %23, double* %4
%24 = load double, double* %4
%25 = call double @f(double %24)
%26 = fcmp oeq double %25, 0.000000e+00
br i1 %26, label %33, label %27
27: ; preds = %8
%28 = load double, double* %4
%29 = load double, double* %5
%30 = fsub double %28, %29
%31 = call double @mod(double %30)
%32 = fcmp olt double %31, 0x3E7AD7F29ABCAF48
br i1 %32, label %33, label %34
33: ; preds = %27, %8
br label %57
34: ; preds = %27
%35 = load double, double* %2
%36 = call double @f(double %35)
%37 = load double, double* %4
%38 = call double @f(double %37)
%39 = fmul double %36, %38
%40 = fcmp olt double %39, 0.000000e+00
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = load double, double* %4
store double %42, double* %3
br label %45
43: ; preds = %34
%44 = load double, double* %4
store double %44, double* %2
br label %45
45: ; preds = %43, %41
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
%48 = load double, double* %2
%49 = load double, double* %3
%50 = load double, double* %4
%51 = load double, double* %4
%52 = load double, double* %5
%53 = fsub double %51, %52
%54 = call double @mod(double %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %46, double %48, double %49, double %50, double %54)
%56 = load double, double* %4
store double %56, double* %5
br label %8
57: ; preds = %33
%58 = load double, double* %4
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %58)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"%d\09%lf\09%f\09%f\09%f\0A\00"
@.str.2 = [16 x i8] c"Final Answer:%f\00"
@str = [46 x i8] c"i\09lowerpoint\09upperpoint\09root\09\09|root-temproot|\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %22, %0
%3 = phi double [ 0x400921FB53C8D4F1, %0 ], [ %27, %22 ]
%4 = phi double [ 0.000000e+00, %0 ], [ %28, %22 ]
%5 = phi double [ 0x4022D97C7ED69FB5, %0 ], [ %15, %22 ]
%6 = phi i32 [ 0, %0 ], [ %29, %22 ]
%7 = tail call double @f(double %3)
%8 = tail call double @f(double %4)
%9 = fneg double %3
%10 = fmul double %8, %9
%11 = tail call double @llvm.fmuladd.f64(double %4, double %7, double %10)
%12 = tail call double @f(double %3)
%13 = tail call double @f(double %4)
%14 = fsub double %12, %13
%15 = fdiv double %11, %14
%16 = tail call double @f(double %15)
%17 = fcmp oeq double %16, 0.000000e+00
br i1 %17, label %32, label %18
18: ; preds = %2
%19 = fsub double %15, %5
%20 = tail call double @mod(double %19)
%21 = fcmp olt double %20, 0x3E7AD7F29ABCAF48
br i1 %21, label %32, label %22
22: ; preds = %18
%23 = tail call double @f(double %4)
%24 = tail call double @f(double %15)
%25 = fmul double %23, %24
%26 = fcmp olt double %25, 0.000000e+00
%27 = select i1 %26, double %15, double %3
%28 = select i1 %26, double %4, double %15
%29 = add nuw nsw i32 %6, 1
%30 = tail call double @mod(double %19)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %6, double %28, double %27, double %15, double %30)
br label %2
32: ; preds = %2, %18
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %15)
ret i32 0
}