#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 int_index(char *, char);
char *replace_special_characters(char *str) {
  char *read = str;
  char *write = str;
  int i;
  if (str == NULL)
    return NULL;
  for (write = str; *read != '\0'; read++, write++) {
    if (*read == '\\' && read[1] != '\0' &&
        (i = int_index("abfnrtv'\"\\", read[1])) != -1) {
      *write = "\a\b\f\n\r\t\v'\"\\"[i];
      read++;
    } else if (read != write)
      *write = *read;
  }
  *write = '\0';
  return str;
}


x86 assembly (clang, -O0):
<replace_special_characters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1144 <replace_special_characters+0x34>
movq   $0x0,-0x8(%rbp)
jmp    1212 <replace_special_characters+0x102>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1203 <replace_special_characters+0xf3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11c2 <replace_special_characters+0xb2>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11c2 <replace_special_characters+0xb2>
mov    -0x18(%rbp),%rax
lea    0xe78(%rip),%rdi
movsbl 0x1(%rax),%esi
call   1030 <int_index@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     11c2 <replace_special_characters+0xb2>
movslq -0x24(%rbp),%rcx
lea    0xe63(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11e1 <replace_special_characters+0xd1>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     11dc <replace_special_characters+0xcc>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
jmp    11e1 <replace_special_characters+0xd1>
jmp    11e6 <replace_special_characters+0xd6>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114c <replace_special_characters+0x3c>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<replace_special_characters>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     119f <replace_special_characters+0x8f>
lea    0xed8(%rip),%r12
lea    0xedc(%rip),%r15
mov    %r14,%rbx
mov    %r14,%r13
jmp    1156 <replace_special_characters+0x46>
mov    %rbx,%rcx
add    $0x1,%rcx
movslq %eax,%rbx
add    %r15,%rbx
movzbl (%rbx),%eax
mov    %al,0x0(%r13)
mov    %rcx,%rbx
add    $0x1,%rbx
add    $0x1,%r13
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     1170 <replace_special_characters+0x60>
test   %al,%al
jne    1190 <replace_special_characters+0x80>
jmp    119a <replace_special_characters+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x1(%rbx),%eax
test   %al,%al
je     1190 <replace_special_characters+0x80>
movsbl %al,%esi
mov    %r12,%rdi
call   1030 <int_index@plt>
cmp    $0xffffffff,%eax
jne    1137 <replace_special_characters+0x27>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rcx
cmp    %rbx,%r13
jne    1144 <replace_special_characters+0x34>
jmp    114e <replace_special_characters+0x3e>
movb   $0x0,0x0(%r13)
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"abfnrtv'\22\\\00"
@.str.1 = [11 x i8] c"\07\08\0C\0A\0D\09\0B'\22\\\00"
define i8* @replace_special_characters(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
store i8* %7, i8** %4
%8 = load i8*, i8** %3
store i8* %8, i8** %5
%9 = load i8*, i8** %3
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* null, i8** %2
br label %62
12: ; preds = %1
%13 = load i8*, i8** %3
store i8* %13, i8** %5
br label %14
14: ; preds = %54, %12
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %59
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 92
br i1 %23, label %24, label %44
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %44
30: ; preds = %24
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = call i32 @int_index(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %33)
store i32 %34, i32* %6
%35 = icmp ne i32 %34, -1
br i1 %35, label %36, label %44
36: ; preds = %30
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [11 x i8], [11 x i8]* @.str.1, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** %5
store i8 %40, i8* %41
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %4
br label %53
44: ; preds = %30, %24, %19
%45 = load i8*, i8** %4
%46 = load i8*, i8** %5
%47 = icmp ne i8* %45, %46
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = load i8*, i8** %4
%50 = load i8, i8* %49
%51 = load i8*, i8** %5
store i8 %50, i8* %51
br label %52
52: ; preds = %48, %44
br label %53
53: ; preds = %52, %36
br label %54
54: ; preds = %53
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %4
%57 = load i8*, i8** %5
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %5
br label %14
59: ; preds = %14
%60 = load i8*, i8** %5
store i8 0, i8* %60
%61 = load i8*, i8** %3
store i8* %61, i8** %2
br label %62
62: ; preds = %59, %11
%63 = load i8*, i8** %2
ret i8* %63
}

LLVM IR (-O2):
@.str = [11 x i8] c"abfnrtv'\22\\\00"
@.str.1 = [11 x i8] c"\07\08\0C\0A\0D\09\0B'\22\\\00"
define i8* @replace_special_characters(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %28, label %3
3: ; preds = %1, %23
%4 = phi i8* [ %25, %23 ], [ %0, %1 ]
%5 = phi i8* [ %26, %23 ], [ %0, %1 ]
%6 = load i8, i8* %4
switch i8 %6, label %17 [
i8 0, label %27
i8 92, label %7
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %7
%12 = tail call i32 @int_index(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %9)
%13 = icmp eq i32 %12, -1
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds [11 x i8], [11 x i8]* @.str.1, i64 0, i64 %15
br label %19
17: ; preds = %3, %11, %7
%18 = icmp eq i8* %4, %5
br i1 %18, label %23, label %19
19: ; preds = %17, %14
%20 = phi i8* [ %16, %14 ], [ %4, %17 ]
%21 = phi i8* [ %8, %14 ], [ %4, %17 ]
%22 = load i8, i8* %20
store i8 %22, i8* %5
br label %23
23: ; preds = %19, %17
%24 = phi i8* [ %4, %17 ], [ %21, %19 ]
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
27: ; preds = %3
store i8 0, i8* %5
br label %28
28: ; preds = %1, %27
ret i8* %0
}