#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*/ bail(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int load_map(FILE *fp, char map[23][80]) {
  int x, y;
  int c;
  for (y = 0; y < 23; y++) {
    for (x = 0; x < 80; x++) {
      map[y][x] = 0;
      c = fgetc(fp);
      if (c == EOF) {
        fclose(fp);
        bail("Unexpected end to map!");
      }
      map[y][x] = c;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<load_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x17,-0x18(%rbp)
jge    11e8 <load_map+0xb8>
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    11d5 <load_map+0xa5>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e59(%rip),%rcx
cmp    (%rcx),%eax
jne    11ac <load_map+0x7c>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe59(%rip),%rdi
call   1050 <bail@plt>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x50,%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    1158 <load_map+0x28>
jmp    11da <load_map+0xaa>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1147 <load_map+0x17>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
mov    0x2e9e(%rip),%r13
lea    0xeaf(%rip),%r15
jmp    1172 <load_map+0x42>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rsp),%rax
add    $0x1,%rax
add    $0x50,%rbx
cmp    $0x17,%rax
je     11b5 <load_map+0x85>
mov    %rax,(%rsp)
xor    %r12d,%r12d
jmp    118e <load_map+0x5e>
nopl   0x0(%rax,%rax,1)
mov    %bpl,(%rbx,%r12,1)
add    $0x1,%r12
cmp    $0x50,%r12
je     1160 <load_map+0x30>
movb   $0x0,(%rbx,%r12,1)
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
jne    1180 <load_map+0x50>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1050 <bail@plt>
jmp    1180 <load_map+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [23 x i8] c"Unexpected end to map!\00"
define i32 @load_map(i32* nocapture %0, [80 x i8]* nocapture writeonly %1) {
br label %3
3: ; preds = %2, %18
%4 = phi i64 [ 0, %2 ], [ %19, %18 ]
br label %5
5: ; preds = %3, %14
%6 = phi i64 [ 0, %3 ], [ %16, %14 ]
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 %4, i64 %6
store i8 0, i8* %7
%8 = tail call i32 @fgetc(i32* %0)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = tail call i32 @fclose(i32* %0)
%13 = tail call i32 @bail(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %5
%15 = trunc i32 %8 to i8
store i8 %15, i8* %7
%16 = add nuw nsw i64 %6, 1
%17 = icmp eq i64 %16, 80
br i1 %17, label %18, label %5
18: ; preds = %14
%19 = add nuw nsw i64 %4, 1
%20 = icmp eq i64 %19, 23
br i1 %20, label %21, label %3
21: ; preds = %18
ret i32 0
}