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

/* Variables and functions */
int /*<<< orphan*/ Com_sprintf(char *, int, char *, int);
int /*<<< orphan*/ Info_SetValueForKey(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ Info_ValueForKey(char *, char *);
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ trap_Cvar_Set(int /*<<< orphan*/, char *);
int /*<<< orphan*/ trap_Cvar_VariableStringBuffer(int /*<<< orphan*/, char *,
                                                  int);
scalar_t__ trap_Cvar_VariableValue(char *);
int /*<<< orphan*/ va(char *, int);
void UI_SetBestScore(int level, int score) {
  int skill;
  int oldScore;
  char arenaKey[16];
  char scores[1024];
  if (score < 1 || score > 8) {
    return;
  }
  skill = (int)trap_Cvar_VariableValue("g_spSkill");
  if (skill < 1 || skill > 5) {
    return;
  }
  trap_Cvar_VariableStringBuffer(va("g_spScores%i", skill), scores, 1024);
  Com_sprintf(arenaKey, sizeof(arenaKey), "l%i", level);
  oldScore = atoi(Info_ValueForKey(scores, arenaKey));
  if (oldScore && oldScore <= score) {
    return;
  }
  Info_SetValueForKey(scores, arenaKey, va("%i", score));
  trap_Cvar_Set(va("g_spScores%i", skill), scores);
}


x86 assembly (clang, -O0):
<UI_SetBestScore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     11a5 <UI_SetBestScore+0x25>
cmpl   $0x8,-0x8(%rbp)
jle    11aa <UI_SetBestScore+0x2a>
jmp    129b <UI_SetBestScore+0x11b>
lea    0xe4f(%rip),%rdi
call   1070 <trap_Cvar_VariableValue@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     11cd <UI_SetBestScore+0x4d>
cmpl   $0x5,-0xc(%rbp)
jle    11d2 <UI_SetBestScore+0x52>
jmp    129b <UI_SetBestScore+0x11b>
mov    -0xc(%rbp),%esi
lea    0xe2e(%rip),%rdi
call   1080 <va@plt>
mov    %eax,%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1040 <trap_Cvar_VariableStringBuffer@plt>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x10,%esi
lea    0xe10(%rip),%rdx
call   1060 <Com_sprintf@plt>
lea    -0x420(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <Info_ValueForKey@plt>
mov    %eax,%edi
call   1090 <atoi@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1241 <UI_SetBestScore+0xc1>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1241 <UI_SetBestScore+0xc1>
jmp    129b <UI_SetBestScore+0x11b>
lea    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdb4(%rip),%rdi
call   1080 <va@plt>
mov    -0x430(%rbp),%rdi
mov    -0x428(%rbp),%rsi
mov    %eax,%edx
call   1030 <Info_SetValueForKey@plt>
mov    -0xc(%rbp),%esi
lea    0xd82(%rip),%rdi
call   1080 <va@plt>
mov    %eax,%edi
lea    -0x420(%rbp),%rsi
call   10a0 <trap_Cvar_Set@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_SetBestScore>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x410,%rsp
mov    %esi,%ebx
lea    -0x9(%rbx),%eax
cmp    $0xfffffff8,%eax
jb     1249 <UI_SetBestScore+0xc9>
mov    %edi,%ebp
lea    0xe5a(%rip),%rdi
call   1070 <trap_Cvar_VariableValue@plt>
mov    %rax,%r14
add    $0xfffffffa,%eax
cmp    $0xfffffffb,%eax
jb     1249 <UI_SetBestScore+0xc9>
lea    0xe49(%rip),%rdi
mov    %r14d,%esi
call   1080 <va@plt>
lea    0x10(%rsp),%r15
mov    %eax,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1040 <trap_Cvar_VariableStringBuffer@plt>
lea    0xe33(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x10,%esi
mov    %ebp,%ecx
call   1060 <Com_sprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <Info_ValueForKey@plt>
mov    %eax,%edi
call   1090 <atoi@plt>
test   %eax,%eax
je     1210 <UI_SetBestScore+0x90>
cmp    %ebx,%eax
jle    1249 <UI_SetBestScore+0xc9>
lea    0xe01(%rip),%rdi
mov    %ebx,%esi
call   1080 <va@plt>
lea    0x10(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <Info_SetValueForKey@plt>
lea    0xdd3(%rip),%rdi
mov    %r14d,%esi
call   1080 <va@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   10a0 <trap_Cvar_Set@plt>
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"g_spSkill\00"
@.str.1 = [13 x i8] c"g_spScores%i\00"
@.str.2 = [4 x i8] c"l%i\00"
@.str.3 = [3 x i8] c"%i\00"
define void @UI_SetBestScore(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [16 x i8]
%8 = alloca [1024 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 8
br i1 %13, label %14, label %15
14: ; preds = %11, %2
br label %53
15: ; preds = %11
%16 = call i64 @trap_Cvar_VariableValue(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%17 = trunc i64 %16 to i32
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load i32, i32* %5
%22 = icmp sgt i32 %21, 5
br i1 %22, label %23, label %24
23: ; preds = %20, %15
br label %53
24: ; preds = %20
%25 = load i32, i32* %5
%26 = call i32 @va(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%28 = call i32 @trap_Cvar_VariableStringBuffer(i32 %26, i8* %27, i32 1024)
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%30 = load i32, i32* %3
%31 = call i32 @Com_sprintf(i8* %29, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%34 = call i32 @Info_ValueForKey(i8* %32, i8* %33)
%35 = call i32 @atoi(i32 %34)
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %24
%39 = load i32, i32* %6
%40 = load i32, i32* %4
%41 = icmp sle i32 %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38
br label %53
43: ; preds = %38, %24
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%45 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%46 = load i32, i32* %4
%47 = call i32 @va(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = call i32 @Info_SetValueForKey(i8* %44, i8* %45, i32 %47)
%49 = load i32, i32* %5
%50 = call i32 @va(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%52 = call i32 @trap_Cvar_Set(i32 %50, i8* %51)
br label %53
53: ; preds = %43, %42, %23, %14
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"g_spSkill\00"
@.str.1 = [13 x i8] c"g_spScores%i\00"
@.str.2 = [4 x i8] c"l%i\00"
@.str.3 = [3 x i8] c"%i\00"
define void @UI_SetBestScore(i32 %0, i32 %1) {
%3 = alloca [16 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = add i32 %1, -9
%8 = icmp ult i32 %7, -8
br i1 %8, label %28, label %9
9: ; preds = %2
%10 = tail call i64 @trap_Cvar_VariableValue(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = trunc i64 %10 to i32
%12 = add i32 %11, -6
%13 = icmp ult i32 %12, -5
br i1 %13, label %28, label %14
14: ; preds = %9
%15 = tail call i32 @va(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%16 = call i32 @trap_Cvar_VariableStringBuffer(i32 %15, i8* %6, i32 1024)
%17 = call i32 @Com_sprintf(i8* %5, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%18 = call i32 @Info_ValueForKey(i8* %6, i8* %5)
%19 = call i32 @atoi(i32 %18)
%20 = icmp eq i32 %19, 0
%21 = icmp sgt i32 %19, %1
%22 = or i1 %20, %21
br i1 %22, label %23, label %28
23: ; preds = %14
%24 = call i32 @va(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%25 = call i32 @Info_SetValueForKey(i8* %6, i8* %5, i32 %24)
%26 = call i32 @va(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%27 = call i32 @trap_Cvar_Set(i32 %26, i8* %6)
br label %28
28: ; preds = %14, %9, %2, %23
ret void
}