#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 *);
char *gettext(char *);
void *malloc(int);
int /*<<< orphan*/ printf(char *);
char **readmap(char *url) {
  FILE *arq = fopen(url, "r");
  if (!arq) {
    printf(gettext("cannot read map file!\n"));
    return NULL;
  } else {
    int i;
    int j = 0;
    char ch;
    char **map = malloc(20 * sizeof(char *));
    if (!map)
      printf(gettext("not enough memory!\n"));
    else {
      for (i = 0; i < 20; i++) {
        map[i] = malloc(20 * sizeof(char));
        if (!map[i]) {
          printf(gettext("not enough memory!\n"));
          return NULL;
        }
      }
    }
    i = 0;
    while ((ch = fgetc(arq)) != EOF) {
      map[i][j] = ch;
      i++;
      if (ch == '\n') {
        i = 0;
        j++;
      }
    }
    fclose(arq);
    return map;
  }
}


x86 assembly (clang, -O0):
<readmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ac <readmap+0x4c>
lea    0xe70(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    12d5 <readmap+0x175>
movl   $0x0,-0x20(%rbp)
mov    $0xa0,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11e5 <readmap+0x85>
lea    0xe46(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
call   1050 <printf@plt>
jmp    125b <readmap+0xfb>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    1256 <readmap+0xf6>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1243 <readmap+0xe3>
lea    0xdf0(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    12d5 <readmap+0x175>
jmp    1248 <readmap+0xe8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ec <readmap+0x8c>
jmp    125b <readmap+0xfb>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2d70(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12c4 <readmap+0x164>
mov    -0x21(%rbp),%dl
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
jne    12bf <readmap+0x15f>
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1262 <readmap+0x102>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     135d <readmap+0x1fd>
mov    %rax,%r14
mov    $0xa0,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     1376 <readmap+0x216>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x8(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x18(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x20(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x28(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x30(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x38(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x40(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x48(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x50(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x58(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x60(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x68(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x70(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x78(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x80(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x88(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x90(%r15)
test   %rax,%rax
je     1354 <readmap+0x1f4>
mov    $0x14,%edi
call   1070 <malloc@plt>
mov    %rax,0x98(%r15)
test   %rax,%rax
jne    138a <readmap+0x22a>
lea    0xcbe(%rip),%rdi
jmp    1364 <readmap+0x204>
lea    0xc9e(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
call   1050 <printf@plt>
xor    %r15d,%r15d
jmp    13e2 <readmap+0x282>
lea    0xc9c(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1060 <fgetc@plt>
mov    0x2c4f(%rip),%r12
cmp    (%r12),%al
je     13da <readmap+0x27a>
xor    %r13d,%r13d
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movslq %ebp,%rbp
mov    (%r15,%rbp,8),%rcx
mov    %ebx,%edx
mov    %al,(%rcx,%rdx,1)
add    $0x1,%ebp
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
cmove  %r13d,%ebp
add    %ecx,%ebx
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    (%r12),%al
jne    13b0 <readmap+0x250>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"cannot read map file!\0A\00"
@.str.2 = [20 x i8] c"not enough memory!\0A\00"
@EOF = global i8 0
define i8** @readmap(i8* %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8**
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
%11 = load i32*, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = call i8* @gettext(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @printf(i8* %14)
store i8** null, i8*** %2
br label %79
16: ; preds = %1
store i32 0, i32* %6
%17 = call i8* @malloc(i32 160)
%18 = bitcast i8* %17 to i8**
store i8** %18, i8*** %8
%19 = load i8**, i8*** %8
%20 = icmp ne i8** %19, null
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = call i8* @gettext(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @printf(i8* %22)
br label %48
24: ; preds = %16
store i32 0, i32* %5
br label %25
25: ; preds = %44, %24
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 20
br i1 %27, label %28, label %47
28: ; preds = %25
%29 = call i8* @malloc(i32 20)
%30 = load i8**, i8*** %8
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
store i8* %29, i8** %33
%34 = load i8**, i8*** %8
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = icmp ne i8* %38, null
br i1 %39, label %43, label %40
40: ; preds = %28
%41 = call i8* @gettext(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @printf(i8* %41)
store i8** null, i8*** %2
br label %79
43: ; preds = %28
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %25
47: ; preds = %25
br label %48
48: ; preds = %47, %21
store i32 0, i32* %5
br label %49
49: ; preds = %74, %48
%50 = load i32*, i32** %4
%51 = call signext i8 @fgetc(i32* %50)
store i8 %51, i8* %7
%52 = sext i8 %51 to i32
%53 = load i8, i8* @EOF
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %52, %54
br i1 %55, label %56, label %75
56: ; preds = %49
%57 = load i8, i8* %7
%58 = load i8**, i8*** %8
%59 = load i32, i32* %5
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
%63 = load i32, i32* %6
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
store i8 %57, i8* %65
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
%68 = load i8, i8* %7
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 10
br i1 %70, label %71, label %74
71: ; preds = %56
store i32 0, i32* %5
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %6
br label %74
74: ; preds = %71, %56
br label %49
75: ; preds = %49
%76 = load i32*, i32** %4
%77 = call i32 @fclose(i32* %76)
%78 = load i8**, i8*** %8
store i8** %78, i8*** %2
br label %79
79: ; preds = %75, %40, %13
%80 = load i8**, i8*** %2
ret i8** %80
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"cannot read map file!\0A\00"
@.str.2 = [20 x i8] c"not enough memory!\0A\00"
@EOF = global i8 0
define noalias i8** @readmap(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i8* @gettext(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) %5)
br label %119
7: ; preds = %1
%8 = tail call dereferenceable_or_null(160) i8* @malloc(i32 160)
%9 = bitcast i8* %8 to i8**
%10 = icmp eq i8* %8, null
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
store i8* %12, i8** %9
%13 = icmp eq i8* %12, null
br i1 %13, label %93, label %17
14: ; preds = %7
%15 = tail call i8* @gettext(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @printf(i8* dereferenceable(1) %15)
br label %96
17: ; preds = %11
%18 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%19 = getelementptr inbounds i8*, i8** %9, i64 1
store i8* %18, i8** %19
%20 = icmp eq i8* %18, null
br i1 %20, label %93, label %21
21: ; preds = %17
%22 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%23 = getelementptr inbounds i8*, i8** %9, i64 2
store i8* %22, i8** %23
%24 = icmp eq i8* %22, null
br i1 %24, label %93, label %25
25: ; preds = %21
%26 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%27 = getelementptr inbounds i8*, i8** %9, i64 3
store i8* %26, i8** %27
%28 = icmp eq i8* %26, null
br i1 %28, label %93, label %29
29: ; preds = %25
%30 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%31 = getelementptr inbounds i8*, i8** %9, i64 4
store i8* %30, i8** %31
%32 = icmp eq i8* %30, null
br i1 %32, label %93, label %33
33: ; preds = %29
%34 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%35 = getelementptr inbounds i8*, i8** %9, i64 5
store i8* %34, i8** %35
%36 = icmp eq i8* %34, null
br i1 %36, label %93, label %37
37: ; preds = %33
%38 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%39 = getelementptr inbounds i8*, i8** %9, i64 6
store i8* %38, i8** %39
%40 = icmp eq i8* %38, null
br i1 %40, label %93, label %41
41: ; preds = %37
%42 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%43 = getelementptr inbounds i8*, i8** %9, i64 7
store i8* %42, i8** %43
%44 = icmp eq i8* %42, null
br i1 %44, label %93, label %45
45: ; preds = %41
%46 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%47 = getelementptr inbounds i8*, i8** %9, i64 8
store i8* %46, i8** %47
%48 = icmp eq i8* %46, null
br i1 %48, label %93, label %49
49: ; preds = %45
%50 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%51 = getelementptr inbounds i8*, i8** %9, i64 9
store i8* %50, i8** %51
%52 = icmp eq i8* %50, null
br i1 %52, label %93, label %53
53: ; preds = %49
%54 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%55 = getelementptr inbounds i8*, i8** %9, i64 10
store i8* %54, i8** %55
%56 = icmp eq i8* %54, null
br i1 %56, label %93, label %57
57: ; preds = %53
%58 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%59 = getelementptr inbounds i8*, i8** %9, i64 11
store i8* %58, i8** %59
%60 = icmp eq i8* %58, null
br i1 %60, label %93, label %61
61: ; preds = %57
%62 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%63 = getelementptr inbounds i8*, i8** %9, i64 12
store i8* %62, i8** %63
%64 = icmp eq i8* %62, null
br i1 %64, label %93, label %65
65: ; preds = %61
%66 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%67 = getelementptr inbounds i8*, i8** %9, i64 13
store i8* %66, i8** %67
%68 = icmp eq i8* %66, null
br i1 %68, label %93, label %69
69: ; preds = %65
%70 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%71 = getelementptr inbounds i8*, i8** %9, i64 14
store i8* %70, i8** %71
%72 = icmp eq i8* %70, null
br i1 %72, label %93, label %73
73: ; preds = %69
%74 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%75 = getelementptr inbounds i8*, i8** %9, i64 15
store i8* %74, i8** %75
%76 = icmp eq i8* %74, null
br i1 %76, label %93, label %77
77: ; preds = %73
%78 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%79 = getelementptr inbounds i8*, i8** %9, i64 16
store i8* %78, i8** %79
%80 = icmp eq i8* %78, null
br i1 %80, label %93, label %81
81: ; preds = %77
%82 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%83 = getelementptr inbounds i8*, i8** %9, i64 17
store i8* %82, i8** %83
%84 = icmp eq i8* %82, null
br i1 %84, label %93, label %85
85: ; preds = %81
%86 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%87 = getelementptr inbounds i8*, i8** %9, i64 18
store i8* %86, i8** %87
%88 = icmp eq i8* %86, null
br i1 %88, label %93, label %89
89: ; preds = %85
%90 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%91 = getelementptr inbounds i8*, i8** %9, i64 19
store i8* %90, i8** %91
%92 = icmp eq i8* %90, null
br i1 %92, label %93, label %96
93: ; preds = %89, %85, %81, %77, %73, %69, %65, %61, %57, %53, %49, %45, %41, %37, %33, %29, %25, %21, %17, %11
%94 = tail call i8* @gettext(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%95 = tail call i32 @printf(i8* dereferenceable(1) %94)
br label %119
96: ; preds = %89, %14
%97 = tail call signext i8 @fgetc(i32* %2)
%98 = load i8, i8* @EOF
%99 = icmp eq i8 %97, %98
br i1 %99, label %117, label %100
100: ; preds = %96, %100
%101 = phi i8 [ %114, %100 ], [ %97, %96 ]
%102 = phi i32 [ %113, %100 ], [ 0, %96 ]
%103 = phi i32 [ %111, %100 ], [ 0, %96 ]
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8*, i8** %9, i64 %104
%106 = load i8*, i8** %105
%107 = zext i32 %102 to i64
%108 = getelementptr inbounds i8, i8* %106, i64 %107
store i8 %101, i8* %108
%109 = add nsw i32 %103, 1
%110 = icmp eq i8 %101, 10
%111 = select i1 %110, i32 0, i32 %109
%112 = zext i1 %110 to i32
%113 = add nuw nsw i32 %102, %112
%114 = tail call signext i8 @fgetc(i32* %2)
%115 = load i8, i8* @EOF
%116 = icmp eq i8 %114, %115
br i1 %116, label %117, label %100
117: ; preds = %100, %96
%118 = tail call i32 @fclose(i32* %2)
br label %119
119: ; preds = %93, %117, %4
%120 = phi i8** [ null, %4 ], [ null, %93 ], [ %9, %117 ]
ret i8** %120
}