#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 */
struct stat {
  int st_size;
};

/* Variables and functions */
int /*<<< orphan*/ MAP_PRIVATE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fstat(int, struct stat *);
unsigned long *mmap(int /*<<< orphan*/, int, int /*<<< orphan*/,
                    int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(unsigned long *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  long size = 0;
  unsigned long c;
  unsigned long *f1_hash = NULL;
  struct stat info1;
  int f1 = open(argv[1], O_RDONLY);
  if (fstat(f1, &info1)) {
    printf("stat error\n");
    exit(0);
  }
  f1_hash = mmap(0, info1.st_size, PROT_READ, MAP_PRIVATE, f1, 0);
  size = info1.st_size / sizeof(unsigned long);
  for (c = 0; c < size; c++) {
    printf("%lu %lu\n", f1_hash[c], c);
  }
  munmap(f1_hash, info1.st_size);
  close(f1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1090 <fstat@plt>
cmp    $0x0,%rax
je     11da <main+0x6a>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x30(%rbp),%esi
mov    0x2e14(%rip),%rax
mov    (%rax),%edx
mov    0x2de3(%rip),%rax
mov    (%rax),%ecx
mov    -0x34(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x28(%rbp)
movslq -0x30(%rbp),%rax
shr    $0x3,%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1253 <main+0xe3>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%rdx
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1216 <main+0xa6>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1060 <munmap@plt>
mov    -0x34(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,%r14d
mov    %rsp,%rsi
mov    %eax,%edi
call   10a0 <fstat@plt>
test   %rax,%rax
jne    123f <main+0xbf>
movslq (%rsp),%r15
mov    0x2e3a(%rip),%rax
mov    (%rax),%edx
mov    0x2e09(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r15d,%esi
mov    %r14d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%r13
cmp    $0x8,%r15
jb     121b <main+0x9b>
mov    %r15,%rax
shr    $0x3,%rax
cmp    $0x2,%rax
mov    $0x1,%ebp
cmovae %rax,%rbp
lea    0xe03(%rip),%r12
xor    %ebx,%ebx
nop
mov    0x0(%r13,%rbx,8),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1200 <main+0x80>
mov    %r13,%rdi
mov    %r15d,%esi
call   1070 <munmap@plt>
mov    %r14d,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc3(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@.str = [12 x i8] c"stat error\0A\00"
@PROT_READ = global i32 0
@MAP_PRIVATE = global i32 0
@.str.1 = [9 x i8] c"%lu %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64*
%9 = alloca %struct.stat
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i64* null, i64** %8
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = call i64 @fstat(i32 %16, %struct.stat* %9)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %2
%23 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load i32, i32* @PROT_READ
%26 = load i32, i32* @MAP_PRIVATE
%27 = load i32, i32* %10
%28 = call i64* @mmap(i32 0, i32 %24, i32 %25, i32 %26, i32 %27, i32 0)
store i64* %28, i64** %8
%29 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%30 = load i32, i32* %29
%31 = sext i32 %30 to i64
%32 = udiv i64 %31, 8
store i64 %32, i64* %6
store i64 0, i64* %7
br label %33
33: ; preds = %44, %22
%34 = load i64, i64* %7
%35 = load i64, i64* %6
%36 = icmp ult i64 %34, %35
br i1 %36, label %37, label %47
37: ; preds = %33
%38 = load i64*, i64** %8
%39 = load i64, i64* %7
%40 = getelementptr inbounds i64, i64* %38, i64 %39
%41 = load i64, i64* %40
%42 = load i64, i64* %7
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 %41, i64 %42)
br label %44
44: ; preds = %37
%45 = load i64, i64* %7
%46 = add i64 %45, 1
store i64 %46, i64* %7
br label %33
47: ; preds = %33
%48 = load i64*, i64** %8
%49 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%50 = load i32, i32* %49
%51 = call i32 @munmap(i64* %48, i32 %50)
%52 = load i32, i32* %10
%53 = call i32 @close(i32 %52)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_PRIVATE = global i32 0
@.str.1 = [9 x i8] c"%lu %lu\0A\00"
@str = [11 x i8] c"stat error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* %6, i32 %7)
%9 = call i64 @fstat(i32 %8, %struct.stat* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* @PROT_READ
%18 = load i32, i32* @MAP_PRIVATE
%19 = tail call i64* @mmap(i32 0, i32 %16, i32 %17, i32 %18, i32 %8, i32 0)
%20 = icmp ult i32 %16, 8
br i1 %20, label %32, label %21
21: ; preds = %14
%22 = sext i32 %16 to i64
%23 = lshr i64 %22, 3
%24 = call i64 @llvm.umax.i64(i64 %23, i64 1)
br label %25
25: ; preds = %21, %25
%26 = phi i64 [ %30, %25 ], [ 0, %21 ]
%27 = getelementptr inbounds i64, i64* %19, i64 %26
%28 = load i64, i64* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 %28, i64 %26)
%30 = add nuw nsw i64 %26, 1
%31 = icmp eq i64 %30, %24
br i1 %31, label %32, label %25
32: ; preds = %25, %14
%33 = tail call i32 @munmap(i64* %19, i32 %16)
%34 = tail call i32 @close(i32 %8)
ret i32 0
}