#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 *, ...);
int main(void) {
  char url[] = "map.txt";
  FILE *arq;
  arq = fopen(url, "r");
  if (arq == NULL)
    printf("Erro, nao foi possivel abrir o arquivo \n");
  else {
    int i = 0, j = 0;
    char map[20][20];
    char ch;
    while ((ch = fgetc(arq)) != EOF) {
      map[i][j] = ch;
      printf("%c", map[i][j]);
      i++;
      if (ch == '\n') {
        i = 0;
        j++;
      }
    }
  }
  fclose(arq);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118f <main+0x4f>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123b <main+0xfb>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x1b1(%rbp)
movsbl %al,%eax
mov    0x2e32(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1236 <main+0xf6>
mov    -0x1b1(%rbp),%dl
movslq -0x1c(%rbp),%rcx
lea    -0x1b0(%rbp),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movslq -0x1c(%rbp),%rcx
lea    -0x1b0(%rbp),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x1b1(%rbp),%eax
cmp    $0xa,%eax
jne    1231 <main+0xf1>
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119d <main+0x5d>
jmp    123b <main+0xfb>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movabs $0x7478742e70616d,%rax
mov    %rax,(%rsp)
lea    0xe97(%rip),%rsi
mov    %rsp,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a7 <main+0x57>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    0x2e60(%rip),%r14
cmp    (%r14),%al
je     11b3 <main+0x63>
nopl   (%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    (%r14),%al
jne    1190 <main+0x40>
jmp    11b3 <main+0x63>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@str = [40 x i8] c"Erro, nao foi possivel abrir o arquivo \00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 32783537689092461, i64* %1
%3 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = tail call signext i8 @fgetc(i32* %3)
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %6, %7
br i1 %8, label %18, label %11
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %18
11: ; preds = %5, %11
%12 = phi i8 [ %15, %11 ], [ %6, %5 ]
%13 = sext i8 %12 to i32
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call signext i8 @fgetc(i32* %3)
%16 = load i8, i8* @EOF
%17 = icmp eq i8 %15, %16
br i1 %17, label %18, label %11
18: ; preds = %11, %5, %9
%19 = tail call i32 @fclose(i32* %3)
ret i32 0
}