#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 */
char _getch();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  int ux = 0, uy = 0;
  int dx = 0, dy = 0;
  char c;
  char ans;
  time_t t;
  srand((unsigned)time(&t));
  ux = rand() % 641;
  uy = rand() % 481;
  dx = rand() % 641;
  dy = rand() % 481;
  printf("your starting location (%d,%d)\n", ux, uy);
  printf("Please user UP DOWN LEFT and RIGHT arrow keys to move around \n");
  do {
    c = _getch();
    if (c = -32) {
      if (c == 72) {
        uy--;
        if (uy < 0) {
          uy = 480;
        }
      }
      if (c == 80) {
        uy++;
        if (uy > 480) {
          uy = 0;
        }
      }
      if (c == 75) {
        ux--;
        if (ux < 0) {
          ux = 640;
        }
      }
      if (c == 77) {
        ux++;
        if (ux > 640) {
          ux = 0;
        }
      }
      if (c == 27) {
        printf("are you sure you want to exit ? (Y/N) ");
        scanf(" %c", &ans);
        if (ans == 'y' || ans == 'Y') {
          exit(0);
        }
      }
    }
    printf("your new location is (%d,%d) \n", ux, uy);
    if (ux == dx && uy == dy) {
      printf("your level is up ! \n");
      return 0;
    }
  } while (c != 27);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x1c(%rbp),%rdi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x281,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x1e1,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x281,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x1e1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <_getch@plt>
mov    %al,-0x15(%rbp)
movb   $0xe0,-0x15(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1232 <main+0xc2>
jmp    133e <main+0x1ce>
movsbl -0x15(%rbp),%eax
cmp    $0x48,%eax
jne    125e <main+0xee>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1259 <main+0xe9>
movl   $0x1e0,-0xc(%rbp)
jmp    125e <main+0xee>
movsbl -0x15(%rbp),%eax
cmp    $0x50,%eax
jne    128d <main+0x11d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1e0,-0xc(%rbp)
jle    1288 <main+0x118>
movl   $0x0,-0xc(%rbp)
jmp    128d <main+0x11d>
movsbl -0x15(%rbp),%eax
cmp    $0x4b,%eax
jne    12b9 <main+0x149>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    12b4 <main+0x144>
movl   $0x280,-0x8(%rbp)
jmp    12b9 <main+0x149>
movsbl -0x15(%rbp),%eax
cmp    $0x4d,%eax
jne    12e8 <main+0x178>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x280,-0x8(%rbp)
jle    12e3 <main+0x173>
movl   $0x0,-0x8(%rbp)
jmp    12e8 <main+0x178>
movsbl -0x15(%rbp),%eax
cmp    $0x1b,%eax
jne    1339 <main+0x1c9>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd7c(%rip),%rdi
lea    -0x16(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x16(%rbp),%eax
cmp    $0x79,%eax
je     132d <main+0x1bd>
movsbl -0x16(%rbp),%eax
cmp    $0x59,%eax
jne    1334 <main+0x1c4>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    1339 <main+0x1c9>
jmp    133e <main+0x1ce>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1384 <main+0x214>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1384 <main+0x214>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    139d <main+0x22d>
jmp    1389 <main+0x219>
movsbl -0x15(%rbp),%eax
cmp    $0x1b,%eax
jne    1215 <main+0xa5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0x4(%rsp),%rdi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%r14
imul   $0x663d81,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
imul   $0x281,%eax,%eax
sub    %eax,%r14d
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%r15
imul   $0xffffffff883fddf1,%r15,%rax
shr    $0x20,%rax
add    %r15d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x8,%eax
add    %ecx,%eax
imul   $0x1e1,%eax,%eax
sub    %eax,%r15d
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%r12
imul   $0x663d81,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
imul   $0x281,%eax,%eax
sub    %eax,%r12d
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rbx
imul   $0xffffffff883fddf1,%rbx,%rax
shr    $0x20,%rax
add    %ebx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x8,%eax
add    %ecx,%eax
imul   $0x1e1,%eax,%eax
sub    %eax,%ebx
lea    0xdde(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r12d
xor    %r15d,%ebx
or     %r12d,%ebx
sete   %bl
lea    0xdd2(%rip),%r12
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <_getch@plt>
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   %bl,%bl
je     1250 <main+0xf0>
lea    0xe0b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"your starting location (%d,%d)\0A\00"
@.str.1 = [63 x i8] c"Please user UP DOWN LEFT and RIGHT arrow keys to move around \0A\00"
@.str.2 = [39 x i8] c"are you sure you want to exit ? (Y/N) \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [31 x i8] c"your new location is (%d,%d) \0A\00"
@.str.5 = [21 x i8] c"your level is up ! \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%9 = call i64 @time(i32* %8)
%10 = trunc i64 %9 to i32
%11 = call i32 @srand(i32 %10)
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 641
store i32 %13, i32* %2
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 481
store i32 %15, i32* %3
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 641
store i32 %17, i32* %4
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 481
store i32 %19, i32* %5
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %102, %0
%25 = call signext i8 (...) @_getch()
store i8 %25, i8* %6
store i8 -32, i8* %6
br i1 true, label %26, label %88
26: ; preds = %24
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 72
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i32, i32* %3
%32 = add nsw i32 %31, -1
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 480, i32* %3
br label %36
36: ; preds = %35, %30
br label %37
37: ; preds = %36, %26
%38 = load i8, i8* %6
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 80
br i1 %40, label %41, label %48
41: ; preds = %37
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = icmp sgt i32 %44, 480
br i1 %45, label %46, label %47
46: ; preds = %41
store i32 0, i32* %3
br label %47
47: ; preds = %46, %41
br label %48
48: ; preds = %47, %37
%49 = load i8, i8* %6
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 75
br i1 %51, label %52, label %59
52: ; preds = %48
%53 = load i32, i32* %2
%54 = add nsw i32 %53, -1
store i32 %54, i32* %2
%55 = load i32, i32* %2
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %52
store i32 640, i32* %2
br label %58
58: ; preds = %57, %52
br label %59
59: ; preds = %58, %48
%60 = load i8, i8* %6
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 77
br i1 %62, label %63, label %70
63: ; preds = %59
%64 = load i32, i32* %2
%65 = add nsw i32 %64, 1
store i32 %65, i32* %2
%66 = load i32, i32* %2
%67 = icmp sgt i32 %66, 640
br i1 %67, label %68, label %69
68: ; preds = %63
store i32 0, i32* %2
br label %69
69: ; preds = %68, %63
br label %70
70: ; preds = %69, %59
%71 = load i8, i8* %6
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 27
br i1 %73, label %74, label %87
74: ; preds = %70
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%76 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%77 = load i8, i8* %7
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 121
br i1 %79, label %84, label %80
80: ; preds = %74
%81 = load i8, i8* %7
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 89
br i1 %83, label %84, label %86
84: ; preds = %80, %74
%85 = call i32 @exit(i32 0)
unreachable
86: ; preds = %80
br label %87
87: ; preds = %86, %70
br label %88
88: ; preds = %87, %24
%89 = load i32, i32* %2
%90 = load i32, i32* %3
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %89, i32 %90)
%92 = load i32, i32* %2
%93 = load i32, i32* %4
%94 = icmp eq i32 %92, %93
br i1 %94, label %95, label %101
95: ; preds = %88
%96 = load i32, i32* %3
%97 = load i32, i32* %5
%98 = icmp eq i32 %96, %97
br i1 %98, label %99, label %101
99: ; preds = %95
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %107
101: ; preds = %95, %88
br label %102
102: ; preds = %101
%103 = load i8, i8* %6
%104 = sext i8 %103 to i32
%105 = icmp ne i32 %104, 27
br i1 %105, label %24, label %106
106: ; preds = %102
store i32 0, i32* %1
br label %107
107: ; preds = %106, %99
%108 = load i32, i32* %1
ret i32 %108
}

LLVM IR (-O2):
@.str = [32 x i8] c"your starting location (%d,%d)\0A\00"
@.str.4 = [31 x i8] c"your new location is (%d,%d) \0A\00"
@str = [62 x i8] c"Please user UP DOWN LEFT and RIGHT arrow keys to move around \00"
@str.6 = [20 x i8] c"your level is up ! \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @time(i32* %1)
%4 = trunc i64 %3 to i32
%5 = call i32 @srand(i32 %4)
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 641
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 481
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 641
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 481
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
%16 = icmp eq i32 %7, %11
%17 = icmp eq i32 %9, %13
%18 = select i1 %16, i1 %17, i1 false
br label %19
19: ; preds = %19, %0
%20 = call signext i8 (...) @_getch()
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %7, i32 %9)
br i1 %18, label %22, label %19
22: ; preds = %19
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}