char *escape_char(char e) {
  switch (e) {
  case 'a':
    return "\a";
  case 'b':
    return "\b";
  case 't':
    return "\t";
  case 'n':
    return "\n";
  case 'v':
    return "\v";
  case 'f':
    return "\f";
  case 'r':
    return "\r";
  case '\"':
    return "\"";
  case '\'':
    return "\'";
  case '\\':
    return "\\";
  default:
    return "\?";
  }
}


x86 assembly (clang, -O0):
<escape_char>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x54,%eax
ja     11d4 <escape_char+0xd4>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x1019(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0x100b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xffd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xfef(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xfe1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xfd3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xfc5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xfb7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xfa9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xf9b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <escape_char+0xdf>
lea    0xf8d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<escape_char>:
add    $0xffffffde,%edi
cmp    $0x54,%edi
ja     1127 <escape_char+0x27>
lea    0x1045(%rip),%rax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0x103c(%rip),%rax
ret
lea    0x103a(%rip),%rax
ret
lea    0x102e(%rip),%rax
ret
lea    0x1028(%rip),%rax
ret
lea    0x1010(%rip),%rax
ret
lea    0x1010(%rip),%rax
ret
lea    0x1004(%rip),%rax
ret
lea    0x1002(%rip),%rax
ret
lea    0xff2(%rip),%rax
ret
lea    0xfee(%rip),%rax
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\07\00"
@.str.1 = [2 x i8] c"\08\00"
@.str.2 = [2 x i8] c"\09\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [2 x i8] c"\0B\00"
@.str.5 = [2 x i8] c"\0C\00"
@.str.6 = [2 x i8] c"\0D\00"
@.str.7 = [2 x i8] c"\22\00"
@.str.8 = [2 x i8] c"'\00"
@.str.9 = [2 x i8] c"\\\00"
@.str.10 = [2 x i8] c"?\00"
define i8* @escape_char(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %16 [
i32 97, label %6
i32 98, label %7
i32 116, label %8
i32 110, label %9
i32 118, label %10
i32 102, label %11
i32 114, label %12
i32 34, label %13
i32 39, label %14
i32 92, label %15
]
6: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2
br label %17
7: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %17
8: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %17
9: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %17
10: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %17
11: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %17
12: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %17
13: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %17
14: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %17
15: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %17
16: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@.str = [2 x i8] c"\07\00"
@.str.1 = [2 x i8] c"\08\00"
@.str.2 = [2 x i8] c"\09\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [2 x i8] c"\0B\00"
@.str.5 = [2 x i8] c"\0C\00"
@.str.6 = [2 x i8] c"\0D\00"
@.str.7 = [2 x i8] c"\22\00"
@.str.8 = [2 x i8] c"'\00"
@.str.9 = [2 x i8] c"\\\00"
@.str.10 = [2 x i8] c"?\00"
define i8* @escape_char(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %12 [
i32 97, label %13
i32 98, label %3
i32 116, label %4
i32 110, label %5
i32 118, label %6
i32 102, label %7
i32 114, label %8
i32 34, label %9
i32 39, label %10
i32 92, label %11
]
3: ; preds = %1
br label %13
4: ; preds = %1
br label %13
5: ; preds = %1
br label %13
6: ; preds = %1
br label %13
7: ; preds = %1
br label %13
8: ; preds = %1
br label %13
9: ; preds = %1
br label %13
10: ; preds = %1
br label %13
11: ; preds = %1
br label %13
12: ; preds = %1
br label %13
13: ; preds = %1, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
%14 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), %12 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), %10 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), %8 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %14
}