#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 (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,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ed <mymemdump+0xdd>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jl     1192 <mymemdump+0x82>
mov    -0x1c(%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    -0x18(%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    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%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
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i32*, i32** %4
%10 = load i8*, i8** %5
%11 = ptrtoint i8* %10 to i64
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %11)
store i32 0, i32* %7
br label %13
13: ; preds = %44, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %47
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = and i32 %23, 255
store i32 %24, i32* %8
%25 = load i32*, i32** %4
%26 = load i32, i32* %8
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** %4
%29 = load i32, i32* %8
%30 = icmp sge i32 %29, 32
br i1 %30, label %31, label %33
31: ; preds = %17
%32 = load i32, i32* %8
br label %34
33: ; preds = %17
br label %34
34: ; preds = %33, %31
%35 = phi i32 [ %32, %31 ], [ 46, %33 ]
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %7
%38 = srem i32 %37, 16
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %34
%41 = load i32*, i32** %4
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %40, %34
br label %44
44: ; preds = %43
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %13
47: ; preds = %13
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 %25
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %22
%10 = phi i64 [ 0, %7 ], [ %23, %22 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = icmp ugt i8 %12, 31
%16 = select i1 %15, i32 %13, i32 46
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = and i64 %10, 15
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %9
%21 = tail call i32 @fputc(i32 10, i32* %0)
br label %22
22: ; preds = %20, %9
%23 = add nuw nsw i64 %10, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %25, label %9
25: ; preds = %22, %3
ret void
}