#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 /*<<< 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 normal distribution.\n");
  for (i = n = 0; i < 16384; i += 4) {
    int value = (int)rint(table[i] * NETEM_DIST_SCALE);
    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  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe9a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11c6 <main+0x86>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
movsd  0xe87(%rip),%xmm2
call   1060 <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  0xe61(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1166 <main+0x26>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4000,-0x14(%rbp)
jge    12a4 <main+0x164>
movslq -0x14(%rbp),%rax
movsd  -0x20030(%rbp,%rax,8),%xmm0
fd ff
mov    0x2de5(%rip),%rax
mulsd  (%rax),%xmm0
call   1050 <rint@plt>
mov    %eax,-0x20034(%rbp)
mov    -0x20034(%rbp),%eax
mov    0x2db9(%rip),%rcx
cmp    (%rcx),%eax
jge    1236 <main+0xf6>
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20034(%rbp)
mov    -0x20034(%rbp),%eax
mov    0x2d8d(%rip),%rcx
cmp    (%rcx),%eax
jle    125a <main+0x11a>
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20034(%rbp)
mov    -0x20034(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x8,%eax
jne    1291 <main+0x151>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x18(%rbp)
jmp    1296 <main+0x156>
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    11e2 <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  0xe97(%rip),%xmm0
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
movsd  0xe81(%rip),%xmm2
call   1070 <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  0xe5f(%rip),%xmm0
movsd  0xe5f(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1170 <main+0x20>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffffffffffc,%rbx
mov    0x2e0f(%rip),%r15
mov    0x2df8(%rip),%r12
mov    0x2de9(%rip),%r13
lea    0xe32(%rip),%r14
xor    %ebp,%ebp
jmp    120d <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x4,%rbx
cmp    $0x3ffc,%rbx
jae    124f <main+0xff>
movsd  0x30(%rsp,%rbx,8),%xmm0
mulsd  (%r15),%xmm0
call   1060 <rint@plt>
mov    (%r12),%esi
cmp    %esi,%eax
cmovge %eax,%esi
mov    0x0(%r13),%eax
cmp    %eax,%esi
cmovg  %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x8,%ebp
jne    1200 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1200 <main+0xb0>
xor    %eax,%eax
add    $0x20018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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