#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 */
scalar_t__ poidev(float, long *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main(void) {
  char txt[50 + 1];
  long idum = (-13);
  int i, j, k, klim, dist[20 + 1];
  float xm, dd;
  for (;;) {
    for (j = 0; j <= 20; j++)
      dist[j] = 0;
    do {
      printf("Mean of Poisson distribution (0.0<x<%d.0) ", 20);
      printf("- Negative to end:\n");
      scanf("%f", &xm);
    } while (xm > 20);
    if (xm < 0.0)
      break;
    for (i = 1; i <= 10000; i++) {
      j = (int)(0.5 + poidev(xm, &idum));
      if ((j >= 0) && (j <= 20))
        ++dist[j];
    }
    printf("Poisson-distributed deviate, mean %5.2f of %6d points\n", xm,
           10000);
    printf("%5s %8s %10s\n", "x", "p(x)", "graph:");
    for (j = 0; j <= 20; j++) {
      dd = (float)dist[j] / 10000;
      for (k = 0; k <= 50; k++)
        txt[k] = ' ';
      klim = (int)(200 * dd);
      if (klim > 50)
        klim = 50;
      for (k = 1; k <= klim; k++)
        txt[k] = '*';
      txt[50] = '\0';
      printf("%6d %8.4f   %s\n", j, dd, txt);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xfffffffffffffff3,-0x48(%rbp)
ff
movl   $0x0,-0x50(%rbp)
cmpl   $0x14,-0x50(%rbp)
jg     1178 <main+0x48>
movslq -0x50(%rbp),%rax
movl   $0x0,-0xb0(%rbp,%rax,4)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1151 <main+0x21>
jmp    117d <main+0x4d>
lea    0xe94(%rip),%rdi
mov    $0x14,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0xb4(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xb4(%rbp),%xmm0
ff
movss  0xe3f(%rip),%xmm1
ucomiss %xmm1,%xmm0
ja     117d <main+0x4d>
movss  -0xb4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11e8 <main+0xb8>
jmp    1387 <main+0x257>
movl   $0x1,-0x4c(%rbp)
cmpl   $0x2710,-0x4c(%rbp)
jg     1261 <main+0x131>
movss  -0xb4(%rbp),%xmm0
ff
lea    -0x48(%rbp),%rdi
call   1050 <poidev@plt>
cvtsi2sd %rax,%xmm1
movsd  0xdf6(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jl     124e <main+0x11e>
cmpl   $0x14,-0x50(%rbp)
jg     124e <main+0x11e>
movslq -0x50(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xb0(%rbp,%rax,4)
jmp    1253 <main+0x123>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11ef <main+0xbf>
movss  -0xb4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xde6(%rip),%rdi
mov    $0x2710,%esi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe0a(%rip),%rdi
lea    0xe11(%rip),%rsi
lea    0xe0c(%rip),%rdx
lea    0xe0a(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x50(%rbp)
cmpl   $0x14,-0x50(%rbp)
jg     1382 <main+0x252>
movslq -0x50(%rbp),%rax
cvtsi2ssl -0xb0(%rbp,%rax,4),%xmm0
ff ff
movss  0xd3b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xb8(%rbp)
ff
movl   $0x0,-0x54(%rbp)
cmpl   $0x32,-0x54(%rbp)
jg     12fd <main+0x1cd>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x40(%rbp,%rax,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12dc <main+0x1ac>
movss  0xd03(%rip),%xmm0
mulss  -0xb8(%rbp),%xmm0
ff
cvttss2si %xmm0,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x32,-0x58(%rbp)
jle    1325 <main+0x1f5>
movl   $0x32,-0x58(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x58(%rbp),%eax
jg     134f <main+0x21f>
movslq -0x54(%rbp),%rax
movb   $0x2a,-0x40(%rbp,%rax,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    132c <main+0x1fc>
movb   $0x0,-0xe(%rbp)
mov    -0x50(%rbp),%esi
movss  -0xb8(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    -0x40(%rbp),%rdx
lea    0xd40(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12aa <main+0x17a>
jmp    114a <main+0x1a>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
movq   $0xfffffffffffffff3,0x8(%rsp)
ff ff
lea    0xf50(%rip),%r12
lea    0xee3(%rip),%r13
mov    %rsp,%rbx
lea    0xf2f(%rip),%r14
lea    0x10(%rsp),%r15
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movl   $0x0,0xa0(%rsp)
lea    0xe6c(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movss  0xe06(%rip),%xmm1
movss  (%rsp),%xmm0
ucomiss %xmm1,%xmm0
ja     11d0 <main+0x80>
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1337 <main+0x1e7>
mov    $0x2710,%ebp
jmp    122a <main+0xda>
nopw   0x0(%rax,%rax,1)
movss  (%rsp),%xmm0
add    $0xffffffff,%ebp
je     1260 <main+0x110>
lea    0x8(%rsp),%rdi
call   1070 <poidev@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xdcc(%rip),%xmm0
cvttsd2si %xmm0,%eax
cmp    $0x14,%eax
ja     1220 <main+0xd0>
mov    %eax,%eax
addl   $0x1,0x50(%rsp,%rax,4)
jmp    1220 <main+0xd0>
cs nopw 0x0(%rax,%rax,1)
cvtss2sd %xmm0,%xmm0
lea    0xdf3(%rip),%rdi
mov    $0x2710,%esi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe17(%rip),%rdi
lea    0xe1e(%rip),%rsi
lea    0xe19(%rip),%rdx
lea    0xe17(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
jmp    12c9 <main+0x179>
xchg   %ax,%ax
movb   $0x0,0x42(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    $0x15,%rbp
je     1190 <main+0x40>
xorps  %xmm1,%xmm1
cvtsi2ssl 0x50(%rsp,%rbp,4),%xmm1
movaps 0xd47(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movl   $0x20202020,0x3f(%rsp)
20
divss  0xd0c(%rip),%xmm1
movaps %xmm1,%xmm0
mulss  0xd05(%rip),%xmm0
cvttss2si %xmm0,%eax
cmp    $0x32,%eax
jl     1311 <main+0x1c1>
mov    $0x32,%eax
test   %eax,%eax
jle    12a0 <main+0x150>
mov    %eax,%edx
lea    0x11(%rsp),%rdi
mov    $0x2a,%esi
movss  %xmm1,0x4(%rsp)
call   1050 <memset@plt>
movss  0x4(%rsp),%xmm1
jmp    12a0 <main+0x150>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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