#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 strlen(char *);
int /*<<< orphan*/ yyerror(char *);
char validate_char(char *yytext) {
  if (strlen(yytext) > 3) {
    switch (yytext[2]) {
    case 'n':
      return '\n';
    case 't':
      return '\t';
    case '\'':
      return '\'';
    case '\\':
      return '\\';
    case '\/':
      return '\/';
    case '\"':
      return '\"';
    case '0':
      return '\0';
    case 'r':
      return '\r';
    case 'b':
      return '\b';
    default:
      return '\0';
      yyerror("undefinded character literal.");
    }
  } else {
    return yytext[1];
  }
}


x86 assembly (clang, -O0):
<validate_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jle    11b6 <validate_char+0xa6>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x52,%eax
ja     11ad <validate_char+0x9d>
mov    -0x18(%rbp),%rax
lea    0xead(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0xa,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0x9,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0x27,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0x5c,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0x2f,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0x22,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0x0,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0xd,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0x8,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
movb   $0x0,-0x1(%rbp)
jmp    11c0 <validate_char+0xb0>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_char>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x4,%eax
jl     1140 <validate_char+0x30>
movsbl 0x2(%rbx),%ecx
add    $0xffffffde,%ecx
cmp    $0x52,%ecx
ja     113c <validate_char+0x2c>
mov    $0xa,%al
lea    0xecd(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
xor    %eax,%eax
pop    %rbx
ret
mov    0x1(%rbx),%al
pop    %rbx
ret
mov    $0x22,%al
pop    %rbx
ret
mov    $0x27,%al
pop    %rbx
ret
mov    $0x2f,%al
pop    %rbx
ret
mov    $0x5c,%al
pop    %rbx
ret
mov    $0x8,%al
pop    %rbx
ret
mov    $0xd,%al
pop    %rbx
ret
mov    $0x9,%al
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @validate_char(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strlen(i8* %4)
%6 = icmp sgt i32 %5, 3
br i1 %6, label %7, label %22
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %21 [
i32 110, label %12
i32 116, label %13
i32 39, label %14
i32 92, label %15
i32 47, label %16
i32 34, label %17
i32 48, label %18
i32 114, label %19
i32 98, label %20
]
12: ; preds = %7
store i8 10, i8* %2
br label %26
13: ; preds = %7
store i8 9, i8* %2
br label %26
14: ; preds = %7
store i8 39, i8* %2
br label %26
15: ; preds = %7
store i8 92, i8* %2
br label %26
16: ; preds = %7
store i8 47, i8* %2
br label %26
17: ; preds = %7
store i8 34, i8* %2
br label %26
18: ; preds = %7
store i8 0, i8* %2
br label %26
19: ; preds = %7
store i8 13, i8* %2
br label %26
20: ; preds = %7
store i8 8, i8* %2
br label %26
21: ; preds = %7
store i8 0, i8* %2
br label %26
22: ; preds = %1
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
store i8 %25, i8* %2
br label %26
26: ; preds = %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12
%27 = load i8, i8* %2
ret i8 %27
}

LLVM IR (-O2):
define signext i8 @validate_char(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 3
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %16 [
i32 110, label %20
i32 116, label %8
i32 39, label %9
i32 92, label %10
i32 47, label %11
i32 34, label %12
i32 48, label %13
i32 114, label %14
i32 98, label %15
]
8: ; preds = %4
br label %20
9: ; preds = %4
br label %20
10: ; preds = %4
br label %20
11: ; preds = %4
br label %20
12: ; preds = %4
br label %20
13: ; preds = %4
br label %20
14: ; preds = %4
br label %20
15: ; preds = %4
br label %20
16: ; preds = %4
br label %20
17: ; preds = %1
%18 = getelementptr inbounds i8, i8* %0, i64 1
%19 = load i8, i8* %18
br label %20
20: ; preds = %4, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8
%21 = phi i8 [ 0, %16 ], [ 8, %15 ], [ 13, %14 ], [ 0, %13 ], [ 34, %12 ], [ 47, %11 ], [ 92, %10 ], [ 39, %9 ], [ 9, %8 ], [ %19, %17 ], [ 10, %4 ]
ret i8 %21
}