#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*/ model;

/* Variables and functions */
int /*<<< orphan*/ Com_sprintf(char *, int, char *, char *, ...);
scalar_t__ Q_stricmp(char *, char *);
int /*<<< orphan*/ Q_strncpyz(char *, char const *, int);
char *Q_strrchr(char *, char);
int /*<<< orphan*/ trap_R_RegisterShaderNoMip(char *);
void ServerPlayerIcon(const char *modelAndSkin, char *iconName,
                      int iconNameMaxSize) {
  char *skin;
  char model[64];
  Q_strncpyz(model, modelAndSkin, sizeof(model));
  skin = Q_strrchr(model, '/');
  if (skin) {
    *skin++ = '\0';
  } else {
    skin = "default";
  }
  Com_sprintf(iconName, iconNameMaxSize, "models/players/%s/icon_%s.tga", model,
              skin);
  if (!trap_R_RegisterShaderNoMip(iconName) &&
      Q_stricmp(skin, "default") != 0) {
    Com_sprintf(iconName, iconNameMaxSize, "models/players/%s/icon_default.tga",
                model);
  }
}


x86 assembly (clang, -O0):
<ServerPlayerIcon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x40,%edx
call   1070 <Q_strncpyz@plt>
lea    -0x60(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <Q_strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a9 <ServerPlayerIcon+0x59>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
jmp    11b4 <ServerPlayerIcon+0x64>
lea    0xe50(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x60(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe3e(%rip),%rdx
mov    $0x0,%al
call   1050 <Com_sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <trap_R_RegisterShaderNoMip@plt>
cmp    $0x0,%eax
jne    1216 <ServerPlayerIcon+0xc6>
mov    -0x20(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1030 <Q_stricmp@plt>
cmp    $0x0,%rax
je     1216 <ServerPlayerIcon+0xc6>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x60(%rbp),%rcx
lea    0xe17(%rip),%rdx
mov    $0x0,%al
call   1050 <Com_sprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ServerPlayerIcon>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x40,%edx
call   1070 <Q_strncpyz@plt>
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1060 <Q_strrchr@plt>
test   %rax,%rax
je     118f <ServerPlayerIcon+0x3f>
mov    %rax,%rbp
add    $0x1,%rbp
movb   $0x0,(%rax)
jmp    1196 <ServerPlayerIcon+0x46>
lea    0xe6a(%rip),%rbp
lea    0xe6b(%rip),%rdx
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rbp,%r8
xor    %eax,%eax
call   1050 <Com_sprintf@plt>
mov    %rbx,%rdi
call   1040 <trap_R_RegisterShaderNoMip@plt>
test   %eax,%eax
jne    11e7 <ServerPlayerIcon+0x97>
lea    0xe3d(%rip),%rsi
mov    %rbp,%rdi
call   1030 <Q_stricmp@plt>
test   %rax,%rax
je     11e7 <ServerPlayerIcon+0x97>
lea    0xe4f(%rip),%rdx
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <Com_sprintf@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"default\00"
@.str.1 = [30 x i8] c"models/players/%s/icon_%s.tga\00"
@.str.2 = [35 x i8] c"models/players/%s/icon_default.tga\00"
define void @ServerPlayerIcon(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [64 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @Q_strncpyz(i8* %9, i8* %10, i32 64)
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%13 = call i8* @Q_strrchr(i8* %12, i8 signext 47)
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %7
store i8 0, i8* %17
br label %20
19: ; preds = %3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %7
br label %20
20: ; preds = %19, %16
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%24 = load i8*, i8** %7
%25 = call i32 (i8*, i32, i8*, i8*, ...) @Com_sprintf(i8* %21, i32 %22, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
%26 = load i8*, i8** %5
%27 = call i32 @trap_R_RegisterShaderNoMip(i8* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %38, label %29
29: ; preds = %20
%30 = load i8*, i8** %7
%31 = call i64 @Q_stricmp(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = load i32, i32* %6
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%37 = call i32 (i8*, i32, i8*, i8*, ...) @Com_sprintf(i8* %34, i32 %35, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %33, %29, %20
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"default\00"
@.str.1 = [30 x i8] c"models/players/%s/icon_%s.tga\00"
@.str.2 = [35 x i8] c"models/players/%s/icon_default.tga\00"
define void @ServerPlayerIcon(i8* %0, i8* %1, i32 %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = call i32 @Q_strncpyz(i8* %5, i8* %0, i32 64)
%7 = call i8* @Q_strrchr(i8* %5, i8 signext 47)
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %3
%10 = getelementptr inbounds i8, i8* %7, i64 1
store i8 0, i8* %7
br label %11
11: ; preds = %3, %9
%12 = phi i8* [ %10, %9 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %3 ]
%13 = call i32 (i8*, i32, i8*, i8*, ...) @Com_sprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %12)
%14 = call i32 @trap_R_RegisterShaderNoMip(i8* %1)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = call i64 @Q_stricmp(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 (i8*, i32, i8*, i8*, ...) @Com_sprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %21
21: ; preds = %19, %16, %11
ret void
}