#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*/ debugmalloc_printf(char *, ...);
scalar_t__ isprint(unsigned char);
void debugmalloc_dump_memory(void const *memoria, size_t meret) {
  unsigned char const *mem = (unsigned char const *)memoria;
  unsigned y, x;
  for (y = 0; y < (meret + 15) / 16; y++) {
    debugmalloc_printf("      %04x  ", y * 16);
    for (x = 0; x < 16; x++)
      if (y * 16 + x < meret)
        debugmalloc_printf("%02x ", mem[y * 16 + x]);
      else
        debugmalloc_printf("   ");
    debugmalloc_printf("  ");
    for (x = 0; x < 16; x++)
      if (y * 16 + x < meret) {
        unsigned char c = mem[y * 16 + x];
        debugmalloc_printf("%c", isprint(c) ? c : '.');
      } else
        debugmalloc_printf(" ");
    debugmalloc_printf("\n");
  }
}


x86 assembly (clang, -O0):
<debugmalloc_dump_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
add    $0xf,%rcx
shr    $0x4,%rcx
cmp    %rcx,%rax
jae    12a0 <debugmalloc_dump_memory+0x180>
mov    -0x1c(%rbp),%esi
shl    $0x4,%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <debugmalloc_printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jae    11d8 <debugmalloc_dump_memory+0xb8>
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
add    -0x20(%rbp),%eax
mov    %eax,%eax
cmp    -0x10(%rbp),%rax
jae    11b7 <debugmalloc_dump_memory+0x97>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x20(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <debugmalloc_printf@plt>
jmp    11c5 <debugmalloc_dump_memory+0xa5>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <debugmalloc_printf@plt>
jmp    11ca <debugmalloc_dump_memory+0xaa>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1172 <debugmalloc_dump_memory+0x52>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <debugmalloc_printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jae    1284 <debugmalloc_dump_memory+0x164>
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
add    -0x20(%rbp),%eax
mov    %eax,%eax
cmp    -0x10(%rbp),%rax
jae    1263 <debugmalloc_dump_memory+0x143>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x20(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
movzbl -0x21(%rbp),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1240 <debugmalloc_dump_memory+0x120>
movzbl -0x21(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    124d <debugmalloc_dump_memory+0x12d>
mov    $0x2e,%eax
mov    %eax,-0x28(%rbp)
jmp    124d <debugmalloc_dump_memory+0x12d>
mov    -0x28(%rbp),%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <debugmalloc_printf@plt>
jmp    1271 <debugmalloc_dump_memory+0x151>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <debugmalloc_printf@plt>
jmp    1276 <debugmalloc_dump_memory+0x156>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ed <debugmalloc_dump_memory+0xcd>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1030 <debugmalloc_printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <debugmalloc_dump_memory+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debugmalloc_dump_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf(%rsi),%rax
mov    %rax,(%rsp)
cmp    $0x10,%rax
jae    114b <debugmalloc_dump_memory+0x2b>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r14
mov    %rdi,%r12
shrq   $0x4,(%rsp)
lea    0xeb0(%rip),%r15
lea    0xeaf(%rip),%r13
xor    %eax,%eax
xor    %ecx,%ecx
jmp    119e <debugmalloc_dump_memory+0x7e>
nopw   0x0(%rax,%rax,1)
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <debugmalloc_printf@plt>
mov    0x10(%rsp),%rcx
add    $0x1,%ecx
mov    0x8(%rsp),%rax
add    $0x10,%eax
cmp    %rcx,(%rsp)
mov    %rbp,%r15
lea    0xe77(%rip),%r13
jbe    113c <debugmalloc_dump_memory+0x1c>
mov    %eax,%ebx
mov    %rcx,0x10(%rsp)
mov    %ecx,%esi
shl    $0x4,%esi
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
call   1030 <debugmalloc_printf@plt>
mov    $0x10,%ebp
mov    %rbx,0x8(%rsp)
jmp    11e4 <debugmalloc_dump_memory+0xc4>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <debugmalloc_printf@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbp
je     1200 <debugmalloc_dump_memory+0xe0>
cmp    %r14,%rbx
jae    11d0 <debugmalloc_dump_memory+0xb0>
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <debugmalloc_printf@plt>
jmp    11da <debugmalloc_dump_memory+0xba>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rbp
lea    0xe0a(%rip),%rdi
xor    %eax,%eax
call   1030 <debugmalloc_printf@plt>
mov    $0x10,%r13d
mov    0x8(%rsp),%r15
jmp    123c <debugmalloc_dump_memory+0x11c>
xchg   %ax,%ax
lea    0xdee(%rip),%rdi
xor    %eax,%eax
call   1030 <debugmalloc_printf@plt>
add    $0x1,%r15
add    $0xffffffffffffffff,%r13
je     1170 <debugmalloc_dump_memory+0x50>
cmp    %r14,%r15
jae    1220 <debugmalloc_dump_memory+0x100>
mov    %r12,%rbx
movzbl (%r12,%r15,1),%r12d
mov    %r12d,%edi
call   1040 <isprint@plt>
test   %rax,%rax
mov    $0x2e,%eax
cmove  %eax,%r12d
lea    0xdb3(%rip),%rdi
mov    %r12d,%esi
mov    %rbx,%r12
xor    %eax,%eax
call   1030 <debugmalloc_printf@plt>
jmp    122e <debugmalloc_dump_memory+0x10e>

LLVM IR (-O0):
@.str = [13 x i8] c" %04x \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [2 x i8] c"\0A\00"
define void @debugmalloc_dump_memory(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %3
store i64 %1, i64* %4
%9 = load i8*, i8** %3
store i8* %9, i8** %5
store i32 0, i32* %6
br label %10
10: ; preds = %89, %2
%11 = load i32, i32* %6
%12 = zext i32 %11 to i64
%13 = load i64, i64* %4
%14 = add i64 %13, 15
%15 = udiv i64 %14, 16
%16 = icmp ult i64 %12, %15
br i1 %16, label %17, label %92
17: ; preds = %10
%18 = load i32, i32* %6
%19 = mul i32 %18, 16
%20 = call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 0, i32* %7
br label %21
21: ; preds = %46, %17
%22 = load i32, i32* %7
%23 = icmp ult i32 %22, 16
br i1 %23, label %24, label %49
24: ; preds = %21
%25 = load i32, i32* %6
%26 = mul i32 %25, 16
%27 = load i32, i32* %7
%28 = add i32 %26, %27
%29 = zext i32 %28 to i64
%30 = load i64, i64* %4
%31 = icmp ult i64 %29, %30
br i1 %31, label %32, label %43
32: ; preds = %24
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = mul i32 %34, 16
%36 = load i32, i32* %7
%37 = add i32 %35, %36
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %33, i64 %38
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %45
43: ; preds = %24
%44 = call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %43, %32
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = add i32 %47, 1
store i32 %48, i32* %7
br label %21
49: ; preds = %21
%50 = call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %51
51: ; preds = %84, %49
%52 = load i32, i32* %7
%53 = icmp ult i32 %52, 16
br i1 %53, label %54, label %87
54: ; preds = %51
%55 = load i32, i32* %6
%56 = mul i32 %55, 16
%57 = load i32, i32* %7
%58 = add i32 %56, %57
%59 = zext i32 %58 to i64
%60 = load i64, i64* %4
%61 = icmp ult i64 %59, %60
br i1 %61, label %62, label %81
62: ; preds = %54
%63 = load i8*, i8** %5
%64 = load i32, i32* %6
%65 = mul i32 %64, 16
%66 = load i32, i32* %7
%67 = add i32 %65, %66
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %63, i64 %68
%70 = load i8, i8* %69
store i8 %70, i8* %8
%71 = load i8, i8* %8
%72 = call i64 @isprint(i8 zeroext %71)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %62
%75 = load i8, i8* %8
%76 = zext i8 %75 to i32
br label %78
77: ; preds = %62
br label %78
78: ; preds = %77, %74
%79 = phi i32 [ %76, %74 ], [ 46, %77 ]
%80 = call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %79)
br label %83
81: ; preds = %54
%82 = call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %83
83: ; preds = %81, %78
br label %84
84: ; preds = %83
%85 = load i32, i32* %7
%86 = add i32 %85, 1
store i32 %86, i32* %7
br label %51
87: ; preds = %51
%88 = call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %89
89: ; preds = %87
%90 = load i32, i32* %6
%91 = add i32 %90, 1
store i32 %91, i32* %6
br label %10
92: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c" %04x \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [2 x i8] c"\0A\00"
define void @debugmalloc_dump_memory(i8* nocapture %0, i64 %1) {
%3 = add i64 %1, 15
%4 = lshr i64 %3, 4
%5 = icmp ult i64 %3, 16
br i1 %5, label %49, label %6
6: ; preds = %2, %44
%7 = phi i32 [ %46, %44 ], [ 0, %2 ]
%8 = shl i32 %7, 4
%9 = tail call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = zext i32 %8 to i64
br label %11
11: ; preds = %6, %22
%12 = phi i64 [ 0, %6 ], [ %23, %22 ]
%13 = add nuw nsw i64 %12, %10
%14 = icmp ult i64 %13, %1
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %0, i64 %13
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = tail call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %22
20: ; preds = %11
%21 = tail call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %15, %20
%23 = add nuw nsw i64 %12, 1
%24 = icmp eq i64 %23, 16
br i1 %24, label %25, label %11
25: ; preds = %22
%26 = tail call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %41
%28 = phi i64 [ 0, %25 ], [ %42, %41 ]
%29 = add nuw nsw i64 %28, %10
%30 = icmp ult i64 %29, %1
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = getelementptr inbounds i8, i8* %0, i64 %29
%33 = load i8, i8* %32
%34 = tail call i64 @isprint(i8 zeroext %33)
%35 = icmp eq i64 %34, 0
%36 = zext i8 %33 to i32
%37 = select i1 %35, i32 46, i32 %36
%38 = tail call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %41
39: ; preds = %27
%40 = tail call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %41
41: ; preds = %31, %39
%42 = add nuw nsw i64 %28, 1
%43 = icmp eq i64 %42, 16
br i1 %43, label %44, label %27
44: ; preds = %41
%45 = tail call i32 (i8*, ...) @debugmalloc_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%46 = add i32 %7, 1
%47 = zext i32 %46 to i64
%48 = icmp ugt i64 %4, %47
br i1 %48, label %6, label %49
49: ; preds = %44, %2
ret void
}