#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 FILENAME_MAX;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  int n;
  unsigned long count = 0;
  unsigned char buf[16];
  FILE *fp;
  char fname[FILENAME_MAX];
  printf("Filename: ");
  scanf("%s", fname);
  if ((fp = fopen(fname, "rb")) == NULL)
    printf("\a Failed to open the file.\n");
  else {
    while ((n = fread(buf, 1, 16, fp)) > 0) {
      int i;
      printf("%08lX ", count);
      for (i = 0; i < n; i++)
        printf("%02X ", (unsigned)buf[i]);
      if (n < 16)
        for (i = n; i < 16; i++)
          printf("    ");
      for (i = 0; i < n; i++)
        putchar(isprint(buf[i]) ? buf[i] : '.');
      putchar('\n');
      count += 16;
    }
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x48(%rbp),%rsi
lea    0xe3f(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x48(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1202 <main+0x92>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1335 <main+0x1c5>
jmp    1207 <main+0x97>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1040 <fread@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    132c <main+0x1bc>
mov    -0x10(%rbp),%rsi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1274 <main+0x104>
movslq -0x3c(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1243 <main+0xd3>
cmpl   $0x10,-0x8(%rbp)
jge    12af <main+0x13f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x10,-0x3c(%rbp)
jge    12aa <main+0x13a>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1284 <main+0x114>
jmp    12af <main+0x13f>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1311 <main+0x1a1>
movslq -0x3c(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%edi
call   1080 <isprint@plt>
cmp    $0x0,%rax
je     12eb <main+0x17b>
movslq -0x3c(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%eax
mov    %eax,-0x4c(%rbp)
jmp    12f8 <main+0x188>
mov    $0x2e,%eax
mov    %eax,-0x4c(%rbp)
jmp    12f8 <main+0x188>
mov    -0x4c(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12b6 <main+0x146>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    1207 <main+0x97>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsp,%r14
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe48(%rip),%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
lea    0xe3c(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1317 <main+0x197>
mov    %rax,%rbx
mov    %r14,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %rax,%rcx
call   1050 <fread@plt>
test   %eax,%eax
jle    1309 <main+0x189>
mov    %eax,%r13d
lea    0xe06(%rip),%r15
lea    0xe05(%rip),%r12
mov    $0x2e,%r14d
xor    %esi,%esi
mov    %rbx,-0x50(%rbp)
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xdda(%rip),%rdi
mov    %rsi,-0x58(%rbp)
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%r13d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl -0x40(%rbp,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1250 <main+0xd0>
cmp    $0xf,%r13d
jg     128e <main+0x10e>
lea    -0x10(%r13),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
inc    %ebx
jne    1280 <main+0x100>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl -0x40(%rbp,%r12,1),%ebx
mov    %ebx,%edi
call   1090 <isprint@plt>
test   %rax,%rax
cmove  %r14d,%ebx
movsbl %bl,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    %r12,%r13
jne    12a0 <main+0x120>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x58(%rbp),%rbx
add    $0x10,%rbx
lea    -0x40(%rbp),%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    -0x50(%rbp),%r12
mov    %r12,%rcx
call   1050 <fread@plt>
mov    %rbx,%rsi
mov    %r12,%rbx
mov    %eax,%r13d
test   %eax,%eax
lea    0xd1b(%rip),%r12
jg     1230 <main+0xb0>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    -0x48(%rbp),%r14
jmp    1323 <main+0x1a3>
lea    0xd05(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@FILENAME_MAX = global i32 0
@.str = [11 x i8] c"Filename: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [28 x i8] c"\07 Failed to open the file.\0A\00"
@.str.4 = [7 x i8] c"%08lX \00"
@.str.5 = [6 x i8] c"%02X \00"
@.str.6 = [5 x i8] c" \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca [16 x i8]
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %3
%9 = load i32, i32* @FILENAME_MAX
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i8, i64 %10
store i64 %10, i64* %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%15 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %15, i32** %5
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %89
19: ; preds = %0
br label %20
20: ; preds = %82, %19
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%22 = load i32*, i32** %5
%23 = call i32 @fread(i8* %21, i32 1, i32 16, i32* %22)
store i32 %23, i32* %2
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %86
25: ; preds = %20
%26 = load i64, i64* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 %26)
store i32 0, i32* %8
br label %28
28: ; preds = %39, %25
%29 = load i32, i32* %8
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %28
42: ; preds = %28
%43 = load i32, i32* %2
%44 = icmp slt i32 %43, 16
br i1 %44, label %45, label %56
45: ; preds = %42
%46 = load i32, i32* %2
store i32 %46, i32* %8
br label %47
47: ; preds = %52, %45
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 16
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %52
52: ; preds = %50
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %47
55: ; preds = %47
br label %56
56: ; preds = %55, %42
store i32 0, i32* %8
br label %57
57: ; preds = %79, %56
%58 = load i32, i32* %8
%59 = load i32, i32* %2
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %82
61: ; preds = %57
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = call i64 @isprint(i8 zeroext %65)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %61
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
br label %75
74: ; preds = %61
br label %75
75: ; preds = %74, %68
%76 = phi i32 [ %73, %68 ], [ 46, %74 ]
%77 = trunc i32 %76 to i8
%78 = call i32 @putchar(i8 signext %77)
br label %79
79: ; preds = %75
%80 = load i32, i32* %8
%81 = add nsw i32 %80, 1
store i32 %81, i32* %8
br label %57
82: ; preds = %57
%83 = call i32 @putchar(i8 signext 10)
%84 = load i64, i64* %3
%85 = add i64 %84, 16
store i64 %85, i64* %3
br label %20
86: ; preds = %20
%87 = load i32*, i32** %5
%88 = call i32 @fclose(i32* %87)
br label %89
89: ; preds = %86, %17
store i32 0, i32* %1
%90 = load i8*, i8** %6
%91 = load i32, i32* %1
ret i32 %91
}

LLVM IR (-O2):
@FILENAME_MAX = global i32 0
@.str = [11 x i8] c"Filename: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.4 = [7 x i8] c"%08lX \00"
@.str.5 = [6 x i8] c"%02X \00"
@.str.6 = [5 x i8] c" \00"
@str = [27 x i8] c"\07 Failed to open the file.\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @FILENAME_MAX
%4 = zext i32 %3 to i64
%5 = tail call i8* @llvm.stacksave()
%6 = alloca i8, i64 %4
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%9 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = call i32 @fread(i8* %2, i32 1, i32 16, i32* %9)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %16, label %53
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %55
16: ; preds = %11, %48
%17 = phi i32 [ %51, %48 ], [ %12, %11 ]
%18 = phi i64 [ %50, %48 ], [ 0, %11 ]
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 %18)
%20 = zext i32 %17 to i64
br label %21
21: ; preds = %16, %21
%22 = phi i64 [ 0, %16 ], [ %27, %21 ]
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i64 %22, 1
%28 = icmp eq i64 %27, %20
br i1 %28, label %29, label %21
29: ; preds = %21
%30 = icmp slt i32 %17, 16
br i1 %30, label %31, label %36
31: ; preds = %29, %31
%32 = phi i32 [ %34, %31 ], [ %17, %29 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%34 = add i32 %32, 1
%35 = icmp eq i32 %34, 16
br i1 %35, label %36, label %31
36: ; preds = %31, %29
%37 = zext i32 %17 to i64
br label %38
38: ; preds = %36, %38
%39 = phi i64 [ 0, %36 ], [ %46, %38 ]
%40 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = call i64 @isprint(i8 zeroext %41)
%43 = icmp eq i64 %42, 0
%44 = select i1 %43, i8 46, i8 %41
%45 = call i32 @putchar(i8 signext %44)
%46 = add nuw nsw i64 %39, 1
%47 = icmp eq i64 %46, %37
br i1 %47, label %48, label %38
48: ; preds = %38
%49 = call i32 @putchar(i8 signext 10)
%50 = add i64 %18, 16
%51 = call i32 @fread(i8* %2, i32 1, i32 16, i32* %9)
%52 = icmp sgt i32 %51, 0
br i1 %52, label %16, label %53
53: ; preds = %48, %11
%54 = call i32 @fclose(i32* %9)
br label %55
55: ; preds = %53, %14
ret i32 0
}