#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
char **read_map(char *fileToRead, char map[10][10]) {
  int c;
  int i = 0;
  int j = 0;
  FILE *file;
  file = fopen(fileToRead, "r");
  if (file) {
    while ((c = getc(file)) != EOF) {
      for (i; i < 10; i++) {
        for (j = 0; j < 10; j++)
          map[i][j] = c;
      }
    }
    fclose(file);
  }
  return map;
}


x86 assembly (clang, -O0):
<read_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f2 <read_map+0xc2>
jmp    1172 <read_map+0x42>
mov    -0x28(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%eax
je     11e9 <read_map+0xb9>
cmpl   $0xa,-0x18(%rbp)
jge    11e4 <read_map+0xb4>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11d1 <read_map+0xa1>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0xa,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119e <read_map+0x6e>
jmp    11d6 <read_map+0xa6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118d <read_map+0x5d>
jmp    1172 <read_map+0x42>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_map>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xeaf(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     117a <read_map+0x3a>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getc@plt>
mov    0x2e7b(%rip),%r15
cmp    (%r15),%eax
jne    1188 <read_map+0x48>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
jmp    119d <read_map+0x5d>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    (%r15),%eax
je     1172 <read_map+0x32>
cmp    $0x9,%ebp
ja     1190 <read_map+0x50>
mov    %ebp,%ecx
lea    (%rcx,%rcx,4),%rcx
lea    (%r14,%rcx,2),%rdi
mov    $0x9,%ecx
sub    %ebp,%ecx
lea    (%rcx,%rcx,4),%rcx
lea    (%rcx,%rcx,1),%rdx
add    $0xa,%rdx
mov    %eax,%esi
call   1040 <memset@plt>
mov    $0xa,%ebp
jmp    1190 <read_map+0x50>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define i8** @read_map(i8* %0, [10 x i8]* %1) {
%3 = alloca i8*
%4 = alloca [10 x i8]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i8* %0, i8** %3
store [10 x i8]* %1, [10 x i8]** %4
store i32 0, i32* %6
store i32 0, i32* %7
%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** %8
%11 = load i32*, i32** %8
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %49
13: ; preds = %2
br label %14
14: ; preds = %45, %13
%15 = load i32*, i32** %8
%16 = call i32 @getc(i32* %15)
store i32 %16, i32* %5
%17 = load i32, i32* @EOF
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %46
19: ; preds = %14
%20 = load i32, i32* %6
br label %21
21: ; preds = %42, %19
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 10
br i1 %23, label %24, label %45
24: ; preds = %21
store i32 0, i32* %7
br label %25
25: ; preds = %38, %24
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 10
br i1 %27, label %28, label %41
28: ; preds = %25
%29 = load i32, i32* %5
%30 = trunc i32 %29 to i8
%31 = load [10 x i8]*, [10 x i8]** %4
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %31, i64 %33
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %34, i64 0, i64 %36
store i8 %30, i8* %37
br label %38
38: ; preds = %28
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %25
41: ; preds = %25
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %21
45: ; preds = %21
br label %14
46: ; preds = %14
%47 = load i32*, i32** %8
%48 = call i32 @fclose(i32* %47)
br label %49
49: ; preds = %46, %2
%50 = load [10 x i8]*, [10 x i8]** %4
%51 = bitcast [10 x i8]* %50 to i8**
ret i8** %51
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define i8** @read_map(i8* nocapture %0, [10 x i8]* writeonly %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %28, label %5
5: ; preds = %2
%6 = tail call i32 @getc(i32* %3)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %26, label %14
9: ; preds = %18, %14
%10 = phi i32 [ %16, %14 ], [ 10, %18 ]
%11 = tail call i32 @getc(i32* %3)
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %26, label %14
14: ; preds = %5, %9
%15 = phi i32 [ %11, %9 ], [ %6, %5 ]
%16 = phi i32 [ %10, %9 ], [ 0, %5 ]
%17 = icmp ult i32 %16, 10
br i1 %17, label %18, label %9
18: ; preds = %14
%19 = trunc i32 %15 to i8
%20 = zext i32 %16 to i64
%21 = getelementptr [10 x i8], [10 x i8]* %1, i64 %20, i64 0
%22 = sub nuw nsw i32 9, %16
%23 = zext i32 %22 to i64
%24 = mul nuw nsw i64 %23, 10
%25 = add nuw nsw i64 %24, 10
br label %9
26: ; preds = %9, %5
%27 = tail call i32 @fclose(i32* %3)
br label %28
28: ; preds = %26, %2
%29 = bitcast [10 x i8]* %1 to i8**
ret i8** %29
}