#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 atoi(char *);
double pow(int, double);
int /*<<< orphan*/ printf(char *, double);
int main(int argc, char **arg) {
  double svar = 0.0;
  int x = 1;
  long ite = pow(10, atoi(arg[1]));
  double nnn;
  for (double n = 1; n < ite; n++) {
    nnn = (2 * n) - 1;
    svar += (pow((-1), (n + 1)) * pow(x, nnn) / (nnn));
  }
  printf("Pi är =\x1B[35m %.12f \x1B[0m,nästan\nriktiga pi är ungefär = "
         "3.141592653590\n",
         svar * 4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    $0xa,%edi
call   1040 <pow@plt>
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
movsd  0xe83(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
cvtsi2sdq -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    120c <main+0xdc>
movsd  -0x38(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe68(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe47(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
mov    $0xffffffff,%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
movsd  -0x30(%rbp),%xmm0
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe03(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1182 <main+0x52>
movsd  0xdf4(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    $0xa,%edi
call   1040 <pow@plt>
cvttsd2si %xmm0,%rax
xorpd  %xmm0,%xmm0
cmp    $0x2,%rax
jl     1208 <main+0xd8>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm0,%xmm0
movsd  0xe8c(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,(%rsp)
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe73(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  0xe5d(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0xffffffff,%edi
movapd %xmm1,%xmm0
call   1040 <pow@plt>
movsd  %xmm0,0x20(%rsp)
mov    $0x1,%edi
movsd  0x8(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0x20(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd 0x10(%rsp),%xmm1
movsd  0x10(%rsp),%xmm1
ja     1180 <main+0x50>
mulsd  0xe08(%rip),%xmm0
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [75 x i8] c"Pi \C3\A4r =\1B[35m %.12f \1B[0m,n\C3\A4stan\0Ariktiga pi \C3\A4r ungef\C3\A4r = 3.141592653590\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
%8 = alloca i64
%9 = alloca double
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %6
store i32 1, i32* %7
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call double @atoi(i8* %13)
%15 = call double @pow(i32 10, double %14)
%16 = fptosi double %15 to i64
store i64 %16, i64* %8
store double 1.000000e+00, double* %10
br label %17
17: ; preds = %36, %2
%18 = load double, double* %10
%19 = load i64, i64* %8
%20 = sitofp i64 %19 to double
%21 = fcmp olt double %18, %20
br i1 %21, label %22, label %39
22: ; preds = %17
%23 = load double, double* %10
%24 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %23, double -1.000000e+00)
store double %24, double* %9
%25 = load double, double* %10
%26 = fadd double %25, 1.000000e+00
%27 = call double @pow(i32 -1, double %26)
%28 = load i32, i32* %7
%29 = load double, double* %9
%30 = call double @pow(i32 %28, double %29)
%31 = fmul double %27, %30
%32 = load double, double* %9
%33 = fdiv double %31, %32
%34 = load double, double* %6
%35 = fadd double %34, %33
store double %35, double* %6
br label %36
36: ; preds = %22
%37 = load double, double* %10
%38 = fadd double %37, 1.000000e+00
store double %38, double* %10
br label %17
39: ; preds = %17
%40 = load double, double* %6
%41 = fmul double %40, 4.000000e+00
%42 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), double %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [75 x i8] c"Pi \C3\A4r =\1B[35m %.12f \1B[0m,n\C3\A4stan\0Ariktiga pi \C3\A4r ungef\C3\A4r = 3.141592653590\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call double @atoi(i8* %4)
%6 = tail call double @pow(i32 10, double %5)
%7 = fptosi double %6 to i64
%8 = sitofp i64 %7 to double
%9 = icmp sgt i64 %7, 1
br i1 %9, label %15, label %12
10: ; preds = %15
%11 = fmul double %24, 4.000000e+00
br label %12
12: ; preds = %10, %2
%13 = phi double [ 0.000000e+00, %2 ], [ %11, %10 ]
%14 = tail call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), double %13)
ret i32 0
15: ; preds = %2, %15
%16 = phi double [ %19, %15 ], [ 1.000000e+00, %2 ]
%17 = phi double [ %24, %15 ], [ 0.000000e+00, %2 ]
%18 = tail call double @llvm.fmuladd.f64(double %16, double 2.000000e+00, double -1.000000e+00)
%19 = fadd double %16, 1.000000e+00
%20 = tail call double @pow(i32 -1, double %19)
%21 = tail call double @pow(i32 1, double %18)
%22 = fmul double %20, %21
%23 = fdiv double %22, %18
%24 = fadd double %17, %23
%25 = fcmp olt double %19, %8
br i1 %25, label %15, label %10
}