#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*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
size_t read(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  unsigned char buffer[16];
  size_t offset = 0;
  size_t bytes_read;
  int i;
  int fd = open(argv[1], O_RDONLY);
  do {
    bytes_read = read(fd, buffer, sizeof(buffer));
    printf("0x%06x : ", offset);
    for (i = 0; i < bytes_read; ++i)
      printf("%02x ", buffer[i]);
    printf("\n");
    offset += bytes_read;
  } while (bytes_read == sizeof(buffer));
  close(fd);
  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,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1050 <read@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    11d8 <main+0x98>
movslq -0x34(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a5 <main+0x65>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x10,-0x30(%rbp)
je     1177 <main+0x37>
mov    -0x38(%rbp),%edi
call   1040 <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
sub    $0x18,%rsp
mov    0x8(%rsi),%rdi
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,%r12d
lea    0xe86(%rip),%r15
lea    0xe89(%rip),%rbx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%edi
mov    %rsp,%rsi
mov    $0x10,%edx
call   1060 <read@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbp,%rbp
je     11ed <main+0x9d>
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%r14,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    11c0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    %rbp,%r13
cmp    $0x10,%rbp
je     1190 <main+0x40>
jmp    11f7 <main+0xa7>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12d,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [10 x i8] c"0x%06x : \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [16 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
%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
br label %16
16: ; preds = %42, %2
%17 = load i32, i32* %10
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%19 = call i64 @read(i32 %17, i8* %18, i32 16)
store i64 %19, i64* %8
%20 = load i64, i64* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %20)
store i32 0, i32* %9
br label %22
22: ; preds = %34, %16
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = load i64, i64* %8
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %37
27: ; preds = %22
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %22
37: ; preds = %22
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%39 = load i64, i64* %8
%40 = load i64, i64* %7
%41 = add i64 %40, %39
store i64 %41, i64* %7
br label %42
42: ; preds = %37
%43 = load i64, i64* %8
%44 = icmp eq i64 %43, 16
br i1 %44, label %16, label %45
45: ; preds = %42
%46 = load i32, i32* %10
%47 = call i32 @close(i32 %46)
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [10 x i8] c"0x%06x : \00"
@.str.1 = [6 x i8] c"%02x \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%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)
br label %9
9: ; preds = %24, %2
%10 = phi i64 [ 0, %2 ], [ %26, %24 ]
%11 = call i64 @read(i32 %8, i8* %4, i32 16)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %10)
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @putchar(i32 10)
br label %28
16: ; preds = %9, %16
%17 = phi i64 [ %22, %16 ], [ 0, %9 ]
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = add nuw i64 %17, 1
%23 = icmp eq i64 %22, %11
br i1 %23, label %24, label %16
24: ; preds = %16
%25 = tail call i32 @putchar(i32 10)
%26 = add i64 %11, %10
%27 = icmp eq i64 %11, 16
br i1 %27, label %9, label %28
28: ; preds = %24, %14
%29 = tail call i32 @close(i32 %8)
ret i32 0
}