int hand_rank(short val) {
  if (val > 6185)
    return (9);
  if (val > 3325)
    return (8);
  if (val > 2467)
    return (7);
  if (val > 1609)
    return (6);
  if (val > 1599)
    return (5);
  if (val > 322)
    return (4);
  if (val > 166)
    return (3);
  if (val > 10)
    return (2);
  return (1);
}


x86 assembly (clang, -O0):
<hand_rank>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x6(%rbp)
movswl -0x6(%rbp),%eax
cmp    $0x1829,%eax
jle    1126 <hand_rank+0x26>
movl   $0x9,-0x4(%rbp)
jmp    11e8 <hand_rank+0xe8>
movswl -0x6(%rbp),%eax
cmp    $0xcfd,%eax
jle    1141 <hand_rank+0x41>
movl   $0x8,-0x4(%rbp)
jmp    11e8 <hand_rank+0xe8>
movswl -0x6(%rbp),%eax
cmp    $0x9a3,%eax
jle    115c <hand_rank+0x5c>
movl   $0x7,-0x4(%rbp)
jmp    11e8 <hand_rank+0xe8>
movswl -0x6(%rbp),%eax
cmp    $0x649,%eax
jle    1177 <hand_rank+0x77>
movl   $0x6,-0x4(%rbp)
jmp    11e8 <hand_rank+0xe8>
movswl -0x6(%rbp),%eax
cmp    $0x63f,%eax
jle    1192 <hand_rank+0x92>
movl   $0x5,-0x4(%rbp)
jmp    11e8 <hand_rank+0xe8>
movswl -0x6(%rbp),%eax
cmp    $0x142,%eax
jle    11ad <hand_rank+0xad>
movl   $0x4,-0x4(%rbp)
jmp    11e8 <hand_rank+0xe8>
movswl -0x6(%rbp),%eax
cmp    $0xa6,%eax
jle    11c8 <hand_rank+0xc8>
movl   $0x3,-0x4(%rbp)
jmp    11e8 <hand_rank+0xe8>
movswl -0x6(%rbp),%eax
cmp    $0xa,%eax
jle    11e1 <hand_rank+0xe1>
movl   $0x2,-0x4(%rbp)
jmp    11e8 <hand_rank+0xe8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hand_rank>:
mov    $0x9,%eax
cmp    $0x1829,%edi
jg     116a <hand_rank+0x6a>
movswl %di,%ecx
mov    $0x8,%eax
cmp    $0xcfd,%ecx
jg     116a <hand_rank+0x6a>
mov    $0x7,%eax
cmp    $0x9a3,%ecx
jg     116a <hand_rank+0x6a>
mov    $0x6,%eax
cmp    $0x649,%ecx
jg     116a <hand_rank+0x6a>
mov    $0x5,%eax
cmp    $0x63f,%ecx
jg     116a <hand_rank+0x6a>
mov    $0x4,%eax
cmp    $0x142,%ecx
jg     116a <hand_rank+0x6a>
mov    $0x3,%eax
cmp    $0xa6,%ecx
jg     116a <hand_rank+0x6a>
xor    %eax,%eax
cmp    $0xb,%di
setge  %al
add    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @hand_rank(i16 signext %0) {
%2 = alloca i32
%3 = alloca i16
store i16 %0, i16* %3
%4 = load i16, i16* %3
%5 = sext i16 %4 to i32
%6 = icmp sgt i32 %5, 6185
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 9, i32* %2
br label %44
8: ; preds = %1
%9 = load i16, i16* %3
%10 = sext i16 %9 to i32
%11 = icmp sgt i32 %10, 3325
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 8, i32* %2
br label %44
13: ; preds = %8
%14 = load i16, i16* %3
%15 = sext i16 %14 to i32
%16 = icmp sgt i32 %15, 2467
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 7, i32* %2
br label %44
18: ; preds = %13
%19 = load i16, i16* %3
%20 = sext i16 %19 to i32
%21 = icmp sgt i32 %20, 1609
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 6, i32* %2
br label %44
23: ; preds = %18
%24 = load i16, i16* %3
%25 = sext i16 %24 to i32
%26 = icmp sgt i32 %25, 1599
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 5, i32* %2
br label %44
28: ; preds = %23
%29 = load i16, i16* %3
%30 = sext i16 %29 to i32
%31 = icmp sgt i32 %30, 322
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 4, i32* %2
br label %44
33: ; preds = %28
%34 = load i16, i16* %3
%35 = sext i16 %34 to i32
%36 = icmp sgt i32 %35, 166
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 3, i32* %2
br label %44
38: ; preds = %33
%39 = load i16, i16* %3
%40 = sext i16 %39 to i32
%41 = icmp sgt i32 %40, 10
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 2, i32* %2
br label %44
43: ; preds = %38
store i32 1, i32* %2
br label %44
44: ; preds = %43, %42, %37, %32, %27, %22, %17, %12, %7
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
define i32 @hand_rank(i16 signext %0) {
%2 = icmp sgt i16 %0, 6185
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = icmp sgt i16 %0, 3325
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = icmp sgt i16 %0, 2467
br i1 %6, label %18, label %7
7: ; preds = %5
%8 = icmp sgt i16 %0, 1609
br i1 %8, label %18, label %9
9: ; preds = %7
%10 = icmp sgt i16 %0, 1599
br i1 %10, label %18, label %11
11: ; preds = %9
%12 = icmp sgt i16 %0, 322
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = icmp sgt i16 %0, 166
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = icmp sgt i16 %0, 10
%17 = select i1 %16, i32 2, i32 1
br label %18
18: ; preds = %15, %13, %11, %9, %7, %5, %3, %1
%19 = phi i32 [ 9, %1 ], [ 8, %3 ], [ 7, %5 ], [ 6, %7 ], [ 5, %9 ], [ 4, %11 ], [ 3, %13 ], [ %17, %15 ]
ret i32 %19
}