char *maptype(char f) {
  char *mt;
  switch (f) {
  case 's':
    mt = "char *";
    break;
  case 'i':
    mt = "int";
    break;
  case 'p':
    mt = "int *";
    break;
  case 'c':
    mt = "char";
    break;
  default:
    mt = "";
    break;
  }
  return mt;
}


x86 assembly (clang, -O0):
<maptype>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x10,%eax
ja     1174 <maptype+0x74>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf09(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    117f <maptype+0x7f>
lea    0xf00(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    117f <maptype+0x7f>
lea    0xef4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    117f <maptype+0x7f>
lea    0xeea(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    117f <maptype+0x7f>
lea    0xecf(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<maptype>:
add    $0xffffff9d,%edi
cmp    $0x10,%edi
ja     1127 <maptype+0x27>
lea    0xf35(%rip),%rax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf2f(%rip),%rax
ret
lea    0xf1c(%rip),%rax
ret
lea    0xf15(%rip),%rax
ret
lea    0xf11(%rip),%rax
ret

LLVM IR (-O0):
@.str = [7 x i8] c"char *\00"
@.str.1 = [4 x i8] c"int\00"
@.str.2 = [6 x i8] c"int *\00"
@.str.3 = [5 x i8] c"char\00"
@.str.4 = [1 x i8] zeroinitializer
define i8* @maptype(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8*
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
switch i32 %5, label %10 [
i32 115, label %6
i32 105, label %7
i32 112, label %8
i32 99, label %9
]
6: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %3
br label %11
7: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %11
8: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %11
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %11
10: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %11
11: ; preds = %10, %9, %8, %7, %6
%12 = load i8*, i8** %3
ret i8* %12
}

LLVM IR (-O2):
@.str = [7 x i8] c"char *\00"
@.str.1 = [4 x i8] c"int\00"
@.str.2 = [6 x i8] c"int *\00"
@.str.3 = [5 x i8] c"char\00"
@.str.4 = [1 x i8] zeroinitializer
define i8* @maptype(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %6 [
i32 115, label %7
i32 105, label %3
i32 112, label %4
i32 99, label %5
]
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
%8 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %8
}