#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 getTrID();
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int sendData(int, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int sendUserInfo(int streamID, char *username) {
  int memSize = strlen("USR ") + strlen(" TWN I ") + strlen(username) +
                strlen("\r\n") + 1;
  char *sendBuffer = malloc(memSize);
  memset(sendBuffer, 0, memSize);
  char id[100];
  sprintf(id, "%d", getTrID());
  strcat(sendBuffer, "USR ");
  strcat(sendBuffer, id);
  strcat(sendBuffer, " TWN I ");
  strcat(sendBuffer, username);
  strcat(sendBuffer, "\r\n");
  int ret = sendData(streamID, sendBuffer);
  return ret;
}


x86 assembly (clang, -O0):
<sendUserInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe77(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xac(%rbp)
lea    0xe6a(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xa8(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xa8(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xa4(%rbp)
lea    0xe3d(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xa4(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    $0x0,%al
call   1030 <getTrID@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%edx
lea    0xdec(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xdb1(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1090 <sendData@plt>
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendUserInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r12
mov    %edi,%r13d
lea    0xe75(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xe6c(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
lea    0xe5a(%rip),%rdi
call   1040 <strlen@plt>
add    %ebp,%r14d
add    %r15d,%r14d
lea    (%rax,%r14,1),%ebx
add    $0x1,%ebx
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <memset@plt>
xor    %eax,%eax
call   1030 <getTrID@plt>
lea    0xe27(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1080 <sprintf@plt>
mov    %rbp,%rdi
lea    0xe00(%rip),%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
lea    0xdeb(%rip),%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
lea    0xdd9(%rip),%rsi
call   1070 <strcat@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
call   1090 <sendData@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"USR \00"
@.str.1 = [8 x i8] c" TWN I \00"
@.str.2 = [3 x i8] c"\0D\0A\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @sendUserInfo(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [100 x i8]
%8 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = add nsw i32 %9, %10
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %11, %13
%15 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = add nsw i32 %14, %15
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = call i8* @malloc(i32 %18)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = load i32, i32* %5
%22 = call i32 @memset(i8* %20, i32 0, i32 %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%24 = call i32 (...) @getTrID()
%25 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %6
%27 = call i32 @strcat(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%28 = load i8*, i8** %6
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%30 = call i32 @strcat(i8* %28, i8* %29)
%31 = load i8*, i8** %6
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%33 = load i8*, i8** %6
%34 = load i8*, i8** %4
%35 = call i32 @strcat(i8* %33, i8* %34)
%36 = load i8*, i8** %6
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = load i8*, i8** %6
%40 = call i32 @sendData(i32 %38, i8* %39)
store i32 %40, i32* %8
%41 = load i32, i32* %8
ret i32 %41
}

LLVM IR (-O2):
@.str = [5 x i8] c"USR \00"
@.str.1 = [8 x i8] c" TWN I \00"
@.str.2 = [3 x i8] c"\0D\0A\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @sendUserInfo(i32 %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @strlen(i8* %1)
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = add i32 %4, 1
%9 = add i32 %8, %5
%10 = add i32 %9, %6
%11 = add i32 %10, %7
%12 = tail call i8* @malloc(i32 %11)
%13 = tail call i32 @memset(i8* %12, i32 0, i32 %11)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = tail call i32 (...) @getTrID()
%16 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @strcat(i8* %12, i8* %14)
%19 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @strcat(i8* %12, i8* %1)
%21 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @sendData(i32 %0, i8* %12)
ret i32 %22
}