#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 */
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int sendData(int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int sendClientInfo(int streamID, char *username) {
  int memSize = strlen("CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS ") +
                strlen(username) + strlen("\r\n") + 1;
  char *sendBuffer = malloc(memSize);
  memset(sendBuffer, 0, memSize);
  strcat(sendBuffer, "CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS ");
  strcat(sendBuffer, username);
  strcat(sendBuffer, "\r\n");
  int ret = sendData(streamID, sendBuffer);
  return ret;
}


x86 assembly (clang, -O0):
<sendClientInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
lea    0xeac(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x20(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <sendData@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendClientInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r12d
lea    0xe98(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
lea    0xeb1(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %ebp,%ebx
add    %eax,%ebx
add    $0x1,%ebx
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <memset@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <sendData@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i32 @sendClientInfo(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = call i32 @strlen(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %8, %10
%12 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = add nsw i32 %11, %12
%14 = add nsw i32 %13, 1
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = call i8* @malloc(i32 %15)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = load i32, i32* %5
%19 = call i32 @memset(i8* %17, i32 0, i32 %18)
%20 = load i8*, i8** %6
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%22 = load i8*, i8** %6
%23 = load i8*, i8** %4
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = load i8*, i8** %6
%29 = call i32 @sendData(i32 %27, i8* %28)
store i32 %29, i32* %7
%30 = load i32, i32* %7
ret i32 %30
}

LLVM IR (-O2):
@.str = [52 x i8] c"CVR 2 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i32 @sendClientInfo(i32 %0, i8* %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = add i32 %3, 1
%7 = add i32 %6, %4
%8 = add i32 %7, %5
%9 = tail call i8* @malloc(i32 %8)
%10 = tail call i32 @memset(i8* %9, i32 0, i32 %8)
%11 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @strcat(i8* %9, i8* %1)
%13 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @sendData(i32 %0, i8* %9)
ret i32 %14
}