#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*/ AddTestClient();
int Cmd_Argc();
int /*<<< orphan*/ Cmd_Argv(int);
int /*<<< orphan*/ Com_Printf(char *);
int GetCvarInt(char *);
int /*<<< orphan*/ SetCvar(char *, char *);
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
void Cmd_BotAdd() {
  int argc = Cmd_Argc();
  if (argc > 2) {
    Com_Printf("Usage: bot_add <amount> or just bot_add\n");
    return;
  }
  if (GetCvarInt("sv_running") < 1) {
    Com_Printf("Server is not running.\n");
    return;
  }
  if (argc == 1) {
    AddTestClient();
    return;
  }
  int amount = atoi(Cmd_Argv(1));
  int botcount = GetCvarInt("bot_count");
  int botmax = GetCvarInt("bot_maxcount");
  if (amount > 64)
    amount = 64;
  if (amount < 1)
    amount = 1;
  if (amount > botmax)
    amount = botmax;
  int i;
  for (i = 0; i < amount; i++)
    AddTestClient();
  int total = amount + botcount;
  char str[2];
  snprintf(str, 2, "%d", total);
  SetCvar("bot_count", str);
}


x86 assembly (clang, -O0):
<Cmd_BotAdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <Cmd_Argc@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jle    11ad <Cmd_BotAdd+0x2d>
lea    0xe5d(%rip),%rdi
call   1080 <Com_Printf@plt>
jmp    12a8 <Cmd_BotAdd+0x128>
lea    0xe75(%rip),%rdi
call   1070 <GetCvarInt@plt>
cmp    $0x1,%eax
jge    11d3 <Cmd_BotAdd+0x53>
lea    0xe6b(%rip),%rdi
call   1080 <Com_Printf@plt>
jmp    12a8 <Cmd_BotAdd+0x128>
cmpl   $0x1,-0x4(%rbp)
jne    11e9 <Cmd_BotAdd+0x69>
mov    $0x0,%al
call   1030 <AddTestClient@plt>
jmp    12a8 <Cmd_BotAdd+0x128>
mov    $0x1,%edi
call   1090 <Cmd_Argv@plt>
mov    %eax,%edi
call   10a0 <atoi@plt>
mov    %eax,-0x8(%rbp)
lea    0xe48(%rip),%rdi
call   1070 <GetCvarInt@plt>
mov    %eax,-0xc(%rbp)
lea    0xe43(%rip),%rdi
call   1070 <GetCvarInt@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x40,-0x8(%rbp)
jle    122c <Cmd_BotAdd+0xac>
movl   $0x40,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    123d <Cmd_BotAdd+0xbd>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    124f <Cmd_BotAdd+0xcf>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1277 <Cmd_BotAdd+0xf7>
mov    $0x0,%al
call   1030 <AddTestClient@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1256 <Cmd_BotAdd+0xd6>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x18(%rbp),%ecx
mov    $0x2,%esi
lea    0xdd0(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x1a(%rbp),%rsi
lea    0xda9(%rip),%rdi
call   1040 <SetCvar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cmd_BotAdd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <Cmd_Argc@plt>
cmp    $0x3,%eax
jl     119c <Cmd_BotAdd+0x1c>
lea    0xe66(%rip),%rdi
jmp    11cb <Cmd_BotAdd+0x4b>
mov    %eax,%ebx
lea    0xe84(%rip),%rdi
call   1070 <GetCvarInt@plt>
test   %eax,%eax
jle    11c4 <Cmd_BotAdd+0x44>
cmp    $0x1,%ebx
jne    11da <Cmd_BotAdd+0x5a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <AddTestClient@plt>
lea    0xe69(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <Com_Printf@plt>
mov    $0x1,%r15d
mov    $0x1,%edi
call   1090 <Cmd_Argv@plt>
mov    %eax,%edi
call   10a0 <atoi@plt>
mov    %eax,%ebx
lea    0xe52(%rip),%rdi
call   1070 <GetCvarInt@plt>
mov    %eax,%r14d
lea    0xe4d(%rip),%rdi
call   1070 <GetCvarInt@plt>
cmp    $0x40,%ebx
mov    $0x40,%ebp
cmovl  %ebx,%ebp
test   %ebp,%ebp
cmovle %r15d,%ebp
cmp    %eax,%ebp
cmovg  %eax,%ebp
test   %ebp,%ebp
jle    123c <Cmd_BotAdd+0xbc>
mov    %ebp,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <AddTestClient@plt>
add    $0xffffffff,%ebx
jne    1230 <Cmd_BotAdd+0xb0>
add    %r14d,%ebp
lea    0xe1d(%rip),%rdx
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %ebp,%ecx
call   1060 <snprintf@plt>
lea    0xdeb(%rip),%rdi
mov    %rbx,%rsi
call   1040 <SetCvar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Usage: bot_add <amount> or just bot_add\0A\00"
@.str.1 = [11 x i8] c"sv_running\00"
@.str.2 = [24 x i8] c"Server is not running.\0A\00"
@.str.3 = [10 x i8] c"bot_count\00"
@.str.4 = [13 x i8] c"bot_maxcount\00"
@.str.5 = [3 x i8] c"%d\00"
define void @Cmd_BotAdd() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2 x i8]
%8 = call i32 (...) @Cmd_Argc()
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @Com_Printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %60
13: ; preds = %0
%14 = call i32 @GetCvarInt(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @Com_Printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %60
18: ; preds = %13
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (...) @AddTestClient()
br label %60
23: ; preds = %18
%24 = call i32 @Cmd_Argv(i32 1)
%25 = call i32 @atoi(i32 %24)
store i32 %25, i32* %2
%26 = call i32 @GetCvarInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 %26, i32* %3
%27 = call i32 @GetCvarInt(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i32 %27, i32* %4
%28 = load i32, i32* %2
%29 = icmp sgt i32 %28, 64
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 64, i32* %2
br label %31
31: ; preds = %30, %23
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 1
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 1, i32* %2
br label %35
35: ; preds = %34, %31
%36 = load i32, i32* %2
%37 = load i32, i32* %4
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load i32, i32* %4
store i32 %40, i32* %2
br label %41
41: ; preds = %39, %35
store i32 0, i32* %5
br label %42
42: ; preds = %48, %41
%43 = load i32, i32* %5
%44 = load i32, i32* %2
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = call i32 (...) @AddTestClient()
br label %48
48: ; preds = %46
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %42
51: ; preds = %42
%52 = load i32, i32* %2
%53 = load i32, i32* %3
%54 = add nsw i32 %52, %53
store i32 %54, i32* %6
%55 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%56 = load i32, i32* %6
%57 = call i32 @snprintf(i8* %55, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%59 = call i32 @SetCvar(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %51, %21, %16, %11
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"Usage: bot_add <amount> or just bot_add\0A\00"
@.str.1 = [11 x i8] c"sv_running\00"
@.str.2 = [24 x i8] c"Server is not running.\0A\00"
@.str.3 = [10 x i8] c"bot_count\00"
@.str.4 = [13 x i8] c"bot_maxcount\00"
@.str.5 = [3 x i8] c"%d\00"
define void @Cmd_BotAdd() {
%1 = alloca [2 x i8]
%2 = tail call i32 (...) @Cmd_Argc()
%3 = icmp sgt i32 %2, 2
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %37
6: ; preds = %0
%7 = tail call i32 @GetCvarInt(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %37
11: ; preds = %6
%12 = icmp eq i32 %2, 1
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 (...) @AddTestClient()
br label %37
15: ; preds = %11
%16 = tail call i32 @Cmd_Argv(i32 1)
%17 = tail call i32 @atoi(i32 %16)
%18 = tail call i32 @GetCvarInt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 @GetCvarInt(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp slt i32 %17, 64
%21 = select i1 %20, i32 %17, i32 64
%22 = icmp sgt i32 %21, 1
%23 = select i1 %22, i32 %21, i32 1
%24 = icmp sgt i32 %23, %19
%25 = select i1 %24, i32 %19, i32 %23
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %15, %27
%28 = phi i32 [ %30, %27 ], [ 0, %15 ]
%29 = tail call i32 (...) @AddTestClient()
%30 = add nuw nsw i32 %28, 1
%31 = icmp eq i32 %30, %25
br i1 %31, label %32, label %27
32: ; preds = %27, %15
%33 = add nsw i32 %25, %18
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%35 = call i32 @snprintf(i8* %34, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%36 = call i32 @SetCvar(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %34)
br label %37
37: ; preds = %32, %13, %9, %4
ret void
}