int GameLevelFromScreen(int screen) {
  int levels[10] = {8, 15, 22, 29, 36, 43, 50, 55, 62, 70};
  for (int i = 0; i < 10; ++i) {
    if (levels[i] > screen)
      return i + 1;
  }
  return 10;
}


x86 assembly (clang, -O0):
<GameLevelFromScreen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeda(%rip),%rsi
mov    $0x28,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1173 <GameLevelFromScreen+0x63>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0x8(%rbp),%eax
jle    1160 <GameLevelFromScreen+0x50>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    117a <GameLevelFromScreen+0x6a>
jmp    1165 <GameLevelFromScreen+0x55>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1137 <GameLevelFromScreen+0x27>
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GameLevelFromScreen>:
mov    $0x1,%eax
cmp    $0x8,%edi
jl     115b <GameLevelFromScreen+0x5b>
mov    $0x2,%eax
cmp    $0xf,%edi
jb     115b <GameLevelFromScreen+0x5b>
mov    $0x3,%eax
cmp    $0x16,%edi
jb     115b <GameLevelFromScreen+0x5b>
mov    $0x4,%eax
cmp    $0x1d,%edi
jb     115b <GameLevelFromScreen+0x5b>
mov    $0x5,%eax
cmp    $0x24,%edi
jb     115b <GameLevelFromScreen+0x5b>
mov    $0x6,%eax
cmp    $0x2b,%edi
jb     115b <GameLevelFromScreen+0x5b>
mov    $0x7,%eax
cmp    $0x32,%edi
jb     115b <GameLevelFromScreen+0x5b>
mov    $0x8,%eax
cmp    $0x37,%edi
jb     115b <GameLevelFromScreen+0x5b>
cmp    $0x3e,%edi
mov    $0xa,%eax
sbb    $0x0,%eax
ret

LLVM IR (-O0):
@__const.GameLevelFromScreen.levels = [10 x i32] [i32 8, i32 15, i32 22, i32 29, i32 36, i32 43, i32 50, i32 55, i32 62, i32 70]
define i32 @GameLevelFromScreen(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca i32
store i32 %0, i32* %3
%6 = bitcast [10 x i32]* %4 to i8*
store i32 0, i32* %5
br label %7
7: ; preds = %21, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = load i32, i32* %3
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %25
20: ; preds = %10
br label %21
21: ; preds = %20
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %7
24: ; preds = %7
store i32 10, i32* %2
br label %25
25: ; preds = %24, %17
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
define i32 @GameLevelFromScreen(i32 %0) {
%2 = icmp slt i32 %0, 8
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 15
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 22
br i1 %6, label %20, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 29
br i1 %8, label %20, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 36
br i1 %10, label %20, label %11
11: ; preds = %9
%12 = icmp ult i32 %0, 43
br i1 %12, label %20, label %13
13: ; preds = %11
%14 = icmp ult i32 %0, 50
br i1 %14, label %20, label %15
15: ; preds = %13
%16 = icmp ult i32 %0, 55
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = icmp ult i32 %0, 62
%19 = select i1 %18, i32 9, i32 10
br label %20
20: ; preds = %17, %1, %3, %5, %7, %9, %11, %13, %15
%21 = phi i32 [ 1, %1 ], [ 2, %3 ], [ 3, %5 ], [ 4, %7 ], [ 5, %9 ], [ 6, %11 ], [ 7, %13 ], [ 8, %15 ], [ %19, %17 ]
ret i32 %21
}