#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 output_print_bytes(unsigned char *data, int size) {
  int out = 0;
  for (int i = 0; (i < size) && (i < (8)); i++) {
    printf("%02x ", data[i]);
    out++;
  }
  if (out < (8)) {
    for (int i = out; i < (8); i++)
      printf("   ");
  }
  return out;
}


x86 assembly (clang, -O0):
<output_print_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x19(%rbp)
jge    1148 <output_print_bytes+0x38>
cmpl   $0x8,-0x14(%rbp)
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1158 <output_print_bytes+0x48>
jmp    1189 <output_print_bytes+0x79>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <output_print_bytes+0x1d>
cmpl   $0x8,-0x10(%rbp)
jge    11c4 <output_print_bytes+0xb4>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    11bf <output_print_bytes+0xaf>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1199 <output_print_bytes+0x89>
jmp    11c4 <output_print_bytes+0xb4>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_print_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1160 <output_print_bytes+0x50>
mov    %esi,%r14d
mov    %rdi,%r12
add    $0xffffffff,%r14d
cmp    $0x7,%r14d
mov    $0x7,%ebx
cmovb  %r14d,%ebx
add    $0x1,%ebx
lea    0xec3(%rip),%r15
xor    %ebp,%ebp
nop
movzbl (%r12,%rbp,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1140 <output_print_bytes+0x30>
cmp    $0x6,%r14d
jbe    1162 <output_print_bytes+0x52>
jmp    1181 <output_print_bytes+0x71>
xor    %ebx,%ebx
mov    $0x8,%ebp
lea    0xe98(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0xffffffff,%ebp
cmp    %ebp,%ebx
jne    1170 <output_print_bytes+0x60>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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