#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 *, ...);
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/);
int main(void) {
  srand((int)time(0));
  char charAnswer = 'x';
  char rollAnswer = 'x';
  int gameTotal = 0;
  int playerOneTotal = 0;
  int playerTwoTotal = 0;
  int randomNumber = 0;
  printf("\nwelcome to a game  of pigthrones\n");
  printf("---------------------------\n");
  printf("  made by dominick hera   \n");
  printf("\ndo you and your friend want to play a game? (y/n) :");
  scanf("%c", &charAnswer);
  if (charAnswer == 'y') {
    printf("please set the game total: \n");
    scanf("%d", &gameTotal);
    printf("do you want to (r)oll or (h)old? : \n");
    scanf("\n%c", &rollAnswer);
    if (rollAnswer == 'r') {
      randomNumber = ((rand() % 6) + 1);
      printf("%d\n", randomNumber);
      if (randomNumber == 1) {
        if (playerOneTotal >= gameTotal) {
          printf("Player one wins! weo weo weo");
          return 0;
        } else if (playerTwoTotal >= gameTotal) {
          printf("Player two wins! weo weo weo");
        }
      } else if (rollAnswer == 'h') {
        if (playerOneTotal >= gameTotal) {
          printf("Player one wins! weo weo weo \n");
          return 0;
        } else if (playerTwoTotal >= gameTotal) {
          printf("Player two wins! weo weo weo \n");
          return 0;
        } else {
          printf("it's now the next players turn");
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movb   $0x78,-0x5(%rbp)
movb   $0x78,-0x6(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
jne    132f <main+0x1df>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x6(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x72,%eax
jne    132a <main+0x1da>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    12af <main+0x15f>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     128b <main+0x13b>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1336 <main+0x1e6>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     12a5 <main+0x155>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12aa <main+0x15a>
jmp    1325 <main+0x1d5>
movsbl -0x6(%rbp),%eax
cmp    $0x68,%eax
jne    1320 <main+0x1d0>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     12e2 <main+0x192>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1336 <main+0x1e6>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1308 <main+0x1b8>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1336 <main+0x1e6>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    131b <main+0x1cb>
jmp    1320 <main+0x1d0>
jmp    1325 <main+0x1d5>
jmp    132a <main+0x1da>
jmp    132f <main+0x1df>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movb   $0x78,0xb(%rsp)
movb   $0x78,0xa(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpb   $0x79,0xb(%rsp)
jne    1294 <main+0x134>
lea    0xef9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4d(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe31(%rip),%rdi
lea    0xa(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpb   $0x72,0xa(%rsp)
jne    1294 <main+0x134>
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
mov    %eax,%ebx
sub    %ecx,%ebx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0x1,%esi
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
je     1271 <main+0x111>
cmpb   $0x68,0xa(%rsp)
jne    1294 <main+0x134>
cmpl   $0x0,0xc(%rsp)
jle    1288 <main+0x128>
lea    0xdee(%rip),%rdi
jmp    127f <main+0x11f>
cmpl   $0x0,0xc(%rsp)
jg     1294 <main+0x134>
lea    0xdc1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1294 <main+0x134>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0Awelcome to a game of pigthrones\0A\00"
@.str.1 = [29 x i8] c"---------------------------\0A\00"
@.str.2 = [28 x i8] c" made by dominick hera \0A\00"
@.str.3 = [53 x i8] c"\0Ado you and your friend want to play a game? (y/n) :\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [29 x i8] c"please set the game total: \0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [37 x i8] c"do you want to (r)oll or (h)old? : \0A\00"
@.str.8 = [4 x i8] c"\0A%c\00"
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [29 x i8] c"Player one wins! weo weo weo\00"
@.str.11 = [29 x i8] c"Player two wins! weo weo weo\00"
@.str.12 = [31 x i8] c"Player one wins! weo weo weo \0A\00"
@.str.13 = [31 x i8] c"Player two wins! weo weo weo \0A\00"
@.str.14 = [31 x i8] c"it's now the next players turn\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i64 @time(i32 0)
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
store i8 120, i8* %2
store i8 120, i8* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 121
br i1 %18, label %19, label %72
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %3)
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 114
br i1 %26, label %27, label %71
27: ; preds = %19
%28 = call i32 (...) @rand()
%29 = srem i32 %28, 6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %7
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %49
35: ; preds = %27
%36 = load i32, i32* %5
%37 = load i32, i32* %4
%38 = icmp sge i32 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %1
br label %73
41: ; preds = %35
%42 = load i32, i32* %6
%43 = load i32, i32* %4
%44 = icmp sge i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
br label %48
48: ; preds = %47
br label %70
49: ; preds = %27
%50 = load i8, i8* %3
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 104
br i1 %52, label %53, label %69
53: ; preds = %49
%54 = load i32, i32* %5
%55 = load i32, i32* %4
%56 = icmp sge i32 %54, %55
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %1
br label %73
59: ; preds = %53
%60 = load i32, i32* %6
%61 = load i32, i32* %4
%62 = icmp sge i32 %60, %61
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %1
br label %73
65: ; preds = %59
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
br label %67
67: ; preds = %65
br label %68
68: ; preds = %67
br label %69
69: ; preds = %68, %49
br label %70
70: ; preds = %69, %48
br label %71
71: ; preds = %70, %19
br label %72
72: ; preds = %71, %0
store i32 0, i32* %1
br label %73
73: ; preds = %72, %63, %57, %39
%74 = load i32, i32* %1
ret i32 %74
}

LLVM IR (-O2):
@.str.3 = [53 x i8] c"\0Ado you and your friend want to play a game? (y/n) :\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.8 = [4 x i8] c"\0A%c\00"
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [29 x i8] c"Player one wins! weo weo weo\00"
@.str.14 = [31 x i8] c"it's now the next players turn\00"
@str = [34 x i8] c"\0Awelcome to a game of pigthrones\00"
@str.15 = [28 x i8] c"---------------------------\00"
@str.16 = [27 x i8] c" made by dominick hera \00"
@str.17 = [28 x i8] c"please set the game total: \00"
@str.18 = [36 x i8] c"do you want to (r)oll or (h)old? : \00"
@str.19 = [30 x i8] c"Player one wins! weo weo weo \00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i32
%4 = tail call i64 @time(i32 0)
%5 = trunc i64 %4 to i32
%6 = tail call i32 @srand(i32 %5)
store i8 120, i8* %1
store i8 120, i8* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.15, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.16, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%13 = load i8, i8* %1
%14 = icmp eq i8 %13, 121
br i1 %14, label %15, label %43
15: ; preds = %0
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.18, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%20 = load i8, i8* %2
%21 = icmp eq i8 %20, 114
br i1 %21, label %22, label %43
22: ; preds = %15
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 6
%25 = add nsw i32 %24, 1
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %25)
%27 = icmp eq i32 %24, 0
br i1 %27, label %28, label %33
28: ; preds = %22
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, 1
br i1 %30, label %31, label %43
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
br label %43
33: ; preds = %22
%34 = load i8, i8* %2
%35 = icmp eq i8 %34, 104
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 1
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.19, i64 0, i64 0))
br label %43
41: ; preds = %36
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
br label %43
43: ; preds = %0, %41, %33, %15, %28, %39, %31
ret i32 0
}