int sqliterkBtreeGetLengthForSerialType(int serialType) {
  if (serialType < 0) {
    return 0;
  }
  static int sqliterk_btree_serialtype_fixlengths[12] = {0, 1, 2, 3, 4, 6,
                                                         8, 8, 0, 0, 0, 0};
  if (serialType < 12) {
    return sqliterk_btree_serialtype_fixlengths[serialType];
  }
  return (serialType - 12 - serialType % 2) / 2;
}


x86 assembly (clang, -O0):
<sqliterkBtreeGetLengthForSerialType>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    111d <sqliterkBtreeGetLengthForSerialType+0x1d>
movl   $0x0,-0x4(%rbp)
jmp    1161 <sqliterkBtreeGetLengthForSerialType+0x61>
cmpl   $0xc,-0x8(%rbp)
jge    113d <sqliterkBtreeGetLengthForSerialType+0x3d>
movslq -0x8(%rbp),%rcx
lea    0x2efe(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    1161 <sqliterkBtreeGetLengthForSerialType+0x61>
mov    -0x8(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0xc(%rbp),%eax
sub    %edx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqliterkBtreeGetLengthForSerialType>:
test   %edi,%edi
js     1118 <sqliterkBtreeGetLengthForSerialType+0x18>
mov    %edi,%eax
cmp    $0xb,%edi
ja     111b <sqliterkBtreeGetLengthForSerialType+0x1b>
mov    %eax,%eax
lea    0xeec(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret
xor    %eax,%eax
ret
add    $0xfffffff4,%eax
shr    %eax
ret

LLVM IR (-O0):
@sqliterkBtreeGetLengthForSerialType.sqliterk_btree_serialtype_fixlengths = internal global [12 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 6, i32 8, i32 8, i32 0, i32 0, i32 0, i32 0]
define i32 @sqliterkBtreeGetLengthForSerialType(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %2
br label %22
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 12
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [12 x i32], [12 x i32]* @sqliterkBtreeGetLengthForSerialType.sqliterk_btree_serialtype_fixlengths, i64 0, i64 %12
%14 = load i32, i32* %13
store i32 %14, i32* %2
br label %22
15: ; preds = %7
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 12
%18 = load i32, i32* %3
%19 = srem i32 %18, 2
%20 = sub nsw i32 %17, %19
%21 = sdiv i32 %20, 2
store i32 %21, i32* %2
br label %22
22: ; preds = %15, %10, %6
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@sqliterkBtreeGetLengthForSerialType.sqliterk_btree_serialtype_fixlengths = internal unnamed_addr constant [12 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 6, i32 8, i32 8, i32 0, i32 0, i32 0, i32 0]
define i32 @sqliterkBtreeGetLengthForSerialType(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 12
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = zext i32 %0 to i64
%7 = getelementptr inbounds [12 x i32], [12 x i32]* @sqliterkBtreeGetLengthForSerialType.sqliterk_btree_serialtype_fixlengths, i64 0, i64 %6
%8 = load i32, i32* %7
br label %12
9: ; preds = %3
%10 = add nsw i32 %0, -12
%11 = lshr i32 %10, 1
br label %12
12: ; preds = %1, %9, %5
%13 = phi i32 [ %8, %5 ], [ %11, %9 ], [ 0, %1 ]
ret i32 %13
}