#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*/ Com_DPrintf(char *, char const *, ...);
int /*<<< orphan*/ Com_Printf(char *, char const *);
int /*<<< orphan*/ FS_FCloseFile(int);
int FS_FOpenFile(char const *, int *, int);
int /*<<< orphan*/ FS_Write(char const *, int /*<<< orphan*/, int);
char *mm_passwordFilename(char const *);
int /*<<< orphan*/ strlen(char const *);
void MM_PasswordWrite(const char *user, const char *password) {
  const char *filename;
  int filenum;
  Com_DPrintf("MM_PasswordWrite: %s %s\n", user, password);
  filename = mm_passwordFilename(user);
  if (FS_FOpenFile(filename, &filenum, 1) == -1) {
    Com_Printf("MM_PasswordWrite: Failed to open %s for writing\n", filename);
    return;
  }
  FS_Write(password, strlen(password), filenum);
  FS_FCloseFile(filenum);
  Com_DPrintf("MM_PasswordWrite: wrote %s\n", filename);
}


x86 assembly (clang, -O0):
<MM_PasswordWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1080 <Com_DPrintf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <mm_passwordFilename@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x1,%edx
call   1030 <FS_FOpenFile@plt>
cmp    $0xffffffff,%eax
jne    11d3 <MM_PasswordWrite+0x63>
mov    -0x18(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1060 <Com_Printf@plt>
jmp    120c <MM_PasswordWrite+0x9c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
call   1070 <FS_Write@plt>
mov    -0x1c(%rbp),%edi
call   1090 <FS_FCloseFile@plt>
mov    -0x18(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1080 <Com_DPrintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MM_PasswordWrite>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe7a(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <Com_DPrintf@plt>
mov    %rbx,%rdi
call   1050 <mm_passwordFilename@plt>
mov    %rax,%r14
lea    0xc(%rsp),%rsi
mov    %rax,%rdi
mov    $0x1,%edx
call   1030 <FS_FOpenFile@plt>
cmp    $0xffffffff,%eax
je     11e7 <MM_PasswordWrite+0x77>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    %eax,%esi
call   1070 <FS_Write@plt>
mov    0xc(%rsp),%edi
call   1090 <FS_FCloseFile@plt>
lea    0xe6f(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <Com_DPrintf@plt>
jmp    11f6 <MM_PasswordWrite+0x86>
lea    0xe2b(%rip),%rdi
mov    %r14,%rsi
call   1060 <Com_Printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"MM_PasswordWrite: %s %s\0A\00"
@.str.1 = [49 x i8] c"MM_PasswordWrite: Failed to open %s for writing\0A\00"
@.str.2 = [28 x i8] c"MM_PasswordWrite: wrote %s\0A\00"
define void @MM_PasswordWrite(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i32 (i8*, i8*, ...) @Com_DPrintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%10 = load i8*, i8** %3
%11 = call i8* @mm_passwordFilename(i8* %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = call i32 @FS_FOpenFile(i8* %12, i32* %6, i32 1)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = call i32 @Com_Printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %28
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = load i8*, i8** %4
%21 = call i32 @strlen(i8* %20)
%22 = load i32, i32* %6
%23 = call i32 @FS_Write(i8* %19, i32 %21, i32 %22)
%24 = load i32, i32* %6
%25 = call i32 @FS_FCloseFile(i32 %24)
%26 = load i8*, i8** %5
%27 = call i32 (i8*, i8*, ...) @Com_DPrintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"MM_PasswordWrite: %s %s\0A\00"
@.str.1 = [49 x i8] c"MM_PasswordWrite: Failed to open %s for writing\0A\00"
@.str.2 = [28 x i8] c"MM_PasswordWrite: wrote %s\0A\00"
define void @MM_PasswordWrite(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, i8*, ...) @Com_DPrintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%6 = tail call i8* @mm_passwordFilename(i8* %0)
%7 = call i32 @FS_FOpenFile(i8* %6, i32* %3, i32 1)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @Com_Printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %18
11: ; preds = %2
%12 = call i32 @strlen(i8* %1)
%13 = load i32, i32* %3
%14 = call i32 @FS_Write(i8* %1, i32 %12, i32 %13)
%15 = load i32, i32* %3
%16 = call i32 @FS_FCloseFile(i32 %15)
%17 = call i32 (i8*, i8*, ...) @Com_DPrintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %18
18: ; preds = %11, %9
ret void
}