#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*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printgrid(char **, int, int);
int strlen(char *);
int /*<<< orphan*/ xplor(int, int, char **, int, int);
main() {
  int x = 0, y = 0, maxy = 0, maxx = 0;
  FILE *fp;
  char grid[69][135];
  if (!(fp = fopen("maze", "r")))
    perror("Error opening maze.");
  while (fgets(grid[y], 134, fp)) {
    printf("%lu\n", strlen(grid[y]));
    if (strlen(grid[y]) - 2 > maxx)
      maxx = strlen(grid[y]) - 2;
    y++;
  }
  maxy = --y;
  printf("I've just read in a %d tall by %d wide maze:\n", maxy, maxx);
  printgrid(grid, maxy, maxx);
  printf("So let's start!\n");
  xplor(1, 1, grid, maxy, maxx);
  printgrid(grid, maxy, maxx);
  printf("Welp, see ya.\n");
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2490,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe4b(%rip),%rdi
lea    0xe49(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11db <main+0x5b>
lea    0xe31(%rip),%rdi
call   1090 <perror@plt>
jmp    11e0 <main+0x60>
movslq -0xc(%rbp),%rax
lea    -0x2490(%rbp),%rdi
imul   $0x87,%rax,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rdx
mov    $0x86,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     128b <main+0x10b>
movslq -0xc(%rbp),%rax
lea    -0x2490(%rbp),%rdi
imul   $0x87,%rax,%rax
add    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0xc(%rbp),%rax
lea    -0x2490(%rbp),%rdi
imul   $0x87,%rax,%rax
add    %rax,%rdi
call   1040 <strlen@plt>
sub    $0x2,%eax
cmp    -0x14(%rbp),%eax
jle    127d <main+0xfd>
movslq -0xc(%rbp),%rax
lea    -0x2490(%rbp),%rdi
imul   $0x87,%rax,%rax
add    %rax,%rdi
call   1040 <strlen@plt>
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e0 <main+0x60>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x2490(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <printgrid@plt>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x2490(%rbp),%rdx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    $0x1,%esi
mov    %esi,%edi
call   10a0 <xplor@plt>
lea    -0x2490(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <printgrid@plt>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x2490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2470,%rsp
lea    0xe5a(%rip),%rdi
lea    0xe58(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     12c0 <main+0x130>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x86,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1244 <main+0xb4>
lea    0xe39(%rip),%r12
xor    %r15d,%r15d
jmp    120f <main+0x7f>
nopw   0x0(%rax,%rax,1)
add    $0x87,%rbx
mov    %rbx,%rdi
mov    $0x86,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     1247 <main+0xb7>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
add    $0xfffffffe,%eax
cmp    %r15d,%eax
jle    11f0 <main+0x60>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
add    $0xfffffffe,%r15d
jmp    11f0 <main+0x60>
xor    %r15d,%r15d
lea    0xdd2(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1080 <printgrid@plt>
lea    0xddd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %r15d,%r8d
call   10b0 <xplor@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1080 <printgrid@plt>
lea    0xdbd(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x2470,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd40(%rip),%rdi
call   10a0 <perror@plt>
jmp    11be <main+0x2e>

LLVM IR (-O0):
@.str = [5 x i8] c"maze\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Error opening maze.\00"
@.str.3 = [5 x i8] c"%lu\0A\00"
@.str.4 = [46 x i8] c"I've just read in a %d tall by %d wide maze:\0A\00"
@.str.5 = [17 x i8] c"So let's start!\0A\00"
@.str.6 = [15 x i8] c"Welp, see ya.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca [69 x [135 x i8]]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %6
%9 = icmp ne i32* %8, null
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
br label %13
13: ; preds = %43, %12
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %7, i64 0, i64 %15
%17 = getelementptr inbounds [135 x i8], [135 x i8]* %16, i64 0, i64 0
%18 = load i32*, i32** %6
%19 = call i64 @fgets(i8* %17, i32 134, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %46
21: ; preds = %13
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %7, i64 0, i64 %23
%25 = getelementptr inbounds [135 x i8], [135 x i8]* %24, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %7, i64 0, i64 %29
%31 = getelementptr inbounds [135 x i8], [135 x i8]* %30, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 2
%34 = load i32, i32* %5
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %21
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %7, i64 0, i64 %38
%40 = getelementptr inbounds [135 x i8], [135 x i8]* %39, i64 0, i64 0
%41 = call i32 @strlen(i8* %40)
%42 = sub nsw i32 %41, 2
store i32 %42, i32* %5
br label %43
43: ; preds = %36, %21
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %13
46: ; preds = %13
%47 = load i32, i32* %3
%48 = add nsw i32 %47, -1
store i32 %48, i32* %3
store i32 %48, i32* %4
%49 = load i32, i32* %4
%50 = load i32, i32* %5
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %49, i32 %50)
%52 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %7, i64 0, i64 0
%53 = bitcast [135 x i8]* %52 to i8**
%54 = load i32, i32* %4
%55 = load i32, i32* %5
%56 = call i32 @printgrid(i8** %53, i32 %54, i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%58 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %7, i64 0, i64 0
%59 = bitcast [135 x i8]* %58 to i8**
%60 = load i32, i32* %4
%61 = load i32, i32* %5
%62 = call i32 @xplor(i32 1, i32 1, i8** %59, i32 %60, i32 %61)
%63 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %7, i64 0, i64 0
%64 = bitcast [135 x i8]* %63 to i8**
%65 = load i32, i32* %4
%66 = load i32, i32* %5
%67 = call i32 @printgrid(i8** %64, i32 %65, i32 %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%69 = load i32*, i32** %6
%70 = call i32 @fclose(i32* %69)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"maze\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Error opening maze.\00"
@.str.3 = [5 x i8] c"%lu\0A\00"
@.str.4 = [46 x i8] c"I've just read in a %d tall by %d wide maze:\0A\00"
@str = [16 x i8] c"So let's start!\00"
@str.7 = [14 x i8] c"Welp, see ya.\00"
define i32 @main() {
%1 = alloca [69 x [135 x i8]]
%2 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %1, i64 0, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = call i64 @fgets(i8* %2, i32 134, i32* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %31, label %10
10: ; preds = %7, %22
%11 = phi i64 [ %24, %22 ], [ 0, %7 ]
%12 = phi i8* [ %25, %22 ], [ %2, %7 ]
%13 = phi i32 [ %23, %22 ], [ 0, %7 ]
%14 = call i32 @strlen(i8* %12)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = call i32 @strlen(i8* %12)
%17 = add nsw i32 %16, -2
%18 = icmp sgt i32 %17, %13
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = call i32 @strlen(i8* %12)
%21 = add nsw i32 %20, -2
br label %22
22: ; preds = %19, %10
%23 = phi i32 [ %21, %19 ], [ %13, %10 ]
%24 = add nuw i64 %11, 1
%25 = getelementptr inbounds [69 x [135 x i8]], [69 x [135 x i8]]* %1, i64 0, i64 %24, i64 0
%26 = call i64 @fgets(i8* %25, i32 134, i32* %3)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %10
28: ; preds = %22
%29 = trunc i64 %24 to i32
%30 = add i32 %29, -1
br label %31
31: ; preds = %28, %7
%32 = phi i32 [ 0, %7 ], [ %23, %28 ]
%33 = phi i32 [ -1, %7 ], [ %30, %28 ]
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %33, i32 %32)
%35 = bitcast [69 x [135 x i8]]* %1 to i8**
%36 = call i32 @printgrid(i8** %35, i32 %33, i32 %32)
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%38 = call i32 @xplor(i32 1, i32 1, i8** %35, i32 %33, i32 %32)
%39 = call i32 @printgrid(i8** %35, i32 %33, i32 %32)
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
%41 = call i32 @fclose(i32* %3)
ret i32 0
}