#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 EXIT_SUCCESS;
scalar_t__ atoi(char *);
scalar_t__ atol(char *);
int /*<<< orphan*/ omp_set_num_threads(unsigned int);
int /*<<< orphan*/ printf(char *, long double);
int main(int argc, char *argv[]) {
  unsigned int processes = 8u;
  unsigned long iter = 1000000000ul;
  if (argc > 1) {
    processes = (unsigned int)atoi(argv[1]);
  }
  if (argc > 2) {
    iter = (unsigned long)atol(argv[2]);
  }
  long double pi = 0.0;
  omp_set_num_threads(processes);
#pragma omp parallel for reduction(+ : pi)
  for (unsigned long i = 0ul; i < iter; ++i) {
    if (i % 2 == 0)
      pi += 1.0 / ((i << 1) + 1);
    else
      pi -= 1.0 / ((i << 1) + 1);
  }
  printf("Processes\t%d\n", processes);
  printf("Iterations\t%ld\n", iter);
  printf("Sum\t\t%.100Lf\n", pi);
  printf("PI\t\t%.100Lf\n", pi * 4.0);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x8,-0x14(%rbp)
movq   $0x3b9aca00,-0x20(%rbp)
3b
cmpl   $0x1,-0x8(%rbp)
jle    117f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    119a <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atol@plt>
mov    %rax,-0x20(%rbp)
fldz
fstpt  -0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <omp_set_num_threads@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1282 <main+0x142>
mov    -0x38(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    1220 <main+0xe0>
mov    -0x38(%rbp),%rax
lea    0x1(%rax,%rax,1),%rax
movq   %rax,%xmm1
movaps 0xe3c(%rip),%xmm0
punpckldq %xmm0,%xmm1
movapd 0xe40(%rip),%xmm0
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe09(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
fldl   -0x58(%rbp)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
jmp    126c <main+0x12c>
mov    -0x38(%rbp),%rax
lea    0x1(%rax,%rax,1),%rax
movq   %rax,%xmm1
movaps 0xdeb(%rip),%xmm0
punpckldq %xmm0,%xmm1
movapd 0xdef(%rip),%xmm0
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdb0(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
fldl   -0x50(%rbp)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
jmp    1271 <main+0x131>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11af <main+0x6f>
mov    -0x14(%rbp),%eax
mov    %rax,-0x48(%rbp)
fildll -0x48(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xda8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
test   %rax,%rax
sets   %al
movzbl %al,%eax
mov    %eax,%ecx
fildll -0x40(%rbp)
lea    0xd46(%rip),%rax
flds   (%rax,%rcx,4)
faddp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xd83(%rip),%rdi
call   1030 <printf@plt>
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xd7f(%rip),%rdi
call   1030 <printf@plt>
fldt   -0x30(%rbp)
flds   0xd2b(%rip)
fmulp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xd71(%rip),%rdi
call   1030 <printf@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    $0x8,%r14d
cmp    $0x2,%edi
jl     116d <main+0x2d>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %rax,%r14
cmp    $0x2,%ebp
jne    1272 <main+0x132>
mov    %r14d,%edi
call   1040 <omp_set_num_threads@plt>
mov    $0x3b9aca00,%ebx
fldz
mov    $0x1,%eax
xor    %ecx,%ecx
movdqa 0xe75(%rip),%xmm0
movapd 0xe7d(%rip),%xmm1
movsd  0xe85(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
test   $0x1,%cl
movq   %rax,%xmm3
punpckldq %xmm0,%xmm3
subpd  %xmm1,%xmm3
movapd %xmm3,%xmm4
unpckhpd %xmm3,%xmm4
addsd  %xmm3,%xmm4
movapd %xmm2,%xmm3
divsd  %xmm4,%xmm3
movsd  %xmm3,0x38(%rsp)
fldl   0x38(%rsp)
fld    %st(0)
fchs
fcmove %st(1),%st
fstp   %st(1)
faddp  %st,%st(1)
add    $0x1,%rcx
add    $0x2,%rax
cmp    %rcx,%rbx
jne    11a0 <main+0x60>
fstpt  0x1c(%rsp)
mov    %r14d,%eax
mov    %rax,0x28(%rsp)
fildll 0x28(%rsp)
fstpt  (%rsp)
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,0x30(%rsp)
xor    %eax,%eax
test   %rbx,%rbx
sets   %al
fildll 0x30(%rsp)
lea    0xe0c(%rip),%rcx
fadds  (%rcx,%rax,4)
fstpt  (%rsp)
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
fldt   0x1c(%rsp)
fld    %st(0)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
fldt   0x1c(%rsp)
fmuls  0xddf(%rip)
fstpt  (%rsp)
lea    0xe05(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x10(%rbx),%rdi
call   1050 <atol@plt>
mov    %rax,%rbx
mov    %r14d,%edi
call   1040 <omp_set_num_threads@plt>
fldz
test   %rbx,%rbx
je     1294 <main+0x154>
fstp   %st(0)
jmp    117a <main+0x3a>
fstpt  0x1c(%rsp)
xor    %ebx,%ebx
jmp    11e9 <main+0xa9>

LLVM IR (-O0):
@.str = [14 x i8] c"Processes\09%d\0A\00"
@.str.1 = [16 x i8] c"Iterations\09%ld\0A\00"
@.str.2 = [14 x i8] c"Sum\09\09%.100Lf\0A\00"
@.str.3 = [13 x i8] c"PI\09\09%.100Lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca x86_fp80
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 8, i32* %6
store i64 1000000000, i64* %7
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @atoi(i8* %15)
%17 = trunc i64 %16 to i32
store i32 %17, i32* %6
br label %18
18: ; preds = %12, %2
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i64 @atol(i8* %24)
store i64 %25, i64* %7
br label %26
26: ; preds = %21, %18
store x86_fp80 0xK00000000000000000000, x86_fp80* %8
%27 = load i32, i32* %6
%28 = call i32 @omp_set_num_threads(i32 %27)
store i64 0, i64* %9
br label %29
29: ; preds = %56, %26
%30 = load i64, i64* %9
%31 = load i64, i64* %7
%32 = icmp ult i64 %30, %31
br i1 %32, label %33, label %59
33: ; preds = %29
%34 = load i64, i64* %9
%35 = urem i64 %34, 2
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = load i64, i64* %9
%39 = shl i64 %38, 1
%40 = add i64 %39, 1
%41 = uitofp i64 %40 to double
%42 = fdiv double 1.000000e+00, %41
%43 = fpext double %42 to x86_fp80
%44 = load x86_fp80, x86_fp80* %8
%45 = fadd x86_fp80 %44, %43
store x86_fp80 %45, x86_fp80* %8
br label %55
46: ; preds = %33
%47 = load i64, i64* %9
%48 = shl i64 %47, 1
%49 = add i64 %48, 1
%50 = uitofp i64 %49 to double
%51 = fdiv double 1.000000e+00, %50
%52 = fpext double %51 to x86_fp80
%53 = load x86_fp80, x86_fp80* %8
%54 = fsub x86_fp80 %53, %52
store x86_fp80 %54, x86_fp80* %8
br label %55
55: ; preds = %46, %37
br label %56
56: ; preds = %55
%57 = load i64, i64* %9
%58 = add i64 %57, 1
store i64 %58, i64* %9
br label %29
59: ; preds = %29
%60 = load i32, i32* %6
%61 = uitofp i32 %60 to x86_fp80
%62 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), x86_fp80 %61)
%63 = load i64, i64* %7
%64 = uitofp i64 %63 to x86_fp80
%65 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %64)
%66 = load x86_fp80, x86_fp80* %8
%67 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), x86_fp80 %66)
%68 = load x86_fp80, x86_fp80* %8
%69 = fmul x86_fp80 %68, 0xK40018000000000000000
%70 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), x86_fp80 %69)
%71 = load i32, i32* @EXIT_SUCCESS
ret i32 %71
}

LLVM IR (-O2):
@.str = [14 x i8] c"Processes\09%d\0A\00"
@.str.1 = [16 x i8] c"Iterations\09%ld\0A\00"
@.str.2 = [14 x i8] c"Sum\09\09%.100Lf\0A\00"
@.str.3 = [13 x i8] c"PI\09\09%.100Lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @atoi(i8* %6)
%8 = trunc i64 %7 to i32
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %13
10: ; preds = %4, %2
%11 = phi i32 [ 8, %2 ], [ %8, %4 ]
%12 = tail call i32 @omp_set_num_threads(i32 %11)
br label %19
13: ; preds = %4
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i64 @atol(i8* %15)
%17 = tail call i32 @omp_set_num_threads(i32 %8)
%18 = icmp eq i64 %16, 0
br i1 %18, label %22, label %19
19: ; preds = %10, %13
%20 = phi i64 [ 1000000000, %10 ], [ %16, %13 ]
%21 = phi i32 [ %11, %10 ], [ %8, %13 ]
br label %34
22: ; preds = %34, %13
%23 = phi i64 [ 0, %13 ], [ %20, %34 ]
%24 = phi i32 [ %8, %13 ], [ %21, %34 ]
%25 = phi x86_fp80 [ 0xK00000000000000000000, %13 ], [ %46, %34 ]
%26 = uitofp i32 %24 to x86_fp80
%27 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), x86_fp80 %26)
%28 = uitofp i64 %23 to x86_fp80
%29 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %28)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), x86_fp80 %25)
%31 = fmul x86_fp80 %25, 0xK40018000000000000000
%32 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), x86_fp80 %31)
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
34: ; preds = %19, %34
%35 = phi i64 [ %47, %34 ], [ 0, %19 ]
%36 = phi x86_fp80 [ %46, %34 ], [ 0xK00000000000000000000, %19 ]
%37 = and i64 %35, 1
%38 = icmp eq i64 %37, 0
%39 = shl i64 %35, 1
%40 = or i64 %39, 1
%41 = uitofp i64 %40 to double
%42 = fdiv double 1.000000e+00, %41
%43 = fpext double %42 to x86_fp80
%44 = fneg x86_fp80 %43
%45 = select i1 %38, x86_fp80 %43, x86_fp80 %44
%46 = fadd x86_fp80 %36, %45
%47 = add nuw i64 %35, 1
%48 = icmp eq i64 %47, %20
br i1 %48, label %22, label %34
}