const char *get_type(int is_signed, int size) {
  if (is_signed) {
    switch (size) {
    case 1:
      return "Interfaces.C.signed_char";
    case 2:
      return "Interfaces.C.short";
    case 4:
      if (sizeof(int) == 4) {
        return "Interfaces.C.long";
      } else {
        return "Interfaces.C.int";
      }
    case 8:
      return "Long_Long_Integer";
    default:
      return "<invalid>";
    }
  } else {
    switch (size) {
    case 1:
      return "Interfaces.C.unsigned_char";
    case 2:
      return "Interfaces.C.unsigned_short";
    case 4:
      if (sizeof(int) == 4) {
        return "Interfaces.C.unsigned_long";
      } else {
        return "Interfaces.C.unsigned_int";
      }
    case 8:
      return "Long_Long_Integer";
    default:
      return "<invalid>";
    }
  }
}


x86 assembly (clang, -O0):
<get_type>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     118d <get_type+0x8d>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     117d <get_type+0x7d>
mov    -0x18(%rbp),%rax
lea    0xeec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xefc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
lea    0xf05(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
lea    0xf08(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
lea    0xf0a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
lea    0xf0c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x7,%eax
ja     11f6 <get_type+0xf6>
mov    -0x20(%rbp),%rax
lea    0xe53(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
lea    0xee8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
lea    0xef4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
lea    0xe91(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <get_type+0x101>
lea    0xe93(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_type>:
add    $0xffffffff,%esi
cmp    $0x7,%esi
ja     1124 <get_type+0x24>
test   %edi,%edi
lea    0x2cff(%rip),%rax
lea    0x2cb8(%rip),%rcx
cmove  %rax,%rcx
movslq %esi,%rax
mov    (%rcx,%rax,8),%rax
ret
lea    0xf25(%rip),%rax
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Interfaces.C.signed_char\00"
@.str.1 = [19 x i8] c"Interfaces.C.short\00"
@.str.2 = [18 x i8] c"Interfaces.C.long\00"
@.str.3 = [18 x i8] c"Long_Long_Integer\00"
@.str.4 = [10 x i8] c"<invalid>\00"
@.str.5 = [27 x i8] c"Interfaces.C.unsigned_char\00"
@.str.6 = [28 x i8] c"Interfaces.C.unsigned_short\00"
@.str.7 = [27 x i8] c"Interfaces.C.unsigned_long\00"
define i8* @get_type(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i32, i32* %5
switch i32 %9, label %14 [
i32 1, label %10
i32 2, label %11
i32 4, label %12
i32 8, label %13
]
10: ; preds = %8
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %3
br label %22
11: ; preds = %8
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %22
12: ; preds = %8
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %22
13: ; preds = %8
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %22
14: ; preds = %8
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %22
15: ; preds = %2
%16 = load i32, i32* %5
switch i32 %16, label %21 [
i32 1, label %17
i32 2, label %18
i32 4, label %19
i32 8, label %20
]
17: ; preds = %15
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %22
18: ; preds = %15
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %22
19: ; preds = %15
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %22
20: ; preds = %15
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %22
21: ; preds = %15
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %22
22: ; preds = %21, %20, %19, %18, %17, %14, %13, %12, %11, %10
%23 = load i8*, i8** %3
ret i8* %23
}

LLVM IR (-O2):
@.str = [25 x i8] c"Interfaces.C.signed_char\00"
@.str.1 = [19 x i8] c"Interfaces.C.short\00"
@.str.2 = [18 x i8] c"Interfaces.C.long\00"
@.str.3 = [18 x i8] c"Long_Long_Integer\00"
@.str.4 = [10 x i8] c"<invalid>\00"
@.str.5 = [27 x i8] c"Interfaces.C.unsigned_char\00"
@.str.6 = [28 x i8] c"Interfaces.C.unsigned_short\00"
@.str.7 = [27 x i8] c"Interfaces.C.unsigned_long\00"
@switch.table.get_type = [8 x i8*] [i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0)]
@switch.table.get_type.8 = [8 x i8*] [i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0)]
define i8* @get_type(i32 %0, i32 %1) {
%3 = add i32 %1, -1
%4 = icmp ult i32 %3, 8
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = icmp eq i32 %0, 0
%7 = select i1 %6, [8 x i8*]* @switch.table.get_type.8, [8 x i8*]* @switch.table.get_type
%8 = sext i32 %3 to i64
%9 = getelementptr inbounds [8 x i8*], [8 x i8*]* %7, i64 0, i64 %8
%10 = load i8*, i8** %9
br label %11
11: ; preds = %2, %5
%12 = phi i8* [ %10, %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %2 ]
ret i8* %12
}