#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*/ debugPrintStr(char *, char *);
char *getTrID();
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int sendData(int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *,
                           char *);
int strlen(char *);
int sendTicket(int streamID, char *ticket) {
  int memSize = strlen(ticket) + 50;
  char *sendBuffer = malloc(memSize);
  memset(sendBuffer, 0, memSize);
  sprintf(sendBuffer, "%s%d%s%s%s", "USR ", getTrID(), " TWN S ", ticket,
          "\r\n");
  debugPrintStr("INFO : msn : sendTicket : sending Ticket :", sendBuffer);
  int retVal = sendData(streamID, sendBuffer);
  return retVal;
}


x86 assembly (clang, -O0):
<sendTicket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x32,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1040 <getTrID@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rcx
mov    -0x10(%rbp),%r9
lea    0xe37(%rip),%rsi
lea    0xe3b(%rip),%rdx
lea    0xe39(%rip),%r8
lea    0xe3a(%rip),%rax
mov    %rax,(%rsp)
call   1080 <sprintf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1030 <debugPrintStr@plt>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1090 <sendData@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendTicket>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
mov    %rsi,%rdi
call   1050 <strlen@plt>
lea    0x32(%rax),%ebx
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1060 <memset@plt>
xor    %eax,%eax
call   1040 <getTrID@plt>
lea    0xe6c(%rip),%rcx
mov    %rcx,(%rsp)
lea    0xe49(%rip),%rsi
lea    0xe4d(%rip),%rdx
lea    0xe4b(%rip),%r8
mov    %rbp,%rdi
mov    %rax,%rcx
mov    %r15,%r9
call   1080 <sprintf@plt>
lea    0xe41(%rip),%rdi
mov    %rbp,%rsi
call   1030 <debugPrintStr@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <sendData@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"%s%d%s%s%s\00"
@.str.1 = [5 x i8] c"USR \00"
@.str.2 = [8 x i8] c" TWN S \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
@.str.4 = [43 x i8] c"INFO : msn : sendTicket : sending Ticket :\00"
define i32 @sendTicket(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 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 50
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = call i8* @malloc(i32 %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = load i32, i32* %5
%15 = call i32 @memset(i8* %13, i32 0, i32 %14)
%16 = load i8*, i8** %6
%17 = call i8* (...) @getTrID()
%18 = load i8*, i8** %4
%19 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = load i8*, i8** %6
%21 = call i32 @debugPrintStr(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = load i32, i32* %3
%23 = load i8*, i8** %6
%24 = call i32 @sendData(i32 %22, i8* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
ret i32 %25
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s%d%s%s%s\00"
@.str.1 = [5 x i8] c"USR \00"
@.str.2 = [8 x i8] c" TWN S \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
@.str.4 = [43 x i8] c"INFO : msn : sendTicket : sending Ticket :\00"
define i32 @sendTicket(i32 %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = add nsw i32 %3, 50
%5 = tail call i8* @malloc(i32 %4)
%6 = tail call i32 @memset(i8* %5, i32 0, i32 %4)
%7 = tail call i8* (...) @getTrID()
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @debugPrintStr(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%10 = tail call i32 @sendData(i32 %0, i8* %5)
ret i32 %10
}