#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ calcula_target(int *, int *, int *);
int /*<<< orphan*/ clear_screen();
int /*<<< orphan*/ dist2(int *);
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*/ verifica_target(char **, int *);
void inky(int pacman[3], int target[2], char maze[23][30]) {
  int red[3];
  do {
    printf("Qual a posição do RED? (x,y)\n");
    printf("x: ");
    scanf("%d", &red[1]);
    printf("y: ");
    scanf("%d", &red[0]);
    clear_screen();
  } while (!validate_position(maze, red[0], red[1]));
  position(maze, red, '4');
  print_maze(maze);
  do {
    printf("Direção do red = 1-Down , 2-Right, 3-Up, 4-Left = ");
    scanf("%d", &red[2]);
  } while (red[2] > 4 || red[2] < 1);
  dist2(pacman);
  calcula_target(red, pacman, target);
  verifica_target(maze, target);
}


x86 assembly (clang, -O0):
<inky>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
lea    -0x24(%rbp),%rsi
add    $0x4,%rsi
lea    0xe59(%rip),%rdi
call   1060 <scanf@plt>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
lea    -0x24(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1070 <clear_screen@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1080 <validate_position@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a4 <inky+0x14>
mov    -0x18(%rbp),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x34,%edx
call   1040 <position@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <print_maze@plt>
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x24(%rbp),%rsi
add    $0x8,%rsi
lea    0xddc(%rip),%rdi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x4,-0x1c(%rbp)
mov    %al,-0x25(%rbp)
jg     1266 <inky+0xd6>
cmpl   $0x1,-0x1c(%rbp)
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    122d <inky+0x9d>
mov    -0x8(%rbp),%rdi
call   1050 <dist2@plt>
lea    -0x24(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1090 <calcula_target@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <verifica_target@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inky>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r13
mov    %rsi,0x20(%rsp)
mov    %rdi,0x18(%rsp)
lea    0xe7e(%rip),%rbx
lea    0xe37(%rip),%rbp
lea    0xe34(%rip),%r14
lea    0xe30(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
lea    0x10(%rsp),%rsi
call   1070 <scanf@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1080 <clear_screen@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %r13,%rdi
call   1090 <validate_position@plt>
test   %eax,%eax
je     11e0 <inky+0x40>
lea    0xc(%rsp),%rsi
mov    %r13,%rdi
mov    $0x34,%edx
call   1050 <position@plt>
mov    %r13,%rdi
call   10c0 <print_maze@plt>
lea    0x14(%rsp),%r14
lea    0xdba(%rip),%rbx
lea    0xdac(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xfffffffb,%eax
cmp    $0xfffffffc,%eax
jb     1260 <inky+0xc0>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <dist2@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    0x20(%rsp),%rbx
mov    %rbx,%rdx
call   10a0 <calcula_target@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   10b0 <verifica_target@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Qual a posi\C3\A7\C3\A3o do RED? (x,y)\0A\00"
@.str.1 = [4 x i8] c"x: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"y: \00"
@.str.4 = [53 x i8] c"Dire\C3\A7\C3\A3o do red = 1-Down , 2-Right, 3-Up, 4-Left = \00"
define void @inky(i32* %0, i32* %1, [30 x i8]* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [30 x i8]*
%7 = alloca [3 x i32]
store i32* %0, i32** %4
store i32* %1, i32** %5
store [30 x i8]* %2, [30 x i8]** %6
br label %8
8: ; preds = %17, %3
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
%16 = call i32 (...) @clear_screen()
br label %17
17: ; preds = %8
%18 = load [30 x i8]*, [30 x i8]** %6
%19 = bitcast [30 x i8]* %18 to i8**
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%21 = load i32, i32* %20
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%23 = load i32, i32* %22
%24 = call i32 @validate_position(i8** %19, i32 %21, i32 %23)
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
br i1 %26, label %8, label %27
27: ; preds = %17
%28 = load [30 x i8]*, [30 x i8]** %6
%29 = bitcast [30 x i8]* %28 to i8**
%30 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%31 = call i32 @position(i8** %29, i32* %30, i8 signext 52)
%32 = load [30 x i8]*, [30 x i8]** %6
%33 = bitcast [30 x i8]* %32 to i8**
%34 = call i32 @print_maze(i8** %33)
br label %35
35: ; preds = %47, %27
%36 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %37)
br label %39
39: ; preds = %35
%40 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%41 = load i32, i32* %40
%42 = icmp sgt i32 %41, 4
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%45 = load i32, i32* %44
%46 = icmp slt i32 %45, 1
br label %47
47: ; preds = %43, %39
%48 = phi i1 [ true, %39 ], [ %46, %43 ]
br i1 %48, label %35, label %49
49: ; preds = %47
%50 = load i32*, i32** %4
%51 = call i32 @dist2(i32* %50)
%52 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%53 = load i32*, i32** %4
%54 = load i32*, i32** %5
%55 = call i32 @calcula_target(i32* %52, i32* %53, i32* %54)
%56 = load [30 x i8]*, [30 x i8]** %6
%57 = bitcast [30 x i8]* %56 to i8**
%58 = load i32*, i32** %5
%59 = call i32 @verifica_target(i8** %57, i32* %58)
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"x: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"y: \00"
@.str.4 = [53 x i8] c"Dire\C3\A7\C3\A3o do red = 1-Down , 2-Right, 3-Up, 4-Left = \00"
@str = [31 x i8] c"Qual a posi\C3\A7\C3\A3o do RED? (x,y)\00"
define void @inky(i32* %0, i32* %1, [30 x i8]* %2) {
%4 = alloca [3 x i32]
%5 = bitcast [3 x i32]* %4 to i8*
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 1
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%8 = bitcast [30 x i8]* %2 to i8**
br label %9
9: ; preds = %9, %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%15 = call i32 (...) @clear_screen()
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = call i32 @validate_position(i8** %8, i32 %16, i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %9, label %20
20: ; preds = %9
%21 = call i32 @position(i8** %8, i32* %7, i8 signext 52)
%22 = call i32 @print_maze(i8** %8)
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 2
br label %24
24: ; preds = %24, %20
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %23)
%27 = load i32, i32* %23
%28 = add i32 %27, -5
%29 = icmp ult i32 %28, -4
br i1 %29, label %24, label %30
30: ; preds = %24
%31 = call i32 @dist2(i32* %0)
%32 = call i32 @calcula_target(i32* %7, i32* %0, i32* %1)
%33 = call i32 @verifica_target(i8** %8, i32* %1)
ret void
}