#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 */
char *strchr(char *, char);
void proto_unescape(char *s) {
  char *cp, *cp2;
  cp = s;
  while ((cp = strchr(cp, '\\')) != NULL) {
    switch (cp[1]) {
    case '_':
      *cp = ' ';
      break;
    case 't':
      *cp = '\t';
      break;
    case 'r':
      *cp = '\r';
      break;
    case 'n':
      *cp = '\n';
      break;
    case '\\':
      *cp = '\\';
      break;
    default:
      *cp = *(cp + 1);
    }
    cp2 = ++cp;
    while (*cp2 != '\0') {
      *cp2 = *(cp2 + 1);
      cp2++;
    }
  }
}


x86 assembly (clang, -O0):
<proto_unescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11fa <proto_unescape+0xea>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
add    $0xffffffa4,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x18,%eax
ja     11aa <proto_unescape+0x9a>
mov    -0x20(%rbp),%rax
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
movb   $0x20,(%rax)
jmp    11b7 <proto_unescape+0xa7>
mov    -0x10(%rbp),%rax
movb   $0x9,(%rax)
jmp    11b7 <proto_unescape+0xa7>
mov    -0x10(%rbp),%rax
movb   $0xd,(%rax)
jmp    11b7 <proto_unescape+0xa7>
mov    -0x10(%rbp),%rax
movb   $0xa,(%rax)
jmp    11b7 <proto_unescape+0xa7>
mov    -0x10(%rbp),%rax
movb   $0x5c,(%rax)
jmp    11b7 <proto_unescape+0xa7>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f5 <proto_unescape+0xe5>
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11c7 <proto_unescape+0xb7>
jmp    1124 <proto_unescape+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proto_unescape>:
push   %rbx
mov    $0x5c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1190 <proto_unescape+0x80>
lea    0xed9(%rip),%rbx
jmp    113f <proto_unescape+0x2f>
nopl   0x0(%rax)
mov    $0x5c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1190 <proto_unescape+0x80>
movsbl 0x1(%rax),%ecx
mov    %ecx,%esi
add    $0xffffffa4,%esi
cmp    $0x18,%esi
ja     115c <proto_unescape+0x4c>
mov    $0x20,%dl
movslq (%rbx,%rsi,4),%rsi
add    %rbx,%rsi
jmp    *%rsi
mov    $0x5c,%dl
jmp    1170 <proto_unescape+0x60>
mov    %ecx,%edx
jmp    1170 <proto_unescape+0x60>
mov    $0xa,%dl
jmp    1170 <proto_unescape+0x60>
mov    $0xd,%dl
jmp    1170 <proto_unescape+0x60>
mov    $0x9,%dl
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%rdi
mov    %dl,(%rax)
test   %cl,%cl
je     1130 <proto_unescape+0x20>
add    $0x2,%rax
xchg   %ax,%ax
movzbl (%rax),%ecx
mov    %cl,-0x1(%rax)
add    $0x1,%rax
test   %cl,%cl
jne    1180 <proto_unescape+0x70>
jmp    1130 <proto_unescape+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define void @proto_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
br label %6
6: ; preds = %45, %1
%7 = load i8*, i8** %3
%8 = call i8* @strchr(i8* %7, i8 signext 92)
store i8* %8, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %46
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
switch i32 %14, label %25 [
i32 95, label %15
i32 116, label %17
i32 114, label %19
i32 110, label %21
i32 92, label %23
]
15: ; preds = %10
%16 = load i8*, i8** %3
store i8 32, i8* %16
br label %30
17: ; preds = %10
%18 = load i8*, i8** %3
store i8 9, i8* %18
br label %30
19: ; preds = %10
%20 = load i8*, i8** %3
store i8 13, i8* %20
br label %30
21: ; preds = %10
%22 = load i8*, i8** %3
store i8 10, i8* %22
br label %30
23: ; preds = %10
%24 = load i8*, i8** %3
store i8 92, i8* %24
br label %30
25: ; preds = %10
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = load i8*, i8** %3
store i8 %28, i8* %29
br label %30
30: ; preds = %25, %23, %21, %19, %17, %15
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
store i8* %32, i8** %4
br label %33
33: ; preds = %38, %30
%34 = load i8*, i8** %4
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = load i8, i8* %40
%42 = load i8*, i8** %4
store i8 %41, i8* %42
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %4
br label %33
45: ; preds = %33
br label %6
46: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @proto_unescape(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 92)
%3 = icmp eq i8* %2, null
br i1 %3, label %25, label %7
4: ; preds = %20, %17
%5 = tail call i8* @strchr(i8* dereferenceable(1) %9, i8 signext 92)
%6 = icmp eq i8* %5, null
br i1 %6, label %25, label %7
7: ; preds = %1, %4
%8 = phi i8* [ %5, %4 ], [ %2, %1 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %16 [
i32 95, label %17
i32 116, label %12
i32 114, label %13
i32 110, label %14
i32 92, label %15
]
12: ; preds = %7
br label %17
13: ; preds = %7
br label %17
14: ; preds = %7
br label %17
15: ; preds = %7
br label %17
16: ; preds = %7
br label %17
17: ; preds = %7, %16, %15, %14, %13, %12
%18 = phi i8 [ %10, %16 ], [ 92, %15 ], [ 10, %14 ], [ 13, %13 ], [ 9, %12 ], [ 32, %7 ]
store i8 %18, i8* %8
%19 = icmp eq i8 %10, 0
br i1 %19, label %4, label %20
20: ; preds = %17, %20
%21 = phi i8* [ %22, %20 ], [ %9, %17 ]
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
store i8 %23, i8* %21
%24 = icmp eq i8 %23, 0
br i1 %24, label %4, label %20
25: ; preds = %4, %1
ret void
}