int calc_nipib(int size) {
  int i;
  static struct {
    int size;
    int nipib;
  } v[] = {{8, 50},  {16, 40}, {32, 30},  {64, 20}, {128, 10},
           {256, 6}, {512, 6}, {1024, 5}, {2048, 5}};
  for (i = 0; i < (sizeof(v) / sizeof(*v)); i++)
    if (size <= v[i].size)
      return v[i].nipib;
  return 1;
}


x86 assembly (clang, -O0):
<calc_nipib>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0x9,%rax
jae    115d <calc_nipib+0x5d>
mov    -0x8(%rbp),%eax
movslq -0xc(%rbp),%rdx
lea    0x2f06(%rip),%rcx
cmp    (%rcx,%rdx,8),%eax
jg     114a <calc_nipib+0x4a>
movslq -0xc(%rbp),%rcx
lea    0x2ef2(%rip),%rax
mov    0x4(%rax,%rcx,8),%eax
mov    %eax,-0x4(%rbp)
jmp    1164 <calc_nipib+0x64>
jmp    114f <calc_nipib+0x4f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110e <calc_nipib+0xe>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_nipib>:
cmp    $0x8,%edi
jle    116a <calc_nipib+0x6a>
mov    $0x1,%ecx
cmp    $0x11,%edi
jb     116c <calc_nipib+0x6c>
mov    $0x2,%ecx
cmp    $0x21,%edi
jb     116c <calc_nipib+0x6c>
mov    $0x3,%ecx
cmp    $0x41,%edi
jb     116c <calc_nipib+0x6c>
mov    $0x4,%ecx
cmp    $0x81,%edi
jb     116c <calc_nipib+0x6c>
mov    $0x5,%ecx
cmp    $0x101,%edi
jb     116c <calc_nipib+0x6c>
mov    $0x6,%ecx
cmp    $0x201,%edi
jb     116c <calc_nipib+0x6c>
mov    $0x7,%ecx
cmp    $0x401,%edi
jb     116c <calc_nipib+0x6c>
mov    $0x8,%ecx
mov    $0x1,%eax
cmp    $0x801,%edi
jb     116c <calc_nipib+0x6c>
ret
xor    %ecx,%ecx
lea    0xe8d(%rip),%rax
mov    0x4(%rax,%rcx,8),%eax
ret

LLVM IR (-O0):
%struct.anon = type { i32, i32 }
@calc_nipib.v = internal global [9 x %struct.anon] [%struct.anon { i32 8, i32 50 }, %struct.anon { i32 16, i32 40 }, %struct.anon { i32 32, i32 30 }, %struct.anon { i32 64, i32 20 }, %struct.anon { i32 128, i32 10 }, %struct.anon { i32 256, i32 6 }, %struct.anon { i32 512, i32 6 }, %struct.anon { i32 1024, i32 5 }, %struct.anon { i32 2048, i32 5 }]
define i32 @calc_nipib(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = icmp ult i64 %7, 9
br i1 %8, label %9, label %27
9: ; preds = %5
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* @calc_nipib.v, i64 0, i64 %12
%14 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = icmp sle i32 %10, %15
br i1 %16, label %17, label %23
17: ; preds = %9
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* @calc_nipib.v, i64 0, i64 %19
%21 = getelementptr inbounds %struct.anon, %struct.anon* %20, i32 0, i32 1
%22 = load i32, i32* %21
store i32 %22, i32* %2
br label %28
23: ; preds = %9
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
store i32 1, i32* %2
br label %28
28: ; preds = %27, %17
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
%struct.anon = type { i32, i32 }
@calc_nipib.v = internal unnamed_addr constant [9 x %struct.anon] [%struct.anon { i32 8, i32 50 }, %struct.anon { i32 16, i32 40 }, %struct.anon { i32 32, i32 30 }, %struct.anon { i32 64, i32 20 }, %struct.anon { i32 128, i32 10 }, %struct.anon { i32 256, i32 6 }, %struct.anon { i32 512, i32 6 }, %struct.anon { i32 1024, i32 5 }, %struct.anon { i32 2048, i32 5 }]
define i32 @calc_nipib(i32 %0) {
%2 = icmp sgt i32 %0, 8
br i1 %2, label %7, label %3
3: ; preds = %21, %19, %17, %15, %13, %11, %9, %7, %1
%4 = phi i64 [ 0, %1 ], [ 1, %7 ], [ 2, %9 ], [ 3, %11 ], [ 4, %13 ], [ 5, %15 ], [ 6, %17 ], [ 7, %19 ], [ 8, %21 ]
%5 = getelementptr inbounds [9 x %struct.anon], [9 x %struct.anon]* @calc_nipib.v, i64 0, i64 %4, i32 1
%6 = load i32, i32* %5
br label %23
7: ; preds = %1
%8 = icmp ugt i32 %0, 16
br i1 %8, label %9, label %3
9: ; preds = %7
%10 = icmp ugt i32 %0, 32
br i1 %10, label %11, label %3
11: ; preds = %9
%12 = icmp ugt i32 %0, 64
br i1 %12, label %13, label %3
13: ; preds = %11
%14 = icmp ugt i32 %0, 128
br i1 %14, label %15, label %3
15: ; preds = %13
%16 = icmp ugt i32 %0, 256
br i1 %16, label %17, label %3
17: ; preds = %15
%18 = icmp ugt i32 %0, 512
br i1 %18, label %19, label %3
19: ; preds = %17
%20 = icmp ugt i32 %0, 1024
br i1 %20, label %21, label %3
21: ; preds = %19
%22 = icmp ugt i32 %0, 2048
br i1 %22, label %23, label %3
23: ; preds = %21, %3
%24 = phi i32 [ %6, %3 ], [ 1, %21 ]
ret i32 %24
}