#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__ floor(double);
double pcg32_float();
int pcg32_int();
int /*<<< orphan*/ pcg32_seed(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int counts[5] = {0, 0, 0, 0, 0};
  int i;
  pcg32_seed(42, 54);
  printf("%u\n", pcg32_int());
  printf("%u\n", pcg32_int());
  printf("%u\n", pcg32_int());
  printf("%u\n", pcg32_int());
  printf("%u\n", pcg32_int());
  printf("\n");
  pcg32_seed(987654321, 1);
  for (i = 0; i < 100000; i++) {
    int j = (int)floor(pcg32_float() * 5.0);
    counts[j]++;
  }
  printf("The counts for 100,000 repetitions are:\n");
  for (i = 0; i < 5; i++) {
    printf("  %d : %d\n", i, counts[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
mov    $0x2a,%edi
mov    $0x36,%esi
call   1070 <pcg32_seed@plt>
mov    $0x0,%al
call   1030 <pcg32_int@plt>
mov    %eax,%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <pcg32_int@plt>
mov    %eax,%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <pcg32_int@plt>
mov    %eax,%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <pcg32_int@plt>
mov    %eax,%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <pcg32_int@plt>
mov    %eax,%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x3ade68b1,%edi
mov    $0x1,%esi
call   1070 <pcg32_seed@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x186a0,-0x24(%rbp)
jge    126a <main+0x10a>
mov    $0x0,%al
call   1040 <pcg32_float@plt>
movsd  0xdbf(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1080 <floor@plt>
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1225 <main+0xc5>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    12b0 <main+0x150>
mov    -0x24(%rbp),%esi
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    127f <main+0x11f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    $0x2a,%edi
mov    $0x36,%esi
call   1080 <pcg32_seed@plt>
xor    %eax,%eax
call   1040 <pcg32_int@plt>
lea    0xe65(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1040 <pcg32_int@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1040 <pcg32_int@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1040 <pcg32_int@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1040 <pcg32_int@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x3ade68b1,%edi
mov    $0x1,%esi
call   1080 <pcg32_seed@plt>
mov    $0x186a0,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <pcg32_float@plt>
mulsd  0xdd1(%rip),%xmm0
call   1090 <floor@plt>
cltq
addl   $0x1,(%rsp,%rax,4)
add    $0xffffffff,%ebx
jne    1220 <main+0xb0>
lea    0xdd1(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%edx
lea    0xdb7(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%u\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [41 x i8] c"The counts for 100,000 repetitions are:\0A\00"
@.str.3 = [11 x i8] c" %d : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [5 x i32]* %2 to i8*
%6 = call i32 @pcg32_seed(i32 42, i32 54)
%7 = call i32 (...) @pcg32_int()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (...) @pcg32_int()
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 (...) @pcg32_int()
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @pcg32_int()
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @pcg32_int()
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @pcg32_seed(i32 987654321, i32 1)
store i32 0, i32* %3
br label %19
19: ; preds = %32, %0
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 100000
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = call double (...) @pcg32_float()
%24 = fmul double %23, 5.000000e+00
%25 = call i64 @floor(double %24)
%26 = trunc i64 %25 to i32
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
br label %32
32: ; preds = %22
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %19
35: ; preds = %19
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %37
37: ; preds = %47, %35
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 5
br i1 %39, label %40, label %50
40: ; preds = %37
%41 = load i32, i32* %3
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %45)
br label %47
47: ; preds = %40
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %37
50: ; preds = %37
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0A\00"
@.str.3 = [11 x i8] c" %d : %d\0A\00"
@str = [40 x i8] c"The counts for 100,000 repetitions are:\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i32 @pcg32_seed(i32 42, i32 54)
%4 = tail call i32 (...) @pcg32_int()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 (...) @pcg32_int()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 (...) @pcg32_int()
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = tail call i32 (...) @pcg32_int()
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = tail call i32 (...) @pcg32_int()
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 @putchar(i32 10)
%15 = tail call i32 @pcg32_seed(i32 987654321, i32 1)
br label %16
16: ; preds = %0, %16
%17 = phi i32 [ 0, %0 ], [ %26, %16 ]
%18 = tail call double (...) @pcg32_float()
%19 = fmul double %18, 5.000000e+00
%20 = tail call i64 @floor(double %19)
%21 = shl i64 %20, 32
%22 = ashr exact i64 %21, 32
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %23
%26 = add nuw nsw i32 %17, 1
%27 = icmp eq i32 %26, 100000
br i1 %27, label %28, label %16
28: ; preds = %16
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%30 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%31 = load i32, i32* %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %31)
%33 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%34 = load i32, i32* %33
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %34)
%36 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%37 = load i32, i32* %36
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %37)
%39 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%40 = load i32, i32* %39
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %40)
%42 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%43 = load i32, i32* %42
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %43)
ret i32 0
}