#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 *, int *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int p1, p2, p3;
  int cmp_guess;
  srand(time(NULL));
  printf("Players Enter your Guess [1-10] : \n");
  scanf(" %d %d %d", &p1, &p2, &p3);
  if (p1 > 10 || p2 > 10 || p3 > 10) {
    printf("Wrong input resetting .. \n");
    return 1;
  }
  printf("Checking your Guess.... \n");
  cmp_guess = (rand() % 10) + 1;
  printf("Computer's Guess is : %d \n", cmp_guess);
  if (cmp_guess == p1) {
    printf("Player 1 won! \n");
  } else if (cmp_guess == p2) {
    printf("Player 2 won! \n");
  } else if (cmp_guess == p3) {
    printf("Player 3 won! \n");
  } else {
    printf("Oh.. Y'all Lost.. \n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <scanf@plt>
cmpl   $0xa,-0x8(%rbp)
jg     11b3 <main+0x63>
cmpl   $0xa,-0xc(%rbp)
jg     11b3 <main+0x63>
cmpl   $0xa,-0x10(%rbp)
jle    11cd <main+0x7d>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    127d <main+0x12d>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1220 <main+0xd0>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1276 <main+0x126>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    123f <main+0xef>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1271 <main+0x121>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    125e <main+0x10e>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126c <main+0x11c>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1271 <main+0x121>
jmp    1276 <main+0x126>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xe79(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1070 <scanf@plt>
cmpl   $0xa,0x14(%rsp)
mov    $0x1,%ebx
lea    0xef5(%rip),%rdi
jg     1240 <main+0xe0>
cmpl   $0xa,0x10(%rsp)
jg     1240 <main+0xe0>
cmpl   $0xa,0xc(%rsp)
jg     1240 <main+0xe0>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
lea    0xe07(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0x14(%rsp),%ebp
jne    121b <main+0xbb>
lea    0xe79(%rip),%rdi
jmp    1240 <main+0xe0>
cmp    0x10(%rsp),%ebp
jne    122a <main+0xca>
lea    0xe5b(%rip),%rdi
jmp    1240 <main+0xe0>
cmp    0xc(%rsp),%ebp
lea    0xe3f(%rip),%rax
lea    0xe25(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Players Enter your Guess [1-10] : \0A\00"
@.str.1 = [10 x i8] c" %d %d %d\00"
@.str.2 = [27 x i8] c"Wrong input resetting .. \0A\00"
@.str.3 = [26 x i8] c"Checking your Guess.... \0A\00"
@.str.4 = [27 x i8] c"Computer's Guess is : %d \0A\00"
@.str.5 = [16 x i8] c"Player 1 won! \0A\00"
@.str.6 = [16 x i8] c"Player 2 won! \0A\00"
@.str.7 = [16 x i8] c"Player 3 won! \0A\00"
@.str.8 = [20 x i8] c"Oh.. Y'all Lost.. \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 10
br i1 %11, label %18, label %12
12: ; preds = %0
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 10
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 10
br i1 %17, label %18, label %20
18: ; preds = %15, %12, %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %49
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 10
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %5
%28 = load i32, i32* %2
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %20
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %48
32: ; preds = %20
%33 = load i32, i32* %5
%34 = load i32, i32* %3
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %47
38: ; preds = %32
%39 = load i32, i32* %5
%40 = load i32, i32* %4
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %46
44: ; preds = %38
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %47
47: ; preds = %46, %36
br label %48
48: ; preds = %47, %30
store i32 0, i32* %1
br label %49
49: ; preds = %48, %18
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c" %d %d %d\00"
@.str.4 = [27 x i8] c"Computer's Guess is : %d \0A\00"
@str = [35 x i8] c"Players Enter your Guess [1-10] : \00"
@str.9 = [25 x i8] c"Checking your Guess.... \00"
@str.10 = [19 x i8] c"Oh.. Y'all Lost.. \00"
@str.11 = [15 x i8] c"Player 3 won! \00"
@str.12 = [15 x i8] c"Player 2 won! \00"
@str.13 = [15 x i8] c"Player 1 won! \00"
@str.14 = [26 x i8] c"Wrong input resetting .. \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 10
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 10
%15 = select i1 %12, i1 true, i1 %14
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 10
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %34, label %19
19: ; preds = %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 10
%23 = add nsw i32 %22, 1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
%26 = icmp eq i32 %23, %25
br i1 %26, label %34, label %27
27: ; preds = %19
%28 = load i32, i32* %2
%29 = icmp eq i32 %23, %28
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = load i32, i32* %3
%32 = icmp eq i32 %23, %31
%33 = select i1 %32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0)
br label %34
34: ; preds = %30, %27, %19, %0
%35 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.14, i64 0, i64 0), %0 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0), %19 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0), %27 ], [ %33, %30 ]
%36 = phi i32 [ 1, %0 ], [ 0, %19 ], [ 0, %27 ], [ 0, %30 ]
%37 = call i32 @puts(i8* dereferenceable(1) %35)
ret i32 %36
}