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

/* Variables and functions */
int /*<<< orphan*/ COM_DefaultExtension(char *, int, char *);
int Cmd_Argc();
int /*<<< orphan*/ Cmd_Argv(int);
int /*<<< orphan*/ Com_Printf(char *);
int /*<<< orphan*/ Q_strncpyz(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ SV_Map(int, char *, int /*<<< orphan*/);
int strlen(int /*<<< orphan*/);
void SV_DemoMap_f(void) {
  char demoName[64];
  if (Cmd_Argc() != 2) {
    Com_Printf("USAGE: demomap <demoname>\n");
    return;
  }
  if (strlen(Cmd_Argv(1)) >= sizeof(demoName) - 1) {
    Com_Printf("Demomap: Demo name is too long\n");
    return;
  }
  Q_strncpyz(demoName, Cmd_Argv(1), sizeof(demoName));
  COM_DefaultExtension(demoName, sizeof(demoName), ".dm2");
  SV_Map(1, demoName, 0);
}


x86 assembly (clang, -O0):
<SV_DemoMap_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    $0x0,%al
call   1040 <Cmd_Argc@plt>
cmp    $0x2,%eax
je     1199 <SV_DemoMap_f+0x29>
lea    0xe71(%rip),%rdi
call   1070 <Com_Printf@plt>
jmp    120e <SV_DemoMap_f+0x9e>
mov    $0x1,%edi
call   1080 <Cmd_Argv@plt>
mov    %eax,%edi
call   1050 <strlen@plt>
cltq
cmp    $0x3f,%rax
jb     11c7 <SV_DemoMap_f+0x57>
lea    0xe5e(%rip),%rdi
call   1070 <Com_Printf@plt>
jmp    120e <SV_DemoMap_f+0x9e>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x1,%edi
call   1080 <Cmd_Argv@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1090 <Q_strncpyz@plt>
lea    -0x40(%rbp),%rdi
mov    $0x40,%esi
lea    0xe42(%rip),%rdx
call   1060 <COM_DefaultExtension@plt>
lea    -0x40(%rbp),%rsi
mov    $0x1,%edi
xor    %edx,%edx
call   1030 <SV_Map@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SV_DemoMap_f>:
push   %rbx
sub    $0x40,%rsp
xor    %eax,%eax
call   1040 <Cmd_Argc@plt>
cmp    $0x2,%eax
jne    11a0 <SV_DemoMap_f+0x30>
mov    $0x1,%edi
call   1080 <Cmd_Argv@plt>
mov    %eax,%edi
call   1050 <strlen@plt>
cmp    $0x3f,%eax
jb     11b1 <SV_DemoMap_f+0x41>
lea    0xe7d(%rip),%rdi
jmp    11a7 <SV_DemoMap_f+0x37>
lea    0xe59(%rip),%rdi
add    $0x40,%rsp
pop    %rbx
jmp    1070 <Com_Printf@plt>
mov    $0x1,%edi
call   1080 <Cmd_Argv@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1090 <Q_strncpyz@plt>
lea    0xe67(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1060 <COM_DefaultExtension@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <SV_Map@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"USAGE: demomap <demoname>\0A\00"
@.str.1 = [32 x i8] c"Demomap: Demo name is too long\0A\00"
@.str.2 = [5 x i8] c".dm2\00"
define void @SV_DemoMap_f() {
%1 = alloca [64 x i8]
%2 = call i32 (...) @Cmd_Argc()
%3 = icmp ne i32 %2, 2
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @Com_Printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %21
6: ; preds = %0
%7 = call i32 @Cmd_Argv(i32 1)
%8 = call i32 @strlen(i32 %7)
%9 = sext i32 %8 to i64
%10 = icmp uge i64 %9, 63
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 @Com_Printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %21
13: ; preds = %6
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%15 = call i32 @Cmd_Argv(i32 1)
%16 = call i32 @Q_strncpyz(i8* %14, i32 %15, i32 64)
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%18 = call i32 @COM_DefaultExtension(i8* %17, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%20 = call i32 @SV_Map(i32 1, i8* %19, i32 0)
br label %21
21: ; preds = %13, %11, %4
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"USAGE: demomap <demoname>\0A\00"
@.str.1 = [32 x i8] c"Demomap: Demo name is too long\0A\00"
@.str.2 = [5 x i8] c".dm2\00"
define void @SV_DemoMap_f() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @Cmd_Argc()
%4 = icmp eq i32 %3, 2
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %18
7: ; preds = %0
%8 = tail call i32 @Cmd_Argv(i32 1)
%9 = tail call i32 @strlen(i32 %8)
%10 = icmp ugt i32 %9, 62
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @Com_Printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %18
13: ; preds = %7
%14 = tail call i32 @Cmd_Argv(i32 1)
%15 = call i32 @Q_strncpyz(i8* %2, i32 %14, i32 64)
%16 = call i32 @COM_DefaultExtension(i8* %2, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @SV_Map(i32 1, i8* %2, i32 0)
br label %18
18: ; preds = %13, %11, %5
ret void
}