#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 hexDump(char *desc, void *addr, int len) {
  int i;
  unsigned char buff[17];
  unsigned char *pc = (unsigned char *)addr;
  if (desc != NULL)
    printf("%s:\n", desc);
  for (i = 0; i < len; i++) {
    if (i != 0 && i % 8 == 0)
      printf(" ");
    if ((i % 16) == 0) {
      if (i != 0)
        printf("  %s\n", buff);
      printf("  %04x ", i);
    }
    printf(" %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) {
    printf("   ");
    i++;
  }
  printf("  %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     1148 <hexDump+0x38>
mov    -0x8(%rbp),%rsi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1265 <hexDump+0x155>
cmpl   $0x0,-0x18(%rbp)
je     1187 <hexDump+0x77>
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1187 <hexDump+0x77>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c8 <hexDump+0xb8>
cmpl   $0x0,-0x18(%rbp)
je     11b7 <hexDump+0xa7>
lea    -0x30(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     120c <hexDump+0xfc>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    1224 <hexDump+0x114>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movb   $0x2e,-0x30(%rbp,%rax,1)
jmp    1241 <hexDump+0x131>
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    114f <hexDump+0x3f>
jmp    126a <hexDump+0x15a>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     129a <hexDump+0x18a>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    126a <hexDump+0x15a>
lea    -0x30(%rbp),%rsi
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@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     1149 <hexDump+0x29>
mov    %rdi,%rsi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    1266 <hexDump+0x146>
lea    0xeb3(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%esi
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
mov    $0x2e,%r12d
cmovb  %r12d,%eax
mov    %al,0x10(%rsp)
movb   $0x0,0x11(%rsp)
mov    $0x1,%r15d
cmp    $0x1,%ebp
je     1235 <hexDump+0x115>
mov    %ebp,0xc(%rsp)
mov    %ebp,%r15d
mov    $0x1,%ebp
lea    0xe63(%rip),%r14
jmp    11f0 <hexDump+0xd0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx,%rbp,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
cmovb  %r12d,%eax
mov    %al,0x10(%rsp,%r13,1)
movb   $0x0,0x11(%rsp,%r13,1)
add    $0x1,%rbp
cmp    %rbp,%r15
je     122e <hexDump+0x10e>
test   $0x7,%bpl
jne    1200 <hexDump+0xe0>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %rbp,%r13
and    $0xf,%r13
jne    11c0 <hexDump+0xa0>
lea    0xdf5(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c0 <hexDump+0xa0>
testb  $0xf,0xc(%rsp)
je     1266 <hexDump+0x146>
add    $0x1,%r15d
lea    0xdd9(%rip),%rbx
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
test   $0xf,%r15b
mov    %ebp,%r15d
jne    1250 <hexDump+0x130>
lea    0xd98(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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