#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 */
typedef int uint8_t;

/* Variables and functions */
int *calloc(int, int);
int flipcoins();
int /*<<< orphan*/ printf(char *, int, ...);
void main() {
  uint8_t *results = calloc(4, sizeof(uint8_t));
  uint8_t curResult;
  for (int i = 0; i < 5000; i++) {
    curResult = flipcoins();
    results[curResult - 1]++;
  }
  for (int i = 0; i < 4; i++) {
    printf("%u: %u\n", i + 1, results[i]);
  }
  uint8_t j = 8;
  for (; j >= 20; j--)
    ;
  printf("%u", j);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x4,%esi
mov    %esi,%edi
call   1040 <calloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1388,-0x10(%rbp)
jge    118a <main+0x5a>
mov    $0x0,%al
call   1050 <flipcoins@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <main+0x1f>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11c8 <main+0x98>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <main+0x61>
movl   $0x8,-0x18(%rbp)
cmpl   $0x14,-0x18(%rbp)
jl     11ec <main+0xbc>
jmp    11de <main+0xae>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11cf <main+0x9f>
mov    -0x18(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x4,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    $0x1388,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <flipcoins@plt>
cltq
addl   $0x1,-0x4(%rbx,%rax,4)
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
mov    (%rbx),%edx
lea    0xe94(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rbx),%edx
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%edx
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rbx),%edx
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%u: %u\0A\00"
@.str.1 = [3 x i8] c"%u\00"
define void @main() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32* @calloc(i32 4, i32 4)
store i32* %6, i32** %1
store i32 0, i32* %3
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 5000
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = call i32 (...) @flipcoins()
store i32 %11, i32* %2
%12 = load i32*, i32** %1
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %12, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
br label %19
19: ; preds = %10
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %7
22: ; preds = %7
store i32 0, i32* %4
br label %23
23: ; preds = %35, %22
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
%29 = load i32*, i32** %1
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %33)
br label %35
35: ; preds = %26
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %23
38: ; preds = %23
store i32 8, i32* %5
br label %39
39: ; preds = %43, %38
%40 = load i32, i32* %5
%41 = icmp sge i32 %40, 20
br i1 %41, label %42, label %46
42: ; preds = %39
br label %43
43: ; preds = %42
%44 = load i32, i32* %5
%45 = add nsw i32 %44, -1
store i32 %45, i32* %5
br label %39
46: ; preds = %39
%47 = load i32, i32* %5
%48 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %47)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%u: %u\0A\00"
@.str.1 = [3 x i8] c"%u\00"
define void @main() {
%1 = tail call i32* @calloc(i32 4, i32 4)
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %10, %2 ]
%4 = tail call i32 (...) @flipcoins()
%5 = add nsw i32 %4, -1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1
store i32 %9, i32* %7
%10 = add nuw nsw i32 %3, 1
%11 = icmp eq i32 %10, 5000
br i1 %11, label %12, label %2
12: ; preds = %2
%13 = load i32, i32* %1
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 1, i32 %13)
%15 = getelementptr inbounds i32, i32* %1, i64 1
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 2, i32 %16)
%18 = getelementptr inbounds i32, i32* %1, i64 2
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 3, i32 %19)
%21 = getelementptr inbounds i32, i32* %1, i64 3
%22 = load i32, i32* %21
%23 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 4, i32 %22)
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 8)
ret void
}