char *collapse_escapes(strptr)
char *strptr;
{
  register char *strout;
  strout = strptr;
  while (*strptr) {
    if (*strptr != '\\')
      *strout++ = *strptr++;
    else {
      switch (*++strptr) {
      case '0':
        *strout++ = '\0';
        break;
      case 'b':
        *strout++ = '\b';
        break;
      case 'f':
        *strout++ = '\f';
        break;
      case 'n':
        *strout++ = '\n';
        break;
      case 'r':
        *strout++ = '\r';
        break;
      case 't':
        *strout++ = '\t';
        break;
      case 'v':
        *strout++ = '\v';
        break;
      default:
        *strout++ = *strptr;
        break;
      }
      strptr++;
    }
  }
  return strout;
}


x86 assembly (clang, -O0):
<collapse_escapes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     12a7 <collapse_escapes+0x1a7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     1154 <collapse_escapes+0x54>
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    12a2 <collapse_escapes+0x1a2>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x30,%eax
je     11de <collapse_escapes+0xde>
jmp    1178 <collapse_escapes+0x78>
mov    -0x14(%rbp),%eax
sub    $0x62,%eax
je     11f5 <collapse_escapes+0xf5>
jmp    1189 <collapse_escapes+0x89>
mov    -0x14(%rbp),%eax
sub    $0x66,%eax
je     120c <collapse_escapes+0x10c>
jmp    119a <collapse_escapes+0x9a>
mov    -0x14(%rbp),%eax
sub    $0x6e,%eax
je     1223 <collapse_escapes+0x123>
jmp    11ab <collapse_escapes+0xab>
mov    -0x14(%rbp),%eax
sub    $0x72,%eax
je     123a <collapse_escapes+0x13a>
jmp    11bc <collapse_escapes+0xbc>
mov    -0x14(%rbp),%eax
sub    $0x74,%eax
je     1251 <collapse_escapes+0x151>
jmp    11cd <collapse_escapes+0xcd>
mov    -0x14(%rbp),%eax
sub    $0x76,%eax
je     1268 <collapse_escapes+0x168>
jmp    127f <collapse_escapes+0x17f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,(%rax)
jmp    1296 <collapse_escapes+0x196>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x8,(%rax)
jmp    1296 <collapse_escapes+0x196>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0xc,(%rax)
jmp    1296 <collapse_escapes+0x196>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0xa,(%rax)
jmp    1296 <collapse_escapes+0x196>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0xd,(%rax)
jmp    1296 <collapse_escapes+0x196>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x9,(%rax)
jmp    1296 <collapse_escapes+0x196>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0xb,(%rax)
jmp    1296 <collapse_escapes+0x196>
mov    -0x8(%rbp),%rax
mov    (%rax),%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    1110 <collapse_escapes+0x10>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<collapse_escapes>:
lea    0xef9(%rip),%r8
mov    %rdi,%rax
jmp    111a <collapse_escapes+0x1a>
mov    $0xb,%dl
xchg   %ax,%ax
mov    %dl,(%rax)
add    $0x2,%rdi
add    $0x1,%rax
movzbl (%rdi),%edx
cmp    $0x5c,%dl
je     1140 <collapse_escapes+0x40>
test   %dl,%dl
je     1175 <collapse_escapes+0x75>
add    $0x1,%rdi
mov    %dl,(%rax)
add    $0x1,%rax
jmp    111a <collapse_escapes+0x1a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x1(%rdi),%edx
movsbl %dl,%esi
lea    -0x62(%rsi),%ecx
cmp    $0x14,%ecx
ja     115c <collapse_escapes+0x5c>
movslq (%r8,%rcx,4),%rcx
add    %r8,%rcx
jmp    *%rcx
mov    $0x8,%dl
jmp    1110 <collapse_escapes+0x10>
cmp    $0x30,%esi
jne    1110 <collapse_escapes+0x10>
xor    %edx,%edx
jmp    1110 <collapse_escapes+0x10>
mov    $0xc,%dl
jmp    1110 <collapse_escapes+0x10>
mov    $0xa,%dl
jmp    1110 <collapse_escapes+0x10>
mov    $0xd,%dl
jmp    1110 <collapse_escapes+0x10>
mov    $0x9,%dl
jmp    1110 <collapse_escapes+0x10>
ret

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

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