#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*/ isprint(unsigned char);
unsigned char literal_escape(unsigned char c, int action) {
  static unsigned char control_escape[] = {'a', 'b', 'e', 'f', 'n',
                                           'r', 't', 'v', '\0'};
  static unsigned char control_actual[] = {'\a', '\b', 0x1B, '\f', '\n',
                                           '\r', '\t', '\v', '\0'};
  static unsigned char valid_escape[] = {
      'a', 'b', 'f',  'n', 'r', 't', 'v', '(', ')', '[', ']',  '<',
      '>', '.', '\\', '|', '^', '$', '*', '+', '?', '&', '\"', '\0'};
  static unsigned char value[] = {
      '\a', '\b', '\f', '\n', '\r', '\t', '\v', '(', ')', '[', ']',  '<',
      '>',  '.',  '\\', '|',  '^',  '$',  '*',  '+', '?', '&', '\"', '\0'};
  int i;
  if (action == 0) {
    for (i = 0; valid_escape[i] != '\0'; i++) {
      if (c == valid_escape[i])
        return value[i];
    }
  } else if (action == 1) {
    for (i = 0; control_actual[i] != '\0'; i++) {
      if (c == control_actual[i]) {
        return control_escape[i];
      }
    }
  }
  if (action == 1) {
    if (!isprint(c)) {
      return '0';
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<literal_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1193 <literal_escape+0x83>
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2f13(%rip),%rax
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     118e <literal_escape+0x7e>
movzbl -0x2(%rbp),%eax
movslq -0xc(%rbp),%rdx
lea    0x2ef7(%rip),%rcx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    117b <literal_escape+0x6b>
movslq -0xc(%rbp),%rcx
lea    0x2f00(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x1(%rbp)
jmp    1238 <literal_escape+0x128>
jmp    1180 <literal_escape+0x70>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <literal_escape+0x22>
jmp    120a <literal_escape+0xfa>
cmpl   $0x1,-0x8(%rbp)
jne    1205 <literal_escape+0xf5>
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2e8a(%rip),%rax
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1200 <literal_escape+0xf0>
movzbl -0x2(%rbp),%eax
movslq -0xc(%rbp),%rdx
lea    0x2e6e(%rip),%rcx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11ed <literal_escape+0xdd>
movslq -0xc(%rbp),%rcx
lea    0x2e4e(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x1(%rbp)
jmp    1238 <literal_escape+0x128>
jmp    11f2 <literal_escape+0xe2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a4 <literal_escape+0x94>
jmp    1205 <literal_escape+0xf5>
jmp    120a <literal_escape+0xfa>
cmpl   $0x1,-0x8(%rbp)
jne    1234 <literal_escape+0x124>
movzbl -0x2(%rbp),%edi
call   1030 <isprint@plt>
cmp    $0x0,%eax
jne    122f <literal_escape+0x11f>
movb   $0x30,-0x1(%rbp)
jmp    1238 <literal_escape+0x128>
jmp    1234 <literal_escape+0x124>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<literal_escape>:
push   %rax
test   %esi,%esi
je     1142 <literal_escape+0x32>
cmp    $0x1,%esi
jne    11a0 <literal_escape+0x90>
lea    -0x7(%rdi),%ecx
cmp    $0x14,%cl
ja     118f <literal_escape+0x7f>
xor    %eax,%eax
movzbl %cl,%ecx
lea    0xece(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x1,%eax
jmp    11a9 <literal_escape+0x99>
add    $0xde,%dil
cmp    $0x5a,%dil
ja     11a0 <literal_escape+0x90>
xor    %eax,%eax
movzbl %dil,%ecx
lea    0xefb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x16,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x6,%eax
jmp    11a9 <literal_escape+0x99>
mov    $0x4,%eax
jmp    11a9 <literal_escape+0x99>
mov    $0x7,%eax
jmp    11a9 <literal_escape+0x99>
mov    $0x3,%eax
jmp    11a9 <literal_escape+0x99>
mov    $0x5,%eax
jmp    11a9 <literal_escape+0x99>
movzbl %dil,%edi
call   1030 <isprint@plt>
test   %eax,%eax
je     1258 <literal_escape+0x148>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x2,%eax
lea    0x1010(%rip),%rcx
jmp    1253 <literal_escape+0x143>
mov    $0x11,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x15,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x7,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x8,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x12,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x13,%eax
jmp    124c <literal_escape+0x13c>
mov    $0xd,%eax
jmp    124c <literal_escape+0x13c>
mov    $0xb,%eax
jmp    124c <literal_escape+0x13c>
mov    $0xc,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x14,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x9,%eax
jmp    124c <literal_escape+0x13c>
mov    $0xe,%eax
jmp    124c <literal_escape+0x13c>
mov    $0xa,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x10,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x1,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x2,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x3,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x4,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x5,%eax
jmp    124c <literal_escape+0x13c>
mov    $0x6,%eax
jmp    124c <literal_escape+0x13c>
mov    $0xf,%eax
lea    0xf7d(%rip),%rcx
mov    (%rax,%rcx,1),%al
pop    %rcx
ret
mov    $0x30,%al
pop    %rcx
ret

LLVM IR (-O0):
@literal_escape.control_escape = internal global [9 x i8] c"abefnrtv\00"
@literal_escape.control_actual = internal global [9 x i8] c"\07\08\1B\0C\0A\0D\09\0B\00"
@literal_escape.valid_escape = internal global [24 x i8] c"abfnrtv()[]<>.\\|^$*+?&\22\00"
@literal_escape.value = internal global [24 x i8] c"\07\08\0C\0A\0D\09\0B()[]<>.\\|^$*+?&\22\00"
define zeroext i8 @literal_escape(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %36
9: ; preds = %2
store i32 0, i32* %6
br label %10
10: ; preds = %32, %9
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [24 x i8], [24 x i8]* @literal_escape.valid_escape, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %35
17: ; preds = %10
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [24 x i8], [24 x i8]* @literal_escape.valid_escape, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp eq i32 %19, %24
br i1 %25, label %26, label %31
26: ; preds = %17
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [24 x i8], [24 x i8]* @literal_escape.value, i64 0, i64 %28
%30 = load i8, i8* %29
store i8 %30, i8* %3
br label %77
31: ; preds = %17
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %10
35: ; preds = %10
br label %67
36: ; preds = %2
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %66
39: ; preds = %36
store i32 0, i32* %6
br label %40
40: ; preds = %62, %39
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [9 x i8], [9 x i8]* @literal_escape.control_actual, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %65
47: ; preds = %40
%48 = load i8, i8* %4
%49 = zext i8 %48 to i32
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [9 x i8], [9 x i8]* @literal_escape.control_actual, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = icmp eq i32 %49, %54
br i1 %55, label %56, label %61
56: ; preds = %47
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [9 x i8], [9 x i8]* @literal_escape.control_escape, i64 0, i64 %58
%60 = load i8, i8* %59
store i8 %60, i8* %3
br label %77
61: ; preds = %47
br label %62
62: ; preds = %61
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %40
65: ; preds = %40
br label %66
66: ; preds = %65, %36
br label %67
67: ; preds = %66, %35
%68 = load i32, i32* %5
%69 = icmp eq i32 %68, 1
br i1 %69, label %70, label %76
70: ; preds = %67
%71 = load i8, i8* %4
%72 = call i32 @isprint(i8 zeroext %71)
%73 = icmp ne i32 %72, 0
br i1 %73, label %75, label %74
74: ; preds = %70
store i8 48, i8* %3
br label %77
75: ; preds = %70
br label %76
76: ; preds = %75, %67
store i8 0, i8* %3
br label %77
77: ; preds = %76, %74, %56, %26
%78 = load i8, i8* %3
ret i8 %78
}

LLVM IR (-O2):
@literal_escape.control_escape = internal unnamed_addr constant [9 x i8] c"abefnrtv\00"
@literal_escape.value = internal unnamed_addr constant [24 x i8] c"\07\08\0C\0A\0D\09\0B()[]<>.\\|^$*+?&\22\00"
define zeroext i8 @literal_escape(i8 zeroext %0, i32 %1) {
switch i32 %1, label %45 [
i32 0, label %4
i32 1, label %3
]
3: ; preds = %2
switch i8 %0, label %42 [
i8 7, label %38
i8 8, label %31
i8 27, label %32
i8 12, label %33
i8 10, label %34
i8 13, label %35
i8 9, label %36
i8 11, label %37
]
4: ; preds = %2
switch i8 %0, label %45 [
i8 97, label %27
i8 98, label %5
i8 102, label %6
i8 110, label %7
i8 114, label %8
i8 116, label %9
i8 118, label %10
i8 40, label %11
i8 41, label %12
i8 91, label %13
i8 93, label %14
i8 60, label %15
i8 62, label %16
i8 46, label %17
i8 92, label %18
i8 124, label %19
i8 94, label %20
i8 36, label %21
i8 42, label %22
i8 43, label %23
i8 63, label %24
i8 38, label %25
i8 34, label %26
]
5: ; preds = %4
br label %27
6: ; preds = %4
br label %27
7: ; preds = %4
br label %27
8: ; preds = %4
br label %27
9: ; preds = %4
br label %27
10: ; preds = %4
br label %27
11: ; preds = %4
br label %27
12: ; preds = %4
br label %27
13: ; preds = %4
br label %27
14: ; preds = %4
br label %27
15: ; preds = %4
br label %27
16: ; preds = %4
br label %27
17: ; preds = %4
br label %27
18: ; preds = %4
br label %27
19: ; preds = %4
br label %27
20: ; preds = %4
br label %27
21: ; preds = %4
br label %27
22: ; preds = %4
br label %27
23: ; preds = %4
br label %27
24: ; preds = %4
br label %27
25: ; preds = %4
br label %27
26: ; preds = %4
br label %27
27: ; preds = %4, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%28 = phi i64 [ 0, %4 ], [ 1, %5 ], [ 2, %6 ], [ 3, %7 ], [ 4, %8 ], [ 5, %9 ], [ 6, %10 ], [ 7, %11 ], [ 8, %12 ], [ 9, %13 ], [ 10, %14 ], [ 11, %15 ], [ 12, %16 ], [ 13, %17 ], [ 14, %18 ], [ 15, %19 ], [ 16, %20 ], [ 17, %21 ], [ 18, %22 ], [ 19, %23 ], [ 20, %24 ], [ 21, %25 ], [ 22, %26 ]
%29 = getelementptr inbounds [24 x i8], [24 x i8]* @literal_escape.value, i64 0, i64 %28
%30 = load i8, i8* %29
br label %46
31: ; preds = %3
br label %38
32: ; preds = %3
br label %38
33: ; preds = %3
br label %38
34: ; preds = %3
br label %38
35: ; preds = %3
br label %38
36: ; preds = %3
br label %38
37: ; preds = %3
br label %38
38: ; preds = %3, %37, %36, %35, %34, %33, %32, %31
%39 = phi i64 [ 0, %3 ], [ 1, %31 ], [ 2, %32 ], [ 3, %33 ], [ 4, %34 ], [ 5, %35 ], [ 6, %36 ], [ 7, %37 ]
%40 = getelementptr inbounds [9 x i8], [9 x i8]* @literal_escape.control_escape, i64 0, i64 %39
%41 = load i8, i8* %40
br label %46
42: ; preds = %3
%43 = tail call i32 @isprint(i8 zeroext %0)
%44 = icmp eq i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %4, %2, %42
br label %46
46: ; preds = %42, %45, %38, %27
%47 = phi i8 [ %30, %27 ], [ 0, %45 ], [ %41, %38 ], [ 48, %42 ]
ret i8 %47
}