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

/* Variables and functions */
int /*<<< orphan*/ G_LoadGame(char *);
scalar_t__ M_CheckParm(char *);
int /*<<< orphan*/ M_ClearMenus();
int /*<<< orphan*/ sprintf(char *, char *, int);
void M_LoadSelect(int choice) {
  char name[256];
  if (M_CheckParm("-cdrom"))
    sprintf(name,
            "c:\\doomdata\\"
            "doomsav"
            "%d.dsg",
            choice);
  else
    sprintf(name,
            "doomsav"
            "%d.dsg",
            choice);
  G_LoadGame(name);
  M_ClearMenus();
}


x86 assembly (clang, -O0):
<M_LoadSelect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeab(%rip),%rdi
call   1060 <M_CheckParm@plt>
cmp    $0x0,%rax
je     117f <M_LoadSelect+0x3f>
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe92(%rip),%rsi
call   1050 <sprintf@plt>
jmp    1195 <M_LoadSelect+0x55>
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe83(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <G_LoadGame@plt>
mov    $0x0,%al
call   1040 <M_ClearMenus@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<M_LoadSelect>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %edi,%ebx
lea    0xead(%rip),%rdi
call   1060 <M_CheckParm@plt>
test   %rax,%rax
lea    0xeb1(%rip),%rax
lea    0xe9e(%rip),%rsi
cmove  %rax,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1030 <G_LoadGame@plt>
xor    %eax,%eax
call   1040 <M_ClearMenus@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"-cdrom\00"
@.str.1 = [26 x i8] c"c:\\doomdata\\doomsav%d.dsg\00"
@.str.2 = [14 x i8] c"doomsav%d.dsg\00"
define void @M_LoadSelect(i32 %0) {
%2 = alloca i32
%3 = alloca [256 x i8]
store i32 %0, i32* %2
%4 = call i64 @M_CheckParm(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %14
10: ; preds = %1
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = load i32, i32* %2
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %10, %6
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = call i32 @G_LoadGame(i8* %15)
%17 = call i32 (...) @M_ClearMenus()
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"-cdrom\00"
@.str.1 = [26 x i8] c"c:\\doomdata\\doomsav%d.dsg\00"
@.str.2 = [14 x i8] c"doomsav%d.dsg\00"
define void @M_LoadSelect(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @M_CheckParm(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0)
%7 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) %6, i32 %0)
%8 = call i32 @G_LoadGame(i8* %3)
%9 = call i32 (...) @M_ClearMenus()
ret void
}