#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 atoi(char *);
int /*<<< orphan*/ printf(char *, short, ...);
int rand();
int /*<<< orphan*/ srand(int);
int main(int argc, char **argv) {
  int num_times = 1;
  short cur_card;
  int num_aces;
  short i;
  long stats[5];
  short cards[52];
  if (argc == 2)
    num_times = atoi(argv[1]);
  printf("Running test %d time(s)\n", num_times);
  srand(num_times);
  for (i = 0; i < 5; stats[i++] = 0)
    ;
  while (num_times--) {
    for (i = 0; i < 52; cards[i++] = 0)
      ;
    num_aces = 0;
    for (i = 0; i < 26; i++) {
      while (cards[cur_card = (rand() % 52)])
        ;
      cards[cur_card] = 1;
      if (cur_card < 4)
        num_aces++;
    }
    stats[num_aces]++;
  }
  for (i = 0; i < 5; i++)
    printf("Number of times %d aces were picked: %d\n", i, stats[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    117a <main+0x3a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
lea    0xe7c(%rip),%rdi
movswl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <srand@plt>
movw   $0x0,-0x1e(%rbp)
movswl -0x1e(%rbp),%eax
cmp    $0x5,%eax
jge    11cf <main+0x8f>
jmp    11ae <main+0x6e>
mov    -0x1e(%rbp),%ax
mov    %ax,%cx
add    $0x1,%cx
mov    %cx,-0x1e(%rbp)
movswq %ax,%rax
movq   $0x0,-0x50(%rbp,%rax,8)
jmp    119c <main+0x5c>
jmp    11d4 <main+0x94>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     12c1 <main+0x181>
movw   $0x0,-0x1e(%rbp)
movswl -0x1e(%rbp),%eax
cmp    $0x34,%eax
jge    1222 <main+0xe2>
jmp    1200 <main+0xc0>
mov    -0x1e(%rbp),%ax
mov    %ax,%cx
add    $0x1,%cx
mov    %cx,-0x1e(%rbp)
movswq %ax,%rax
movw   $0x0,-0xc0(%rbp,%rax,2)
jmp    11ee <main+0xae>
movl   $0x0,-0x1c(%rbp)
movw   $0x0,-0x1e(%rbp)
movswl -0x1e(%rbp),%eax
cmp    $0x1a,%eax
jge    12aa <main+0x16a>
jmp    1241 <main+0x101>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x34,%ecx
cltd
idiv   %ecx
mov    %dx,%ax
mov    %ax,-0x16(%rbp)
movswq %ax,%rax
cmpw   $0x0,-0xc0(%rbp,%rax,2)
je     126f <main+0x12f>
jmp    1241 <main+0x101>
movswq -0x16(%rbp),%rax
movw   $0x1,-0xc0(%rbp,%rax,2)
movswl -0x16(%rbp),%eax
cmp    $0x4,%eax
jge    1294 <main+0x154>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1299 <main+0x159>
mov    -0x1e(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1e(%rbp)
jmp    122f <main+0xef>
movslq -0x1c(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp,%rax,8)
jmp    11d4 <main+0x94>
movw   $0x0,-0x1e(%rbp)
movswl -0x1e(%rbp),%eax
cmp    $0x5,%eax
jge    1304 <main+0x1c4>
mov    -0x1e(%rbp),%ax
movswq -0x1e(%rbp),%rcx
mov    -0x50(%rbp,%rcx,8),%rdx
lea    0xd30(%rip),%rdi
movswl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1e(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1e(%rbp)
jmp    12c7 <main+0x187>
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    $0x98,%rsp
mov    $0x1,%r15d
cmp    $0x2,%edi
jne    1168 <main+0x28>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r15d
movswl %r15w,%esi
lea    0xe8d(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15d,%edi
call   1040 <srand@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
test   %r15d,%r15d
je     1261 <main+0x121>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x90(%rsp)
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x34,%ecx,%ecx
sub    %ecx,%eax
cltq
cmpw   $0x0,0x30(%rsp,%rax,2)
jne    11f0 <main+0xb0>
movw   $0x1,0x30(%rsp,%rax,2)
xor    %ecx,%ecx
cmp    $0x4,%eax
setl   %cl
add    %ecx,%ebp
add    $0x1,%ebx
cmp    $0x1a,%bx
jne    11f0 <main+0xb0>
mov    %ebp,%eax
addq   $0x1,(%rsp,%rax,8)
add    $0xffffffff,%r15d
jne    11b0 <main+0x70>
mov    (%rsp),%rdx
mov    0x8(%rsp),%r13
mov    0x10(%rsp),%r12
mov    0x18(%rsp),%r15
mov    0x20(%rsp),%r14
jmp    126c <main+0x12c>
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %edx,%edx
lea    0xda6(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r13,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Running test %d time(s)\0A\00"
@.str.1 = [41 x i8] c"Number of times %d aces were picked: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i16
%8 = alloca i32
%9 = alloca i16
%10 = alloca [5 x i64]
%11 = alloca [52 x i16]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
br label %19
19: ; preds = %14, %2
%20 = load i32, i32* %6
%21 = trunc i32 %20 to i16
%22 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i16 signext %21)
%23 = load i32, i32* %6
%24 = call i32 @srand(i32 %23)
store i16 0, i16* %9
br label %25
25: ; preds = %30, %19
%26 = load i16, i16* %9
%27 = sext i16 %26 to i32
%28 = icmp slt i32 %27, 5
br i1 %28, label %29, label %35
29: ; preds = %25
br label %30
30: ; preds = %29
%31 = load i16, i16* %9
%32 = add i16 %31, 1
store i16 %32, i16* %9
%33 = sext i16 %31 to i64
%34 = getelementptr inbounds [5 x i64], [5 x i64]* %10, i64 0, i64 %33
store i64 0, i64* %34
br label %25
35: ; preds = %25
br label %36
36: ; preds = %80, %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, -1
store i32 %38, i32* %6
%39 = icmp ne i32 %37, 0
br i1 %39, label %40, label %86
40: ; preds = %36
store i16 0, i16* %9
br label %41
41: ; preds = %46, %40
%42 = load i16, i16* %9
%43 = sext i16 %42 to i32
%44 = icmp slt i32 %43, 52
br i1 %44, label %45, label %51
45: ; preds = %41
br label %46
46: ; preds = %45
%47 = load i16, i16* %9
%48 = add i16 %47, 1
store i16 %48, i16* %9
%49 = sext i16 %47 to i64
%50 = getelementptr inbounds [52 x i16], [52 x i16]* %11, i64 0, i64 %49
store i16 0, i16* %50
br label %41
51: ; preds = %41
store i32 0, i32* %8
store i16 0, i16* %9
br label %52
52: ; preds = %77, %51
%53 = load i16, i16* %9
%54 = sext i16 %53 to i32
%55 = icmp slt i32 %54, 26
br i1 %55, label %56, label %80
56: ; preds = %52
br label %57
57: ; preds = %65, %56
%58 = call i32 (...) @rand()
%59 = srem i32 %58, 52
%60 = trunc i32 %59 to i16
store i16 %60, i16* %7
%61 = sext i16 %60 to i64
%62 = getelementptr inbounds [52 x i16], [52 x i16]* %11, i64 0, i64 %61
%63 = load i16, i16* %62
%64 = icmp ne i16 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %57
br label %57
66: ; preds = %57
%67 = load i16, i16* %7
%68 = sext i16 %67 to i64
%69 = getelementptr inbounds [52 x i16], [52 x i16]* %11, i64 0, i64 %68
store i16 1, i16* %69
%70 = load i16, i16* %7
%71 = sext i16 %70 to i32
%72 = icmp slt i32 %71, 4
br i1 %72, label %73, label %76
73: ; preds = %66
%74 = load i32, i32* %8
%75 = add nsw i32 %74, 1
store i32 %75, i32* %8
br label %76
76: ; preds = %73, %66
br label %77
77: ; preds = %76
%78 = load i16, i16* %9
%79 = add i16 %78, 1
store i16 %79, i16* %9
br label %52
80: ; preds = %52
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [5 x i64], [5 x i64]* %10, i64 0, i64 %82
%84 = load i64, i64* %83
%85 = add nsw i64 %84, 1
store i64 %85, i64* %83
br label %36
86: ; preds = %36
store i16 0, i16* %9
br label %87
87: ; preds = %98, %86
%88 = load i16, i16* %9
%89 = sext i16 %88 to i32
%90 = icmp slt i32 %89, 5
br i1 %90, label %91, label %101
91: ; preds = %87
%92 = load i16, i16* %9
%93 = load i16, i16* %9
%94 = sext i16 %93 to i64
%95 = getelementptr inbounds [5 x i64], [5 x i64]* %10, i64 0, i64 %94
%96 = load i64, i64* %95
%97 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i16 signext %92, i64 %96)
br label %98
98: ; preds = %91
%99 = load i16, i16* %9
%100 = add i16 %99, 1
store i16 %100, i16* %9
br label %87
101: ; preds = %87
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Running test %d time(s)\0A\00"
@.str.1 = [41 x i8] c"Number of times %d aces were picked: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5 x i64]
%4 = bitcast [5 x i64]* %3 to i8*
%5 = alloca [52 x i16]
%6 = bitcast [52 x i16]* %5 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
br label %12
12: ; preds = %8, %2
%13 = phi i32 [ %11, %8 ], [ 1, %2 ]
%14 = trunc i32 %13 to i16
%15 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i16 signext %14)
%16 = tail call i32 @srand(i32 %13)
%17 = icmp eq i32 %13, 0
br i1 %17, label %31, label %18
18: ; preds = %12, %59
%19 = phi i32 [ %60, %59 ], [ %13, %12 ]
br label %42
20: ; preds = %59
%21 = getelementptr inbounds [5 x i64], [5 x i64]* %3, i64 0, i64 0
%22 = load i64, i64* %21
%23 = getelementptr inbounds [5 x i64], [5 x i64]* %3, i64 0, i64 1
%24 = load i64, i64* %23
%25 = getelementptr inbounds [5 x i64], [5 x i64]* %3, i64 0, i64 2
%26 = load i64, i64* %25
%27 = getelementptr inbounds [5 x i64], [5 x i64]* %3, i64 0, i64 3
%28 = load i64, i64* %27
%29 = getelementptr inbounds [5 x i64], [5 x i64]* %3, i64 0, i64 4
%30 = load i64, i64* %29
br label %31
31: ; preds = %20, %12
%32 = phi i64 [ %30, %20 ], [ 0, %12 ]
%33 = phi i64 [ %28, %20 ], [ 0, %12 ]
%34 = phi i64 [ %26, %20 ], [ 0, %12 ]
%35 = phi i64 [ %24, %20 ], [ 0, %12 ]
%36 = phi i64 [ %22, %20 ], [ 0, %12 ]
%37 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i16 signext 0, i64 %36)
%38 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i16 signext 1, i64 %35)
%39 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i16 signext 2, i64 %34)
%40 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i16 signext 3, i64 %33)
%41 = tail call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i16 signext 4, i64 %32)
ret i32 0
42: ; preds = %18, %52
%43 = phi i16 [ %57, %52 ], [ 0, %18 ]
%44 = phi i32 [ %56, %52 ], [ 0, %18 ]
br label %45
45: ; preds = %42, %45
%46 = tail call i32 (...) @rand()
%47 = srem i32 %46, 52
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [52 x i16], [52 x i16]* %5, i64 0, i64 %48
%50 = load i16, i16* %49
%51 = icmp eq i16 %50, 0
br i1 %51, label %52, label %45
52: ; preds = %45
%53 = getelementptr inbounds [52 x i16], [52 x i16]* %5, i64 0, i64 %48
store i16 1, i16* %53
%54 = icmp slt i32 %47, 4
%55 = zext i1 %54 to i32
%56 = add nuw nsw i32 %44, %55
%57 = add nuw nsw i16 %43, 1
%58 = icmp eq i16 %57, 26
br i1 %58, label %59, label %42
59: ; preds = %52
%60 = add nsw i32 %19, -1
%61 = zext i32 %56 to i64
%62 = getelementptr inbounds [5 x i64], [5 x i64]* %3, i64 0, i64 %61
%63 = load i64, i64* %62
%64 = add nsw i64 %63, 1
store i64 %64, i64* %62
%65 = icmp eq i32 %60, 0
br i1 %65, label %20, label %18
}