#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*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void main() {
  int mydice1, mydice2, yourdice1, yourdice2, myresult, yourresult;
  srand((unsigned)time(NULL));
  printf("Lets play a game.\n");
  printf("The highest score of the two dice wins\n");
  mydice1 = rand() % 6 + 1;
  printf("My first throw is %i\n", mydice1);
  mydice2 = rand() % 6 + 1;
  printf("My second throw is %i\n", mydice2);
  printf("Your turn now.\n");
  yourdice1 = rand() % 6 + 1;
  printf("Your first throw is %i\n", yourdice1);
  yourdice2 = rand() % 6 + 1;
  printf("Your second throw is %i\n", yourdice2);
  myresult = mydice1 + mydice2;
  yourresult = yourdice1 + yourdice2;
  printf("I scored %i , you scored %i\n", myresult, yourresult);
  if (myresult > yourresult)
    printf("I win , better luck next time.\n");
  else if (myresult < yourresult)
    printf("You win , you were lucky that time.\n");
  else
    printf("Its a tie.\n");
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    125f <main+0x11f>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1291 <main+0x151>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    127e <main+0x13e>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128c <main+0x14c>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1291 <main+0x151>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xeff(%rip),%rdi
call   1040 <puts@plt>
lea    0xf05(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r14d
add    $0x1,%r14d
lea    0xe40(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
lea    0xe1b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea9(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r15d
add    $0x1,%r15d
lea    0xdea(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
lea    0xdc7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    %r14d,%ebp
add    %r15d,%ebx
lea    0xdca(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %ebx,%ebp
lea    0xe26(%rip),%rax
lea    0xe14(%rip),%rcx
cmovl  %rax,%rcx
lea    0xe38(%rip),%rdi
cmovle %rcx,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Lets play a game.\0A\00"
@.str.1 = [40 x i8] c"The highest score of the two dice wins\0A\00"
@.str.2 = [22 x i8] c"My first throw is %i\0A\00"
@.str.3 = [23 x i8] c"My second throw is %i\0A\00"
@.str.4 = [16 x i8] c"Your turn now.\0A\00"
@.str.5 = [24 x i8] c"Your first throw is %i\0A\00"
@.str.6 = [25 x i8] c"Your second throw is %i\0A\00"
@.str.7 = [29 x i8] c"I scored %i , you scored %i\0A\00"
@.str.8 = [32 x i8] c"I win , better luck next time.\0A\00"
@.str.9 = [37 x i8] c"You win , you were lucky that time.\0A\00"
@.str.10 = [12 x i8] c"Its a tie.\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i64 @time(i32* null)
%8 = trunc i64 %7 to i32
%9 = call i32 @srand(i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 6
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %1
%34 = load i32, i32* %2
%35 = add nsw i32 %33, %34
store i32 %35, i32* %5
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = add nsw i32 %36, %37
store i32 %38, i32* %6
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %39, i32 %40)
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
br label %56
47: ; preds = %0
%48 = load i32, i32* %5
%49 = load i32, i32* %6
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
br label %55
53: ; preds = %47
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %55
55: ; preds = %53, %51
br label %56
56: ; preds = %55, %45
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [22 x i8] c"My first throw is %i\0A\00"
@.str.3 = [23 x i8] c"My second throw is %i\0A\00"
@.str.5 = [24 x i8] c"Your first throw is %i\0A\00"
@.str.6 = [25 x i8] c"Your second throw is %i\0A\00"
@.str.7 = [29 x i8] c"I scored %i , you scored %i\0A\00"
@str = [18 x i8] c"Lets play a game.\00"
@str.12 = [39 x i8] c"The highest score of the two dice wins\00"
@str.13 = [15 x i8] c"Your turn now.\00"
@str.14 = [11 x i8] c"Its a tie.\00"
@str.15 = [36 x i8] c"You win , you were lucky that time.\00"
@str.16 = [31 x i8] c"I win , better luck next time.\00"
define void @main() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.12, i64 0, i64 0))
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 6
%8 = add nsw i32 %7, 1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 6
%12 = add nsw i32 %11, 1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 6
%17 = add nsw i32 %16, 1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 6
%21 = add nsw i32 %20, 1
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%23 = add nsw i32 %12, %8
%24 = add nsw i32 %21, %17
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %23, i32 %24)
%26 = icmp sgt i32 %23, %24
%27 = icmp slt i32 %23, %24
%28 = select i1 %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.15, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0)
%29 = select i1 %26, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @str.16, i64 0, i64 0), i8* %28
%30 = tail call i32 @puts(i8* dereferenceable(1) %29)
%31 = tail call i32 @putchar(i32 10)
ret void
}