void unescape(char *str) {
  char *wptr = str;
  char *rptr = str;
  while (*rptr) {
    if (*rptr != '\\') {
      *wptr++ = *rptr++;
      continue;
    }
    rptr++;
    switch (*rptr) {
    case '\\':
      *wptr++ = '\\';
      break;
    case '\"':
      *wptr++ = '\"';
      break;
    case '\'':
      *wptr++ = '\'';
      break;
    case 't':
      *wptr++ = '\t';
      break;
    case 'v':
      *wptr++ = '\v';
      break;
    case 'n':
      *wptr++ = '\n';
      break;
    case 'r':
      *wptr++ = '\r';
      break;
    default:
      *wptr++ = *rptr;
      break;
    }
    rptr++;
  }
  *wptr = 0;
}


x86 assembly (clang, -O0):
<unescape>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     12af <unescape+0x1af>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     115c <unescape+0x5c>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1118 <unescape+0x18>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x22,%eax
je     11fd <unescape+0xfd>
jmp    1180 <unescape+0x80>
mov    -0x1c(%rbp),%eax
sub    $0x27,%eax
je     1214 <unescape+0x114>
jmp    1191 <unescape+0x91>
mov    -0x1c(%rbp),%eax
sub    $0x5c,%eax
je     11e6 <unescape+0xe6>
jmp    11a2 <unescape+0xa2>
mov    -0x1c(%rbp),%eax
sub    $0x6e,%eax
je     1259 <unescape+0x159>
jmp    11b3 <unescape+0xb3>
mov    -0x1c(%rbp),%eax
sub    $0x72,%eax
je     1270 <unescape+0x170>
jmp    11c4 <unescape+0xc4>
mov    -0x1c(%rbp),%eax
sub    $0x74,%eax
je     122b <unescape+0x12b>
jmp    11d5 <unescape+0xd5>
mov    -0x1c(%rbp),%eax
sub    $0x76,%eax
je     1242 <unescape+0x142>
jmp    1287 <unescape+0x187>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x5c,(%rax)
jmp    129e <unescape+0x19e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x22,(%rax)
jmp    129e <unescape+0x19e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x27,(%rax)
jmp    129e <unescape+0x19e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x9,(%rax)
jmp    129e <unescape+0x19e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0xb,(%rax)
jmp    129e <unescape+0x19e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0xa,(%rax)
jmp    129e <unescape+0x19e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0xd,(%rax)
jmp    129e <unescape+0x19e>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1118 <unescape+0x18>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<unescape>:
lea    0xef9(%rip),%r8
mov    %rdi,%rcx
jmp    111a <unescape+0x1a>
mov    %eax,%edx
xchg   %ax,%ax
mov    %dl,(%rdi)
add    $0x2,%rcx
add    $0x1,%rdi
movzbl (%rcx),%eax
cmp    $0x5c,%al
je     1140 <unescape+0x40>
test   %al,%al
je     117c <unescape+0x7c>
add    $0x1,%rcx
mov    %al,(%rdi)
add    $0x1,%rdi
jmp    111a <unescape+0x1a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rcx),%eax
movsbl %al,%edx
lea    -0x5c(%rdx),%esi
cmp    $0x1a,%esi
ja     115e <unescape+0x5e>
mov    $0x5c,%dl
movslq (%r8,%rsi,4),%rsi
add    %r8,%rsi
jmp    *%rsi
mov    $0xa,%dl
jmp    1110 <unescape+0x10>
cmp    $0x27,%edx
je     1178 <unescape+0x78>
cmp    $0x22,%edx
jne    110c <unescape+0xc>
mov    $0x22,%dl
jmp    1110 <unescape+0x10>
mov    $0xd,%dl
jmp    1110 <unescape+0x10>
mov    $0x9,%dl
jmp    1110 <unescape+0x10>
mov    $0xb,%dl
jmp    1110 <unescape+0x10>
mov    $0x27,%dl
jmp    1110 <unescape+0x10>
movb   $0x0,(%rdi)
ret

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

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