#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*/ fputc(char const, int /*<<< orphan*/);
scalar_t__ isalnum(unsigned char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
void dbgmem_hexdump(void *block, size_t bytes) {
  unsigned char *p = (unsigned char *)block;
  unsigned char *end = p + bytes;
  const char *hextable = "0123456789abcdef";
  printf("Dump: \t");
  for (; p < end; ++p) {
    if (isalnum(*p))
      fputc(*p, stdout);
    else {
      fputc('\\', stdout);
      fputc('x', stdout);
      fputc(hextable[(*p >> 4) & 0x0f], stdout);
      fputc(hextable[*p & 0x0f], stdout);
    }
  }
  fputc('\n', stdout);
}


x86 assembly (clang, -O0):
<dbgmem_hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xea5(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1234 <dbgmem_hexdump+0x104>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
je     11ab <dbgmem_hexdump+0x7b>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    0x2e44(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    121e <dbgmem_hexdump+0xee>
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
mov    $0x5c,%edi
call   1050 <fputc@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
mov    $0x78,%edi
call   1050 <fputc@plt>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rcx),%ecx
sar    $0x4,%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    0x2df1(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1050 <fputc@plt>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rcx),%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    0x2dcc(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    1223 <dbgmem_hexdump+0xf3>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116b <dbgmem_hexdump+0x3b>
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1050 <fputc@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbgmem_hexdump>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
test   %r14,%r14
jle    11cd <dbgmem_hexdump+0x9d>
add    %rbx,%r14
mov    0x2e87(%rip),%r15
lea    0xea0(%rip),%r12
jmp    1184 <dbgmem_hexdump+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rcx),%edi
mov    (%r15),%esi
call   1050 <fputc@plt>
add    $0x1,%rbx
cmp    %r14,%rbx
jae    11cd <dbgmem_hexdump+0x9d>
movzbl (%rbx),%edi
call   1040 <isalnum@plt>
mov    %rbx,%rcx
test   %rax,%rax
jne    1170 <dbgmem_hexdump+0x40>
mov    (%r15),%esi
mov    $0x5c,%edi
call   1050 <fputc@plt>
mov    (%r15),%esi
mov    $0x78,%edi
call   1050 <fputc@plt>
movzbl (%rbx),%eax
shr    $0x4,%rax
movsbl (%rax,%r12,1),%edi
mov    (%r15),%esi
call   1050 <fputc@plt>
movzbl (%rbx),%ecx
and    $0xf,%ecx
add    %r12,%rcx
jmp    1170 <dbgmem_hexdump+0x40>
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <fputc@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"0123456789abcdef\00"
@.str.1 = [8 x i8] c"Dump: \09\00"
@stdout = global i32 0
define void @dbgmem_hexdump(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%8 = load i8*, i8** %3
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = load i64, i64* %4
%11 = getelementptr inbounds i8, i8* %9, i64 %10
store i8* %11, i8** %6
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %7
%12 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %54, %2
%14 = load i8*, i8** %5
%15 = load i8*, i8** %6
%16 = icmp ult i8* %14, %15
br i1 %16, label %17, label %57
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = call i64 @isalnum(i8 zeroext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = load i32, i32* @stdout
%26 = call i32 @fputc(i8 signext %24, i32 %25)
br label %53
27: ; preds = %17
%28 = load i32, i32* @stdout
%29 = call i32 @fputc(i8 signext 92, i32 %28)
%30 = load i32, i32* @stdout
%31 = call i32 @fputc(i8 signext 120, i32 %30)
%32 = load i8*, i8** %7
%33 = load i8*, i8** %5
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = ashr i32 %35, 4
%37 = and i32 %36, 15
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %32, i64 %38
%40 = load i8, i8* %39
%41 = load i32, i32* @stdout
%42 = call i32 @fputc(i8 signext %40, i32 %41)
%43 = load i8*, i8** %7
%44 = load i8*, i8** %5
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = and i32 %46, 15
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %43, i64 %48
%50 = load i8, i8* %49
%51 = load i32, i32* @stdout
%52 = call i32 @fputc(i8 signext %50, i32 %51)
br label %53
53: ; preds = %27, %22
br label %54
54: ; preds = %53
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %5
br label %13
57: ; preds = %13
%58 = load i32, i32* @stdout
%59 = call i32 @fputc(i8 signext 10, i32 %58)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789abcdef\00"
@.str.1 = [8 x i8] c"Dump: \09\00"
@stdout = global i32 0
define void @dbgmem_hexdump(i8* %0, i64 %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 %1
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp sgt i64 %1, 0
br i1 %5, label %6, label %34
6: ; preds = %2, %27
%7 = phi i8* [ %32, %27 ], [ %0, %2 ]
%8 = load i8, i8* %7
%9 = tail call i64 @isalnum(i8 zeroext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %6
%12 = load i32, i32* @stdout
%13 = tail call i32 @fputc(i8 signext 92, i32 %12)
%14 = load i32, i32* @stdout
%15 = tail call i32 @fputc(i8 signext 120, i32 %14)
%16 = load i8, i8* %7
%17 = lshr i8 %16, 4
%18 = zext i8 %17 to i64
%19 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = load i32, i32* @stdout
%22 = tail call i32 @fputc(i8 signext %20, i32 %21)
%23 = load i8, i8* %7
%24 = and i8 %23, 15
%25 = zext i8 %24 to i64
%26 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %25
br label %27
27: ; preds = %6, %11
%28 = phi i8* [ %26, %11 ], [ %7, %6 ]
%29 = load i8, i8* %28
%30 = load i32, i32* @stdout
%31 = tail call i32 @fputc(i8 signext %29, i32 %30)
%32 = getelementptr inbounds i8, i8* %7, i64 1
%33 = icmp ult i8* %32, %3
br i1 %33, label %6, label %34
34: ; preds = %27, %2
%35 = load i32, i32* @stdout
%36 = tail call i32 @fputc(i8 signext 10, i32 %35)
ret void
}