unsigned char compute_CNo(unsigned long avg) {
  const unsigned long CNo_table[60] = {
      1,      249,    280,    314,    352,    395,   443,   497,   557,
      625,    702,    787,    883,    991,    1112,  1247,  1399,  1570,
      1762,   1976,   2217,   2488,   2792,   3132,  3514,  3943,  4424,
      4964,   5569,   6249,   7011,   7867,   8826,  9903,  11112, 12467,
      13989,  15695,  17611,  19759,  22170,  24875, 27911, 31316, 35137,
      39425,  44235,  49632,  55688,  62483,  70107, 78662, 88260, 99029,
      111112, 124670, 139882, 156950, 176101, 197589};
  int i;
  unsigned char CNo = 0;
  CNo = 60;
  for (i = 0; i < 61; i++) {
    if (avg < CNo_table[i]) {
      CNo = i;
      break;
    }
  }
  return CNo;
}


x86 assembly (clang, -O0):
<compute_CNo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x1f0(%rbp),%rdi
lea    0xed3(%rip),%rsi
mov    $0x1e0,%edx
call   1030 <memcpy@plt>
movb   $0x0,-0x1f5(%rbp)
movb   $0x3c,-0x1f5(%rbp)
movl   $0x0,-0x1f4(%rbp)
cmpl   $0x3d,-0x1f4(%rbp)
jge    119f <compute_CNo+0x8f>
mov    -0x8(%rbp),%rax
movslq -0x1f4(%rbp),%rcx
cmp    -0x1f0(%rbp,%rcx,8),%rax
ff
jae    1186 <compute_CNo+0x76>
mov    -0x1f4(%rbp),%eax
mov    %al,-0x1f5(%rbp)
jmp    119f <compute_CNo+0x8f>
jmp    118b <compute_CNo+0x7b>
mov    -0x1f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f4(%rbp)
jmp    114f <compute_CNo+0x3f>
movzbl -0x1f5(%rbp),%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_CNo>:
mov    $0x3,%eax
lea    0xef4(%rip),%rcx
cmp    %rdi,-0x18(%rcx,%rax,8)
ja     1145 <compute_CNo+0x45>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x3f,%rax
je     114a <compute_CNo+0x4a>
cmp    %rdi,-0x10(%rcx,%rax,8)
ja     114d <compute_CNo+0x4d>
cmp    %rdi,-0x8(%rcx,%rax,8)
ja     1152 <compute_CNo+0x52>
cmp    %rdi,(%rcx,%rax,8)
ja     114c <compute_CNo+0x4c>
add    $0x4,%rax
cmp    %rdi,-0x18(%rcx,%rax,8)
jbe    1120 <compute_CNo+0x20>
add    $0xfffffffffffffffd,%rax
ret
mov    $0x3c,%al
ret
add    $0xfffffffffffffffe,%rax
ret
add    $0xffffffffffffffff,%rax
ret

LLVM IR (-O0):
@__const.compute_CNo.CNo_table = [60 x i64] [i64 1, i64 249, i64 280, i64 314, i64 352, i64 395, i64 443, i64 497, i64 557, i64 625, i64 702, i64 787, i64 883, i64 991, i64 1112, i64 1247, i64 1399, i64 1570, i64 1762, i64 1976, i64 2217, i64 2488, i64 2792, i64 3132, i64 3514, i64 3943, i64 4424, i64 4964, i64 5569, i64 6249, i64 7011, i64 7867, i64 8826, i64 9903, i64 11112, i64 12467, i64 13989, i64 15695, i64 17611, i64 19759, i64 22170, i64 24875, i64 27911, i64 31316, i64 35137, i64 39425, i64 44235, i64 49632, i64 55688, i64 62483, i64 70107, i64 78662, i64 88260, i64 99029, i64 111112, i64 124670, i64 139882, i64 156950, i64 176101, i64 197589]
define zeroext i8 @compute_CNo(i64 %0) {
%2 = alloca i64
%3 = alloca [60 x i64]
%4 = alloca i32
%5 = alloca i8
store i64 %0, i64* %2
%6 = bitcast [60 x i64]* %3 to i8*
store i8 0, i8* %5
store i8 60, i8* %5
store i32 0, i32* %4
br label %7
7: ; preds = %21, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 61
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = load i64, i64* %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [60 x i64], [60 x i64]* %3, i64 0, i64 %13
%15 = load i64, i64* %14
%16 = icmp ult i64 %11, %15
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i32, i32* %4
%19 = trunc i32 %18 to i8
store i8 %19, i8* %5
br label %24
20: ; preds = %10
br label %21
21: ; preds = %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %7
24: ; preds = %17, %7
%25 = load i8, i8* %5
ret i8 %25
}

LLVM IR (-O2):
@__const.compute_CNo.CNo_table = [60 x i64] [i64 1, i64 249, i64 280, i64 314, i64 352, i64 395, i64 443, i64 497, i64 557, i64 625, i64 702, i64 787, i64 883, i64 991, i64 1112, i64 1247, i64 1399, i64 1570, i64 1762, i64 1976, i64 2217, i64 2488, i64 2792, i64 3132, i64 3514, i64 3943, i64 4424, i64 4964, i64 5569, i64 6249, i64 7011, i64 7867, i64 8826, i64 9903, i64 11112, i64 12467, i64 13989, i64 15695, i64 17611, i64 19759, i64 22170, i64 24875, i64 27911, i64 31316, i64 35137, i64 39425, i64 44235, i64 49632, i64 55688, i64 62483, i64 70107, i64 78662, i64 88260, i64 99029, i64 111112, i64 124670, i64 139882, i64 156950, i64 176101, i64 197589]
define zeroext i8 @compute_CNo(i64 %0) {
br label %2
2: ; preds = %27, %1
%3 = phi i64 [ 0, %1 ], [ %28, %27 ]
%4 = getelementptr inbounds [60 x i64], [60 x i64]* @__const.compute_CNo.CNo_table, i64 0, i64 %3
%5 = load i64, i64* %4
%6 = icmp ugt i64 %5, %0
br i1 %6, label %7, label %10
7: ; preds = %22, %17, %13, %2
%8 = phi i64 [ %3, %2 ], [ %11, %13 ], [ %18, %17 ], [ %23, %22 ]
%9 = trunc i64 %8 to i8
br label %29
10: ; preds = %2
%11 = or i64 %3, 1
%12 = icmp eq i64 %11, 61
br i1 %12, label %29, label %13
13: ; preds = %10
%14 = getelementptr inbounds [60 x i64], [60 x i64]* @__const.compute_CNo.CNo_table, i64 0, i64 %11
%15 = load i64, i64* %14
%16 = icmp ugt i64 %15, %0
br i1 %16, label %7, label %17
17: ; preds = %13
%18 = or i64 %3, 2
%19 = getelementptr inbounds [60 x i64], [60 x i64]* @__const.compute_CNo.CNo_table, i64 0, i64 %18
%20 = load i64, i64* %19
%21 = icmp ugt i64 %20, %0
br i1 %21, label %7, label %22
22: ; preds = %17
%23 = or i64 %3, 3
%24 = getelementptr inbounds [60 x i64], [60 x i64]* @__const.compute_CNo.CNo_table, i64 0, i64 %23
%25 = load i64, i64* %24
%26 = icmp ugt i64 %25, %0
br i1 %26, label %7, label %27
27: ; preds = %22
%28 = add nuw nsw i64 %3, 4
br label %2
29: ; preds = %10, %7
%30 = phi i8 [ %9, %7 ], [ 60, %10 ]
ret i8 %30
}