#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 *, char const);
int /*<<< orphan*/ puts(char *);
int printHexArray(const char *array, int startIndex, int length) {
  int i;
  for (i = startIndex; i < startIndex + length; i++) {
    printf("0x%02x ", array[i]);
    if (i % 10 == 9)
      puts("");
    if (i % 100 == 99)
      puts("");
  }
  puts("");
  return 0;
}


x86 assembly (clang, -O0):
<printHexArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11b4 <printHexArray+0x94>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xea8(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x9,%edx
jne    1181 <printHexArray+0x61>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x63,%edx
jne    11a1 <printHexArray+0x81>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
jmp    11a6 <printHexArray+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <printHexArray+0x18>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printHexArray>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    11bf <printHexArray+0x9f>
mov    %rdi,%r15
add    %esi,%edx
movslq %esi,%r13
movslq %edx,%r12
lea    0xebd(%rip),%r14
jmp    1159 <printHexArray+0x39>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r13
cmp    %r12,%r13
jge    11bf <printHexArray+0x9f>
movsbl (%r15,%r13,1),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movslq %r13d,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%ecx
sub    %eax,%ecx
cmp    $0x9,%ecx
jne    1195 <printHexArray+0x75>
mov    $0xa,%edi
call   1030 <putchar@plt>
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
cmp    $0x63,%ebx
jne    1150 <printHexArray+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <printHexArray+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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