#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 = addr;
  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("  %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    1239 <hexDump+0x129>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119c <hexDump+0x8c>
cmpl   $0x0,-0x18(%rbp)
je     118b <hexDump+0x7b>
lea    -0x30(%rbp),%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe64(%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     11e0 <hexDump+0xd0>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    11f8 <hexDump+0xe8>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movb   $0x2e,-0x30(%rbp,%rax,1)
jmp    1215 <hexDump+0x105>
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    123e <hexDump+0x12e>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     126e <hexDump+0x15e>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    123e <hexDump+0x12e>
lea    -0x30(%rbp),%rsi
lea    0xd8c(%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     1139 <hexDump+0x29>
mov    %rdi,%rsi
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
jle    1246 <hexDump+0x136>
lea    0xec3(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl (%rbx),%esi
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <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     1215 <hexDump+0x105>
mov    %ebp,0xc(%rsp)
mov    %ebp,%r15d
mov    $0x1,%ebp
lea    0xe73(%rip),%r14
jmp    11e0 <hexDump+0xd0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <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     120e <hexDump+0xfe>
mov    %rbp,%r13
and    $0xf,%r13
jne    11b0 <hexDump+0xa0>
lea    0xe15(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe08(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11b0 <hexDump+0xa0>
testb  $0xf,0xc(%rsp)
je     1246 <hexDump+0x136>
add    $0x1,%r15d
lea    0xdf9(%rip),%rbx
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
test   $0xf,%r15b
mov    %ebp,%r15d
jne    1230 <hexDump+0x120>
lea    0xdb8(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <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 = [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 %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 = %78, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %81
21: ; preds = %17
%22 = load i32, i32* %7
%23 = srem i32 %22, 16
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = load i32, i32* %7
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %25
%32 = load i32, i32* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %21
%35 = load i8*, i8** %9
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i8*, i8** %9
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = icmp slt i32 %47, 32
br i1 %48, label %57, label %49
49: ; preds = %34
%50 = load i8*, i8** %9
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = icmp sgt i32 %55, 126
br i1 %56, label %57, label %62
57: ; preds = %49, %34
%58 = load i32, i32* %7
%59 = srem i32 %58, 16
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 %60
store i8 46, i8* %61
br label %72
62: ; preds = %49
%63 = load i8*, i8** %9
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = load i32, i32* %7
%69 = srem i32 %68, 16
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 %70
store i8 %67, i8* %71
br label %72
72: ; preds = %62, %57
%73 = load i32, i32* %7
%74 = srem i32 %73, 16
%75 = add nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 %76
store i8 0, i8* %77
br label %78
78: ; preds = %72
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %17
81: ; preds = %17
br label %82
82: ; preds = %86, %81
%83 = load i32, i32* %7
%84 = srem i32 %83, 16
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %90
86: ; preds = %82
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%88 = load i32, i32* %7
%89 = add nsw i32 %88, 1
store i32 %89, i32* %7
br label %82
90: ; preds = %82
%91 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %91)
ret void
}

LLVM IR (-O2):
@.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 %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 %58
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.2, 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.3, 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 = %36
%24 = and i32 %2, 15
%25 = icmp eq i32 %24, 0
br i1 %25, label %58, label %26
26: ; preds = %11, %23
%27 = phi i32 [ 1, %11 ], [ %2, %23 ]
br label %52
28: ; preds = %11, %36
%29 = phi i64 [ %50, %36 ], [ 1, %11 ]
%30 = trunc i64 %29 to i32
%31 = and i32 %30, 15
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %36
36: ; preds = %33, %28
%37 = getelementptr inbounds i8, i8* %1, i64 %29
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i8, i8* %37
%42 = add i8 %41, -127
%43 = icmp ult i8 %42, -95
%44 = zext i32 %31 to i64
%45 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 %44
%46 = select i1 %43, i8 46, i8 %41
store i8 %46, i8* %45
%47 = add nuw nsw i32 %31, 1
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 %48
store i8 0, i8* %49
%50 = add nuw nsw i64 %29, 1
%51 = icmp eq i64 %50, %12
br i1 %51, label %23, label %28
52: ; preds = %26, %52
%53 = phi i32 [ %55, %52 ], [ %27, %26 ]
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%55 = add nuw nsw i32 %53, 1
%56 = and i32 %55, 15
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %52
58: ; preds = %52, %9, %23
%59 = 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
}