#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);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *get_last_winner_str(int last, char *name, char *u1) {
  char *last_str = malloc(40);
  if (strcmp(name, u1) == 0) {
    if (last == 2)
      strcpy(last_str, "Waiting");
    else if (last == 0)
      strcpy(last_str, "You Won");
    else
      strcpy(last_str, "They won");
  } else {
    if (last == 2)
      strcpy(last_str, "Waiting");
    else if (last == 0)
      strcpy(last_str, "They Won");
    else
      strcpy(last_str, "You won");
  }
  return last_str;
}


x86 assembly (clang, -O0):
<get_last_winner_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c0 <get_last_winner_str+0x90>
cmpl   $0x2,-0x4(%rbp)
jne    1187 <get_last_winner_str+0x57>
mov    -0x20(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11bb <get_last_winner_str+0x8b>
cmpl   $0x0,-0x4(%rbp)
jne    11a6 <get_last_winner_str+0x76>
mov    -0x20(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b6 <get_last_winner_str+0x86>
mov    -0x20(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11bb <get_last_winner_str+0x8b>
jmp    1218 <get_last_winner_str+0xe8>
cmpl   $0x2,-0x4(%rbp)
jne    11df <get_last_winner_str+0xaf>
mov    -0x20(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1213 <get_last_winner_str+0xe3>
cmpl   $0x0,-0x4(%rbp)
jne    11fe <get_last_winner_str+0xce>
mov    -0x20(%rbp),%rdi
lea    0xe25(%rip),%rsi
call   1030 <strcpy@plt>
jmp    120e <get_last_winner_str+0xde>
mov    -0x20(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1213 <get_last_winner_str+0xe3>
jmp    1218 <get_last_winner_str+0xe8>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_last_winner_str>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %ebp,%ebp
lea    0xeb9(%rip),%rcx
lea    0xebb(%rip),%rdx
cmove  %rcx,%rdx
lea    0xe96(%rip),%rcx
lea    0xe97(%rip),%rdi
cmove  %rcx,%rdi
test   %rax,%rax
cmovne %rdx,%rdi
cmp    $0x2,%ebp
lea    0xe72(%rip),%rsi
cmovne %rdi,%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Waiting\00"
@.str.1 = [8 x i8] c"You Won\00"
@.str.2 = [9 x i8] c"They won\00"
@.str.3 = [9 x i8] c"They Won\00"
@.str.4 = [8 x i8] c"You won\00"
define i8* @get_last_winner_str(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = call i8* @malloc(i32 40)
store i8* %8, i8** %7
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = call i64 @strcmp(i8* %9, i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %30
13: ; preds = %3
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i8*, i8** %7
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %29
19: ; preds = %13
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i8*, i8** %7
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %28
25: ; preds = %19
%26 = load i8*, i8** %7
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %25, %22
br label %29
29: ; preds = %28, %16
br label %47
30: ; preds = %3
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i8*, i8** %7
%35 = call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %46
36: ; preds = %30
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i8*, i8** %7
%41 = call i32 @strcpy(i8* %40, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %45
42: ; preds = %36
%43 = load i8*, i8** %7
%44 = call i32 @strcpy(i8* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %42, %39
br label %46
46: ; preds = %45, %33
br label %47
47: ; preds = %46, %29
%48 = load i8*, i8** %7
ret i8* %48
}

LLVM IR (-O2):
@.str = [8 x i8] c"Waiting\00"
@.str.1 = [8 x i8] c"You Won\00"
@.str.2 = [9 x i8] c"They won\00"
@.str.3 = [9 x i8] c"They Won\00"
@.str.4 = [8 x i8] c"You won\00"
define i8* @get_last_winner_str(i32 %0, i8* %1, i8* %2) {
%4 = tail call dereferenceable_or_null(40) i8* @malloc(i32 40)
%5 = tail call i64 @strcmp(i8* %1, i8* %2)
%6 = icmp eq i64 %5, 0
%7 = icmp eq i32 %0, 0
%8 = select i1 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%9 = select i1 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%10 = select i1 %6, i8* %9, i8* %8
%11 = icmp eq i32 %0, 2
%12 = select i1 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %10
%13 = tail call i32 @strcpy(i8* %4, i8* %12)
ret i8* %4
}