#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*/ stderr;
void hexDump(char *desc, void *addr, int len) {
  int i;
  unsigned char buff[17];
  unsigned char *pc = (unsigned char *)addr;
  if (desc != NULL)
    fprintf(stderr, "%s:\n", desc);
  for (i = 0; i < len; i++) {
    if ((i % 16) == 0) {
      if (i != 0)
        fprintf(stderr, "  %s\n", buff);
      fprintf(stderr, "  %04x ", i);
    }
    fprintf(stderr, " %02x", pc[i]);
    if ((pc[i] < 0x20) || (pc[i] > 0x7e))
      buff[i % 16] = '.';
    else
      buff[i % 16] = pc[i];
    buff[(i % 16) + 1] = '\0';
  }
  while ((i % 16) != 0) {
    fprintf(stderr, "   ");
    i++;
  }
  fprintf(stderr, "  %s\n", buff);
}


x86 assembly (clang, -O0):
<hexDump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1151 <hexDump+0x41>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeb6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125d <hexDump+0x14d>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b7 <hexDump+0xa7>
cmpl   $0x0,-0x18(%rbp)
je     119d <hexDump+0x8d>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     1204 <hexDump+0xf4>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    121c <hexDump+0x10c>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movb   $0x2e,-0x30(%rbp,%rax,1)
jmp    1239 <hexDump+0x129>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%eax
mov    $0x10,%esi
cltd
idiv   %esi
movslq %edx,%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
movslq %edx,%rax
movb   $0x0,-0x30(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1158 <hexDump+0x48>
jmp    1262 <hexDump+0x152>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     129b <hexDump+0x18b>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1262 <hexDump+0x152>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
lea    0xd56(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexDump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
test   %rdi,%rdi
je     1142 <hexDump+0x32>
mov    %rdi,%rdx
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
lea    0xec5(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebp,%ebp
jle    1259 <hexDump+0x149>
mov    0x2e8f(%rip),%r15
mov    (%r15),%edi
lea    0xeb0(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
movzbl (%rbx),%edx
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
movzbl (%rbx),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
mov    $0x2e,%ecx
cmovb  %ecx,%eax
mov    %al,0x10(%rsp)
movb   $0x0,0x11(%rsp)
mov    $0x1,%r12d
cmp    $0x1,%ebp
je     1232 <hexDump+0x122>
mov    %ebp,0xc(%rsp)
mov    %ebp,%r12d
mov    $0x1,%ebp
lea    0xe5f(%rip),%r14
jmp    11f7 <hexDump+0xe7>
cs nopw 0x0(%rax,%rax,1)
mov    (%r15),%edi
movzbl (%rbx,%rbp,1),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
movzbl (%rbx,%rbp,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
mov    $0x2e,%ecx
cmovb  %ecx,%eax
mov    %al,0x10(%rsp,%r13,1)
movb   $0x0,0x11(%rsp,%r13,1)
add    $0x1,%rbp
cmp    %rbp,%r12
je     122b <hexDump+0x11b>
mov    %rbp,%r13
and    $0xf,%r13
jne    11c0 <hexDump+0xb0>
mov    (%r15),%edi
lea    0xdfb(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xdeb(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11c0 <hexDump+0xb0>
testb  $0xf,0xc(%rsp)
je     1259 <hexDump+0x149>
add    $0x1,%r12d
lea    0xddc(%rip),%rbx
mov    %r12d,%ebp
mov    (%r15),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebp
test   $0xf,%r12b
mov    %ebp,%r12d
jne    1240 <hexDump+0x130>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [6 x i8] c" %s\0A\00"
@.str.2 = [8 x i8] c" %04x \00"
@.str.3 = [6 x i8] c" %02x\00"
@.str.4 = [4 x i8] c" \00"
define void @hexDump(i8* %0, i8* nocapture %1, i32 %2) {
%4 = alloca [17 x i8]
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %0, null
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %7, %3
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %65
12: ; preds = %10
%13 = zext i32 %2 to i64
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 0)
%16 = load i32, i32* @stderr
%17 = load i8, i8* %1
%18 = zext i8 %17 to i32
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i8, i8* %1
%21 = add i8 %20, -127
%22 = icmp ult i8 %21, -95
%23 = select i1 %22, i8 46, i8 %20
store i8 %23, i8* %5
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 1
store i8 0, i8* %24
%25 = icmp eq i32 %2, 1
br i1 %25, label %29, label %31
26: ; preds = %41
%27 = and i32 %2, 15
%28 = icmp eq i32 %27, 0
br i1 %28, label %65, label %29
29: ; preds = %12, %26
%30 = phi i32 [ 1, %12 ], [ %2, %26 ]
br label %58
31: ; preds = %12, %41
%32 = phi i64 [ %56, %41 ], [ 1, %12 ]
%33 = trunc i64 %32 to i32
%34 = and i32 %33, 15
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %41
41: ; preds = %36, %31
%42 = load i32, i32* @stderr
%43 = getelementptr inbounds i8, i8* %1, i64 %32
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i8, i8* %43
%48 = add i8 %47, -127
%49 = icmp ult i8 %48, -95
%50 = zext i32 %34 to i64
%51 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 %50
%52 = select i1 %49, i8 46, i8 %47
store i8 %52, i8* %51
%53 = add nuw nsw i32 %34, 1
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 %54
store i8 0, i8* %55
%56 = add nuw nsw i64 %32, 1
%57 = icmp eq i64 %56, %13
br i1 %57, label %26, label %31
58: ; preds = %29, %58
%59 = phi i32 [ %62, %58 ], [ %30, %29 ]
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%62 = add nuw nsw i32 %59, 1
%63 = and i32 %62, 15
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %58
65: ; preds = %58, %10, %26
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
ret void
}