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

/* Variables and functions */
int /*<<< orphan*/ print_bits(int const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void print_bytes(const uint8_t *bytes, const size_t size) {
  size_t i;
  printf("showing bytes read:\nHEX    DEC    BIN");
  for (i = 0; i < size; ++i) {
    printf("\n$%02X    %3d    ", bytes[i], bytes[i]);
    print_bits(bytes[i]);
  }
  puts("\n--------------------------");
}


x86 assembly (clang, -O0):
<print_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11a9 <print_bytes+0x79>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1050 <print_bits@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1156 <print_bytes+0x26>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bytes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14,%r14
je     1182 <print_bytes+0x52>
lea    0xece(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%edx
mov    %r15,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12,%rbx,4),%edi
call   1050 <print_bits@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1160 <print_bytes+0x30>
lea    0xeaf(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"showing bytes read:\0AHEX DEC BIN\00"
@.str.1 = [18 x i8] c"\0A$%02X %3d \00"
@.str.2 = [28 x i8] c"\0A--------------------------\00"
define void @print_bytes(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %5
br label %7
7: ; preds = %26, %2
%8 = load i64, i64* %5
%9 = load i64, i64* %4
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i64, i64* %5
%14 = getelementptr inbounds i32, i32* %12, i64 %13
%15 = load i32, i32* %14
%16 = load i32*, i32** %3
%17 = load i64, i64* %5
%18 = getelementptr inbounds i32, i32* %16, i64 %17
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %19)
%21 = load i32*, i32** %3
%22 = load i64, i64* %5
%23 = getelementptr inbounds i32, i32* %21, i64 %22
%24 = load i32, i32* %23
%25 = call i32 @print_bits(i32 %24)
br label %26
26: ; preds = %11
%27 = load i64, i64* %5
%28 = add i64 %27, 1
store i64 %28, i64* %5
br label %7
29: ; preds = %7
%30 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"showing bytes read:\0AHEX DEC BIN\00"
@.str.1 = [18 x i8] c"\0A$%02X %3d \00"
@.str.2 = [28 x i8] c"\0A--------------------------\00"
define void @print_bytes(i32* nocapture %0, i64 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %1, 0
br i1 %4, label %14, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %12, %5 ], [ 0, %2 ]
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = load i32, i32* %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %8)
%10 = load i32, i32* %7
%11 = tail call i32 @print_bits(i32 %10)
%12 = add nuw i64 %6, 1
%13 = icmp eq i64 %12, %1
br i1 %13, label %14, label %5
14: ; preds = %5, %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
ret void
}