#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*/ printf(char *, ...);
void printMemory(const char *title, const unsigned char *start,
                 unsigned int length) {
  int row, col, i = 0;
  printf("%s:\n", title);
  for (row = 0; (i + 1) < length; row++) {
    for (col = 0; col < 16; col++) {
      i = row * 16 + col;
      if (col == 8)
        printf(" ");
      if (i < length)
        printf("%02X", start[i]);
      else
        printf("  ");
      printf(" ");
    }
    printf(" ");
    for (col = 0; col < 16; col++) {
      i = row * 16 + col;
      if (col == 8)
        printf("  ");
      if (i < length) {
        if (start[i] > 0x20 && start[i] < 0x7F)
          printf("%c", start[i]);
        else
          printf(".");
      } else
        break;
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printMemory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jae    12bb <printMemory+0x1ab>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11dc <printMemory+0xcc>
mov    -0x18(%rbp),%eax
shl    $0x4,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jne    1187 <printMemory+0x77>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11b2 <printMemory+0xa2>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c0 <printMemory+0xb0>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <printMemory+0x49>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    129f <printMemory+0x18f>
mov    -0x18(%rbp),%eax
shl    $0x4,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jne    121f <printMemory+0x10f>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1287 <printMemory+0x177>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jle    1274 <printMemory+0x164>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7f,%eax
jge    1274 <printMemory+0x164>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1282 <printMemory+0x172>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128c <printMemory+0x17c>
jmp    129f <printMemory+0x18f>
jmp    1291 <printMemory+0x181>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f1 <printMemory+0xe1>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <printMemory+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMemory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %rdi,%rsi
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,0xc(%rsp)
cmp    $0x2,%ebx
jb     125b <printMemory+0x13b>
mov    0xc(%rsp),%r12d
xor    %r14d,%r14d
jmp    1185 <printMemory+0x65>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
mov    0x10(%rsp),%r14
add    $0x10,%r14
cmp    0xc(%rsp),%r13d
mov    %rbx,%r12
jae    125b <printMemory+0x13b>
mov    %r14,0x10(%rsp)
and    $0xfffffff0,%r14d
mov    %rbp,%r13
lea    (%r14,%rbp,1),%r15
xor    %ebx,%ebx
jmp    11c2 <printMemory+0xa2>
nopl   0x0(%rax)
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x10,%rbx
je     11f0 <printMemory+0xd0>
lea    (%r14,%rbx,1),%rbp
cmp    $0x8,%rbx
jne    11d6 <printMemory+0xb6>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    %r12,%rbp
jae    11a0 <printMemory+0x80>
movzbl (%r15,%rbx,1),%esi
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ae <printMemory+0x8e>
mov    %r12,%rbx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x8,%r15d
mov    $0x10,%r12d
mov    %r13,%rbp
nopl   0x0(%rax)
mov    %r14,%r13
sub    $0x1,%r15
jae    1227 <printMemory+0x107>
lea    0xdea(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbx,%r13
jae    1160 <printMemory+0x40>
movzbl 0x0(%rbp,%r13,1),%eax
lea    -0x21(%rax),%ecx
cmp    $0x5e,%cl
mov    $0x2e,%ecx
cmovae %ecx,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
lea    0x1(%r13),%r14
add    $0xffffffffffffffff,%r12
jne    1210 <printMemory+0xf0>
jmp    1160 <printMemory+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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