#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*/ puts(char *);
int /*<<< orphan*/ screen_print_int(unsigned char, int);
void hexDump(char *desc, void *addr, int len) {
  int i;
  char buff[17];
  unsigned char *pc = (unsigned char *)addr;
  if (desc)
    puts(desc);
  puts(":");
  if (!len) {
    puts("  ZERO LENGTH\n");
    return;
  }
  if (len < 0) {
    puts("  NEGATIVE LENGTH\n");
    return;
  }
  for (i = 0; i < len; i++) {
    if ((i % 16) == 0) {
      if (i != 0) {
        puts(buff);
        puts("\n");
      }
      screen_print_int(i, 16);
      puts(": ");
    }
    screen_print_int(pc[i], 16);
    puts(" ");
    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) {
    puts("   ");
    i++;
  }
  puts("  ");
  puts(buff);
  puts("\n");
}


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     114f <hexDump+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <puts@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1176 <hexDump+0x56>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
jmp    12ec <hexDump+0x1cc>
cmpl   $0x0,-0x14(%rbp)
jge    1191 <hexDump+0x71>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
jmp    12ec <hexDump+0x1cc>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1298 <hexDump+0x178>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f3 <hexDump+0xd3>
cmpl   $0x0,-0x18(%rbp)
je     11d7 <hexDump+0xb7>
lea    -0x30(%rbp),%rdi
call   1030 <puts@plt>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%eax
mov    $0x10,%esi
movzbl %al,%edi
call   1040 <screen_print_int@plt>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    $0x10,%esi
movzbl (%rax,%rcx,1),%edi
call   1040 <screen_print_int@plt>
lea    0xe19(%rip),%rdi
call   1030 <puts@plt>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     123f <hexDump+0x11f>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    1257 <hexDump+0x137>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movb   $0x2e,-0x30(%rbp,%rax,1)
jmp    1274 <hexDump+0x154>
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    1198 <hexDump+0x78>
jmp    129d <hexDump+0x17d>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     12cb <hexDump+0x1ab>
lea    0xd6f(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    129d <hexDump+0x17d>
lea    0xd56(%rip),%rdi
call   1030 <puts@plt>
lea    -0x30(%rbp),%rdi
call   1030 <puts@plt>
lea    0xd3b(%rip),%rdi
call   1030 <puts@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     113d <hexDump+0x1d>
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
je     1245 <hexDump+0x125>
js     124e <hexDump+0x12e>
xor    %edi,%edi
mov    $0x10,%esi
call   1040 <screen_print_int@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
movzbl (%rbx),%edi
mov    $0x10,%esi
call   1040 <screen_print_int@plt>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
movzbl (%rbx),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
mov    $0x2e,%r15d
cmovb  %r15d,%eax
mov    %al,0x10(%rsp)
movb   $0x0,0x11(%rsp)
mov    $0x1,%r14d
cmp    $0x1,%ebp
je     125e <hexDump+0x13e>
mov    %ebp,0xc(%rsp)
mov    %ebp,%r14d
mov    $0x1,%r12d
lea    0xe62(%rip),%rbp
jmp    120a <hexDump+0xea>
nopl   0x0(%rax)
movzbl (%rbx,%r12,1),%edi
mov    $0x10,%esi
call   1040 <screen_print_int@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
movzbl (%rbx,%r12,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
cmovb  %r15d,%eax
mov    %al,0x10(%rsp,%r13,1)
movb   $0x0,0x11(%rsp,%r13,1)
add    $0x1,%r12
cmp    %r12,%r14
je     1257 <hexDump+0x137>
mov    %r12,%r13
and    $0xf,%r13
jne    11d0 <hexDump+0xb0>
lea    0x10(%rsp),%rdi
call   1030 <puts@plt>
lea    0xdfe(%rip),%rdi
call   1030 <puts@plt>
movzbl %r12b,%edi
mov    $0x10,%esi
call   1040 <screen_print_int@plt>
lea    0xde6(%rip),%rdi
call   1030 <puts@plt>
jmp    11d0 <hexDump+0xb0>
lea    0xdb6(%rip),%rdi
jmp    12a1 <hexDump+0x181>
lea    0xdbc(%rip),%rdi
jmp    12a1 <hexDump+0x181>
testb  $0xf,0xc(%rsp)
je     1284 <hexDump+0x164>
add    $0x1,%r14d
lea    0xdbe(%rip),%rbx
mov    %r14d,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
test   $0xf,%r14b
mov    %ebp,%r14d
jne    1270 <hexDump+0x150>
lea    0xd9d(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
call   1030 <puts@plt>
lea    0xd81(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

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

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