#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isprint(char);
int /*<<< orphan*/ isspace(char);
void DumpHex(FILE *fp, const uint8_t *data, unsigned len) {
  char str[18];
  unsigned i;
  unsigned pos;
  char c;
  for (i = 0, pos = 0; i < len; i++, pos++) {
    if (pos == 17) {
      str[pos] = 0;
      fprintf(fp, "  %s\n", str);
      pos = 0;
    } else if (pos == 8) {
      str[pos] = ' ';
      pos++;
      fprintf(fp, "%s", " ");
    }
    c = (char)data[i];
    if (isprint(c) && (c == ' ' || !isspace(c)))
      str[pos] = c;
    else
      str[pos] = '.';
    fprintf(fp, "%02X ", data[i]);
  }
  if (pos) {
    for (; pos < 17; pos++) {
      if (pos == 8) {
        str[pos] = ' ';
        pos++;
        fprintf(fp, "%s", "    ");
      } else {
        fprintf(fp, "%s", "   ");
      }
      str[pos] = 0;
    }
    str[pos] = 0;
    fprintf(fp, "  %s\n", str);
  }
}


x86 assembly (clang, -O0):
<DumpHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1253 <DumpHex+0x123>
cmpl   $0x11,-0x38(%rbp)
jne    1191 <DumpHex+0x61>
mov    -0x38(%rbp),%eax
movb   $0x0,-0x30(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x38(%rbp)
jmp    11ca <DumpHex+0x9a>
cmpl   $0x8,-0x38(%rbp)
jne    11c5 <DumpHex+0x95>
mov    -0x38(%rbp),%eax
movb   $0x20,-0x30(%rbp,%rax,1)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4f(%rip),%rsi
lea    0xe54(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11ca <DumpHex+0x9a>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %al,-0x39(%rbp)
movsbl -0x39(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     1218 <DumpHex+0xe8>
movsbl -0x39(%rbp),%eax
cmp    $0x20,%eax
je     1209 <DumpHex+0xd9>
movsbl -0x39(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    1218 <DumpHex+0xe8>
mov    -0x39(%rbp),%cl
mov    -0x38(%rbp),%eax
mov    %cl,-0x30(%rbp,%rax,1)
jmp    1220 <DumpHex+0xf0>
mov    -0x38(%rbp),%eax
movb   $0x2e,-0x30(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1151 <DumpHex+0x21>
cmpl   $0x0,-0x38(%rbp)
je     12f2 <DumpHex+0x1c2>
jmp    1262 <DumpHex+0x132>
cmpl   $0x11,-0x38(%rbp)
jae    12d4 <DumpHex+0x1a4>
cmpl   $0x8,-0x38(%rbp)
jne    12a5 <DumpHex+0x175>
mov    -0x38(%rbp),%eax
movb   $0x20,-0x30(%rbp,%rax,1)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd74(%rip),%rsi
lea    0xd76(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12be <DumpHex+0x18e>
mov    -0x8(%rbp),%rdi
lea    0xd56(%rip),%rsi
lea    0xd59(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x38(%rbp),%eax
movb   $0x0,-0x30(%rbp,%rax,1)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1262 <DumpHex+0x132>
mov    -0x38(%rbp),%eax
movb   $0x0,-0x30(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DumpHex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edx,%edx
je     12bf <DumpHex+0x16f>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %edx,%eax
mov    %rax,0x20(%rsp)
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11b2 <DumpHex+0x62>
nopl   0x0(%rax,%rax,1)
mov    $0x2e,%r13b
mov    %r12d,%eax
mov    %r13b,(%rsp,%rax,1)
mov    (%rbx,%r15,4),%edx
mov    %r14,%rdi
lea    0xe6e(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%r15
add    $0x1,%r12d
cmp    %r15,0x20(%rsp)
je     1231 <DumpHex+0xe1>
cmp    $0x8,%r12d
je     11e0 <DumpHex+0x90>
cmp    $0x11,%r12d
jne    11f8 <DumpHex+0xa8>
movb   $0x0,0x11(%rsp)
xor    %r12d,%r12d
mov    %r14,%rdi
lea    0xe30(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11f8 <DumpHex+0xa8>
nopl   0x0(%rax)
movb   $0x20,0x8(%rsp)
mov    $0x20,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    $0x9,%r12d
mov    (%rbx,%r15,4),%r13d
movsbl %r13b,%ebp
mov    %ebp,%edi
call   1060 <isprint@plt>
test   %rax,%rax
je     1180 <DumpHex+0x30>
movzbl %r13b,%eax
cmp    $0x20,%eax
je     1183 <DumpHex+0x33>
mov    %ebp,%edi
call   1030 <isspace@plt>
test   %eax,%eax
jne    1180 <DumpHex+0x30>
jmp    1183 <DumpHex+0x33>
test   %r12d,%r12d
je     12bf <DumpHex+0x16f>
cmp    $0x10,%r12d
ja     12a2 <DumpHex+0x152>
lea    0xdc5(%rip),%r15
lea    0xdbf(%rip),%rbx
jmp    127a <DumpHex+0x12a>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1070 <fwrite@plt>
mov    %r12d,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0x1(%r12),%eax
cmp    $0x10,%r12d
mov    %eax,%r12d
jae    12a5 <DumpHex+0x155>
cmp    $0x8,%r12d
jne    1250 <DumpHex+0x100>
movb   $0x20,0x8(%rsp)
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1070 <fwrite@plt>
mov    $0x9,%r12d
jmp    1265 <DumpHex+0x115>
mov    %r12d,%eax
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xd4e(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c" %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [6 x i8] c"%02X \00"
@.str.4 = [5 x i8] c" \00"
@.str.5 = [4 x i8] c" \00"
define void @DumpHex(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [18 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %72, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %6
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %77
15: ; preds = %11
%16 = load i32, i32* %9
%17 = icmp eq i32 %16, 17
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %9
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %20
store i8 0, i8* %21
%22 = load i32*, i32** %4
%23 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 0
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 0, i32* %9
br label %37
25: ; preds = %15
%26 = load i32, i32* %9
%27 = icmp eq i32 %26, 8
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load i32, i32* %9
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %30
store i8 32, i8* %31
%32 = load i32, i32* %9
%33 = add i32 %32, 1
store i32 %33, i32* %9
%34 = load i32*, i32** %4
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %28, %25
br label %37
37: ; preds = %36, %18
%38 = load i32*, i32** %5
%39 = load i32, i32* %8
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = trunc i32 %42 to i8
store i8 %43, i8* %10
%44 = load i8, i8* %10
%45 = call i64 @isprint(i8 signext %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %60
47: ; preds = %37
%48 = load i8, i8* %10
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 32
br i1 %50, label %55, label %51
51: ; preds = %47
%52 = load i8, i8* %10
%53 = call i32 @isspace(i8 signext %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %60, label %55
55: ; preds = %51, %47
%56 = load i8, i8* %10
%57 = load i32, i32* %9
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %58
store i8 %56, i8* %59
br label %64
60: ; preds = %51, %37
%61 = load i32, i32* %9
%62 = zext i32 %61 to i64
%63 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %62
store i8 46, i8* %63
br label %64
64: ; preds = %60, %55
%65 = load i32*, i32** %4
%66 = load i32*, i32** %5
%67 = load i32, i32* %8
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
%70 = load i32, i32* %69
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %64
%73 = load i32, i32* %8
%74 = add i32 %73, 1
store i32 %74, i32* %8
%75 = load i32, i32* %9
%76 = add i32 %75, 1
store i32 %76, i32* %9
br label %11
77: ; preds = %11
%78 = load i32, i32* %9
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %112
80: ; preds = %77
br label %81
81: ; preds = %102, %80
%82 = load i32, i32* %9
%83 = icmp ult i32 %82, 17
br i1 %83, label %84, label %105
84: ; preds = %81
%85 = load i32, i32* %9
%86 = icmp eq i32 %85, 8
br i1 %86, label %87, label %95
87: ; preds = %84
%88 = load i32, i32* %9
%89 = zext i32 %88 to i64
%90 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %89
store i8 32, i8* %90
%91 = load i32, i32* %9
%92 = add i32 %91, 1
store i32 %92, i32* %9
%93 = load i32*, i32** %4
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %98
95: ; preds = %84
%96 = load i32*, i32** %4
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %98
98: ; preds = %95, %87
%99 = load i32, i32* %9
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %100
store i8 0, i8* %101
br label %102
102: ; preds = %98
%103 = load i32, i32* %9
%104 = add i32 %103, 1
store i32 %104, i32* %9
br label %81
105: ; preds = %81
%106 = load i32, i32* %9
%107 = zext i32 %106 to i64
%108 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %107
store i8 0, i8* %108
%109 = load i32*, i32** %4
%110 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 0
%111 = call i32 (i32*, i8*, ...) @fprintf(i32* %109, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %110)
br label %112
112: ; preds = %105, %77
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c" %s\0A\00"
@.str.3 = [6 x i8] c"%02X \00"
@.str.4 = [5 x i8] c" \00"
@.str.5 = [4 x i8] c" \00"
define void @DumpHex(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = alloca [18 x i8]
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%6 = icmp eq i32 %2, 0
br i1 %6, label %65, label %7
7: ; preds = %3
%8 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 8
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 17
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %7, %32
%12 = phi i64 [ 0, %7 ], [ %38, %32 ]
%13 = phi i32 [ 0, %7 ], [ %39, %32 ]
switch i32 %13, label %18 [
i32 17, label %14
i32 8, label %16
]
14: ; preds = %11
store i8 0, i8* %9
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %18
16: ; preds = %11
store i8 32, i8* %8
%17 = call i32 @fputc(i32 32, i32* %0)
br label %18
18: ; preds = %11, %16, %14
%19 = phi i32 [ 0, %14 ], [ 9, %16 ], [ %13, %11 ]
%20 = getelementptr inbounds i32, i32* %1, i64 %12
%21 = load i32, i32* %20
%22 = trunc i32 %21 to i8
%23 = call i64 @isprint(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %18
%26 = and i32 %21, 255
%27 = icmp eq i32 %26, 32
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = call i32 @isspace(i8 signext %22)
%30 = icmp eq i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %28, %18
br label %32
32: ; preds = %25, %28, %31
%33 = phi i8 [ 46, %31 ], [ %22, %28 ], [ %22, %25 ]
%34 = zext i32 %19 to i64
%35 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 %34
store i8 %33, i8* %35
%36 = load i32, i32* %20
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = add nuw nsw i64 %12, 1
%39 = add i32 %19, 1
%40 = icmp eq i64 %38, %10
br i1 %40, label %41, label %11
41: ; preds = %32
%42 = icmp eq i32 %39, 0
br i1 %42, label %65, label %43
43: ; preds = %41
%44 = icmp ult i32 %39, 17
br i1 %44, label %45, label %60
45: ; preds = %43
%46 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 8
br label %47
47: ; preds = %45, %54
%48 = phi i32 [ %39, %45 ], [ %58, %54 ]
%49 = icmp eq i32 %48, 8
br i1 %49, label %50, label %52
50: ; preds = %47
store i8 32, i8* %46
%51 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %0)
br label %54
52: ; preds = %47
%53 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %0)
br label %54
54: ; preds = %52, %50
%55 = phi i32 [ 9, %50 ], [ %48, %52 ]
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 %56
store i8 0, i8* %57
%58 = add nuw nsw i32 %55, 1
%59 = icmp ult i32 %55, 16
br i1 %59, label %47, label %60
60: ; preds = %54, %43
%61 = phi i32 [ %39, %43 ], [ %58, %54 ]
%62 = zext i32 %61 to i64
%63 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 %62
store i8 0, i8* %63
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %65
65: ; preds = %3, %60, %41
ret void
}