#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__ isgraph(unsigned char);
void _pst_debug_hexdump(FILE *out, unsigned char *buf, size_t size, int col) {
  int off = 0, toff;
  int count = 0;
  if (col == -1) {
    col = 30;
  }
  fprintf(out, "\n");
  while (off < size) {
    fprintf(out, "%X\t:", off);
    toff = off;
    while (count < col && off < size) {
      fprintf(out, "%02hhx ", buf[off]);
      off++;
      count++;
    }
    off = toff;
    while (count < col) {
      fprintf(out, "   ");
      count++;
    }
    count = 0;
    fprintf(out, ":");
    while (count < col && off < size) {
      fprintf(out, "%c", isgraph(buf[off]) ? buf[off] : '.');
      off++;
      count++;
    }
    fprintf(out, "\n");
    count = 0;
  }
  fprintf(out, "\n");
}


x86 assembly (clang, -O0):
<_pst_debug_hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1156 <_pst_debug_hexdump+0x36>
movl   $0x1e,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movslq -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    12fd <_pst_debug_hexdump+0x1dd>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x29(%rbp)
jge    11b0 <_pst_debug_hexdump+0x90>
movslq -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
setb   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11c0 <_pst_debug_hexdump+0xa0>
jmp    11f5 <_pst_debug_hexdump+0xd5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1191 <_pst_debug_hexdump+0x71>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1227 <_pst_debug_hexdump+0x107>
mov    -0x8(%rbp),%rdi
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11fb <_pst_debug_hexdump+0xdb>
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x2a(%rbp)
jge    125f <_pst_debug_hexdump+0x13f>
movslq -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
setb   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    126f <_pst_debug_hexdump+0x14f>
jmp    12df <_pst_debug_hexdump+0x1bf>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isgraph@plt>
cmp    $0x0,%rax
je     12a6 <_pst_debug_hexdump+0x186>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x3c(%rbp)
jmp    12b3 <_pst_debug_hexdump+0x193>
mov    $0x2e,%eax
mov    %eax,-0x3c(%rbp)
jmp    12b3 <_pst_debug_hexdump+0x193>
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%edx
lea    0xd52(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1240 <_pst_debug_hexdump+0x120>
mov    -0x8(%rbp),%rdi
lea    0xd16(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x28(%rbp)
jmp    1168 <_pst_debug_hexdump+0x48>
mov    -0x8(%rbp),%rdi
lea    0xcf8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_pst_debug_hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rsi,0x20(%rsp)
mov    %rdi,%r13
cmp    $0xffffffff,%ecx
mov    $0x1e,%r14d
cmovne %ecx,%r14d
mov    $0xa,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
test   %rbx,%rbx
je     12fd <_pst_debug_hexdump+0x1bd>
xor    %r12d,%r12d
mov    %r14d,0xc(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r13,0x18(%rsp)
jmp    11ab <_pst_debug_hexdump+0x6b>
mov    0x10(%rsp),%rbx
mov    $0xa,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
cmp    %rbx,%rbp
jae    12fd <_pst_debug_hexdump+0x1bd>
test   %r14d,%r14d
setg   %r15b
mov    %r13,%rdi
lea    0xe44(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
movslq %r12d,%rbp
cmp    %rbx,%rbp
setb   %cl
and    %r15b,%cl
mov    $0x0,%eax
mov    %cl,0xb(%rsp)
cmp    $0x1,%cl
jne    1222 <_pst_debug_hexdump+0xe2>
mov    0x20(%rsp),%rax
lea    (%rax,%rbp,1),%r14
lea    0x1(%rbp),%r15
xor    %ebx,%ebx
nop
movzbl (%r14,%rbx,1),%edx
mov    %r13,%rdi
lea    0xe06(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0x1(%rbx),%rax
cmp    0xc(%rsp),%eax
jge    121d <_pst_debug_hexdump+0xdd>
add    %r15,%rbx
cmp    0x10(%rsp),%rbx
mov    %rax,%rbx
jb     11f0 <_pst_debug_hexdump+0xb0>
mov    0xc(%rsp),%r14d
cmp    %r14d,%eax
lea    0xde1(%rip),%r15
jge    125a <_pst_debug_hexdump+0x11a>
mov    %r14d,%ebx
sub    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r13,%rcx
call   1050 <fwrite@plt>
add    $0xffffffff,%ebx
jne    1240 <_pst_debug_hexdump+0x100>
mov    $0x3a,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
cmpb   $0x0,0xb(%rsp)
je     1190 <_pst_debug_hexdump+0x50>
lea    0x1(%rbp),%r14
shl    $0x20,%rbp
mov    $0x1,%r15d
mov    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%r13
mov    0x20(%rsp),%rbx
movzbl -0x1(%rbx,%r14,1),%edi
call   1060 <isgraph@plt>
test   %rax,%rax
je     12b0 <_pst_debug_hexdump+0x170>
movzbl -0x1(%rbx,%r14,1),%edi
jmp    12b5 <_pst_debug_hexdump+0x175>
mov    $0x2e,%edi
mov    0x18(%rsp),%rsi
call   1030 <fputc@plt>
movabs $0x100000000,%rax
add    %rax,%rbp
add    $0x1,%r12d
cmp    0xc(%rsp),%r15d
mov    %r13,%rbx
jge    12ea <_pst_debug_hexdump+0x1aa>
lea    0x1(%r14),%rax
add    $0x1,%r15d
cmp    %rbx,%r14
mov    %rax,%r14
jb     1290 <_pst_debug_hexdump+0x150>
sar    $0x20,%rbp
mov    0xc(%rsp),%r14d
mov    0x18(%rsp),%r13
jmp    1195 <_pst_debug_hexdump+0x55>
mov    $0xa,%edi
mov    %r13,%rsi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

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

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