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

/* Variables and functions */
int /*<<< orphan*/ Com_sprintf(char *, int, char *, int);
int /*<<< orphan*/ Info_SetValueForKey(char *, char *, char *);
int /*<<< orphan*/ trap_Cvar_Set(char *, char *);
int /*<<< orphan*/ trap_Cvar_VariableStringBuffer(char *, char *, int);
int /*<<< orphan*/ trap_Print(char *);
void UI_SPUnlockMedals_f(void) {
  int n;
  char key[16];
  char awardData[1024];
  trap_Cvar_VariableStringBuffer("g_spAwards", awardData, 1024);
  for (n = 0; n < 6; n++) {
    Com_sprintf(key, sizeof(key), "a%i", n);
    Info_SetValueForKey(awardData, key, "100");
  }
  trap_Cvar_Set("g_spAwards", awardData);
  trap_Print("All levels unlocked at 100\n");
}


x86 assembly (clang, -O0):
<UI_SPUnlockMedals_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    -0x420(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x400,%edx
call   1050 <trap_Cvar_VariableStringBuffer@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x6,-0x4(%rbp)
jge    11c1 <UI_SPUnlockMedals_f+0x71>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x10,%esi
lea    0xe74(%rip),%rdx
call   1060 <Com_sprintf@plt>
lea    -0x420(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    0xe61(%rip),%rdx
call   1030 <Info_SetValueForKey@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    117a <UI_SPUnlockMedals_f+0x2a>
lea    -0x420(%rbp),%rsi
lea    0xe31(%rip),%rdi
call   1070 <trap_Cvar_Set@plt>
lea    0xe38(%rip),%rdi
call   1040 <trap_Print@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_SPUnlockMedals_f>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x410,%rsp
lea    0xe99(%rip),%r14
lea    0x10(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x400,%edx
call   1050 <trap_Cvar_VariableStringBuffer@plt>
lea    0xe88(%rip),%r12
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   1060 <Com_sprintf@plt>
lea    0xe70(%rip),%r13
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <Info_SetValueForKey@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
mov    $0x1,%ecx
call   1060 <Com_sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <Info_SetValueForKey@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
mov    $0x2,%ecx
call   1060 <Com_sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <Info_SetValueForKey@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
mov    $0x3,%ecx
call   1060 <Com_sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <Info_SetValueForKey@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
mov    $0x4,%ecx
call   1060 <Com_sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <Info_SetValueForKey@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
mov    $0x5,%ecx
call   1060 <Com_sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <Info_SetValueForKey@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <trap_Cvar_Set@plt>
lea    0xda5(%rip),%rdi
call   1040 <trap_Print@plt>
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"g_spAwards\00"
@.str.1 = [4 x i8] c"a%i\00"
@.str.2 = [4 x i8] c"100\00"
@.str.3 = [28 x i8] c"All levels unlocked at 100\0A\00"
define void @UI_SPUnlockMedals_f() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @trap_Cvar_VariableStringBuffer(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4, i32 1024)
store i32 0, i32* %1
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 6
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* %1
%12 = call i32 @Com_sprintf(i8* %10, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%15 = call i32 @Info_SetValueForKey(i8* %13, i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %9
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
br label %6
19: ; preds = %6
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = call i32 @trap_Cvar_Set(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @trap_Print(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"g_spAwards\00"
@.str.1 = [4 x i8] c"a%i\00"
@.str.2 = [4 x i8] c"100\00"
@.str.3 = [28 x i8] c"All levels unlocked at 100\0A\00"
define void @UI_SPUnlockMedals_f() {
%1 = alloca [16 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call i32 @trap_Cvar_VariableStringBuffer(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4, i32 1024)
%6 = call i32 @Com_sprintf(i8* %3, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 0)
%7 = call i32 @Info_SetValueForKey(i8* %4, i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @Com_sprintf(i8* %3, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%9 = call i32 @Info_SetValueForKey(i8* %4, i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @Com_sprintf(i8* %3, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 2)
%11 = call i32 @Info_SetValueForKey(i8* %4, i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @Com_sprintf(i8* %3, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%13 = call i32 @Info_SetValueForKey(i8* %4, i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @Com_sprintf(i8* %3, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%15 = call i32 @Info_SetValueForKey(i8* %4, i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @Com_sprintf(i8* %3, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 5)
%17 = call i32 @Info_SetValueForKey(i8* %4, i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @trap_Cvar_Set(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4)
%19 = call i32 @trap_Print(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
ret void
}