#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  FILE *f;
  int x, y;
  unsigned char c;
  f = fopen("a.o65", "rb");
  if (f == NULL)
    return -1;
  for (y = 0; y < 31; y++) {
    for (x = 0; x < 32; x++) {
      c = fgetc(f);
      switch (c) {
      case 128:
        printf("#");
        break;
      case 129:
        printf("x");
        break;
      case 64:
        printf(".");
        break;
      case 32:
        printf("O");
        break;
      case 0:
        printf(" ");
        break;
      default:
        printf("?");
      }
    }
    printf("\n");
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117d <main+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a5 <main+0x165>
movl   $0x0,-0x18(%rbp)
cmpl   $0x1f,-0x18(%rbp)
jge    1295 <main+0x155>
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    127b <main+0x13b>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     124b <main+0x10b>
jmp    11bf <main+0x7f>
mov    -0x20(%rbp),%eax
sub    $0x20,%eax
je     123a <main+0xfa>
jmp    11d0 <main+0x90>
mov    -0x20(%rbp),%eax
sub    $0x40,%eax
je     1229 <main+0xe9>
jmp    11e1 <main+0xa1>
mov    -0x20(%rbp),%eax
sub    $0x80,%eax
je     1207 <main+0xc7>
jmp    11f4 <main+0xb4>
mov    -0x20(%rbp),%eax
sub    $0x81,%eax
je     1218 <main+0xd8>
jmp    125c <main+0x11c>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
jmp    1268 <main+0x128>
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
jmp    1268 <main+0x128>
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
jmp    1268 <main+0x128>
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
jmp    1268 <main+0x128>
lea    0xdbf(%rip),%rdi
call   1040 <printf@plt>
jmp    1268 <main+0x128>
lea    0xdb0(%rip),%rdi
call   1040 <printf@plt>
jmp    126d <main+0x12d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <main+0x55>
lea    0xd93(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1184 <main+0x44>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ee <main+0xae>
mov    %rax,%rbx
xor    %r14d,%r14d
jmp    1184 <main+0x44>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
cmp    $0x1f,%r14d
je     11e2 <main+0xa2>
mov    $0x20,%ebp
jmp    119a <main+0x5a>
mov    $0x3f,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
je     1170 <main+0x30>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
test   %al,%al
js     11c0 <main+0x80>
je     11d4 <main+0x94>
cmp    $0x20,%al
je     11db <main+0x9b>
cmp    $0x40,%al
jne    118b <main+0x4b>
mov    $0x2e,%edi
jmp    1190 <main+0x50>
nopw   0x0(%rax,%rax,1)
mov    $0x23,%edi
cmp    $0x80,%al
je     1190 <main+0x50>
cmp    $0x81,%al
jne    118b <main+0x4b>
mov    $0x78,%edi
jmp    1190 <main+0x50>
mov    $0x20,%edi
jmp    1190 <main+0x50>
mov    $0x4f,%edi
jmp    1190 <main+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11f3 <main+0xb3>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"a.o65\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [2 x i8] c"#\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [2 x i8] c"O\00"
@.str.6 = [2 x i8] c" \00"
@.str.7 = [2 x i8] c"?\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 -1, i32* %1
br label %47
10: ; preds = %0
store i32 0, i32* %4
br label %11
11: ; preds = %41, %10
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 31
br i1 %13, label %14, label %44
14: ; preds = %11
store i32 0, i32* %3
br label %15
15: ; preds = %36, %14
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 32
br i1 %17, label %18, label %39
18: ; preds = %15
%19 = load i32*, i32** %2
%20 = call zeroext i8 @fgetc(i32* %19)
store i8 %20, i8* %5
%21 = load i8, i8* %5
%22 = zext i8 %21 to i32
switch i32 %22, label %33 [
i32 128, label %23
i32 129, label %25
i32 64, label %27
i32 32, label %29
i32 0, label %31
]
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
25: ; preds = %18
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %35
27: ; preds = %18
%28 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %35
29: ; preds = %18
%30 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %35
31: ; preds = %18
%32 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %35
33: ; preds = %18
%34 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %35
35: ; preds = %33, %31, %29, %27, %25, %23
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %15
39: ; preds = %15
%40 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %41
41: ; preds = %39
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %11
44: ; preds = %11
%45 = load i32*, i32** %2
%46 = call i32 @fclose(i32* %45)
store i32 0, i32* %1
br label %47
47: ; preds = %44, %9
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [6 x i8] c"a.o65\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %24, label %3
3: ; preds = %0, %18
%4 = phi i32 [ %20, %18 ], [ 0, %0 ]
br label %5
5: ; preds = %3, %13
%6 = phi i32 [ 0, %3 ], [ %16, %13 ]
%7 = tail call zeroext i8 @fgetc(i32* %1)
switch i8 %7, label %12 [
i8 -128, label %13
i8 -127, label %8
i8 64, label %9
i8 32, label %10
i8 0, label %11
]
8: ; preds = %5
br label %13
9: ; preds = %5
br label %13
10: ; preds = %5
br label %13
11: ; preds = %5
br label %13
12: ; preds = %5
br label %13
13: ; preds = %5, %8, %9, %10, %11, %12
%14 = phi i32 [ 120, %8 ], [ 46, %9 ], [ 79, %10 ], [ 32, %11 ], [ 63, %12 ], [ 35, %5 ]
%15 = tail call i32 @putchar(i32 %14)
%16 = add nuw nsw i32 %6, 1
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %5
18: ; preds = %13
%19 = tail call i32 @putchar(i32 10)
%20 = add nuw nsw i32 %4, 1
%21 = icmp eq i32 %20, 31
br i1 %21, label %22, label %3
22: ; preds = %18
%23 = tail call i32 @fclose(i32* %1)
br label %24
24: ; preds = %0, %22
%25 = phi i32 [ 0, %22 ], [ -1, %0 ]
ret i32 %25
}