#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ BotAI_Print(int, char *);
int /*<<< orphan*/ Info_ValueForKey(char *, char *);
int /*<<< orphan*/ Q_CleanStr(char *);
int /*<<< orphan*/ strncpy(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ trap_GetConfigstring(int, char *, int);
char *ClientName(int client, char *name, int size) {
  char buf[1024];
  if (client < 0 || client >= 64) {
    BotAI_Print(3, "ClientName: client out of range\n");
    return "[client out of range]";
  }
  trap_GetConfigstring(((64 + 256) + 256) + client, buf, sizeof(buf));
  strncpy(name, Info_ValueForKey(buf, "n"), size - 1);
  name[size - 1] = '\0';
  Q_CleanStr(name);
  return name;
}


x86 assembly (clang, -O0):
<ClientName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1179 <ClientName+0x29>
cmpl   $0x40,-0xc(%rbp)
jl     119a <ClientName+0x4a>
mov    $0x3,%edi
lea    0xe7b(%rip),%rsi
call   1070 <BotAI_Print@plt>
lea    0xe90(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1208 <ClientName+0xb8>
mov    -0xc(%rbp),%edi
add    $0x240,%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <trap_GetConfigstring@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <Info_ValueForKey@plt>
mov    -0x428(%rbp),%rdi
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1050 <Q_CleanStr@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClientName>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
cmp    $0x40,%edi
jb     117a <ClientName+0x2a>
lea    0xe99(%rip),%rsi
mov    $0x3,%edi
call   1070 <BotAI_Print@plt>
lea    0xea9(%rip),%rbx
jmp    11c2 <ClientName+0x72>
mov    %edx,%ebp
mov    %rsi,%rbx
add    $0x240,%edi
mov    %rsp,%r14
mov    %r14,%rsi
mov    $0x400,%edx
call   1060 <trap_GetConfigstring@plt>
lea    0xe9b(%rip),%rsi
mov    %r14,%rdi
call   1040 <Info_ValueForKey@plt>
movslq %ebp,%rbp
lea    -0x1(%rbp),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strncpy@plt>
movb   $0x0,-0x1(%rbx,%rbp,1)
mov    %rbx,%rdi
call   1050 <Q_CleanStr@plt>
mov    %rbx,%rax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"ClientName: client out of range\0A\00"
@.str.1 = [22 x i8] c"[client out of range]\00"
@.str.2 = [2 x i8] c"n\00"
define i8* @ClientName(i32 %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [1024 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load i32, i32* %5
%13 = icmp sge i32 %12, 64
br i1 %13, label %14, label %16
14: ; preds = %11, %3
%15 = call i32 @BotAI_Print(i32 3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %35
16: ; preds = %11
%17 = load i32, i32* %5
%18 = add nsw i32 576, %17
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%20 = call i32 @trap_GetConfigstring(i32 %18, i8* %19, i32 1024)
%21 = load i8*, i8** %6
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%23 = call i32 @Info_ValueForKey(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* %7
%25 = sub nsw i32 %24, 1
%26 = call i32 @strncpy(i8* %21, i32 %23, i32 %25)
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8 0, i8* %31
%32 = load i8*, i8** %6
%33 = call i32 @Q_CleanStr(i8* %32)
%34 = load i8*, i8** %6
store i8* %34, i8** %4
br label %35
35: ; preds = %16, %14
%36 = load i8*, i8** %4
ret i8* %36
}

LLVM IR (-O2):
@.str = [33 x i8] c"ClientName: client out of range\0A\00"
@.str.1 = [22 x i8] c"[client out of range]\00"
@.str.2 = [2 x i8] c"n\00"
define i8* @ClientName(i32 %0, i8* %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = icmp ugt i32 %0, 63
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @BotAI_Print(i32 3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %18
9: ; preds = %3
%10 = add nuw nsw i32 %0, 576
%11 = call i32 @trap_GetConfigstring(i32 %10, i8* %5, i32 1024)
%12 = call i32 @Info_ValueForKey(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = add nsw i32 %2, -1
%14 = call i32 @strncpy(i8* %1, i32 %12, i32 %13)
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i8, i8* %1, i64 %15
store i8 0, i8* %16
%17 = call i32 @Q_CleanStr(i8* %1)
br label %18
18: ; preds = %9, %7
%19 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %7 ], [ %1, %9 ]
ret i8* %19
}