#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*/ printf(char *);
int /*<<< orphan*/ stderr;
void dumphex(unsigned char *buf, int buflen, int out) {
  if (buflen < 1)
    return;
  if (out)
    printf("==> ");
  else
    printf("<== ");
  int i;
  for (i = 0; i < buflen; i++)
    fprintf(stderr, "%02X", buf[i]);
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<dumphex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    1141 <dumphex+0x21>
jmp    11c3 <dumphex+0xa3>
cmpl   $0x0,-0x10(%rbp)
je     115c <dumphex+0x3c>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    1168 <dumphex+0x48>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ac <dumphex+0x8c>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <dumphex+0x4f>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumphex>:
test   %esi,%esi
jle    1194 <dumphex+0x74>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r12
test   %edx,%edx
lea    0xecb(%rip),%rax
lea    0xebf(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
mov    %ebp,%ebp
mov    0x2e8d(%rip),%r15
lea    0xeb0(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15),%edi
movzbl (%r12,%rbx,1),%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <dumphex+0x40>
mov    (%r15),%edi
lea    0xe8a(%rip),%rsi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"==> \00"
@.str.1 = [5 x i8] c"<== \00"
@stderr = global i32 0
@.str.2 = [5 x i8] c"%02X\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @dumphex(i8* nocapture %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 1
br i1 %4, label %22, label %5
5: ; preds = %3
%6 = icmp eq i32 %2, 0
%7 = select i1 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)
%8 = tail call i32 @printf(i8* dereferenceable(1) %7)
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %5, %10
%11 = phi i64 [ 0, %5 ], [ %17, %10 ]
%12 = load i32, i32* @stderr
%13 = getelementptr inbounds i8, i8* %0, i64 %11
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %11, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %19, label %10
19: ; preds = %10
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %3, %19
ret void
}