#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*/ isblank(unsigned char);
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void dump(char *buf, int n) {
  int i;
  char ascii[15 + 1];
  ascii[15] = 0;
  for (i = 0; i < n; i++) {
    unsigned char x = buf[i];
    printf("%02X ", x);
    if (isprint(x) && !isblank(x))
      ascii[i % 15] = x;
    else
      ascii[i % 15] = '.';
    if (((i + 1) % 15) == 0)
      printf("%s\n", ascii);
  }
  i = i % 15;
  if (i > 0) {
    ascii[i] = 0;
    for (; i < 15; i++)
      printf("   ");
    printf("%s\n", ascii);
  } else
    puts("");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1214 <dump+0xd4>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
movzbl -0x21(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x21(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     11c5 <dump+0x85>
movzbl -0x21(%rbp),%edi
call   1050 <isblank@plt>
cmp    $0x0,%eax
jne    11c5 <dump+0x85>
mov    -0x21(%rbp),%cl
mov    -0x10(%rbp),%eax
mov    $0xf,%esi
cltd
idiv   %esi
movslq %edx,%rax
mov    %cl,-0x20(%rbp,%rax,1)
jmp    11d8 <dump+0x98>
mov    -0x10(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movb   $0x2e,-0x20(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1201 <dump+0xc1>
lea    -0x20(%rbp),%rsi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1206 <dump+0xc6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <dump+0x1a>
mov    -0x10(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1272 <dump+0x132>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
cmpl   $0xf,-0x10(%rbp)
jge    125b <dump+0x11b>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1235 <dump+0xf5>
lea    -0x20(%rbp),%rsi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127e <dump+0x13e>
lea    0xd90(%rip),%rdi
call   1030 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,0x30(%rsp)
movb   $0x0,0x1f(%rsp)
test   %esi,%esi
jle    12bb <dump+0x16b>
mov    %esi,0xc(%rsp)
mov    %esi,%edi
lea    0x10(%rsp),%r15
mov    $0x1,%r12d
xor    %ebp,%ebp
mov    %rdi,0x28(%rsp)
jmp    11a9 <dump+0x59>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
add    $0x1,%r12d
mov    %rbx,%rbp
mov    0x28(%rsp),%rdi
cmp    %rbx,%rdi
je     1249 <dump+0xf9>
mov    %rbp,%rax
movabs $0x8888888888888889,%rcx
88 88 88
mul    %rcx
mov    %rdx,%rbx
shr    $0x3,%rbx
mov    %rbx,%rax
shl    $0x4,%rax
sub    %rax,%rbx
mov    %r12d,%r13d
mov    $0x88888889,%eax
imul   %rax,%r13
shr    $0x23,%r13
mov    0x30(%rsp),%rax
movzbl (%rax,%rbp,1),%eax
mov    %al,0xb(%rsp)
movzbl %al,%r14d
lea    0xe0e(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
call   1070 <isprint@plt>
test   %rax,%rax
je     1215 <dump+0xc5>
mov    %r14d,%edi
call   1060 <isblank@plt>
test   %eax,%eax
je     121a <dump+0xca>
movb   $0x2e,0xb(%rsp)
lea    0x0(%r13,%r13,4),%eax
lea    (%rax,%rax,2),%eax
add    $0xffffffff,%eax
movzbl 0xb(%rsp),%ecx
mov    %cl,(%r15,%rbx,1)
lea    0x1(%rbp),%rbx
cmp    %ebp,%eax
jne    1190 <dump+0x40>
lea    0x10(%rsp),%rdi
call   1040 <puts@plt>
jmp    1190 <dump+0x40>
mov    $0x88888889,%eax
mov    %rdi,%rcx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,2),%edx
mov    0xc(%rsp),%esi
mov    %esi,%ecx
sub    %edx,%ecx
je     12bb <dump+0x16b>
mov    %ecx,%ecx
movb   $0x0,0x10(%rsp,%rcx,1)
imul   %rax,%rdi
shr    $0x23,%rdi
lea    (%rdi,%rdi,4),%eax
lea    (%rax,%rax,2),%ebp
not    %ebp
add    %esi,%ebp
lea    0xd7d(%rip),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0xe,%ebp
jb     1290 <dump+0x140>
lea    0x10(%rsp),%rdi
call   1040 <puts@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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