#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 printBuf(unsigned char *buf, unsigned short bufSize, const char *file,
              const char *func, unsigned int line) {
  unsigned short i = 0;
  printf("[%s][%s][%d]buf: ", file, func, line);
  for (i = 0; i < bufSize; i++)
    printf("%02X ", buf[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<printBuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movw   $0x0,-0x26(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movw   $0x0,-0x26(%rbp)
movzwl -0x26(%rbp),%eax
movzwl -0xa(%rbp),%ecx
cmp    %ecx,%eax
jge    118f <printBuf+0x7f>
mov    -0x8(%rbp),%rax
movzwl -0x26(%rbp),%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x26(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x26(%rbp)
jmp    1154 <printBuf+0x44>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBuf>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xecd(%rip),%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r8d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
je     1178 <printBuf+0x58>
movzwl %bp,%ebp
lea    0xec1(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <printBuf+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [18 x i8] c"[%s][%s][%d]buf: \00"
@.str.1 = [6 x i8] c"%02X \00"
define void @printBuf(i8* nocapture %0, i16 zeroext %1, i8* %2, i8* %3, i32 %4) {
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i32 %4)
%7 = icmp eq i16 %1, 0
br i1 %7, label %18, label %8
8: ; preds = %5
%9 = zext i16 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %16, %10 ]
%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 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %18, label %10
18: ; preds = %10, %5
%19 = tail call i32 @putchar(i32 10)
ret void
}