#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 *, ...);
void print_bytes2(char *bytes, int len) {
  unsigned char i;
  for (i = 0; i < len; i++) {
    printf("%02x ", bytes[i] & 0xff);
    if ((i + 1) % 16 == 0) {
      printf("\n");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_bytes2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
movzbl -0xd(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1188 <print_bytes2+0x78>
mov    -0x8(%rbp),%rax
movzbl -0xd(%rbp),%ecx
movsbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0xd(%rbp),%eax
add    $0x1,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1176 <print_bytes2+0x66>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117b <print_bytes2+0x6b>
mov    -0xd(%rbp),%al
add    $0x1,%al
mov    %al,-0xd(%rbp)
jmp    1123 <print_bytes2+0x13>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bytes2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    116e <print_bytes2+0x4e>
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xec9(%rip),%r15
xor    %ebp,%ebp
jmp    1148 <print_bytes2+0x28>
nopl   0x0(%rax,%rax,1)
movzbl %bpl,%ebp
cmp    %ebx,%ebp
jge    116e <print_bytes2+0x4e>
mov    %ebp,%eax
movzbl (%r14,%rax,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
test   $0xf,%bpl
jne    1140 <print_bytes2+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1140 <print_bytes2+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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