#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 *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  printf("Heads or Tails [h|t]? \n");
  char buffer;
  scanf("%c", &buffer);
  srand(time(NULL));
  short int outcome = (rand() % 2);
  if (buffer == 'h') {
    if (outcome == 0) {
      printf("Winner!\n");
    } else {
      printf("Loser!\n");
    }
  }
  if (buffer == 't') {
    if (outcome == 1) {
      printf("Winner!\n");
    } else {
      printf("Loser!\n");
    }
  }
  if (buffer != 'h' && buffer != 't') {
    printf("%c is not a correct input", buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %dx,%ax
mov    %ax,-0x8(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
jne    11e3 <main+0x93>
movswl -0x8(%rbp),%eax
cmp    $0x0,%eax
jne    11d0 <main+0x80>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <main+0x8e>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <main+0x93>
movsbl -0x5(%rbp),%eax
cmp    $0x74,%eax
jne    1223 <main+0xd3>
movswl -0x8(%rbp),%eax
cmp    $0x1,%eax
jne    1210 <main+0xc0>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <main+0xce>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1223 <main+0xd3>
movsbl -0x5(%rbp),%eax
cmp    $0x68,%eax
je     124f <main+0xff>
movsbl -0x5(%rbp),%eax
cmp    $0x74,%eax
je     124f <main+0xff>
movsbl -0x5(%rbp),%esi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
shr    $0x1f,%eax
add    %ebx,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebx
mov    0xf(%rsp),%al
cmp    $0x68,%al
jne    11c8 <main+0x68>
test   %ebx,%ebx
lea    0xe87(%rip),%rax
lea    0xe79(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    0xf(%rsp),%al
cmp    $0x74,%al
jne    11e6 <main+0x86>
cmp    $0x1,%ebx
lea    0xe65(%rip),%rax
lea    0xe57(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
movsbl 0xf(%rsp),%esi
cmp    $0x68,%esi
je     1204 <main+0xa4>
cmp    $0x74,%sil
je     1204 <main+0xa4>
lea    0xe06(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Heads or Tails [h|t]? \0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [9 x i8] c"Winner!\0A\00"
@.str.3 = [8 x i8] c"Loser!\0A\00"
@.str.4 = [26 x i8] c"%c is not a correct input\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i16
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 2
%10 = trunc i32 %9 to i16
store i16 %10, i16* %3
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 104
br i1 %13, label %14, label %23
14: ; preds = %0
%15 = load i16, i16* %3
%16 = sext i16 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %22
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
br label %23
23: ; preds = %22, %0
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 116
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i16, i16* %3
%29 = sext i16 %28 to i32
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %35
33: ; preds = %27
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
br label %36
36: ; preds = %35, %23
%37 = load i8, i8* %2
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 104
br i1 %39, label %40, label %48
40: ; preds = %36
%41 = load i8, i8* %2
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 116
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8, i8* %2
%46 = sext i8 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %44, %40, %36
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@.str.4 = [26 x i8] c"%c is not a correct input\00"
@str = [23 x i8] c"Heads or Tails [h|t]? \00"
@str.7 = [7 x i8] c"Loser!\00"
@str.8 = [8 x i8] c"Winner!\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 2
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 104
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = icmp eq i32 %7, 0
%12 = select i1 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.7, i64 0, i64 0)
%13 = call i32 @puts(i8* dereferenceable(1) %12)
%14 = load i8, i8* %1
br label %15
15: ; preds = %10, %0
%16 = phi i8 [ %14, %10 ], [ %8, %0 ]
%17 = icmp eq i8 %16, 116
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = icmp eq i32 %7, 1
%20 = select i1 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.7, i64 0, i64 0)
%21 = call i32 @puts(i8* dereferenceable(1) %20)
br label %22
22: ; preds = %18, %15
%23 = load i8, i8* %1
switch i8 %23, label %24 [
i8 116, label %27
i8 104, label %27
]
24: ; preds = %22
%25 = sext i8 %23 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %22, %22, %24
ret i32 0
}