#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 uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void __hexdump(FILE *fp, const void *buff, unsigned int size) {
  unsigned int i;
  const uint8_t *b = (uint8_t *)buff;
  for (i = 0; i < size; i++) {
    if ((i & 0x0f) == 0x00)
      fprintf(fp, " %p: ", &b[i]);
    fprintf(fp, " %02x", b[i]);
    if ((i & 0x0f) == 0x0f)
      fprintf(fp, "\n");
  }
  fprintf(fp, "\n");
}


x86 assembly (clang, -O0):
<__hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11bd <__hexdump+0xad>
mov    -0x18(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    116d <__hexdump+0x5d>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
and    $0xf,%eax
cmp    $0xf,%eax
jne    11aa <__hexdump+0x9a>
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11af <__hexdump+0x9f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1132 <__hexdump+0x22>
mov    -0x8(%rbp),%rdi
lea    0xe44(%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
mov    %rdi,%r14
test   %edx,%edx
je     11ad <__hexdump+0x8d>
mov    %rsi,%rbx
mov    %edx,%r13d
lea    0xec7(%rip),%r12
xor    %ebp,%ebp
jmp    1180 <__hexdump+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
lea    0xea6(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbp
add    $0x4,%rbx
cmp    %rbp,%r13
je     11ad <__hexdump+0x8d>
mov    %ebp,%r15d
and    $0xf,%r15d
je     1150 <__hexdump+0x30>
mov    (%rbx),%edx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0xf,%r15d
jne    1173 <__hexdump+0x53>
mov    $0xa,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1173 <__hexdump+0x53>
mov    $0xa,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

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

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