#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*/ strncpy(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ trap_GetConfigstring(int, char *, int);
char *ClientSkin(int client, char *skin, int size) {
  char buf[1024];
  if (client < 0 || client >= 64) {
    BotAI_Print(3, "ClientSkin: client out of range\n");
    return "[client out of range]";
  }
  trap_GetConfigstring(((((((64 + 256) + 256) + 32) + 1) + 64) + 16) + client,
                       buf, sizeof(buf));
  strncpy(skin, Info_ValueForKey(buf, "model"), size - 1);
  skin[size - 1] = '\0';
  return skin;
}


x86 assembly (clang, -O0):
<ClientSkin>:
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     1169 <ClientSkin+0x29>
cmpl   $0x40,-0xc(%rbp)
jl     118a <ClientSkin+0x4a>
mov    $0x3,%edi
lea    0xe8b(%rip),%rsi
call   1060 <BotAI_Print@plt>
lea    0xea0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ef <ClientSkin+0xaf>
mov    -0xc(%rbp),%edi
add    $0x2b1,%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <trap_GetConfigstring@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xe7a(%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),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClientSkin>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
cmp    $0x40,%edi
jb     116a <ClientSkin+0x2a>
lea    0xea9(%rip),%rsi
mov    $0x3,%edi
call   1060 <BotAI_Print@plt>
lea    0xeb9(%rip),%rbx
jmp    11aa <ClientSkin+0x6a>
mov    %edx,%ebp
mov    %rsi,%rbx
add    $0x2b1,%edi
mov    %rsp,%r14
mov    %r14,%rsi
mov    $0x400,%edx
call   1050 <trap_GetConfigstring@plt>
lea    0xeab(%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,%rax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"ClientSkin: client out of range\0A\00"
@.str.1 = [22 x i8] c"[client out of range]\00"
@.str.2 = [6 x i8] c"model\00"
define i8* @ClientSkin(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 %33
16: ; preds = %11
%17 = load i32, i32* %5
%18 = add nsw i32 689, %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 ([6 x i8], [6 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
store i8* %32, i8** %4
br label %33
33: ; preds = %16, %14
%34 = load i8*, i8** %4
ret i8* %34
}

LLVM IR (-O2):
@.str = [33 x i8] c"ClientSkin: client out of range\0A\00"
@.str.1 = [22 x i8] c"[client out of range]\00"
@.str.2 = [6 x i8] c"model\00"
define i8* @ClientSkin(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 %17
9: ; preds = %3
%10 = add nuw nsw i32 %0, 689
%11 = call i32 @trap_GetConfigstring(i32 %10, i8* %5, i32 1024)
%12 = call i32 @Info_ValueForKey(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 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
br label %17
17: ; preds = %9, %7
%18 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %7 ], [ %1, %9 ]
ret i8* %18
}