#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 *, ...);
int printbytes(char *str, int numchars) {
  int i;
  for (i = 0; i < numchars; i++)
    if ((i + 1) % 8 == 0)
      printf("%02X\n", str[i]);
    else
      printf("%02X ", str[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<printbytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1195 <printbytes+0x85>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1168 <printbytes+0x58>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1182 <printbytes+0x72>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1187 <printbytes+0x77>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <printbytes+0x16>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbytes>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %esi,%esi
jle    1179 <printbytes+0x59>
mov    %rdi,%r14
mov    %esi,%r15d
neg    %r15
mov    $0x1,%ebx
lea    0xebe(%rip),%r12
lea    0xebd(%rip),%r13
nopl   0x0(%rax)
test   $0x7,%bl
movsbl -0x1(%r14,%rbx,1),%esi
mov    %r13,%rdi
cmove  %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r15,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
jne    1150 <printbytes+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c"%02X\0A\00"
@.str.1 = [6 x i8] c"%02X \00"
define i32 @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
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %8, %6 ]
%8 = add nuw nsw i64 %7, 1
%9 = and i64 %8, 7
%10 = icmp eq i64 %9, 0
%11 = getelementptr inbounds i8, i8* %0, i64 %7
%12 = load i8, i8* %11
%13 = sext 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 ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %14, i32 %13)
%16 = icmp eq i64 %8, %5
br i1 %16, label %17, label %6
17: ; preds = %6, %2
%18 = tail call i32 @putchar(i32 10)
ret i32 undef
}