#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 PrintArray(unsigned char *buffer, unsigned length) {
  unsigned i;
  if (length > 16)
    printf("\n");
  for (i = 0; i < length; i++) {
    printf("%02X ", buffer[i]);
    if (i % 16 == 15)
      printf("\n");
  }
  if (i % 16 != 0)
    printf("\n");
}


x86 assembly (clang, -O0):
<PrintArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jbe    1137 <PrintArray+0x27>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1193 <PrintArray+0x83>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
and    $0xf,%eax
cmp    $0xf,%eax
jne    1180 <PrintArray+0x70>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <PrintArray+0x75>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113e <PrintArray+0x2e>
mov    -0x10(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
je     11b0 <PrintArray+0xa0>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r12
cmp    $0x11,%esi
jb     113f <PrintArray+0x1f>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1144 <PrintArray+0x24>
test   %r14d,%r14d
je     11a4 <PrintArray+0x84>
mov    %r14d,%ebp
lea    0xeb2(%rip),%r15
xor    %ebx,%ebx
jmp    1169 <PrintArray+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     118c <PrintArray+0x6c>
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
not    %eax
test   $0xf,%al
jne    1160 <PrintArray+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1160 <PrintArray+0x40>
test   $0xf,%r14b
je     11a4 <PrintArray+0x84>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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