#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*/ cprintf(char *, ...);
void pretty_dump_memory(void *start, int len) {
  int i, rem;
  unsigned char *ptr = (unsigned char *)start;
  char linebuffer[17], *lbptr;
  for (i = 0; i < 16; i++)
    linebuffer[i] = ' ';
  linebuffer[16] = 0;
  lbptr = &linebuffer[0];
  cprintf("%08lx ", (unsigned)ptr & (~15));
  for (i = 0; i < ((unsigned)ptr & 15); i++) {
    cprintf("   ");
    lbptr++;
  }
  while (len) {
    if (*ptr >= 32 && *ptr < 127)
      *lbptr = *ptr;
    else
      *lbptr = '.';
    cprintf(" %02x", *ptr++);
    len--;
    lbptr++;
    if ((unsigned)ptr % 16 == 0) {
      cprintf("  %s", linebuffer);
      lbptr = &linebuffer[0];
      if (len)
        cprintf("\n%08lx ", ptr);
      else {
        cprintf("\n");
        return;
      }
    }
  }
  rem = 16 - ((unsigned)ptr & 15);
  for (i = 0; i < rem; i++) {
    cprintf("   ");
    *lbptr = ' ';
    lbptr++;
  }
  cprintf("  %s\n", linebuffer);
}


x86 assembly (clang, -O0):
<pretty_dump_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    114f <pretty_dump_memory+0x3f>
movslq -0x10(%rbp),%rax
movb   $0x20,-0x40(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112e <pretty_dump_memory+0x1e>
movb   $0x0,-0x30(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%esi
and    $0xfffffff0,%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x20(%rbp),%rcx
and    $0xf,%ecx
cmp    %ecx,%eax
jae    11b3 <pretty_dump_memory+0xa3>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1179 <pretty_dump_memory+0x69>
jmp    11b8 <pretty_dump_memory+0xa8>
cmpl   $0x0,-0xc(%rbp)
je     1297 <pretty_dump_memory+0x187>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jl     11f3 <pretty_dump_memory+0xe3>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x7f,%eax
jge    11f3 <pretty_dump_memory+0xe3>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x48(%rbp),%rax
mov    %cl,(%rax)
jmp    11fa <pretty_dump_memory+0xea>
mov    -0x48(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movzbl (%rax),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1292 <pretty_dump_memory+0x182>
lea    -0x40(%rbp),%rsi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     127a <pretty_dump_memory+0x16a>
mov    -0x20(%rbp),%rsi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
jmp    128d <pretty_dump_memory+0x17d>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
jmp    12fe <pretty_dump_memory+0x1ee>
jmp    1292 <pretty_dump_memory+0x182>
jmp    11b8 <pretty_dump_memory+0xa8>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
and    $0xf,%ecx
mov    $0x10,%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ec <pretty_dump_memory+0x1dc>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
mov    -0x48(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12b1 <pretty_dump_memory+0x1a1>
lea    -0x40(%rbp),%rsi
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1030 <cprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pretty_dump_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r13d
mov    %rdi,%r14
movaps 0xed5(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
mov    %r14d,%esi
and    $0xfffffff0,%esi
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <cprintf@plt>
mov    %r14d,%r15d
and    $0xf,%r15d
je     118c <pretty_dump_memory+0x7c>
lea    -0x1(%r15),%r12d
add    $0x1,%r12
lea    0xeb0(%rip),%rbp
mov    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <cprintf@plt>
add    $0xffffffff,%ebx
jne    1170 <pretty_dump_memory+0x60>
add    %rsp,%r12
test   %r13d,%r13d
jne    1198 <pretty_dump_memory+0x88>
jmp    1247 <pretty_dump_memory+0x137>
mov    %rsp,%r12
test   %r13d,%r13d
je     1247 <pretty_dump_memory+0x137>
mov    %r13d,%r13d
lea    -0x1(%r13),%rax
mov    %rax,0x20(%rsp)
lea    0xe69(%rip),%rbx
xor    %r15d,%r15d
mov    %r14,0x18(%rsp)
jmp    11cd <pretty_dump_memory+0xbd>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12
add    $0x1,%r15
cmp    %r15d,%r13d
je     123d <pretty_dump_memory+0x12d>
movzbl (%r14,%r15,1),%esi
lea    -0x20(%rsi),%eax
cmp    $0x5f,%al
mov    $0x2e,%eax
cmovb  %esi,%eax
mov    %al,(%r12)
lea    (%r14,%r15,1),%rbp
add    $0x1,%rbp
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <cprintf@plt>
test   $0xf,%bpl
jne    11c0 <pretty_dump_memory+0xb0>
mov    %r13,%r14
mov    %rbx,%r13
lea    0xe12(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <cprintf@plt>
cmp    %r15d,0x20(%rsp)
je     1297 <pretty_dump_memory+0x187>
lea    0xdfc(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <cprintf@plt>
mov    %rbx,%r12
mov    %r13,%rbx
mov    %r14,%r13
mov    0x18(%rsp),%r14
jmp    11c4 <pretty_dump_memory+0xb4>
add    %r15d,%r14d
and    $0xf,%r14d
mov    %r14d,%r15d
neg    %r15d
movslq %r15d,%rbp
add    $0x10,%rbp
lea    0xdb8(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <cprintf@plt>
movb   $0x20,(%r12,%rbx,1)
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1260 <pretty_dump_memory+0x150>
lea    0xda9(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <cprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd8d(%rip),%rdi
xor    %eax,%eax
call   1030 <cprintf@plt>
jmp    1288 <pretty_dump_memory+0x178>

LLVM IR (-O0):
@.str = [7 x i8] c"%08lx \00"
@.str.1 = [4 x i8] c" \00"
@.str.2 = [6 x i8] c" %02x\00"
@.str.3 = [5 x i8] c" %s\00"
@.str.4 = [8 x i8] c"\0A%08lx \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [6 x i8] c" %s\0A\00"
define void @pretty_dump_memory(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [17 x i8]
%9 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = load i8*, i8** %3
store i8* %10, i8** %7
store i32 0, i32* %5
br label %11
11: ; preds = %18, %2
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 16
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 %16
store i8 32, i8* %17
br label %18
18: ; preds = %14
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %11
21: ; preds = %11
%22 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 16
store i8 0, i8* %22
%23 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
store i8* %23, i8** %9
%24 = load i8*, i8** %7
%25 = ptrtoint i8* %24 to i32
%26 = and i32 %25, -16
%27 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %26)
store i32 0, i32* %5
br label %28
28: ; preds = %38, %21
%29 = load i32, i32* %5
%30 = load i8*, i8** %7
%31 = ptrtoint i8* %30 to i32
%32 = and i32 %31, 15
%33 = icmp ult i32 %29, %32
br i1 %33, label %34, label %41
34: ; preds = %28
%35 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%36 = load i8*, i8** %9
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %9
br label %38
38: ; preds = %34
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %28
41: ; preds = %28
br label %42
42: ; preds = %87, %41
%43 = load i32, i32* %4
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %88
45: ; preds = %42
%46 = load i8*, i8** %7
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = icmp sge i32 %48, 32
br i1 %49, label %50, label %59
50: ; preds = %45
%51 = load i8*, i8** %7
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = icmp slt i32 %53, 127
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load i8*, i8** %7
%57 = load i8, i8* %56
%58 = load i8*, i8** %9
store i8 %57, i8* %58
br label %61
59: ; preds = %50, %45
%60 = load i8*, i8** %9
store i8 46, i8* %60
br label %61
61: ; preds = %59, %55
%62 = load i8*, i8** %7
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %7
%64 = load i8, i8* %62
%65 = zext i8 %64 to i32
%66 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %4
%68 = add nsw i32 %67, -1
store i32 %68, i32* %4
%69 = load i8*, i8** %9
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %9
%71 = load i8*, i8** %7
%72 = ptrtoint i8* %71 to i32
%73 = urem i32 %72, 16
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %87
75: ; preds = %61
%76 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%77 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %76)
%78 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
store i8* %78, i8** %9
%79 = load i32, i32* %4
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %75
%82 = load i8*, i8** %7
%83 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %82)
br label %86
84: ; preds = %75
%85 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %108
86: ; preds = %81
br label %87
87: ; preds = %86, %61
br label %42
88: ; preds = %42
%89 = load i8*, i8** %7
%90 = ptrtoint i8* %89 to i32
%91 = and i32 %90, 15
%92 = sub i32 16, %91
store i32 %92, i32* %6
store i32 0, i32* %5
br label %93
93: ; preds = %102, %88
%94 = load i32, i32* %5
%95 = load i32, i32* %6
%96 = icmp slt i32 %94, %95
br i1 %96, label %97, label %105
97: ; preds = %93
%98 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%99 = load i8*, i8** %9
store i8 32, i8* %99
%100 = load i8*, i8** %9
%101 = getelementptr inbounds i8, i8* %100, i32 1
store i8* %101, i8** %9
br label %102
102: ; preds = %97
%103 = load i32, i32* %5
%104 = add nsw i32 %103, 1
store i32 %104, i32* %5
br label %93
105: ; preds = %93
%106 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%107 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %106)
br label %108
108: ; preds = %105, %84
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%08lx \00"
@.str.1 = [4 x i8] c" \00"
@.str.2 = [6 x i8] c" %02x\00"
@.str.3 = [5 x i8] c" %s\00"
@.str.4 = [8 x i8] c"\0A%08lx \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [6 x i8] c" %s\0A\00"
define void @pretty_dump_memory(i8* %0, i32 %1) {
%3 = alloca [17 x i8]
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 16
store i8 0, i8* %6
%7 = ptrtoint i8* %0 to i64
%8 = trunc i64 %7 to i32
%9 = and i32 %8, -16
%10 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = and i32 %8, 15
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %2
%14 = add nsw i32 %11, -1
%15 = zext i32 %14 to i64
%16 = add nuw nsw i64 %15, 1
br label %22
17: ; preds = %22
%18 = getelementptr [17 x i8], [17 x i8]* %3, i64 0, i64 %16
br label %19
19: ; preds = %17, %2
%20 = phi i8* [ %5, %2 ], [ %18, %17 ]
%21 = icmp eq i32 %1, 0
br i1 %21, label %57, label %27
22: ; preds = %13, %22
%23 = phi i32 [ %25, %22 ], [ 0, %13 ]
%24 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, %11
br i1 %26, label %17, label %22
27: ; preds = %19, %50
%28 = phi i8* [ %51, %50 ], [ %20, %19 ]
%29 = phi i8* [ %35, %50 ], [ %0, %19 ]
%30 = phi i32 [ %38, %50 ], [ %1, %19 ]
%31 = load i8, i8* %29
%32 = add i8 %31, -32
%33 = icmp ult i8 %32, 95
%34 = select i1 %33, i8 %31, i8 46
store i8 %34, i8* %28
%35 = getelementptr inbounds i8, i8* %29, i64 1
%36 = zext i8 %31 to i32
%37 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = add nsw i32 %30, -1
%39 = getelementptr inbounds i8, i8* %28, i64 1
%40 = ptrtoint i8* %35 to i64
%41 = and i64 %40, 15
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %27
%44 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%45 = icmp eq i32 %38, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %35)
br label %50
48: ; preds = %43
%49 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %70
50: ; preds = %46, %27
%51 = phi i8* [ %5, %46 ], [ %39, %27 ]
%52 = icmp eq i32 %38, 0
br i1 %52, label %53, label %27
53: ; preds = %50
%54 = ptrtoint i8* %35 to i64
%55 = trunc i64 %54 to i32
%56 = and i32 %55, 15
br label %57
57: ; preds = %19, %53
%58 = phi i32 [ %56, %53 ], [ %11, %19 ]
%59 = phi i8* [ %51, %53 ], [ %20, %19 ]
%60 = sub nuw nsw i32 16, %58
br label %61
61: ; preds = %57, %61
%62 = phi i8* [ %65, %61 ], [ %59, %57 ]
%63 = phi i32 [ %66, %61 ], [ 0, %57 ]
%64 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8 32, i8* %62
%65 = getelementptr inbounds i8, i8* %62, i64 1
%66 = add nuw nsw i32 %63, 1
%67 = icmp eq i32 %66, %60
br i1 %67, label %68, label %61
68: ; preds = %61
%69 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %5)
br label %70
70: ; preds = %68, %48
ret void
}