#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;
double count(double *, double, int);
int /*<<< orphan*/ doubleAbs(double, double);
double pareto();
int /*<<< orphan*/ pareto_init();
double pow(double, int);
int /*<<< orphan*/ printf(char *, ...);
double stddev(double *, double, int);
int main(int argc, char **argv) {
  unsigned int i;
  double x = 1;
  double inc = (10.0) / (400 * 0.2);
  double array[400];
  double sum = 0, mean, sdev;
  pareto_init();
  for (i = 0; i < 400; i++)
    sum += (array[i] = pareto());
  mean = sum / (double)400;
  sdev = stddev(array, mean, 400);
  printf("#Pareto Random Number Generator (PRNG)\n");
  printf("#ParetoRN\tNorm of PRN\tstd value\tStandardNorm\tDiff\n");
  double normX, normx;
  for (i = 0; i < 400; i++) {
    normX = count(array, x, 400);
    normx = 1.0 - pow(1.0 / x, 2);
    printf("%lf\t%lf\t%lf\t%lf\t%lf\n", array[i], normX, x, normx,
           doubleAbs(normX, normx));
    x += inc;
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd00,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xcb8(%rbp)
ff
mov    $0x0,%al
call   1080 <pareto_init@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x190,-0x14(%rbp)
jae    11fa <main+0x8a>
mov    $0x0,%al
call   1050 <pareto@plt>
mov    -0x14(%rbp),%eax
movsd  %xmm0,-0xcb0(%rbp,%rax,8)
ff ff
addsd  -0xcb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xcb8(%rbp)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <main+0x4c>
movsd  -0xcb8(%rbp),%xmm0
ff
movsd  0xe06(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xcc0(%rbp)
ff
lea    -0xcb0(%rbp),%rdi
movsd  -0xcc0(%rbp),%xmm0
ff
mov    $0x190,%esi
call   1040 <stddev@plt>
movsd  %xmm0,-0xcc8(%rbp)
ff
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x190,-0x14(%rbp)
jae    1356 <main+0x1e6>
lea    -0xcb0(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
mov    $0x190,%esi
call   1030 <count@plt>
movsd  %xmm0,-0xcd0(%rbp)
ff
movsd  0xd7b(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1090 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xd61(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xcd8(%rbp)
ff
mov    -0x14(%rbp),%eax
movsd  -0xcb0(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0xcf8(%rbp)
ff
movsd  -0xcd0(%rbp),%xmm0
ff
movsd  %xmm0,-0xcf0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xce8(%rbp)
ff
movsd  -0xcd8(%rbp),%xmm0
ff
movsd  %xmm0,-0xce0(%rbp)
ff
movsd  -0xcd0(%rbp),%xmm0
ff
movsd  -0xcd8(%rbp),%xmm1
ff
call   1060 <doubleAbs@plt>
movsd  -0xcf8(%rbp),%xmm0
ff
movsd  -0xcf0(%rbp),%xmm1
ff
movsd  -0xce8(%rbp),%xmm2
ff
movsd  -0xce0(%rbp),%xmm3
ff
mov    %eax,%esi
lea    0xd41(%rip),%rdi
mov    $0x4,%al
call   1070 <printf@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    125a <main+0xea>
mov    0x2c83(%rip),%rax
mov    (%rax),%eax
add    $0xd00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xca0,%rsp
xor    %eax,%eax
call   1090 <pareto_init@plt>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <pareto@plt>
movsd  %xmm0,0x20(%rsp,%rbx,8)
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%rbx
cmp    $0x190,%rbx
jne    11a0 <main+0x20>
divsd  0xe26(%rip),%xmm0
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x190,%esi
call   1050 <stddev@plt>
lea    0xe3a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe55(%rip),%rdi
call   1040 <puts@plt>
movsd  0xdfc(%rip),%xmm0
xor    %ebx,%ebx
lea    0xe03(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
movsd  (%rsp),%xmm0
mov    $0x190,%esi
call   1030 <count@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xdc3(%rip),%xmm0
divsd  (%rsp),%xmm0
mov    $0x2,%edi
call   10a0 <pow@plt>
movsd  0xdac(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x20(%rsp,%rbx,8),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <doubleAbs@plt>
mov    %r15,%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
mov    %eax,%esi
mov    $0x4,%al
call   1080 <printf@plt>
movsd  (%rsp),%xmm0
addsd  0xd63(%rip),%xmm0
add    $0x1,%rbx
cmp    $0x190,%rbx
jne    1220 <main+0xa0>
mov    0x2d1b(%rip),%rax
mov    (%rax),%eax
add    $0xca0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [40 x i8] c"#Pareto Random Number Generator (PRNG)\0A\00"
@.str.1 = [51 x i8] c"#ParetoRN\09Norm of PRN\09std value\09StandardNorm\09Diff\0A\00"
@.str.2 = [21 x i8] c"%lf\09%lf\09%lf\09%lf\09%lf\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 double
%8 = alloca double
%9 = alloca [400 x double]
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 1.000000e+00, double* %7
store double 1.250000e-01, double* %8
store double 0.000000e+00, double* %10
%15 = call i32 (...) @pareto_init()
store i32 0, i32* %6
br label %16
16: ; preds = %26, %2
%17 = load i32, i32* %6
%18 = icmp ult i32 %17, 400
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = call double (...) @pareto()
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [400 x double], [400 x double]* %9, i64 0, i64 %22
store double %20, double* %23
%24 = load double, double* %10
%25 = fadd double %24, %20
store double %25, double* %10
br label %26
26: ; preds = %19
%27 = load i32, i32* %6
%28 = add i32 %27, 1
store i32 %28, i32* %6
br label %16
29: ; preds = %16
%30 = load double, double* %10
%31 = fdiv double %30, 4.000000e+02
store double %31, double* %11
%32 = getelementptr inbounds [400 x double], [400 x double]* %9, i64 0, i64 0
%33 = load double, double* %11
%34 = call double @stddev(double* %32, double %33, i32 400)
store double %34, double* %12
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %37
37: ; preds = %62, %29
%38 = load i32, i32* %6
%39 = icmp ult i32 %38, 400
br i1 %39, label %40, label %65
40: ; preds = %37
%41 = getelementptr inbounds [400 x double], [400 x double]* %9, i64 0, i64 0
%42 = load double, double* %7
%43 = call double @count(double* %41, double %42, i32 400)
store double %43, double* %13
%44 = load double, double* %7
%45 = fdiv double 1.000000e+00, %44
%46 = call double @pow(double %45, i32 2)
%47 = fsub double 1.000000e+00, %46
store double %47, double* %14
%48 = load i32, i32* %6
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds [400 x double], [400 x double]* %9, i64 0, i64 %49
%51 = load double, double* %50
%52 = load double, double* %13
%53 = load double, double* %7
%54 = load double, double* %14
%55 = load double, double* %13
%56 = load double, double* %14
%57 = call i32 @doubleAbs(double %55, double %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %51, double %52, double %53, double %54, i32 %57)
%59 = load double, double* %8
%60 = load double, double* %7
%61 = fadd double %60, %59
store double %61, double* %7
br label %62
62: ; preds = %40
%63 = load i32, i32* %6
%64 = add i32 %63, 1
store i32 %64, i32* %6
br label %37
65: ; preds = %37
%66 = load i32, i32* @EXIT_SUCCESS
ret i32 %66
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"%lf\09%lf\09%lf\09%lf\09%lf\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [39 x i8] c"#Pareto Random Number Generator (PRNG)\00"
@str.3 = [50 x i8] c"#ParetoRN\09Norm of PRN\09std value\09StandardNorm\09Diff\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [400 x double]
%4 = bitcast [400 x double]* %3 to i8*
%5 = tail call i32 (...) @pareto_init()
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %12, %6 ]
%8 = phi double [ 0.000000e+00, %2 ], [ %11, %6 ]
%9 = tail call double (...) @pareto()
%10 = getelementptr inbounds [400 x double], [400 x double]* %3, i64 0, i64 %7
store double %9, double* %10
%11 = fadd double %8, %9
%12 = add nuw nsw i64 %7, 1
%13 = icmp eq i64 %12, 400
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = fdiv double %11, 4.000000e+02
%16 = getelementptr inbounds [400 x double], [400 x double]* %3, i64 0, i64 0
%17 = call double @stddev(double* %16, double %15, i32 400)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.3, i64 0, i64 0))
br label %20
20: ; preds = %14, %20
%21 = phi i64 [ 0, %14 ], [ %32, %20 ]
%22 = phi double [ 1.000000e+00, %14 ], [ %31, %20 ]
%23 = call double @count(double* %16, double %22, i32 400)
%24 = fdiv double 1.000000e+00, %22
%25 = call double @pow(double %24, i32 2)
%26 = fsub double 1.000000e+00, %25
%27 = getelementptr inbounds [400 x double], [400 x double]* %3, i64 0, i64 %21
%28 = load double, double* %27
%29 = call i32 @doubleAbs(double %23, double %26)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %28, double %23, double %22, double %26, i32 %29)
%31 = fadd double %22, 1.250000e-01
%32 = add nuw nsw i64 %21, 1
%33 = icmp eq i64 %32, 400
br i1 %33, label %34, label %20
34: ; preds = %20
%35 = load i32, i32* @EXIT_SUCCESS
ret i32 %35
}