#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 print_hexdump(const char *s, size_t size) {
  const char *p = NULL;
  int i = 0;
  for (p = s, i = 0; p < s + size; p++, i++) {
    if (i % 8 == 0) {
      fprintf(stderr, "\n");
    }
    fprintf(stderr, "%02X ", *p);
  }
}


x86 assembly (clang, -O0):
<print_hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    -0x10(%rbp),%rcx
cmp    %rcx,%rax
jae    11b6 <print_hexdump+0xa6>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117e <print_hexdump+0x6e>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <print_hexdump+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
jle    1189 <print_hexdump+0x79>
mov    %rsi,%r14
mov    %rdi,%rbx
add    %rdi,%r14
mov    0x2eb0(%rip),%r13
lea    0xec9(%rip),%r15
lea    0xec4(%rip),%r12
xor    %ebp,%ebp
jmp    1173 <print_hexdump+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%r13),%edi
movsbl (%rbx,%rbp,1),%edx
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    (%rbx,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    %r14,%rax
jae    1189 <print_hexdump+0x79>
test   $0x7,%bpl
jne    1150 <print_hexdump+0x40>
mov    0x0(%r13),%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1150 <print_hexdump+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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