#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 PlayerIcon(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_rpgx/%s/model_icon.jpg", model);
  if (!trap_R_RegisterShaderNoMip(iconName) &&
      Q_stricmp(skin, "default") != 0) {
    Com_sprintf(iconName, iconNameMaxSize,
                "models/players_rpgx/%s/model_icon.jpg", model);
  }
}


x86 assembly (clang, -O0):
<PlayerIcon>:
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 <PlayerIcon+0x59>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
jmp    11b4 <PlayerIcon+0x64>
lea    0xe50(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x60(%rbp),%rcx
lea    0xe42(%rip),%rdx
call   1050 <Com_sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <trap_R_RegisterShaderNoMip@plt>
cmp    $0x0,%eax
jne    120e <PlayerIcon+0xbe>
mov    -0x20(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1030 <Q_stricmp@plt>
cmp    $0x0,%rax
je     120e <PlayerIcon+0xbe>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x60(%rbp),%rcx
lea    0xdff(%rip),%rdx
call   1050 <Com_sprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PlayerIcon>:
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 <PlayerIcon+0x3f>
mov    %rax,%rbp
add    $0x1,%rbp
movb   $0x0,(%rax)
jmp    1196 <PlayerIcon+0x46>
lea    0xe6a(%rip),%rbp
lea    0xe6b(%rip),%rdx
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <Com_sprintf@plt>
mov    %rbx,%rdi
call   1040 <trap_R_RegisterShaderNoMip@plt>
test   %eax,%eax
jne    11e0 <PlayerIcon+0x90>
lea    0xe42(%rip),%rsi
mov    %rbp,%rdi
call   1030 <Q_stricmp@plt>
test   %rax,%rax
je     11e0 <PlayerIcon+0x90>
lea    0xe36(%rip),%rdx
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %r14d,%esi
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 = [38 x i8] c"models/players_rpgx/%s/model_icon.jpg\00"
define void @PlayerIcon(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 = call i32 @Com_sprintf(i8* %21, i32 %22, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %5
%26 = call i32 @trap_R_RegisterShaderNoMip(i8* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %37, label %28
28: ; preds = %20
%29 = load i8*, i8** %7
%30 = call i64 @Q_stricmp(i8* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%36 = call i32 @Com_sprintf(i8* %33, i32 %34, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %32, %28, %20
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"default\00"
@.str.1 = [38 x i8] c"models/players_rpgx/%s/model_icon.jpg\00"
define void @PlayerIcon(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 @Com_sprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%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 @Com_sprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %21
21: ; preds = %19, %16, %11
ret void
}