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

/* Variables and functions */
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
void HexDumpMemory(unsigned char *bypMem, unsigned int FileLength) {
  unsigned char b[16];
  unsigned int l;
  int n, i;
  puts("[-Addr-] [--------------------Data---------------------] "
       "[-----Text-----]");
  for (l = 0; l < FileLength; l += 16) {
    printf("%08X ", l);
    n = (int)(FileLength - l > 16 ? 16 : FileLength - l);
    for (i = 0; i < n; i++)
      printf("%02X ", b[i] = *bypMem++);
    while (i++ < 16)
      printf("	 ");
    for (i = 0; i < n; i++)
      putchar(isprint(b[i]) ? b[i] : '.');
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<HexDumpMemory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    129b <HexDumpMemory+0x15b>
mov    -0x24(%rbp),%esi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    $0x10,%eax
jbe    119b <HexDumpMemory+0x5b>
mov    $0x10,%eax
mov    %eax,-0x30(%rbp)
jmp    11a4 <HexDumpMemory+0x64>
mov    -0xc(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11f5 <HexDumpMemory+0xb5>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
movslq -0x2c(%rbp),%rcx
mov    %al,-0x20(%rbp,%rcx,1)
movzbl %al,%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b1 <HexDumpMemory+0x71>
jmp    11fa <HexDumpMemory+0xba>
mov    -0x2c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x2c(%rbp)
cmp    $0x10,%eax
jge    1221 <HexDumpMemory+0xe1>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11fa <HexDumpMemory+0xba>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1283 <HexDumpMemory+0x143>
movslq -0x2c(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     125d <HexDumpMemory+0x11d>
movslq -0x2c(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%eax
mov    %eax,-0x34(%rbp)
jmp    126a <HexDumpMemory+0x12a>
mov    $0x2e,%eax
mov    %eax,-0x34(%rbp)
jmp    126a <HexDumpMemory+0x12a>
mov    -0x34(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1228 <HexDumpMemory+0xe8>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x24(%rbp)
jmp    1162 <HexDumpMemory+0x22>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HexDumpMemory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
test   %r14d,%r14d
je     126c <HexDumpMemory+0x12c>
lea    0xee6(%rip),%r12
lea    0xed9(%rip),%rbx
xor    %ebp,%ebp
mov    %r14d,0x8(%rsp)
jmp    11ad <HexDumpMemory+0x6d>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%ebp
add    $0x10,%ebp
mov    0x8(%rsp),%r14d
cmp    %r14d,%ebp
lea    0xeb0(%rip),%rbx
lea    0xeaf(%rip),%r12
jae    126c <HexDumpMemory+0x12c>
lea    0xe96(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
sub    %ebp,%r14d
cmp    $0x10,%r14d
mov    $0x10,%eax
cmovae %eax,%r14d
mov    %r14d,%r13d
test   %r14d,%r14d
mov    %ebp,0xc(%rsp)
je     1210 <HexDumpMemory+0xd0>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbp,1),%esi
mov    %sil,0x10(%rsp,%rbp,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
jb     11e0 <HexDumpMemory+0xa0>
add    %rbp,%r15
cmp    $0xf,%ebp
jbe    1212 <HexDumpMemory+0xd2>
jmp    122e <HexDumpMemory+0xee>
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
add    $0xfffffff0,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
inc    %ebp
jne    1220 <HexDumpMemory+0xe0>
test   %r14d,%r14d
mov    $0x2e,%r12d
je     1180 <HexDumpMemory+0x40>
xor    %ebp,%ebp
nop
movzbl 0x10(%rsp,%rbp,1),%r14d
mov    %r14d,%edi
call   1060 <isprint@plt>
test   %rax,%rax
cmove  %r12d,%r14d
movsbl %r14b,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
jb     1240 <HexDumpMemory+0x100>
jmp    1180 <HexDumpMemory+0x40>
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"
@.str.1 = [6 x i8] c"%08X \00"
@.str.2 = [6 x i8] c"%02X \00"
@.str.3 = [3 x i8] c"\09 \00"
define void @HexDumpMemory(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [16 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = call i32 @puts(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %10
10: ; preds = %79, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %82
14: ; preds = %10
%15 = load i32, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %4
%18 = load i32, i32* %6
%19 = sub i32 %17, %18
%20 = icmp ugt i32 %19, 16
br i1 %20, label %21, label %22
21: ; preds = %14
br label %26
22: ; preds = %14
%23 = load i32, i32* %4
%24 = load i32, i32* %6
%25 = sub i32 %23, %24
br label %26
26: ; preds = %22, %21
%27 = phi i32 [ 16, %21 ], [ %25, %22 ]
store i32 %27, i32* %7
store i32 0, i32* %8
br label %28
28: ; preds = %41, %26
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %44
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
%35 = load i8, i8* %33
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %37
store i8 %35, i8* %38
%39 = zext i8 %35 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %32
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %28
44: ; preds = %28
br label %45
45: ; preds = %49, %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
%48 = icmp slt i32 %46, 16
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %45
51: ; preds = %45
store i32 0, i32* %8
br label %52
52: ; preds = %74, %51
%53 = load i32, i32* %8
%54 = load i32, i32* %7
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %77
56: ; preds = %52
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = call i64 @isprint(i8 zeroext %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %56
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
br label %70
69: ; preds = %56
br label %70
70: ; preds = %69, %63
%71 = phi i32 [ %68, %63 ], [ 46, %69 ]
%72 = trunc i32 %71 to i8
%73 = call i32 @putchar(i8 signext %72)
br label %74
74: ; preds = %70
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %52
77: ; preds = %52
%78 = call i32 @putchar(i8 signext 10)
br label %79
79: ; preds = %77
%80 = load i32, i32* %6
%81 = add i32 %80, 16
store i32 %81, i32* %6
br label %10
82: ; preds = %10
ret void
}

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