#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
void escape(char *p1) {
  char *p2;
  for (p2 = p1;; p1++, p2++) {
    if (*p1 == '\\') {
      p1++;
      switch (*p1) {
      case '\0':
        *p2 = '\\';
        *++p2 = '\0';
        return;
      case 'a':
        *p2 = '\007';
        break;
      case 'b':
        *p2 = '\b';
        break;
      case 'f':
        *p2 = '\f';
        break;
      case 'n':
        *p2 = '\n';
        break;
      case 'r':
        *p2 = '\r';
        break;
      case 't':
        *p2 = '\t';
        break;
      case 'v':
        *p2 = '\v';
        break;
      default:
        *p2 = *p1;
        break;
      }
    } else {
      *p2 = *p1;
      if (*p1 == '\0')
        return;
    }
  }
}


x86 assembly (clang, -O0):
<escape>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    123e <escape+0x13e>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     11ba <escape+0xba>
jmp    1143 <escape+0x43>
mov    -0x14(%rbp),%eax
sub    $0x61,%eax
je     11d9 <escape+0xd9>
jmp    1154 <escape+0x54>
mov    -0x14(%rbp),%eax
sub    $0x62,%eax
je     11e5 <escape+0xe5>
jmp    1165 <escape+0x65>
mov    -0x14(%rbp),%eax
sub    $0x66,%eax
je     11f1 <escape+0xf1>
jmp    1176 <escape+0x76>
mov    -0x14(%rbp),%eax
sub    $0x6e,%eax
je     11fd <escape+0xfd>
jmp    1187 <escape+0x87>
mov    -0x14(%rbp),%eax
sub    $0x72,%eax
je     1209 <escape+0x109>
jmp    1198 <escape+0x98>
mov    -0x14(%rbp),%eax
sub    $0x74,%eax
je     1215 <escape+0x115>
jmp    11a9 <escape+0xa9>
mov    -0x14(%rbp),%eax
sub    $0x76,%eax
je     1221 <escape+0x121>
jmp    122d <escape+0x12d>
mov    -0x10(%rbp),%rax
movb   $0x5c,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,0x1(%rax)
jmp    1286 <escape+0x186>
mov    -0x10(%rbp),%rax
movb   $0x7,(%rax)
jmp    1239 <escape+0x139>
mov    -0x10(%rbp),%rax
movb   $0x8,(%rax)
jmp    1239 <escape+0x139>
mov    -0x10(%rbp),%rax
movb   $0xc,(%rax)
jmp    1239 <escape+0x139>
mov    -0x10(%rbp),%rax
movb   $0xa,(%rax)
jmp    1239 <escape+0x139>
mov    -0x10(%rbp),%rax
movb   $0xd,(%rax)
jmp    1239 <escape+0x139>
mov    -0x10(%rbp),%rax
movb   $0x9,(%rax)
jmp    1239 <escape+0x139>
mov    -0x10(%rbp),%rax
movb   $0xb,(%rax)
jmp    1239 <escape+0x139>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    1264 <escape+0x164>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    125f <escape+0x15f>
jmp    1286 <escape+0x186>
jmp    1264 <escape+0x164>
jmp    1269 <escape+0x169>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1110 <escape+0x10>
pop    %rbp
ret

x86 assembly (clang, -O2):
<escape>:
lea    0xef9(%rip),%r8
mov    %rdi,%rcx
jmp    111e <escape+0x1e>
mov    $0x8,%dl
xchg   %ax,%ax
add    $0x1,%rdi
mov    %dl,(%rcx)
add    $0x1,%rdi
add    $0x1,%rcx
movzbl (%rdi),%eax
cmp    $0x5c,%al
jne    1150 <escape+0x50>
movzbl 0x1(%rdi),%r9d
movsbl %r9b,%esi
lea    -0x61(%rsi),%eax
cmp    $0x15,%eax
ja     1169 <escape+0x69>
mov    $0x7,%dl
movslq (%r8,%rax,4),%rax
add    %r8,%rax
jmp    *%rax
mov    $0xc,%dl
jmp    1110 <escape+0x10>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %al,(%rcx)
cmpb   $0x0,(%rdi)
jne    1116 <escape+0x16>
jmp    1177 <escape+0x77>
mov    $0xa,%dl
jmp    1110 <escape+0x10>
mov    $0xd,%dl
jmp    1110 <escape+0x10>
mov    $0x9,%dl
jmp    1110 <escape+0x10>
mov    $0xb,%dl
jmp    1110 <escape+0x10>
mov    %r9d,%edx
test   %esi,%esi
jne    1110 <escape+0x10>
jmp    1178 <escape+0x78>
mov    %r9d,%edx
jmp    1110 <escape+0x10>
ret
movw   $0x5c,(%rcx)
ret

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

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