void string_replace_backslash_codes(const char *a, char *b) {
  while (*a) {
    if (*a == '\\') {
      a++;
      char c;
      switch (*a) {
      case 'a':
        c = 7;
        break;
      case 'b':
        c = 8;
        break;
      case 't':
        c = 9;
        break;
      case 'n':
        c = 10;
        break;
      case 'v':
        c = 11;
        break;
      case 'f':
        c = 12;
        break;
      case 'r':
        c = 13;
        break;
      default:
        c = *a;
        break;
      }
      *b++ = c;
      a++;
    } else {
      *b++ = *a++;
    }
  }
  *b = 0;
}


x86 assembly (clang, -O0):
<string_replace_backslash_codes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11f6 <string_replace_backslash_codes+0xf6>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11cf <string_replace_backslash_codes+0xcf>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x15,%eax
ja     11a1 <string_replace_backslash_codes+0xa1>
mov    -0x20(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x7,-0x11(%rbp)
jmp    11aa <string_replace_backslash_codes+0xaa>
movb   $0x8,-0x11(%rbp)
jmp    11aa <string_replace_backslash_codes+0xaa>
movb   $0x9,-0x11(%rbp)
jmp    11aa <string_replace_backslash_codes+0xaa>
movb   $0xa,-0x11(%rbp)
jmp    11aa <string_replace_backslash_codes+0xaa>
movb   $0xb,-0x11(%rbp)
jmp    11aa <string_replace_backslash_codes+0xaa>
movb   $0xc,-0x11(%rbp)
jmp    11aa <string_replace_backslash_codes+0xaa>
movb   $0xd,-0x11(%rbp)
jmp    11aa <string_replace_backslash_codes+0xaa>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11f1 <string_replace_backslash_codes+0xf1>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    110c <string_replace_backslash_codes+0xc>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_replace_backslash_codes>:
lea    0xef9(%rip),%r8
jmp    111a <string_replace_backslash_codes+0x1a>
mov    %edx,%ecx
nopl   0x0(%rax,%rax,1)
mov    %cl,(%rsi)
add    $0x2,%rdi
add    $0x1,%rsi
movzbl (%rdi),%ecx
cmp    $0x5c,%cl
je     1140 <string_replace_backslash_codes+0x40>
test   %cl,%cl
je     116f <string_replace_backslash_codes+0x6f>
add    $0x1,%rdi
mov    %cl,(%rsi)
add    $0x1,%rsi
jmp    111a <string_replace_backslash_codes+0x1a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl 0x1(%rdi),%edx
lea    -0x61(%rdx),%eax
cmp    $0x15,%eax
ja     1109 <string_replace_backslash_codes+0x9>
mov    $0x7,%cl
movslq (%r8,%rax,4),%rax
add    %r8,%rax
jmp    *%rax
mov    $0x8,%cl
jmp    1110 <string_replace_backslash_codes+0x10>
mov    $0x9,%cl
jmp    1110 <string_replace_backslash_codes+0x10>
mov    $0xc,%cl
jmp    1110 <string_replace_backslash_codes+0x10>
mov    $0xa,%cl
jmp    1110 <string_replace_backslash_codes+0x10>
mov    $0xd,%cl
jmp    1110 <string_replace_backslash_codes+0x10>
mov    $0xb,%cl
jmp    1110 <string_replace_backslash_codes+0x10>
movb   $0x0,(%rsi)
ret

LLVM IR (-O0):
define void @string_replace_backslash_codes(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %43, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %44
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 92
br i1 %14, label %15, label %37
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %28 [
i32 97, label %21
i32 98, label %22
i32 116, label %23
i32 110, label %24
i32 118, label %25
i32 102, label %26
i32 114, label %27
]
21: ; preds = %15
store i8 7, i8* %5
br label %31
22: ; preds = %15
store i8 8, i8* %5
br label %31
23: ; preds = %15
store i8 9, i8* %5
br label %31
24: ; preds = %15
store i8 10, i8* %5
br label %31
25: ; preds = %15
store i8 11, i8* %5
br label %31
26: ; preds = %15
store i8 12, i8* %5
br label %31
27: ; preds = %15
store i8 13, i8* %5
br label %31
28: ; preds = %15
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
store i8 %30, i8* %5
br label %31
31: ; preds = %28, %27, %26, %25, %24, %23, %22, %21
%32 = load i8, i8* %5
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %4
store i8 %32, i8* %33
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %3
br label %43
37: ; preds = %10
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
%40 = load i8, i8* %38
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %4
store i8 %40, i8* %41
br label %43
43: ; preds = %37, %31
br label %6
44: ; preds = %6
%45 = load i8*, i8** %4
store i8 0, i8* %45
ret void
}

LLVM IR (-O2):
define void @string_replace_backslash_codes(i8* nocapture %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %23, %2
%4 = phi i8* [ %0, %2 ], [ %24, %23 ]
%5 = phi i8* [ %1, %2 ], [ %25, %23 ]
%6 = load i8, i8* %4
switch i8 %6, label %21 [
i8 0, label %26
i8 92, label %7
]
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %17 [
i32 97, label %18
i32 98, label %11
i32 116, label %12
i32 110, label %13
i32 118, label %14
i32 102, label %15
i32 114, label %16
]
11: ; preds = %7
br label %18
12: ; preds = %7
br label %18
13: ; preds = %7
br label %18
14: ; preds = %7
br label %18
15: ; preds = %7
br label %18
16: ; preds = %7
br label %18
17: ; preds = %7
br label %18
18: ; preds = %7, %17, %16, %15, %14, %13, %12, %11
%19 = phi i8 [ %9, %17 ], [ 13, %16 ], [ 12, %15 ], [ 11, %14 ], [ 10, %13 ], [ 9, %12 ], [ 8, %11 ], [ 7, %7 ]
store i8 %19, i8* %5
%20 = getelementptr inbounds i8, i8* %4, i64 2
br label %23
21: ; preds = %3
%22 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %6, i8* %5
br label %23
23: ; preds = %21, %18
%24 = phi i8* [ %20, %18 ], [ %22, %21 ]
%25 = getelementptr inbounds i8, i8* %5, i64 1
br label %3
26: ; preds = %3
store i8 0, i8* %5
ret void
}