#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");
      }
      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     1217 <unescape+0x107>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11f0 <unescape+0xe0>
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     11d3 <unescape+0xc3>
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    11d3 <unescape+0xc3>
mov    -0x18(%rbp),%rax
movb   $0xc,(%rax)
jmp    11d3 <unescape+0xc3>
mov    -0x18(%rbp),%rax
movb   $0xa,(%rax)
jmp    11d3 <unescape+0xc3>
mov    -0x18(%rbp),%rax
movb   $0xd,(%rax)
jmp    11d3 <unescape+0xc3>
mov    -0x18(%rbp),%rax
movb   $0x9,(%rax)
jmp    11d3 <unescape+0xc3>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1212 <unescape+0x102>
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   $0xc,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     11af <unescape+0x9f>
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
add    $0xffffff9e,%eax
cmp    $0x16,%eax
ja     1140 <unescape+0x30>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    (%r12),%edi
mov    %r14,%rsi
call   1030 <fprintf@plt>
jmp    1140 <unescape+0x30>
movb   $0x8,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 = %46, %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %47
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 %40
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 %35
24: ; preds = %16
%25 = load i8*, i8** %4
store i8 12, i8* %25
br label %35
26: ; preds = %16
%27 = load i8*, i8** %4
store i8 10, i8* %27
br label %35
28: ; preds = %16
%29 = load i8*, i8** %4
store i8 13, i8* %29
br label %35
30: ; preds = %16
%31 = load i8*, i8** %4
store i8 9, i8* %31
br label %35
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 %35
35: ; preds = %32, %16, %30, %28, %26, %24, %22
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %4
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
br label %46
40: ; preds = %11
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %3
%43 = load i8, i8* %41
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %4
store i8 %43, i8* %44
br label %46
46: ; preds = %40, %35
br label %7
47: ; preds = %7
%48 = load i8*, i8** %4
store i8 0, i8* %48
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 = %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 %20 [
i8 0, label %25
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 %18
11: ; preds = %6
store i8 12, i8* %4
br label %18
12: ; preds = %6
store i8 10, i8* %4
br label %18
13: ; preds = %6
store i8 13, i8* %4
br label %18
14: ; preds = %6
store i8 9, i8* %4
br label %18
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 %18
18: ; preds = %15, %6, %14, %13, %12, %11, %10
%19 = getelementptr inbounds i8, i8* %3, i64 2
br label %22
20: ; preds = %2
%21 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %5, i8* %4
br label %22
22: ; preds = %20, %18
%23 = phi i8* [ %19, %18 ], [ %21, %20 ]
%24 = getelementptr inbounds i8, i8* %4, i64 1
br label %2
25: ; preds = %2
store i8 0, i8* %4
ret void
}