#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void dump(char *m, char *p, int len) {
  char hex[] = "0123456789ABCDEF";
  fprintf(stderr, "%s: >", m);
  while (len) {
    if (*p >= ' ' && *p < 127)
      fputc(*p, stderr);
    else
      fprintf(stderr, "\\x%c%c", hex[(*p >> 4) & 0x0f], hex[*p & 0x0f]);
    p++, len--;
  }
  fprintf(stderr, "<\n");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec1(%rip),%al
mov    %al,-0x20(%rbp)
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
je     1209 <dump+0xe9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jl     11b3 <dump+0x93>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7f,%eax
jge    11b3 <dump+0x93>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    0x2e3c(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    11ef <dump+0xcf>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sar    $0x4,%eax
and    $0xf,%eax
cltq
movsbl -0x30(%rbp,%rax,1),%edx
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
and    $0xf,%eax
cltq
movsbl -0x30(%rbp,%rax,1),%ecx
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <dump+0x4d>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r13
mov    %rdi,%rdx
mov    0x2ea5(%rip),%r15
mov    (%r15),%edi
lea    0xecc(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r14d,%r14d
je     11b3 <dump+0x93>
mov    %r14d,%ebp
lea    0xea5(%rip),%r12
lea    0xeb5(%rip),%r14
xor    %ebx,%ebx
jmp    1198 <dump+0x78>
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rcx
shr    $0x4,%rcx
movsbl (%rcx,%r12,1),%edx
and    $0xf,%eax
movsbl (%rax,%r12,1),%ecx
mov    %esi,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
je     11b3 <dump+0x93>
movzbl 0x0(%r13,%rbx,1),%eax
lea    -0x7f(%rax),%ecx
mov    (%r15),%esi
cmp    $0xa1,%cl
jb     1170 <dump+0x50>
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    1190 <dump+0x70>
mov    (%r15),%edi
lea    0xe61(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@__const.dump.hex = [17 x i8] c"0123456789ABCDEF\00"
@stderr = global i32 0
@.str = [6 x i8] c"%s: >\00"
@.str.1 = [7 x i8] c"\\x%c%c\00"
@.str.2 = [3 x i8] c"<\0A\00"
define void @dump(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [17 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = bitcast [17 x i8]* %7 to i8*
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %4
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %50, %3
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %55
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sge i32 %18, 32
br i1 %19, label %20, label %30
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp slt i32 %23, 127
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = load i32, i32* @stderr
%29 = call i32 @fputc(i8 signext %27, i32 %28)
br label %50
30: ; preds = %20, %15
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %5
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = ashr i32 %34, 4
%36 = and i32 %35, 15
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = load i8*, i8** %5
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = and i32 %43, 15
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %48)
br label %50
50: ; preds = %30, %25
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %5
%53 = load i32, i32* %6
%54 = add nsw i32 %53, -1
store i32 %54, i32* %6
br label %12
55: ; preds = %12
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.dump.hex = [17 x i8] c"0123456789ABCDEF\00"
@stderr = global i32 0
@.str = [6 x i8] c"%s: >\00"
@.str.1 = [7 x i8] c"\\x%c%c\00"
@.str.2 = [3 x i8] c"<\0A\00"
define void @dump(i8* %0, i8* nocapture %1, i32 %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp eq i32 %2, 0
br i1 %6, label %33, label %7
7: ; preds = %3, %29
%8 = phi i32 [ %31, %29 ], [ %2, %3 ]
%9 = phi i8* [ %30, %29 ], [ %1, %3 ]
%10 = load i8, i8* %9
%11 = add i8 %10, -127
%12 = icmp ult i8 %11, -95
%13 = load i32, i32* @stderr
br i1 %12, label %16, label %14
14: ; preds = %7
%15 = tail call i32 @fputc(i8 signext %10, i32 %13)
br label %29
16: ; preds = %7
%17 = zext i8 %10 to i32
%18 = lshr i32 %17, 4
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.dump.hex, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = and i32 %17, 15
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.dump.hex, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %27)
br label %29
29: ; preds = %16, %14
%30 = getelementptr inbounds i8, i8* %9, i64 1
%31 = add nsw i32 %8, -1
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %7
33: ; preds = %29, %3
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}