#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int u_int16_t;
typedef int u_int;

/* Variables and functions */
u_int ieee80211_mhz2ieee(u_int16_t freq) {
  if (freq == 2484)
    return 14;
  if (freq < 2484)
    return (freq - 2407) / 5;
  if (freq < 5000) {
    if (((freq) > 4940 && (freq) < 4990)) {
      return ((freq * 10) + (((freq % 5) == 2) ? 5 : 0) - 49400) / 5;
    } else if (freq > 4900) {
      return (freq - 4000) / 5;
    } else {
      return 15 + ((freq - 2512) / 20);
    }
  }
  return (freq - 5000) / 5;
}


x86 assembly (clang, -O0):
<ieee80211_mhz2ieee>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x9b4,-0x8(%rbp)
jne    1120 <ieee80211_mhz2ieee+0x20>
movl   $0xe,-0x4(%rbp)
jmp    11fa <ieee80211_mhz2ieee+0xfa>
cmpl   $0x9b4,-0x8(%rbp)
jge    1145 <ieee80211_mhz2ieee+0x45>
mov    -0x8(%rbp),%eax
sub    $0x967,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11fa <ieee80211_mhz2ieee+0xfa>
cmpl   $0x1388,-0x8(%rbp)
jge    11e7 <ieee80211_mhz2ieee+0xe7>
cmpl   $0x134c,-0x8(%rbp)
jle    11a7 <ieee80211_mhz2ieee+0xa7>
cmpl   $0x137e,-0x8(%rbp)
jge    11a7 <ieee80211_mhz2ieee+0xa7>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0xc(%rbp),%eax
mov    %edx,%esi
xor    %ecx,%ecx
mov    $0x5,%edx
cmp    $0x2,%esi
cmove  %edx,%ecx
add    %ecx,%eax
sub    $0xc0f8,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11fa <ieee80211_mhz2ieee+0xfa>
cmpl   $0x1324,-0x8(%rbp)
jle    11cc <ieee80211_mhz2ieee+0xcc>
mov    -0x8(%rbp),%eax
sub    $0xfa0,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11fa <ieee80211_mhz2ieee+0xfa>
mov    -0x8(%rbp),%eax
sub    $0x9d0,%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
add    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    11fa <ieee80211_mhz2ieee+0xfa>
mov    -0x8(%rbp),%eax
sub    $0x1388,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ieee80211_mhz2ieee>:
mov    $0xe,%eax
cmp    $0x9b4,%edi
jne    110e <ieee80211_mhz2ieee+0xe>
ret
jge    112e <ieee80211_mhz2ieee+0x2e>
add    $0xfffff699,%edi
movslq %edi,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
ret
cmp    $0x1387,%edi
ja     116e <ieee80211_mhz2ieee+0x6e>
lea    -0x134d(%rdi),%eax
cmp    $0x30,%eax
ja     1182 <ieee80211_mhz2ieee+0x82>
lea    (%rdi,%rdi,4),%eax
imul   $0xffffcccd,%edi,%ecx
add    $0x6666,%ecx
movzwl %cx,%ecx
xor    %edx,%edx
cmp    $0x3333,%ecx
setb   %dl
lea    (%rdx,%rdx,4),%ecx
lea    (%rcx,%rax,2),%eax
add    $0x3f08,%eax
movzwl %ax,%eax
jmp    1193 <ieee80211_mhz2ieee+0x93>
add    $0xffffec78,%edi
mov    $0xcccccccd,%eax
imul   %rdi,%rax
shr    $0x22,%rax
ret
cmp    $0x1325,%edi
jb     119d <ieee80211_mhz2ieee+0x9d>
add    $0xfffff060,%edi
movzwl %di,%eax
imul   $0xcccd,%eax,%eax
shr    $0x12,%eax
ret
add    $0xfffff630,%edi
movswl %di,%eax
imul   $0x6667,%eax,%eax
mov    %eax,%ecx
sar    $0x13,%ecx
shr    $0x1f,%eax
add    %ecx,%eax
add    $0xf,%eax
movzwl %ax,%eax
ret

LLVM IR (-O0):
define i32 @ieee80211_mhz2ieee(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 2484
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 14, i32* %2
br label %50
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 2484
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sub nsw i32 %11, 2407
%13 = sdiv i32 %12, 5
store i32 %13, i32* %2
br label %50
14: ; preds = %7
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 5000
br i1 %16, label %17, label %46
17: ; preds = %14
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 4940
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 4990
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load i32, i32* %3
%25 = mul nsw i32 %24, 10
%26 = load i32, i32* %3
%27 = srem i32 %26, 5
%28 = icmp eq i32 %27, 2
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 5, i32 0
%31 = add nsw i32 %25, %30
%32 = sub nsw i32 %31, 49400
%33 = sdiv i32 %32, 5
store i32 %33, i32* %2
br label %50
34: ; preds = %20, %17
%35 = load i32, i32* %3
%36 = icmp sgt i32 %35, 4900
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32, i32* %3
%39 = sub nsw i32 %38, 4000
%40 = sdiv i32 %39, 5
store i32 %40, i32* %2
br label %50
41: ; preds = %34
%42 = load i32, i32* %3
%43 = sub nsw i32 %42, 2512
%44 = sdiv i32 %43, 20
%45 = add nsw i32 15, %44
store i32 %45, i32* %2
br label %50
46: ; preds = %14
%47 = load i32, i32* %3
%48 = sub nsw i32 %47, 5000
%49 = sdiv i32 %48, 5
store i32 %49, i32* %2
br label %50
50: ; preds = %46, %41, %37, %23, %10, %6
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
define i32 @ieee80211_mhz2ieee(i32 %0) {
%2 = icmp eq i32 %0, 2484
br i1 %2, label %39, label %3
3: ; preds = %1
%4 = icmp slt i32 %0, 2484
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = add nsw i32 %0, -2407
%7 = sdiv i32 %6, 5
br label %39
8: ; preds = %3
%9 = icmp ult i32 %0, 5000
br i1 %9, label %10, label %36
10: ; preds = %8
%11 = add nsw i32 %0, -4941
%12 = icmp ult i32 %11, 49
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = mul nuw nsw i32 %0, 10
%15 = trunc i32 %0 to i16
%16 = urem i16 %15, 5
%17 = icmp eq i16 %16, 2
%18 = select i1 %17, i32 5, i32 0
%19 = add nuw nsw i32 %18, %14
%20 = trunc i32 %19 to i16
%21 = add nsw i16 %20, 16136
%22 = udiv i16 %21, 5
%23 = zext i16 %22 to i32
br label %39
24: ; preds = %10
%25 = icmp ugt i32 %0, 4900
%26 = trunc i32 %0 to i16
br i1 %25, label %27, label %31
27: ; preds = %24
%28 = add nsw i16 %26, -4000
%29 = udiv i16 %28, 5
%30 = zext i16 %29 to i32
br label %39
31: ; preds = %24
%32 = add nsw i16 %26, -2512
%33 = sdiv i16 %32, 20
%34 = add nsw i16 %33, 15
%35 = zext i16 %34 to i32
br label %39
36: ; preds = %8
%37 = add nsw i32 %0, -5000
%38 = udiv i32 %37, 5
br label %39
39: ; preds = %1, %36, %31, %27, %13, %5
%40 = phi i32 [ %7, %5 ], [ %23, %13 ], [ %30, %27 ], [ %35, %31 ], [ %38, %36 ], [ 14, %1 ]
ret i32 %40
}