#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*/ strcat(unsigned char *, char *);
int /*<<< orphan*/ strcpy(unsigned char *, char *);
int strlen(unsigned char *);
int /*<<< orphan*/ vOneTwo0(unsigned char *, int, unsigned char *);
int /*<<< orphan*/ vTraceOut(int, unsigned char *);
void vTraceWriteBinCr(int iTraceType, char *pszTitle, void *pData, int iLen) {
  unsigned char szMsg[2048];
  if (iLen > 1000)
    iLen = 1000;
  if (pszTitle)
    strcpy(szMsg, pszTitle);
  else
    szMsg[0] = 0;
  vOneTwo0((unsigned char *)pData, iLen, szMsg + strlen(szMsg));
  strcat(szMsg, "\x0d\x0a");
  vTraceOut(iTraceType, szMsg);
}


x86 assembly (clang, -O0):
<vTraceWriteBinCr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jle    117d <vTraceWriteBinCr+0x2d>
movl   $0x3e8,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119d <vTraceWriteBinCr+0x4d>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11a4 <vTraceWriteBinCr+0x54>
movb   $0x0,-0x820(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x824(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x820(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x838(%rbp),%rdx
mov    -0x830(%rbp),%rdi
mov    -0x824(%rbp),%esi
cltq
add    %rax,%rdx
call   1070 <vOneTwo0@plt>
lea    -0x820(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
call   1050 <vTraceOut@plt>
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vTraceWriteBinCr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %edi,%r14d
test   %rsi,%rsi
je     1174 <vTraceWriteBinCr+0x24>
mov    %rsp,%rdi
call   1030 <strcpy@plt>
jmp    1178 <vTraceWriteBinCr+0x28>
movb   $0x0,(%rsp)
cmp    $0x3e8,%ebp
mov    $0x3e8,%ebx
cmovl  %ebp,%ebx
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
call   1070 <vOneTwo0@plt>
lea    0xe58(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcat@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
call   1050 <vTraceOut@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
define void @vTraceWriteBinCr(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [2048 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = icmp sgt i32 %10, 1000
br i1 %11, label %12, label %13
12: ; preds = %4
store i32 1000, i32* %8
br label %13
13: ; preds = %12, %4
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%18 = load i8*, i8** %6
%19 = call i32 @strcpy(i8* %17, i8* %18)
br label %22
20: ; preds = %13
%21 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
store i8 0, i8* %21
br label %22
22: ; preds = %20, %16
%23 = load i8*, i8** %7
%24 = load i32, i32* %8
%25 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = call i32 @vOneTwo0(i8* %23, i32 %24, i8* %29)
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* %5
%34 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%35 = call i32 @vTraceOut(i32 %33, i8* %34)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
define void @vTraceWriteBinCr(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [2048 x i8]
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%7 = icmp eq i8* %1, null
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = call i32 @strcpy(i8* %6, i8* %1)
br label %11
10: ; preds = %4
store i8 0, i8* %6
br label %11
11: ; preds = %10, %8
%12 = icmp slt i32 %3, 1000
%13 = select i1 %12, i32 %3, i32 1000
%14 = call i32 @strlen(i8* %6)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 %15
%17 = call i32 @vOneTwo0(i8* %2, i32 %13, i8* %16)
%18 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @vTraceOut(i32 %0, i8* %6)
ret void
}