#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*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void makeResponse(char *msg, char *name) {
  if (name[0] == '\0') {
    strcpy(name, msg);
    strcat(msg, " joined.\n");
  } else if (msg[0] == '\0') {
    strcpy(msg, name);
    strcat(msg, " left.\n");
  } else {
    char temp[(20 + 1000 + sizeof "<> ")];
    sprintf(temp, "<%s> %s", name, msg);
    strcpy(msg, temp);
  }
}


x86 assembly (clang, -O0):
<makeResponse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1175 <makeResponse+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1040 <strcat@plt>
jmp    11d7 <makeResponse+0xa7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a7 <makeResponse+0x77>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1040 <strcat@plt>
jmp    11d2 <makeResponse+0xa2>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe55(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11d7 <makeResponse+0xa7>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeResponse>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rdx
mov    %rdi,%rbx
cmpb   $0x0,(%rsi)
je     1175 <makeResponse+0x45>
cmpb   $0x0,(%rbx)
je     1189 <makeResponse+0x59>
lea    0xec1(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rcx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret
mov    %rdx,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe79(%rip),%rsi
jmp    119b <makeResponse+0x6b>
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1030 <strcpy@plt>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
add    $0x408,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strcat@plt>

LLVM IR (-O0):
@.str = [10 x i8] c" joined.\0A\00"
@.str.1 = [8 x i8] c" left.\0A\00"
@.str.2 = [8 x i8] c"<%s> %s\00"
define void @makeResponse(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = load i8*, i8** %3
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %38
17: ; preds = %2
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = load i8*, i8** %4
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i8*, i8** %3
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %37
29: ; preds = %17
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%31 = load i8*, i8** %4
%32 = load i8*, i8** %3
%33 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32)
%34 = load i8*, i8** %3
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%36 = call i32 @strcpy(i8* %34, i8* %35)
br label %37
37: ; preds = %29, %23
br label %38
38: ; preds = %37, %11
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c" joined.\0A\00"
@.str.1 = [8 x i8] c" left.\0A\00"
@.str.2 = [8 x i8] c"<%s> %s\00"
define void @makeResponse(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @strcpy(i8* %1, i8* %0)
%8 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %19
9: ; preds = %2
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = tail call i32 @strcpy(i8* %0, i8* %1)
%14 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %19
15: ; preds = %9
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%17 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %0)
%18 = call i32 @strcpy(i8* %0, i8* %16)
br label %19
19: ; preds = %12, %15, %6
ret void
}