#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 atoi(char *);
int /*<<< orphan*/ trap_Cvar_Set(char *, char *);
int /*<<< orphan*/ trap_Cvar_VariableStringBuffer(char *, char *, int);
int /*<<< orphan*/ trap_SendConsoleCommand(int /*<<< orphan*/);
int /*<<< orphan*/ va(char *, char *);
void CG_MessageSend_f(void) {
  char messageText[256];
  int messageType;
  trap_Cvar_VariableStringBuffer("cg_messageType", messageText, 256);
  messageType = atoi(messageText);
  trap_Cvar_VariableStringBuffer("cg_messageText", messageText, 256);
  trap_Cvar_Set("cg_messageText", "");
  trap_Cvar_Set("cg_messageType", "");
  trap_Cvar_Set("cg_messagePlayer", "");
  if (messageText[0] == '\0') {
    return;
  }
  if (messageType == 2) {
    trap_SendConsoleCommand(va("say_team \"%s\"\n", messageText));
  } else if (messageType == 3) {
    trap_SendConsoleCommand(va("say_buddy \"%s\"\n", messageText));
  } else {
    trap_SendConsoleCommand(va("say \"%s\"\n", messageText));
  }
}


x86 assembly (clang, -O0):
<CG_MessageSend_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    -0x100(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x100,%edx
call   1030 <trap_Cvar_VariableStringBuffer@plt>
lea    -0x100(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x104(%rbp)
lea    -0x100(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x100,%edx
call   1030 <trap_Cvar_VariableStringBuffer@plt>
lea    0xe6b(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1070 <trap_Cvar_Set@plt>
lea    0xe49(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1070 <trap_Cvar_Set@plt>
lea    0xe54(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1070 <trap_Cvar_Set@plt>
movsbl -0x100(%rbp),%eax
cmp    $0x0,%eax
jne    11eb <CG_MessageSend_f+0x9b>
jmp    1262 <CG_MessageSend_f+0x112>
cmpl   $0x2,-0x104(%rbp)
jne    1217 <CG_MessageSend_f+0xc7>
lea    -0x100(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1040 <va@plt>
mov    %eax,%edi
call   1060 <trap_SendConsoleCommand@plt>
jmp    1262 <CG_MessageSend_f+0x112>
cmpl   $0x3,-0x104(%rbp)
jne    1243 <CG_MessageSend_f+0xf3>
lea    -0x100(%rbp),%rsi
lea    0xe0c(%rip),%rdi
call   1040 <va@plt>
mov    %eax,%edi
call   1060 <trap_SendConsoleCommand@plt>
jmp    125d <CG_MessageSend_f+0x10d>
lea    -0x100(%rbp),%rsi
lea    0xdfd(%rip),%rdi
call   1040 <va@plt>
mov    %eax,%edi
call   1060 <trap_SendConsoleCommand@plt>
jmp    1262 <CG_MessageSend_f+0x112>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CG_MessageSend_f>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xe9c(%rip),%r14
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1030 <trap_Cvar_VariableStringBuffer@plt>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%r15d
lea    0xe86(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1030 <trap_Cvar_VariableStringBuffer@plt>
lea    0xe9d(%rip),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <trap_Cvar_Set@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <trap_Cvar_Set@plt>
lea    0xe61(%rip),%rdi
mov    %rbx,%rsi
call   1070 <trap_Cvar_Set@plt>
cmpb   $0x0,(%rsp)
je     11ff <CG_MessageSend_f+0xaf>
cmp    $0x3,%r15d
lea    0xe68(%rip),%rax
lea    0xe71(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x2,%r15d
lea    0xe43(%rip),%rdi
cmovne %rcx,%rdi
mov    %rsp,%rsi
call   1040 <va@plt>
mov    %eax,%edi
call   1060 <trap_SendConsoleCommand@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"cg_messageType\00"
@.str.1 = [15 x i8] c"cg_messageText\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [17 x i8] c"cg_messagePlayer\00"
@.str.4 = [15 x i8] c"say_team \22%s\22\0A\00"
@.str.5 = [16 x i8] c"say_buddy \22%s\22\0A\00"
@.str.6 = [10 x i8] c"say \22%s\22\0A\00"
define void @CG_MessageSend_f() {
%1 = alloca [256 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = call i32 @trap_Cvar_VariableStringBuffer(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %3, i32 256)
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%6 = call i32 @atoi(i8* %5)
store i32 %6, i32* %2
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%8 = call i32 @trap_Cvar_VariableStringBuffer(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 256)
%9 = call i32 @trap_Cvar_Set(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @trap_Cvar_Set(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @trap_Cvar_Set(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %0
br label %36
17: ; preds = %0
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%22 = call i32 @va(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = call i32 @trap_SendConsoleCommand(i32 %22)
br label %36
24: ; preds = %17
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%29 = call i32 @va(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = call i32 @trap_SendConsoleCommand(i32 %29)
br label %35
31: ; preds = %24
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%33 = call i32 @va(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %32)
%34 = call i32 @trap_SendConsoleCommand(i32 %33)
br label %35
35: ; preds = %31, %27
br label %36
36: ; preds = %16, %35, %20
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"cg_messageType\00"
@.str.1 = [15 x i8] c"cg_messageText\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [17 x i8] c"cg_messagePlayer\00"
@.str.4 = [15 x i8] c"say_team \22%s\22\0A\00"
@.str.5 = [16 x i8] c"say_buddy \22%s\22\0A\00"
@.str.6 = [10 x i8] c"say \22%s\22\0A\00"
define void @CG_MessageSend_f() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @trap_Cvar_VariableStringBuffer(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %2, i32 256)
%4 = call i32 @atoi(i8* %2)
%5 = call i32 @trap_Cvar_VariableStringBuffer(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 256)
%6 = call i32 @trap_Cvar_Set(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @trap_Cvar_Set(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @trap_Cvar_Set(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%9 = load i8, i8* %2
%10 = icmp eq i8 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %0
%12 = icmp eq i32 %4, 3
%13 = select i1 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0)
%14 = icmp eq i32 %4, 2
%15 = select i1 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %13
%16 = call i32 @va(i8* %15, i8* %2)
%17 = call i32 @trap_SendConsoleCommand(i32 %16)
br label %18
18: ; preds = %11, %0
ret void
}