#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 gasdev(long *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char words[50 + 1];
  int i, j, k, klim, dist[20 + 1];
  long idum = (-13);
  float dd, x;
  for (j = 0; j <= 20; j++)
    dist[j] = 0;
  for (i = 1; i <= 10000; i++) {
    x = 0.25 * 20 * gasdev(&idum);
    j = (int)(x > 0 ? x + 0.5 : x - 0.5);
    if ((j >= -(20 / 2)) && (j <= (20 / 2)))
      ++dist[j + (20 / 2)];
  }
  printf("Normally distributed deviate of %6d points\n", 10000);
  printf("%5s %10s %9s\n", "x", "p(x)", "graph:");
  for (j = 0; j <= 20; j++) {
    dd = (float)dist[j] / 10000;
    for (k = 1; k <= 50; k++)
      words[k] = ' ';
    klim = (int)(400 * dd);
    if (klim > 50)
      klim = 50;
    for (k = 1; k <= klim; k++)
      words[k] = '*';
    printf("%8.4f %8.4f  ", j / (0.25 * 20), dd);
    for (k = 1; k <= 50; k++)
      printf("%c", words[k]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xfffffffffffffff3,-0xb8(%rbp)
f3 ff ff ff
movl   $0x0,-0x48(%rbp)
cmpl   $0x14,-0x48(%rbp)
jg     116b <main+0x4b>
movslq -0x48(%rbp),%rax
movl   $0x0,-0xb0(%rbp,%rax,4)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1144 <main+0x24>
movl   $0x1,-0x44(%rbp)
cmpl   $0x2710,-0x44(%rbp)
jg     124e <main+0x12e>
lea    -0xb8(%rbp),%rdi
call   1040 <gasdev@plt>
movaps %xmm0,%xmm1
movsd  0xe72(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc0(%rbp)
ff
movss  -0xc0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11df <main+0xbf>
movss  -0xc0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xe42(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
jmp    11ff <main+0xdf>
movss  -0xc0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xe1d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
cvttsd2si %xmm0,%eax
mov    %eax,-0x48(%rbp)
cmpl   $0xfffffff6,-0x48(%rbp)
jl     123b <main+0x11b>
cmpl   $0xa,-0x48(%rbp)
jg     123b <main+0x11b>
mov    -0x48(%rbp),%eax
add    $0xa,%eax
cltq
mov    -0xb0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xb0(%rbp,%rax,4)
jmp    1240 <main+0x120>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1172 <main+0x52>
lea    0xdc3(%rip),%rdi
mov    $0x2710,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xddc(%rip),%rdi
lea    0xde3(%rip),%rsi
lea    0xdde(%rip),%rdx
lea    0xddc(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x48(%rbp)
cmpl   $0x14,-0x48(%rbp)
jg     13ad <main+0x28d>
movslq -0x48(%rbp),%rax
cvtsi2ssl -0xb0(%rbp,%rax,4),%xmm0
ff ff
movss  0xd56(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xbc(%rbp)
ff
movl   $0x1,-0x4c(%rbp)
cmpl   $0x32,-0x4c(%rbp)
jg     12de <main+0x1be>
movslq -0x4c(%rbp),%rax
movb   $0x20,-0x40(%rbp,%rax,1)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12bd <main+0x19d>
movss  0xd1e(%rip),%xmm0
mulss  -0xbc(%rbp),%xmm0
ff
cvttss2si %xmm0,%eax
mov    %eax,-0x50(%rbp)
cmpl   $0x32,-0x50(%rbp)
jle    1306 <main+0x1e6>
movl   $0x32,-0x50(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jg     1330 <main+0x210>
movslq -0x4c(%rbp),%rax
movb   $0x2a,-0x40(%rbp,%rax,1)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    130d <main+0x1ed>
cvtsi2sdl -0x48(%rbp),%xmm0
movsd  0xccb(%rip),%xmm1
divsd  %xmm1,%xmm0
movss  -0xbc(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
lea    0xd0c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x1,-0x4c(%rbp)
cmpl   $0x32,-0x4c(%rbp)
jg     1391 <main+0x271>
movslq -0x4c(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1362 <main+0x242>
lea    0xcb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    128b <main+0x16b>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb0,%rsp
movq   $0xfffffffffffffff3,0x8(%rsp)
ff ff
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x30(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x50(%rsp)
movl   $0x0,0x60(%rsp)
mov    $0x2710,%ebp
lea    0x8(%rsp),%r14
lea    0xe7d(%rip),%rbx
jmp    11a5 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebp
je     11e3 <main+0xa3>
mov    %r14,%rdi
call   1060 <gasdev@plt>
mulsd  0xe4b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
xor    %eax,%eax
ucomiss 0xe76(%rip),%xmm0
seta   %al
cvtss2sd %xmm0,%xmm0
addsd  (%rbx,%rax,8),%xmm0
cvttsd2si %xmm0,%eax
add    $0xa,%eax
cmp    $0x14,%eax
ja     11a0 <main+0x60>
mov    %eax,%eax
addl   $0x1,0x10(%rsp,%rax,4)
jmp    11a0 <main+0x60>
lea    0xe52(%rip),%rdi
xor    %ebx,%ebx
mov    $0x2710,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
lea    0xe70(%rip),%rsi
lea    0xe6b(%rip),%rdx
lea    0xe69(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x71(%rsp),%r15
mov    $0x32,%r12d
lea    0xe57(%rip),%r14
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2ssl 0x10(%rsp,%rbx,4),%xmm1
movaps 0xde0(%rip),%xmm0
movups %xmm0,0x20(%r15)
movups %xmm0,0x10(%r15)
movups %xmm0,(%r15)
movw   $0x2020,0x30(%r15)
divss  0xdd3(%rip),%xmm1
movaps %xmm1,%xmm0
mulss  0xdcc(%rip),%xmm0
cvttss2si %xmm0,%eax
cmp    $0x32,%eax
cmovge %r12d,%eax
test   %eax,%eax
jle    1292 <main+0x152>
mov    %eax,%edx
mov    %r15,%rdi
mov    $0x2a,%esi
movss  %xmm1,0x4(%rsp)
call   1050 <memset@plt>
movss  0x4(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  0xd5f(%rip),%xmm0
cvtss2sd %xmm1,%xmm1
mov    %r14,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x70(%rsp,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    $0x33,%rbp
jne    12c0 <main+0x180>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x15,%rbx
jne    1230 <main+0xf0>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Normally distributed deviate of %6d points\0A\00"
@.str.1 = [14 x i8] c"%5s %10s %9s\0A\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [5 x i8] c"p(x)\00"
@.str.4 = [7 x i8] c"graph:\00"
@.str.5 = [14 x i8] c"%8.4f %8.4f \00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [51 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [21 x i32]
%8 = alloca i64
%9 = alloca float
%10 = alloca float
store i32 0, i32* %1
store i64 -13, i64* %8
store i32 0, i32* %4
br label %11
11: ; preds = %18, %0
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 20
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [21 x i32], [21 x i32]* %7, i64 0, i64 %16
store i32 0, i32* %17
br label %18
18: ; preds = %14
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %11
21: ; preds = %11
store i32 1, i32* %3
br label %22
22: ; preds = %55, %21
%23 = load i32, i32* %3
%24 = icmp sle i32 %23, 10000
br i1 %24, label %25, label %58
25: ; preds = %22
%26 = call double @gasdev(i64* %8)
%27 = fmul double 5.000000e+00, %26
%28 = fptrunc double %27 to float
store float %28, float* %10
%29 = load float, float* %10
%30 = fcmp ogt float %29, 0.000000e+00
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = load float, float* %10
%33 = fpext float %32 to double
%34 = fadd double %33, 5.000000e-01
br label %39
35: ; preds = %25
%36 = load float, float* %10
%37 = fpext float %36 to double
%38 = fsub double %37, 5.000000e-01
br label %39
39: ; preds = %35, %31
%40 = phi double [ %34, %31 ], [ %38, %35 ]
%41 = fptosi double %40 to i32
store i32 %41, i32* %4
%42 = load i32, i32* %4
%43 = icmp sge i32 %42, -10
br i1 %43, label %44, label %54
44: ; preds = %39
%45 = load i32, i32* %4
%46 = icmp sle i32 %45, 10
br i1 %46, label %47, label %54
47: ; preds = %44
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [21 x i32], [21 x i32]* %7, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = add nsw i32 %52, 1
store i32 %53, i32* %51
br label %54
54: ; preds = %47, %44, %39
br label %55
55: ; preds = %54
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %22
58: ; preds = %22
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 10000)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %61
61: ; preds = %122, %58
%62 = load i32, i32* %4
%63 = icmp sle i32 %62, 20
br i1 %63, label %64, label %125
64: ; preds = %61
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [21 x i32], [21 x i32]* %7, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = sitofp i32 %68 to float
%70 = fdiv float %69, 1.000000e+04
store float %70, float* %9
store i32 1, i32* %5
br label %71
71: ; preds = %78, %64
%72 = load i32, i32* %5
%73 = icmp sle i32 %72, 50
br i1 %73, label %74, label %81
74: ; preds = %71
%75 = load i32, i32* %5
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [51 x i8], [51 x i8]* %2, i64 0, i64 %76
store i8 32, i8* %77
br label %78
78: ; preds = %74
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
store i32 %80, i32* %5
br label %71
81: ; preds = %71
%82 = load float, float* %9
%83 = fmul float 4.000000e+02, %82
%84 = fptosi float %83 to i32
store i32 %84, i32* %6
%85 = load i32, i32* %6
%86 = icmp sgt i32 %85, 50
br i1 %86, label %87, label %88
87: ; preds = %81
store i32 50, i32* %6
br label %88
88: ; preds = %87, %81
store i32 1, i32* %5
br label %89
89: ; preds = %97, %88
%90 = load i32, i32* %5
%91 = load i32, i32* %6
%92 = icmp sle i32 %90, %91
br i1 %92, label %93, label %100
93: ; preds = %89
%94 = load i32, i32* %5
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [51 x i8], [51 x i8]* %2, i64 0, i64 %95
store i8 42, i8* %96
br label %97
97: ; preds = %93
%98 = load i32, i32* %5
%99 = add nsw i32 %98, 1
store i32 %99, i32* %5
br label %89
100: ; preds = %89
%101 = load i32, i32* %4
%102 = sitofp i32 %101 to double
%103 = fdiv double %102, 5.000000e+00
%104 = load float, float* %9
%105 = fpext float %104 to double
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %103, double %105)
store i32 1, i32* %5
br label %107
107: ; preds = %117, %100
%108 = load i32, i32* %5
%109 = icmp sle i32 %108, 50
br i1 %109, label %110, label %120
110: ; preds = %107
%111 = load i32, i32* %5
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [51 x i8], [51 x i8]* %2, i64 0, i64 %112
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %115)
br label %117
117: ; preds = %110
%118 = load i32, i32* %5
%119 = add nsw i32 %118, 1
store i32 %119, i32* %5
br label %107
120: ; preds = %107
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %122
122: ; preds = %120
%123 = load i32, i32* %4
%124 = add nsw i32 %123, 1
store i32 %124, i32* %4
br label %61
125: ; preds = %61
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"Normally distributed deviate of %6d points\0A\00"
@.str.1 = [14 x i8] c"%5s %10s %9s\0A\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [5 x i8] c"p(x)\00"
@.str.4 = [7 x i8] c"graph:\00"
@.str.5 = [14 x i8] c"%8.4f %8.4f \00"
define i32 @main() {
%1 = alloca [51 x i8]
%2 = alloca [21 x i32]
%3 = bitcast [21 x i32]* %2 to i8*
%4 = alloca i64
%5 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%6 = bitcast i64* %4 to i8*
store i64 -13, i64* %4
br label %7
7: ; preds = %0, %24
%8 = phi i32 [ %25, %24 ], [ 1, %0 ]
%9 = call double @gasdev(i64* %4)
%10 = fmul double %9, 5.000000e+00
%11 = fptrunc double %10 to float
%12 = fcmp ogt float %11, 0.000000e+00
%13 = fpext float %11 to double
%14 = select i1 %12, double 5.000000e-01, double -5.000000e-01
%15 = fadd double %14, %13
%16 = fptosi double %15 to i32
%17 = add i32 %16, 10
%18 = icmp ult i32 %17, 21
br i1 %18, label %19, label %24
19: ; preds = %7
%20 = zext i32 %17 to i64
%21 = getelementptr inbounds [21 x i32], [21 x i32]* %2, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %24
24: ; preds = %7, %19
%25 = add nuw nsw i32 %8, 1
%26 = icmp eq i32 %25, 10001
br i1 %26, label %27, label %7
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 10000)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%30 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 1
br label %31
31: ; preds = %27, %58
%32 = phi i64 [ 0, %27 ], [ %60, %58 ]
%33 = getelementptr inbounds [21 x i32], [21 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = sitofp i32 %34 to float
%36 = fdiv float %35, 1.000000e+04
%37 = fmul float %36, 4.000000e+02
%38 = fptosi float %37 to i32
%39 = icmp slt i32 %38, 50
%40 = select i1 %39, i32 %38, i32 50
%41 = icmp slt i32 %40, 1
br i1 %41, label %44, label %42
42: ; preds = %31
%43 = zext i32 %40 to i64
br label %44
44: ; preds = %42, %31
%45 = trunc i64 %32 to i32
%46 = sitofp i32 %45 to double
%47 = fdiv double %46, 5.000000e+00
%48 = fpext float %36 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %47, double %48)
br label %50
50: ; preds = %44, %50
%51 = phi i64 [ 1, %44 ], [ %56, %50 ]
%52 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = call i32 @putchar(i32 %54)
%56 = add nuw nsw i64 %51, 1
%57 = icmp eq i64 %56, 51
br i1 %57, label %58, label %50
58: ; preds = %50
%59 = call i32 @putchar(i32 10)
%60 = add nuw nsw i64 %32, 1
%61 = icmp eq i64 %60, 21
br i1 %61, label %62, label %31
62: ; preds = %58
ret i32 0
}