char *scan_quote(char *dst, char *src) {
  while (*src != '"' && *src != '\0') {
    if (*src == '\\') {
      switch (*++src) {
      case '\0':
        *dst++ = '\0';
        break;
      case '\\':
        *dst++ = '\\';
        src++;
        break;
      case 't':
        *dst++ = '\t';
        src++;
        break;
      case 'r':
        *dst++ = '\r';
        src++;
        break;
      case 'n':
        *dst++ = '\n';
        src++;
        break;
      default:
        *dst++ = *src;
        src++;
        break;
      }
    } else {
      *dst++ = *src++;
    }
  }
  if (*src == '"')
    src++;
  *dst = '\0';
  return src;
}


x86 assembly (clang, -O0):
<scan_quote>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x22,%ecx
mov    %al,-0x11(%rbp)
je     1131 <scan_quote+0x31>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1141 <scan_quote+0x41>
jmp    12aa <scan_quote+0x1aa>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1283 <scan_quote+0x183>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     11b8 <scan_quote+0xb8>
jmp    1174 <scan_quote+0x74>
mov    -0x18(%rbp),%eax
sub    $0x5c,%eax
je     11cf <scan_quote+0xcf>
jmp    1185 <scan_quote+0x85>
mov    -0x18(%rbp),%eax
sub    $0x6e,%eax
je     1238 <scan_quote+0x138>
jmp    1196 <scan_quote+0x96>
mov    -0x18(%rbp),%eax
sub    $0x72,%eax
je     1215 <scan_quote+0x115>
jmp    11a7 <scan_quote+0xa7>
mov    -0x18(%rbp),%eax
sub    $0x74,%eax
je     11f2 <scan_quote+0xf2>
jmp    125b <scan_quote+0x15b>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
jmp    127e <scan_quote+0x17e>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    127e <scan_quote+0x17e>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x9,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    127e <scan_quote+0x17e>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0xd,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    127e <scan_quote+0x17e>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0xa,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    127e <scan_quote+0x17e>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    12a5 <scan_quote+0x1a5>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    110c <scan_quote+0xc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    12c6 <scan_quote+0x1c6>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_quote>:
mov    %rsi,%rax
lea    0xef6(%rip),%r8
jmp    1116 <scan_quote+0x16>
mov    %dl,(%rdi)
add    $0x2,%rax
add    $0x1,%rdi
movzbl (%rax),%edx
cmp    $0x5c,%dl
je     1140 <scan_quote+0x40>
test   %dl,%dl
je     117d <scan_quote+0x7d>
cmp    $0x22,%dl
je     117d <scan_quote+0x7d>
add    $0x1,%rax
mov    %dl,(%rdi)
add    $0x1,%rdi
jmp    1116 <scan_quote+0x16>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x1(%rax),%edx
movsbl %dl,%esi
lea    -0x5c(%rsi),%ecx
cmp    $0x18,%ecx
ja     115d <scan_quote+0x5d>
movslq (%r8,%rcx,4),%rcx
add    %r8,%rcx
jmp    *%rcx
movb   $0x5c,(%rdi)
jmp    110e <scan_quote+0xe>
test   %esi,%esi
jne    110c <scan_quote+0xc>
add    $0x1,%rax
movb   $0x0,(%rdi)
add    $0x1,%rdi
jmp    1116 <scan_quote+0x16>
movb   $0xa,(%rdi)
jmp    110e <scan_quote+0xe>
movb   $0xd,(%rdi)
jmp    110e <scan_quote+0xe>
movb   $0x9,(%rdi)
jmp    110e <scan_quote+0xe>
xor    %ecx,%ecx
cmp    $0x22,%dl
sete   %cl
add    %rcx,%rax
movb   $0x0,(%rdi)
ret

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

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