#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 /*<<< orphan*/ fabs(double);
int /*<<< orphan*/ printf(char *, int, double, double, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int sqrt(int);
int main() {
  double x1 = 1;
  double x2 = 1 - sqrt(3);
  double x3 = 0;
  double z = 1 - sqrt(3);
  int i = 0;
  for (i = 3; i <= 50; i++) {
    x3 = 2 * (x1 + x2);
    z *= 1 - sqrt(3);
    printf("%2d %+.8le %+.8le %+.8le %+.8le\n", i, z, x3, fabs(x3 - z),
           fabs((x3 - z) / x3));
    x1 = x2;
    x2 = x3;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x3,%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x3,%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x3,-0x2c(%rbp)
cmpl   $0x32,-0x2c(%rbp)
jg     1260 <main+0x130>
movsd  -0x10(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
movsd  0xe52(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x3,%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x44(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %eax,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1040 <fabs@plt>
mov    -0x44(%rbp),%esi
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mov    -0x30(%rbp),%edx
mov    %eax,%ecx
lea    0xdd7(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119a <main+0x6a>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x3,%ebx
mov    $0x3,%edi
call   1050 <sqrt@plt>
mov    $0x1,%ebp
mov    $0x1,%ecx
sub    %eax,%ecx
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,(%rsp)
mov    $0x3,%edi
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm1
sub    %eax,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe7e(%rip),%xmm0
lea    0xe7f(%rip),%r14
nopl   0x0(%rax)
movsd  %xmm1,0x18(%rsp)
addsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    $0x3,%edi
call   1050 <sqrt@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <fabs@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
divsd  (%rsp),%xmm0
call   1040 <fabs@plt>
mov    %r14,%rdi
mov    %ebx,%esi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
add    $0x1,%ebx
movsd  (%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
cmp    $0x33,%ebx
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"%2d %+.8le %+.8le %+.8le %+.8le\0A\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 1.000000e+00, double* %2
%7 = call i32 @sqrt(i32 3)
%8 = sub nsw i32 1, %7
%9 = sitofp i32 %8 to double
store double %9, double* %3
store double 0.000000e+00, double* %4
%10 = call i32 @sqrt(i32 3)
%11 = sub nsw i32 1, %10
%12 = sitofp i32 %11 to double
store double %12, double* %5
store i32 0, i32* %6
store i32 3, i32* %6
br label %13
13: ; preds = %42, %0
%14 = load i32, i32* %6
%15 = icmp sle i32 %14, 50
br i1 %15, label %16, label %45
16: ; preds = %13
%17 = load double, double* %2
%18 = load double, double* %3
%19 = fadd double %17, %18
%20 = fmul double 2.000000e+00, %19
store double %20, double* %4
%21 = call i32 @sqrt(i32 3)
%22 = sub nsw i32 1, %21
%23 = sitofp i32 %22 to double
%24 = load double, double* %5
%25 = fmul double %24, %23
store double %25, double* %5
%26 = load i32, i32* %6
%27 = load double, double* %5
%28 = load double, double* %4
%29 = load double, double* %4
%30 = load double, double* %5
%31 = fsub double %29, %30
%32 = call i32 @fabs(double %31)
%33 = load double, double* %4
%34 = load double, double* %5
%35 = fsub double %33, %34
%36 = load double, double* %4
%37 = fdiv double %35, %36
%38 = call i32 @fabs(double %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %26, double %27, double %28, i32 %32, i32 %38)
%40 = load double, double* %3
store double %40, double* %2
%41 = load double, double* %4
store double %41, double* %3
br label %42
42: ; preds = %16
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %13
45: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"%2d %+.8le %+.8le %+.8le %+.8le\0A\00"
define i32 @main() {
%1 = tail call i32 @sqrt(i32 3)
%2 = sub nsw i32 1, %1
%3 = sitofp i32 %2 to double
%4 = tail call i32 @sqrt(i32 3)
%5 = sub nsw i32 1, %4
%6 = sitofp i32 %5 to double
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 3, %0 ], [ %23, %7 ]
%9 = phi double [ %6, %0 ], [ %17, %7 ]
%10 = phi double [ %3, %0 ], [ %13, %7 ]
%11 = phi double [ 1.000000e+00, %0 ], [ %10, %7 ]
%12 = fadd double %11, %10
%13 = fmul double %12, 2.000000e+00
%14 = tail call i32 @sqrt(i32 3)
%15 = sub nsw i32 1, %14
%16 = sitofp i32 %15 to double
%17 = fmul double %9, %16
%18 = fsub double %13, %17
%19 = tail call i32 @fabs(double %18)
%20 = fdiv double %18, %13
%21 = tail call i32 @fabs(double %20)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %8, double %17, double %13, i32 %19, i32 %21)
%23 = add nuw nsw i32 %8, 1
%24 = icmp eq i32 %23, 51
br i1 %24, label %25, label %7
25: ; preds = %7
ret i32 0
}