#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*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read_lsb_int(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage: %s dink.dat\n", argv[0]);
    exit(1);
  }
  FILE *f = fopen(argv[1], "rb");
  if (f == NULL) {
    perror("fopen");
    exit(2);
  }
  fseek(f, 24, SEEK_SET);
  for (int i = 0; i < 768; i++) {
    printf("Screen #%03d: %d\n", (i + 1), read_lsb_int(f));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe66(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d8 <main+0x78>
lea    0xe4e(%rip),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dfd(%rip),%rax
mov    (%rax),%edx
mov    $0x18,%esi
call   1050 <fseek@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x300,-0x1c(%rbp)
jge    1236 <main+0xd6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <read_lsb_int@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f6 <main+0x96>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    11d8 <main+0x78>
mov    0x8(%rsi),%rdi
lea    0xea0(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11f3 <main+0x93>
mov    %rax,%rbx
mov    0x2e58(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x18,%esi
call   1050 <fseek@plt>
mov    $0x1,%ebp
lea    0xe7a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <read_lsb_int@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x301,%ebp
jne    11b0 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%rsi),%rsi
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe1d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Usage: %s dink.dat\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [6 x i8] c"fopen\00"
@SEEK_SET = global i32 0
@.str.3 = [18 x i8] c"Screen #%03d: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @exit(i32 2)
unreachable
26: ; preds = %16
%27 = load i32*, i32** %6
%28 = load i32, i32* @SEEK_SET
%29 = call i32 @fseek(i32* %27, i32 24, i32 %28)
store i32 0, i32* %7
br label %30
30: ; preds = %39, %26
%31 = load i32, i32* %7
%32 = icmp slt i32 %31, 768
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
%36 = load i32*, i32** %6
%37 = call i32 @read_lsb_int(i32* %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %37)
br label %39
39: ; preds = %33
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %30
42: ; preds = %30
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [20 x i8] c"Usage: %s dink.dat\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [6 x i8] c"fopen\00"
@SEEK_SET = global i32 0
@.str.3 = [18 x i8] c"Screen #%03d: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @exit(i32 2)
unreachable
16: ; preds = %8
%17 = load i32, i32* @SEEK_SET
%18 = tail call i32 @fseek(i32* %11, i32 24, i32 %17)
br label %20
19: ; preds = %20
ret i32 0
20: ; preds = %16, %20
%21 = phi i32 [ 0, %16 ], [ %22, %20 ]
%22 = add nuw nsw i32 %21, 1
%23 = tail call i32 @read_lsb_int(i32* %11)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23)
%25 = icmp eq i32 %22, 768
br i1 %25, label %19, label %20
}