#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/*.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,-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    0xe58(%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    0xe2f(%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    0xe04(%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     1286 <SV_WipeSavegame+0x116>
mov    -0x98(%rbp),%rdi
call   1040 <remove@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <Sys_FindNext@plt>
mov    %rax,-0x98(%rbp)
jmp    1257 <SV_WipeSavegame+0xe7>
mov    $0x0,%al
call   1060 <Sys_FindClose@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    0xd95(%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     1306 <SV_WipeSavegame+0x196>
mov    -0x98(%rbp),%rdi
call   1040 <remove@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <Sys_FindNext@plt>
mov    %rax,-0x98(%rbp)
jmp    12d7 <SV_WipeSavegame+0x167>
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
xor    %esi,%esi
xor    %edx,%edx
call   1050 <Sys_FindFirst@plt>
test   %rax,%rax
je     1226 <SV_WipeSavegame+0xb6>
mov    %rax,%rdi
call   1040 <remove@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <Sys_FindNext@plt>
test   %rax,%rax
jne    1210 <SV_WipeSavegame+0xa0>
xor    %eax,%eax
call   1060 <Sys_FindClose@plt>
xor    %eax,%eax
call   1070 <FS_Gamedir@plt>
lea    0xe15(%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     1286 <SV_WipeSavegame+0x116>
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    1270 <SV_WipeSavegame+0x100>
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 = [17 x i8] c"%s/save/%s/*.sav\00"
@.str.4 = [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 ([17 x i8], [17 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 i8* @Sys_FindFirst(i8* %23, i32 0, i32 0)
store i8* %24, i8** %4
br label %25
25: ; preds = %28, %1
%26 = load i8*, i8** %4
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i8*, i8** %4
%30 = call i32 @remove(i8* %29)
%31 = call i8* @Sys_FindNext(i32 0, i32 0)
store i8* %31, i8** %4
br label %25
32: ; preds = %25
%33 = call i32 (...) @Sys_FindClose()
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%35 = call i32 (...) @FS_Gamedir()
%36 = load i8*, i8** %2
%37 = call i32 @Com_sprintf(i8* %34, i32 128, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %35, i8* %36)
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%39 = call i8* @Sys_FindFirst(i8* %38, i32 0, i32 0)
store i8* %39, i8** %4
br label %40
40: ; preds = %43, %32
%41 = load i8*, i8** %4
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i8*, i8** %4
%45 = call i32 @remove(i8* %44)
%46 = call i8* @Sys_FindNext(i32 0, i32 0)
store i8* %46, i8** %4
br label %40
47: ; preds = %40
%48 = 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 = [17 x i8] c"%s/save/%s/*.sav\00"
@.str.4 = [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 ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %11, i8* %0)
%13 = call i8* @Sys_FindFirst(i8* %3, i32 0, i32 0)
%14 = icmp eq i8* %13, null
br i1 %14, label %20, label %15
15: ; preds = %1, %15
%16 = phi i8* [ %18, %15 ], [ %13, %1 ]
%17 = call i32 @remove(i8* %16)
%18 = call i8* @Sys_FindNext(i32 0, i32 0)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %15
20: ; preds = %15, %1
%21 = call i32 (...) @Sys_FindClose()
%22 = call i32 (...) @FS_Gamedir()
%23 = call i32 @Com_sprintf(i8* %3, i32 128, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %22, i8* %0)
%24 = call i8* @Sys_FindFirst(i8* %3, i32 0, i32 0)
%25 = icmp eq i8* %24, null
br i1 %25, label %31, label %26
26: ; preds = %20, %26
%27 = phi i8* [ %29, %26 ], [ %24, %20 ]
%28 = call i32 @remove(i8* %27)
%29 = call i8* @Sys_FindNext(i32 0, i32 0)
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %26
31: ; preds = %26, %20
%32 = call i32 (...) @Sys_FindClose()
ret void
}