#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void _hex_dump(char *buf, int len) {
  int i;
  fprintf(stderr, "**********************start**********************\n");
  for (i = 0; i < len; i++) {
    fprintf(stderr, "%02X ", (unsigned char)buf[i]);
    if (i % 8 == 7) {
      fprintf(stderr, " ");
    }
    if (i % 16 == 15) {
      fprintf(stderr, "\n");
    }
  }
  if (!((--i) % 16 == 15)) {
    fprintf(stderr, "\n");
  }
  fprintf(stderr, "********************** end **********************\n");
}


x86 assembly (clang, -O0):
<_hex_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2eba(%rip),%rax
mov    (%rax),%edi
lea    0xed1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d5 <_hex_dump+0xc5>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x7,%edx
jne    1197 <_hex_dump+0x87>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    11c2 <_hex_dump+0xb2>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11c7 <_hex_dump+0xb7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <_hex_dump+0x2d>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
je     1206 <_hex_dump+0xf6>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_hex_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2eb8(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xece(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r14d,%r14d
jle    11cc <_hex_dump+0xbc>
mov    %r14,(%rsp)
mov    %r14d,%r14d
lea    0xee3(%rip),%r15
lea    0xf13(%rip),%r13
xor    %r12d,%r12d
jmp    1169 <_hex_dump+0x59>
nopl   0x0(%rax)
add    $0x1,%r12
cmp    %r12,%r14
je     11ad <_hex_dump+0x9d>
mov    0x0(%rbp),%edi
movzbl (%rbx,%r12,1),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r12d,%eax
not    %eax
test   $0x7,%al
jne    1195 <_hex_dump+0x85>
mov    0x0(%rbp),%edi
lea    0xea9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r12d,%eax
not    %eax
test   $0xf,%al
jne    1160 <_hex_dump+0x50>
mov    0x0(%rbp),%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1160 <_hex_dump+0x50>
mov    (%rsp),%rdx
lea    -0x1(%rdx),%eax
lea    0xe(%rdx),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffff0,%ecx
neg    %ecx
lea    (%rdx,%rcx,1),%eax
add    $0xffffffff,%eax
cmp    $0xf,%eax
je     11dd <_hex_dump+0xcd>
mov    0x0(%rbp),%edi
lea    0xe94(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe52(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"**********************start**********************\0A\00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [51 x i8] c"********************** end **********************\0A\00"
define void @_hex_dump(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* @stderr
%7 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %8
8: ; preds = %35, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %38
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %5
%22 = srem i32 %21, 8
%23 = icmp eq i32 %22, 7
br i1 %23, label %24, label %27
24: ; preds = %12
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %24, %12
%28 = load i32, i32* %5
%29 = srem i32 %28, 16
%30 = icmp eq i32 %29, 15
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %31, %27
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %8
38: ; preds = %8
%39 = load i32, i32* %5
%40 = add nsw i32 %39, -1
store i32 %40, i32* %5
%41 = srem i32 %40, 16
%42 = icmp eq i32 %41, 15
br i1 %42, label %46, label %43
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %43, %38
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"**********************start**********************\0A\00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [51 x i8] c"********************** end **********************\0A\00"
define void @_hex_dump(i8* nocapture %0, i32 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %34
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %27
%9 = phi i64 [ 0, %6 ], [ %28, %27 ]
%10 = load i32, i32* @stderr
%11 = getelementptr inbounds i8, i8* %0, i64 %9
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = trunc i64 %9 to i32
%16 = and i32 %15, 7
%17 = icmp eq i32 %16, 7
br i1 %17, label %18, label %21
18: ; preds = %8
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %18, %8
%22 = and i32 %15, 15
%23 = icmp eq i32 %22, 15
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %21, %24
%28 = add nuw nsw i64 %9, 1
%29 = icmp eq i64 %28, %7
br i1 %29, label %30, label %8
30: ; preds = %27
%31 = add i32 %1, -1
%32 = srem i32 %31, 16
%33 = icmp eq i32 %32, 15
br i1 %33, label %37, label %34
34: ; preds = %2, %30
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %34, %30
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
ret void
}