#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 pr_bytes(unsigned char *b, size_t nbytes) {
  size_t i;
  for (i = 0; i < nbytes; i++) {
    if (i && (i % 16 == 0))
      printf("\n");
    printf("%02x ", b[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<pr_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118c <pr_bytes+0x7c>
cmpq   $0x0,-0x18(%rbp)
je     1161 <pr_bytes+0x51>
mov    -0x18(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    1161 <pr_bytes+0x51>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <pr_bytes+0x18>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_bytes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1173 <pr_bytes+0x53>
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xec6(%rip),%r15
xor    %ebx,%ebx
jmp    1158 <pr_bytes+0x38>
xchg   %ax,%ax
movzbl (%r14,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1173 <pr_bytes+0x53>
test   %rbx,%rbx
je     1140 <pr_bytes+0x20>
mov    %ebx,%eax
and    $0xf,%eax
test   %rax,%rax
jne    1140 <pr_bytes+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1140 <pr_bytes+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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