#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ maze_print(char **);
int /*<<< orphan*/ maze_solve(char **);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  FILE *input = NULL;
  char maze[41][81];
  char *line = NULL;
  size_t line_len = 0;
  ssize_t read_chars = 0;
  int line_num = 0, chars_check = 0, r = 0, c = 0;
  if (argc != 2) {
    fprintf(stderr, "Invalid number of arguments.\n");
    return 1;
  }
  input = fopen(argv[1], "r");
  if (!input) {
    fprintf(stderr, "Could not open maze file for reading.\n");
    return 2;
  }
  while ((read_chars = getline(&line, &line_len, input)) != -1) {
    if (read_chars != 81 + 1) {
      fprintf(stderr, "Invalid maze file, invalid data.\n");
      goto missing_data;
    }
    chars_check = 0;
    while (chars_check < read_chars - 1) {
      if (line[chars_check] != '#' && line[chars_check] != ' ') {
        fprintf(stderr, "Invalid character found, invalid data.\n");
        goto invalid_data_found;
      }
      chars_check++;
    }
    strncpy(maze[line_num], line, 81);
    line_num++;
  }
  free(line);
  fclose(input);
  if (line_num != 41) {
    fprintf(stderr, "Maze too small or too large, invalid data.\n");
    return 3;
  }
  if (maze[0][1] != ' ' || maze[40][79] != ' ') {
    fprintf(stderr, "No entrance or exit point.\n");
    return 4;
  }
  r = 0;
  c = 2;
  while (c < 81) {
    if (maze[r][c] != '#') {
      fprintf(stderr, "There is an opening in the outside wall.\n");
      return 3;
    }
    c++;
  }
  r = 41 - 1;
  c = 0;
  while (c < 81 - 2) {
    if (maze[r][c] != '#') {
      fprintf(stderr, "There is an opening in the outside wall.\n");
      return 3;
    }
    c++;
  }
  r = 0;
  c = 81 - 1;
  while (r < 41) {
    if (maze[r][c] != '#') {
      fprintf(stderr, "There is an opening in the outside wall.\n");
      return 3;
    }
    r++;
  }
  r = 0;
  c = 0;
  while (r < 41) {
    if (maze[r][c] != '#') {
      fprintf(stderr, "There is an opening in the outside wall.\n");
      return 3;
    }
    r++;
  }
  if (!(maze_solve(maze))) {
    fprintf(stderr, "Cannot solve maze.\n");
    return 5;
  }
  maze_print(maze);
  return 0;
invalid_data_found:
  free(line);
  fclose(input);
  return 3;
missing_data:
  free(line);
  fclose(input);
  return 6;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0xd28(%rbp)
movq   $0x0,-0xd30(%rbp)
movl   $0x0,-0xd34(%rbp)
movl   $0x0,-0xd38(%rbp)
movl   $0x0,-0xd3c(%rbp)
movl   $0x0,-0xd40(%rbp)
movl   $0x0,-0xd44(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1214 <main+0x94>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1671 <main+0x4f1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfb(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1258 <main+0xd8>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1671 <main+0x4f1>
jmp    125d <main+0xdd>
mov    -0x18(%rbp),%rdx
lea    -0xd28(%rbp),%rdi
lea    -0xd30(%rbp),%rsi
call   10a0 <getline@plt>
mov    %eax,-0xd34(%rbp)
cmp    $0xffffffff,%eax
je     1369 <main+0x1e9>
cmpl   $0x52,-0xd34(%rbp)
je     12aa <main+0x12a>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
lea    0xda7(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1655 <main+0x4d5>
movl   $0x0,-0xd3c(%rbp)
mov    -0xd3c(%rbp),%eax
mov    -0xd34(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    132f <main+0x1af>
mov    -0xd28(%rbp),%rax
movslq -0xd3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
je     131b <main+0x19b>
mov    -0xd28(%rbp),%rax
movslq -0xd3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     131b <main+0x19b>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
lea    0xd58(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1634 <main+0x4b4>
mov    -0xd3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd3c(%rbp)
jmp    12b4 <main+0x134>
movslq -0xd38(%rbp),%rax
lea    -0xd20(%rbp),%rdi
imul   $0x51,%rax,%rax
add    %rax,%rdi
mov    -0xd28(%rbp),%rsi
mov    $0x51,%edx
call   1050 <strncpy@plt>
mov    -0xd38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd38(%rbp)
jmp    125d <main+0xdd>
mov    -0xd28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
cmpl   $0x29,-0xd38(%rbp)
je     13ac <main+0x22c>
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
lea    0xcf6(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1671 <main+0x4f1>
movsbl -0xd1f(%rbp),%eax
cmp    $0x20,%eax
jne    13c9 <main+0x249>
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
je     13ea <main+0x26a>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
lea    0xce4(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x4,-0x4(%rbp)
jmp    1671 <main+0x4f1>
movl   $0x0,-0xd40(%rbp)
movl   $0x2,-0xd44(%rbp)
cmpl   $0x51,-0xd44(%rbp)
jge    1469 <main+0x2e9>
movslq -0xd40(%rbp),%rcx
lea    -0xd20(%rbp),%rax
imul   $0x51,%rcx,%rcx
add    %rcx,%rax
movslq -0xd44(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
je     1455 <main+0x2d5>
mov    0x2ba5(%rip),%rax
mov    (%rax),%edi
lea    0xc95(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1671 <main+0x4f1>
mov    -0xd44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd44(%rbp)
jmp    13fe <main+0x27e>
movl   $0x28,-0xd40(%rbp)
movl   $0x0,-0xd44(%rbp)
cmpl   $0x4f,-0xd44(%rbp)
jge    14e8 <main+0x368>
movslq -0xd40(%rbp),%rcx
lea    -0xd20(%rbp),%rax
imul   $0x51,%rcx,%rcx
add    %rcx,%rax
movslq -0xd44(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
je     14d4 <main+0x354>
mov    0x2b26(%rip),%rax
mov    (%rax),%edi
lea    0xc16(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1671 <main+0x4f1>
mov    -0xd44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd44(%rbp)
jmp    147d <main+0x2fd>
movl   $0x0,-0xd40(%rbp)
movl   $0x50,-0xd44(%rbp)
cmpl   $0x29,-0xd40(%rbp)
jge    1567 <main+0x3e7>
movslq -0xd40(%rbp),%rcx
lea    -0xd20(%rbp),%rax
imul   $0x51,%rcx,%rcx
add    %rcx,%rax
movslq -0xd44(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
je     1553 <main+0x3d3>
mov    0x2aa7(%rip),%rax
mov    (%rax),%edi
lea    0xb97(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1671 <main+0x4f1>
mov    -0xd40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd40(%rbp)
jmp    14fc <main+0x37c>
movl   $0x0,-0xd40(%rbp)
movl   $0x0,-0xd44(%rbp)
cmpl   $0x29,-0xd40(%rbp)
jge    15e6 <main+0x466>
movslq -0xd40(%rbp),%rcx
lea    -0xd20(%rbp),%rax
imul   $0x51,%rcx,%rcx
add    %rcx,%rax
movslq -0xd44(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
je     15d2 <main+0x452>
mov    0x2a28(%rip),%rax
mov    (%rax),%edi
lea    0xb18(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1671 <main+0x4f1>
mov    -0xd40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd40(%rbp)
jmp    157b <main+0x3fb>
lea    -0xd20(%rbp),%rdi
call   1070 <maze_solve@plt>
cmp    $0x0,%eax
jne    161c <main+0x49c>
mov    0x29de(%rip),%rax
mov    (%rax),%edi
lea    0xaf8(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x5,-0x4(%rbp)
jmp    1671 <main+0x4f1>
lea    -0xd20(%rbp),%rdi
call   1030 <maze_print@plt>
movl   $0x0,-0x4(%rbp)
jmp    1671 <main+0x4f1>
mov    -0xd28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x3,-0x4(%rbp)
jmp    1671 <main+0x4f1>
mov    -0xd28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x6,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd18,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    125b <main+0xdb>
mov    0x8(%rsi),%rdi
lea    0xe6b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12a4 <main+0x124>
mov    %rax,%rbx
xor    %r12d,%r12d
mov    %rsp,%r14
lea    0x8(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   10a0 <getline@plt>
cmp    $0x52,%eax
jne    12cd <main+0x14d>
mov    $0x2,%eax
mov    (%rsp),%rsi
jmp    120a <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x3,%rax
cmp    $0x53,%rax
je     1238 <main+0xb8>
movzbl -0x2(%rsi,%rax,1),%ecx
cmp    $0x20,%cl
je     1219 <main+0x99>
cmp    $0x23,%cl
jne    1277 <main+0xf7>
movzbl -0x1(%rsi,%rax,1),%ecx
cmp    $0x23,%cl
je     1228 <main+0xa8>
cmp    $0x20,%cl
jne    1277 <main+0xf7>
movzbl (%rsi,%rax,1),%ecx
cmp    $0x23,%cl
je     1200 <main+0x80>
cmp    $0x20,%cl
je     1200 <main+0x80>
jmp    1277 <main+0xf7>
lea    (%r12,%r12,8),%rax
lea    (%rax,%rax,8),%rax
lea    (%rsp,%rax,1),%rdi
add    $0x10,%rdi
mov    $0x51,%edx
call   1050 <strncpy@plt>
add    $0x1,%r12
jmp    11cf <main+0x4f>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xd95(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    12be <main+0x13e>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
call   1080 <fprintf@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    $0x3,%eax
jmp    12be <main+0x13e>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xd6c(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x2,%eax
add    $0xd18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
cmp    $0xffffffff,%eax
jne    134e <main+0x1ce>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
cmp    $0x29,%r12d
jne    137e <main+0x1fe>
cmpb   $0x20,0x11(%rsp)
jne    139d <main+0x21d>
cmpb   $0x20,0xd07(%rsp)
20
jne    139d <main+0x21d>
mov    $0x5,%eax
cmpb   $0x23,0xd(%rsp,%rax,1)
jne    133c <main+0x1bc>
cmpb   $0x23,0xe(%rsp,%rax,1)
jne    133c <main+0x1bc>
cmpb   $0x23,0xf(%rsp,%rax,1)
jne    133c <main+0x1bc>
cmp    $0x51,%rax
je     13bc <main+0x23c>
cmpb   $0x23,0x10(%rsp,%rax,1)
jne    133c <main+0x1bc>
add    $0x4,%rax
cmpb   $0x23,0xd(%rsp,%rax,1)
je     1312 <main+0x192>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
lea    0xd8d(%rip),%rsi
jmp    138e <main+0x20e>
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
lea    0xce9(%rip),%rsi
call   1080 <fprintf@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    $0x6,%eax
jmp    12be <main+0x13e>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
lea    0xd03(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x3,%eax
jmp    12be <main+0x13e>
mov    0x2c3c(%rip),%rax
mov    (%rax),%edi
lea    0xd10(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x4,%eax
jmp    12be <main+0x13e>
xor    %eax,%eax
cmpb   $0x23,0xcb8(%rsp,%rax,1)
23
jne    133c <main+0x1bc>
cmpb   $0x23,0xcb9(%rsp,%rax,1)
23
jne    133c <main+0x1bc>
cmpb   $0x23,0xcba(%rsp,%rax,1)
23
jne    133c <main+0x1bc>
cmp    $0x4c,%rax
je     1402 <main+0x282>
cmpb   $0x23,0xcbb(%rsp,%rax,1)
23
jne    133c <main+0x1bc>
add    $0x4,%rax
jmp    13be <main+0x23e>
mov    $0x143,%eax
cmpb   $0x23,-0xe3(%rsp,%rax,1)
23
jne    133c <main+0x1bc>
cmp    $0xdeb,%rax
je     1449 <main+0x2c9>
cmpb   $0x23,-0x92(%rsp,%rax,1)
23
jne    133c <main+0x1bc>
cmpb   $0x23,-0x41(%rsp,%rax,1)
jne    133c <main+0x1bc>
cmpb   $0x23,0x10(%rsp,%rax,1)
jne    133c <main+0x1bc>
add    $0x144,%rax
jmp    1407 <main+0x287>
xor    %eax,%eax
cmpb   $0x23,0x10(%rsp,%rax,1)
jne    133c <main+0x1bc>
cmp    $0xca8,%rax
je     148d <main+0x30d>
cmpb   $0x23,0x61(%rsp,%rax,1)
jne    133c <main+0x1bc>
cmpb   $0x23,0xb2(%rsp,%rax,1)
23
jne    133c <main+0x1bc>
cmpb   $0x23,0x103(%rsp,%rax,1)
23
jne    133c <main+0x1bc>
add    $0x144,%rax
jmp    144b <main+0x2cb>
lea    0x10(%rsp),%rdi
call   1070 <maze_solve@plt>
test   %eax,%eax
je     14ac <main+0x32c>
lea    0x10(%rsp),%rdi
call   1030 <maze_print@plt>
xor    %eax,%eax
jmp    12be <main+0x13e>
mov    0x2b2d(%rip),%rax
mov    (%rax),%edi
lea    0xc47(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x5,%eax
jmp    12be <main+0x13e>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Invalid number of arguments.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [39 x i8] c"Could not open maze file for reading.\0A\00"
@.str.3 = [34 x i8] c"Invalid maze file, invalid data.\0A\00"
@.str.4 = [40 x i8] c"Invalid character found, invalid data.\0A\00"
@.str.5 = [44 x i8] c"Maze too small or too large, invalid data.\0A\00"
@.str.6 = [28 x i8] c"No entrance or exit point.\0A\00"
@.str.7 = [42 x i8] c"There is an opening in the outside wall.\0A\00"
@.str.8 = [20 x i8] c"Cannot solve maze.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [41 x [81 x i8]]
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i8* null, i8** %8
store i64 0, i64* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %205
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp ne i32* %25, null
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %205
30: ; preds = %20
br label %31
31: ; preds = %69, %30
%32 = load i32*, i32** %6
%33 = call i32 @getline(i8** %8, i64* %9, i32* %32)
store i32 %33, i32* %10
%34 = icmp ne i32 %33, -1
br i1 %34, label %35, label %78
35: ; preds = %31
%36 = load i32, i32* %10
%37 = icmp ne i32 %36, 82
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %200
41: ; preds = %35
store i32 0, i32* %12
br label %42
42: ; preds = %66, %41
%43 = load i32, i32* %12
%44 = load i32, i32* %10
%45 = sub nsw i32 %44, 1
%46 = icmp slt i32 %43, %45
br i1 %46, label %47, label %69
47: ; preds = %42
%48 = load i8*, i8** %8
%49 = load i32, i32* %12
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 35
br i1 %54, label %55, label %66
55: ; preds = %47
%56 = load i8*, i8** %8
%57 = load i32, i32* %12
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 32
br i1 %62, label %63, label %66
63: ; preds = %55
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %195
66: ; preds = %55, %47
%67 = load i32, i32* %12
%68 = add nsw i32 %67, 1
store i32 %68, i32* %12
br label %42
69: ; preds = %42
%70 = load i32, i32* %11
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 %71
%73 = getelementptr inbounds [81 x i8], [81 x i8]* %72, i64 0, i64 0
%74 = load i8*, i8** %8
%75 = call i32 @strncpy(i8* %73, i8* %74, i32 81)
%76 = load i32, i32* %11
%77 = add nsw i32 %76, 1
store i32 %77, i32* %11
br label %31
78: ; preds = %31
%79 = load i8*, i8** %8
%80 = call i32 @free(i8* %79)
%81 = load i32*, i32** %6
%82 = call i32 @fclose(i32* %81)
%83 = load i32, i32* %11
%84 = icmp ne i32 %83, 41
br i1 %84, label %85, label %88
85: ; preds = %78
%86 = load i32, i32* @stderr
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
store i32 3, i32* %3
br label %205
88: ; preds = %78
%89 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 0
%90 = getelementptr inbounds [81 x i8], [81 x i8]* %89, i64 0, i64 1
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp ne i32 %92, 32
br i1 %93, label %100, label %94
94: ; preds = %88
%95 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 40
%96 = getelementptr inbounds [81 x i8], [81 x i8]* %95, i64 0, i64 79
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp ne i32 %98, 32
br i1 %99, label %100, label %103
100: ; preds = %94, %88
%101 = load i32, i32* @stderr
%102 = call i32 @fprintf(i32 %101, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
store i32 4, i32* %3
br label %205
103: ; preds = %94
store i32 0, i32* %13
store i32 2, i32* %14
br label %104
104: ; preds = %120, %103
%105 = load i32, i32* %14
%106 = icmp slt i32 %105, 81
br i1 %106, label %107, label %123
107: ; preds = %104
%108 = load i32, i32* %13
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 %109
%111 = load i32, i32* %14
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [81 x i8], [81 x i8]* %110, i64 0, i64 %112
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = icmp ne i32 %115, 35
br i1 %116, label %117, label %120
117: ; preds = %107
%118 = load i32, i32* @stderr
%119 = call i32 @fprintf(i32 %118, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
store i32 3, i32* %3
br label %205
120: ; preds = %107
%121 = load i32, i32* %14
%122 = add nsw i32 %121, 1
store i32 %122, i32* %14
br label %104
123: ; preds = %104
store i32 40, i32* %13
store i32 0, i32* %14
br label %124
124: ; preds = %140, %123
%125 = load i32, i32* %14
%126 = icmp slt i32 %125, 79
br i1 %126, label %127, label %143
127: ; preds = %124
%128 = load i32, i32* %13
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 %129
%131 = load i32, i32* %14
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [81 x i8], [81 x i8]* %130, i64 0, i64 %132
%134 = load i8, i8* %133
%135 = sext i8 %134 to i32
%136 = icmp ne i32 %135, 35
br i1 %136, label %137, label %140
137: ; preds = %127
%138 = load i32, i32* @stderr
%139 = call i32 @fprintf(i32 %138, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
store i32 3, i32* %3
br label %205
140: ; preds = %127
%141 = load i32, i32* %14
%142 = add nsw i32 %141, 1
store i32 %142, i32* %14
br label %124
143: ; preds = %124
store i32 0, i32* %13
store i32 80, i32* %14
br label %144
144: ; preds = %160, %143
%145 = load i32, i32* %13
%146 = icmp slt i32 %145, 41
br i1 %146, label %147, label %163
147: ; preds = %144
%148 = load i32, i32* %13
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 %149
%151 = load i32, i32* %14
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds [81 x i8], [81 x i8]* %150, i64 0, i64 %152
%154 = load i8, i8* %153
%155 = sext i8 %154 to i32
%156 = icmp ne i32 %155, 35
br i1 %156, label %157, label %160
157: ; preds = %147
%158 = load i32, i32* @stderr
%159 = call i32 @fprintf(i32 %158, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
store i32 3, i32* %3
br label %205
160: ; preds = %147
%161 = load i32, i32* %13
%162 = add nsw i32 %161, 1
store i32 %162, i32* %13
br label %144
163: ; preds = %144
store i32 0, i32* %13
store i32 0, i32* %14
br label %164
164: ; preds = %180, %163
%165 = load i32, i32* %13
%166 = icmp slt i32 %165, 41
br i1 %166, label %167, label %183
167: ; preds = %164
%168 = load i32, i32* %13
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 %169
%171 = load i32, i32* %14
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [81 x i8], [81 x i8]* %170, i64 0, i64 %172
%174 = load i8, i8* %173
%175 = sext i8 %174 to i32
%176 = icmp ne i32 %175, 35
br i1 %176, label %177, label %180
177: ; preds = %167
%178 = load i32, i32* @stderr
%179 = call i32 @fprintf(i32 %178, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
store i32 3, i32* %3
br label %205
180: ; preds = %167
%181 = load i32, i32* %13
%182 = add nsw i32 %181, 1
store i32 %182, i32* %13
br label %164
183: ; preds = %164
%184 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 0
%185 = bitcast [81 x i8]* %184 to i8**
%186 = call i32 @maze_solve(i8** %185)
%187 = icmp ne i32 %186, 0
br i1 %187, label %191, label %188
188: ; preds = %183
%189 = load i32, i32* @stderr
%190 = call i32 @fprintf(i32 %189, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
store i32 5, i32* %3
br label %205
191: ; preds = %183
%192 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %7, i64 0, i64 0
%193 = bitcast [81 x i8]* %192 to i8**
%194 = call i32 @maze_print(i8** %193)
store i32 0, i32* %3
br label %205
195: ; preds = %63
%196 = load i8*, i8** %8
%197 = call i32 @free(i8* %196)
%198 = load i32*, i32** %6
%199 = call i32 @fclose(i32* %198)
store i32 3, i32* %3
br label %205
200: ; preds = %38
%201 = load i8*, i8** %8
%202 = call i32 @free(i8* %201)
%203 = load i32*, i32** %6
%204 = call i32 @fclose(i32* %203)
store i32 6, i32* %3
br label %205
205: ; preds = %200, %195, %191, %188, %177, %157, %137, %117, %100, %85, %27, %17
%206 = load i32, i32* %3
ret i32 %206
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Invalid number of arguments.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [39 x i8] c"Could not open maze file for reading.\0A\00"
@.str.3 = [34 x i8] c"Invalid maze file, invalid data.\0A\00"
@.str.4 = [40 x i8] c"Invalid character found, invalid data.\0A\00"
@.str.5 = [44 x i8] c"Maze too small or too large, invalid data.\0A\00"
@.str.6 = [28 x i8] c"No entrance or exit point.\0A\00"
@.str.7 = [42 x i8] c"There is an opening in the outside wall.\0A\00"
@.str.8 = [20 x i8] c"Cannot solve maze.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [41 x [81 x i8]]
%4 = alloca i8*
%5 = alloca i64
%6 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 0, i64 0
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%9 = icmp eq i32 %0, 2
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %194
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %194
21: ; preds = %13, %53
%22 = phi i64 [ %56, %53 ], [ 0, %13 ]
%23 = call i32 @getline(i8** %4, i64* %5, i32* %16)
switch i32 %23, label %26 [
i32 -1, label %57
i32 82, label %24
]
24: ; preds = %21
%25 = load i8*, i8** %4
br label %32
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8*, i8** %4
%30 = call i32 @free(i8* %29)
%31 = call i32 @fclose(i32* %16)
br label %194
32: ; preds = %50, %24
%33 = phi i64 [ 0, %24 ], [ %51, %50 ]
%34 = getelementptr inbounds i8, i8* %25, i64 %33
%35 = load i8, i8* %34
switch i8 %35, label %36 [
i8 35, label %42
i8 32, label %42
]
36: ; preds = %46, %42, %32
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%39 = load i8*, i8** %4
%40 = call i32 @free(i8* %39)
%41 = call i32 @fclose(i32* %16)
br label %194
42: ; preds = %32, %32
%43 = add nuw nsw i64 %33, 1
%44 = getelementptr inbounds i8, i8* %25, i64 %43
%45 = load i8, i8* %44
switch i8 %45, label %36 [
i8 35, label %46
i8 32, label %46
]
46: ; preds = %42, %42
%47 = add nuw nsw i64 %33, 2
%48 = getelementptr inbounds i8, i8* %25, i64 %47
%49 = load i8, i8* %48
switch i8 %49, label %36 [
i8 35, label %50
i8 32, label %50
]
50: ; preds = %46, %46
%51 = add nuw nsw i64 %33, 3
%52 = icmp eq i64 %51, 81
br i1 %52, label %53, label %32
53: ; preds = %50
%54 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %22, i64 0
%55 = call i32 @strncpy(i8* %54, i8* %25, i32 81)
%56 = add nuw i64 %22, 1
br label %21
57: ; preds = %21
%58 = trunc i64 %22 to i32
%59 = load i8*, i8** %4
%60 = call i32 @free(i8* %59)
%61 = call i32 @fclose(i32* %16)
%62 = icmp eq i32 %58, 41
br i1 %62, label %66, label %63
63: ; preds = %57
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
br label %194
66: ; preds = %57
%67 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 0, i64 1
%68 = load i8, i8* %67
%69 = icmp ne i8 %68, 32
%70 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 40, i64 79
%71 = load i8, i8* %70
%72 = icmp ne i8 %71, 32
%73 = select i1 %69, i1 true, i1 %72
br i1 %73, label %74, label %96
74: ; preds = %66
%75 = load i32, i32* @stderr
%76 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %194
77: ; preds = %96
%78 = or i64 %97, 1
%79 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 0, i64 %78
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 35
br i1 %81, label %82, label %101
82: ; preds = %77
%83 = add nuw nsw i64 %97, 2
%84 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = icmp eq i8 %85, 35
br i1 %86, label %87, label %101
87: ; preds = %82
%88 = add nuw nsw i64 %97, 3
%89 = icmp eq i64 %88, 81
br i1 %89, label %123, label %90
90: ; preds = %87
%91 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 0, i64 %88
%92 = load i8, i8* %91
%93 = icmp eq i8 %92, 35
br i1 %93, label %94, label %101
94: ; preds = %90
%95 = add nuw nsw i64 %97, 4
br label %96
96: ; preds = %66, %94
%97 = phi i64 [ %95, %94 ], [ 2, %66 ]
%98 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 0, i64 %97
%99 = load i8, i8* %98
%100 = icmp eq i8 %99, 35
br i1 %100, label %77, label %101
101: ; preds = %90, %82, %77, %96
%102 = load i32, i32* @stderr
%103 = call i32 @fprintf(i32 %102, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
br label %194
104: ; preds = %123
%105 = or i64 %124, 1
%106 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 40, i64 %105
%107 = load i8, i8* %106
%108 = icmp eq i8 %107, 35
br i1 %108, label %109, label %128
109: ; preds = %104
%110 = or i64 %124, 2
%111 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 40, i64 %110
%112 = load i8, i8* %111
%113 = icmp eq i8 %112, 35
br i1 %113, label %114, label %128
114: ; preds = %109
%115 = or i64 %124, 3
%116 = icmp eq i64 %115, 79
br i1 %116, label %150, label %117
117: ; preds = %114
%118 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 40, i64 %115
%119 = load i8, i8* %118
%120 = icmp eq i8 %119, 35
br i1 %120, label %121, label %128
121: ; preds = %117
%122 = add nuw nsw i64 %124, 4
br label %123
123: ; preds = %87, %121
%124 = phi i64 [ %122, %121 ], [ 0, %87 ]
%125 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 40, i64 %124
%126 = load i8, i8* %125
%127 = icmp eq i8 %126, 35
br i1 %127, label %104, label %128
128: ; preds = %117, %109, %104, %123
%129 = load i32, i32* @stderr
%130 = call i32 @fprintf(i32 %129, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
br label %194
131: ; preds = %150
%132 = or i64 %151, 1
%133 = icmp eq i64 %132, 41
br i1 %133, label %177, label %134
134: ; preds = %131
%135 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %132, i64 80
%136 = load i8, i8* %135
%137 = icmp eq i8 %136, 35
br i1 %137, label %138, label %155
138: ; preds = %134
%139 = or i64 %151, 2
%140 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %139, i64 80
%141 = load i8, i8* %140
%142 = icmp eq i8 %141, 35
br i1 %142, label %143, label %155
143: ; preds = %138
%144 = or i64 %151, 3
%145 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %144, i64 80
%146 = load i8, i8* %145
%147 = icmp eq i8 %146, 35
br i1 %147, label %148, label %155
148: ; preds = %143
%149 = add nuw nsw i64 %151, 4
br label %150
150: ; preds = %114, %148
%151 = phi i64 [ %149, %148 ], [ 0, %114 ]
%152 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %151, i64 80
%153 = load i8, i8* %152
%154 = icmp eq i8 %153, 35
br i1 %154, label %131, label %155
155: ; preds = %143, %138, %134, %150
%156 = load i32, i32* @stderr
%157 = call i32 @fprintf(i32 %156, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
br label %194
158: ; preds = %177
%159 = or i64 %178, 1
%160 = icmp eq i64 %159, 41
br i1 %160, label %185, label %161
161: ; preds = %158
%162 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %159, i64 0
%163 = load i8, i8* %162
%164 = icmp eq i8 %163, 35
br i1 %164, label %165, label %182
165: ; preds = %161
%166 = or i64 %178, 2
%167 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %166, i64 0
%168 = load i8, i8* %167
%169 = icmp eq i8 %168, 35
br i1 %169, label %170, label %182
170: ; preds = %165
%171 = or i64 %178, 3
%172 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %171, i64 0
%173 = load i8, i8* %172
%174 = icmp eq i8 %173, 35
br i1 %174, label %175, label %182
175: ; preds = %170
%176 = add nuw nsw i64 %178, 4
br label %177
177: ; preds = %131, %175
%178 = phi i64 [ %176, %175 ], [ 0, %131 ]
%179 = getelementptr inbounds [41 x [81 x i8]], [41 x [81 x i8]]* %3, i64 0, i64 %178, i64 0
%180 = load i8, i8* %179
%181 = icmp eq i8 %180, 35
br i1 %181, label %158, label %182
182: ; preds = %170, %165, %161, %177
%183 = load i32, i32* @stderr
%184 = call i32 @fprintf(i32 %183, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
br label %194
185: ; preds = %158
%186 = bitcast [41 x [81 x i8]]* %3 to i8**
%187 = call i32 @maze_solve(i8** %186)
%188 = icmp eq i32 %187, 0
br i1 %188, label %189, label %192
189: ; preds = %185
%190 = load i32, i32* @stderr
%191 = call i32 @fprintf(i32 %190, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %194
192: ; preds = %185
%193 = call i32 @maze_print(i8** %186)
br label %194
194: ; preds = %26, %36, %192, %189, %182, %155, %128, %101, %74, %63, %18, %10
%195 = phi i32 [ 1, %10 ], [ 6, %26 ], [ 3, %36 ], [ 3, %63 ], [ 4, %74 ], [ 3, %101 ], [ 3, %128 ], [ 3, %155 ], [ 3, %182 ], [ 0, %192 ], [ 5, %189 ], [ 2, %18 ]
ret i32 %195
}