#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 sanitize(char *string) {
  int i;
  for (i = 0; i < strlen(string); i++) {
    switch (string[i]) {
    case '<':
      string[i] = '[';
      break;
    case '>':
      string[i] = ']';
      break;
    case '|':
      string[i] = '_';
      break;
    case '/':
      string[i] = '-';
      break;
    case '\\':
      string[i] = '-';
      break;
    case '*':
      string[i] = '_';
      break;
    case '?':
      string[i] = '_';
      break;
    case ':':
      string[i] = ';';
      break;
    case '"':
      string[i] = '-';
      break;
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<sanitize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    1295 <sanitize+0x185>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
sub    $0x22,%eax
je     126c <sanitize+0x15c>
jmp    115c <sanitize+0x4c>
mov    -0x14(%rbp),%eax
sub    $0x2a,%eax
je     1239 <sanitize+0x129>
jmp    116d <sanitize+0x5d>
mov    -0x14(%rbp),%eax
sub    $0x2f,%eax
je     1217 <sanitize+0x107>
jmp    117e <sanitize+0x6e>
mov    -0x14(%rbp),%eax
sub    $0x3a,%eax
je     125b <sanitize+0x14b>
jmp    118f <sanitize+0x7f>
mov    -0x14(%rbp),%eax
sub    $0x3c,%eax
je     11e4 <sanitize+0xd4>
jmp    11a0 <sanitize+0x90>
mov    -0x14(%rbp),%eax
sub    $0x3e,%eax
je     11f5 <sanitize+0xe5>
jmp    11b1 <sanitize+0xa1>
mov    -0x14(%rbp),%eax
sub    $0x3f,%eax
je     124a <sanitize+0x13a>
jmp    11c2 <sanitize+0xb2>
mov    -0x14(%rbp),%eax
sub    $0x5c,%eax
je     1228 <sanitize+0x118>
jmp    11d3 <sanitize+0xc3>
mov    -0x14(%rbp),%eax
sub    $0x7c,%eax
je     1206 <sanitize+0xf6>
jmp    127d <sanitize+0x16d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x5b,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x5d,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x2d,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x2d,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x3b,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x2d,(%rax,%rcx,1)
jmp    1282 <sanitize+0x172>
jmp    1282 <sanitize+0x172>
jmp    1287 <sanitize+0x177>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <sanitize+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sanitize>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    116e <sanitize+0x5e>
xor    %ebx,%ebx
lea    0xed6(%rip),%r15
jmp    114a <sanitize+0x3a>
cmp    $0x7c,%eax
jne    1137 <sanitize+0x27>
mov    $0x5f,%al
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    116e <sanitize+0x5e>
movsbl (%r14,%rbx,1),%eax
lea    -0x22(%rax),%ecx
cmp    $0x3a,%ecx
ja     112c <sanitize+0x1c>
mov    $0x5b,%al
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mov    $0x2d,%al
jmp    1133 <sanitize+0x23>
mov    $0x3b,%al
jmp    1133 <sanitize+0x23>
mov    $0x5d,%al
jmp    1133 <sanitize+0x23>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @sanitize(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %63, %1
%5 = load i32, i32* %3
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = icmp slt i32 %5, %7
br i1 %8, label %9, label %66
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %61 [
i32 60, label %16
i32 62, label %21
i32 124, label %26
i32 47, label %31
i32 92, label %36
i32 42, label %41
i32 63, label %46
i32 58, label %51
i32 34, label %56
]
16: ; preds = %9
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 91, i8* %20
br label %62
21: ; preds = %9
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 93, i8* %25
br label %62
26: ; preds = %9
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 95, i8* %30
br label %62
31: ; preds = %9
%32 = load i8*, i8** %2
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 45, i8* %35
br label %62
36: ; preds = %9
%37 = load i8*, i8** %2
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 45, i8* %40
br label %62
41: ; preds = %9
%42 = load i8*, i8** %2
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 95, i8* %45
br label %62
46: ; preds = %9
%47 = load i8*, i8** %2
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 95, i8* %50
br label %62
51: ; preds = %9
%52 = load i8*, i8** %2
%53 = load i32, i32* %3
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 59, i8* %55
br label %62
56: ; preds = %9
%57 = load i8*, i8** %2
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
store i8 45, i8* %60
br label %62
61: ; preds = %9
br label %62
62: ; preds = %61, %56, %51, %46, %41, %36, %31, %26, %21, %16
br label %63
63: ; preds = %62
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
store i32 %65, i32* %3
br label %4
66: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @sanitize(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %24
4: ; preds = %1, %19
%5 = phi i64 [ %20, %19 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %19 [
i32 60, label %17
i32 62, label %9
i32 124, label %10
i32 47, label %11
i32 92, label %12
i32 42, label %13
i32 63, label %14
i32 58, label %15
i32 34, label %16
]
9: ; preds = %4
br label %17
10: ; preds = %4
br label %17
11: ; preds = %4
br label %17
12: ; preds = %4
br label %17
13: ; preds = %4
br label %17
14: ; preds = %4
br label %17
15: ; preds = %4
br label %17
16: ; preds = %4
br label %17
17: ; preds = %4, %16, %15, %14, %13, %12, %11, %10, %9
%18 = phi i8 [ 93, %9 ], [ 95, %10 ], [ 45, %11 ], [ 45, %12 ], [ 95, %13 ], [ 95, %14 ], [ 59, %15 ], [ 45, %16 ], [ 91, %4 ]
store i8 %18, i8* %6
br label %19
19: ; preds = %17, %4
%20 = add nuw nsw i64 %5, 1
%21 = tail call i32 @strlen(i8* %0)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %4, label %24
24: ; preds = %19, %1
ret void
}