#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';
  }
}


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>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexDump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%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    117e <hexDump+0x6e>
lea    0xec7(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl (%rbx),%esi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl (%rbx),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
mov    $0x2e,%r14d
cmovb  %r14d,%eax
mov    %al,(%rsp)
movb   $0x0,0x1(%rsp)
cmp    $0x1,%ebp
jne    118d <hexDump+0x7d>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%r15d
mov    $0x1,%ebp
lea    0xe77(%rip),%r13
jmp    11cf <hexDump+0xbf>
xchg   %ax,%ax
movzbl (%rbx,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl (%rbx,%rbp,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
cmovb  %r14d,%eax
mov    %al,(%rsp,%r12,1)
movb   $0x0,0x1(%rsp,%r12,1)
add    $0x1,%rbp
cmp    %rbp,%r15
je     117e <hexDump+0x6e>
mov    %rbp,%r12
and    $0xf,%r12
jne    11a0 <hexDump+0x90>
lea    0xe26(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe1b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a0 <hexDump+0x90>

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