#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, diff;
  unsigned char buff[17];
  unsigned char *pc;
  uintptr_t begin = (uintptr_t)addr & ~((uintptr_t)0xF);
  pc = (unsigned char *)begin;
  diff = (uintptr_t)addr - (uintptr_t)pc;
  len += diff;
  if (desc != NULL)
    printf("%s:\n", desc);
  for (i = 0; i < len; i++) {
    if ((i % 16) == 0) {
      if (i != 0)
        printf("  %s\n", buff);
      printf("  %p ", pc + i);
    }
    if ((i % 8) == 0) {
      printf(" ");
    }
    if (i < diff) {
      printf("   ");
    } else {
      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("   ");
    if ((i % 8) == 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
and    $0xfffffffffffffff0,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     116b <hexDump+0x5b>
mov    -0x8(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12a5 <hexDump+0x195>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c7 <hexDump+0xb7>
cmpl   $0x0,-0x18(%rbp)
je     11ae <hexDump+0x9e>
lea    -0x30(%rbp),%rsi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e9 <hexDump+0xd9>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1208 <hexDump+0xf8>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1222 <hexDump+0x112>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xdfa(%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     124c <hexDump+0x13c>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    1264 <hexDump+0x154>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movb   $0x2e,-0x30(%rbp,%rax,1)
jmp    1281 <hexDump+0x171>
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    1172 <hexDump+0x62>
jmp    12aa <hexDump+0x19a>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     12fc <hexDump+0x1ec>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12ee <hexDump+0x1de>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12aa <hexDump+0x19a>
lea    -0x30(%rbp),%rsi
lea    0xcfe(%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,%r13d
mov    %rsi,%rbx
mov    %ebx,%r14d
and    $0xf,%r14d
add    %r14d,%r13d
test   %rdi,%rdi
je     1154 <hexDump+0x34>
mov    %rdi,%rsi
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13d,%r13d
jle    12c5 <hexDump+0x1a5>
and    $0xfffffffffffffff0,%rbx
lea    0xea3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
je     1191 <hexDump+0x71>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a2 <hexDump+0x82>
movzbl (%rbx),%esi
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%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,%ebp
cmp    $0x1,%r13d
je     128b <hexDump+0x16b>
mov    %r14d,%r12d
mov    %r13d,0xc(%rsp)
mov    %r13d,%r13d
mov    $0x1,%ebp
jmp    1214 <hexDump+0xf4>
xchg   %ax,%ax
movzbl (%rbx,%rbp,1),%esi
lea    0xe2a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx,%rbp,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
cmovb  %r15d,%eax
mov    %al,0x10(%rsp,%r14,1)
movb   $0x0,0x11(%rsp,%r14,1)
add    $0x1,%rbp
cmp    %rbp,%r13
je     1281 <hexDump+0x161>
mov    %rbp,%r14
and    $0xf,%r14
je     1230 <hexDump+0x110>
test   $0x7,%bpl
je     125b <hexDump+0x13b>
cmp    %r12,%rbp
jae    11e0 <hexDump+0xc0>
jmp    126e <hexDump+0x14e>
nopw   0x0(%rax,%rax,1)
lea    0xdce(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbp,1),%rsi
lea    0xdbd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x7,%bpl
jne    1223 <hexDump+0x103>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    %r12,%rbp
jae    11e0 <hexDump+0xc0>
lea    0xd9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f2 <hexDump+0xd2>
mov    0xc(%rsp),%eax
mov    %eax,%ebp
test   $0xf,%al
je     12c5 <hexDump+0x1a5>
lea    0xd7f(%rip),%rbx
jmp    12a9 <hexDump+0x189>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
test   $0xf,%bpl
je     12c5 <hexDump+0x1a5>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x7,%bpl
jne    12a0 <hexDump+0x180>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    12a0 <hexDump+0x180>
lea    0xd39(%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 = [6 x i8] c" %s\0A\00"
@.str.2 = [6 x i8] c" %p \00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [4 x i8] c" \00"
@.str.5 = [6 x i8] c" %02x\00"
define void @hexDump(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [17 x i8]
%10 = alloca i8*
%11 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%12 = load i8*, i8** %5
%13 = ptrtoint i8* %12 to i64
%14 = and i64 %13, -16
store i64 %14, i64* %11
%15 = load i64, i64* %11
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %10
%17 = load i8*, i8** %5
%18 = ptrtoint i8* %17 to i64
%19 = load i8*, i8** %10
%20 = ptrtoint i8* %19 to i64
%21 = sub i64 %18, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = load i32, i32* %6
%25 = add nsw i32 %24, %23
store i32 %25, i32* %6
%26 = load i8*, i8** %4
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %31
28: ; preds = %3
%29 = load i8*, i8** %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %3
store i32 0, i32* %7
br label %32
32: ; preds = %109, %31
%33 = load i32, i32* %7
%34 = load i32, i32* %6
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %112
36: ; preds = %32
%37 = load i32, i32* %7
%38 = srem i32 %37, 16
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %52
40: ; preds = %36
%41 = load i32, i32* %7
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %43, %40
%47 = load i8*, i8** %10
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %46, %36
%53 = load i32, i32* %7
%54 = srem i32 %53, 8
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %52
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %52
%59 = load i32, i32* %7
%60 = load i32, i32* %8
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %72
64: ; preds = %58
%65 = load i8*, i8** %10
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %64, %62
%73 = load i8*, i8** %10
%74 = load i32, i32* %7
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = icmp slt i32 %78, 32
br i1 %79, label %88, label %80
80: ; preds = %72
%81 = load i8*, i8** %10
%82 = load i32, i32* %7
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
%87 = icmp sgt i32 %86, 126
br i1 %87, label %88, label %93
88: ; preds = %80, %72
%89 = load i32, i32* %7
%90 = srem i32 %89, 16
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 %91
store i8 46, i8* %92
br label %103
93: ; preds = %80
%94 = load i8*, i8** %10
%95 = load i32, i32* %7
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = load i8, i8* %97
%99 = load i32, i32* %7
%100 = srem i32 %99, 16
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 %101
store i8 %98, i8* %102
br label %103
103: ; preds = %93, %88
%104 = load i32, i32* %7
%105 = srem i32 %104, 16
%106 = add nsw i32 %105, 1
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 %107
store i8 0, i8* %108
br label %109
109: ; preds = %103
%110 = load i32, i32* %7
%111 = add nsw i32 %110, 1
store i32 %111, i32* %7
br label %32
112: ; preds = %32
br label %113
113: ; preds = %124, %112
%114 = load i32, i32* %7
%115 = srem i32 %114, 16
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %127
117: ; preds = %113
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%119 = load i32, i32* %7
%120 = srem i32 %119, 8
%121 = icmp eq i32 %120, 0
br i1 %121, label %122, label %124
122: ; preds = %117
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %124
124: ; preds = %122, %117
%125 = load i32, i32* %7
%126 = add nsw i32 %125, 1
store i32 %126, i32* %7
br label %113
127: ; preds = %113
%128 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %128)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [6 x i8] c" %s\0A\00"
@.str.2 = [6 x i8] c" %p \00"
@.str.4 = [4 x i8] c" \00"
@.str.5 = [6 x i8] c" %02x\00"
define void @hexDump(i8* %0, i8* %1, i32 %2) {
%4 = alloca [17 x i8]
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%6 = ptrtoint i8* %1 to i64
%7 = and i64 %6, -16
%8 = inttoptr i64 %7 to i8*
%9 = trunc i64 %6 to i32
%10 = and i32 %9, 15
%11 = add i32 %10, %2
%12 = icmp eq i8* %0, null
br i1 %12, label %15, label %13
13: ; preds = %3
%14 = 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 %15
15: ; preds = %13, %3
%16 = icmp sgt i32 %11, 0
br i1 %16, label %17, label %88
17: ; preds = %15
%18 = zext i32 %10 to i64
%19 = zext i32 %11 to i64
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%21 = call i32 @putchar(i32 32)
%22 = icmp eq i32 %10, 0
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load i8, i8* %8
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %25)
br label %29
27: ; preds = %17
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
%30 = load i8, i8* %8
%31 = add i8 %30, -127
%32 = icmp ult i8 %31, -95
%33 = select i1 %32, i8 46, i8 %30
store i8 %33, i8* %5
%34 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 1
store i8 0, i8* %34
%35 = icmp eq i32 %11, 1
br i1 %35, label %39, label %41
36: ; preds = %64
%37 = and i32 %11, 15
%38 = icmp eq i32 %37, 0
br i1 %38, label %88, label %39
39: ; preds = %29, %36
%40 = phi i32 [ 1, %29 ], [ %11, %36 ]
br label %77
41: ; preds = %29, %64
%42 = phi i64 [ %75, %64 ], [ 1, %29 ]
%43 = trunc i64 %42 to i32
%44 = and i32 %43, 15
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %41
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%48 = getelementptr inbounds i8, i8* %8, i64 %42
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %46, %41
%51 = and i32 %43, 7
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 @putchar(i32 32)
br label %55
55: ; preds = %53, %50
%56 = icmp ult i64 %42, %18
br i1 %56, label %57, label %59
57: ; preds = %55
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %64
59: ; preds = %55
%60 = getelementptr inbounds i8, i8* %8, i64 %42
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %59, %57
%65 = getelementptr inbounds i8, i8* %8, i64 %42
%66 = load i8, i8* %65
%67 = add i8 %66, -127
%68 = icmp ult i8 %67, -95
%69 = zext i32 %44 to i64
%70 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 %69
%71 = select i1 %68, i8 46, i8 %66
store i8 %71, i8* %70
%72 = add nuw nsw i32 %44, 1
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 %73
store i8 0, i8* %74
%75 = add nuw nsw i64 %42, 1
%76 = icmp eq i64 %75, %19
br i1 %76, label %36, label %41
77: ; preds = %39, %84
%78 = phi i32 [ %85, %84 ], [ %40, %39 ]
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%80 = and i32 %78, 7
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = call i32 @putchar(i32 32)
br label %84
84: ; preds = %82, %77
%85 = add nuw nsw i32 %78, 1
%86 = and i32 %85, 15
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %77
88: ; preds = %84, %15, %36
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
ret void
}