#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*/ printf(char *, unsigned int);
void printbytes(char *b, int len) {
  int cont;
  for (cont = 0; cont < len; cont++) {
    if (cont + 1 < len)
      printf("%02X ", (unsigned)(unsigned char)b[cont]);
    else
      printf("%02X", (unsigned)(unsigned char)b[cont]);
  }
}


x86 assembly (clang, -O0):
<printbytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1189 <printbytes+0x79>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cmp    -0xc(%rbp),%eax
jge    115e <printbytes+0x4e>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    1176 <printbytes+0x66>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
jmp    117b <printbytes+0x6b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <printbytes+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1167 <printbytes+0x57>
mov    %rdi,%r14
mov    %esi,%r15d
mov    %r15,%r12
neg    %r12
mov    $0x1,%ebx
lea    0xec9(%rip),%r13
lea    0xec8(%rip),%rbp
xchg   %ax,%ax
cmp    %r15,%rbx
movzbl -0x1(%r14,%rbx,1),%esi
mov    %rbp,%rdi
cmovb  %r13,%rdi
call   1030 <printf@plt>
lea    (%r12,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
jne    1140 <printbytes+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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