#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 */
scalar_t__ floor(int /*<<< orphan*/);
int /*<<< orphan*/ log10(double);
int /*<<< orphan*/ printf(char *, double, ...);
void printLog(double precision, double pi, double error, unsigned long i) {
  if (i % (1) == 0 || error < precision || i == 1024) {
    printf("Iteration\t%ld\n", i);
    printf("Precision\t%d (%s)\n", (unsigned int)floor(-log10(error)),
           i == 1024           ? "Timeout"
           : error > precision ? "Still Working"
                               : "Reached");
    printf("PI\t\t%.100f\n", pi);
    printf("Error\t\t%.100f\n", error);
  }
}


x86 assembly (clang, -O0):
<printLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    -0x20(%rbp),%rax
and    $0x0,%rax
cmp    $0x0,%rax
je     117f <printLog+0x4f>
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     117f <printLog+0x4f>
cmpq   $0x400,-0x20(%rbp)
jne    1252 <printLog+0x122>
movaps 0xe7a(%rip),%xmm1
movq   -0x20(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe79(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xe73(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
call   1040 <log10@plt>
mov    %eax,%edi
neg    %edi
call   1050 <floor@plt>
mov    %eax,%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x400,-0x20(%rbp)
jne    11f1 <printLog+0xc1>
lea    0xe5a(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1215 <printLog+0xe5>
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
lea    0xe56(%rip),%rax
lea    0xe41(%rip),%rcx
ucomisd %xmm1,%xmm0
cmova  %rcx,%rax
mov    %rax,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe21(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printLog>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
movq   %rdi,%xmm1
punpckldq 0xea9(%rip),%xmm1
subpd  0xeb1(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xeae(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
call   1040 <log10@plt>
neg    %eax
mov    %eax,%edi
call   1050 <floor@plt>
mov    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd 0x10(%rsp),%xmm1
lea    0xea0(%rip),%rax
lea    0xea7(%rip),%rcx
cmova  %rax,%rcx
cmp    $0x400,%rbx
lea    0xe7f(%rip),%rsi
cmovne %rcx,%rsi
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe84(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
add    $0x20,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"Iteration\09%ld\0A\00"
@.str.1 = [19 x i8] c"Precision\09%d (%s)\0A\00"
@.str.2 = [8 x i8] c"Timeout\00"
@.str.3 = [14 x i8] c"Still Working\00"
@.str.4 = [8 x i8] c"Reached\00"
@.str.5 = [12 x i8] c"PI\09\09%.100f\0A\00"
@.str.6 = [15 x i8] c"Error\09\09%.100f\0A\00"
define void @printLog(double %0, double %1, double %2, i64 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i64
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i64 %3, i64* %8
%9 = load i64, i64* %8
%10 = urem i64 %9, 1
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %4
%13 = load double, double* %7
%14 = load double, double* %5
%15 = fcmp olt double %13, %14
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i64, i64* %8
%18 = icmp eq i64 %17, 1024
br i1 %18, label %19, label %45
19: ; preds = %16, %12, %4
%20 = load i64, i64* %8
%21 = uitofp i64 %20 to double
%22 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %21)
%23 = load double, double* %7
%24 = call i32 @log10(double %23)
%25 = sub nsw i32 0, %24
%26 = call i64 @floor(i32 %25)
%27 = trunc i64 %26 to i32
%28 = uitofp i32 %27 to double
%29 = load i64, i64* %8
%30 = icmp eq i64 %29, 1024
br i1 %30, label %31, label %32
31: ; preds = %19
br label %38
32: ; preds = %19
%33 = load double, double* %7
%34 = load double, double* %5
%35 = fcmp ogt double %33, %34
%36 = zext i1 %35 to i64
%37 = select i1 %35, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
br label %38
38: ; preds = %32, %31
%39 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %31 ], [ %37, %32 ]
%40 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %28, i8* %39)
%41 = load double, double* %6
%42 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %41)
%43 = load double, double* %7
%44 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %43)
br label %45
45: ; preds = %38, %16
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Iteration\09%ld\0A\00"
@.str.1 = [19 x i8] c"Precision\09%d (%s)\0A\00"
@.str.2 = [8 x i8] c"Timeout\00"
@.str.3 = [14 x i8] c"Still Working\00"
@.str.4 = [8 x i8] c"Reached\00"
@.str.5 = [12 x i8] c"PI\09\09%.100f\0A\00"
@.str.6 = [15 x i8] c"Error\09\09%.100f\0A\00"
define void @printLog(double %0, double %1, double %2, i64 %3) {
%5 = uitofp i64 %3 to double
%6 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %5)
%7 = tail call i32 @log10(double %2)
%8 = sub nsw i32 0, %7
%9 = tail call i64 @floor(i32 %8)
%10 = trunc i64 %9 to i32
%11 = uitofp i32 %10 to double
%12 = icmp eq i64 %3, 1024
%13 = fcmp ogt double %2, %0
%14 = select i1 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%15 = select i1 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %14
%16 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %11, i8* %15)
%17 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %1)
%18 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %2)
ret void
}