#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 */
char EOF;
int /*<<< orphan*/ clear_screen();
int /*<<< orphan*/ dist(int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ position(char **, int *, char);
int /*<<< orphan*/ print_maze(char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ validate_position(char **, int, int);
int /*<<< orphan*/ walking(char **, int *, int *);
int main(int argc, char *argv[]) {
  int ghost[3], pacman[3], red[3], target[2], number_ghost;
  char maze[23][30];
  char ch;
  int i = 0, j = 0;
  FILE *fp;
  fp = fopen("maze.txt", "r");
  if (fp == NULL)
    printf("Erro, nao foi possivel abrir o arquivo\n");
  else
    while ((ch = fgetc(fp)) != EOF) {
      if (ch != '\n') {
        maze[i][j] = ch;
        j++;
      } else {
        j = 0;
        i++;
      }
    }
  fclose(fp);
  clear_screen();
  print_maze(maze);
  printf("\t>>> GHOSTS <<<\n");
  printf("1.BLINK  2.PINK  3.INKY  4.CLYDE\n");
  do {
    printf("Qual o numero do Ghost? = ");
    scanf("%d", &number_ghost);
  } while (number_ghost > 4 || number_ghost < 1);
  do {
    print_maze(maze);
    printf("Qual a posição do GHOST? (x,y)\n");
    printf("x: ");
    scanf("%d", &ghost[1]);
    printf("y: ");
    scanf("%d", &ghost[0]);
    printf("Direção do ghost = 1-Down , 2-Right, 3-Up, 4-Left = ");
    scanf("%d", &ghost[2]);
    clear_screen();
  } while (!validate_position(maze, ghost[0], ghost[1]) || ghost[2] > 4 ||
           ghost[2] < 1);
  position(maze, ghost, '3');
  do {
    print_maze(maze);
    printf("Qual a posição do RED? (x,y)\n");
    printf("x: ");
    scanf("%d", &red[1]);
    printf("y: ");
    scanf("%d", &red[0]);
    printf("Direção do red = 1-Down , 2-Right, 3-Up, 4-Left = ");
    scanf("%d", &red[2]);
    clear_screen();
  } while (!validate_position(maze, red[0], red[1]) || red[2] > 4 ||
           red[2] < 1);
  position(maze, red, '4');
  do {
    clear_screen();
    print_maze(maze);
    printf("Qual a posição do Pacman? (x,y)\n");
    printf("x: ");
    scanf("%d", &pacman[1]);
    printf("y: ");
    scanf("%d", &pacman[0]);
  } while (!validate_position(maze, pacman[0], pacman[1]));
  do {
    printf("Direção do Pac-mam: 1-Down , 2-Right, 3-Up, 4-Left =  ");
    scanf("%d", &pacman[2]);
  } while (pacman[2] > 4 || pacman[2] < 1);
  position(maze, pacman, '5');
  dist(pacman);
  target[0] = (pacman[0] - red[0]) + pacman[0];
  target[1] = (pacman[1] - red[1]) + pacman[1];
  position(maze, target, '8');
  print_maze(maze);
  walking(maze, ghost, target);
  print_maze(maze);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x320,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x308(%rbp)
movl   $0x0,-0x30c(%rbp)
lea    0xe1c(%rip),%rdi
lea    0xe1e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x318(%rbp)
cmpq   $0x0,-0x318(%rbp)
jne    1216 <main+0x66>
lea    0xdff(%rip),%rdi
call   1040 <printf@plt>
jmp    12ae <main+0xfe>
jmp    121b <main+0x6b>
mov    -0x318(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x301(%rbp)
movsbl %al,%eax
mov    0x2db1(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12a9 <main+0xf9>
movsbl -0x301(%rbp),%eax
cmp    $0xa,%eax
je     128b <main+0xdb>
mov    -0x301(%rbp),%dl
movslq -0x308(%rbp),%rcx
lea    -0x300(%rbp),%rax
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
movslq -0x30c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30c(%rbp)
jmp    12a4 <main+0xf4>
movl   $0x0,-0x30c(%rbp)
mov    -0x308(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x308(%rbp)
jmp    121b <main+0x6b>
jmp    12ae <main+0xfe>
mov    -0x318(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x0,%al
call   1090 <clear_screen@plt>
lea    -0x300(%rbp),%rdi
call   10d0 <print_maze@plt>
lea    0xd5f(%rip),%rdi
call   1040 <printf@plt>
lea    0xd64(%rip),%rdi
call   1040 <printf@plt>
lea    0xd7a(%rip),%rdi
call   1040 <printf@plt>
lea    0xd89(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x1,%al
cmpl   $0x4,-0x40(%rbp)
mov    %al,-0x319(%rbp)
jg     1320 <main+0x170>
cmpl   $0x1,-0x40(%rbp)
setl   %al
mov    %al,-0x319(%rbp)
mov    -0x319(%rbp),%al
test   $0x1,%al
jne    12e5 <main+0x135>
jmp    1333 <main+0x183>
lea    -0x300(%rbp),%rdi
call   10d0 <print_maze@plt>
lea    0xd3e(%rip),%rdi
call   1040 <printf@plt>
lea    0xd54(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1c(%rbp),%rsi
add    $0x4,%rsi
lea    0xd1b(%rip),%rdi
call   1080 <scanf@plt>
lea    0xd38(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1c(%rbp),%rsi
lea    0xcff(%rip),%rdi
call   1080 <scanf@plt>
lea    0xd20(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1c(%rbp),%rsi
add    $0x8,%rsi
lea    0xcdf(%rip),%rdi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1090 <clear_screen@plt>
lea    -0x300(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10b0 <validate_position@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x31a(%rbp)
je     13f2 <main+0x242>
mov    $0x1,%al
cmpl   $0x4,-0x14(%rbp)
mov    %al,-0x31a(%rbp)
jg     13f2 <main+0x242>
cmpl   $0x1,-0x14(%rbp)
setl   %al
mov    %al,-0x31a(%rbp)
mov    -0x31a(%rbp),%al
test   $0x1,%al
jne    1333 <main+0x183>
lea    -0x300(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x33,%edx
call   1050 <position@plt>
lea    -0x300(%rbp),%rdi
call   10d0 <print_maze@plt>
lea    0xcbd(%rip),%rdi
call   1040 <printf@plt>
lea    0xc72(%rip),%rdi
call   1040 <printf@plt>
lea    -0x34(%rbp),%rsi
add    $0x4,%rsi
lea    0xc39(%rip),%rdi
call   1080 <scanf@plt>
lea    0xc56(%rip),%rdi
call   1040 <printf@plt>
lea    -0x34(%rbp),%rsi
lea    0xc1d(%rip),%rdi
call   1080 <scanf@plt>
lea    0xc95(%rip),%rdi
call   1040 <printf@plt>
lea    -0x34(%rbp),%rsi
add    $0x8,%rsi
lea    0xbfd(%rip),%rdi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1090 <clear_screen@plt>
lea    -0x300(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%edx
call   10b0 <validate_position@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x31b(%rbp)
je     14d4 <main+0x324>
mov    $0x1,%al
cmpl   $0x4,-0x2c(%rbp)
mov    %al,-0x31b(%rbp)
jg     14d4 <main+0x324>
cmpl   $0x1,-0x2c(%rbp)
setl   %al
mov    %al,-0x31b(%rbp)
mov    -0x31b(%rbp),%al
test   $0x1,%al
jne    1415 <main+0x265>
lea    -0x300(%rbp),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x34,%edx
call   1050 <position@plt>
mov    $0x0,%al
call   1090 <clear_screen@plt>
lea    -0x300(%rbp),%rdi
call   10d0 <print_maze@plt>
lea    0xc29(%rip),%rdi
call   1040 <printf@plt>
lea    0xb89(%rip),%rdi
call   1040 <printf@plt>
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
lea    0xb50(%rip),%rdi
call   1080 <scanf@plt>
lea    0xb6d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x28(%rbp),%rsi
lea    0xb34(%rip),%rdi
call   1080 <scanf@plt>
lea    -0x300(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10b0 <validate_position@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    14f7 <main+0x347>
jmp    1579 <main+0x3c9>
lea    0xbdd(%rip),%rdi
call   1040 <printf@plt>
lea    -0x28(%rbp),%rsi
add    $0x8,%rsi
lea    0xaed(%rip),%rdi
call   1080 <scanf@plt>
mov    $0x1,%al
cmpl   $0x4,-0x20(%rbp)
mov    %al,-0x31c(%rbp)
jg     15b8 <main+0x408>
cmpl   $0x1,-0x20(%rbp)
setl   %al
mov    %al,-0x31c(%rbp)
mov    -0x31c(%rbp),%al
test   $0x1,%al
jne    1579 <main+0x3c9>
lea    -0x300(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x35,%edx
call   1050 <position@plt>
lea    -0x28(%rbp),%rdi
call   1070 <dist@plt>
mov    -0x28(%rbp),%eax
sub    -0x34(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%eax
sub    -0x30(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x300(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
mov    $0x38,%edx
call   1050 <position@plt>
lea    -0x300(%rbp),%rdi
call   10d0 <print_maze@plt>
lea    -0x300(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   10c0 <walking@plt>
lea    -0x300(%rbp),%rdi
call   10d0 <print_maze@plt>
xor    %eax,%eax
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2e8,%rsp
lea    0xe28(%rip),%rdi
lea    0xe2a(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1249 <main+0x89>
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    0x2ded(%rip),%r14
cmp    (%r14),%al
je     1255 <main+0x95>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1222 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %ebx,%ebx
mov    %r15,%rdi
call   1070 <fgetc@plt>
cmp    (%r14),%al
je     1255 <main+0x95>
cmp    $0xa,%al
je     1210 <main+0x50>
movslq %ebp,%rcx
movslq %ebx,%rbx
mov    %rcx,%rdx
shl    $0x5,%rdx
sub    %rcx,%rdx
sub    %rcx,%rdx
lea    (%rsp,%rdx,1),%rcx
add    $0x30,%rcx
mov    %al,(%rbx,%rcx,1)
add    $0x1,%ebx
jmp    1215 <main+0x55>
lea    0xf19(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
call   10a0 <clear_screen@plt>
lea    0x30(%rsp),%rdi
call   10e0 <print_maze@plt>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
lea    0xd7e(%rip),%r14
lea    0xd92(%rip),%rbp
lea    0x24(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
mov    0x24(%rsp),%eax
add    $0xfffffffb,%eax
cmp    $0xfffffffc,%eax
jb     12a0 <main+0xe0>
lea    0x30(%rsp),%rbx
lea    0xd5e(%rip),%r13
lea    0xd54(%rip),%rbp
lea    0xd54(%rip),%r14
lea    0x18(%rsp),%r15
lea    0xd4c(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   10e0 <print_maze@plt>
lea    0xe08(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
lea    0x1c(%rsp),%rsi
call   1090 <scanf@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1090 <scanf@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
lea    0x20(%rsp),%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   10a0 <clear_screen@plt>
mov    0x18(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
call   10c0 <validate_position@plt>
test   %eax,%eax
je     12f0 <main+0x130>
mov    0x20(%rsp),%eax
cmp    $0x4,%eax
jg     12f0 <main+0x130>
test   %eax,%eax
jle    12f0 <main+0x130>
lea    0x30(%rsp),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x33,%edx
call   1060 <position@plt>
lea    0xca2(%rip),%r13
lea    0xc98(%rip),%rbp
lea    0xc98(%rip),%r14
mov    %rsp,%r15
lea    0xcc9(%rip),%r12
nop
mov    %rbx,%rdi
call   10e0 <print_maze@plt>
lea    0xd79(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1090 <scanf@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
lea    0x8(%rsp),%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   10a0 <clear_screen@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
call   10c0 <validate_position@plt>
test   %eax,%eax
je     13a0 <main+0x1e0>
mov    0x8(%rsp),%eax
cmp    $0x4,%eax
jg     13a0 <main+0x1e0>
test   %eax,%eax
jle    13a0 <main+0x1e0>
lea    0x30(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x34,%edx
call   1060 <position@plt>
lea    0xd13(%rip),%r15
lea    0xbee(%rip),%r12
lea    0xbe4(%rip),%rbp
lea    0xbe4(%rip),%r13
lea    0xc(%rsp),%r14
xchg   %ax,%ax
xor    %eax,%eax
call   10a0 <clear_screen@plt>
mov    %rbx,%rdi
call   10e0 <print_maze@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
call   1090 <scanf@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
call   10c0 <validate_position@plt>
test   %eax,%eax
je     1450 <main+0x290>
lea    0x14(%rsp),%r14
lea    0xbee(%rip),%rbp
lea    0xb70(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xfffffffb,%eax
cmp    $0xfffffffc,%eax
jb     14c0 <main+0x300>
lea    0x30(%rsp),%rbx
lea    0xc(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x35,%edx
call   1060 <position@plt>
mov    %rbp,%rdi
call   1080 <dist@plt>
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%ecx
add    %eax,%eax
sub    (%rsp),%eax
mov    %eax,0x28(%rsp)
add    %ecx,%ecx
sub    0x4(%rsp),%ecx
mov    %ecx,0x2c(%rsp)
lea    0x28(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x38,%edx
call   1060 <position@plt>
mov    %rbx,%rdi
call   10e0 <print_maze@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
call   10d0 <walking@plt>
mov    %rbx,%rdi
call   10e0 <print_maze@plt>
xor    %eax,%eax
add    $0x2e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"maze.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [40 x i8] c"Erro, nao foi possivel abrir o arquivo\0A\00"
@EOF = global i8 0
@.str.3 = [17 x i8] c"\09>>> GHOSTS <<<\0A\00"
@.str.4 = [34 x i8] c"1.BLINK 2.PINK 3.INKY 4.CLYDE\0A\00"
@.str.5 = [27 x i8] c"Qual o numero do Ghost? = \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [34 x i8] c"Qual a posi\C3\A7\C3\A3o do GHOST? (x,y)\0A\00"
@.str.8 = [4 x i8] c"x: \00"
@.str.9 = [4 x i8] c"y: \00"
@.str.10 = [55 x i8] c"Dire\C3\A7\C3\A3o do ghost = 1-Down , 2-Right, 3-Up, 4-Left = \00"
@.str.11 = [32 x i8] c"Qual a posi\C3\A7\C3\A3o do RED? (x,y)\0A\00"
@.str.12 = [53 x i8] c"Dire\C3\A7\C3\A3o do red = 1-Down , 2-Right, 3-Up, 4-Left = \00"
@.str.13 = [35 x i8] c"Qual a posi\C3\A7\C3\A3o do Pacman? (x,y)\0A\00"
@.str.14 = [57 x i8] c"Dire\C3\A7\C3\A3o do Pac-mam: 1-Down , 2-Right, 3-Up, 4-Left = \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i32]
%7 = alloca [3 x i32]
%8 = alloca [3 x i32]
%9 = alloca [2 x i32]
%10 = alloca i32
%11 = alloca [23 x [30 x i8]]
%12 = alloca i8
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %13
store i32 0, i32* %14
%16 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %15
%17 = load i32*, i32** %15
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %48
21: ; preds = %2
br label %22
22: ; preds = %46, %21
%23 = load i32*, i32** %15
%24 = call signext i8 @fgetc(i32* %23)
store i8 %24, i8* %12
%25 = sext i8 %24 to i32
%26 = load i8, i8* @EOF
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %25, %27
br i1 %28, label %29, label %47
29: ; preds = %22
%30 = load i8, i8* %12
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %43
33: ; preds = %29
%34 = load i8, i8* %12
%35 = load i32, i32* %13
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 %36
%38 = load i32, i32* %14
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [30 x i8], [30 x i8]* %37, i64 0, i64 %39
store i8 %34, i8* %40
%41 = load i32, i32* %14
%42 = add nsw i32 %41, 1
store i32 %42, i32* %14
br label %46
43: ; preds = %29
store i32 0, i32* %14
%44 = load i32, i32* %13
%45 = add nsw i32 %44, 1
store i32 %45, i32* %13
br label %46
46: ; preds = %43, %33
br label %22
47: ; preds = %22
br label %48
48: ; preds = %47, %19
%49 = load i32*, i32** %15
%50 = call i32 @fclose(i32* %49)
%51 = call i32 (...) @clear_screen()
%52 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%53 = bitcast [30 x i8]* %52 to i8**
%54 = call i32 @print_maze(i8** %53)
%55 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%56 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %66, %48
%58 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%59 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %10)
br label %60
60: ; preds = %57
%61 = load i32, i32* %10
%62 = icmp sgt i32 %61, 4
br i1 %62, label %66, label %63
63: ; preds = %60
%64 = load i32, i32* %10
%65 = icmp slt i32 %64, 1
br label %66
66: ; preds = %63, %60
%67 = phi i1 [ true, %60 ], [ %65, %63 ]
br i1 %67, label %57, label %68
68: ; preds = %66
br label %69
69: ; preds = %101, %68
%70 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%71 = bitcast [30 x i8]* %70 to i8**
%72 = call i32 @print_maze(i8** %71)
%73 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%74 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%75 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%76 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %75)
%77 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%78 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%79 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %78)
%80 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0))
%81 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
%82 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %81)
%83 = call i32 (...) @clear_screen()
br label %84
84: ; preds = %69
%85 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%86 = bitcast [30 x i8]* %85 to i8**
%87 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%88 = load i32, i32* %87
%89 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%90 = load i32, i32* %89
%91 = call i32 @validate_position(i8** %86, i32 %88, i32 %90)
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %101
93: ; preds = %84
%94 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
%95 = load i32, i32* %94
%96 = icmp sgt i32 %95, 4
br i1 %96, label %101, label %97
97: ; preds = %93
%98 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
%99 = load i32, i32* %98
%100 = icmp slt i32 %99, 1
br label %101
101: ; preds = %97, %93, %84
%102 = phi i1 [ true, %93 ], [ true, %84 ], [ %100, %97 ]
br i1 %102, label %69, label %103
103: ; preds = %101
%104 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%105 = bitcast [30 x i8]* %104 to i8**
%106 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%107 = call i32 @position(i8** %105, i32* %106, i8 signext 51)
br label %108
108: ; preds = %140, %103
%109 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%110 = bitcast [30 x i8]* %109 to i8**
%111 = call i32 @print_maze(i8** %110)
%112 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
%113 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%114 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 1
%115 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %114)
%116 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%117 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%118 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %117)
%119 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.12, i64 0, i64 0))
%120 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 2
%121 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %120)
%122 = call i32 (...) @clear_screen()
br label %123
123: ; preds = %108
%124 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%125 = bitcast [30 x i8]* %124 to i8**
%126 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%127 = load i32, i32* %126
%128 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 1
%129 = load i32, i32* %128
%130 = call i32 @validate_position(i8** %125, i32 %127, i32 %129)
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %140
132: ; preds = %123
%133 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 2
%134 = load i32, i32* %133
%135 = icmp sgt i32 %134, 4
br i1 %135, label %140, label %136
136: ; preds = %132
%137 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 2
%138 = load i32, i32* %137
%139 = icmp slt i32 %138, 1
br label %140
140: ; preds = %136, %132, %123
%141 = phi i1 [ true, %132 ], [ true, %123 ], [ %139, %136 ]
br i1 %141, label %108, label %142
142: ; preds = %140
%143 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%144 = bitcast [30 x i8]* %143 to i8**
%145 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%146 = call i32 @position(i8** %144, i32* %145, i8 signext 52)
br label %147
147: ; preds = %159, %142
%148 = call i32 (...) @clear_screen()
%149 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%150 = bitcast [30 x i8]* %149 to i8**
%151 = call i32 @print_maze(i8** %150)
%152 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
%153 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%154 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%155 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %154)
%156 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%157 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%158 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %157)
br label %159
159: ; preds = %147
%160 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%161 = bitcast [30 x i8]* %160 to i8**
%162 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%163 = load i32, i32* %162
%164 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%165 = load i32, i32* %164
%166 = call i32 @validate_position(i8** %161, i32 %163, i32 %165)
%167 = icmp ne i32 %166, 0
%168 = xor i1 %167, true
br i1 %168, label %147, label %169
169: ; preds = %159
br label %170
170: ; preds = %182, %169
%171 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0))
%172 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%173 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %172)
br label %174
174: ; preds = %170
%175 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%176 = load i32, i32* %175
%177 = icmp sgt i32 %176, 4
br i1 %177, label %182, label %178
178: ; preds = %174
%179 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%180 = load i32, i32* %179
%181 = icmp slt i32 %180, 1
br label %182
182: ; preds = %178, %174
%183 = phi i1 [ true, %174 ], [ %181, %178 ]
br i1 %183, label %170, label %184
184: ; preds = %182
%185 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%186 = bitcast [30 x i8]* %185 to i8**
%187 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%188 = call i32 @position(i8** %186, i32* %187, i8 signext 53)
%189 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%190 = call i32 @dist(i32* %189)
%191 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%192 = load i32, i32* %191
%193 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%194 = load i32, i32* %193
%195 = sub nsw i32 %192, %194
%196 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%197 = load i32, i32* %196
%198 = add nsw i32 %195, %197
%199 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
store i32 %198, i32* %199
%200 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%201 = load i32, i32* %200
%202 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 1
%203 = load i32, i32* %202
%204 = sub nsw i32 %201, %203
%205 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%206 = load i32, i32* %205
%207 = add nsw i32 %204, %206
%208 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
store i32 %207, i32* %208
%209 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%210 = bitcast [30 x i8]* %209 to i8**
%211 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%212 = call i32 @position(i8** %210, i32* %211, i8 signext 56)
%213 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%214 = bitcast [30 x i8]* %213 to i8**
%215 = call i32 @print_maze(i8** %214)
%216 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%217 = bitcast [30 x i8]* %216 to i8**
%218 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%219 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%220 = call i32 @walking(i8** %217, i32* %218, i32* %219)
%221 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %11, i64 0, i64 0
%222 = bitcast [30 x i8]* %221 to i8**
%223 = call i32 @print_maze(i8** %222)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"maze.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.5 = [27 x i8] c"Qual o numero do Ghost? = \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.8 = [4 x i8] c"x: \00"
@.str.9 = [4 x i8] c"y: \00"
@.str.10 = [55 x i8] c"Dire\C3\A7\C3\A3o do ghost = 1-Down , 2-Right, 3-Up, 4-Left = \00"
@.str.12 = [53 x i8] c"Dire\C3\A7\C3\A3o do red = 1-Down , 2-Right, 3-Up, 4-Left = \00"
@.str.14 = [57 x i8] c"Dire\C3\A7\C3\A3o do Pac-mam: 1-Down , 2-Right, 3-Up, 4-Left = \00"
@str = [16 x i8] c"\09>>> GHOSTS <<<\00"
@str.15 = [33 x i8] c"1.BLINK 2.PINK 3.INKY 4.CLYDE\00"
@str.16 = [33 x i8] c"Qual a posi\C3\A7\C3\A3o do GHOST? (x,y)\00"
@str.17 = [31 x i8] c"Qual a posi\C3\A7\C3\A3o do RED? (x,y)\00"
@str.18 = [34 x i8] c"Qual a posi\C3\A7\C3\A3o do Pacman? (x,y)\00"
@str.19 = [39 x i8] c"Erro, nao foi possivel abrir o arquivo\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i32]
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = alloca [2 x i32]
%7 = alloca i32
%8 = alloca [23 x [30 x i8]]
%9 = bitcast [3 x i32]* %3 to i8*
%10 = bitcast [3 x i32]* %4 to i8*
%11 = bitcast [3 x i32]* %5 to i8*
%12 = bitcast [2 x i32]* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 0, i64 0
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %21, label %17
17: ; preds = %2
%18 = tail call signext i8 @fgetc(i32* %15)
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %18, %19
br i1 %20, label %41, label %23
21: ; preds = %2
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.19, i64 0, i64 0))
br label %41
23: ; preds = %17, %35
%24 = phi i8 [ %38, %35 ], [ %18, %17 ]
%25 = phi i32 [ %37, %35 ], [ 0, %17 ]
%26 = phi i32 [ %36, %35 ], [ 0, %17 ]
%27 = icmp eq i8 %24, 10
br i1 %27, label %33, label %28
28: ; preds = %23
%29 = sext i32 %26 to i64
%30 = sext i32 %25 to i64
%31 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 %29, i64 %30
store i8 %24, i8* %31
%32 = add nsw i32 %25, 1
br label %35
33: ; preds = %23
%34 = add nsw i32 %26, 1
br label %35
35: ; preds = %33, %28
%36 = phi i32 [ %26, %28 ], [ %34, %33 ]
%37 = phi i32 [ %32, %28 ], [ 0, %33 ]
%38 = tail call signext i8 @fgetc(i32* %15)
%39 = load i8, i8* @EOF
%40 = icmp eq i8 %38, %39
br i1 %40, label %41, label %23
41: ; preds = %35, %17, %21
%42 = tail call i32 @fclose(i32* %15)
%43 = tail call i32 (...) @clear_screen()
%44 = bitcast [23 x [30 x i8]]* %8 to i8**
%45 = call i32 @print_maze(i8** %44)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.15, i64 0, i64 0))
br label %48
48: ; preds = %48, %41
%49 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %7)
%51 = load i32, i32* %7
%52 = add i32 %51, -5
%53 = icmp ult i32 %52, -4
br i1 %53, label %48, label %54
54: ; preds = %48
%55 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%56 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%57 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
br label %58
58: ; preds = %54, %58
%59 = call i32 @print_maze(i8** %44)
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.16, i64 0, i64 0))
%61 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%62 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %55)
%63 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%64 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %56)
%65 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0))
%66 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %57)
%67 = call i32 (...) @clear_screen()
%68 = load i32, i32* %56
%69 = load i32, i32* %55
%70 = call i32 @validate_position(i8** %44, i32 %68, i32 %69)
%71 = icmp eq i32 %70, 0
%72 = load i32, i32* %57
%73 = icmp sgt i32 %72, 4
%74 = select i1 %71, i1 true, i1 %73
%75 = icmp slt i32 %72, 1
%76 = select i1 %74, i1 true, i1 %75
br i1 %76, label %58, label %77
77: ; preds = %58
%78 = call i32 @position(i8** %44, i32* %56, i8 signext 51)
%79 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 1
%80 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%81 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 2
br label %82
82: ; preds = %82, %77
%83 = call i32 @print_maze(i8** %44)
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.17, i64 0, i64 0))
%85 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%86 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %79)
%87 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%88 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %80)
%89 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.12, i64 0, i64 0))
%90 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %81)
%91 = call i32 (...) @clear_screen()
%92 = load i32, i32* %80
%93 = load i32, i32* %79
%94 = call i32 @validate_position(i8** %44, i32 %92, i32 %93)
%95 = icmp eq i32 %94, 0
%96 = load i32, i32* %81
%97 = icmp sgt i32 %96, 4
%98 = select i1 %95, i1 true, i1 %97
%99 = icmp slt i32 %96, 1
%100 = select i1 %98, i1 true, i1 %99
br i1 %100, label %82, label %101
101: ; preds = %82
%102 = call i32 @position(i8** %44, i32* %80, i8 signext 52)
%103 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 1
%104 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
br label %105
105: ; preds = %105, %101
%106 = call i32 (...) @clear_screen()
%107 = call i32 @print_maze(i8** %44)
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.18, i64 0, i64 0))
%109 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%110 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %103)
%111 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%112 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %104)
%113 = load i32, i32* %104
%114 = load i32, i32* %103
%115 = call i32 @validate_position(i8** %44, i32 %113, i32 %114)
%116 = icmp eq i32 %115, 0
br i1 %116, label %105, label %117
117: ; preds = %105
%118 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 2
br label %119
119: ; preds = %117, %119
%120 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0))
%121 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %118)
%122 = load i32, i32* %118
%123 = add i32 %122, -5
%124 = icmp ult i32 %123, -4
br i1 %124, label %119, label %125
125: ; preds = %119
%126 = call i32 @position(i8** %44, i32* %104, i8 signext 53)
%127 = call i32 @dist(i32* %104)
%128 = load i32, i32* %104
%129 = load i32, i32* %80
%130 = shl i32 %128, 1
%131 = sub i32 %130, %129
%132 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %131, i32* %132
%133 = load i32, i32* %103
%134 = load i32, i32* %79
%135 = shl i32 %133, 1
%136 = sub i32 %135, %134
%137 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %136, i32* %137
%138 = call i32 @position(i8** %44, i32* %132, i8 signext 56)
%139 = call i32 @print_maze(i8** %44)
%140 = call i32 @walking(i8** %44, i32* %56, i32* %132)
%141 = call i32 @print_maze(i8** %44)
ret i32 0
}