#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*/ libc_printf(char *, int, ...);
void memDump(void *a, unsigned int len) {
  unsigned int i;
  unsigned int j;
  unsigned char *p;
  p = a;
  j = 0;
  for (i = 0; i <= len; i++) {
    if ((j % 16) == 0) {
      libc_printf((char *)"\\n%p  %02x", 10, p, (unsigned int)((*p)));
    } else {
      libc_printf((char *)" %02x", 5, (unsigned int)((*p)));
    }
    p += 1;
    j += 1;
  }
  libc_printf((char *)"\\n", 2);
}


x86 assembly (clang, -O0):
<memDump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     11b0 <memDump+0xa0>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1173 <memDump+0x63>
mov    -0x20(%rbp),%rdx
mov    -0x20(%rbp),%rax
movzbl (%rax),%ecx
lea    0xe9e(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <libc_printf@plt>
jmp    118d <memDump+0x7d>
mov    -0x20(%rbp),%rax
movzbl (%rax),%edx
lea    0xe84(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <libc_printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1135 <memDump+0x25>
lea    0xe54(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <libc_printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memDump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0xedb(%rip),%r14
lea    0xed9(%rip),%r15
xor    %ebp,%ebp
jmp    114a <memDump+0x3a>
mov    %r15,%rdi
mov    $0x5,%esi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <libc_printf@plt>
add    $0x1,%rbp
cmp    %r12d,%ebp
ja     1169 <memDump+0x59>
movzbl (%rbx,%rbp,1),%ecx
test   $0xf,%bpl
jne    1130 <memDump+0x20>
lea    (%rbx,%rbp,1),%rdx
mov    %r14,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <libc_printf@plt>
jmp    1141 <memDump+0x31>
lea    0xe9b(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <libc_printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"\\n%p %02x\00"
@.str.1 = [6 x i8] c" %02x\00"
@.str.2 = [3 x i8] c"\\n\00"
define void @memDump(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i8*, i8** %3
store i8* %8, i8** %7
store i32 0, i32* %6
store i32 0, i32* %5
br label %9
9: ; preds = %33, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp ule i32 %10, %11
br i1 %12, label %13, label %36
13: ; preds = %9
%14 = load i32, i32* %6
%15 = urem i32 %14, 16
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = load i8*, i8** %7
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = call i32 (i8*, i32, ...) @libc_printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10, i8* %18, i32 %21)
br label %28
23: ; preds = %13
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = call i32 (i8*, i32, ...) @libc_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %26)
br label %28
28: ; preds = %23, %17
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8* %30, i8** %7
%31 = load i32, i32* %6
%32 = add i32 %31, 1
store i32 %32, i32* %6
br label %33
33: ; preds = %28
%34 = load i32, i32* %5
%35 = add i32 %34, 1
store i32 %35, i32* %5
br label %9
36: ; preds = %9
%37 = call i32 (i8*, i32, ...) @libc_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"\\n%p %02x\00"
@.str.1 = [6 x i8] c" %02x\00"
@.str.2 = [3 x i8] c"\\n\00"
define void @memDump(i8* %0, i32 %1) {
br label %3
3: ; preds = %2, %14
%4 = phi i8* [ %0, %2 ], [ %15, %14 ]
%5 = phi i32 [ 0, %2 ], [ %16, %14 ]
%6 = and i32 %5, 15
%7 = icmp eq i32 %6, 0
%8 = load i8, i8* %4
%9 = zext i8 %8 to i32
br i1 %7, label %10, label %12
10: ; preds = %3
%11 = tail call i32 (i8*, i32, ...) @libc_printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10, i8* %4, i32 %9)
br label %14
12: ; preds = %3
%13 = tail call i32 (i8*, i32, ...) @libc_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %9)
br label %14
14: ; preds = %12, %10
%15 = getelementptr inbounds i8, i8* %4, i64 1
%16 = add i32 %5, 1
%17 = icmp ugt i32 %16, %1
br i1 %17, label %18, label %3
18: ; preds = %14
%19 = tail call i32 (i8*, i32, ...) @libc_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
ret void
}