void tov8(char *v8, char *basic) {
  while (*basic)
    switch (*basic) {
    case '?':
    case '+':
    case '|':
    case '(':
    case ')': {
      *v8++ = '\\';
      *v8++ = *basic++;
      break;
    }
    case '\\': {
      switch (*(basic + 1)) {
      case '?':
      case '+':
      case '|':
      case '(':
      case ')': {
        *v8++ = *++basic;
        ++basic;
        break;
      }
      case '\0': {
        *v8++ = *basic++;
        break;
      }
      default: {
        *v8++ = *basic++;
        *v8++ = *basic++;
      }
      }
      break;
    }
    default: {
      *v8++ = *basic++;
    }
    }
  *v8++ = '\0';
}


x86 assembly (clang, -O0):
<tov8>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     12db <tov8+0x1db>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
add    $0xffffffd8,%eax
sub    $0x2,%eax
jb     1178 <tov8+0x78>
jmp    1134 <tov8+0x34>
mov    -0x14(%rbp),%eax
sub    $0x2b,%eax
je     1178 <tov8+0x78>
jmp    1145 <tov8+0x45>
mov    -0x14(%rbp),%eax
sub    $0x3f,%eax
je     1178 <tov8+0x78>
jmp    1156 <tov8+0x56>
mov    -0x14(%rbp),%eax
sub    $0x5c,%eax
je     11b1 <tov8+0xb1>
jmp    1167 <tov8+0x67>
mov    -0x14(%rbp),%eax
sub    $0x7c,%eax
jne    12b4 <tov8+0x1b4>
jmp    1178 <tov8+0x78>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
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    12d6 <tov8+0x1d6>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     1244 <tov8+0x144>
jmp    11c9 <tov8+0xc9>
mov    -0x18(%rbp),%eax
add    $0xffffffd8,%eax
sub    $0x2,%eax
jb     1210 <tov8+0x110>
jmp    11dd <tov8+0xdd>
mov    -0x18(%rbp),%eax
sub    $0x2b,%eax
je     1210 <tov8+0x110>
jmp    11ee <tov8+0xee>
mov    -0x18(%rbp),%eax
sub    $0x3f,%eax
je     1210 <tov8+0x110>
jmp    11ff <tov8+0xff>
mov    -0x18(%rbp),%eax
sub    $0x7c,%eax
jne    126b <tov8+0x16b>
jmp    1210 <tov8+0x110>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x1(%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    12af <tov8+0x1af>
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    12af <tov8+0x1af>
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)
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    12d6 <tov8+0x1d6>
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 <tov8+0xc>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<tov8>:
mov    (%rsi),%dl
test   %dl,%dl
je     11a4 <tov8+0xa4>
mov    $0x80000b,%r9d
movabs $0x80000b0000000000,%r8
jmp    1137 <tov8+0x37>
test   %rax,%rax
jne    1187 <tov8+0x87>
add    $0x1,%rsi
mov    %dl,(%rdi)
add    $0x1,%rdi
nopl   0x0(%rax,%rax,1)
movzbl (%rsi),%edx
test   %dl,%dl
je     11a4 <tov8+0xa4>
movsbl %dl,%ecx
lea    -0x28(%rcx),%eax
cmp    $0x34,%eax
ja     1180 <tov8+0x80>
bt     %rax,%r9
jae    1160 <tov8+0x60>
movb   $0x5c,(%rdi)
movzbl (%rsi),%eax
add    $0x1,%rsi
mov    %al,0x1(%rdi)
add    $0x2,%rdi
jmp    1130 <tov8+0x30>
nopl   0x0(%rax,%rax,1)
cmp    $0x34,%rax
jne    1180 <tov8+0x80>
movzbl 0x1(%rsi),%ecx
movsbl %cl,%eax
cmp    $0x3f,%eax
ja     1187 <tov8+0x87>
bt     %rax,%r8
jb     118c <tov8+0x8c>
jmp    111c <tov8+0x1c>
nopw   0x0(%rax,%rax,1)
cmp    $0x7c,%ecx
jne    1121 <tov8+0x21>
jmp    1148 <tov8+0x48>
cmp    $0x7c,%eax
jne    1198 <tov8+0x98>
mov    %cl,(%rdi)
add    $0x1,%rdi
add    $0x2,%rsi
jmp    1130 <tov8+0x30>
mov    %dl,(%rdi)
movzbl 0x1(%rsi),%eax
add    $0x2,%rsi
jmp    1152 <tov8+0x52>
movb   $0x0,(%rdi)
ret

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

LLVM IR (-O2):
define void @tov8(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %37, label %5
5: ; preds = %2, %32
%6 = phi i8 [ %35, %32 ], [ %3, %2 ]
%7 = phi i8* [ %34, %32 ], [ %1, %2 ]
%8 = phi i8* [ %33, %32 ], [ %0, %2 ]
%9 = sext i8 %6 to i32
switch i32 %9, label %29 [
i32 63, label %10
i32 43, label %10
i32 124, label %10
i32 40, label %10
i32 41, label %10
i32 92, label %15
]
10: ; preds = %5, %5, %5, %5, %5
%11 = getelementptr inbounds i8, i8* %8, i64 1
store i8 92, i8* %8
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = load i8, i8* %7
%14 = getelementptr inbounds i8, i8* %8, i64 2
store i8 %13, i8* %11
br label %32
15: ; preds = %5
%16 = getelementptr inbounds i8, i8* %7, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %24 [
i32 63, label %19
i32 43, label %19
i32 124, label %19
i32 40, label %19
i32 41, label %19
i32 0, label %22
]
19: ; preds = %15, %15, %15, %15, %15
%20 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %17, i8* %8
%21 = getelementptr inbounds i8, i8* %7, i64 2
br label %32
22: ; preds = %15
%23 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %6, i8* %8
br label %32
24: ; preds = %15
%25 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %6, i8* %8
%26 = getelementptr inbounds i8, i8* %7, i64 2
%27 = load i8, i8* %16
%28 = getelementptr inbounds i8, i8* %8, i64 2
store i8 %27, i8* %25
br label %32
29: ; preds = %5
%30 = getelementptr inbounds i8, i8* %7, i64 1
%31 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %6, i8* %8
br label %32
32: ; preds = %19, %22, %24, %29, %10
%33 = phi i8* [ %31, %29 ], [ %28, %24 ], [ %23, %22 ], [ %20, %19 ], [ %14, %10 ]
%34 = phi i8* [ %30, %29 ], [ %26, %24 ], [ %16, %22 ], [ %21, %19 ], [ %12, %10 ]
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %5
37: ; preds = %32, %2
%38 = phi i8* [ %0, %2 ], [ %33, %32 ]
store i8 0, i8* %38
ret void
}