#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 NETEM_DIST_SCALE;
int SHRT_MAX;
int SHRT_MIN;
int normal(double, double, double);
int paretovalue(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int rint(double);
int main(int argc, char **argv) {
  int i, n;
  double x;
  double table[16384 + 1];
  for (x = -10.0; x < 10.05; x += .00005) {
    i = rint(16384 * normal(x, 0.0, 1.0));
    table[i] = x;
  }
  printf(
      "# This is the distribution table for the paretonormal distribution.\n");
  for (i = n = 0; i < 16384; i += 4) {
    int normvalue, parvalue, value;
    normvalue = (int)rint(table[i] * NETEM_DIST_SCALE);
    parvalue = paretovalue(i);
    value = (normvalue + 3 * parvalue) / 4;
    if (value < SHRT_MIN)
      value = SHRT_MIN;
    if (value > SHRT_MAX)
      value = SHRT_MAX;
    printf(" %d", value);
    if (++n == 8) {
      putchar('\n');
      n = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20040,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xe8f(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe8a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11d6 <main+0x86>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
movsd  0xe77(%rip),%xmm2
call   1070 <normal@plt>
shl    $0xe,%eax
cvtsi2sd %eax,%xmm0
call   1050 <rint@plt>
mov    %eax,-0x14(%rbp)
movsd  -0x20(%rbp),%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x20030(%rbp,%rax,8)
fd ff
movsd  0xe51(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1176 <main+0x26>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4000,-0x14(%rbp)
jge    12df <main+0x18f>
movslq -0x14(%rbp),%rax
movsd  -0x20030(%rbp,%rax,8),%xmm0
fd ff
mov    0x2dd5(%rip),%rax
mulsd  (%rax),%xmm0
call   1050 <rint@plt>
mov    %eax,-0x20034(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <paretovalue@plt>
mov    %eax,-0x20038(%rbp)
mov    -0x20034(%rbp),%eax
imul   $0x3,-0x20038(%rbp),%ecx
add    %ecx,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2003c(%rbp)
mov    -0x2003c(%rbp),%eax
mov    0x2d7e(%rip),%rcx
cmp    (%rcx),%eax
jge    1271 <main+0x121>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2003c(%rbp)
mov    -0x2003c(%rbp),%eax
mov    0x2d52(%rip),%rcx
cmp    (%rcx),%eax
jle    1295 <main+0x145>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2003c(%rbp)
mov    -0x2003c(%rbp),%esi
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x8,%eax
jne    12cc <main+0x17c>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x18(%rbp)
jmp    12d1 <main+0x181>
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    11f2 <main+0xa2>
xor    %eax,%eax
add    $0x20040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20018,%rsp
movsd  0xe87(%rip),%xmm0
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
movsd  0xe71(%rip),%xmm2
call   1080 <normal@plt>
shl    $0xe,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1060 <rint@plt>
movsd  0x8(%rsp),%xmm0
cltq
movsd  %xmm0,0x10(%rsp,%rax,8)
addsd  0xe4f(%rip),%xmm0
movsd  0xe4f(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1180 <main+0x20>
lea    0xe4e(%rip),%rdi
call   1040 <puts@plt>
mov    0x2df6(%rip),%r13
mov    0x2de7(%rip),%rbp
lea    0xe30(%rip),%r14
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    1224 <main+0xc4>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12d
cmp    $0x8,%r12d
je     1270 <main+0x110>
lea    0x4(%r15),%rax
cmp    $0x3ffc,%r15
mov    %rax,%r15
jae    127f <main+0x11f>
movsd  0x10(%rsp,%r15,8),%xmm0
mov    0x2db6(%rip),%rax
mulsd  (%rax),%xmm0
call   1060 <rint@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1070 <paretovalue@plt>
lea    (%rax,%rax,2),%eax
lea    (%rbx,%rax,1),%ecx
add    $0x3,%ecx
add    %ebx,%eax
cmovns %eax,%ecx
sar    $0x2,%ecx
mov    0x0(%r13),%eax
cmp    %eax,%ecx
jl     1260 <main+0x100>
mov    %ecx,%eax
mov    0x0(%rbp),%esi
cmp    %esi,%eax
jg     1200 <main+0xa0>
mov    %eax,%esi
jmp    1200 <main+0xa0>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %r12d,%r12d
jmp    1214 <main+0xb4>
xor    %eax,%eax
add    $0x20018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [69 x i8] c"# This is the distribution table for the paretonormal distribution.\0A\00"
@NETEM_DIST_SCALE = global double 0.000000e+00
@SHRT_MIN = global i32 0
@SHRT_MAX = global i32 0
@.str.1 = [4 x i8] c" %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca [16385 x double]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double -1.000000e+01, double* %8
br label %13
13: ; preds = %26, %2
%14 = load double, double* %8
%15 = fcmp olt double %14, 1.005000e+01
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load double, double* %8
%18 = call i32 @normal(double %17, double 0.000000e+00, double 1.000000e+00)
%19 = mul nsw i32 16384, %18
%20 = sitofp i32 %19 to double
%21 = call i32 @rint(double %20)
store i32 %21, i32* %6
%22 = load double, double* %8
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [16385 x double], [16385 x double]* %9, i64 0, i64 %24
store double %22, double* %25
br label %26
26: ; preds = %16
%27 = load double, double* %8
%28 = fadd double %27, 5.000000e-05
store double %28, double* %8
br label %13
29: ; preds = %13
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
store i32 0, i32* %6
br label %31
31: ; preds = %69, %29
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 16384
br i1 %33, label %34, label %72
34: ; preds = %31
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [16385 x double], [16385 x double]* %9, i64 0, i64 %36
%38 = load double, double* %37
%39 = load double, double* @NETEM_DIST_SCALE
%40 = fmul double %38, %39
%41 = call i32 @rint(double %40)
store i32 %41, i32* %10
%42 = load i32, i32* %6
%43 = call i32 @paretovalue(i32 %42)
store i32 %43, i32* %11
%44 = load i32, i32* %10
%45 = load i32, i32* %11
%46 = mul nsw i32 3, %45
%47 = add nsw i32 %44, %46
%48 = sdiv i32 %47, 4
store i32 %48, i32* %12
%49 = load i32, i32* %12
%50 = load i32, i32* @SHRT_MIN
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %54
52: ; preds = %34
%53 = load i32, i32* @SHRT_MIN
store i32 %53, i32* %12
br label %54
54: ; preds = %52, %34
%55 = load i32, i32* %12
%56 = load i32, i32* @SHRT_MAX
%57 = icmp sgt i32 %55, %56
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = load i32, i32* @SHRT_MAX
store i32 %59, i32* %12
br label %60
60: ; preds = %58, %54
%61 = load i32, i32* %12
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
%65 = icmp eq i32 %64, 8
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %7
br label %68
68: ; preds = %66, %60
br label %69
69: ; preds = %68
%70 = load i32, i32* %6
%71 = add nsw i32 %70, 4
store i32 %71, i32* %6
br label %31
72: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
@NETEM_DIST_SCALE = global double 0.000000e+00
@SHRT_MIN = global i32 0
@SHRT_MAX = global i32 0
@.str.1 = [4 x i8] c" %d\00"
@str = [68 x i8] c"# This is the distribution table for the paretonormal distribution.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [16385 x double]
%4 = bitcast [16385 x double]* %3 to i8*
br label %5
5: ; preds = %2, %5
%6 = phi double [ -1.000000e+01, %2 ], [ %13, %5 ]
%7 = tail call i32 @normal(double %6, double 0.000000e+00, double 1.000000e+00)
%8 = shl nsw i32 %7, 14
%9 = sitofp i32 %8 to double
%10 = tail call i32 @rint(double %9)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [16385 x double], [16385 x double]* %3, i64 0, i64 %11
store double %6, double* %12
%13 = fadd double %6, 5.000000e-05
%14 = fcmp olt double %13, 1.005000e+01
br i1 %14, label %5, label %15
15: ; preds = %5
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %15, %41
%18 = phi i64 [ 0, %15 ], [ %43, %41 ]
%19 = phi i32 [ 0, %15 ], [ %42, %41 ]
%20 = getelementptr inbounds [16385 x double], [16385 x double]* %3, i64 0, i64 %18
%21 = load double, double* %20
%22 = load double, double* @NETEM_DIST_SCALE
%23 = fmul double %21, %22
%24 = tail call i32 @rint(double %23)
%25 = trunc i64 %18 to i32
%26 = tail call i32 @paretovalue(i32 %25)
%27 = mul nsw i32 %26, 3
%28 = add nsw i32 %27, %24
%29 = sdiv i32 %28, 4
%30 = load i32, i32* @SHRT_MIN
%31 = icmp slt i32 %29, %30
%32 = select i1 %31, i32 %30, i32 %29
%33 = load i32, i32* @SHRT_MAX
%34 = icmp sgt i32 %32, %33
%35 = select i1 %34, i32 %33, i32 %32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = add nsw i32 %19, 1
%38 = icmp eq i32 %37, 8
br i1 %38, label %39, label %41
39: ; preds = %17
%40 = tail call i32 @putchar(i8 signext 10)
br label %41
41: ; preds = %39, %17
%42 = phi i32 [ 0, %39 ], [ %37, %17 ]
%43 = add nuw nsw i64 %18, 4
%44 = icmp ult i64 %18, 16380
br i1 %44, label %17, label %45
45: ; preds = %41
ret i32 0
}