#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_CUR;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
unsigned char getc(int /*<<< orphan*/ *);
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
void HexDump(FILE *f, long FileLength, long offset) {
  unsigned char b[16];
  long l;
  int n, i;
  puts("[-Addr-] [--------------------Data---------------------] "
       "[-----Text-----]");
  fseek(f, offset, SEEK_CUR);
  for (l = offset; l < FileLength; l += 16) {
    printf("%08lX ", l);
    n = (int)(FileLength - l > 16 ? 16 : FileLength - l);
    for (i = 0; i < n; i++)
      printf("%02X ", b[i] = getc(f));
    while (i++ < 16)
      printf("	 ");
    for (i = 0; i < n; i++)
      putchar(isprint(b[i]) ? b[i] : '.');
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<HexDump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe85(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e59(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    12dd <HexDump+0x17d>
mov    -0x38(%rbp),%rsi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
sub    -0x38(%rbp),%rax
cmp    $0x10,%rax
jle    11de <HexDump+0x7e>
mov    $0x10,%eax
mov    %rax,-0x48(%rbp)
jmp    11ea <HexDump+0x8a>
mov    -0x10(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1234 <HexDump+0xd4>
mov    -0x8(%rbp),%rdi
call   1080 <getc@plt>
movslq -0x40(%rbp),%rcx
mov    %al,-0x30(%rbp,%rcx,1)
movzbl %al,%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11f8 <HexDump+0x98>
jmp    1239 <HexDump+0xd9>
mov    -0x40(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp)
cmp    $0x10,%eax
jge    1260 <HexDump+0x100>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1239 <HexDump+0xd9>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    12c2 <HexDump+0x162>
movslq -0x40(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%edi
call   1070 <isprint@plt>
cmp    $0x0,%rax
je     129c <HexDump+0x13c>
movslq -0x40(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%eax
mov    %eax,-0x4c(%rbp)
jmp    12a9 <HexDump+0x149>
mov    $0x2e,%eax
mov    %eax,-0x4c(%rbp)
jmp    12a9 <HexDump+0x149>
mov    -0x4c(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1267 <HexDump+0x107>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
jmp    119e <HexDump+0x3e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HexDump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <fseek@plt>
cmp    %r12,%rbx
jge    129c <HexDump+0x13c>
lea    0xeb0(%rip),%r15
mov    %r12,(%rsp)
jmp    11d0 <HexDump+0x70>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%rbx
add    $0x10,%rbx
mov    (%rsp),%r12
cmp    %r12,%rbx
jge    129c <HexDump+0x13c>
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
sub    %rbx,%r12
cmp    $0x10,%r12
mov    $0x10,%eax
cmovge %rax,%r12
mov    $0x0,%ebp
test   %r12d,%r12d
mov    %rbx,0x8(%rsp)
jle    1237 <HexDump+0xd7>
movslq %r12d,%r13
xor    %ebp,%ebp
lea    0xe45(%rip),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1080 <getc@plt>
mov    %al,0x10(%rsp,%rbp,1)
movzbl %al,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
jl     1210 <HexDump+0xb0>
cmp    $0xf,%ebp
ja     124e <HexDump+0xee>
add    $0xfffffff0,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
inc    %ebp
jne    1240 <HexDump+0xe0>
test   %r12d,%r12d
mov    $0x2e,%r13d
jle    11b0 <HexDump+0x50>
movslq %r12d,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x10(%rsp,%rbx,1),%r12d
mov    %r12d,%edi
call   1070 <isprint@plt>
test   %rax,%rax
cmove  %r13d,%r12d
movsbl %r12b,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbp,%rbx
jl     1270 <HexDump+0x110>
jmp    11b0 <HexDump+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [74 x i8] c"[-Addr-] [--------------------Data---------------------] [-----Text-----]\00"
@SEEK_CUR = global i32 0
@.str.1 = [7 x i8] c"%08lX \00"
@.str.2 = [6 x i8] c"%02X \00"
@.str.3 = [3 x i8] c"\09 \00"
define void @HexDump(i32* nocapture %0, i64 %1, i64 %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @SEEK_CUR
%8 = tail call i32 @fseek(i32* %0, i64 %2, i32 %7)
%9 = icmp slt i64 %2, %1
br i1 %9, label %10, label %57
10: ; preds = %3, %53
%11 = phi i64 [ %55, %53 ], [ %2, %3 ]
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%13 = sub nsw i64 %1, %11
%14 = icmp slt i64 %13, 16
%15 = select i1 %14, i64 %13, i64 16
%16 = trunc i64 %15 to i32
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %10
%19 = shl i64 %15, 32
%20 = ashr exact i64 %19, 32
br label %26
21: ; preds = %26
%22 = trunc i64 %32 to i32
%23 = icmp ult i32 %22, 16
br i1 %23, label %24, label %34
24: ; preds = %10, %21
%25 = phi i32 [ 0, %10 ], [ %22, %21 ]
br label %38
26: ; preds = %18, %26
%27 = phi i64 [ 0, %18 ], [ %32, %26 ]
%28 = tail call zeroext i8 @getc(i32* %0)
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %27
store i8 %28, i8* %29
%30 = zext i8 %28 to i32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = add nuw nsw i64 %27, 1
%33 = icmp slt i64 %32, %20
br i1 %33, label %26, label %21
34: ; preds = %38, %21
br i1 %17, label %35, label %53
35: ; preds = %34
%36 = shl i64 %15, 32
%37 = ashr exact i64 %36, 32
br label %43
38: ; preds = %24, %38
%39 = phi i32 [ %40, %38 ], [ %25, %24 ]
%40 = add nuw i32 %39, 1
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i32 %40, 16
br i1 %42, label %34, label %38
43: ; preds = %35, %43
%44 = phi i64 [ 0, %35 ], [ %51, %43 ]
%45 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = tail call i64 @isprint(i8 zeroext %46)
%48 = icmp eq i64 %47, 0
%49 = select i1 %48, i8 46, i8 %46
%50 = tail call i32 @putchar(i8 signext %49)
%51 = add nuw nsw i64 %44, 1
%52 = icmp slt i64 %51, %37
br i1 %52, label %43, label %53
53: ; preds = %43, %34
%54 = tail call i32 @putchar(i8 signext 10)
%55 = add nsw i64 %11, 16
%56 = icmp slt i64 %55, %1
br i1 %56, label %10, label %57
57: ; preds = %53, %3
ret void
}