#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 */
int /*<<< orphan*/ printf(char *, ...);
size_t random7_int();
size_t random7_pair();
int /*<<< orphan*/ srand48(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int i, count[7];
  srand48(time(NULL));
  for (i = 0; i < 7; i++)
    count[i] = 0;
  for (i = 0; i < 1.4e5; i++)
    count[random7_pair()]++;
  printf("random7_pair bin counts:\n");
  for (i = 0; i < 7; i++)
    printf("Bin %d count %d.\n", i, count[i]);
  for (i = 0; i < 7; i++)
    count[i] = 0;
  for (i = 0; i < 1.4e5; i++)
    count[random7_int()]++;
  printf("random7_int bin counts:\n");
  for (i = 0; i < 7; i++)
    printf("Bin %d count %d.\n", i, count[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1070 <srand48@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    119a <main+0x4a>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <main+0x26>
movl   $0x0,-0x8(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe52(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d8 <main+0x88>
mov    $0x0,%al
call   1030 <random7_pair@plt>
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a1 <main+0x51>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    121e <main+0xce>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ed <main+0x9d>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    1249 <main+0xf9>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1225 <main+0xd5>
movl   $0x0,-0x8(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xda3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1287 <main+0x137>
mov    $0x0,%al
call   1060 <random7_int@plt>
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1250 <main+0x100>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    12cd <main+0x17d>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    129c <main+0x14c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1080 <srand48@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movups %xmm0,0xc(%rsp)
mov    $0x222e0,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <random7_pair@plt>
addl   $0x1,(%rsp,%rax,4)
add    $0xffffffff,%ebx
jne    1190 <main+0x30>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%edx
lea    0xe4a(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movups %xmm0,0xc(%rsp)
mov    $0x222e0,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1070 <random7_int@plt>
addl   $0x1,(%rsp,%rax,4)
add    $0xffffffff,%ebx
jne    1250 <main+0xf0>
lea    0xdc4(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%edx
lea    0xd8a(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"random7_pair bin counts:\0A\00"
@.str.1 = [18 x i8] c"Bin %d count %d.\0A\00"
@.str.2 = [25 x i8] c"random7_int bin counts:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [7 x i32]
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand48(i32 %4)
store i32 0, i32* %2
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 7
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %11
store i32 0, i32* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %6
16: ; preds = %6
store i32 0, i32* %2
br label %17
17: ; preds = %26, %16
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to double
%20 = fcmp olt double %19, 1.400000e+05
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = call i64 (...) @random7_pair()
%23 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %23
br label %26
26: ; preds = %21
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %17
29: ; preds = %17
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %31
31: ; preds = %41, %29
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 7
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32, i32* %2
%36 = load i32, i32* %2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %39)
br label %41
41: ; preds = %34
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %31
44: ; preds = %31
store i32 0, i32* %2
br label %45
45: ; preds = %52, %44
%46 = load i32, i32* %2
%47 = icmp slt i32 %46, 7
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %50
store i32 0, i32* %51
br label %52
52: ; preds = %48
%53 = load i32, i32* %2
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
br label %45
55: ; preds = %45
store i32 0, i32* %2
br label %56
56: ; preds = %65, %55
%57 = load i32, i32* %2
%58 = sitofp i32 %57 to double
%59 = fcmp olt double %58, 1.400000e+05
br i1 %59, label %60, label %68
60: ; preds = %56
%61 = call i64 (...) @random7_int()
%62 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %61
%63 = load i32, i32* %62
%64 = add nsw i32 %63, 1
store i32 %64, i32* %62
br label %65
65: ; preds = %60
%66 = load i32, i32* %2
%67 = add nsw i32 %66, 1
store i32 %67, i32* %2
br label %56
68: ; preds = %56
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %70
70: ; preds = %80, %68
%71 = load i32, i32* %2
%72 = icmp slt i32 %71, 7
br i1 %72, label %73, label %83
73: ; preds = %70
%74 = load i32, i32* %2
%75 = load i32, i32* %2
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %76
%78 = load i32, i32* %77
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %74, i32 %78)
br label %80
80: ; preds = %73
%81 = load i32, i32* %2
%82 = add nsw i32 %81, 1
store i32 %82, i32* %2
br label %70
83: ; preds = %70
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"Bin %d count %d.\0A\00"
@str = [25 x i8] c"random7_pair bin counts:\00"
@str.3 = [24 x i8] c"random7_int bin counts:\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand48(i32 %3)
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ %11, %5 ], [ 0, %0 ]
%7 = tail call i64 (...) @random7_pair()
%8 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 %7
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
store i32 %10, i32* %8
%11 = add nuw nsw i32 %6, 1
%12 = icmp eq i32 %11, 140000
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%15 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %16)
%18 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 1
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %19)
%21 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 2
%22 = load i32, i32* %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %22)
%24 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 3
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %25)
%27 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 4
%28 = load i32, i32* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %28)
%30 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 5
%31 = load i32, i32* %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %31)
%33 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 6
%34 = load i32, i32* %33
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %34)
br label %36
36: ; preds = %13, %36
%37 = phi i32 [ %42, %36 ], [ 0, %13 ]
%38 = tail call i64 (...) @random7_int()
%39 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
%42 = add nuw nsw i32 %37, 1
%43 = icmp eq i32 %42, 140000
br i1 %43, label %44, label %36
44: ; preds = %36
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.3, i64 0, i64 0))
%46 = load i32, i32* %15
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %46)
%48 = load i32, i32* %18
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %48)
%50 = load i32, i32* %21
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %50)
%52 = load i32, i32* %24
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %52)
%54 = load i32, i32* %27
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %54)
%56 = load i32, i32* %30
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %56)
%58 = load i32, i32* %33
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %58)
ret i32 0
}