#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void mymemdump(FILE *fd, char *p, int len) {
  int i;
  fprintf(fd, "0x%016lX: ", (unsigned long)p);
  for (int i = 0; i < len; i++) {
    int c = p[i] & 0xFF;
    fprintf(fd, "%02X ", c);
    fprintf(fd, "%c ", (c >= 32) ? c : '.');
    if (i % 16 == 0) {
      fprintf(fd, "\n");
    }
  }
}


x86 assembly (clang, -O0):
<mymemdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ed <mymemdump+0xdd>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x20,-0x20(%rbp)
jl     1192 <mymemdump+0x82>
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    119f <mymemdump+0x8f>
mov    $0x2e,%eax
mov    %eax,-0x2c(%rbp)
jmp    119f <mymemdump+0x8f>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11da <mymemdump+0xca>
mov    -0x8(%rbp),%rdi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11df <mymemdump+0xcf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1140 <mymemdump+0x30>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mymemdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xec6(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %ebp,%ebp
jle    11b0 <mymemdump+0x90>
mov    %ebp,%r13d
lea    0xebf(%rip),%r12
xor    %r15d,%r15d
jmp    1169 <mymemdump+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r15,%r13
je     11b0 <mymemdump+0x90>
movzbl (%r14,%r15,1),%ebp
mov    %rbx,%rdi
lea    0xe93(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x20,%ebp
mov    $0x2e,%eax
cmovb  %eax,%ebp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   $0xf,%r15b
jne    1160 <mymemdump+0x40>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    1160 <mymemdump+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"0x%016lX: \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [4 x i8] c"%c \00"
define void @mymemdump(i32* nocapture %0, i8* %1, i32 %2) {
%4 = ptrtoint i8* %1 to i64
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %4)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %10
9: ; preds = %23, %3
ret void
10: ; preds = %7, %23
%11 = phi i64 [ 0, %7 ], [ %24, %23 ]
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = icmp ugt i8 %13, 31
%17 = select i1 %16, i32 %14, i32 46
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = and i64 %11, 15
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %10
%22 = tail call i32 @fputc(i32 10, i32* %0)
br label %23
23: ; preds = %21, %10
%24 = add nuw nsw i64 %11, 1
%25 = icmp eq i64 %24, %8
br i1 %25, label %9, label %10
}