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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isprint(unsigned char const);
void dumpHex(FILE *fp, unsigned char const *buf, int len) {
  int i;
  int base;
  if (!fp)
    return;
  if (len >= 2 && buf[0] == 0xC0 && buf[1] == 0x23) {
    fprintf(fp, "(PAP Authentication Frame -- Contents not dumped)\n");
    return;
  }
  for (base = 0; base < len; base += 16) {
    for (i = base; i < base + 16; i++) {
      if (i < len) {
        fprintf(fp, "%02x ", (unsigned)buf[i]);
      } else {
        fprintf(fp, "   ");
      }
    }
    fprintf(fp, "  ");
    for (i = base; i < base + 16; i++) {
      if (i < len) {
        if (isprint(buf[i])) {
          fprintf(fp, "%c", buf[i]);
        } else {
          fprintf(fp, ".");
        }
      } else {
        break;
      }
    }
    fprintf(fp, "\n");
  }
}


x86 assembly (clang, -O0):
<dumpHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1143 <dumpHex+0x23>
jmp    12c7 <dumpHex+0x1a7>
cmpl   $0x2,-0x14(%rbp)
jl     1187 <dumpHex+0x67>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xc0,%eax
jne    1187 <dumpHex+0x67>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x23,%eax
jne    1187 <dumpHex+0x67>
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12c7 <dumpHex+0x1a7>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12c7 <dumpHex+0x1a7>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x10,%ecx
cmp    %ecx,%eax
jge    1205 <dumpHex+0xe5>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e0 <dumpHex+0xc0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11f2 <dumpHex+0xd2>
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11f7 <dumpHex+0xd7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a0 <dumpHex+0x80>
mov    -0x8(%rbp),%rdi
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x10,%ecx
cmp    %ecx,%eax
jge    12a7 <dumpHex+0x187>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128f <dumpHex+0x16f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1278 <dumpHex+0x158>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    128a <dumpHex+0x16a>
mov    -0x8(%rbp),%rdi
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1294 <dumpHex+0x174>
jmp    12a7 <dumpHex+0x187>
jmp    1299 <dumpHex+0x179>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    121d <dumpHex+0xfd>
mov    -0x8(%rbp),%rdi
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x1c(%rbp)
jmp    118e <dumpHex+0x6e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpHex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %rdi,%rdi
je     12ba <dumpHex+0x17a>
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%r12
cmp    $0x2,%edx
jl     1198 <dumpHex+0x58>
cmpb   $0xc0,0x0(%rbp)
jne    11a2 <dumpHex+0x62>
cmpb   $0x23,0x1(%rbp)
jne    11a2 <dumpHex+0x62>
lea    0xe88(%rip),%rdi
mov    $0x32,%esi
mov    $0x1,%edx
mov    %r12,%rcx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fwrite@plt>
cmp    $0x1,%r15d
jne    12ba <dumpHex+0x17a>
mov    %r15d,%ebx
mov    $0x1,%eax
mov    %rax,0x10(%rsp)
xor    %r14d,%r14d
mov    %r15d,0xc(%rsp)
jmp    11df <dumpHex+0x9f>
nopl   0x0(%rax)
mov    $0xa,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
addq   $0x10,0x10(%rsp)
cmp    %r15d,%r14d
mov    %r13,%rbx
jge    12ba <dumpHex+0x17a>
mov    $0x10,%r13d
mov    %r14,%r15
jmp    1213 <dumpHex+0xd3>
nopw   0x0(%rax,%rax,1)
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xe38(%rip),%rdi
mov    %r12,%rcx
call   1060 <fwrite@plt>
add    $0x1,%r15
add    $0xffffffffffffffff,%r13
je     1240 <dumpHex+0x100>
cmp    %rbx,%r15
jge    11f0 <dumpHex+0xb0>
movzbl 0x0(%rbp,%r15,1),%edx
mov    %r12,%rdi
lea    0xe0b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1209 <dumpHex+0xc9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%r13
add    $0x10,%r14
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xde2(%rip),%rdi
mov    %r12,%rcx
call   1060 <fwrite@plt>
mov    0x10(%rsp),%rbx
mov    0xc(%rsp),%r15d
nopw   0x0(%rax,%rax,1)
movzbl -0x1(%rbp,%rbx,1),%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     1290 <dumpHex+0x150>
movzbl -0x1(%rbp,%rbx,1),%edi
jmp    1295 <dumpHex+0x155>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2e,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    %r14,%rbx
jae    11c0 <dumpHex+0x80>
mov    %rbx,%rax
add    $0x1,%rax
cmp    %r15d,%ebx
mov    %rax,%rbx
jl     1270 <dumpHex+0x130>
jmp    11c0 <dumpHex+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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