#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ DEBUG_PrintScreen(char **, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char *argv[]) {
  char Screen[20][20 + 1] = {0};
  int Curr_Score = 0;
  int Curr_X = 0;
  int Curr_Y = 0;
  int Move_X = 0;
  int Move_Y = 0;
  char Curr_Move = 0;
  char GameOver = (1 == 0);
  FILE *fp;
  int X, Y;
  fp = fopen("grid.in", "r");
  if (!fp)
    exit(1);
  for (Y = 0; Y < 20; Y++) {
    for (X = 0; X < 20; X++) {
      Screen[Y][X] = fgetc(fp);
      if (Screen[Y][X] == 'P') {
        Curr_X = X;
        Curr_Y = Y;
      }
    }
    if (fgetc(fp) != 0xD)
      printf("Error Reading Grid File, (%d,%d)", X, Y);
    if (fgetc(fp) != 0xA)
      printf("Error Reading Grid File, (%d,%d)", X, Y);
  }
  fclose(fp);
  fp = NULL;
  DEBUG_PrintScreen(Screen, Curr_Score);
  fp = fopen("prob10.in", "r");
  if (!fp)
    exit(1);
  while (!feof(fp) && !GameOver) {
    Curr_Move = ' ';
    Curr_Move = fgetc(fp);
    if (Curr_Move == ' ')
      continue;
    printf("*** Move-%c ***\n", Curr_Move);
    Screen[Curr_Y][Curr_X] = ' ';
    switch (Curr_Move) {
    case 'L':
      Move_X = Curr_X - 1;
      Move_Y = Curr_Y;
      break;
    case 'R':
      Move_X = Curr_X + 1;
      Move_Y = Curr_Y;
      break;
    case 'U':
      Move_X = Curr_X;
      Move_Y = Curr_Y - 1;
      break;
    case 'D':
      Move_X = Curr_X;
      Move_Y = Curr_Y + 1;
      break;
    }
    if ((Move_X < 0) || (Move_X >= 20) || (Move_Y < 0) || (Move_Y >= 20) ||
        (Screen[Move_Y][Move_X] == '#')) {
      continue;
    }
    if (Screen[Move_Y][Move_X] == '[') {
      Move_X = 20 - 2;
    } else if (Screen[Move_Y][Move_X] == ']') {
      Move_X = 1;
    }
    switch (Screen[Move_Y][Move_X]) {
    case '@':
      printf("Encountered a Ghost at %02d,%02d, GAME OVER\n", Move_X, Move_Y);
      GameOver = (1 == 1);
      continue;
    case 'O':
      Curr_Score += 25;
    case '%':
      Curr_Score += 15;
    case '*':
      Curr_Score += 9;
    case '.':
      Curr_Score += 1;
    case ' ':
      Curr_Score += 0;
      Curr_X = Move_X;
      Curr_Y = Move_Y;
      Screen[Curr_Y][Curr_X] = 'P';
    }
    DEBUG_PrintScreen(Screen, Curr_Score);
  }
  fclose(fp);
  printf("\n\n%d pts.\n", Curr_Score);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x1a4,%edx
call   1050 <memset@plt>
movl   $0x0,-0x1c4(%rbp)
movl   $0x0,-0x1c8(%rbp)
movl   $0x0,-0x1cc(%rbp)
movl   $0x0,-0x1d0(%rbp)
movl   $0x0,-0x1d4(%rbp)
movb   $0x0,-0x1d5(%rbp)
movb   $0x0,-0x1d6(%rbp)
lea    0xf15(%rip),%rdi
lea    0xf16(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x1e0(%rbp)
cmpq   $0x0,-0x1e0(%rbp)
jne    121e <main+0x9e>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x0,-0x1e8(%rbp)
cmpl   $0x14,-0x1e8(%rbp)
jge    134a <main+0x1ca>
movl   $0x0,-0x1e4(%rbp)
cmpl   $0x14,-0x1e4(%rbp)
jge    12d3 <main+0x153>
mov    -0x1e0(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,%dl
movslq -0x1e8(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
imul   $0x15,%rcx,%rcx
add    %rcx,%rax
movslq -0x1e4(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movslq -0x1e8(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
imul   $0x15,%rcx,%rcx
add    %rcx,%rax
movslq -0x1e4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x50,%eax
jne    12ba <main+0x13a>
mov    -0x1e4(%rbp),%eax
mov    %eax,-0x1c8(%rbp)
mov    -0x1e8(%rbp),%eax
mov    %eax,-0x1cc(%rbp)
jmp    12bf <main+0x13f>
mov    -0x1e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1e4(%rbp)
jmp    123f <main+0xbf>
mov    -0x1e0(%rbp),%rdi
call   1060 <fgetc@plt>
cmp    $0xd,%eax
je     1302 <main+0x182>
mov    -0x1e4(%rbp),%esi
mov    -0x1e8(%rbp),%edx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1e0(%rbp),%rdi
call   1060 <fgetc@plt>
cmp    $0xa,%eax
je     1331 <main+0x1b1>
mov    -0x1e4(%rbp),%esi
mov    -0x1e8(%rbp),%edx
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1336 <main+0x1b6>
mov    -0x1e8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1e8(%rbp)
jmp    1228 <main+0xa8>
mov    -0x1e0(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x1e0(%rbp)
lea    -0x1c0(%rbp),%rdi
mov    -0x1c4(%rbp),%esi
call   10a0 <DEBUG_PrintScreen@plt>
lea    0xdb9(%rip),%rdi
lea    0xd8f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x1e0(%rbp)
cmpq   $0x0,-0x1e0(%rbp)
jne    13a5 <main+0x225>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    13aa <main+0x22a>
mov    -0x1e0(%rbp),%rdi
call   1070 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1e9(%rbp)
jne    13db <main+0x25b>
cmpb   $0x0,-0x1d6(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x1e9(%rbp)
mov    -0x1e9(%rbp),%al
test   $0x1,%al
jne    13ee <main+0x26e>
jmp    16e1 <main+0x561>
movb   $0x20,-0x1d5(%rbp)
mov    -0x1e0(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x1d5(%rbp)
movsbl -0x1d5(%rbp),%eax
cmp    $0x20,%eax
jne    141c <main+0x29c>
jmp    13aa <main+0x22a>
movsbl -0x1d5(%rbp),%esi
lea    0xd13(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq -0x1cc(%rbp),%rax
lea    (%rax,%rax,4),%rcx
lea    (%rax,%rcx,4),%rax
lea    -0x1c0(%rbp,%rax,1),%rcx
ff
movslq -0x1c8(%rbp),%rax
movb   $0x20,(%rax,%rcx,1)
movsbl -0x1d5(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x1f8(%rbp)
sub    $0x11,%eax
ja     1501 <main+0x381>
mov    -0x1f8(%rbp),%rax
lea    0xb83(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x1c8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1d0(%rbp)
mov    -0x1cc(%rbp),%eax
mov    %eax,-0x1d4(%rbp)
jmp    1501 <main+0x381>
mov    -0x1c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d0(%rbp)
mov    -0x1cc(%rbp),%eax
mov    %eax,-0x1d4(%rbp)
jmp    1501 <main+0x381>
mov    -0x1c8(%rbp),%eax
mov    %eax,-0x1d0(%rbp)
mov    -0x1cc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1d4(%rbp)
jmp    1501 <main+0x381>
mov    -0x1c8(%rbp),%eax
mov    %eax,-0x1d0(%rbp)
mov    -0x1cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4(%rbp)
cmpl   $0x0,-0x1d0(%rbp)
jl     155e <main+0x3de>
cmpl   $0x14,-0x1d0(%rbp)
jge    155e <main+0x3de>
cmpl   $0x0,-0x1d4(%rbp)
jl     155e <main+0x3de>
cmpl   $0x14,-0x1d4(%rbp)
jge    155e <main+0x3de>
movslq -0x1d4(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
imul   $0x15,%rcx,%rcx
add    %rcx,%rax
movslq -0x1d0(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
jne    1563 <main+0x3e3>
jmp    13aa <main+0x22a>
movslq -0x1d4(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
imul   $0x15,%rcx,%rcx
add    %rcx,%rax
movslq -0x1d0(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
jne    159b <main+0x41b>
movl   $0x12,-0x1d0(%rbp)
jmp    15d3 <main+0x453>
movslq -0x1d4(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
imul   $0x15,%rcx,%rcx
add    %rcx,%rax
movslq -0x1d0(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    15ce <main+0x44e>
movl   $0x1,-0x1d0(%rbp)
jmp    15d3 <main+0x453>
movslq -0x1d4(%rbp),%rax
lea    (%rax,%rax,4),%rcx
lea    (%rax,%rcx,4),%rax
lea    -0x1c0(%rbp,%rax,1),%rcx
ff
movslq -0x1d0(%rbp),%rax
movsbl (%rax,%rcx,1),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x200(%rbp)
sub    $0x2f,%eax
ja     16ca <main+0x54a>
mov    -0x200(%rbp),%rax
lea    0xa30(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x1d0(%rbp),%esi
mov    -0x1d4(%rbp),%edx
lea    0xb1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movb   $0x1,-0x1d6(%rbp)
jmp    13aa <main+0x22a>
mov    -0x1c4(%rbp),%eax
add    $0x19,%eax
mov    %eax,-0x1c4(%rbp)
mov    -0x1c4(%rbp),%eax
add    $0xf,%eax
mov    %eax,-0x1c4(%rbp)
mov    -0x1c4(%rbp),%eax
add    $0x9,%eax
mov    %eax,-0x1c4(%rbp)
mov    -0x1c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c4(%rbp)
mov    -0x1c4(%rbp),%eax
add    $0x0,%eax
mov    %eax,-0x1c4(%rbp)
mov    -0x1d0(%rbp),%eax
mov    %eax,-0x1c8(%rbp)
mov    -0x1d4(%rbp),%eax
mov    %eax,-0x1cc(%rbp)
movslq -0x1cc(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
imul   $0x15,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c8(%rbp),%rcx
movb   $0x50,(%rax,%rcx,1)
lea    -0x1c0(%rbp),%rdi
mov    -0x1c4(%rbp),%esi
call   10a0 <DEBUG_PrintScreen@plt>
jmp    13aa <main+0x22a>
mov    -0x1e0(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c4(%rbp),%esi
lea    0xa81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d8,%rsp
lea    0x30(%rsp),%r13
mov    $0x1a4,%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xf5c(%rip),%rdi
lea    0xf5d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     14b8 <main+0x338>
mov    %rax,%r15
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %ebp,%ebp
jmp    11de <main+0x5e>
nopl   (%rax)
add    $0x1,%rbx
add    $0x15,%r13
cmp    $0x14,%rbx
je     125a <main+0xda>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %al,0x0(%r13,%r14,1)
cmp    $0x50,%al
cmove  %r14d,%ebp
cmove  %ebx,%r12d
add    $0x1,%r14
cmp    $0x14,%r14
jne    11f0 <main+0x70>
mov    %r15,%rdi
call   1060 <fgetc@plt>
cmp    $0xd,%eax
je     1233 <main+0xb3>
lea    0xeed(%rip),%rdi
mov    $0x14,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1060 <fgetc@plt>
cmp    $0xa,%eax
je     11d0 <main+0x50>
lea    0xecb(%rip),%rdi
mov    $0x14,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d0 <main+0x50>
mov    %r15,%rdi
call   1030 <fclose@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
call   10a0 <DEBUG_PrintScreen@plt>
lea    0xebe(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     14b8 <main+0x338>
mov    %rax,%rbx
movl   $0x0,0x8(%rsp)
xor    %r15d,%r15d
xor    %r13d,%r13d
movslq %r12d,%rcx
movslq %ebp,%rdx
lea    (%rcx,%rcx,4),%rax
lea    (%rcx,%rax,4),%rax
add    %rsp,%rax
add    $0x30,%rax
add    %rdx,%rax
mov    %rax,0x28(%rsp)
lea    0x1(%rcx),%eax
mov    %eax,0x14(%rsp)
add    $0xffffffff,%ecx
mov    %rcx,0x20(%rsp)
lea    0x1(%rdx),%eax
mov    %eax,0x10(%rsp)
add    $0xffffffff,%edx
mov    %rdx,0x18(%rsp)
mov    $0x1,%r14b
mov    %r13d,0xc(%rsp)
mov    %r15d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <feof@plt>
test   $0x1,%r14b
je     148a <main+0x30a>
test   %eax,%eax
jne    148a <main+0x30a>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r15d
shl    $0x18,%r15d
mov    $0x1,%r14b
cmp    $0x20000000,%r15d
je     12f0 <main+0x170>
sar    $0x18,%r15d
lea    0xe0d(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%rax
movb   $0x20,(%rax)
add    $0xffffffbc,%r15d
cmp    $0x11,%r15d
ja     1392 <main+0x212>
lea    0xcad(%rip),%rcx
movslq (%rcx,%r15,4),%rax
add    %rcx,%rax
mov    %r13d,%r15d
mov    0xc(%rsp),%r13d
jmp    *%rax
mov    %ebp,%r15d
mov    0x14(%rsp),%r13d
jmp    13a0 <main+0x220>
mov    0x18(%rsp),%rax
mov    %eax,%r15d
mov    %r12d,%r13d
jmp    13a0 <main+0x220>
mov    0x10(%rsp),%r15d
mov    %r12d,%r13d
jmp    13a0 <main+0x220>
mov    %ebp,%r15d
mov    0x20(%rsp),%rax
mov    %eax,%r13d
jmp    13a0 <main+0x220>
mov    %r13d,%r15d
mov    0xc(%rsp),%r13d
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r14b
cmp    $0x13,%r15d
ja     12d9 <main+0x159>
test   %r13d,%r13d
js     12d9 <main+0x159>
cmp    $0x13,%r13d
jg     12d9 <main+0x159>
mov    %r13d,%eax
mov    %r15d,%ecx
lea    (%rax,%rax,4),%rdx
lea    (%rax,%rdx,4),%rax
add    %rsp,%rax
add    $0x30,%rax
mov    (%rcx,%rax,1),%cl
cmp    $0x5b,%cl
je     13f4 <main+0x274>
cmp    $0x23,%cl
je     12d9 <main+0x159>
cmp    $0x5d,%cl
mov    $0x1,%ecx
cmove  %ecx,%r15d
jmp    13fa <main+0x27a>
mov    $0x12,%r15d
mov    %r15d,%ecx
movsbl (%rcx,%rax,1),%edx
cmp    $0x40,%edx
jne    1422 <main+0x2a2>
xor    %r14d,%r14d
lea    0xd3e(%rip),%rdi
mov    %r15d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12d9 <main+0x159>
add    $0xffffffe0,%edx
cmp    $0x2f,%edx
ja     1446 <main+0x2c6>
add    %rcx,%rax
lea    0xc14(%rip),%rsi
movslq (%rsi,%rdx,4),%rcx
add    %rsi,%rcx
jmp    *%rcx
movb   $0x50,(%rax)
mov    %r15d,%ebp
mov    %r13d,%r12d
mov    0x8(%rsp),%esi
jmp    1477 <main+0x2f7>
mov    0x8(%rsp),%esi
jmp    1465 <main+0x2e5>
mov    0x8(%rsp),%esi
jmp    1468 <main+0x2e8>
mov    0x8(%rsp),%esi
jmp    146b <main+0x2eb>
mov    0x8(%rsp),%esi
add    $0x19,%esi
add    $0xf,%esi
add    $0x9,%esi
add    $0x1,%esi
movb   $0x50,(%rax)
mov    %r15d,%ebp
mov    %r13d,%r12d
lea    0x30(%rsp),%rdi
mov    %esi,0x8(%rsp)
call   10a0 <DEBUG_PrintScreen@plt>
jmp    129b <main+0x11b>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xce2(%rip),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"grid.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [33 x i8] c"Error Reading Grid File, (%d,%d)\00"
@.str.3 = [10 x i8] c"prob10.in\00"
@.str.4 = [17 x i8] c"*** Move-%c ***\0A\00"
@.str.5 = [45 x i8] c"Encountered a Ghost at %02d,%02d, GAME OVER\0A\00"
@.str.6 = [11 x i8] c"\0A\0A%d pts.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x [21 x i8]]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i8
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = bitcast [20 x [21 x i8]]* %6 to i8*
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i8 0, i8* %12
store i8 0, i8* %13
%18 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %14
%19 = load i32*, i32** %14
%20 = icmp ne i32* %19, null
br i1 %20, label %23, label %21
21: ; preds = %2
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
store i32 0, i32* %16
br label %24
24: ; preds = %74, %23
%25 = load i32, i32* %16
%26 = icmp slt i32 %25, 20
br i1 %26, label %27, label %77
27: ; preds = %24
store i32 0, i32* %15
br label %28
28: ; preds = %54, %27
%29 = load i32, i32* %15
%30 = icmp slt i32 %29, 20
br i1 %30, label %31, label %57
31: ; preds = %28
%32 = load i32*, i32** %14
%33 = call i32 @fgetc(i32* %32)
%34 = trunc i32 %33 to i8
%35 = load i32, i32* %16
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 %36
%38 = load i32, i32* %15
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [21 x i8], [21 x i8]* %37, i64 0, i64 %39
store i8 %34, i8* %40
%41 = load i32, i32* %16
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 %42
%44 = load i32, i32* %15
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [21 x i8], [21 x i8]* %43, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 80
br i1 %49, label %50, label %53
50: ; preds = %31
%51 = load i32, i32* %15
store i32 %51, i32* %8
%52 = load i32, i32* %16
store i32 %52, i32* %9
br label %53
53: ; preds = %50, %31
br label %54
54: ; preds = %53
%55 = load i32, i32* %15
%56 = add nsw i32 %55, 1
store i32 %56, i32* %15
br label %28
57: ; preds = %28
%58 = load i32*, i32** %14
%59 = call i32 @fgetc(i32* %58)
%60 = icmp ne i32 %59, 13
br i1 %60, label %61, label %65
61: ; preds = %57
%62 = load i32, i32* %15
%63 = load i32, i32* %16
%64 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %62, i32 %63)
br label %65
65: ; preds = %61, %57
%66 = load i32*, i32** %14
%67 = call i32 @fgetc(i32* %66)
%68 = icmp ne i32 %67, 10
br i1 %68, label %69, label %73
69: ; preds = %65
%70 = load i32, i32* %15
%71 = load i32, i32* %16
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %70, i32 %71)
br label %73
73: ; preds = %69, %65
br label %74
74: ; preds = %73
%75 = load i32, i32* %16
%76 = add nsw i32 %75, 1
store i32 %76, i32* %16
br label %24
77: ; preds = %24
%78 = load i32*, i32** %14
%79 = call i32 @fclose(i32* %78)
store i32* null, i32** %14
%80 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 0
%81 = bitcast [21 x i8]* %80 to i8**
%82 = load i32, i32* %7
%83 = call i32 @DEBUG_PrintScreen(i8** %81, i32 %82)
%84 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %84, i32** %14
%85 = load i32*, i32** %14
%86 = icmp ne i32* %85, null
br i1 %86, label %89, label %87
87: ; preds = %77
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %77
br label %90
90: ; preds = %218, %191, %158, %107, %89
%91 = load i32*, i32** %14
%92 = call i32 @feof(i32* %91)
%93 = icmp ne i32 %92, 0
br i1 %93, label %98, label %94
94: ; preds = %90
%95 = load i8, i8* %13
%96 = icmp ne i8 %95, 0
%97 = xor i1 %96, true
br label %98
98: ; preds = %94, %90
%99 = phi i1 [ false, %90 ], [ %97, %94 ]
br i1 %99, label %100, label %223
100: ; preds = %98
store i8 32, i8* %12
%101 = load i32*, i32** %14
%102 = call i32 @fgetc(i32* %101)
%103 = trunc i32 %102 to i8
store i8 %103, i8* %12
%104 = load i8, i8* %12
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 32
br i1 %106, label %107, label %108
107: ; preds = %100
br label %90
108: ; preds = %100
%109 = load i8, i8* %12
%110 = sext i8 %109 to i32
%111 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %110)
%112 = load i32, i32* %9
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 %113
%115 = load i32, i32* %8
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [21 x i8], [21 x i8]* %114, i64 0, i64 %116
store i8 32, i8* %117
%118 = load i8, i8* %12
%119 = sext i8 %118 to i32
switch i32 %119, label %136 [
i32 76, label %120
i32 82, label %124
i32 85, label %128
i32 68, label %132
]
120: ; preds = %108
%121 = load i32, i32* %8
%122 = sub nsw i32 %121, 1
store i32 %122, i32* %10
%123 = load i32, i32* %9
store i32 %123, i32* %11
br label %136
124: ; preds = %108
%125 = load i32, i32* %8
%126 = add nsw i32 %125, 1
store i32 %126, i32* %10
%127 = load i32, i32* %9
store i32 %127, i32* %11
br label %136
128: ; preds = %108
%129 = load i32, i32* %8
store i32 %129, i32* %10
%130 = load i32, i32* %9
%131 = sub nsw i32 %130, 1
store i32 %131, i32* %11
br label %136
132: ; preds = %108
%133 = load i32, i32* %8
store i32 %133, i32* %10
%134 = load i32, i32* %9
%135 = add nsw i32 %134, 1
store i32 %135, i32* %11
br label %136
136: ; preds = %108, %132, %128, %124, %120
%137 = load i32, i32* %10
%138 = icmp slt i32 %137, 0
br i1 %138, label %158, label %139
139: ; preds = %136
%140 = load i32, i32* %10
%141 = icmp sge i32 %140, 20
br i1 %141, label %158, label %142
142: ; preds = %139
%143 = load i32, i32* %11
%144 = icmp slt i32 %143, 0
br i1 %144, label %158, label %145
145: ; preds = %142
%146 = load i32, i32* %11
%147 = icmp sge i32 %146, 20
br i1 %147, label %158, label %148
148: ; preds = %145
%149 = load i32, i32* %11
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 %150
%152 = load i32, i32* %10
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [21 x i8], [21 x i8]* %151, i64 0, i64 %153
%155 = load i8, i8* %154
%156 = sext i8 %155 to i32
%157 = icmp eq i32 %156, 35
br i1 %157, label %158, label %159
158: ; preds = %148, %145, %142, %139, %136
br label %90
159: ; preds = %148
%160 = load i32, i32* %11
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 %161
%163 = load i32, i32* %10
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds [21 x i8], [21 x i8]* %162, i64 0, i64 %164
%166 = load i8, i8* %165
%167 = sext i8 %166 to i32
%168 = icmp eq i32 %167, 91
br i1 %168, label %169, label %170
169: ; preds = %159
store i32 18, i32* %10
br label %182
170: ; preds = %159
%171 = load i32, i32* %11
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 %172
%174 = load i32, i32* %10
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [21 x i8], [21 x i8]* %173, i64 0, i64 %175
%177 = load i8, i8* %176
%178 = sext i8 %177 to i32
%179 = icmp eq i32 %178, 93
br i1 %179, label %180, label %181
180: ; preds = %170
store i32 1, i32* %10
br label %181
181: ; preds = %180, %170
br label %182
182: ; preds = %181, %169
%183 = load i32, i32* %11
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 %184
%186 = load i32, i32* %10
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [21 x i8], [21 x i8]* %185, i64 0, i64 %187
%189 = load i8, i8* %188
%190 = sext i8 %189 to i32
switch i32 %190, label %218 [
i32 64, label %191
i32 79, label %195
i32 37, label %198
i32 42, label %201
i32 46, label %204
i32 32, label %207
]
191: ; preds = %182
%192 = load i32, i32* %10
%193 = load i32, i32* %11
%194 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %192, i32 %193)
store i8 1, i8* %13
br label %90
195: ; preds = %182
%196 = load i32, i32* %7
%197 = add nsw i32 %196, 25
store i32 %197, i32* %7
br label %198
198: ; preds = %182, %195
%199 = load i32, i32* %7
%200 = add nsw i32 %199, 15
store i32 %200, i32* %7
br label %201
201: ; preds = %182, %198
%202 = load i32, i32* %7
%203 = add nsw i32 %202, 9
store i32 %203, i32* %7
br label %204
204: ; preds = %182, %201
%205 = load i32, i32* %7
%206 = add nsw i32 %205, 1
store i32 %206, i32* %7
br label %207
207: ; preds = %182, %204
%208 = load i32, i32* %7
%209 = add nsw i32 %208, 0
store i32 %209, i32* %7
%210 = load i32, i32* %10
store i32 %210, i32* %8
%211 = load i32, i32* %11
store i32 %211, i32* %9
%212 = load i32, i32* %9
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 %213
%215 = load i32, i32* %8
%216 = sext i32 %215 to i64
%217 = getelementptr inbounds [21 x i8], [21 x i8]* %214, i64 0, i64 %216
store i8 80, i8* %217
br label %218
218: ; preds = %207, %182
%219 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %6, i64 0, i64 0
%220 = bitcast [21 x i8]* %219 to i8**
%221 = load i32, i32* %7
%222 = call i32 @DEBUG_PrintScreen(i8** %220, i32 %221)
br label %90
223: ; preds = %98
%224 = load i32*, i32** %14
%225 = call i32 @fclose(i32* %224)
%226 = load i32, i32* %7
%227 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %226)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"grid.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [33 x i8] c"Error Reading Grid File, (%d,%d)\00"
@.str.3 = [10 x i8] c"prob10.in\00"
@.str.4 = [17 x i8] c"*** Move-%c ***\0A\00"
@.str.5 = [45 x i8] c"Encountered a Ghost at %02d,%02d, GAME OVER\0A\00"
@.str.6 = [11 x i8] c"\0A\0A%d pts.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x [21 x i8]]
%4 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %3, i64 0, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2, %39
%10 = phi i64 [ %40, %39 ], [ 0, %2 ]
%11 = phi i32 [ %25, %39 ], [ 0, %2 ]
%12 = phi i32 [ %24, %39 ], [ 0, %2 ]
%13 = trunc i64 %10 to i32
br label %14
14: ; preds = %9, %14
%15 = phi i64 [ 0, %9 ], [ %26, %14 ]
%16 = phi i32 [ %11, %9 ], [ %25, %14 ]
%17 = phi i32 [ %12, %9 ], [ %24, %14 ]
%18 = tail call i32 @fgetc(i32* %5)
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %3, i64 0, i64 %10, i64 %15
store i8 %19, i8* %20
%21 = and i32 %18, 255
%22 = icmp eq i32 %21, 80
%23 = trunc i64 %15 to i32
%24 = select i1 %22, i32 %23, i32 %17
%25 = select i1 %22, i32 %13, i32 %16
%26 = add nuw nsw i64 %15, 1
%27 = icmp eq i64 %26, 20
br i1 %27, label %28, label %14
28: ; preds = %14
%29 = trunc i64 %10 to i32
%30 = tail call i32 @fgetc(i32* %5)
%31 = icmp eq i32 %30, 13
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 20, i32 %29)
br label %34
34: ; preds = %32, %28
%35 = tail call i32 @fgetc(i32* %5)
%36 = icmp eq i32 %35, 10
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 20, i32 %29)
br label %39
39: ; preds = %34, %37
%40 = add nuw nsw i64 %10, 1
%41 = icmp eq i64 %40, 20
br i1 %41, label %42, label %9
42: ; preds = %39
%43 = tail call i32 @fclose(i32* %5)
%44 = bitcast [20 x [21 x i8]]* %3 to i8**
%45 = call i32 @DEBUG_PrintScreen(i8** %44, i32 0)
%46 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %115
48: ; preds = %42
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %82, %55
%51 = phi i1 [ true, %55 ], [ %85, %82 ]
%52 = call i32 @feof(i32* %46)
%53 = icmp eq i32 %52, 0
%54 = and i1 %51, %53
br i1 %54, label %55, label %128
55: ; preds = %50
%56 = call i32 @fgetc(i32* %46)
%57 = shl i32 %56, 24
%58 = icmp eq i32 %57, 536870912
br i1 %58, label %50, label %59
59: ; preds = %55
%60 = ashr exact i32 %57, 24
%61 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %60)
store i8 32, i8* %123
switch i32 %60, label %66 [
i32 76, label %62
i32 82, label %63
i32 85, label %64
i32 68, label %65
]
62: ; preds = %59
br label %66
63: ; preds = %59
br label %66
64: ; preds = %59
br label %66
65: ; preds = %59
br label %66
66: ; preds = %59, %65, %64, %63, %62
%67 = phi i32 [ %83, %59 ], [ %117, %65 ], [ %117, %64 ], [ %126, %63 ], [ %127, %62 ]
%68 = phi i32 [ %84, %59 ], [ %124, %65 ], [ %125, %64 ], [ %118, %63 ], [ %118, %62 ]
%69 = icmp ugt i32 %67, 19
%70 = icmp slt i32 %68, 0
%71 = select i1 %69, i1 true, i1 %70
%72 = icmp sgt i32 %68, 19
%73 = select i1 %71, i1 true, i1 %72
br i1 %73, label %74, label %77
74: ; preds = %66, %77, %95
%75 = phi i32 [ %90, %95 ], [ %67, %77 ], [ %67, %66 ]
%76 = phi i1 [ false, %95 ], [ true, %77 ], [ true, %66 ]
br label %82
77: ; preds = %66
%78 = zext i32 %68 to i64
%79 = zext i32 %67 to i64
%80 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %3, i64 0, i64 %78, i64 %79
%81 = load i8, i8* %80
switch i8 %81, label %86 [
i8 35, label %74
i8 91, label %89
]
82: ; preds = %74, %115
%83 = phi i32 [ %119, %115 ], [ %75, %74 ]
%84 = phi i32 [ %120, %115 ], [ %68, %74 ]
%85 = phi i1 [ true, %115 ], [ %76, %74 ]
br label %50
86: ; preds = %77
%87 = icmp eq i8 %81, 93
%88 = select i1 %87, i32 1, i32 %67
br label %89
89: ; preds = %77, %86
%90 = phi i32 [ %88, %86 ], [ 18, %77 ]
%91 = zext i32 %90 to i64
%92 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %3, i64 0, i64 %78, i64 %91
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
switch i32 %94, label %110 [
i32 64, label %95
i32 79, label %97
i32 37, label %99
i32 42, label %102
i32 46, label %105
i32 32, label %108
]
95: ; preds = %89
%96 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %90, i32 %68)
br label %74
97: ; preds = %89
%98 = add nsw i32 %116, 25
br label %99
99: ; preds = %89, %97
%100 = phi i32 [ %98, %97 ], [ %116, %89 ]
%101 = add nsw i32 %100, 15
br label %102
102: ; preds = %89, %99
%103 = phi i32 [ %101, %99 ], [ %116, %89 ]
%104 = add nsw i32 %103, 9
br label %105
105: ; preds = %89, %102
%106 = phi i32 [ %104, %102 ], [ %116, %89 ]
%107 = add nsw i32 %106, 1
br label %108
108: ; preds = %89, %105
%109 = phi i32 [ %107, %105 ], [ %116, %89 ]
store i8 80, i8* %92
br label %110
110: ; preds = %89, %108
%111 = phi i32 [ %109, %108 ], [ %116, %89 ]
%112 = phi i32 [ %90, %108 ], [ %117, %89 ]
%113 = phi i32 [ %68, %108 ], [ %118, %89 ]
%114 = call i32 @DEBUG_PrintScreen(i8** %44, i32 %111)
br label %115
115: ; preds = %42, %110
%116 = phi i32 [ %111, %110 ], [ 0, %42 ]
%117 = phi i32 [ %112, %110 ], [ %24, %42 ]
%118 = phi i32 [ %113, %110 ], [ %25, %42 ]
%119 = phi i32 [ %90, %110 ], [ 0, %42 ]
%120 = phi i32 [ %68, %110 ], [ 0, %42 ]
%121 = sext i32 %118 to i64
%122 = sext i32 %117 to i64
%123 = getelementptr inbounds [20 x [21 x i8]], [20 x [21 x i8]]* %3, i64 0, i64 %121, i64 %122
%124 = add nsw i32 %118, 1
%125 = add nsw i32 %118, -1
%126 = add nsw i32 %117, 1
%127 = add nsw i32 %117, -1
br label %82
128: ; preds = %50
%129 = call i32 @fclose(i32* %46)
%130 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %116)
ret i32 0
}