#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void unescape(char *buf) {
  char *r, *w;
  r = buf;
  w = buf;
  while (*r) {
    if (*r == '\\') {
      r++;
      switch (*r) {
      case 'b':
        *w = '\b';
        break;
      case 'f':
        *w = '\f';
        break;
      case 'n':
        *w = '\n';
        break;
      case 'r':
        *w = '\r';
        break;
      case 't':
        *w = '\t';
        break;
      case 'x':
      case 'u':
        fprintf(stderr, "unsupported escape sequence\n");
        break;
      default:
        *w = *r;
        break;
      }
      w++;
      r++;
    } else {
      *w++ = *r++;
    }
  }
  *w = '\0';
}


x86 assembly (clang, -O0):
<unescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1228 <unescape+0x118>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1201 <unescape+0xf1>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x16,%eax
ja     11d8 <unescape+0xc8>
mov    -0x20(%rbp),%rax
lea    0xe87(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movb   $0x8,(%rax)
jmp    11e4 <unescape+0xd4>
mov    -0x18(%rbp),%rax
movb   $0xc,(%rax)
jmp    11e4 <unescape+0xd4>
mov    -0x18(%rbp),%rax
movb   $0xa,(%rax)
jmp    11e4 <unescape+0xd4>
mov    -0x18(%rbp),%rax
movb   $0xd,(%rax)
jmp    11e4 <unescape+0xd4>
mov    -0x18(%rbp),%rax
movb   $0x9,(%rax)
jmp    11e4 <unescape+0xd4>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11e4 <unescape+0xd4>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1223 <unescape+0x113>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    112c <unescape+0x1c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unescape>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%rbx
lea    0xedd(%rip),%r15
mov    0x2eb6(%rip),%r12
lea    0xf2b(%rip),%r14
mov    %rdi,%r13
jmp    1148 <unescape+0x38>
movb   $0x8,0x0(%r13)
nopl   0x0(%rax,%rax,1)
add    $0x2,%rbx
add    $0x1,%r13
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     1170 <unescape+0x60>
test   %al,%al
je     11b5 <unescape+0xa5>
add    $0x1,%rbx
mov    %al,0x0(%r13)
add    $0x1,%r13
jmp    1148 <unescape+0x38>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%eax
lea    -0x62(%rax),%ecx
cmp    $0x16,%ecx
ja     1193 <unescape+0x83>
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mov    (%r12),%edi
mov    %r14,%rsi
call   1030 <fprintf@plt>
jmp    1140 <unescape+0x30>
mov    %al,0x0(%r13)
jmp    1140 <unescape+0x30>
movb   $0xc,0x0(%r13)
jmp    1140 <unescape+0x30>
movb   $0xa,0x0(%r13)
jmp    1140 <unescape+0x30>
movb   $0xd,0x0(%r13)
jmp    1140 <unescape+0x30>
movb   $0x9,0x0(%r13)
jmp    1140 <unescape+0x30>
movb   $0x0,0x0(%r13)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"unsupported escape sequence\0A\00"
define void @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
%6 = load i8*, i8** %2
store i8* %6, i8** %4
br label %7
7: ; preds = %50, %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %51
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 92
br i1 %15, label %16, label %44
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %35 [
i32 98, label %22
i32 102, label %24
i32 110, label %26
i32 114, label %28
i32 116, label %30
i32 120, label %32
i32 117, label %32
]
22: ; preds = %16
%23 = load i8*, i8** %4
store i8 8, i8* %23
br label %39
24: ; preds = %16
%25 = load i8*, i8** %4
store i8 12, i8* %25
br label %39
26: ; preds = %16
%27 = load i8*, i8** %4
store i8 10, i8* %27
br label %39
28: ; preds = %16
%29 = load i8*, i8** %4
store i8 13, i8* %29
br label %39
30: ; preds = %16
%31 = load i8*, i8** %4
store i8 9, i8* %31
br label %39
32: ; preds = %16, %16
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %39
35: ; preds = %16
%36 = load i8*, i8** %3
%37 = load i8, i8* %36
%38 = load i8*, i8** %4
store i8 %37, i8* %38
br label %39
39: ; preds = %35, %32, %30, %28, %26, %24, %22
%40 = load i8*, i8** %4
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %4
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %3
br label %50
44: ; preds = %11
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %3
%47 = load i8, i8* %45
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %4
store i8 %47, i8* %48
br label %50
50: ; preds = %44, %39
br label %7
51: ; preds = %7
%52 = load i8*, i8** %4
store i8 0, i8* %52
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"unsupported escape sequence\0A\00"
define void @unescape(i8* nocapture %0) {
br label %2
2: ; preds = %23, %1
%3 = phi i8* [ %0, %1 ], [ %24, %23 ]
%4 = phi i8* [ %0, %1 ], [ %25, %23 ]
%5 = load i8, i8* %3
switch i8 %5, label %21 [
i8 0, label %26
i8 92, label %6
]
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %18 [
i32 98, label %10
i32 102, label %11
i32 110, label %12
i32 114, label %13
i32 116, label %14
i32 120, label %15
i32 117, label %15
]
10: ; preds = %6
store i8 8, i8* %4
br label %19
11: ; preds = %6
store i8 12, i8* %4
br label %19
12: ; preds = %6
store i8 10, i8* %4
br label %19
13: ; preds = %6
store i8 13, i8* %4
br label %19
14: ; preds = %6
store i8 9, i8* %4
br label %19
15: ; preds = %6, %6
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %19
18: ; preds = %6
store i8 %8, i8* %4
br label %19
19: ; preds = %18, %15, %14, %13, %12, %11, %10
%20 = getelementptr inbounds i8, i8* %3, i64 2
br label %23
21: ; preds = %2
%22 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %5, i8* %4
br label %23
23: ; preds = %21, %19
%24 = phi i8* [ %20, %19 ], [ %22, %21 ]
%25 = getelementptr inbounds i8, i8* %4, i64 1
br label %2
26: ; preds = %2
store i8 0, i8* %4
ret void
}