char getEscapeCharacter(char c) {
  if (c == 'n')
    return '\n';
  else if (c == 'r')
    return '\r';
  else if (c == 't')
    return '\t';
  else if (c == '0')
    return '\0';
  else if (c == 'b')
    return '\b';
  return c;
}


x86 assembly (clang, -O0):
<getEscapeCharacter>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x6e,%eax
jne    1120 <getEscapeCharacter+0x20>
movb   $0xa,-0x1(%rbp)
jmp    1192 <getEscapeCharacter+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x72,%eax
jne    1136 <getEscapeCharacter+0x36>
movb   $0xd,-0x1(%rbp)
jmp    1192 <getEscapeCharacter+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x74,%eax
jne    114c <getEscapeCharacter+0x4c>
movb   $0x9,-0x1(%rbp)
jmp    1192 <getEscapeCharacter+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x30,%eax
jne    1162 <getEscapeCharacter+0x62>
movb   $0x0,-0x1(%rbp)
jmp    1192 <getEscapeCharacter+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x62,%eax
jne    1178 <getEscapeCharacter+0x78>
movb   $0x8,-0x1(%rbp)
jmp    1192 <getEscapeCharacter+0x92>
jmp    117d <getEscapeCharacter+0x7d>
jmp    1182 <getEscapeCharacter+0x82>
jmp    1187 <getEscapeCharacter+0x87>
jmp    118c <getEscapeCharacter+0x8c>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getEscapeCharacter>:
lea    -0x62(%rdi),%ecx
cmp    $0x12,%cl
ja     1120 <getEscapeCharacter+0x20>
mov    $0xa,%al
movzbl %cl,%ecx
lea    0xeec(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x8,%al
ret
cmp    $0x30,%dil
jne    1129 <getEscapeCharacter+0x29>
xor    %eax,%eax
ret
mov    %edi,%eax
ret
mov    $0xd,%al
ret
mov    $0x9,%al
ret

LLVM IR (-O0):
define signext i8 @getEscapeCharacter(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
%6 = icmp eq i32 %5, 110
br i1 %6, label %7, label %8
7: ; preds = %1
store i8 10, i8* %2
br label %34
8: ; preds = %1
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 114
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 13, i8* %2
br label %34
13: ; preds = %8
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 116
br i1 %16, label %17, label %18
17: ; preds = %13
store i8 9, i8* %2
br label %34
18: ; preds = %13
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 48
br i1 %21, label %22, label %23
22: ; preds = %18
store i8 0, i8* %2
br label %34
23: ; preds = %18
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 98
br i1 %26, label %27, label %28
27: ; preds = %23
store i8 8, i8* %2
br label %34
28: ; preds = %23
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = load i8, i8* %3
store i8 %33, i8* %2
br label %34
34: ; preds = %32, %27, %22, %17, %12, %7
%35 = load i8, i8* %2
ret i8 %35
}

LLVM IR (-O2):
define signext i8 @getEscapeCharacter(i8 signext %0) {
switch i8 %0, label %6 [
i8 110, label %7
i8 114, label %2
i8 116, label %3
i8 48, label %4
i8 98, label %5
]
2: ; preds = %1
br label %7
3: ; preds = %1
br label %7
4: ; preds = %1
br label %7
5: ; preds = %1
br label %7
6: ; preds = %1
br label %7
7: ; preds = %1, %6, %5, %4, %3, %2
%8 = phi i8 [ 13, %2 ], [ 9, %3 ], [ 0, %4 ], [ 8, %5 ], [ %0, %6 ], [ 10, %1 ]
ret i8 %8
}