#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_END;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
size_t fread(unsigned char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main() {
  FILE *pFile;
  long lSize;
  unsigned char *buffer;
  size_t result;
  pFile = fopen("hg19.2bit", "rb");
  if (pFile == NULL) {
    fputs("File error", stderr);
    exit(1);
  }
  fseek(pFile, 0, SEEK_END);
  lSize = ftell(pFile);
  printf("%f\n", (float)lSize);
  rewind(pFile);
  buffer = (unsigned char *)malloc(sizeof(unsigned char) * lSize);
  if (buffer == NULL) {
    fputs("Memory error", stderr);
    exit(2);
  }
  result = fread(buffer, 1, lSize, pFile);
  if (result != lSize) {
    fputs("Reading error", stderr);
    exit(3);
  }
  int i;
  for (i = 0; i < lSize; i++) {
    printf("%d\n", *(buffer + i));
  }
  fclose(pFile);
  free(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe3a(%rip),%rdi
lea    0xe3d(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1200 <main+0x50>
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
lea    0xe1c(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    0x2ddd(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%al
lea    0xded(%rip),%rdi
movzbl %al,%esi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1279 <main+0xc9>
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
lea    0xdb2(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     12c0 <main+0x110>
mov    0x2d30(%rip),%rax
mov    (%rax),%esi
lea    0xd78(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x3,%edi
call   10d0 <exit@plt>
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    12fb <main+0x14b>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
lea    0xd53(%rip),%rdi
movzbl (%rax,%rcx,1),%esi
call   1060 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12c7 <main+0x117>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xe40(%rip),%rdi
lea    0xe43(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1283 <main+0xd3>
mov    %rax,%r14
mov    0x2e09(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r14,%rdi
call   1090 <ftell@plt>
mov    %rax,%r15
movzbl %r15b,%esi
lea    0xe17(%rip),%rdi
call   1060 <printf@plt>
mov    %r14,%rdi
call   1070 <rewind@plt>
mov    %r15d,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     12a2 <main+0xf2>
mov    %rax,%r13
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    %r15,%rax
jne    12c1 <main+0x111>
test   %r15,%r15
jle    1267 <main+0xb7>
xor    %ebx,%ebx
lea    0xdeb(%rip),%r12
nopl   0x0(%rax)
movzbl 0x0(%r13,%rbx,1),%esi
mov    %r12,%rdi
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1250 <main+0xa0>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
lea    0xd7a(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2d2f(%rip),%rax
mov    (%rax),%esi
lea    0xd6a(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%esi
lea    0xd58(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x3,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"hg19.2bit\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [11 x i8] c"File error\00"
@stderr = global i32 0
@SEEK_END = global i32 0
@.str.3 = [4 x i8] c"%f\0A\00"
@.str.4 = [13 x i8] c"Memory error\00"
@.str.5 = [14 x i8] c"Reading error\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = load i32*, i32** %2
%16 = load i32, i32* @SEEK_END
%17 = call i32 @fseek(i32* %15, i32 0, i32 %16)
%18 = load i32*, i32** %2
%19 = call i64 @ftell(i32* %18)
store i64 %19, i64* %3
%20 = load i64, i64* %3
%21 = sitofp i64 %20 to float
%22 = fptoui float %21 to i8
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %22)
%24 = load i32*, i32** %2
%25 = call i32 @rewind(i32* %24)
%26 = load i64, i64* %3
%27 = mul i64 1, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %4
%31 = load i8*, i8** %4
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %37
33: ; preds = %14
%34 = load i32, i32* @stderr
%35 = call i32 @fputs(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = call i32 @exit(i32 2)
unreachable
37: ; preds = %14
%38 = load i8*, i8** %4
%39 = load i64, i64* %3
%40 = load i32*, i32** %2
%41 = call i64 @fread(i8* %38, i32 1, i64 %39, i32* %40)
store i64 %41, i64* %5
%42 = load i64, i64* %5
%43 = load i64, i64* %3
%44 = icmp ne i64 %42, %43
br i1 %44, label %45, label %49
45: ; preds = %37
%46 = load i32, i32* @stderr
%47 = call i32 @fputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %46)
%48 = call i32 @exit(i32 3)
unreachable
49: ; preds = %37
store i32 0, i32* %6
br label %50
50: ; preds = %62, %49
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = load i64, i64* %3
%54 = icmp slt i64 %52, %53
br i1 %54, label %55, label %65
55: ; preds = %50
%56 = load i8*, i8** %4
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8 zeroext %60)
br label %62
62: ; preds = %55
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %50
65: ; preds = %50
%66 = load i32*, i32** %2
%67 = call i32 @fclose(i32* %66)
%68 = load i8*, i8** %4
%69 = call i32 @free(i8* %68)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"hg19.2bit\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [11 x i8] c"File error\00"
@stderr = global i32 0
@SEEK_END = global i32 0
@.str.3 = [4 x i8] c"%f\0A\00"
@.str.4 = [13 x i8] c"Memory error\00"
@.str.5 = [14 x i8] c"Reading error\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 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 %3, label %7
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = load i32, i32* @SEEK_END
%9 = tail call i32 @fseek(i32* %1, i32 0, i32 %8)
%10 = tail call i64 @ftell(i32* %1)
%11 = trunc i64 %10 to i8
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %11)
%13 = tail call i32 @rewind(i32* %1)
%14 = trunc i64 %10 to i32
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
%17 = icmp eq i64 %15, 0
br i1 %17, label %18, label %22
18: ; preds = %7
%19 = load i32, i32* @stderr
%20 = tail call i32 @fputs(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = tail call i32 @exit(i32 2)
unreachable
22: ; preds = %7
%23 = tail call i64 @fread(i8* %16, i32 1, i64 %10, i32* %1)
%24 = icmp eq i64 %23, %10
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = icmp sgt i64 %10, 0
br i1 %26, label %31, label %38
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = tail call i32 @fputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = tail call i32 @exit(i32 3)
unreachable
31: ; preds = %25, %31
%32 = phi i64 [ %36, %31 ], [ 0, %25 ]
%33 = getelementptr inbounds i8, i8* %16, i64 %32
%34 = load i8, i8* %33
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8 zeroext %34)
%36 = add nuw nsw i64 %32, 1
%37 = icmp eq i64 %36, %10
br i1 %37, label %38, label %31
38: ; preds = %31, %25
%39 = tail call i32 @fclose(i32* %1)
%40 = tail call i32 @free(i8* %16)
ret i32 0
}