#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 uint8_t;

/* Variables and functions */
scalar_t__ isprint(int const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void dump_memory(const void *start, size_t size, size_t offset, int print_chars,
                 const char *desc) {
  const uint8_t *p = start;
  const uint8_t *end = p + size;
  while (p < end) {
    const uint8_t *line = p;
    const uint8_t *line_end = p + 16;
    printf("%07x: ", (int)((void *)p - start + offset));
    while (p < line_end) {
      int i;
      for (i = 0; i < 2; ++i, ++p) {
        if (p < end) {
          printf("%02x", *p);
        } else {
          putchar(' ');
          putchar(' ');
        }
      }
      putchar(' ');
    }
    putchar(' ');
    p = line;
    int i;
    for (i = 0; i < 16 && p < end; ++i, ++p)
      if (print_chars)
        printf("%c", isprint(*p) ? *p : '.');
    if (p >= end && desc)
      printf("  ; %s", desc);
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<dump_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    1319 <dump_memory+0x1e9>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    122f <dump_memory+0xff>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x2,-0x4c(%rbp)
jge    1220 <dump_memory+0xf0>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    11ed <dump_memory+0xbd>
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1201 <dump_memory+0xd1>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1206 <dump_memory+0xd6>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
jmp    11bc <dump_memory+0x8c>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11a7 <dump_memory+0x77>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x50(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x50(%rbp)
mov    %al,-0x51(%rbp)
jge    1265 <dump_memory+0x135>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
setb   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1275 <dump_memory+0x145>
jmp    12df <dump_memory+0x1af>
cmpl   $0x0,-0x1c(%rbp)
je     12c0 <dump_memory+0x190>
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     12a2 <dump_memory+0x172>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
jmp    12af <dump_memory+0x17f>
mov    $0x2e,%eax
mov    %eax,-0x58(%rbp)
jmp    12af <dump_memory+0x17f>
mov    -0x58(%rbp),%esi
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c5 <dump_memory+0x195>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
jmp    1248 <dump_memory+0x118>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jb     130a <dump_memory+0x1da>
cmpq   $0x0,-0x28(%rbp)
je     130a <dump_memory+0x1da>
mov    -0x28(%rbp),%rsi
lea    0xd0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1166 <dump_memory+0x36>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rdx,0x8(%rsp)
lea    (%rdi,%rsi,4),%r12
cmp    %rdi,%r12
jbe    12b8 <dump_memory+0x188>
mov    %ecx,%r14d
mov    %rdi,%rbx
sub    %rdi,0x8(%rsp)
lea    0xea0(%rip),%r13
mov    %ecx,0x4(%rsp)
jmp    1183 <dump_memory+0x53>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r12,%rbx
jae    12b8 <dump_memory+0x188>
mov    0x8(%rsp),%rax
lea    (%rax,%rbx,1),%esi
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rbx),%r14
mov    $0xffffffffffffffff,%r15
jmp    11d5 <dump_memory+0xa5>
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x8,%r14
add    $0x2,%r15
cmp    $0xf,%r15
jae    1230 <dump_memory+0x100>
lea    -0x4(%r14),%rax
cmp    %r12,%rax
jae    1200 <dump_memory+0xd0>
mov    (%rax),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,%r14
jb     11b0 <dump_memory+0x80>
jmp    1219 <dump_memory+0xe9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    %r12,%r14
jb     11b0 <dump_memory+0x80>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11bd <dump_memory+0x8d>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    %r12,%rbx
jae    128b <dump_memory+0x15b>
xor    %ebp,%ebp
mov    0x4(%rsp),%r14d
cs nopw 0x0(%rax,%rax,1)
test   %r14d,%r14d
je     127a <dump_memory+0x14a>
mov    (%rbx),%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     1270 <dump_memory+0x140>
mov    (%rbx),%edi
jmp    1275 <dump_memory+0x145>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x4,%rbx
cmp    $0xe,%ebp
ja     128b <dump_memory+0x15b>
add    $0x1,%ebp
cmp    %r12,%rbx
jb     1250 <dump_memory+0x120>
cmpq   $0x0,0x10(%rsp)
je     1170 <dump_memory+0x40>
cmp    %r12,%rbx
jb     1170 <dump_memory+0x40>
lea    0xd65(%rip),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <dump_memory+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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