#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 pow(int, int);
long double sqrt(int);
long double approx3(int wut) {
  long double pix = 0;
  long double numer = 1;
  long double denom = 9;
  int zed = 3;
  int ted = 1;
  if (wut == 1) {
    pix = 1;
  } else {
    --wut;
    pix = 1;
    for (int i = 1; i <= wut; i++) {
      if (i % 2 != 0) {
        pix = pix - (numer / denom);
      } else {
        pix = pix + (numer / denom);
      }
      zed = zed + 2;
      ++ted;
      denom = (zed * pow(3, ted));
    }
  }
  pix = (sqrt(12) * pix);
  return pix;
}


x86 assembly (clang, -O0):
<approx3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
fldz
fstpt  -0x20(%rbp)
fld1
fstpt  -0x30(%rbp)
flds   0xec5(%rip)
fstpt  -0x40(%rbp)
movl   $0x3,-0x44(%rbp)
movl   $0x1,-0x48(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1160 <approx3+0x40>
fld1
fstpt  -0x20(%rbp)
jmp    1203 <approx3+0xe3>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
fld1
fstpt  -0x20(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11fe <approx3+0xde>
mov    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11aa <approx3+0x8a>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fldt   -0x40(%rbp)
fdivrp %st,%st(1)
fsubrp %st,%st(1)
fstpt  -0x20(%rbp)
jmp    11ba <approx3+0x9a>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fldt   -0x40(%rbp)
fdivrp %st,%st(1)
faddp  %st,%st(1)
fstpt  -0x20(%rbp)
mov    -0x44(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x44(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%esi
mov    $0x3,%edi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x50(%rbp)
fildl  -0x50(%rbp)
fstpt  -0x40(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1175 <approx3+0x55>
jmp    1203 <approx3+0xe3>
mov    $0xc,%edi
call   1040 <sqrt@plt>
fldt   -0x20(%rbp)
fmulp  %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approx3>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
fld1
cmp    $0x2,%edi
fldz
jl     118e <approx3+0x6e>
mov    %edi,%r14d
fstp   %st(0)
fstp   %st(0)
fld1
flds   0xec0(%rip)
mov    $0x1,%ebp
mov    $0x5,%ebx
fld    %st(1)
fstpt  0x14(%rsp)
test   $0x1,%bpl
fldt   0x14(%rsp)
fdivp  %st,%st(1)
fld    %st(0)
fchs
fcmove %st(1),%st
fstp   %st(1)
faddp  %st,%st(1)
fstpt  0x8(%rsp)
add    $0x1,%ebp
mov    $0x3,%edi
mov    %ebp,%esi
call   1030 <pow@plt>
fldt   0x8(%rsp)
imul   %ebx,%eax
mov    %eax,0x4(%rsp)
fildl  0x4(%rsp)
add    $0x2,%ebx
cmp    %ebp,%r14d
jne    1150 <approx3+0x30>
fstp   %st(0)
fstpt  0x8(%rsp)
mov    $0xc,%edi
call   1040 <sqrt@plt>
fldt   0x8(%rsp)
fmulp  %st,%st(1)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define x86_fp80 @approx3(i32 %0) {
%2 = alloca i32
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %2
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %4
store x86_fp80 0xK40029000000000000000, x86_fp80* %5
store i32 3, i32* %6
store i32 1, i32* %7
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %1
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %3
br label %49
12: ; preds = %1
%13 = load i32, i32* %2
%14 = add nsw i32 %13, -1
store i32 %14, i32* %2
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %3
store i32 1, i32* %8
br label %15
15: ; preds = %45, %12
%16 = load i32, i32* %8
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %48
19: ; preds = %15
%20 = load i32, i32* %8
%21 = srem i32 %20, 2
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load x86_fp80, x86_fp80* %3
%25 = load x86_fp80, x86_fp80* %4
%26 = load x86_fp80, x86_fp80* %5
%27 = fdiv x86_fp80 %25, %26
%28 = fsub x86_fp80 %24, %27
store x86_fp80 %28, x86_fp80* %3
br label %35
29: ; preds = %19
%30 = load x86_fp80, x86_fp80* %3
%31 = load x86_fp80, x86_fp80* %4
%32 = load x86_fp80, x86_fp80* %5
%33 = fdiv x86_fp80 %31, %32
%34 = fadd x86_fp80 %30, %33
store x86_fp80 %34, x86_fp80* %3
br label %35
35: ; preds = %29, %23
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 2
store i32 %37, i32* %6
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 @pow(i32 3, i32 %41)
%43 = mul nsw i32 %40, %42
%44 = sitofp i32 %43 to x86_fp80
store x86_fp80 %44, x86_fp80* %5
br label %45
45: ; preds = %35
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %15
48: ; preds = %15
br label %49
49: ; preds = %48, %11
%50 = call x86_fp80 @sqrt(i32 12)
%51 = load x86_fp80, x86_fp80* %3
%52 = fmul x86_fp80 %50, %51
store x86_fp80 %52, x86_fp80* %3
%53 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %53
}

LLVM IR (-O2):
define x86_fp80 @approx3(i32 %0) {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %3, label %20
3: ; preds = %1, %3
%4 = phi i32 [ %15, %3 ], [ 1, %1 ]
%5 = phi i32 [ %14, %3 ], [ 3, %1 ]
%6 = phi x86_fp80 [ %18, %3 ], [ 0xK40029000000000000000, %1 ]
%7 = phi x86_fp80 [ %13, %3 ], [ 0xK3FFF8000000000000000, %1 ]
%8 = and i32 %4, 1
%9 = icmp eq i32 %8, 0
%10 = fdiv x86_fp80 0xK3FFF8000000000000000, %6
%11 = fneg x86_fp80 %10
%12 = select i1 %9, x86_fp80 %10, x86_fp80 %11
%13 = fadd x86_fp80 %7, %12
%14 = add nuw nsw i32 %5, 2
%15 = add nuw nsw i32 %4, 1
%16 = tail call i32 @pow(i32 3, i32 %15)
%17 = mul nsw i32 %16, %14
%18 = sitofp i32 %17 to x86_fp80
%19 = icmp eq i32 %15, %0
br i1 %19, label %20, label %3
20: ; preds = %3, %1
%21 = phi x86_fp80 [ 0xK3FFF8000000000000000, %1 ], [ %13, %3 ]
%22 = tail call x86_fp80 @sqrt(i32 12)
%23 = fmul x86_fp80 %21, %22
ret x86_fp80 %23
}