#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*/ strncasecmp(char const *, char *, size_t);
char parse_char_name(const char *s, size_t n) {
  switch (n) {
  case 3:
    if (strncasecmp(s, "tab", n) == 0) {
      return '\t';
    }
    break;
  case 5:
    if (strncasecmp(s, "space", n) == 0) {
      return ' ';
    }
    break;
  case 6:
    if (strncasecmp(s, "return", n) == 0) {
      return '\r';
    }
    break;
  case 7:
    if (strncasecmp(s, "newline", n) == 0) {
      return '\n';
    }
    break;
  }
  return '\0';
}


x86 assembly (clang, -O0):
<parse_char_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffffd,%rax
mov    %rax,-0x20(%rbp)
sub    $0x4,%rax
ja     11f6 <parse_char_name+0xe6>
mov    -0x20(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xebb(%rip),%rsi
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1170 <parse_char_name+0x60>
movb   $0x9,-0x1(%rbp)
jmp    11fa <parse_char_name+0xea>
jmp    11f6 <parse_char_name+0xe6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe94(%rip),%rsi
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    119b <parse_char_name+0x8b>
movb   $0x20,-0x1(%rbp)
jmp    11fa <parse_char_name+0xea>
jmp    11f6 <parse_char_name+0xe6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe6f(%rip),%rsi
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11c6 <parse_char_name+0xb6>
movb   $0xd,-0x1(%rbp)
jmp    11fa <parse_char_name+0xea>
jmp    11f6 <parse_char_name+0xe6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe4b(%rip),%rsi
call   1030 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11f1 <parse_char_name+0xe1>
movb   $0xa,-0x1(%rbp)
jmp    11fa <parse_char_name+0xea>
jmp    11f6 <parse_char_name+0xe6>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_char_name>:
push   %rax
add    $0xfffffffffffffffd,%rsi
cmp    $0x4,%rsi
ja     118b <parse_char_name+0x7b>
lea    0xede(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xee2(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
jne    118b <parse_char_name+0x7b>
mov    $0x9,%al
pop    %rcx
ret
lea    0xecd(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
jne    118b <parse_char_name+0x7b>
mov    $0x20,%al
pop    %rcx
ret
lea    0xeba(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
jne    118b <parse_char_name+0x7b>
mov    $0xd,%al
pop    %rcx
ret
lea    0xea8(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     118f <parse_char_name+0x7f>
xor    %eax,%eax
pop    %rcx
ret
mov    $0xa,%al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"tab\00"
@.str.1 = [6 x i8] c"space\00"
@.str.2 = [7 x i8] c"return\00"
@.str.3 = [8 x i8] c"newline\00"
define signext i8 @parse_char_name(i8* %0, i64 %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
switch i64 %6, label %35 [
i64 3, label %7
i64 5, label %14
i64 6, label %21
i64 7, label %28
]
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = load i64, i64* %5
%10 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7
store i8 9, i8* %3
br label %36
13: ; preds = %7
br label %35
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i64, i64* %5
%17 = call i32 @strncasecmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i8 32, i8* %3
br label %36
20: ; preds = %14
br label %35
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = load i64, i64* %5
%24 = call i32 @strncasecmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %23)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i8 13, i8* %3
br label %36
27: ; preds = %21
br label %35
28: ; preds = %2
%29 = load i8*, i8** %4
%30 = load i64, i64* %5
%31 = call i32 @strncasecmp(i8* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i8 10, i8* %3
br label %36
34: ; preds = %28
br label %35
35: ; preds = %2, %34, %27, %20, %13
store i8 0, i8* %3
br label %36
36: ; preds = %35, %33, %26, %19, %12
%37 = load i8, i8* %3
ret i8 %37
}

LLVM IR (-O2):
@.str = [4 x i8] c"tab\00"
@.str.1 = [6 x i8] c"space\00"
@.str.2 = [7 x i8] c"return\00"
@.str.3 = [8 x i8] c"newline\00"
define signext i8 @parse_char_name(i8* nocapture %0, i64 %1) {
switch i64 %1, label %15 [
i64 3, label %3
i64 5, label %6
i64 6, label %9
i64 7, label %12
]
3: ; preds = %2
%4 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %15
6: ; preds = %2
%7 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %16, label %15
9: ; preds = %2
%10 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 6)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %15
12: ; preds = %2
%13 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %12, %9, %6, %3, %2
br label %16
16: ; preds = %12, %9, %6, %3, %15
%17 = phi i8 [ 0, %15 ], [ 9, %3 ], [ 32, %6 ], [ 13, %9 ], [ 10, %12 ]
ret i8 %17
}