void CopyPlayerNameIntoFileName(char **dest, char *src) {
  while (*src != '\000' && *src != ',') {
    if (*src == ' ') {
      *(*dest)++ = '_';
      src++;
    } else {
      *(*dest)++ = *src++;
    }
  }
}


x86 assembly (clang, -O0):
<CopyPlayerNameIntoFileName>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1131 <CopyPlayerNameIntoFileName+0x31>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1141 <CopyPlayerNameIntoFileName+0x41>
jmp    119f <CopyPlayerNameIntoFileName+0x9f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1176 <CopyPlayerNameIntoFileName+0x76>
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movb   $0x5f,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    119a <CopyPlayerNameIntoFileName+0x9a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rdx
mov    (%rdx),%rax
mov    %rax,%rsi
add    $0x1,%rsi
mov    %rsi,(%rdx)
mov    %cl,(%rax)
jmp    110c <CopyPlayerNameIntoFileName+0xc>
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyPlayerNameIntoFileName>:
jmp    1121 <CopyPlayerNameIntoFileName+0x21>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rdi),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rdi)
movb   $0x5f,(%rax)
add    $0x1,%rsi
movzbl (%rsi),%eax
cmp    $0x20,%al
je     1110 <CopyPlayerNameIntoFileName+0x10>
test   %al,%al
je     1142 <CopyPlayerNameIntoFileName+0x42>
cmp    $0x2c,%al
je     1142 <CopyPlayerNameIntoFileName+0x42>
mov    (%rdi),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%rdi)
mov    %al,(%rcx)
add    $0x1,%rsi
jmp    1121 <CopyPlayerNameIntoFileName+0x21>
ret

LLVM IR (-O0):
define void @CopyPlayerNameIntoFileName(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %35, %2
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 44
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %36
17: ; preds = %15
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 32
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i8**, i8*** %3
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %23
store i8 95, i8* %24
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
br label %35
28: ; preds = %17
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
%31 = load i8, i8* %29
%32 = load i8**, i8*** %3
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %32
store i8 %31, i8* %33
br label %35
35: ; preds = %28, %22
br label %5
36: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @CopyPlayerNameIntoFileName(i8** nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %12, %2
%4 = phi i8* [ %1, %2 ], [ %13, %12 ]
%5 = load i8, i8* %4
switch i8 %5, label %9 [
i8 0, label %14
i8 44, label %14
i8 32, label %6
]
6: ; preds = %3
%7 = load i8*, i8** %0
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %8, i8** %0
store i8 95, i8* %7
br label %12
9: ; preds = %3
%10 = load i8*, i8** %0
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %11, i8** %0
store i8 %5, i8* %10
br label %12
12: ; preds = %9, %6
%13 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
14: ; preds = %3, %3
ret void
}