#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*/ Debug(char *, ...);
void dumpBytes(unsigned short len, char *data) {
  unsigned short i;
  Debug("%d: ", len);
  for (i = 0; i < len; i++)
    Debug("%02x ", data[i] & 0377);
  Debug("\n");
}


x86 assembly (clang, -O0):
<dumpBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
movzwl -0x2(%rbp),%esi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <Debug@plt>
movw   $0x0,-0x12(%rbp)
movzwl -0x12(%rbp),%eax
movzwl -0x2(%rbp),%ecx
cmp    %ecx,%eax
jge    117c <dumpBytes+0x6c>
mov    -0x10(%rbp),%rax
movzwl -0x12(%rbp),%ecx
movsbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <Debug@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    113b <dumpBytes+0x2b>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <Debug@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpBytes>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xedd(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <Debug@plt>
test   %ebp,%ebp
je     1158 <dumpBytes+0x48>
movzwl %bp,%ebp
lea    0xecb(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <Debug@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <dumpBytes+0x30>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <Debug@plt>

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

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