#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
size_t fread(unsigned long *, int, int, int /*<<< orphan*/ *);
unsigned long *malloc(int);
int /*<<< orphan*/ printf(char *, unsigned long);
int /*<<< orphan*/ stderr;
void dump(char *file) {
  unsigned long int terms, i, *crap;
  size_t elts_read;
  crap = malloc(sizeof(unsigned long int) * 262144);
  assert(crap != NULL);
  FILE *fp = fopen(file, "rb");
  if (fp == NULL) {
    fprintf(stderr, "\ndump(): Cant open %s\n", file);
    return;
  }
  fread(&terms, sizeof(unsigned long int), 1, fp);
  do {
    elts_read = fread(crap, sizeof(unsigned long int), 262144, fp);
    for (i = 0; i < elts_read; i++)
      printf("%lu\n", crap[i]);
  } while (elts_read == 262144);
  fclose(fp);
  return;
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x200000,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11d9 <dump+0x69>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe34(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1266 <dump+0xf6>
mov    -0x30(%rbp),%rcx
lea    -0x10(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x8,%esi
mov    $0x40000,%edx
call   1030 <fread@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    124a <dump+0xda>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xde6(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1213 <dump+0xa3>
jmp    124f <dump+0xdf>
cmpq   $0x40000,-0x28(%rbp)
je     11f0 <dump+0x80>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
mov    $0x200000,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
lea    0xe5e(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1223 <dump+0xb3>
mov    %rax,%r14
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
lea    0xe4a(%rip),%r15
mov    %r12,%rdi
mov    $0x8,%esi
mov    $0x40000,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     120e <dump+0x9e>
mov    %rax,%r13
xor    %ebx,%ebx
nop
mov    (%r12,%rbx,8),%rsi
mov    %r15,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11f0 <dump+0x80>
cmp    $0x40000,%r13
je     11d0 <dump+0x60>
mov    %r14,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
mov    %r15,%rdx
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1070 <fprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"\0Adump(): Cant open %s\0A\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
define void @dump(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i32*
store i8* %0, i8** %2
%8 = call i64* @malloc(i32 2097152)
store i64* %8, i64** %5
%9 = load i64*, i64** %5
%10 = icmp ne i64* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i8*, i8** %2
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %2
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %48
21: ; preds = %1
%22 = load i32*, i32** %7
%23 = call i64 @fread(i64* %3, i32 8, i32 1, i32* %22)
br label %24
24: ; preds = %42, %21
%25 = load i64*, i64** %5
%26 = load i32*, i32** %7
%27 = call i64 @fread(i64* %25, i32 8, i32 262144, i32* %26)
store i64 %27, i64* %6
store i64 0, i64* %4
br label %28
28: ; preds = %38, %24
%29 = load i64, i64* %4
%30 = load i64, i64* %6
%31 = icmp ult i64 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i64*, i64** %5
%34 = load i64, i64* %4
%35 = getelementptr inbounds i64, i64* %33, i64 %34
%36 = load i64, i64* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %36)
br label %38
38: ; preds = %32
%39 = load i64, i64* %4
%40 = add i64 %39, 1
store i64 %40, i64* %4
br label %28
41: ; preds = %28
br label %42
42: ; preds = %41
%43 = load i64, i64* %6
%44 = icmp eq i64 %43, 262144
br i1 %44, label %24, label %45
45: ; preds = %42
%46 = load i32*, i32** %7
%47 = call i32 @fclose(i32* %46)
br label %48
48: ; preds = %45, %17
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"\0Adump(): Cant open %s\0A\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
define void @dump(i8* %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = tail call i64* @malloc(i32 2097152)
%5 = icmp ne i64* %4, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %29
13: ; preds = %1
%14 = call i64 @fread(i64* %2, i32 8, i32 1, i32* %8)
br label %15
15: ; preds = %25, %13
%16 = tail call i64 @fread(i64* %4, i32 8, i32 262144, i32* %8)
%17 = icmp eq i64 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %15, %18
%19 = phi i64 [ %23, %18 ], [ 0, %15 ]
%20 = getelementptr inbounds i64, i64* %4, i64 %19
%21 = load i64, i64* %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %21)
%23 = add nuw i64 %19, 1
%24 = icmp eq i64 %23, %16
br i1 %24, label %25, label %18
25: ; preds = %18
%26 = icmp eq i64 %16, 262144
br i1 %26, label %15, label %27
27: ; preds = %15, %25
%28 = tail call i32 @fclose(i32* %8)
br label %29
29: ; preds = %27, %10
ret void
}