#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 flip();
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void main(void) {
  int i = 0, tails = 0, heads = 0;
  srand(time(NULL));
  for (i = 1; i <= 100; i++) {
    if (1 == flip()) {
      heads++;
    } else
      tails++;
  }
  printf("Heads=%d\tTails=%d\n", heads, tails);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jg     11be <main+0x7e>
mov    $0x0,%al
call   1050 <flip@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    11a2 <main+0x62>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ab <main+0x6b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b0 <main+0x70>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1174 <main+0x34>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x64,%ebx
xor    %r14d,%r14d
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <flip@plt>
xor    %ecx,%ecx
xor    %edx,%edx
cmp    $0x1,%eax
sete   %cl
setne  %dl
add    %edx,%ebp
add    %ecx,%r14d
add    $0xffffffff,%ebx
jne    1160 <main+0x20>
lea    0xe7b(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Heads=%d\09Tails=%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i32 1, i32* %1
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %1
%8 = icmp sle i32 %7, 100
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = call i32 (...) @flip()
%11 = icmp eq i32 1, %10
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %18
15: ; preds = %9
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %18
18: ; preds = %15, %12
br label %19
19: ; preds = %18
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
store i32 %21, i32* %1
br label %6
22: ; preds = %6
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Heads=%d\09Tails=%d\0A\00"
define void @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %13, %3 ]
%5 = phi i32 [ 0, %0 ], [ %11, %3 ]
%6 = phi i32 [ 1, %0 ], [ %14, %3 ]
%7 = tail call i32 (...) @flip()
%8 = icmp eq i32 %7, 1
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %5, %10
%12 = zext i1 %8 to i32
%13 = add nuw nsw i32 %4, %12
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, 101
br i1 %15, label %16, label %3
16: ; preds = %3
%17 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %11)
ret void
}