#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 */
int /*<<< orphan*/ printf(char *, ...);
void DumpMemory(const char *BufferName, const unsigned char *BufferStart,
                const unsigned int BufferLen) {
  int i;
  printf("DUMP %s: ...................................\n", BufferName);
  const int maxLen = (BufferLen > 32) ? 32 : BufferLen;
  for (i = 0; i < maxLen; i++) {
    if (!(i & 0x7)) {
      printf("\n%p\t", &BufferStart[i]);
    }
    printf("%02x ", BufferStart[i]);
  }
  printf("\n...................................................\n");
}


x86 assembly (clang, -O0):
<DumpMemory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x20,-0x14(%rbp)
jbe    114c <DumpMemory+0x3c>
mov    $0x20,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <DumpMemory+0x42>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bb <DumpMemory+0xab>
mov    -0x18(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    1193 <DumpMemory+0x83>
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <DumpMemory+0x4f>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DumpMemory>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x20,%ebp
mov    $0x20,%eax
cmovb  %ebp,%eax
test   %eax,%eax
je     119d <DumpMemory+0x7d>
mov    %eax,%r12d
lea    0xed7(%rip),%r14
lea    0xed5(%rip),%r15
xor    %ebp,%ebp
jmp    1187 <DumpMemory+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx,%rbp,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
je     119d <DumpMemory+0x7d>
test   $0x7,%bpl
jne    1170 <DumpMemory+0x50>
lea    (%rbx,%rbp,1),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <DumpMemory+0x50>
lea    0xe95(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"DUMP %s: ...................................\0A\00"
@.str.1 = [5 x i8] c"\0A%p\09\00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [54 x i8] c"\0A...................................................\0A\00"
define void @DumpMemory(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %6
%12 = icmp ugt i32 %11, 32
br i1 %12, label %13, label %14
13: ; preds = %3
br label %16
14: ; preds = %3
%15 = load i32, i32* %6
br label %16
16: ; preds = %14, %13
%17 = phi i32 [ 32, %13 ], [ %15, %14 ]
store i32 %17, i32* %8
store i32 0, i32* %7
br label %18
18: ; preds = %40, %16
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %43
22: ; preds = %18
%23 = load i32, i32* %7
%24 = and i32 %23, 7
%25 = icmp ne i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %26, %22
%33 = load i8*, i8** %5
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %32
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %18
43: ; preds = %18
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"DUMP %s: ...................................\0A\00"
@.str.1 = [5 x i8] c"\0A%p\09\00"
@.str.2 = [6 x i8] c"%02x \00"
@str = [53 x i8] c"\0A...................................................\00"
define void @DumpMemory(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp ult i32 %2, 32
%6 = select i1 %5, i32 %2, i32 32
%7 = icmp eq i32 %6, 0
br i1 %7, label %24, label %8
8: ; preds = %3
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %17
%11 = phi i64 [ 0, %8 ], [ %22, %17 ]
%12 = and i64 %11, 7
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %1, i64 %11
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %10
%18 = getelementptr inbounds i8, i8* %1, i64 %11
%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.2, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %24, label %10
24: ; preds = %17, %3
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
ret void
}