#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 strlen(char *);
void FilterFilename(char *pszDest, char *pszSrc) {
  int iLoop, iToken, iNumTokens;
  char *pcToken;
  pcToken = " .\\/~`!@#$%^&*()-+=[]{}|;:"
            "'<>,/?";
  iNumTokens = strlen(pcToken);
  for (iLoop = 0; iLoop < (strlen(pszSrc) + 1); iLoop++) {
    for (iToken = 0; iToken < iNumTokens; iToken++) {
      if (pszSrc[iLoop] == pcToken[iToken]) {
        pszDest[iLoop] = '_';
        break;
      }
    }
    if (iToken == iNumTokens) {
      pszDest[iLoop] = pszSrc[iLoop];
    }
  }
}


x86 assembly (clang, -O0):
<FilterFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11e9 <FilterFilename+0xd9>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b4 <FilterFilename+0xa4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x28(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11a1 <FilterFilename+0x91>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
jmp    11b4 <FilterFilename+0xa4>
jmp    11a6 <FilterFilename+0x96>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <FilterFilename+0x54>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11d6 <FilterFilename+0xc6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11db <FilterFilename+0xcb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <FilterFilename+0x2e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FilterFilename>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,(%rsp)
lea    0xed7(%rip),%r13
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
js     11bf <FilterFilename+0xaf>
mov    %r12d,%ebp
xor    %ebx,%ebx
jmp    1171 <FilterFilename+0x61>
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,1),%al
mov    (%rsp),%rcx
mov    %al,(%rcx,%rbx,1)
lea    0x1(%rbx),%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
mov    %r14,%rbx
jge    11bf <FilterFilename+0xaf>
mov    $0x0,%eax
test   %r12d,%r12d
jle    11b8 <FilterFilename+0xa8>
mov    (%r15,%rbx,1),%cl
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    (%rax,%r13,1),%cl
je     11b0 <FilterFilename+0xa0>
add    $0x1,%rax
cmp    %rax,%rbp
jne    1190 <FilterFilename+0x80>
jmp    1150 <FilterFilename+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rcx
movb   $0x5f,(%rcx,%rbx,1)
cmp    %r12d,%eax
je     1150 <FilterFilename+0x40>
jmp    115b <FilterFilename+0x4b>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c" .\\/~`!@#$%^&*()-+=[]{}|;:'<>,/?\00"
define void @FilterFilename(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = load i8*, i8** %8
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %7
store i32 0, i32* %5
br label %11
11: ; preds = %60, %2
%12 = load i32, i32* %5
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = add nsw i32 %14, 1
%16 = icmp slt i32 %12, %15
br i1 %16, label %17, label %63
17: ; preds = %11
store i32 0, i32* %6
br label %18
18: ; preds = %42, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %45
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i8*, i8** %8
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %28, %34
br i1 %35, label %36, label %41
36: ; preds = %22
%37 = load i8*, i8** %3
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 95, i8* %40
br label %45
41: ; preds = %22
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %18
45: ; preds = %36, %18
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %59
49: ; preds = %45
%50 = load i8*, i8** %4
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = load i8*, i8** %3
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 %54, i8* %58
br label %59
59: ; preds = %49, %45
br label %60
60: ; preds = %59
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
br label %11
63: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c" .\\/~`!@#$%^&*()-+=[]{}|;:'<>,/?\00"
define void @FilterFilename(i8* nocapture writeonly %0, i8* %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %1)
%5 = icmp slt i32 %4, 0
br i1 %5, label %37, label %6
6: ; preds = %2
%7 = icmp sgt i32 %3, 0
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %6, %32
%10 = phi i64 [ 0, %6 ], [ %33, %32 ]
br i1 %7, label %11, label %25
11: ; preds = %9
%12 = getelementptr inbounds i8, i8* %1, i64 %10
%13 = load i8, i8* %12
br label %14
14: ; preds = %11, %22
%15 = phi i64 [ 0, %11 ], [ %23, %22 ]
%16 = getelementptr inbounds [33 x i8], [33 x i8]* @.str, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %13, %17
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = trunc i64 %15 to i32
%21 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 95, i8* %21
br label %25
22: ; preds = %14
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %28, label %14
25: ; preds = %9, %19
%26 = phi i32 [ %20, %19 ], [ 0, %9 ]
%27 = icmp eq i32 %26, %3
br i1 %27, label %28, label %32
28: ; preds = %22, %25
%29 = getelementptr inbounds i8, i8* %1, i64 %10
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 %30, i8* %31
br label %32
32: ; preds = %25, %28
%33 = add nuw nsw i64 %10, 1
%34 = tail call i32 @strlen(i8* %1)
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %10, %35
br i1 %36, label %9, label %37
37: ; preds = %32, %2
ret void
}