#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 dump(char *buffer, int size) {
  int base, i;
  char c;
  for (base = 0; base < size; base += 16) {
    printf("%04d ", base);
    for (i = 0; i < 16; ++i) {
      if (base + i < size)
        printf("%02X ", buffer[base + i]);
      else
        printf("   ");
    }
    printf(" *");
    for (i = 0; i < 16; ++i) {
      if (base + i < size)
        c = buffer[base + i];
      else
        c = ' ';
      if (c < ' ' || c > 'z')
        c = ' ';
      printf("%c", c);
    }
    printf("*\n");
  }
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    124c <dump+0x13c>
mov    -0x10(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    11a8 <dump+0x98>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1187 <dump+0x77>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1195 <dump+0x85>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119a <dump+0x8a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <dump+0x3a>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1230 <dump+0x120>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ee <dump+0xde>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
jmp    11f2 <dump+0xe2>
movb   $0x20,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x20,%eax
jl     120c <dump+0xfc>
movsbl -0x15(%rbp),%eax
cmp    $0x7a,%eax
jle    1210 <dump+0x100>
movb   $0x20,-0x15(%rbp)
movsbl -0x15(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <dump+0xad>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <dump+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
test   %esi,%esi
jle    1244 <dump+0x114>
mov    %rdi,%rbx
mov    0x4(%rsp),%r13d
mov    $0x20,%r15d
lea    0xeb0(%rip),%r14
xor    %r12d,%r12d
jmp    118f <dump+0x5f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
add    $0x10,%r12
add    $0x10,%rbx
cmp    0x4(%rsp),%r12d
jge    1244 <dump+0x114>
lea    0xe6a(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %ebp,%ebp
jmp    11c4 <dump+0x94>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     11f0 <dump+0xc0>
lea    (%r12,%rbp,1),%rax
cmp    %r13,%rax
jge    11b0 <dump+0x80>
movsbl (%rbx,%rbp,1),%esi
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ba <dump+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %ebp,%ebp
jmp    1233 <dump+0x103>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x7b(%rax),%ecx
cmp    $0xa5,%cl
movzbl %al,%eax
cmovb  %r15d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1170 <dump+0x40>
lea    (%r12,%rbp,1),%rcx
mov    $0x20,%al
cmp    %r13,%rcx
jge    1210 <dump+0xe0>
movzbl (%rbx,%rbp,1),%eax
jmp    1210 <dump+0xe0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%04d \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 = [3 x i8] c"*\0A\00"
define void @dump(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %78, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %81
12: ; preds = %8
%13 = load i32, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 0, i32* %6
br label %15
15: ; preds = %37, %12
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 16
br i1 %17, label %18, label %40
18: ; preds = %15
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = add nsw i32 %19, %20
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = add nsw i32 %26, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %25, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %18
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %15
40: ; preds = %15
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %42
42: ; preds = %73, %40
%43 = load i32, i32* %6
%44 = icmp slt i32 %43, 16
br i1 %44, label %45, label %76
45: ; preds = %42
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = add nsw i32 %46, %47
%49 = load i32, i32* %4
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %59
51: ; preds = %45
%52 = load i8*, i8** %3
%53 = load i32, i32* %5
%54 = load i32, i32* %6
%55 = add nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %52, i64 %56
%58 = load i8, i8* %57
store i8 %58, i8* %7
br label %60
59: ; preds = %45
store i8 32, i8* %7
br label %60
60: ; preds = %59, %51
%61 = load i8, i8* %7
%62 = sext i8 %61 to i32
%63 = icmp slt i32 %62, 32
br i1 %63, label %68, label %64
64: ; preds = %60
%65 = load i8, i8* %7
%66 = sext i8 %65 to i32
%67 = icmp sgt i32 %66, 122
br i1 %67, label %68, label %69
68: ; preds = %64, %60
store i8 32, i8* %7
br label %69
69: ; preds = %68, %64
%70 = load i8, i8* %7
%71 = sext i8 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %69
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %42
76: ; preds = %42
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %78
78: ; preds = %76
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 16
store i32 %80, i32* %5
br label %8
81: ; preds = %8
ret void
}

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