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

/* 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*/ Com_WriteConfigToFile(char *);
int /*<<< orphan*/ Q_strncpyz(char *, int /*<<< orphan*/, int);
void Com_WriteConfig_f(void) {
  char filename[64];
  if (Cmd_Argc() != 2) {
    Com_Printf("Usage: writeconfig <filename>\n");
    return;
  }
  Q_strncpyz(filename, Cmd_Argv(1), sizeof(filename));
  COM_DefaultExtension(filename, sizeof(filename), ".cfg");
  Com_Printf("Writing %s.\n", filename);
  Com_WriteConfigToFile(filename);
}


x86 assembly (clang, -O0):
<Com_WriteConfig_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    $0x0,%al
call   1030 <Cmd_Argc@plt>
cmp    $0x2,%eax
je     118b <Com_WriteConfig_f+0x2b>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <Com_Printf@plt>
jmp    11dd <Com_WriteConfig_f+0x7d>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x1,%edi
call   1060 <Cmd_Argv@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1080 <Q_strncpyz@plt>
lea    -0x40(%rbp),%rdi
mov    $0x40,%esi
lea    0xe62(%rip),%rdx
call   1040 <COM_DefaultExtension@plt>
lea    -0x40(%rbp),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1050 <Com_Printf@plt>
lea    -0x40(%rbp),%rdi
call   1070 <Com_WriteConfigToFile@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Com_WriteConfig_f>:
push   %rbx
sub    $0x40,%rsp
xor    %eax,%eax
call   1030 <Cmd_Argc@plt>
cmp    $0x2,%eax
jne    11c0 <Com_WriteConfig_f+0x60>
mov    $0x1,%edi
call   1060 <Cmd_Argv@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1080 <Q_strncpyz@plt>
lea    0xe8b(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1040 <COM_DefaultExtension@plt>
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <Com_Printf@plt>
mov    %rbx,%rdi
call   1070 <Com_WriteConfigToFile@plt>
add    $0x40,%rsp
pop    %rbx
ret
lea    0xe39(%rip),%rdi
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
jmp    1050 <Com_Printf@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Usage: writeconfig <filename>\0A\00"
@.str.1 = [5 x i8] c".cfg\00"
@.str.2 = [13 x i8] c"Writing %s.\0A\00"
define void @Com_WriteConfig_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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %16
6: ; preds = %0
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%8 = call i32 @Cmd_Argv(i32 1)
%9 = call i32 @Q_strncpyz(i8* %7, i32 %8, i32 64)
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%11 = call i32 @COM_DefaultExtension(i8* %10, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%13 = call i32 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%15 = call i32 @Com_WriteConfigToFile(i8* %14)
br label %16
16: ; preds = %6, %4
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"Usage: writeconfig <filename>\0A\00"
@.str.1 = [5 x i8] c".cfg\00"
@.str.2 = [13 x i8] c"Writing %s.\0A\00"
define void @Com_WriteConfig_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 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %0
%8 = tail call i32 @Cmd_Argv(i32 1)
%9 = call i32 @Q_strncpyz(i8* %2, i32 %8, i32 64)
%10 = call i32 @COM_DefaultExtension(i8* %2, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @Com_Printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%12 = call i32 @Com_WriteConfigToFile(i8* %2)
br label %13
13: ; preds = %7, %5
ret void
}