#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*/ Info_ValueForKey(char *, char *);
int /*<<< orphan*/ Q_CleanStr(char *);
scalar_t__ Q_stricmp(int /*<<< orphan*/, char *);
int trap_Cvar_VariableIntegerValue(char *);
int /*<<< orphan*/ trap_GetConfigstring(int, char *, int);
int ClientFromName(char *name) {
  int i;
  char buf[1024];
  static int maxclients;
  if (!maxclients) {
    maxclients = trap_Cvar_VariableIntegerValue("sv_maxclients");
  }
  for (i = 0; i < maxclients && i < 64; i++) {
    trap_GetConfigstring(((32 + 256) + 256) + i, buf, sizeof(buf));
    Q_CleanStr(buf);
    if ((Q_stricmp(Info_ValueForKey(buf, "n"), name) == 0)) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<ClientFromName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
cmpl   $0x0,0x2ee6(%rip)
jne    117e <ClientFromName+0x2e>
lea    0xe8d(%rip),%rdi
call   1040 <trap_Cvar_VariableIntegerValue@plt>
mov    %eax,0x2ece(%rip)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    0x2ebc(%rip),%ecx
mov    %al,-0x421(%rbp)
jge    11a9 <ClientFromName+0x59>
cmpl   $0x40,-0x14(%rbp)
setl   %al
mov    %al,-0x421(%rbp)
mov    -0x421(%rbp),%al
test   $0x1,%al
jne    11bc <ClientFromName+0x6c>
jmp    1228 <ClientFromName+0xd8>
mov    -0x14(%rbp),%edi
add    $0x220,%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1070 <trap_GetConfigstring@plt>
lea    -0x420(%rbp),%rdi
call   1060 <Q_CleanStr@plt>
lea    -0x420(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1050 <Info_ValueForKey@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1030 <Q_stricmp@plt>
cmp    $0x0,%rax
jne    1215 <ClientFromName+0xc5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    122f <ClientFromName+0xdf>
jmp    121a <ClientFromName+0xca>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1185 <ClientFromName+0x35>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClientFromName>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%r12
mov    0x2ee4(%rip),%eax
test   %eax,%eax
jne    117e <ClientFromName+0x2e>
lea    0xe8d(%rip),%rdi
call   1040 <trap_Cvar_VariableIntegerValue@plt>
mov    %eax,0x2ece(%rip)
mov    $0xffffffff,%r14d
test   %eax,%eax
jle    11ea <ClientFromName+0x9a>
xor    %ebx,%ebx
mov    %rsp,%rbp
lea    0xe7a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x220(%rbx),%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1070 <trap_GetConfigstring@plt>
mov    %rbp,%rdi
call   1060 <Q_CleanStr@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1050 <Info_ValueForKey@plt>
mov    %eax,%edi
mov    %r12,%rsi
call   1030 <Q_stricmp@plt>
test   %rax,%rax
je     11e7 <ClientFromName+0x97>
cmp    $0x3e,%ebx
ja     11ea <ClientFromName+0x9a>
add    $0x1,%ebx
cmp    0x2e69(%rip),%ebx
jl     11a0 <ClientFromName+0x50>
jmp    11ea <ClientFromName+0x9a>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ClientFromName.maxclients = internal global i32 0
@.str = [14 x i8] c"sv_maxclients\00"
@.str.1 = [2 x i8] c"n\00"
define i32 @ClientFromName(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
store i8* %0, i8** %3
%6 = load i32, i32* @ClientFromName.maxclients
%7 = icmp ne i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @trap_Cvar_VariableIntegerValue(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* @ClientFromName.maxclients
br label %10
10: ; preds = %8, %1
store i32 0, i32* %4
br label %11
11: ; preds = %35, %10
%12 = load i32, i32* %4
%13 = load i32, i32* @ClientFromName.maxclients
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 64
br label %18
18: ; preds = %15, %11
%19 = phi i1 [ false, %11 ], [ %17, %15 ]
br i1 %19, label %20, label %38
20: ; preds = %18
%21 = load i32, i32* %4
%22 = add nsw i32 544, %21
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = call i32 @trap_GetConfigstring(i32 %22, i8* %23, i32 1024)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = call i32 @Q_CleanStr(i8* %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%28 = call i32 @Info_ValueForKey(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = load i8*, i8** %3
%30 = call i64 @Q_stricmp(i32 %28, i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %20
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %39
34: ; preds = %20
br label %35
35: ; preds = %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %11
38: ; preds = %18
store i32 -1, i32* %2
br label %39
39: ; preds = %38, %32
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@ClientFromName.maxclients = internal unnamed_addr global i32 0
@.str = [14 x i8] c"sv_maxclients\00"
@.str.1 = [2 x i8] c"n\00"
define i32 @ClientFromName(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @ClientFromName.maxclients
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @trap_Cvar_VariableIntegerValue(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %7, i32* @ClientFromName.maxclients
br label %8
8: ; preds = %6, %1
%9 = phi i32 [ %7, %6 ], [ %4, %1 ]
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %8, %19
%12 = phi i32 [ %20, %19 ], [ 0, %8 ]
%13 = add nuw nsw i32 %12, 544
%14 = call i32 @trap_GetConfigstring(i32 %13, i8* %3, i32 1024)
%15 = call i32 @Q_CleanStr(i8* %3)
%16 = call i32 @Info_ValueForKey(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = call i64 @Q_stricmp(i32 %16, i8* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %11
%20 = add nuw nsw i32 %12, 1
%21 = load i32, i32* @ClientFromName.maxclients
%22 = icmp slt i32 %20, %21
%23 = icmp ult i32 %12, 63
%24 = and i1 %23, %22
br i1 %24, label %11, label %25
25: ; preds = %11, %19, %8
%26 = phi i32 [ -1, %8 ], [ -1, %19 ], [ %12, %11 ]
ret i32 %26
}