#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 strbase(char *, int, int, int *);
int strlen(char *);
int unescape(char *str, int *skip) {
  if (*str != '\\')
    return *str;
  int ret;
  *skip = 0;
  switch (str[1]) {
  case 'a':
    ret = '\a';
    break;
  case 'b':
    ret = '\b';
    break;
  case 'c':
    ret = -1;
    break;
  case 'e':
  case 'E':
    ret = '\x1b';
    break;
  case 'n':
    ret = '\n';
    break;
  case 't':
    ret = '\t';
    break;
  case 'f':
    ret = '\f';
    break;
  case 'v':
    ret = '\v';
    break;
  case '0':
    if (strlen(str) > 2) {
      ret = strbase(str + 2, 8, 3, skip);
      if (*skip)
        break;
    }
    ret = '\0';
    break;
  case 'x':
    if (strlen(str) > 2) {
      ret = strbase(str + 2, 16, 2, skip);
      if (*skip)
        break;
    }
  default:
    ret = *str;
    *skip = -1;
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<unescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     114f <unescape+0x2f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <unescape+0x180>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x48,%eax
ja     1286 <unescape+0x166>
mov    -0x28(%rbp),%rax
lea    0xe82(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x7,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
movl   $0x8,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
movl   $0xffffffff,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
movl   $0x1b,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
movl   $0xa,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
movl   $0x9,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
movl   $0xc,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
movl   $0xb,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jle    122e <unescape+0x10e>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x18(%rbp),%rcx
mov    $0x8,%esi
mov    $0x3,%edx
call   1040 <strbase@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     1229 <unescape+0x109>
jmp    129a <unescape+0x17a>
jmp    122e <unescape+0x10e>
movl   $0x0,-0x1c(%rbp)
jmp    129a <unescape+0x17a>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jle    1281 <unescape+0x161>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x18(%rbp),%rcx
mov    $0x10,%esi
mov    $0x2,%edx
call   1040 <strbase@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     127c <unescape+0x15c>
jmp    129a <unescape+0x17a>
jmp    1281 <unescape+0x161>
jmp    1286 <unescape+0x166>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unescape>:
push   %r14
push   %rbx
push   %rax
movsbl (%rdi),%eax
cmp    $0x5c,%eax
jne    11f8 <unescape+0xd8>
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,(%rsi)
movsbl 0x1(%rdi),%ecx
add    $0xffffffd0,%ecx
cmp    $0x48,%ecx
ja     11d2 <unescape+0xb2>
mov    $0x7,%eax
lea    0xea8(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x1b,%eax
jmp    11f8 <unescape+0xd8>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     1197 <unescape+0x77>
add    $0x2,%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x3,%edx
mov    %r14,%rcx
call   1040 <strbase@plt>
cmpl   $0x0,(%r14)
jne    11f8 <unescape+0xd8>
xor    %eax,%eax
jmp    11f8 <unescape+0xd8>
mov    $0xc,%eax
jmp    11f8 <unescape+0xd8>
mov    $0x9,%eax
jmp    11f8 <unescape+0xd8>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     11d2 <unescape+0xb2>
lea    0x2(%rbx),%rdi
mov    $0x10,%esi
mov    $0x2,%edx
mov    %r14,%rcx
call   1040 <strbase@plt>
cmpl   $0x0,(%r14)
jne    11f8 <unescape+0xd8>
movsbl (%rbx),%eax
movl   $0xffffffff,(%r14)
jmp    11f8 <unescape+0xd8>
mov    $0x8,%eax
jmp    11f8 <unescape+0xd8>
mov    $0xffffffff,%eax
jmp    11f8 <unescape+0xd8>
mov    $0xa,%eax
jmp    11f8 <unescape+0xd8>
mov    $0xb,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @unescape(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 92
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
store i32 %14, i32* %3
br label %66
15: ; preds = %2
%16 = load i32*, i32** %5
store i32 0, i32* %16
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %59 [
i32 97, label %21
i32 98, label %22
i32 99, label %23
i32 101, label %24
i32 69, label %24
i32 110, label %25
i32 116, label %26
i32 102, label %27
i32 118, label %28
i32 48, label %29
i32 120, label %44
]
21: ; preds = %15
store i32 7, i32* %6
br label %64
22: ; preds = %15
store i32 8, i32* %6
br label %64
23: ; preds = %15
store i32 -1, i32* %6
br label %64
24: ; preds = %15, %15
store i32 27, i32* %6
br label %64
25: ; preds = %15
store i32 10, i32* %6
br label %64
26: ; preds = %15
store i32 9, i32* %6
br label %64
27: ; preds = %15
store i32 12, i32* %6
br label %64
28: ; preds = %15
store i32 11, i32* %6
br label %64
29: ; preds = %15
%30 = load i8*, i8** %4
%31 = call i32 @strlen(i8* %30)
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %43
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = load i32*, i32** %5
%37 = call i32 @strbase(i8* %35, i32 8, i32 3, i32* %36)
store i32 %37, i32* %6
%38 = load i32*, i32** %5
%39 = load i32, i32* %38
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %33
br label %64
42: ; preds = %33
br label %43
43: ; preds = %42, %29
store i32 0, i32* %6
br label %64
44: ; preds = %15
%45 = load i8*, i8** %4
%46 = call i32 @strlen(i8* %45)
%47 = icmp sgt i32 %46, 2
br i1 %47, label %48, label %58
48: ; preds = %44
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i64 2
%51 = load i32*, i32** %5
%52 = call i32 @strbase(i8* %50, i32 16, i32 2, i32* %51)
store i32 %52, i32* %6
%53 = load i32*, i32** %5
%54 = load i32, i32* %53
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %48
br label %64
57: ; preds = %48
br label %58
58: ; preds = %57, %44
br label %59
59: ; preds = %15, %58
%60 = load i8*, i8** %4
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
store i32 %62, i32* %6
%63 = load i32*, i32** %5
store i32 -1, i32* %63
br label %64
64: ; preds = %59, %56, %43, %41, %28, %27, %26, %25, %24, %23, %22, %21
%65 = load i32, i32* %6
store i32 %65, i32* %3
br label %66
66: ; preds = %64, %11
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
define i32 @unescape(i8* %0, i32* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 92
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = sext i8 %3 to i32
br label %38
7: ; preds = %2
store i32 0, i32* %1
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %35 [
i32 97, label %38
i32 98, label %11
i32 99, label %12
i32 101, label %13
i32 69, label %13
i32 110, label %14
i32 116, label %15
i32 102, label %16
i32 118, label %17
i32 48, label %18
i32 120, label %27
]
11: ; preds = %7
br label %38
12: ; preds = %7
br label %38
13: ; preds = %7, %7
br label %38
14: ; preds = %7
br label %38
15: ; preds = %7
br label %38
16: ; preds = %7
br label %38
17: ; preds = %7
br label %38
18: ; preds = %7
%19 = tail call i32 @strlen(i8* %0)
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %0, i64 2
%23 = tail call i32 @strbase(i8* %22, i32 8, i32 3, i32* %1)
%24 = load i32, i32* %1
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %38
26: ; preds = %21, %18
br label %38
27: ; preds = %7
%28 = tail call i32 @strlen(i8* %0)
%29 = icmp sgt i32 %28, 2
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = getelementptr inbounds i8, i8* %0, i64 2
%32 = tail call i32 @strbase(i8* %31, i32 16, i32 2, i32* %1)
%33 = load i32, i32* %1
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27, %30, %7
%36 = load i8, i8* %0
%37 = sext i8 %36 to i32
store i32 -1, i32* %1
br label %38
38: ; preds = %11, %12, %13, %14, %15, %16, %17, %26, %35, %21, %30, %7, %5
%39 = phi i32 [ %6, %5 ], [ %37, %35 ], [ %32, %30 ], [ %23, %21 ], [ 0, %26 ], [ 11, %17 ], [ 12, %16 ], [ 9, %15 ], [ 10, %14 ], [ 27, %13 ], [ -1, %12 ], [ 8, %11 ], [ 7, %7 ]
ret i32 %39
}