#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(". \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    -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,-0x1c(%rbp)
test   %eax,%eax
je     12ab <main+0x14b>
jmp    1289 <main+0x129>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     12bc <main+0x15c>
jmp    129a <main+0x13a>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     12cd <main+0x16d>
jmp    12d9 <main+0x179>
lea    0xda1(%rip),%rdi
call   1030 <puts@plt>
jmp    12d9 <main+0x179>
lea    0xd96(%rip),%rdi
call   1030 <puts@plt>
jmp    12d9 <main+0x179>
lea    0xd8f(%rip),%rdi
call   1030 <puts@plt>
lea    0xd8c(%rip),%rdi
call   1040 <printf@plt>
lea    0xd44(%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    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe96(%rip),%rbx
lea    0xeee(%rip),%r13
lea    0xef6(%rip),%r15
lea    0xeb9(%rip),%rbp
mov    %rsp,%r14
jmp    11cd <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
cmpl   $0x1,(%rsp)
jne    127b <main+0x11b>
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%r12
imul   $0x55555556,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%r12d
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xe14(%rip),%rdi
call   1040 <printf@plt>
cmp    $0x2,%r12d
ja     1232 <main+0xd2>
movslq %r12d,%rax
lea    0xe5e(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1040 <printf@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
sub    %r12d,%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
movslq (%r15,%rax,4),%rdi
add    %r15,%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 = [4 x i8] c". \0A\00"
@.str.8 = [6 x i8] c"Same.\00"
@.str.9 = [10 x i8] c"You lose.\00"
@.str.10 = [9 x i8] c"You win.\00"
@.str.11 = [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 = %39, %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 ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = sub nsw i32 %24, %25
%27 = add nsw i32 %26, 3
%28 = srem i32 %27, 3
store i32 %28, i32* %4
%29 = load i32, i32* %4
switch i32 %29, label %36 [
i32 0, label %30
i32 1, label %32
i32 2, label %34
]
30: ; preds = %22
%31 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %36
32: ; preds = %22
%33 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
br label %36
34: ; preds = %22
%35 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
br label %36
36: ; preds = %22, %34, %32, %30
%37 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
br label %39
39: ; preds = %36
%40 = load i32, i32* %5
%41 = icmp eq i32 %40, 1
br i1 %41, label %9, label %42
42: ; preds = %39
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.8 = [6 x i8] c"Same.\00"
@.str.9 = [10 x i8] c"You lose.\00"
@.str.10 = [9 x i8] c"You win.\00"
@.str.11 = [26 x i8] c"Again......(0)No (1)Yes: \00"
@str = [13 x i8] c"Game start!!\00"
@str.12 = [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.14 = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.8 to i64), i64 ptrtoint ([3 x i32]* @reltable.main.14 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.9 to i64), i64 ptrtoint ([3 x i32]* @reltable.main.14 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.10 to i64), i64 ptrtoint ([3 x i32]* @reltable.main.14 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 = %32, %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 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.12, i64 0, i64 0))
%22 = load i32, i32* %1
%23 = sub nsw i32 3, %10
%24 = add i32 %23, %22
%25 = srem i32 %24, 3
%26 = icmp ult i32 %25, 3
br i1 %26, label %27, label %32
27: ; preds = %20
%28 = sext i32 %25 to i64
%29 = shl i64 %28, 2
%30 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main.14 to i8*), i64 %29)
%31 = call i32 @puts(i8* dereferenceable(1) %30)
br label %32
32: ; preds = %20, %27
%33 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 1
br i1 %36, label %8, label %37
37: ; preds = %32
ret i32 0
}