#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 *dist(int *);
int *malloc(int);
int *pacman;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int *teste;
int main(int argc, const char *argv[]) {
  int validate_position(char maze[23][30], int x, int y), pacman[3], *teste;
  pacman[0] = 1;
  pacman[2] = 2;
  pacman[3] = 4;
  teste = malloc(sizeof(int) * 2);
  teste = dist(pacman);
  printf("%d %d\n", teste[0], teste[1]);
  void print_maze(char maze[23][30]);
  void target_destiny_blue(char matriz[23][30], int lpack, int cpack, int lred,
                           int cred);
  char maze[23][30] = {{'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'},
                       {'0', ' ', ' ', ' ', ' ', ' ', '7', ' ', ' ', ' ',
                        ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ',
                        ' ', ' ', '7', ' ', ' ', ' ', ' ', ' ', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', '0', '0',
                        '0', '0', '0', ' ', '0', ' ', '0', '0', '0', '0',
                        '0', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', '0', '0',
                        '0', '0', '0', ' ', '0', ' ', '0', '0', '0', '0',
                        '0', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', '7', ' ', ' ', ' ', ' ', '7', ' ', ' ', ' ',
                        ' ', ' ', ' ', '7', ' ', '7', ' ', ' ', ' ', ' ',
                        ' ', ' ', '7', ' ', ' ', ' ', ' ', ' ', '7', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', ' ', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', ' ', ' ', ' ', ' ', '7', '0', ' ', ' ',
                        ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ',
                        ' ', '0', '7', ' ', ' ', ' ', ' ', ' ', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', '0', '0',
                        '0', '0', '0', ' ', '0', ' ', '0', '0', '0', '0',
                        '0', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', ' ', ' ',
                        ' ', ' ', ' ', '6', ' ', '6', ' ', ' ', ' ', ' ',
                        ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', ' ', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', ' ', '7', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        '7', ' ', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', ' ', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', ' ', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', '7', ' ',
                        ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
                        '7', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', ' ', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', ' ', ' ', ' ', ' ', '7', ' ', '7', ' ',
                        ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ',
                        '7', ' ', '7', ' ', ' ', ' ', ' ', ' ', ' ', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', '0', '0',
                        '0', '0', '0', ' ', '0', ' ', '0', '0', '0', '0',
                        '0', '0', ' ', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', '7', ' ', ' ', ' ', ' ', '7', ' ', '7', ' ',
                        ' ', ' ', ' ', '6', ' ', '6', ' ', ' ', ' ', ' ',
                        '7', ' ', '7', '0', ' ', ' ', ' ', ' ', '7', '0'},
                       {'0', ' ', '0', '0', '0', '0', ' ', '0', ' ', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        ' ', '0', ' ', '0', ' ', '0', '0', '0', ' ', '0'},
                       {'0', '7', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ',
                        ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ',
                        ' ', '0', ' ', ' ', '7', ' ', ' ', ' ', '7', '0'},
                       {'0', ' ', '0', '0', '0', '0', '0', '0', '0', '0',
                        '0', '0', '0', ' ', '0', ' ', '0', '0', '0', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', ' ', '0'},
                       {'0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
                        ' ', ' ', ' ', '7', ' ', '7', ' ', ' ', ' ', ' ',
                        ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0'},
                       {'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
                        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'}};
  print_maze(maze);
  int lpac, cpac, validade1 = 0;
  pacman[0] = 3;
  pacman[1] = 3;
  pacman[2] = 1;
  while (validade1 == 0) {
    printf("Insira a posicao do pacman: \n");
    scanf("%d", &lpac);
    scanf("%d", &cpac);
    if (validate_position(maze, lpac, cpac)) {
      validade1 = 1;
      maze[lpac][cpac] = 'P';
    } else {
      printf("Posicao invalida!!!\n\n");
    }
  }
  int lred, cred, validade2 = 0;
  while (validade2 == 0) {
    printf("Insira a posicao do ghost red: \n");
    scanf("%d", &lred);
    scanf("%d", &cred);
    if (validate_position(maze, lred, cred)) {
      validade2 = 1;
      maze[lred][cred] = 'R';
    } else {
      printf("Posicao invalida!!!\n\n");
    }
  }
  int lblu, cblu, validade3 = 0;
  while (validade3 == 0) {
    printf("Insira a posicao do ghost blue: \n");
    scanf("%d", &lblu);
    scanf("%d", &cblu);
    if (validate_position(maze, lblu, cblu)) {
      validade3 = 1;
      maze[lblu][cblu] = 'B';
    } else {
      printf("Posicao invalida!!!\n\n");
    }
  }
  target_destiny_blue(maze, lpac, cpac, lred, cred);
  print_maze(maze);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x310,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x2,-0x14(%rbp)
movl   $0x4,-0x10(%rbp)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    -0x1c(%rbp),%rdi
call   1070 <dist@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2e0(%rbp),%rdi
lea    0xe9e(%rip),%rsi
mov    $0x2b2,%edx
call   1050 <memcpy@plt>
lea    -0x2e0(%rbp),%rdi
call   10a0 <print_maze@plt>
movl   $0x0,-0x2ec(%rbp)
movl   $0x3,-0x1c(%rbp)
movl   $0x3,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x0,-0x2ec(%rbp)
jne    12cb <main+0x14b>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xddc(%rip),%rdi
lea    -0x2e4(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xdc9(%rip),%rdi
lea    -0x2e8(%rbp),%rsi
call   1080 <scanf@plt>
lea    -0x2e0(%rbp),%rdi
mov    -0x2e4(%rbp),%esi
mov    -0x2e8(%rbp),%edx
call   1090 <validate_position@plt>
cmp    $0x0,%eax
je     12b8 <main+0x138>
movl   $0x1,-0x2ec(%rbp)
movslq -0x2e4(%rbp),%rcx
lea    -0x2e0(%rbp),%rax
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
movslq -0x2e8(%rbp),%rcx
movb   $0x50,(%rax,%rcx,1)
jmp    12c6 <main+0x146>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1227 <main+0xa7>
movl   $0x0,-0x2f8(%rbp)
cmpl   $0x0,-0x2f8(%rbp)
jne    1379 <main+0x1f9>
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd2e(%rip),%rdi
lea    -0x2f0(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xd1b(%rip),%rdi
lea    -0x2f4(%rbp),%rsi
call   1080 <scanf@plt>
lea    -0x2e0(%rbp),%rdi
mov    -0x2f0(%rbp),%esi
mov    -0x2f4(%rbp),%edx
call   1090 <validate_position@plt>
cmp    $0x0,%eax
je     1366 <main+0x1e6>
movl   $0x1,-0x2f8(%rbp)
movslq -0x2f0(%rbp),%rcx
lea    -0x2e0(%rbp),%rax
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
movslq -0x2f4(%rbp),%rcx
movb   $0x52,(%rax,%rcx,1)
jmp    1374 <main+0x1f4>
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d5 <main+0x155>
movl   $0x0,-0x304(%rbp)
cmpl   $0x0,-0x304(%rbp)
jne    1427 <main+0x2a7>
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc80(%rip),%rdi
lea    -0x2fc(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xc6d(%rip),%rdi
lea    -0x300(%rbp),%rsi
call   1080 <scanf@plt>
lea    -0x2e0(%rbp),%rdi
mov    -0x2fc(%rbp),%esi
mov    -0x300(%rbp),%edx
call   1090 <validate_position@plt>
cmp    $0x0,%eax
je     1414 <main+0x294>
movl   $0x1,-0x304(%rbp)
movslq -0x2fc(%rbp),%rcx
lea    -0x2e0(%rbp),%rax
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
movslq -0x300(%rbp),%rcx
movb   $0x42,(%rax,%rcx,1)
jmp    1422 <main+0x2a2>
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1383 <main+0x203>
lea    -0x2e0(%rbp),%rdi
mov    -0x2e4(%rbp),%esi
mov    -0x2e8(%rbp),%edx
mov    -0x2f0(%rbp),%ecx
mov    -0x2f4(%rbp),%r8d
call   1030 <target_destiny_blue@plt>
lea    -0x2e0(%rbp),%rdi
call   10a0 <print_maze@plt>
xor    %eax,%eax
add    $0x310,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2e8,%rsp
movl   $0x1,0x24(%rsp)
movl   $0x2,0x2c(%rsp)
movl   $0x4,0x30(%rsp)
mov    $0x8,%edi
call   1070 <malloc@plt>
lea    0x24(%rsp),%rdi
call   1080 <dist@plt>
mov    (%rax),%esi
mov    0x4(%rax),%edx
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe99(%rip),%rsi
lea    0x30(%rsp),%rbx
mov    $0x2b2,%edx
mov    %rbx,%rdi
call   1060 <memcpy@plt>
mov    %rbx,%rdi
call   10b0 <print_maze@plt>
movabs $0x300000003,%rax
mov    %rax,0x24(%rsp)
movl   $0x1,0x2c(%rsp)
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
lea    0xddc(%rip),%rbp
lea    0x18(%rsp),%rsi
mov    %rbp,%rdi
call   1090 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbp,%rdi
call   1090 <scanf@plt>
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
call   10a0 <validate_position@plt>
test   %eax,%eax
jne    12ba <main+0x12a>
lea    0xe08(%rip),%r14
lea    0xde4(%rip),%r15
lea    0xd99(%rip),%rbx
lea    0x18(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x30(%rsp),%rbp
nopl   (%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
mov    %rbp,%rdi
call   10a0 <validate_position@plt>
test   %eax,%eax
je     1280 <main+0xf0>
movslq 0x18(%rsp),%rax
movslq 0x14(%rsp),%rcx
mov    %rax,%rdx
shl    $0x5,%rdx
sub    %rax,%rdx
sub    %rax,%rdx
lea    (%rsp,%rdx,1),%rax
add    $0x30,%rax
movb   $0x50,(%rcx,%rax,1)
lea    0xd47(%rip),%rdi
call   1040 <puts@plt>
lea    0xd17(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0x30(%rsp),%rdi
call   10a0 <validate_position@plt>
test   %eax,%eax
jne    138a <main+0x1fa>
lea    0xd41(%rip),%r14
lea    0xcfd(%rip),%r15
lea    0xcd2(%rip),%rbx
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x30(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbp,%rdi
call   10a0 <validate_position@plt>
test   %eax,%eax
je     1350 <main+0x1c0>
movslq 0x10(%rsp),%rax
movslq 0xc(%rsp),%rcx
mov    %rax,%rdx
shl    $0x5,%rdx
sub    %rax,%rdx
sub    %rax,%rdx
lea    (%rsp,%rdx,1),%rax
add    $0x30,%rax
movb   $0x52,(%rcx,%rax,1)
lea    0xc56(%rip),%rdi
call   1040 <puts@plt>
lea    0xc47(%rip),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
mov    0x20(%rsp),%esi
mov    0x1c(%rsp),%edx
lea    0x30(%rsp),%rdi
call   10a0 <validate_position@plt>
test   %eax,%eax
jne    145a <main+0x2ca>
lea    0xc71(%rip),%r14
lea    0xc0c(%rip),%r15
lea    0xc02(%rip),%rbx
lea    0x20(%rsp),%r12
lea    0x1c(%rsp),%r13
lea    0x30(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    0x20(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    %rbp,%rdi
call   10a0 <validate_position@plt>
test   %eax,%eax
je     1420 <main+0x290>
movslq 0x20(%rsp),%rax
movslq 0x1c(%rsp),%rcx
mov    %rax,%rdx
shl    $0x5,%rdx
sub    %rax,%rdx
sub    %rax,%rdx
lea    (%rsp,%rdx,1),%rax
add    $0x30,%rax
movb   $0x42,(%rcx,%rax,1)
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <target_destiny_blue@plt>
mov    %rbx,%rdi
call   10b0 <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 = [7 x i8] c"%d %d\0A\00"
@__const.main.maze = [23 x [30 x i8]] [[30 x i8] c"000000000000000000000000000000", [30 x i8] c"0 7 0 7 0", [30 x i8] c"0 0000 000000 0 000000 00000 0", [30 x i8] c"0 0000 000000 0 000000 00000 0", [30 x i8] c"07 7 7 7 7 70", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 70 0 07 0", [30 x i8] c"0 0000 000000 0 000000 00000 0", [30 x i8] c"0 0000 0 6 6 0 00000 0", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 0000 7000000000007 00000 0", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 0000 07 70 00000 0", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 7 7 0 7 7 0", [30 x i8] c"0 0000 000000 0 000000 00000 0", [30 x i8] c"07 7 7 6 6 7 70 70", [30 x i8] c"0 0000 0 00000000000 0 0 000 0", [30 x i8] c"07 0 0 0 7 70", [30 x i8] c"0 00000000000 0 000000000000 0", [30 x i8] c"0 7 7 0", [30 x i8] c"000000000000000000000000000000"]
@.str.1 = [30 x i8] c"Insira a posicao do pacman: \0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [22 x i8] c"Posicao invalida!!!\0A\0A\00"
@.str.4 = [33 x i8] c"Insira a posicao do ghost red: \0A\00"
@.str.5 = [34 x i8] c"Insira a posicao do ghost blue: \0A\00"
@pacman = global i32* null
@teste = global i32* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i32]
%7 = alloca i32*
%8 = alloca [23 x [30 x i8]]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
store i32 1, i32* %18
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
store i32 2, i32* %19
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 3
store i32 4, i32* %20
%21 = call i32* @malloc(i32 8)
store i32* %21, i32** %7
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%23 = call i32* @dist(i32* %22)
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = getelementptr inbounds i32, i32* %24, i64 0
%26 = load i32, i32* %25
%27 = load i32*, i32** %7
%28 = getelementptr inbounds i32, i32* %27, i64 1
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %29)
%31 = bitcast [23 x [30 x i8]]* %8 to i8*
%32 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 0
store i32 0, i32* %11
%33 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
store i32 3, i32* %33
%34 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
store i32 3, i32* %34
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
store i32 1, i32* %35
br label %36
36: ; preds = %57, %2
%37 = load i32, i32* %11
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %58
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%43 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 0
%44 = load i32, i32* %9
%45 = load i32, i32* %10
%46 = call i32 @validate_position([30 x i8]* %43, i32 %44, i32 %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %39
store i32 1, i32* %11
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 %50
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [30 x i8], [30 x i8]* %51, i64 0, i64 %53
store i8 80, i8* %54
br label %57
55: ; preds = %39
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %55, %48
br label %36
58: ; preds = %36
store i32 0, i32* %14
br label %59
59: ; preds = %80, %58
%60 = load i32, i32* %14
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %81
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%65 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %13)
%66 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 0
%67 = load i32, i32* %12
%68 = load i32, i32* %13
%69 = call i32 @validate_position([30 x i8]* %66, i32 %67, i32 %68)
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %78
71: ; preds = %62
store i32 1, i32* %14
%72 = load i32, i32* %12
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 %73
%75 = load i32, i32* %13
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [30 x i8], [30 x i8]* %74, i64 0, i64 %76
store i8 82, i8* %77
br label %80
78: ; preds = %62
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %80
80: ; preds = %78, %71
br label %59
81: ; preds = %59
store i32 0, i32* %17
br label %82
82: ; preds = %103, %81
%83 = load i32, i32* %17
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %104
85: ; preds = %82
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%87 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %15)
%88 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%89 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 0
%90 = load i32, i32* %15
%91 = load i32, i32* %16
%92 = call i32 @validate_position([30 x i8]* %89, i32 %90, i32 %91)
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %101
94: ; preds = %85
store i32 1, i32* %17
%95 = load i32, i32* %15
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 %96
%98 = load i32, i32* %16
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [30 x i8], [30 x i8]* %97, i64 0, i64 %99
store i8 66, i8* %100
br label %103
101: ; preds = %85
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %103
103: ; preds = %101, %94
br label %82
104: ; preds = %82
%105 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 0
%106 = load i32, i32* %9
%107 = load i32, i32* %10
%108 = load i32, i32* %12
%109 = load i32, i32* %13
%110 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %8, i64 0, i64 0
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
@__const.main.maze = [23 x [30 x i8]] [[30 x i8] c"000000000000000000000000000000", [30 x i8] c"0 7 0 7 0", [30 x i8] c"0 0000 000000 0 000000 00000 0", [30 x i8] c"0 0000 000000 0 000000 00000 0", [30 x i8] c"07 7 7 7 7 70", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 70 0 07 0", [30 x i8] c"0 0000 000000 0 000000 00000 0", [30 x i8] c"0 0000 0 6 6 0 00000 0", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 0000 7000000000007 00000 0", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 0000 07 70 00000 0", [30 x i8] c"0 0000 0 00000000000 0 00000 0", [30 x i8] c"0 7 7 0 7 7 0", [30 x i8] c"0 0000 000000 0 000000 00000 0", [30 x i8] c"07 7 7 6 6 7 70 70", [30 x i8] c"0 0000 0 00000000000 0 0 000 0", [30 x i8] c"07 0 0 0 7 70", [30 x i8] c"0 00000000000 0 000000000000 0", [30 x i8] c"0 7 7 0", [30 x i8] c"000000000000000000000000000000"]
@.str.2 = [3 x i8] c"%d\00"
@pacman = global i32* null
@teste = global i32* null
@str = [33 x i8] c"Insira a posicao do ghost blue: \00"
@str.7 = [32 x i8] c"Insira a posicao do ghost red: \00"
@str.9 = [29 x i8] c"Insira a posicao do pacman: \00"
@str.10 = [21 x i8] c"Posicao invalida!!!\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i32]
%4 = alloca [23 x [30 x i8]]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast [3 x i32]* %3 to i8*
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
store i32 1, i32* %12
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
store i32 2, i32* %13
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 3
store i32 4, i32* %14
%15 = tail call i32* @malloc(i32 8)
%16 = call i32* @dist(i32* %12)
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %16, i64 1
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19)
%21 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %4, i64 0, i64 0, i64 0
%22 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %4, i64 0, i64 0
%23 = bitcast i32* %5 to i8*
%24 = bitcast i32* %6 to i8*
store i32 3, i32* %12
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
store i32 3, i32* %25
store i32 1, i32* %13
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = call i32 @validate_position([30 x i8]* %22, i32 %29, i32 %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %2, %33
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = call i32 @validate_position([30 x i8]* %22, i32 %38, i32 %39)
%41 = icmp eq i32 %40, 0
br i1 %41, label %33, label %42
42: ; preds = %33, %2
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %4, i64 0, i64 %44, i64 %46
store i8 80, i8* %47
%48 = bitcast i32* %7 to i8*
%49 = bitcast i32* %8 to i8*
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%51 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%52 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%53 = load i32, i32* %7
%54 = load i32, i32* %8
%55 = call i32 @validate_position([30 x i8]* %22, i32 %53, i32 %54)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %66
57: ; preds = %42, %57
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%60 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%62 = load i32, i32* %7
%63 = load i32, i32* %8
%64 = call i32 @validate_position([30 x i8]* %22, i32 %62, i32 %63)
%65 = icmp eq i32 %64, 0
br i1 %65, label %57, label %66
66: ; preds = %57, %42
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %4, i64 0, i64 %68, i64 %70
store i8 82, i8* %71
%72 = bitcast i32* %9 to i8*
%73 = bitcast i32* %10 to i8*
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%75 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%76 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%77 = load i32, i32* %9
%78 = load i32, i32* %10
%79 = call i32 @validate_position([30 x i8]* %22, i32 %77, i32 %78)
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %90
81: ; preds = %66, %81
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%84 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%85 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%86 = load i32, i32* %9
%87 = load i32, i32* %10
%88 = call i32 @validate_position([30 x i8]* %22, i32 %86, i32 %87)
%89 = icmp eq i32 %88, 0
br i1 %89, label %81, label %90
90: ; preds = %81, %66
%91 = load i32, i32* %9
%92 = sext i32 %91 to i64
%93 = load i32, i32* %10
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [23 x [30 x i8]], [23 x [30 x i8]]* %4, i64 0, i64 %92, i64 %94
store i8 66, i8* %95
%96 = load i32, i32* %5
%97 = load i32, i32* %6
%98 = load i32, i32* %7
%99 = load i32, i32* %8
ret i32 0
}