int fits_size_from_bitpix_(int *pBitpix) {
  int size;
  if (*pBitpix == 8)
    size = 1;
  else if (*pBitpix == 16)
    size = 2;
  else if (*pBitpix == 32)
    size = 4;
  else if (*pBitpix == 64)
    size = 8;
  else if (*pBitpix == -16)
    size = 2;
  else if (*pBitpix == -32)
    size = 4;
  else if (*pBitpix == -64)
    size = 8;
  else
    size = 0;
  return size;
}


x86 assembly (clang, -O0):
<fits_size_from_bitpix_>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x8,(%rax)
jne    1121 <fits_size_from_bitpix_+0x21>
movl   $0x1,-0xc(%rbp)
jmp    11dc <fits_size_from_bitpix_+0xdc>
mov    -0x8(%rbp),%rax
cmpl   $0x10,(%rax)
jne    113a <fits_size_from_bitpix_+0x3a>
movl   $0x2,-0xc(%rbp)
jmp    11d7 <fits_size_from_bitpix_+0xd7>
mov    -0x8(%rbp),%rax
cmpl   $0x20,(%rax)
jne    1153 <fits_size_from_bitpix_+0x53>
movl   $0x4,-0xc(%rbp)
jmp    11d2 <fits_size_from_bitpix_+0xd2>
mov    -0x8(%rbp),%rax
cmpl   $0x40,(%rax)
jne    116c <fits_size_from_bitpix_+0x6c>
movl   $0x8,-0xc(%rbp)
jmp    11cd <fits_size_from_bitpix_+0xcd>
mov    -0x8(%rbp),%rax
cmpl   $0xfffffff0,(%rax)
jne    1185 <fits_size_from_bitpix_+0x85>
movl   $0x2,-0xc(%rbp)
jmp    11c8 <fits_size_from_bitpix_+0xc8>
mov    -0x8(%rbp),%rax
cmpl   $0xffffffe0,(%rax)
jne    119e <fits_size_from_bitpix_+0x9e>
movl   $0x4,-0xc(%rbp)
jmp    11c3 <fits_size_from_bitpix_+0xc3>
mov    -0x8(%rbp),%rax
cmpl   $0xffffffc0,(%rax)
jne    11b7 <fits_size_from_bitpix_+0xb7>
movl   $0x8,-0xc(%rbp)
jmp    11be <fits_size_from_bitpix_+0xbe>
movl   $0x0,-0xc(%rbp)
jmp    11c3 <fits_size_from_bitpix_+0xc3>
jmp    11c8 <fits_size_from_bitpix_+0xc8>
jmp    11cd <fits_size_from_bitpix_+0xcd>
jmp    11d2 <fits_size_from_bitpix_+0xd2>
jmp    11d7 <fits_size_from_bitpix_+0xd7>
jmp    11dc <fits_size_from_bitpix_+0xdc>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fits_size_from_bitpix_>:
mov    (%rdi),%ecx
add    $0x40,%ecx
rol    $0x1d,%ecx
xor    %eax,%eax
cmp    $0x10,%ecx
ja     111c <fits_size_from_bitpix_+0x1c>
movslq %ecx,%rax
lea    0xee7(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @fits_size_from_bitpix_(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 8
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 1, i32* %3
br label %45
8: ; preds = %1
%9 = load i32*, i32** %2
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 16
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 2, i32* %3
br label %44
13: ; preds = %8
%14 = load i32*, i32** %2
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 4, i32* %3
br label %43
18: ; preds = %13
%19 = load i32*, i32** %2
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 64
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 8, i32* %3
br label %42
23: ; preds = %18
%24 = load i32*, i32** %2
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, -16
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 2, i32* %3
br label %41
28: ; preds = %23
%29 = load i32*, i32** %2
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, -32
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 4, i32* %3
br label %40
33: ; preds = %28
%34 = load i32*, i32** %2
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, -64
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 8, i32* %3
br label %39
38: ; preds = %33
store i32 0, i32* %3
br label %39
39: ; preds = %38, %37
br label %40
40: ; preds = %39, %32
br label %41
41: ; preds = %40, %27
br label %42
42: ; preds = %41, %22
br label %43
43: ; preds = %42, %17
br label %44
44: ; preds = %43, %12
br label %45
45: ; preds = %44, %7
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@switch.table.fits_size_from_bitpix_ = [17 x i32] [i32 8, i32 0, i32 0, i32 0, i32 4, i32 0, i32 2, i32 0, i32 0, i32 1, i32 2, i32 0, i32 4, i32 0, i32 0, i32 0, i32 8]
define i32 @fits_size_from_bitpix_(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = add i32 %2, 64
%4 = tail call i32 @llvm.fshl.i32(i32 %3, i32 %3, i32 29)
%5 = icmp ult i32 %4, 17
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = getelementptr inbounds [17 x i32], [17 x i32]* @switch.table.fits_size_from_bitpix_, i64 0, i64 %7
%9 = load i32, i32* %8
br label %10
10: ; preds = %1, %6
%11 = phi i32 [ %9, %6 ], [ 0, %1 ]
ret i32 %11
}