#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ route(char **);
int main() {
  int i, j;
  char maze[6][6];
  FILE *fd = fopen("maze_stack.txt", "r");
  for (i = 0; i < 6; i++)
    for (j = 0; j < 6; j++)
      fscanf(fd, "%c", &maze[i][j]);
  route(maze);
  fclose(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    11cf <main+0x8f>
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    11bc <main+0x7c>
mov    -0x38(%rbp),%rdi
movslq -0x8(%rbp),%rax
lea    -0x30(%rbp),%rdx
imul   $0x6,%rax,%rax
add    %rax,%rdx
movslq -0xc(%rbp),%rax
add    %rax,%rdx
lea    0xe68(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117e <main+0x3e>
jmp    11c1 <main+0x81>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x2d>
lea    -0x30(%rbp),%rdi
call   1050 <route@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xeb0(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
xor    %ebx,%ebx
lea    0xea9(%rip),%r14
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <fscanf@plt>
lea    (%rsp,%rbx,1),%rdx
add    $0x1,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <fscanf@plt>
lea    (%rsp,%rbx,1),%rdx
add    $0x2,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <fscanf@plt>
lea    (%rsp,%rbx,1),%rdx
add    $0x3,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <fscanf@plt>
lea    (%rsp,%rbx,1),%rdx
add    $0x4,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <fscanf@plt>
lea    (%rsp,%rbx,1),%rdx
add    $0x5,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <fscanf@plt>
add    $0x6,%rbx
cmp    $0x24,%rbx
jne    1170 <main+0x30>
mov    %rsp,%rdi
call   1050 <route@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"maze_stack.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x [6 x i8]]
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
store i32 0, i32* %2
br label %7
7: ; preds = %27, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %30
10: ; preds = %7
store i32 0, i32* %3
br label %11
11: ; preds = %23, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load i32*, i32** %5
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %4, i64 0, i64 %17
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %18, i64 0, i64 %20
%22 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %14
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %11
26: ; preds = %11
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %7
30: ; preds = %7
%31 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %4, i64 0, i64 0
%32 = bitcast [6 x i8]* %31 to i8**
%33 = call i32 @route(i8** %32)
%34 = load i32*, i32** %5
%35 = call i32 @fclose(i32* %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"maze_stack.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [6 x [6 x i8]]
%2 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %1, i64 0, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %18, %4 ]
%6 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %1, i64 0, i64 %5, i64 0
%7 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %1, i64 0, i64 %5, i64 1
%9 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %1, i64 0, i64 %5, i64 2
%11 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %1, i64 0, i64 %5, i64 3
%13 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %1, i64 0, i64 %5, i64 4
%15 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %1, i64 0, i64 %5, i64 5
%17 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = add nuw nsw i64 %5, 1
%19 = icmp eq i64 %18, 6
br i1 %19, label %20, label %4
20: ; preds = %4
%21 = bitcast [6 x [6 x i8]]* %1 to i8**
%22 = call i32 @route(i8** %21)
%23 = call i32 @fclose(i32* %3)
ret i32 0
}