#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int user, comp;
  time_t t;
  printf(
      "Choose your weapon.\n1 - Rock\n2 - Paper\n3 - Scissors\nYour choice: ");
  scanf("%i", &user);
  comp = rand() % 3;
  if (user == comp) {
    printf("Tie.\n");
  }
  if (user == 1 && comp == 2) {
    printf("You lose Paper covers Rock.\n");
  }
  if (user == 1 && comp == 3) {
    printf("You win Rock smashed Scissors.\n");
  }
  if (user == 2 && comp == 1) {
    printf("You win Paper covers Rock.\n");
  }
  if (user == 2 && comp == 3) {
    printf("You lose Scissors cuts Paper.\n");
  }
  if (user == 3 && comp == 1) {
    printf("You lose Rock smashes Scissors.\n");
  }
  if (user == 3 && comp == 2) {
    printf("You win Scissors cuts Paper.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    118c <main+0x5c>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    11ac <main+0x7c>
cmpl   $0x2,-0x18(%rbp)
jne    11ac <main+0x7c>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    11cc <main+0x9c>
cmpl   $0x3,-0x18(%rbp)
jne    11cc <main+0x9c>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x14(%rbp)
jne    11ec <main+0xbc>
cmpl   $0x1,-0x18(%rbp)
jne    11ec <main+0xbc>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x14(%rbp)
jne    120c <main+0xdc>
cmpl   $0x3,-0x18(%rbp)
jne    120c <main+0xdc>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x3,-0x14(%rbp)
jne    122c <main+0xfc>
cmpl   $0x1,-0x18(%rbp)
jne    122c <main+0xfc>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x3,-0x14(%rbp)
jne    124c <main+0x11c>
cmpl   $0x2,-0x18(%rbp)
jne    124c <main+0x11c>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
lea    0xeea(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rbx
imul   $0x55555556,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
jne    119d <main+0x5d>
lea    0xf25(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
jne    11b0 <main+0x70>
cmp    $0x2,%ebx
jne    11b0 <main+0x70>
lea    0xeef(%rip),%rdi
jmp    11e2 <main+0xa2>
cmp    $0x1,%ebx
sete   %cl
cmp    $0x2,%eax
jne    11ce <main+0x8e>
cmp    $0x1,%ebx
jne    11ce <main+0x8e>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%cl
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
jne    11eb <main+0xab>
test   %cl,%cl
je     11eb <main+0xab>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
jne    1201 <main+0xc1>
cmp    $0x2,%ebx
jne    1201 <main+0xc1>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [66 x i8] c"Choose your weapon.\0A1 - Rock\0A2 - Paper\0A3 - Scissors\0AYour choice: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [6 x i8] c"Tie.\0A\00"
@.str.3 = [29 x i8] c"You lose Paper covers Rock.\0A\00"
@.str.4 = [32 x i8] c"You win Rock smashed Scissors.\0A\00"
@.str.5 = [28 x i8] c"You win Paper covers Rock.\0A\00"
@.str.6 = [31 x i8] c"You lose Scissors cuts Paper.\0A\00"
@.str.7 = [33 x i8] c"You lose Rock smashes Scissors.\0A\00"
@.str.8 = [30 x i8] c"You win Scissors cuts Paper.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 3
store i32 %12, i32* %7
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %21, %18
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %29, %26
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 2
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %40, %37, %34
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 2
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i32, i32* %7
%47 = icmp eq i32 %46, 3
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
br label %50
50: ; preds = %48, %45, %42
%51 = load i32, i32* %6
%52 = icmp eq i32 %51, 3
br i1 %52, label %53, label %58
53: ; preds = %50
%54 = load i32, i32* %7
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
br label %58
58: ; preds = %56, %53, %50
%59 = load i32, i32* %6
%60 = icmp eq i32 %59, 3
br i1 %60, label %61, label %66
61: ; preds = %58
%62 = load i32, i32* %7
%63 = icmp eq i32 %62, 2
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %66
66: ; preds = %64, %61, %58
ret i32 0
}

LLVM IR (-O2):
@.str = [66 x i8] c"Choose your weapon.\0A1 - Rock\0A2 - Paper\0A3 - Scissors\0AYour choice: \00"
@.str.1 = [3 x i8] c"%i\00"
@str = [29 x i8] c"You win Scissors cuts Paper.\00"
@str.9 = [32 x i8] c"You lose Rock smashes Scissors.\00"
@str.10 = [27 x i8] c"You win Paper covers Rock.\00"
@str.11 = [28 x i8] c"You lose Paper covers Rock.\00"
@str.12 = [5 x i8] c"Tie.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, %8
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
%13 = load i32, i32* %3
br label %14
14: ; preds = %11, %2
%15 = phi i32 [ %13, %11 ], [ %9, %2 ]
%16 = icmp eq i32 %15, 1
%17 = icmp eq i32 %8, 2
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.11, i64 0, i64 0))
%21 = load i32, i32* %3
br label %36
22: ; preds = %14
%23 = icmp eq i32 %15, 2
%24 = icmp eq i32 %8, 1
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
br label %28
28: ; preds = %22, %26
%29 = phi i1 [ %24, %22 ], [ true, %26 ]
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 3
%32 = select i1 %31, i1 %29, i1 false
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%35 = load i32, i32* %3
br label %36
36: ; preds = %19, %33, %28
%37 = phi i32 [ %35, %33 ], [ %30, %28 ], [ %21, %19 ]
%38 = icmp eq i32 %37, 3
%39 = select i1 %38, i1 %17, i1 false
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
ret i32 0
}