#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void print_buffer_content(unsigned char *buff, ssize_t len) {
  fprintf(stderr, "%zd bytes:\n", len);
  for (ssize_t i = 0; i < len; i++) {
    if (!(i % 10))
      fprintf(stderr, "\n");
    fprintf(stderr, "%02X ", buff[i]);
  }
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<print_buffer_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2eba(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <print_buffer_content+0x98>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1177 <print_buffer_content+0x67>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <print_buffer_content+0x30>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_buffer_content>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2eb8(%rip),%r12
mov    (%r12),%edi
lea    0xecd(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r14d,%r14d
jle    11ae <print_buffer_content+0x9e>
mov    %r14d,%ebp
lea    0xec0(%rip),%r15
xor    %r14d,%r14d
xor    %r13d,%r13d
jmp    1180 <print_buffer_content+0x70>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12),%edi
movzbl (%rbx,%r13,1),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r13
add    $0xffffffff,%r14d
cmp    %r13,%rbp
je     11ae <print_buffer_content+0x9e>
mov    %r13d,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
add    %eax,%eax
add    %r14d,%eax
jne    1160 <print_buffer_content+0x50>
mov    (%r12),%edi
lea    0xe65(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1160 <print_buffer_content+0x50>
mov    (%r12),%edi
lea    0xe51(%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 = [12 x i8] c"%zd bytes:\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [6 x i8] c"%02X \00"
define void @print_buffer_content(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* @stderr
%7 = load i32, i32* %4
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %5
br label %9
9: ; preds = %29, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %32
13: ; preds = %9
%14 = load i32, i32* %5
%15 = srem i32 %14, 10
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %17, %13
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %20
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %9
32: ; preds = %9
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

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