#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 const *, char);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void hexdump(char *p, size_t l) {
  const char *fmt = " %02X";
  register size_t i;
  fprintf(stderr, fmt + 1, *p);
  for (i = 1; i < l; i++) {
    fprintf(stderr, fmt, p[i]);
  }
  fputc('\n', stderr);
}


x86 assembly (clang, -O0):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
call   1040 <fprintf@plt>
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    119d <hexdump+0x7d>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1160 <hexdump+0x40>
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r13
mov    0x2eaa(%rip),%r12
mov    (%r12),%edi
movsbl 0x0(%r13),%edx
lea    0xebb(%rip),%rsi
call   1040 <fprintf@plt>
cmp    $0x2,%r14
jb     117b <hexdump+0x5b>
mov    $0x1,%ebx
lea    0xea3(%rip),%r15
nopl   (%rax)
mov    (%r12),%edi
movsbl 0x0(%r13,%rbx,1),%edx
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1160 <hexdump+0x40>
mov    (%r12),%esi
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [6 x i8] c" %02X\00"
@stderr = global i32 0
define void @hexdump(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %5
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = call i32 @fprintf(i32 %7, i8* %9, i8 signext %11)
store i64 1, i64* %6
br label %13
13: ; preds = %25, %2
%14 = load i64, i64* %6
%15 = load i64, i64* %4
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %5
%20 = load i8*, i8** %3
%21 = load i64, i64* %6
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @fprintf(i32 %18, i8* %19, i8 signext %23)
br label %25
25: ; preds = %17
%26 = load i64, i64* %6
%27 = add i64 %26, 1
store i64 %27, i64* %6
br label %13
28: ; preds = %13
%29 = load i32, i32* @stderr
%30 = call i32 @fputc(i8 signext 10, i32 %29)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c" %02X\00"
@stderr = global i32 0
define void @hexdump(i8* nocapture %0, i64 %1) {
%3 = load i32, i32* @stderr
%4 = load i8, i8* %0
%5 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 1), i8 signext %4)
%6 = icmp ugt i64 %1, 1
br i1 %6, label %7, label %15
7: ; preds = %2, %7
%8 = phi i64 [ %13, %7 ], [ 1, %2 ]
%9 = load i32, i32* @stderr
%10 = getelementptr inbounds i8, i8* %0, i64 %8
%11 = load i8, i8* %10
%12 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%13 = add nuw i64 %8, 1
%14 = icmp eq i64 %13, %1
br i1 %14, label %15, label %7
15: ; preds = %7, %2
%16 = load i32, i32* @stderr
%17 = tail call i32 @fputc(i8 signext 10, i32 %16)
ret void
}