#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*/ _exit(int /*<<< orphan*/);
int hextoint(unsigned char);
int /*<<< orphan*/ isxdigit(unsigned char);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ write(int, char *, int);
void handle_escape(char *s) {
  do {
    if (*s == '\\') {
      switch (*++s) {
      case '\0':
        write(1, "\\", 1);
        return;
      case 'c':
        _exit(0);
      case '\\':
        write(1, "\\", 1);
        break;
      case 'a':
        write(1, "\a", 1);
        break;
      case 'b':
        write(1, "\b", 1);
        break;
      case 'e':
        write(1, "\x1b", 1);
        break;
      case 'f':
        write(1, "\f", 1);
        break;
      case 'n':
        write(1, "\n", 1);
        break;
      case 'r':
        write(1, "\r", 1);
        break;
      case 't':
        write(1, "\t", 1);
        break;
      case 'v':
        write(1, "\v", 1);
        break;
      case 'x':
        if (isxdigit((unsigned char)s[1])) {
          if (isxdigit((unsigned char)s[2])) {
            putchar(hextoint((unsigned char)s[1]) << 4 |
                    hextoint((unsigned char)s[2]));
            s += 2;
          } else {
            putchar(hextoint((unsigned char)s[1]));
            ++s;
          }
          break;
        }
      default:
        write(1, "\\", 1);
        write(1, s, 1);
      }
    } else {
      write(1, s, 1);
    }
  } while (*++s);
}


x86 assembly (clang, -O0):
<handle_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    13fa <handle_escape+0x2aa>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     124a <handle_escape+0xfa>
jmp    118f <handle_escape+0x3f>
mov    -0xc(%rbp),%eax
sub    $0x5c,%eax
je     1269 <handle_escape+0x119>
jmp    11a0 <handle_escape+0x50>
mov    -0xc(%rbp),%eax
sub    $0x61,%eax
je     1281 <handle_escape+0x131>
jmp    11b1 <handle_escape+0x61>
mov    -0xc(%rbp),%eax
sub    $0x62,%eax
je     1299 <handle_escape+0x149>
jmp    11c2 <handle_escape+0x72>
mov    -0xc(%rbp),%eax
sub    $0x63,%eax
je     1262 <handle_escape+0x112>
jmp    11d3 <handle_escape+0x83>
mov    -0xc(%rbp),%eax
sub    $0x65,%eax
je     12b1 <handle_escape+0x161>
jmp    11e4 <handle_escape+0x94>
mov    -0xc(%rbp),%eax
sub    $0x66,%eax
je     12c9 <handle_escape+0x179>
jmp    11f5 <handle_escape+0xa5>
mov    -0xc(%rbp),%eax
sub    $0x6e,%eax
je     12e1 <handle_escape+0x191>
jmp    1206 <handle_escape+0xb6>
mov    -0xc(%rbp),%eax
sub    $0x72,%eax
je     12f9 <handle_escape+0x1a9>
jmp    1217 <handle_escape+0xc7>
mov    -0xc(%rbp),%eax
sub    $0x74,%eax
je     1311 <handle_escape+0x1c1>
jmp    1228 <handle_escape+0xd8>
mov    -0xc(%rbp),%eax
sub    $0x76,%eax
je     1329 <handle_escape+0x1d9>
jmp    1239 <handle_escape+0xe9>
mov    -0xc(%rbp),%eax
sub    $0x78,%eax
je     1341 <handle_escape+0x1f1>
jmp    13d2 <handle_escape+0x282>
mov    $0x1,%edx
lea    0xdaa(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    1428 <handle_escape+0x2d8>
xor    %edi,%edi
call   1040 <_exit@plt>
mov    $0x1,%edx
lea    0xd8b(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    $0x1,%edx
lea    0xd75(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    $0x1,%edx
lea    0xd5f(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    $0x1,%edx
lea    0xd49(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    $0x1,%edx
lea    0xd33(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    $0x1,%edx
lea    0xd1d(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    $0x1,%edx
lea    0xd07(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    $0x1,%edx
lea    0xcf1(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    $0x1,%edx
lea    0xcdb(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
jmp    13f5 <handle_escape+0x2a5>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1070 <isxdigit@plt>
cmp    $0x0,%eax
je     13cd <handle_escape+0x27d>
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%edi
call   1070 <isxdigit@plt>
cmp    $0x0,%eax
je     13a8 <handle_escape+0x258>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1060 <hextoint@plt>
shl    $0x4,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%edi
call   1060 <hextoint@plt>
mov    -0x10(%rbp),%edi
or     %eax,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    13c8 <handle_escape+0x278>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1060 <hextoint@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    13f5 <handle_escape+0x2a5>
jmp    13d2 <handle_escape+0x282>
mov    $0x1,%edx
lea    0xc22(%rip),%rsi
mov    %edx,%edi
call   1050 <write@plt>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1050 <write@plt>
jmp    140a <handle_escape+0x2ba>
mov    -0x8(%rbp),%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1050 <write@plt>
jmp    140f <handle_escape+0x2bf>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
cmpb   $0x0,0x1(%rax)
jne    115c <handle_escape+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_escape>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
mov    (%rdi),%al
lea    0xf0d(%rip),%rbx
lea    0xe92(%rip),%r15
lea    0xf01(%rip),%r14
lea    0xefc(%rip),%r12
jmp    11a8 <handle_escape+0x58>
xchg   %ax,%ax
mov    $0x1,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    %r13,%rbp
movzbl 0x1(%rbp),%eax
add    $0x1,%rbp
mov    %rbp,%r13
test   %al,%al
je     12ec <handle_escape+0x19c>
cmp    $0x5c,%al
jne    1180 <handle_escape+0x30>
lea    0x1(%r13),%rbp
movsbl 0x1(%r13),%eax
lea    -0x5c(%rax),%ecx
cmp    $0x1c,%ecx
ja     1295 <handle_escape+0x145>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x1,%edi
mov    %rbx,%rsi
jmp    12c0 <handle_escape+0x170>
mov    $0x1,%edi
mov    %r14,%rsi
jmp    12c0 <handle_escape+0x170>
mov    $0x1,%edi
mov    %r12,%rsi
jmp    12c0 <handle_escape+0x170>
mov    $0x1,%edi
lea    0xe7d(%rip),%rsi
jmp    12c0 <handle_escape+0x170>
mov    $0x1,%edi
lea    0xe6e(%rip),%rsi
jmp    12c0 <handle_escape+0x170>
mov    $0x1,%edi
lea    0xe5f(%rip),%rsi
jmp    12c0 <handle_escape+0x170>
mov    $0x1,%edi
lea    0xe50(%rip),%rsi
jmp    12c0 <handle_escape+0x170>
mov    $0x1,%edi
lea    0xe41(%rip),%rsi
jmp    12c0 <handle_escape+0x170>
mov    $0x1,%edi
lea    0xe35(%rip),%rsi
jmp    12c0 <handle_escape+0x170>
movzbl 0x2(%r13),%edi
call   1070 <isxdigit@plt>
test   %eax,%eax
je     1299 <handle_escape+0x149>
mov    %r14,%rbx
movzbl 0x3(%r13),%edi
call   1070 <isxdigit@plt>
mov    %eax,%r14d
movzbl 0x2(%r13),%edi
call   1060 <hextoint@plt>
mov    %eax,%ebp
test   %r14d,%r14d
je     12cf <handle_escape+0x17f>
add    $0x3,%r13
shl    $0x4,%ebp
movzbl 0x0(%r13),%edi
call   1060 <hextoint@plt>
or     %eax,%ebp
jmp    12d3 <handle_escape+0x183>
test   %eax,%eax
je     12fb <handle_escape+0x1ab>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%edx
call   1050 <write@plt>
jmp    1195 <handle_escape+0x45>
add    $0x2,%r13
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    %r13,%rbp
mov    %rbx,%r14
lea    0xd8d(%rip),%rbx
jmp    1195 <handle_escape+0x45>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd72(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <write@plt>
xor    %edi,%edi
call   1040 <_exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\\\00"
@.str.1 = [2 x i8] c"\07\00"
@.str.2 = [2 x i8] c"\08\00"
@.str.3 = [2 x i8] c"\1B\00"
@.str.4 = [2 x i8] c"\0C\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [2 x i8] c"\0D\00"
@.str.7 = [2 x i8] c"\09\00"
@.str.8 = [2 x i8] c"\0B\00"
define void @handle_escape(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %80, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 92
br i1 %7, label %8, label %76
8: ; preds = %3
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %71 [
i32 0, label %13
i32 99, label %15
i32 92, label %17
i32 97, label %19
i32 98, label %21
i32 101, label %23
i32 102, label %25
i32 110, label %27
i32 114, label %29
i32 116, label %31
i32 118, label %33
i32 120, label %35
]
13: ; preds = %8
%14 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %85
15: ; preds = %8
%16 = call i32 @_exit(i32 0)
unreachable
17: ; preds = %8
%18 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %75
19: ; preds = %8
%20 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %75
21: ; preds = %8
%22 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %75
23: ; preds = %8
%24 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %75
25: ; preds = %8
%26 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %75
27: ; preds = %8
%28 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
br label %75
29: ; preds = %8
%30 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1)
br label %75
31: ; preds = %8
%32 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 1)
br label %75
33: ; preds = %8
%34 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
br label %75
35: ; preds = %8
%36 = load i8*, i8** %2
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = call i32 @isxdigit(i8 zeroext %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %70
41: ; preds = %35
%42 = load i8*, i8** %2
%43 = getelementptr inbounds i8, i8* %42, i64 2
%44 = load i8, i8* %43
%45 = call i32 @isxdigit(i8 zeroext %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %61
47: ; preds = %41
%48 = load i8*, i8** %2
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = load i8, i8* %49
%51 = call i32 @hextoint(i8 zeroext %50)
%52 = shl i32 %51, 4
%53 = load i8*, i8** %2
%54 = getelementptr inbounds i8, i8* %53, i64 2
%55 = load i8, i8* %54
%56 = call i32 @hextoint(i8 zeroext %55)
%57 = or i32 %52, %56
%58 = call i32 @putchar(i32 %57)
%59 = load i8*, i8** %2
%60 = getelementptr inbounds i8, i8* %59, i64 2
store i8* %60, i8** %2
br label %69
61: ; preds = %41
%62 = load i8*, i8** %2
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = load i8, i8* %63
%65 = call i32 @hextoint(i8 zeroext %64)
%66 = call i32 @putchar(i32 %65)
%67 = load i8*, i8** %2
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %2
br label %69
69: ; preds = %61, %47
br label %75
70: ; preds = %35
br label %71
71: ; preds = %8, %70
%72 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%73 = load i8*, i8** %2
%74 = call i32 @write(i32 1, i8* %73, i32 1)
br label %75
75: ; preds = %71, %69, %33, %31, %29, %27, %25, %23, %21, %19, %17
br label %79
76: ; preds = %3
%77 = load i8*, i8** %2
%78 = call i32 @write(i32 1, i8* %77, i32 1)
br label %79
79: ; preds = %76, %75
br label %80
80: ; preds = %79
%81 = load i8*, i8** %2
%82 = getelementptr inbounds i8, i8* %81, i32 1
store i8* %82, i8** %2
%83 = load i8, i8* %82
%84 = icmp ne i8 %83, 0
br i1 %84, label %3, label %85
85: ; preds = %13, %80
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\\\00"
@.str.1 = [2 x i8] c"\07\00"
@.str.2 = [2 x i8] c"\08\00"
@.str.3 = [2 x i8] c"\1B\00"
@.str.4 = [2 x i8] c"\0C\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [2 x i8] c"\0D\00"
@.str.7 = [2 x i8] c"\09\00"
@.str.8 = [2 x i8] c"\0B\00"
define void @handle_escape(i8* nocapture %0) {
%2 = load i8, i8* %0
br label %3
3: ; preds = %58, %1
%4 = phi i8 [ %61, %58 ], [ %2, %1 ]
%5 = phi i8* [ %60, %58 ], [ %0, %1 ]
%6 = icmp eq i8 %4, 92
br i1 %6, label %7, label %56
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %5, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %53 [
i32 0, label %11
i32 99, label %13
i32 92, label %15
i32 97, label %17
i32 98, label %19
i32 101, label %21
i32 102, label %23
i32 110, label %25
i32 114, label %27
i32 116, label %29
i32 118, label %31
i32 120, label %33
]
11: ; preds = %7
%12 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %63
13: ; preds = %7
%14 = tail call i32 @_exit(i32 0)
unreachable
15: ; preds = %7
%16 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %58
17: ; preds = %7
%18 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %58
19: ; preds = %7
%20 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %58
21: ; preds = %7
%22 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %58
23: ; preds = %7
%24 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %58
25: ; preds = %7
%26 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
br label %58
27: ; preds = %7
%28 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1)
br label %58
29: ; preds = %7
%30 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 1)
br label %58
31: ; preds = %7
%32 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
br label %58
33: ; preds = %7
%34 = getelementptr inbounds i8, i8* %5, i64 2
%35 = load i8, i8* %34
%36 = tail call i32 @isxdigit(i8 zeroext %35)
%37 = icmp eq i32 %36, 0
br i1 %37, label %53, label %38
38: ; preds = %33
%39 = getelementptr inbounds i8, i8* %5, i64 3
%40 = load i8, i8* %39
%41 = tail call i32 @isxdigit(i8 zeroext %40)
%42 = icmp eq i32 %41, 0
%43 = load i8, i8* %34
%44 = tail call i32 @hextoint(i8 zeroext %43)
br i1 %42, label %51, label %45
45: ; preds = %38
%46 = shl i32 %44, 4
%47 = load i8, i8* %39
%48 = tail call i32 @hextoint(i8 zeroext %47)
%49 = or i32 %48, %46
%50 = tail call i32 @putchar(i32 %49)
br label %58
51: ; preds = %38
%52 = tail call i32 @putchar(i32 %44)
br label %58
53: ; preds = %33, %7
%54 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%55 = tail call i32 @write(i32 1, i8* %8, i32 1)
br label %58
56: ; preds = %3
%57 = tail call i32 @write(i32 1, i8* %5, i32 1)
br label %58
58: ; preds = %56, %45, %51, %53, %31, %29, %27, %25, %23, %21, %19, %17, %15
%59 = phi i8* [ %8, %53 ], [ %39, %45 ], [ %34, %51 ], [ %8, %31 ], [ %8, %29 ], [ %8, %27 ], [ %8, %25 ], [ %8, %23 ], [ %8, %21 ], [ %8, %19 ], [ %8, %17 ], [ %8, %15 ], [ %5, %56 ]
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = load i8, i8* %60
%62 = icmp eq i8 %61, 0
br i1 %62, label %63, label %3
63: ; preds = %58, %11
ret void
}