#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 /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int human;
  int comp;
  int judge;
  int retry;
  srand(time(NULL));
  printf("Game start!!\n");
  do {
    comp = rand() % 3;
    printf("\n\a (0)Stone (1)Scissor (2)Cloth: ");
    scanf("%d", &human);
    printf("Choose ");
    switch (comp) {
    case 0:
      printf("Stone");
      break;
    case 1:
      printf("Scissor");
      break;
    case 2:
      printf("Cloth");
      break;
    }
    printf(", you choose ");
    switch (human) {
    case 0:
      printf("Stone");
      break;
    case 1:
      printf("Scissor");
      break;
    case 2:
      printf("Cloth");
      break;
    default:
      printf("\n\a (0)Stone (1)Scissor (2)Cloth: ");
      scanf("%d", &human);
      break;
    }
    printf(". \n");
    judge = (human - comp + 3) % 3;
    switch (judge) {
    case 0:
      puts("Same.");
      break;
    case 1:
      puts("You lose.");
      break;
    case 2:
      puts("You win.");
      break;
    }
    printf("Again......(0)No (1)Yes: ");
    scanf("%d", &retry);
  } while (retry == 1);
  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   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rcx
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     1210 <main+0xb0>
jmp    11ee <main+0x8e>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     1221 <main+0xc1>
jmp    11ff <main+0x9f>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1232 <main+0xd2>
jmp    123e <main+0xde>
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
jmp    123e <main+0xde>
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
jmp    123e <main+0xde>
lea    0xe10(%rip),%rdi
call   1040 <printf@plt>
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     127f <main+0x11f>
jmp    125d <main+0xfd>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     1290 <main+0x130>
jmp    126e <main+0x10e>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     12a1 <main+0x141>
jmp    12b2 <main+0x152>
lea    0xdb5(%rip),%rdi
call   1040 <printf@plt>
jmp    12ce <main+0x16e>
lea    0xdaa(%rip),%rdi
call   1040 <printf@plt>
jmp    12ce <main+0x16e>
lea    0xda1(%rip),%rdi
call   1040 <printf@plt>
jmp    12ce <main+0x16e>
lea    0xd55(%rip),%rdi
call   1040 <printf@plt>
lea    0xd6b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xd88(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    %ecx,%eax
add    $0x3,%eax
movslq %eax,%rcx
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     133b <main+0x1db>
jmp    1319 <main+0x1b9>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
je     134c <main+0x1ec>
jmp    132a <main+0x1ca>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     135d <main+0x1fd>
jmp    1369 <main+0x209>
lea    0xd1f(%rip),%rdi
call   1030 <puts@plt>
jmp    1369 <main+0x209>
lea    0xd14(%rip),%rdi
call   1030 <puts@plt>
jmp    1369 <main+0x209>
lea    0xd0d(%rip),%rdi
call   1030 <puts@plt>
lea    0xd0a(%rip),%rdi
call   1040 <printf@plt>
lea    0xcb4(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
je     118b <main+0x2b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xe74(%rip),%r14
lea    0xe8f(%rip),%rbx
mov    %rsp,%r15
lea    0xecb(%rip),%r12
lea    0x4(%rsp),%r13
jmp    11ce <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
jne    12e5 <main+0x185>
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rbp
imul   $0x55555556,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebp
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
cmp    $0x2,%ebp
ja     122b <main+0xcb>
movslq %ebp,%rax
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1040 <printf@plt>
lea    0xe0f(%rip),%rdi
call   1040 <printf@plt>
mov    (%rsp),%eax
cmp    $0x2,%eax
je     1270 <main+0x110>
cmp    $0x1,%eax
je     1260 <main+0x100>
test   %eax,%eax
jne    1280 <main+0x120>
lea    0xdde(%rip),%rdi
call   1040 <printf@plt>
jmp    1293 <main+0x133>
cs nopw 0x0(%rax,%rax,1)
lea    0xdcc(%rip),%rdi
call   1040 <printf@plt>
jmp    1293 <main+0x133>
xchg   %ax,%ax
lea    0xdc4(%rip),%rdi
call   1040 <printf@plt>
jmp    1293 <main+0x133>
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
lea    0xdf5(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%eax
sub    %ebp,%eax
add    $0x3,%eax
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x2,%eax
ja     11b0 <main+0x50>
cltq
lea    0xdcc(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
jmp    11b0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Game start!!\0A\00"
@.str.1 = [34 x i8] c"\0A\07 (0)Stone (1)Scissor (2)Cloth: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"Choose \00"
@.str.4 = [6 x i8] c"Stone\00"
@.str.5 = [8 x i8] c"Scissor\00"
@.str.6 = [6 x i8] c"Cloth\00"
@.str.7 = [14 x i8] c", you choose \00"
@.str.8 = [4 x i8] c". \0A\00"
@.str.9 = [6 x i8] c"Same.\00"
@.str.10 = [10 x i8] c"You lose.\00"
@.str.11 = [9 x i8] c"You win.\00"
@.str.12 = [26 x i8] c"Again......(0)No (1)Yes: \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 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %51, %0
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 3
store i32 %11, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%14 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32, i32* %3
switch i32 %15, label %22 [
i32 0, label %16
i32 1, label %18
i32 2, label %20
]
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %22
18: ; preds = %9
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %22
20: ; preds = %9
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %22
22: ; preds = %9, %20, %18, %16
%23 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%24 = load i32, i32* %2
switch i32 %24, label %31 [
i32 0, label %25
i32 1, label %27
i32 2, label %29
]
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %34
27: ; preds = %22
%28 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %34
29: ; preds = %22
%30 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %34
31: ; preds = %22
%32 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %34
34: ; preds = %31, %29, %27, %25
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = sub nsw i32 %36, %37
%39 = add nsw i32 %38, 3
%40 = srem i32 %39, 3
store i32 %40, i32* %4
%41 = load i32, i32* %4
switch i32 %41, label %48 [
i32 0, label %42
i32 1, label %44
i32 2, label %46
]
42: ; preds = %34
%43 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %48
44: ; preds = %34
%45 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
br label %48
46: ; preds = %34
%47 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
br label %48
48: ; preds = %34, %46, %44, %42
%49 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
br label %51
51: ; preds = %48
%52 = load i32, i32* %5
%53 = icmp eq i32 %52, 1
br i1 %53, label %9, label %54
54: ; preds = %51
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c"\0A\07 (0)Stone (1)Scissor (2)Cloth: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"Choose \00"
@.str.4 = [6 x i8] c"Stone\00"
@.str.5 = [8 x i8] c"Scissor\00"
@.str.6 = [6 x i8] c"Cloth\00"
@.str.7 = [14 x i8] c", you choose \00"
@.str.9 = [6 x i8] c"Same.\00"
@.str.10 = [10 x i8] c"You lose.\00"
@.str.11 = [9 x i8] c"You win.\00"
@.str.12 = [26 x i8] c"Again......(0)No (1)Yes: \00"
@str = [13 x i8] c"Game start!!\00"
@str.13 = [3 x i8] c". \00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32)]
@reltable.main.15 = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.9 to i64), i64 ptrtoint ([3 x i32]* @reltable.main.15 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.10 to i64), i64 ptrtoint ([3 x i32]* @reltable.main.15 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.11 to i64), i64 ptrtoint ([3 x i32]* @reltable.main.15 to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %44, %0
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 3
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp ult i32 %10, 3
br i1 %14, label %15, label %20
15: ; preds = %8
%16 = sext i32 %10 to i64
%17 = shl i64 %16, 2
%18 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %17)
%19 = call i32 @printf(i8* dereferenceable(1) %18)
br label %20
20: ; preds = %8, %15
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%22 = load i32, i32* %1
switch i32 %22, label %29 [
i32 0, label %23
i32 1, label %25
i32 2, label %27
]
23: ; preds = %20
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %32
25: ; preds = %20
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %32
27: ; preds = %20
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %32
29: ; preds = %20
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
br label %32
32: ; preds = %29, %27, %25, %23
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.13, i64 0, i64 0))
%34 = load i32, i32* %1
%35 = sub nsw i32 3, %10
%36 = add i32 %35, %34
%37 = srem i32 %36, 3
%38 = icmp ult i32 %37, 3
br i1 %38, label %39, label %44
39: ; preds = %32
%40 = sext i32 %37 to i64
%41 = shl i64 %40, 2
%42 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main.15 to i8*), i64 %41)
%43 = call i32 @puts(i8* dereferenceable(1) %42)
br label %44
44: ; preds = %32, %39
%45 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%47 = load i32, i32* %2
%48 = icmp eq i32 %47, 1
br i1 %48, label %8, label %49
49: ; preds = %44
ret i32 0
}