int getChannelFromFrequency(int frequency) {
  if (frequency >= 2412 && frequency <= 2472)
    return (frequency - 2407) / 5;
  else if (frequency == 2484)
    return 14;
  else if (frequency >= 5000 && frequency <= 6100)
    return (frequency - 5000) / 5;
  else
    return -1;
}


x86 assembly (clang, -O0):
<getChannelFromFrequency>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x96c,-0x8(%rbp)
jl     1139 <getChannelFromFrequency+0x39>
cmpl   $0x9a8,-0x8(%rbp)
jg     1139 <getChannelFromFrequency+0x39>
mov    -0x8(%rbp),%eax
sub    $0x967,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    118b <getChannelFromFrequency+0x8b>
cmpl   $0x9b4,-0x8(%rbp)
jne    1152 <getChannelFromFrequency+0x52>
movl   $0xe,-0x4(%rbp)
jmp    118b <getChannelFromFrequency+0x8b>
cmpl   $0x1388,-0x8(%rbp)
jl     1184 <getChannelFromFrequency+0x84>
cmpl   $0x17d4,-0x8(%rbp)
jg     1184 <getChannelFromFrequency+0x84>
mov    -0x8(%rbp),%eax
sub    $0x1388,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    118b <getChannelFromFrequency+0x8b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getChannelFromFrequency>:
lea    -0x96c(%rdi),%eax
cmp    $0x3c,%eax
ja     111d <getChannelFromFrequency+0x1d>
add    $0x99,%dil
movzbl %dil,%eax
imul   $0xcd,%eax,%eax
shr    $0xa,%eax
ret
mov    $0xe,%eax
cmp    $0x9b4,%edi
je     1149 <getChannelFromFrequency+0x49>
add    $0xffffec78,%edi
mov    $0xffffffff,%eax
cmp    $0x44c,%edi
ja     1149 <getChannelFromFrequency+0x49>
movzwl %di,%eax
imul   $0xcccd,%eax,%eax
shr    $0x12,%eax
ret

LLVM IR (-O0):
define i32 @getChannelFromFrequency(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 2412
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 2472
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 2407
%12 = sdiv i32 %11, 5
store i32 %12, i32* %2
br label %28
13: ; preds = %6, %1
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 2484
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 14, i32* %2
br label %28
17: ; preds = %13
%18 = load i32, i32* %3
%19 = icmp sge i32 %18, 5000
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp sle i32 %21, 6100
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 5000
%26 = sdiv i32 %25, 5
store i32 %26, i32* %2
br label %28
27: ; preds = %20, %17
store i32 -1, i32* %2
br label %28
28: ; preds = %27, %23, %16, %9
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @getChannelFromFrequency(i32 %0) {
%2 = add i32 %0, -2412
%3 = icmp ult i32 %2, 61
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = trunc i32 %0 to i8
%6 = add i8 %5, -103
%7 = udiv i8 %6, 5
%8 = zext i8 %7 to i32
br label %18
9: ; preds = %1
%10 = icmp eq i32 %0, 2484
br i1 %10, label %18, label %11
11: ; preds = %9
%12 = add i32 %0, -5000
%13 = icmp ult i32 %12, 1101
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = trunc i32 %12 to i16
%16 = udiv i16 %15, 5
%17 = zext i16 %16 to i32
br label %18
18: ; preds = %11, %9, %14, %4
%19 = phi i32 [ %8, %4 ], [ %17, %14 ], [ 14, %9 ], [ -1, %11 ]
ret i32 %19
}