#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
void load_maze(char maze[23][30], char path) {
  char ch;
  int i = 0, j = 0;
  FILE *fp;
  fp = fopen("maze.txt", "r");
  if (fp == NULL)
    printf("Erro, nao foi possivel abrir o arquivo\n");
  else {
    while ((ch = fgetc(fp)) != EOF) {
      if (ch != '\n') {
        maze[i][j] = ch;
        j++;
      } else {
        j = 0;
        i++;
      }
    }
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<load_maze>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe99(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1193 <load_maze+0x53>
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
jmp    1207 <load_maze+0xc7>
jmp    1198 <load_maze+0x58>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0xa(%rbp)
movsbl %al,%eax
mov    0x2e3a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1202 <load_maze+0xc2>
movsbl -0xa(%rbp),%eax
cmp    $0xa,%eax
je     11ed <load_maze+0xad>
mov    -0xa(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fd <load_maze+0xbd>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1198 <load_maze+0x58>
jmp    1207 <load_maze+0xc7>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_maze>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
lea    0xeae(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
je     11b4 <load_maze+0x74>
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    0x2e73(%rip),%r15
cmp    (%r15),%al
je     11c0 <load_maze+0x80>
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1192 <load_maze+0x52>
add    $0x1,%ebp
xor    %ebx,%ebx
mov    %r12,%rdi
call   1050 <fgetc@plt>
cmp    (%r15),%al
je     11c0 <load_maze+0x80>
cmp    $0xa,%al
je     1180 <load_maze+0x40>
movslq %ebp,%rcx
movslq %ebx,%rbx
mov    %rcx,%rdx
shl    $0x5,%rdx
sub    %rcx,%rdx
sub    %rcx,%rdx
add    %r14,%rdx
mov    %al,(%rbx,%rdx,1)
add    $0x1,%ebx
jmp    1185 <load_maze+0x45>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"maze.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [40 x i8] c"Erro, nao foi possivel abrir o arquivo\0A\00"
@EOF = global i8 0
define void @load_maze([30 x i8]* %0, i8 signext %1) {
%3 = alloca [30 x i8]*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store [30 x i8]* %0, [30 x i8]** %3
store i8 %1, i8* %4
store i32 0, i32* %6
store i32 0, i32* %7
%9 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %8
%10 = load i32*, i32** %8
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %42
14: ; preds = %2
br label %15
15: ; preds = %40, %14
%16 = load i32*, i32** %8
%17 = call signext i8 @fgetc(i32* %16)
store i8 %17, i8* %5
%18 = sext i8 %17 to i32
%19 = load i8, i8* @EOF
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %41
22: ; preds = %15
%23 = load i8, i8* %5
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i8, i8* %5
%28 = load [30 x i8]*, [30 x i8]** %3
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [30 x i8], [30 x i8]* %28, i64 %30
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [30 x i8], [30 x i8]* %31, i64 0, i64 %33
store i8 %27, i8* %34
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %40
37: ; preds = %22
store i32 0, i32* %7
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %40
40: ; preds = %37, %26
br label %15
41: ; preds = %15
br label %42
42: ; preds = %41, %12
%43 = load i32*, i32** %8
%44 = call i32 @fclose(i32* %43)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"maze.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@str = [39 x i8] c"Erro, nao foi possivel abrir o arquivo\00"
define void @load_maze([30 x i8]* nocapture writeonly %0, i8 signext %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 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 %9, label %5
5: ; preds = %2
%6 = tail call signext i8 @fgetc(i32* %3)
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %6, %7
br i1 %8, label %29, label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %29
11: ; preds = %5, %23
%12 = phi i8 [ %26, %23 ], [ %6, %5 ]
%13 = phi i32 [ %25, %23 ], [ 0, %5 ]
%14 = phi i32 [ %24, %23 ], [ 0, %5 ]
%15 = icmp eq i8 %12, 10
br i1 %15, label %21, label %16
16: ; preds = %11
%17 = sext i32 %13 to i64
%18 = sext i32 %14 to i64
%19 = getelementptr inbounds [30 x i8], [30 x i8]* %0, i64 %17, i64 %18
store i8 %12, i8* %19
%20 = add nsw i32 %14, 1
br label %23
21: ; preds = %11
%22 = add nsw i32 %13, 1
br label %23
23: ; preds = %21, %16
%24 = phi i32 [ %20, %16 ], [ 0, %21 ]
%25 = phi i32 [ %13, %16 ], [ %22, %21 ]
%26 = tail call signext i8 @fgetc(i32* %3)
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %29, label %11
29: ; preds = %23, %5, %9
%30 = tail call i32 @fclose(i32* %3)
ret void
}