int grbBitsPerValue(int datatype) {
  int bitsPerValue = 16;
  if (datatype == 64 || datatype == 128)
    Error_(__func__, "CDI/GRIB library does not support complex numbers!");
  if (datatype != -1) {
    if (datatype > 0 && datatype <= 32)
      bitsPerValue = datatype;
    else if (datatype == 164)
      bitsPerValue = 24;
    else
      bitsPerValue = 16;
  }
  return (bitsPerValue);
}


x86 assembly (clang, -O0):
<grbBitsPerValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x10,-0x8(%rbp)
cmpl   $0x40,-0x4(%rbp)
je     1139 <grbBitsPerValue+0x29>
cmpl   $0x80,-0x4(%rbp)
jne    114e <grbBitsPerValue+0x3e>
lea    0xec0(%rip),%rdi
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <Error_@plt>
cmpl   $0xffffffff,-0x4(%rbp)
je     11a1 <grbBitsPerValue+0x91>
cmpl   $0x0,-0x4(%rbp)
jle    1177 <grbBitsPerValue+0x67>
cmpl   $0x20,-0x4(%rbp)
jg     1177 <grbBitsPerValue+0x67>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    119c <grbBitsPerValue+0x8c>
cmpl   $0xa4,-0x4(%rbp)
jne    1190 <grbBitsPerValue+0x80>
movl   $0x18,-0x8(%rbp)
jmp    1197 <grbBitsPerValue+0x87>
movl   $0x10,-0x8(%rbp)
jmp    119c <grbBitsPerValue+0x8c>
jmp    11a1 <grbBitsPerValue+0x91>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grbBitsPerValue>:
push   %rbx
cmp    $0xffffffff,%edi
je     113c <grbBitsPerValue+0x2c>
mov    %edi,%ebx
cmp    $0x80,%edi
je     1125 <grbBitsPerValue+0x15>
cmp    $0x40,%ebx
jne    1143 <grbBitsPerValue+0x33>
lea    0xed4(%rip),%rdi
lea    0xedd(%rip),%rsi
xor    %eax,%eax
call   1030 <Error_@plt>
jmp    114b <grbBitsPerValue+0x3b>
mov    $0x10,%ebx
jmp    115d <grbBitsPerValue+0x4d>
lea    -0x1(%rbx),%eax
cmp    $0x20,%eax
jb     115d <grbBitsPerValue+0x4d>
xor    %eax,%eax
cmp    $0xa4,%ebx
sete   %al
lea    0x10(,%rax,8),%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__func__.grbBitsPerValue = [16 x i8] c"grbBitsPerValue\00"
@.str = [51 x i8] c"CDI/GRIB library does not support complex numbers!\00"
define i32 @grbBitsPerValue(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 16, i32* %3
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 64
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 128
br i1 %8, label %9, label %11
9: ; preds = %6, %1
%10 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Error_ to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.grbBitsPerValue, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp sle i32 %18, 32
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32, i32* %2
store i32 %21, i32* %3
br label %28
22: ; preds = %17, %14
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 164
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 24, i32* %3
br label %27
26: ; preds = %22
store i32 16, i32* %3
br label %27
27: ; preds = %26, %25
br label %28
28: ; preds = %27, %20
br label %29
29: ; preds = %28, %11
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@__func__.grbBitsPerValue = [16 x i8] c"grbBitsPerValue\00"
@.str = [51 x i8] c"CDI/GRIB library does not support complex numbers!\00"
define i32 @grbBitsPerValue(i32 %0) {
switch i32 %0, label %4 [
i32 128, label %2
i32 64, label %2
i32 -1, label %10
]
2: ; preds = %1, %1
%3 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Error_ to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.grbBitsPerValue, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %7
4: ; preds = %1
%5 = add i32 %0, -1
%6 = icmp ult i32 %5, 32
br i1 %6, label %10, label %7
7: ; preds = %2, %4
%8 = icmp eq i32 %0, 164
%9 = select i1 %8, i32 24, i32 16
br label %10
10: ; preds = %7, %4, %1
%11 = phi i32 [ 16, %1 ], [ %0, %4 ], [ %9, %7 ]
ret i32 %11
}