#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*/ _psTrace(char *);
int /*<<< orphan*/ _psTraceInt(char *, int);
int /*<<< orphan*/ _psTraceStr(char *, char *);
int /*<<< orphan*/ mem2str(char *, unsigned char *, unsigned int);
int /*<<< orphan*/ memset(char *, int, int);
void psTraceBytes(char *tag, unsigned char *p, int l) {
  char s[17];
  int i;
  s[16] = '\0';
  _psTraceStr("psTraceBytes(%s, ", tag);
  _psTraceInt("%d);", l);
  for (i = 0; i < l; i++) {
    if (!(i & 0xF)) {
      if (i != 0) {
        mem2str(s, p - 16, 16);
        _psTraceStr("  %s", s);
      }
      _psTraceInt("\n0x%08x:", (int)p);
    }
    _psTraceInt("%02x ", *p++);
  }
  memset(s, 0x0, 16);
  i = l & 0xF;
  mem2str(s, p - i, (unsigned int)i);
  for (; i < 16; i++) {
    _psTrace("   ");
  }
  _psTraceStr("  %s", s);
  _psTrace("\n");
}


x86 assembly (clang, -O0):
<psTraceBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movb   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1030 <_psTraceStr@plt>
mov    -0x14(%rbp),%esi
lea    0xe91(%rip),%rdi
call   1070 <_psTraceInt@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1216 <psTraceBytes+0xc6>
mov    -0x34(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11ea <psTraceBytes+0x9a>
cmpl   $0x0,-0x34(%rbp)
je     11d8 <psTraceBytes+0x88>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0xfffffffffffffff0,%rsi
mov    $0x10,%edx
call   1060 <mem2str@plt>
lea    -0x30(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1030 <_psTraceStr@plt>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xe37(%rip),%rdi
call   1070 <_psTraceInt@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%esi
lea    0xe22(%rip),%rdi
call   1070 <_psTraceInt@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118d <psTraceBytes+0x3d>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x34(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rsi
mov    -0x34(%rbp),%edx
call   1060 <mem2str@plt>
cmpl   $0x10,-0x34(%rbp)
jge    126f <psTraceBytes+0x11f>
lea    0xdcf(%rip),%rdi
call   1050 <_psTrace@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    124b <psTraceBytes+0xfb>
lea    -0x30(%rbp),%rsi
lea    0xd9d(%rip),%rdi
call   1030 <_psTraceStr@plt>
lea    0xda9(%rip),%rdi
call   1050 <_psTrace@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psTraceBytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%rsi
movb   $0x0,0x10(%rsp)
lea    0xe8e(%rip),%rdi
call   1030 <_psTraceStr@plt>
lea    0xe94(%rip),%rdi
mov    %ebx,%esi
call   1070 <_psTraceInt@plt>
test   %ebx,%ebx
jle    121f <psTraceBytes+0xcf>
lea    0xe88(%rip),%rdi
mov    %r14d,%esi
call   1070 <_psTraceInt@plt>
lea    0x1(%r14),%r15
movzbl (%r14),%esi
lea    0xe7a(%rip),%rdi
call   1070 <_psTraceInt@plt>
cmp    $0x1,%ebx
je     1222 <psTraceBytes+0xd2>
mov    $0x1,%ebp
mov    %rsp,%r12
lea    0xe61(%rip),%r13
jmp    11e7 <psTraceBytes+0x97>
cs nopw 0x0(%rax,%rax,1)
movzbl (%r15),%esi
add    $0x1,%r15
mov    %r13,%rdi
call   1070 <_psTraceInt@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
je     1222 <psTraceBytes+0xd2>
test   $0xf,%bpl
jne    11d0 <psTraceBytes+0x80>
lea    -0x10(%r15),%rsi
mov    %r12,%rdi
mov    $0x10,%edx
call   1060 <mem2str@plt>
lea    0xe12(%rip),%rdi
mov    %r12,%rsi
call   1030 <_psTraceStr@plt>
lea    (%r14,%rbp,1),%esi
lea    0xe04(%rip),%rdi
call   1070 <_psTraceInt@plt>
jmp    11d0 <psTraceBytes+0x80>
mov    %r14,%r15
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
and    $0xf,%ebx
sub    %rbx,%r15
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1060 <mem2str@plt>
or     $0xfffffff0,%ebx
lea    0xdda(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1050 <_psTrace@plt>
inc    %ebx
jne    1260 <psTraceBytes+0x110>
lea    0xda4(%rip),%rdi
mov    %rsp,%rsi
call   1030 <_psTraceStr@plt>
lea    0xdad(%rip),%rdi
call   1050 <_psTrace@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"psTraceBytes(%s, \00"
@.str.1 = [5 x i8] c"%d);\00"
@.str.2 = [5 x i8] c" %s\00"
@.str.3 = [9 x i8] c"\0A0x%08x:\00"
@.str.4 = [6 x i8] c"%02x \00"
@.str.5 = [4 x i8] c" \00"
@.str.6 = [2 x i8] c"\0A\00"
define void @psTraceBytes(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [17 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 16
store i8 0, i8* %9
%10 = load i8*, i8** %4
%11 = call i32 @_psTraceStr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* %6
%13 = call i32 @_psTraceInt(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %12)
store i32 0, i32* %8
br label %14
14: ; preds = %42, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %45
18: ; preds = %14
%19 = load i32, i32* %8
%20 = and i32 %19, 15
%21 = icmp ne i32 %20, 0
br i1 %21, label %36, label %22
22: ; preds = %18
%23 = load i32, i32* %8
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 -16
%29 = call i32 @mem2str(i8* %26, i8* %28, i32 16)
%30 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%31 = call i32 @_psTraceStr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %25, %22
%33 = load i8*, i8** %5
%34 = ptrtoint i8* %33 to i32
%35 = call i32 @_psTraceInt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %32, %18
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
%39 = load i8, i8* %37
%40 = zext i8 %39 to i32
%41 = call i32 @_psTraceInt(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %36
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %14
45: ; preds = %14
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%47 = call i32 @memset(i8* %46, i32 0, i32 16)
%48 = load i32, i32* %6
%49 = and i32 %48, 15
store i32 %49, i32* %8
%50 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%51 = load i8*, i8** %5
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = sub i64 0, %53
%55 = getelementptr inbounds i8, i8* %51, i64 %54
%56 = load i32, i32* %8
%57 = call i32 @mem2str(i8* %50, i8* %55, i32 %56)
br label %58
58: ; preds = %63, %45
%59 = load i32, i32* %8
%60 = icmp slt i32 %59, 16
br i1 %60, label %61, label %66
61: ; preds = %58
%62 = call i32 @_psTrace(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %63
63: ; preds = %61
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %58
66: ; preds = %58
%67 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%68 = call i32 @_psTraceStr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %67)
%69 = call i32 @_psTrace(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"psTraceBytes(%s, \00"
@.str.1 = [5 x i8] c"%d);\00"
@.str.2 = [5 x i8] c" %s\00"
@.str.3 = [9 x i8] c"\0A0x%08x:\00"
@.str.4 = [6 x i8] c"%02x \00"
@.str.5 = [4 x i8] c" \00"
@.str.6 = [2 x i8] c"\0A\00"
define void @psTraceBytes(i8* %0, i8* %1, i32 %2) {
%4 = alloca [17 x i8]
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 16
store i8 0, i8* %6
%7 = tail call i32 @_psTraceStr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @_psTraceInt(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %38
10: ; preds = %3
%11 = ptrtoint i8* %1 to i64
%12 = trunc i64 %11 to i32
%13 = call i32 @_psTraceInt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds i8, i8* %1, i64 1
%15 = load i8, i8* %1
%16 = zext i8 %15 to i32
%17 = call i32 @_psTraceInt(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = icmp eq i32 %2, 1
br i1 %18, label %38, label %19
19: ; preds = %10, %31
%20 = phi i32 [ %36, %31 ], [ 1, %10 ]
%21 = phi i8* [ %32, %31 ], [ %14, %10 ]
%22 = and i32 %20, 15
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %21, i64 -16
%26 = call i32 @mem2str(i8* %5, i8* %25, i32 16)
%27 = call i32 @_psTraceStr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%28 = ptrtoint i8* %21 to i64
%29 = trunc i64 %28 to i32
%30 = call i32 @_psTraceInt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %24, %19
%32 = getelementptr inbounds i8, i8* %21, i64 1
%33 = load i8, i8* %21
%34 = zext i8 %33 to i32
%35 = call i32 @_psTraceInt(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = add nuw nsw i32 %20, 1
%37 = icmp eq i32 %36, %2
br i1 %37, label %38, label %19
38: ; preds = %31, %10, %3
%39 = phi i8* [ %1, %3 ], [ %14, %10 ], [ %32, %31 ]
%40 = call i32 @memset(i8* %5, i32 0, i32 16)
%41 = and i32 %2, 15
%42 = zext i32 %41 to i64
%43 = sub nsw i64 0, %42
%44 = getelementptr inbounds i8, i8* %39, i64 %43
%45 = call i32 @mem2str(i8* %5, i8* %44, i32 %41)
br label %46
46: ; preds = %38, %46
%47 = phi i32 [ %41, %38 ], [ %49, %46 ]
%48 = call i32 @_psTrace(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%49 = add nuw nsw i32 %47, 1
%50 = icmp eq i32 %49, 16
br i1 %50, label %51, label %46
51: ; preds = %46
%52 = call i32 @_psTraceStr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%53 = call i32 @_psTrace(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}