#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*/ ClientName(int, char *, int);
int /*<<< orphan*/ Q_stricmp(char *, char *);
scalar_t__ stristr(char *, char *);
int trap_Cvar_VariableIntegerValue(char *);
int FindClientByName(char *name) {
  int i;
  char buf[1024];
  static int maxclis;
  if (!maxclis)
    maxclis = trap_Cvar_VariableIntegerValue("sv_maxclients");
  for (i = 0; i < maxclis && i < 128; i++) {
    ClientName(i, buf, sizeof(buf));
    if (!Q_stricmp(buf, name))
      return i;
  }
  for (i = 0; i < maxclis && i < 128; i++) {
    ClientName(i, buf, sizeof(buf));
    if (stristr(buf, name))
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<FindClientByName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
cmpl   $0x0,0x2eee(%rip)
jne    116e <FindClientByName+0x2e>
lea    0xe9d(%rip),%rdi
call   1050 <trap_Cvar_VariableIntegerValue@plt>
mov    %eax,0x2ed6(%rip)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    0x2ec4(%rip),%ecx
mov    %al,-0x421(%rbp)
jge    119c <FindClientByName+0x5c>
cmpl   $0x80,-0x14(%rbp)
setl   %al
mov    %al,-0x421(%rbp)
mov    -0x421(%rbp),%al
test   $0x1,%al
jne    11af <FindClientByName+0x6f>
jmp    11fa <FindClientByName+0xba>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <ClientName@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <Q_stricmp@plt>
cmp    $0x0,%eax
jne    11e7 <FindClientByName+0xa7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128e <FindClientByName+0x14e>
jmp    11ec <FindClientByName+0xac>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1175 <FindClientByName+0x35>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    0x2e38(%rip),%ecx
mov    %al,-0x422(%rbp)
jge    1228 <FindClientByName+0xe8>
cmpl   $0x80,-0x14(%rbp)
setl   %al
mov    %al,-0x422(%rbp)
mov    -0x422(%rbp),%al
test   $0x1,%al
jne    123b <FindClientByName+0xfb>
jmp    1287 <FindClientByName+0x147>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <ClientName@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <stristr@plt>
cmp    $0x0,%rax
je     1274 <FindClientByName+0x134>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128e <FindClientByName+0x14e>
jmp    1279 <FindClientByName+0x139>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1201 <FindClientByName+0xc1>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindClientByName>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r15
mov    0x2eee(%rip),%eax
test   %eax,%eax
jne    116c <FindClientByName+0x2c>
lea    0xe9f(%rip),%rdi
call   1050 <trap_Cvar_VariableIntegerValue@plt>
mov    %eax,0x2ed8(%rip)
mov    $0xffffffff,%r14d
test   %eax,%eax
jle    11f9 <FindClientByName+0xb9>
xor    %ebp,%ebp
mov    %rsp,%rbx
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1060 <ClientName@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <Q_stricmp@plt>
test   %eax,%eax
je     11f1 <FindClientByName+0xb1>
mov    0x2ea0(%rip),%eax
cmp    $0x7e,%ebp
ja     11b0 <FindClientByName+0x70>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1180 <FindClientByName+0x40>
test   %eax,%eax
jle    11f9 <FindClientByName+0xb9>
xor    %ebx,%ebx
mov    %rsp,%rbp
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1060 <ClientName@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <stristr@plt>
test   %rax,%rax
jne    11f6 <FindClientByName+0xb6>
cmp    $0x7e,%ebx
ja     11f9 <FindClientByName+0xb9>
add    $0x1,%ebx
cmp    0x2e57(%rip),%ebx
jl     11c0 <FindClientByName+0x80>
jmp    11f9 <FindClientByName+0xb9>
mov    %ebp,%r14d
jmp    11f9 <FindClientByName+0xb9>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@FindClientByName.maxclis = internal global i32 0
@.str = [14 x i8] c"sv_maxclients\00"
define i32 @FindClientByName(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* @FindClientByName.maxclis
%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* @FindClientByName.maxclis
br label %10
10: ; preds = %8, %1
store i32 0, i32* %4
br label %11
11: ; preds = %31, %10
%12 = load i32, i32* %4
%13 = load i32, i32* @FindClientByName.maxclis
%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, 128
br label %18
18: ; preds = %15, %11
%19 = phi i1 [ false, %11 ], [ %17, %15 ]
br i1 %19, label %20, label %34
20: ; preds = %18
%21 = load i32, i32* %4
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%23 = call i32 @ClientName(i32 %21, i8* %22, i32 1024)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = load i8*, i8** %3
%26 = call i32 @Q_stricmp(i8* %24, i8* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %20
%29 = load i32, i32* %4
store i32 %29, i32* %2
br label %59
30: ; preds = %20
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %11
34: ; preds = %18
store i32 0, i32* %4
br label %35
35: ; preds = %55, %34
%36 = load i32, i32* %4
%37 = load i32, i32* @FindClientByName.maxclis
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i32, i32* %4
%41 = icmp slt i32 %40, 128
br label %42
42: ; preds = %39, %35
%43 = phi i1 [ false, %35 ], [ %41, %39 ]
br i1 %43, label %44, label %58
44: ; preds = %42
%45 = load i32, i32* %4
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%47 = call i32 @ClientName(i32 %45, i8* %46, i32 1024)
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%49 = load i8*, i8** %3
%50 = call i64 @stristr(i8* %48, i8* %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %44
%53 = load i32, i32* %4
store i32 %53, i32* %2
br label %59
54: ; preds = %44
br label %55
55: ; preds = %54
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %35
58: ; preds = %42
store i32 -1, i32* %2
br label %59
59: ; preds = %58, %52, %28
%60 = load i32, i32* %2
ret i32 %60
}

LLVM IR (-O2):
@FindClientByName.maxclis = internal unnamed_addr global i32 0
@.str = [14 x i8] c"sv_maxclients\00"
define i32 @FindClientByName(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* @FindClientByName.maxclis
%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* @FindClientByName.maxclis
br label %8
8: ; preds = %6, %1
%9 = phi i32 [ %7, %6 ], [ %4, %1 ]
%10 = icmp sgt i32 %9, 0
br i1 %10, label %13, label %35
11: ; preds = %18
%12 = icmp sgt i32 %20, 0
br i1 %12, label %24, label %35
13: ; preds = %8, %18
%14 = phi i32 [ %19, %18 ], [ 0, %8 ]
%15 = call i32 @ClientName(i32 %14, i8* %3, i32 1024)
%16 = call i32 @Q_stricmp(i8* %3, i8* %0)
%17 = icmp eq i32 %16, 0
br i1 %17, label %35, label %18
18: ; preds = %13
%19 = add nuw nsw i32 %14, 1
%20 = load i32, i32* @FindClientByName.maxclis
%21 = icmp slt i32 %19, %20
%22 = icmp ult i32 %14, 127
%23 = and i1 %22, %21
br i1 %23, label %13, label %11
24: ; preds = %11, %29
%25 = phi i32 [ %30, %29 ], [ 0, %11 ]
%26 = call i32 @ClientName(i32 %25, i8* %3, i32 1024)
%27 = call i64 @stristr(i8* %3, i8* %0)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %24
%30 = add nuw nsw i32 %25, 1
%31 = load i32, i32* @FindClientByName.maxclis
%32 = icmp slt i32 %30, %31
%33 = icmp ult i32 %25, 127
%34 = and i1 %33, %32
br i1 %34, label %24, label %35
35: ; preds = %13, %24, %29, %8, %11
%36 = phi i32 [ -1, %11 ], [ -1, %8 ], [ %25, %24 ], [ -1, %29 ], [ %14, %13 ]
ret i32 %36
}