#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(double);
int pow(int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int sqrt(int);
int main() {
  int j = 0;
  int k = 0;
  double s_k = 0;
  double c_k = 0;
  s_k = sqrt(2);
  j = 2;
  while (fabs(c_k - s_k) >= 0.0000001) {
    k = pow(2, j);
    c_k = 2 * s_k / sqrt(4 - s_k * s_k);
    printf("%9d %.10lf %.10lf\n", k, k * s_k, k * c_k);
    s_k = sqrt(2 - sqrt(4 - s_k * s_k));
    j++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x2,%edi
call   1050 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x2,-0x8(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movaps 0xe98(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe6c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1294 <main+0x164>
mov    -0x8(%rbp),%esi
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,-0xc(%rbp)
movsd  0xe5a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe1b(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%esi
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edx
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%ecx
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xda4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
mov    $0x2,%edi
sub    %eax,%edi
call   1050 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1177 <main+0x47>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    $0x2,%ebx
mov    $0x2,%edi
call   1050 <sqrt@plt>
cvtsi2sd %eax,%xmm1
xorpd  %xmm0,%xmm0
subsd  %xmm1,%xmm0
andpd  0xea3(%rip),%xmm0
ucomisd 0xeab(%rip),%xmm0
jb     1245 <main+0x115>
lea    0xeae(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm1,0x8(%rsp)
mov    $0x2,%edi
mov    %ebx,%esi
call   1040 <pow@plt>
mov    %eax,%r15d
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe5f(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebp
mov    %ebp,%edi
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edx
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd 0x10(%rsp),%xmm2
divsd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ecx
mov    %r14,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %ebp,%edi
call   1050 <sqrt@plt>
mov    $0x2,%edi
sub    %eax,%edi
call   1050 <sqrt@plt>
add    $0x1,%ebx
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd 0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
andpd  0xdc9(%rip),%xmm0
ucomisd 0xdd1(%rip),%xmm0
jae    1180 <main+0x50>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"%9d %.10lf %.10lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
%6 = call i32 @sqrt(i32 2)
%7 = sitofp i32 %6 to double
store double %7, double* %4
store i32 2, i32* %2
br label %8
8: ; preds = %14, %0
%9 = load double, double* %5
%10 = load double, double* %4
%11 = fsub double %9, %10
%12 = call double @llvm.fabs.f64(double %11)
%13 = fcmp oge double %12, 0x3E7AD7F29ABCAF48
br i1 %13, label %14, label %50
14: ; preds = %8
%15 = load i32, i32* %2
%16 = call i32 @pow(i32 2, i32 %15)
store i32 %16, i32* %3
%17 = load double, double* %4
%18 = fmul double 2.000000e+00, %17
%19 = load double, double* %4
%20 = load double, double* %4
%21 = fneg double %19
%22 = call double @llvm.fmuladd.f64(double %21, double %20, double 4.000000e+00)
%23 = fptosi double %22 to i32
%24 = call i32 @sqrt(i32 %23)
%25 = sitofp i32 %24 to double
%26 = fdiv double %18, %25
store double %26, double* %5
%27 = load i32, i32* %3
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to double
%30 = load double, double* %4
%31 = fmul double %29, %30
%32 = fptosi double %31 to i32
%33 = load i32, i32* %3
%34 = sitofp i32 %33 to double
%35 = load double, double* %5
%36 = fmul double %34, %35
%37 = fptosi double %36 to i32
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %32, i32 %37)
%39 = load double, double* %4
%40 = load double, double* %4
%41 = fneg double %39
%42 = call double @llvm.fmuladd.f64(double %41, double %40, double 4.000000e+00)
%43 = fptosi double %42 to i32
%44 = call i32 @sqrt(i32 %43)
%45 = sub nsw i32 2, %44
%46 = call i32 @sqrt(i32 %45)
%47 = sitofp i32 %46 to double
store double %47, double* %4
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %8
50: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"%9d %.10lf %.10lf\0A\00"
define i32 @main() {
%1 = tail call i32 @sqrt(i32 2)
%2 = sitofp i32 %1 to double
%3 = fsub double 0.000000e+00, %2
%4 = tail call double @llvm.fabs.f64(double %3)
%5 = fcmp ult double %4, 0x3E7AD7F29ABCAF48
br i1 %5, label %31, label %6
6: ; preds = %0, %6
%7 = phi double [ %27, %6 ], [ %2, %0 ]
%8 = phi i32 [ %26, %6 ], [ 2, %0 ]
%9 = tail call i32 @pow(i32 2, i32 %8)
%10 = fmul double %7, 2.000000e+00
%11 = fneg double %7
%12 = tail call double @llvm.fmuladd.f64(double %11, double %7, double 4.000000e+00)
%13 = fptosi double %12 to i32
%14 = tail call i32 @sqrt(i32 %13)
%15 = sitofp i32 %14 to double
%16 = fdiv double %10, %15
%17 = sitofp i32 %9 to double
%18 = fmul double %7, %17
%19 = fptosi double %18 to i32
%20 = fmul double %16, %17
%21 = fptosi double %20 to i32
%22 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %19, i32 %21)
%23 = tail call i32 @sqrt(i32 %13)
%24 = sub nsw i32 2, %23
%25 = tail call i32 @sqrt(i32 %24)
%26 = add nuw nsw i32 %8, 1
%27 = sitofp i32 %25 to double
%28 = fsub double %16, %27
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fcmp ult double %29, 0x3E7AD7F29ABCAF48
br i1 %30, label %31, label %6
31: ; preds = %6, %0
ret i32 0
}