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

/* Variables and functions */
int /*<<< orphan*/ Com_DPrintf(char *, char *);
int /*<<< orphan*/ Com_sprintf(char *, int, char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ FS_Gamedir();
int /*<<< orphan*/ Sys_FindClose();
char *Sys_FindFirst(char *, int /*<<< orphan*/, int /*<<< orphan*/);
char *Sys_FindNext(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ remove(char *);
void SV_WipeSavegame(char *savename) {
  char name[128];
  char *s;
  Com_DPrintf("SV_WipeSaveGame(%s)\n", savename);
  Com_sprintf(name, sizeof(name), "%s/save/%s/server.ssv", FS_Gamedir(),
              savename);
  remove(name);
  Com_sprintf(name, sizeof(name), "%s/save/%s/game.ssv", FS_Gamedir(),
              savename);
  remove(name);
  Com_sprintf(name, sizeof(name), "%s/save/%s/shot.jpg", FS_Gamedir(),
              savename);
  remove(name);
  Com_sprintf(name, sizeof(name), "%s/save/%s/*.sav", FS_Gamedir(), savename);
  s = Sys_FindFirst(name, 0, 0);
  while (s) {
    remove(s);
    s = Sys_FindNext(0, 0);
  }
  Sys_FindClose();
  Com_sprintf(name, sizeof(name), "%s/save/%s/*.sv2", FS_Gamedir(), savename);
  s = Sys_FindFirst(name, 0, 0);
  while (s) {
    remove(s);
    s = Sys_FindNext(0, 0);
  }
  Sys_FindClose();
}


x86 assembly (clang, -O0):
<SV_WipeSavegame>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1090 <Com_DPrintf@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    $0x0,%al
call   1070 <FS_Gamedir@plt>
mov    -0xb8(%rbp),%rdi
mov    %eax,%ecx
mov    -0x8(%rbp),%r8
mov    $0x80,%esi
lea    0xe58(%rip),%rdx
call   1080 <Com_sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <remove@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    $0x0,%al
call   1070 <FS_Gamedir@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,%ecx
mov    -0x8(%rbp),%r8
mov    $0x80,%esi
lea    0xe2f(%rip),%rdx
call   1080 <Com_sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <remove@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    $0x0,%al
call   1070 <FS_Gamedir@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%ecx
mov    -0x8(%rbp),%r8
mov    $0x80,%esi
lea    0xe04(%rip),%rdx
call   1080 <Com_sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <remove@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    $0x0,%al
call   1070 <FS_Gamedir@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%ecx
mov    -0x8(%rbp),%r8
mov    $0x80,%esi
lea    0xdd9(%rip),%rdx
call   1080 <Com_sprintf@plt>
lea    -0x90(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <Sys_FindFirst@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     12c5 <SV_WipeSavegame+0x155>
mov    -0x98(%rbp),%rdi
call   1040 <remove@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <Sys_FindNext@plt>
mov    %rax,-0x98(%rbp)
jmp    1296 <SV_WipeSavegame+0x126>
mov    $0x0,%al
call   1060 <Sys_FindClose@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    $0x0,%al
call   1070 <FS_Gamedir@plt>
mov    -0xc0(%rbp),%rdi
mov    %eax,%ecx
mov    -0x8(%rbp),%r8
mov    $0x80,%esi
lea    0xd6a(%rip),%rdx
call   1080 <Com_sprintf@plt>
lea    -0x90(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <Sys_FindFirst@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     1345 <SV_WipeSavegame+0x1d5>
mov    -0x98(%rbp),%rdi
call   1040 <remove@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <Sys_FindNext@plt>
mov    %rax,-0x98(%rbp)
jmp    1316 <SV_WipeSavegame+0x1a6>
mov    $0x0,%al
call   1060 <Sys_FindClose@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SV_WipeSavegame>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%r14
lea    0xe7c(%rip),%rdi
mov    %r14,%rsi
call   1090 <Com_DPrintf@plt>
xor    %eax,%eax
call   1070 <FS_Gamedir@plt>
lea    0xe7b(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
mov    %r14,%r8
call   1080 <Com_sprintf@plt>
mov    %rbx,%rdi
call   1040 <remove@plt>
xor    %eax,%eax
call   1070 <FS_Gamedir@plt>
lea    0xe66(%rip),%rdx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
mov    %r14,%r8
call   1080 <Com_sprintf@plt>
mov    %rbx,%rdi
call   1040 <remove@plt>
xor    %eax,%eax
call   1070 <FS_Gamedir@plt>
lea    0xe52(%rip),%rdx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
mov    %r14,%r8
call   1080 <Com_sprintf@plt>
mov    %rbx,%rdi
call   1040 <remove@plt>
xor    %eax,%eax
call   1070 <FS_Gamedir@plt>
lea    0xe3e(%rip),%rdx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
mov    %r14,%r8
call   1080 <Com_sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <Sys_FindFirst@plt>
test   %rax,%rax
je     1256 <SV_WipeSavegame+0xe6>
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1040 <remove@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <Sys_FindNext@plt>
test   %rax,%rax
jne    1240 <SV_WipeSavegame+0xd0>
xor    %eax,%eax
call   1060 <Sys_FindClose@plt>
xor    %eax,%eax
call   1070 <FS_Gamedir@plt>
lea    0xdf9(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %eax,%ecx
mov    %r14,%r8
call   1080 <Com_sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <Sys_FindFirst@plt>
test   %rax,%rax
je     12b6 <SV_WipeSavegame+0x146>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1040 <remove@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <Sys_FindNext@plt>
test   %rax,%rax
jne    12a0 <SV_WipeSavegame+0x130>
xor    %eax,%eax
call   1060 <Sys_FindClose@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"SV_WipeSaveGame(%s)\0A\00"
@.str.1 = [22 x i8] c"%s/save/%s/server.ssv\00"
@.str.2 = [20 x i8] c"%s/save/%s/game.ssv\00"
@.str.3 = [20 x i8] c"%s/save/%s/shot.jpg\00"
@.str.4 = [17 x i8] c"%s/save/%s/*.sav\00"
@.str.5 = [17 x i8] c"%s/save/%s/*.sv2\00"
define void @SV_WipeSavegame(i8* %0) {
%2 = alloca i8*
%3 = alloca [128 x i8]
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @Com_DPrintf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%8 = call i32 (...) @FS_Gamedir()
%9 = load i8*, i8** %2
%10 = call i32 @Com_sprintf(i8* %7, i32 128, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %8, i8* %9)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%12 = call i32 @remove(i8* %11)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%14 = call i32 (...) @FS_Gamedir()
%15 = load i8*, i8** %2
%16 = call i32 @Com_sprintf(i8* %13, i32 128, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %14, i8* %15)
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%18 = call i32 @remove(i8* %17)
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%20 = call i32 (...) @FS_Gamedir()
%21 = load i8*, i8** %2
%22 = call i32 @Com_sprintf(i8* %19, i32 128, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %20, i8* %21)
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%24 = call i32 @remove(i8* %23)
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%26 = call i32 (...) @FS_Gamedir()
%27 = load i8*, i8** %2
%28 = call i32 @Com_sprintf(i8* %25, i32 128, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %26, i8* %27)
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%30 = call i8* @Sys_FindFirst(i8* %29, i32 0, i32 0)
store i8* %30, i8** %4
br label %31
31: ; preds = %34, %1
%32 = load i8*, i8** %4
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i8*, i8** %4
%36 = call i32 @remove(i8* %35)
%37 = call i8* @Sys_FindNext(i32 0, i32 0)
store i8* %37, i8** %4
br label %31
38: ; preds = %31
%39 = call i32 (...) @Sys_FindClose()
%40 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%41 = call i32 (...) @FS_Gamedir()
%42 = load i8*, i8** %2
%43 = call i32 @Com_sprintf(i8* %40, i32 128, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %41, i8* %42)
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%45 = call i8* @Sys_FindFirst(i8* %44, i32 0, i32 0)
store i8* %45, i8** %4
br label %46
46: ; preds = %49, %38
%47 = load i8*, i8** %4
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i8*, i8** %4
%51 = call i32 @remove(i8* %50)
%52 = call i8* @Sys_FindNext(i32 0, i32 0)
store i8* %52, i8** %4
br label %46
53: ; preds = %46
%54 = call i32 (...) @Sys_FindClose()
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"SV_WipeSaveGame(%s)\0A\00"
@.str.1 = [22 x i8] c"%s/save/%s/server.ssv\00"
@.str.2 = [20 x i8] c"%s/save/%s/game.ssv\00"
@.str.3 = [20 x i8] c"%s/save/%s/shot.jpg\00"
@.str.4 = [17 x i8] c"%s/save/%s/*.sav\00"
@.str.5 = [17 x i8] c"%s/save/%s/*.sv2\00"
define void @SV_WipeSavegame(i8* %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @Com_DPrintf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32 (...) @FS_Gamedir()
%6 = call i32 @Com_sprintf(i8* %3, i32 128, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %5, i8* %0)
%7 = call i32 @remove(i8* %3)
%8 = call i32 (...) @FS_Gamedir()
%9 = call i32 @Com_sprintf(i8* %3, i32 128, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %8, i8* %0)
%10 = call i32 @remove(i8* %3)
%11 = call i32 (...) @FS_Gamedir()
%12 = call i32 @Com_sprintf(i8* %3, i32 128, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %11, i8* %0)
%13 = call i32 @remove(i8* %3)
%14 = call i32 (...) @FS_Gamedir()
%15 = call i32 @Com_sprintf(i8* %3, i32 128, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %14, i8* %0)
%16 = call i8* @Sys_FindFirst(i8* %3, i32 0, i32 0)
%17 = icmp eq i8* %16, null
br i1 %17, label %23, label %18
18: ; preds = %1, %18
%19 = phi i8* [ %21, %18 ], [ %16, %1 ]
%20 = call i32 @remove(i8* %19)
%21 = call i8* @Sys_FindNext(i32 0, i32 0)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %18
23: ; preds = %18, %1
%24 = call i32 (...) @Sys_FindClose()
%25 = call i32 (...) @FS_Gamedir()
%26 = call i32 @Com_sprintf(i8* %3, i32 128, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %25, i8* %0)
%27 = call i8* @Sys_FindFirst(i8* %3, i32 0, i32 0)
%28 = icmp eq i8* %27, null
br i1 %28, label %34, label %29
29: ; preds = %23, %29
%30 = phi i8* [ %32, %29 ], [ %27, %23 ]
%31 = call i32 @remove(i8* %30)
%32 = call i8* @Sys_FindNext(i32 0, i32 0)
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %29
34: ; preds = %29, %23
%35 = call i32 (...) @Sys_FindClose()
ret void
}