#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*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  FILE *f;
  int x, y, z;
  int c, dots = 0;
  f = fopen("a.o65", "rb");
  if (f == NULL)
    return -1;
  for (y = 0; y < 31; y++) {
    for (x = 0; x < 16; x++) {
      c = fgetc(f);
      for (z = 0; z < 2; z++) {
        switch (c & 240) {
        case 128:
          printf("#");
          break;
        case 144:
          printf("x");
          break;
        case 64:
          printf(".");
          dots++;
          break;
        case 32:
          printf("O");
          dots++;
          break;
        case 0:
          printf(" ");
          break;
        case 16:
          printf("~");
          break;
        default:
          printf("?");
        }
        c <<= 4;
      }
    }
    printf("\n");
  }
  printf("\ndots+pills = %d\n\n", dots);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xea3(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1184 <main+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    132b <main+0x1eb>
movl   $0x0,-0x18(%rbp)
cmpl   $0x1f,-0x18(%rbp)
jge    130a <main+0x1ca>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    12ee <main+0x1ae>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    12db <main+0x19b>
mov    -0x20(%rbp),%eax
and    $0xf0,%eax
mov    %eax,-0x28(%rbp)
je     1290 <main+0x150>
jmp    11d9 <main+0x99>
mov    -0x28(%rbp),%eax
sub    $0x10,%eax
je     12a3 <main+0x163>
jmp    11ea <main+0xaa>
mov    -0x28(%rbp),%eax
sub    $0x20,%eax
je     1274 <main+0x134>
jmp    11fb <main+0xbb>
mov    -0x28(%rbp),%eax
sub    $0x40,%eax
je     1258 <main+0x118>
jmp    120c <main+0xcc>
mov    -0x28(%rbp),%eax
sub    $0x80,%eax
je     1232 <main+0xf2>
jmp    121f <main+0xdf>
mov    -0x28(%rbp),%eax
sub    $0x90,%eax
je     1245 <main+0x105>
jmp    12b6 <main+0x176>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c4 <main+0x184>
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c4 <main+0x184>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12c4 <main+0x184>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12c4 <main+0x184>
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c4 <main+0x184>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c4 <main+0x184>
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b9 <main+0x79>
jmp    12e0 <main+0x1a0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <main+0x5c>
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118b <main+0x4b>
mov    -0x24(%rbp),%esi
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeee(%rip),%rdi
lea    0xeed(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     129a <main+0x14a>
mov    %rax,%r14
xor    %ebp,%ebp
lea    0xea5(%rip),%r15
lea    0xe76(%rip),%r12
xor    %eax,%eax
jmp    11aa <main+0x5a>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
add    $0x1,%eax
cmp    $0x1f,%eax
je     127e <main+0x12e>
mov    %eax,0x4(%rsp)
mov    $0x10,%r13d
jmp    11cb <main+0x7b>
mov    $0x3f,%edi
nopl   0x0(%rax,%rax,1)
call   1030 <putchar@plt>
add    $0xffffffff,%r13d
je     1190 <main+0x40>
mov    %r14,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
shr    $0x4,%eax
and    $0xf,%eax
cmp    $0x9,%eax
ja     11fe <main+0xae>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    $0x20,%edi
jmp    1220 <main+0xd0>
mov    $0x7e,%edi
jmp    1220 <main+0xd0>
mov    $0x4f,%edi
jmp    120a <main+0xba>
mov    $0x3f,%edi
jmp    1220 <main+0xd0>
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
jmp    1225 <main+0xd5>
mov    $0x23,%edi
jmp    1220 <main+0xd0>
mov    $0x78,%edi
call   1030 <putchar@plt>
and    $0xf,%ebx
cmp    $0x9,%ebx
ja     11b6 <main+0x66>
movslq (%r15,%rbx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x20,%edi
jmp    11c0 <main+0x70>
mov    $0x7e,%edi
jmp    11c0 <main+0x70>
mov    $0x4f,%edi
jmp    1253 <main+0x103>
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
add    $0xffffffff,%r13d
jne    11cb <main+0x7b>
jmp    1190 <main+0x40>
mov    $0x23,%edi
jmp    11c0 <main+0x70>
mov    $0x78,%edi
jmp    11c0 <main+0x70>
lea    0xdd4(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    129f <main+0x14f>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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"?\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [19 x i8] c"\0Adots+pills = %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
%8 = 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* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 -1, i32* %1
br label %67
12: ; preds = %0
store i32 0, i32* %4
br label %13
13: ; preds = %59, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 31
br i1 %15, label %16, label %62
16: ; preds = %13
store i32 0, i32* %3
br label %17
17: ; preds = %54, %16
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 16
br i1 %19, label %20, label %57
20: ; preds = %17
%21 = load i32*, i32** %2
%22 = call i32 @fgetc(i32* %21)
store i32 %22, i32* %6
store i32 0, i32* %5
br label %23
23: ; preds = %50, %20
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 2
br i1 %25, label %26, label %53
26: ; preds = %23
%27 = load i32, i32* %6
%28 = and i32 %27, 240
switch i32 %28, label %45 [
i32 128, label %29
i32 144, label %31
i32 64, label %33
i32 32, label %37
i32 0, label %41
i32 16, label %43
]
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %47
31: ; preds = %26
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %47
33: ; preds = %26
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %47
37: ; preds = %26
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %47
41: ; preds = %26
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %47
43: ; preds = %26
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %47
45: ; preds = %26
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %47
47: ; preds = %45, %43, %41, %37, %33, %31, %29
%48 = load i32, i32* %6
%49 = shl i32 %48, 4
store i32 %49, i32* %6
br label %50
50: ; preds = %47
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %23
53: ; preds = %23
br label %54
54: ; preds = %53
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %17
57: ; preds = %17
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %59
59: ; preds = %57
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
br label %13
62: ; preds = %13
%63 = load i32, i32* %7
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i32 %63)
%65 = load i32*, i32** %2
%66 = call i32 @fclose(i32* %65)
store i32 0, i32* %1
br label %67
67: ; preds = %62, %11
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@.str = [6 x i8] c"a.o65\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.10 = [19 x i8] c"\0Adots+pills = %d\0A\0A\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 %58, label %3
3: ; preds = %0, %51
%4 = phi i32 [ %48, %51 ], [ 0, %0 ]
%5 = phi i32 [ %53, %51 ], [ 0, %0 ]
br label %6
6: ; preds = %3, %47
%7 = phi i32 [ %4, %3 ], [ %48, %47 ]
%8 = phi i32 [ 0, %3 ], [ %49, %47 ]
%9 = tail call i32 @fgetc(i32* %1)
%10 = lshr i32 %9, 4
%11 = and i32 %10, 15
switch i32 %11, label %26 [
i32 8, label %12
i32 9, label %14
i32 4, label %16
i32 2, label %19
i32 0, label %22
i32 1, label %24
]
12: ; preds = %6
%13 = tail call i32 @putchar(i32 35)
br label %28
14: ; preds = %6
%15 = tail call i32 @putchar(i32 120)
br label %28
16: ; preds = %6
%17 = tail call i32 @putchar(i32 46)
%18 = add nsw i32 %7, 1
br label %28
19: ; preds = %6
%20 = tail call i32 @putchar(i32 79)
%21 = add nsw i32 %7, 1
br label %28
22: ; preds = %6
%23 = tail call i32 @putchar(i32 32)
br label %28
24: ; preds = %6
%25 = tail call i32 @putchar(i32 126)
br label %28
26: ; preds = %6
%27 = tail call i32 @putchar(i32 63)
br label %28
28: ; preds = %26, %24, %22, %19, %16, %14, %12
%29 = phi i32 [ %7, %26 ], [ %7, %24 ], [ %7, %22 ], [ %21, %19 ], [ %18, %16 ], [ %7, %14 ], [ %7, %12 ]
%30 = and i32 %9, 15
switch i32 %30, label %45 [
i32 8, label %43
i32 9, label %41
i32 4, label %38
i32 2, label %35
i32 0, label %33
i32 1, label %31
]
31: ; preds = %28
%32 = tail call i32 @putchar(i32 126)
br label %47
33: ; preds = %28
%34 = tail call i32 @putchar(i32 32)
br label %47
35: ; preds = %28
%36 = tail call i32 @putchar(i32 79)
%37 = add nsw i32 %29, 1
br label %47
38: ; preds = %28
%39 = tail call i32 @putchar(i32 46)
%40 = add nsw i32 %29, 1
br label %47
41: ; preds = %28
%42 = tail call i32 @putchar(i32 120)
br label %47
43: ; preds = %28
%44 = tail call i32 @putchar(i32 35)
br label %47
45: ; preds = %28
%46 = tail call i32 @putchar(i32 63)
br label %47
47: ; preds = %45, %43, %41, %38, %35, %33, %31
%48 = phi i32 [ %29, %45 ], [ %29, %31 ], [ %29, %33 ], [ %37, %35 ], [ %40, %38 ], [ %29, %41 ], [ %29, %43 ]
%49 = add nuw nsw i32 %8, 1
%50 = icmp eq i32 %49, 16
br i1 %50, label %51, label %6
51: ; preds = %47
%52 = tail call i32 @putchar(i32 10)
%53 = add nuw nsw i32 %5, 1
%54 = icmp eq i32 %53, 31
br i1 %54, label %55, label %3
55: ; preds = %51
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i32 %48)
%57 = tail call i32 @fclose(i32* %1)
br label %58
58: ; preds = %0, %55
%59 = phi i32 [ 0, %55 ], [ -1, %0 ]
ret i32 %59
}