#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*/ Cbuf_AddText(char const *);
int /*<<< orphan*/ Cbuf_Execute();
int /*<<< orphan*/ Cbuf_InsertText(char const *);
int /*<<< orphan*/ Cmd_ExecuteString(char const *);
int /*<<< orphan*/ Com_Error(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strlen(char const *);
void Cbuf_ExecuteText(int exec_when, const char *text) {
  switch (exec_when) {
  case 0:
    if (text && strlen(text) > 0) {
      Cmd_ExecuteString(text);
    } else {
      Cbuf_Execute();
    }
    break;
  case 1:
    Cbuf_InsertText(text);
    break;
  case 2:
    Cbuf_AddText(text);
    break;
  default:
    Com_Error(0, "Cbuf_ExecuteText: bad exec_when");
  }
}


x86 assembly (clang, -O0):
<Cbuf_ExecuteText>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     11a4 <Cbuf_ExecuteText+0x44>
jmp    1182 <Cbuf_ExecuteText+0x22>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     11db <Cbuf_ExecuteText+0x7b>
jmp    1193 <Cbuf_ExecuteText+0x33>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11e9 <Cbuf_ExecuteText+0x89>
jmp    11f7 <Cbuf_ExecuteText+0x97>
cmpq   $0x0,-0x10(%rbp)
je     11cf <Cbuf_ExecuteText+0x6f>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jle    11cf <Cbuf_ExecuteText+0x6f>
mov    -0x10(%rbp),%rdi
call   1070 <Cmd_ExecuteString@plt>
jmp    11d6 <Cbuf_ExecuteText+0x76>
mov    $0x0,%al
call   1050 <Cbuf_Execute@plt>
jmp    1205 <Cbuf_ExecuteText+0xa5>
mov    -0x10(%rbp),%rdi
call   1060 <Cbuf_InsertText@plt>
jmp    1205 <Cbuf_ExecuteText+0xa5>
mov    -0x10(%rbp),%rdi
call   1030 <Cbuf_AddText@plt>
jmp    1205 <Cbuf_ExecuteText+0xa5>
xor    %edi,%edi
lea    0xe00(%rip),%rsi
call   1080 <Com_Error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cbuf_ExecuteText>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     118c <Cbuf_ExecuteText+0x2c>
cmp    $0x1,%edi
je     1195 <Cbuf_ExecuteText+0x35>
test   %edi,%edi
jne    119e <Cbuf_ExecuteText+0x3e>
test   %rbx,%rbx
je     11ad <Cbuf_ExecuteText+0x4d>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11ad <Cbuf_ExecuteText+0x4d>
mov    %rbx,%rdi
pop    %rbx
jmp    1070 <Cmd_ExecuteString@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <Cbuf_AddText@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <Cbuf_InsertText@plt>
lea    0xe5b(%rip),%rsi
xor    %edi,%edi
pop    %rbx
jmp    1080 <Com_Error@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <Cbuf_Execute@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Cbuf_ExecuteText: bad exec_when\00"
define void @Cbuf_ExecuteText(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
switch i32 %5, label %25 [
i32 0, label %6
i32 1, label %19
i32 2, label %22
]
6: ; preds = %2
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = call i32 @Cmd_ExecuteString(i8* %14)
br label %18
16: ; preds = %9, %6
%17 = call i32 (...) @Cbuf_Execute()
br label %18
18: ; preds = %16, %13
br label %27
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 @Cbuf_InsertText(i8* %20)
br label %27
22: ; preds = %2
%23 = load i8*, i8** %4
%24 = call i32 @Cbuf_AddText(i8* %23)
br label %27
25: ; preds = %2
%26 = call i32 @Com_Error(i32 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %22, %19, %18
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"Cbuf_ExecuteText: bad exec_when\00"
define void @Cbuf_ExecuteText(i32 %0, i8* %1) {
switch i32 %0, label %16 [
i32 0, label %3
i32 1, label %12
i32 2, label %14
]
3: ; preds = %2
%4 = icmp eq i8* %1, null
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %1)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @Cmd_ExecuteString(i8* %1)
br label %18
10: ; preds = %5, %3
%11 = tail call i32 (...) @Cbuf_Execute()
br label %18
12: ; preds = %2
%13 = tail call i32 @Cbuf_InsertText(i8* %1)
br label %18
14: ; preds = %2
%15 = tail call i32 @Cbuf_AddText(i8* %1)
br label %18
16: ; preds = %2
%17 = tail call i32 @Com_Error(i32 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %8, %10, %16, %14, %12
ret void
}