#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 */
const char *d64Extension(int filetype) {
  int ft;
  const char *exten = NULL;
  ft = filetype & 0x0f;
  switch (ft) {
  case 0x00:
    exten = "DEL";
    break;
  case 0x01:
    exten = "SEQ";
    break;
  case 0x02:
    exten = "PRG";
    break;
  case 0x03:
    exten = "USR";
    break;
  case 0x04:
    exten = "REL";
    break;
  }
  return exten;
}


x86 assembly (clang, -O0):
<d64Extension>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     1188 <d64Extension+0x88>
mov    -0x18(%rbp),%rax
lea    0xecc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1188 <d64Extension+0x88>
lea    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1188 <d64Extension+0x88>
lea    0xeb8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1188 <d64Extension+0x88>
lea    0xeac(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1188 <d64Extension+0x88>
lea    0xea0(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<d64Extension>:
and    $0xf,%edi
cmp    $0x4,%edi
ja     1119 <d64Extension+0x19>
mov    %edi,%eax
lea    0xf03(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"DEL\00"
@.str.1 = [4 x i8] c"SEQ\00"
@.str.2 = [4 x i8] c"PRG\00"
@.str.3 = [4 x i8] c"USR\00"
@.str.4 = [4 x i8] c"REL\00"
define i8* @d64Extension(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i8* null, i8** %4
%5 = load i32, i32* %2
%6 = and i32 %5, 15
store i32 %6, i32* %3
%7 = load i32, i32* %3
switch i32 %7, label %13 [
i32 0, label %8
i32 1, label %9
i32 2, label %10
i32 3, label %11
i32 4, label %12
]
8: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %4
br label %13
9: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %13
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %13
11: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %4
br label %13
12: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %4
br label %13
13: ; preds = %1, %12, %11, %10, %9, %8
%14 = load i8*, i8** %4
ret i8* %14
}

LLVM IR (-O2):
@.str = [4 x i8] c"DEL\00"
@.str.1 = [4 x i8] c"SEQ\00"
@.str.2 = [4 x i8] c"PRG\00"
@.str.3 = [4 x i8] c"USR\00"
@.str.4 = [4 x i8] c"REL\00"
@reltable.d64Extension = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([5 x i32]* @reltable.d64Extension to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([5 x i32]* @reltable.d64Extension to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([5 x i32]* @reltable.d64Extension to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.d64Extension to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.d64Extension to i64)) to i32)]
define i8* @d64Extension(i32 %0) {
%2 = and i32 %0, 15
%3 = icmp ult i32 %2, 5
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.d64Extension to i8*), i64 %6)
br label %8
8: ; preds = %4, %1
%9 = phi i8* [ null, %1 ], [ %7, %4 ]
ret i8* %9
}