#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 hexdump(const void *p, size_t len) {
  int count = 1;
  while (len--) {
    if (count == 1)
      fprintf(stderr, "    %p: ", p);
    fprintf(stderr, " %02x", *(unsigned char *)p++ & 0xff);
    if (count++ == 16) {
      fprintf(stderr, "\n");
      count = 1;
    }
  }
  if (count != 1)
    fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11cb <hexdump+0xbb>
cmpl   $0x1,-0x14(%rbp)
jne    1165 <hexdump+0x55>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%edx
and    $0xff,%edx
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x10,%eax
jne    11c6 <hexdump+0xb6>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
jmp    1127 <hexdump+0x17>
cmpl   $0x1,-0x14(%rbp)
je     11ec <hexdump+0xdc>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11af <hexdump+0x9f>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%r13d
mov    0x2ea9(%rip),%rbp
lea    0xec2(%rip),%r15
lea    0xec4(%rip),%r12
jmp    1177 <hexdump+0x67>
nopw   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%r14
mov    0x0(%rbp),%edi
movzbl (%rbx),%edx
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    $0x10,%r13d
je     1190 <hexdump+0x80>
add    $0x1,%r13d
add    $0x1,%rbx
test   %r14,%r14
je     11a9 <hexdump+0x99>
cmp    $0x1,%r13d
jne    1150 <hexdump+0x40>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1150 <hexdump+0x40>
nop
mov    0x0(%rbp),%edi
lea    0xe75(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%r13d
jmp    116e <hexdump+0x5e>
cmp    $0x1,%r13d
jne    11be <hexdump+0xae>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%rbp),%edi
lea    0xe47(%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 = [9 x i8] c" %p: \00"
@.str.1 = [6 x i8] c" %02x\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @hexdump(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
store i32 1, i32* %5
br label %6
6: ; preds = %31, %2
%7 = load i64, i64* %4
%8 = add i64 %7, -1
store i64 %8, i64* %4
%9 = icmp ne i64 %7, 0
br i1 %9, label %10, label %32
10: ; preds = %6
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %3
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %13, %10
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
%21 = load i8, i8* %19
%22 = zext i8 %21 to i32
%23 = and i32 %22, 255
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
%27 = icmp eq i32 %25, 16
br i1 %27, label %28, label %31
28: ; preds = %17
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %5
br label %31
31: ; preds = %28, %17
br label %6
32: ; preds = %6
%33 = load i32, i32* %5
%34 = icmp ne i32 %33, 1
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %35, %32
ret void
}

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