#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);
int /*<<< orphan*/ stdout;
void dump_bytes(const char *data, size_t len) {
  size_t i;
  for (i = 0; i < len; i++)
    if (i == 0)
      fprintf(stdout, "%02x", 0xff & data[i]);
    else
      fprintf(stdout, " %02x", 0xff & data[i]);
}


x86 assembly (clang, -O0):
<dump_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11aa <dump_bytes+0x9a>
cmpq   $0x0,-0x18(%rbp)
jne    116d <dump_bytes+0x5d>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
and    $0xff,%edx
lea    0xe9e(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1194 <dump_bytes+0x84>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
and    $0xff,%edx
lea    0xe71(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1199 <dump_bytes+0x89>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <dump_bytes+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_bytes>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rsi,%rsi
je     117a <dump_bytes+0x6a>
mov    %rsi,%r13
mov    %rdi,%r14
mov    0x2eb5(%rip),%r12
mov    (%r12),%edi
movzbl (%r14),%edx
lea    0xec7(%rip),%rsi
call   1030 <fprintf@plt>
cmp    $0x1,%r13
je     117a <dump_bytes+0x6a>
mov    $0x1,%ebx
lea    0xeaf(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edi
movzbl (%r14,%rbx,1),%edx
mov    %r15,%rsi
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <dump_bytes+0x50>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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