int ethertype_to_ppptype(proto)
int proto;
{
  switch (proto) {
  case 0x0800:
    proto = 0x0021;
    break;
  case 0x86dd:
    proto = 0x0057;
    break;
  case 0x6003:
    proto = 0x0027;
    break;
  case 0x809b:
    proto = 0x0029;
    break;
  case 0x0600:
    proto = 0x0025;
    break;
  case 0xfe:
    proto = 0x0023;
    break;
  case 0x42:
    proto = 0x0031;
    break;
  case 0xe0:
    proto = 0x002b;
    break;
  }
  return (proto);
}


x86 assembly (clang, -O0):
<ethertype_to_ppptype>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x42,%eax
je     11e8 <ethertype_to_ppptype+0xe8>
jmp    111b <ethertype_to_ppptype+0x1b>
mov    -0x8(%rbp),%eax
sub    $0xe0,%eax
je     11f4 <ethertype_to_ppptype+0xf4>
jmp    112e <ethertype_to_ppptype+0x2e>
mov    -0x8(%rbp),%eax
sub    $0xfe,%eax
je     11dc <ethertype_to_ppptype+0xdc>
jmp    1141 <ethertype_to_ppptype+0x41>
mov    -0x8(%rbp),%eax
sub    $0x600,%eax
je     11d0 <ethertype_to_ppptype+0xd0>
jmp    1154 <ethertype_to_ppptype+0x54>
mov    -0x8(%rbp),%eax
sub    $0x800,%eax
je     11a0 <ethertype_to_ppptype+0xa0>
jmp    1167 <ethertype_to_ppptype+0x67>
mov    -0x8(%rbp),%eax
sub    $0x6003,%eax
je     11b8 <ethertype_to_ppptype+0xb8>
jmp    117a <ethertype_to_ppptype+0x7a>
mov    -0x8(%rbp),%eax
sub    $0x809b,%eax
je     11c4 <ethertype_to_ppptype+0xc4>
jmp    118d <ethertype_to_ppptype+0x8d>
mov    -0x8(%rbp),%eax
sub    $0x86dd,%eax
je     11ac <ethertype_to_ppptype+0xac>
jmp    11fb <ethertype_to_ppptype+0xfb>
movl   $0x21,-0x4(%rbp)
jmp    11fb <ethertype_to_ppptype+0xfb>
movl   $0x57,-0x4(%rbp)
jmp    11fb <ethertype_to_ppptype+0xfb>
movl   $0x27,-0x4(%rbp)
jmp    11fb <ethertype_to_ppptype+0xfb>
movl   $0x29,-0x4(%rbp)
jmp    11fb <ethertype_to_ppptype+0xfb>
movl   $0x25,-0x4(%rbp)
jmp    11fb <ethertype_to_ppptype+0xfb>
movl   $0x23,-0x4(%rbp)
jmp    11fb <ethertype_to_ppptype+0xfb>
movl   $0x31,-0x4(%rbp)
jmp    11fb <ethertype_to_ppptype+0xfb>
movl   $0x2b,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ethertype_to_ppptype>:
mov    %edi,%eax
cmp    $0x7ff,%edi
jg     1123 <ethertype_to_ppptype+0x23>
cmp    $0xfd,%eax
jg     113e <ethertype_to_ppptype+0x3e>
cmp    $0x42,%eax
je     1166 <ethertype_to_ppptype+0x66>
cmp    $0xe0,%eax
jne    116b <ethertype_to_ppptype+0x6b>
mov    $0x2b,%eax
ret
cmp    $0x809a,%eax
jg     1152 <ethertype_to_ppptype+0x52>
cmp    $0x800,%eax
je     116c <ethertype_to_ppptype+0x6c>
cmp    $0x6003,%eax
jne    116b <ethertype_to_ppptype+0x6b>
mov    $0x27,%eax
ret
cmp    $0xfe,%eax
je     1172 <ethertype_to_ppptype+0x72>
cmp    $0x600,%eax
jne    116b <ethertype_to_ppptype+0x6b>
mov    $0x25,%eax
ret
cmp    $0x809b,%eax
je     1178 <ethertype_to_ppptype+0x78>
cmp    $0x86dd,%eax
jne    116b <ethertype_to_ppptype+0x6b>
mov    $0x57,%eax
ret
mov    $0x31,%eax
ret
mov    $0x21,%eax
ret
mov    $0x23,%eax
ret
mov    $0x29,%eax
ret

LLVM IR (-O0):
define i32 @ethertype_to_ppptype(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %12 [
i32 2048, label %4
i32 34525, label %5
i32 24579, label %6
i32 32923, label %7
i32 1536, label %8
i32 254, label %9
i32 66, label %10
i32 224, label %11
]
4: ; preds = %1
store i32 33, i32* %2
br label %12
5: ; preds = %1
store i32 87, i32* %2
br label %12
6: ; preds = %1
store i32 39, i32* %2
br label %12
7: ; preds = %1
store i32 41, i32* %2
br label %12
8: ; preds = %1
store i32 37, i32* %2
br label %12
9: ; preds = %1
store i32 35, i32* %2
br label %12
10: ; preds = %1
store i32 49, i32* %2
br label %12
11: ; preds = %1
store i32 43, i32* %2
br label %12
12: ; preds = %1, %11, %10, %9, %8, %7, %6, %5, %4
%13 = load i32, i32* %2
ret i32 %13
}

LLVM IR (-O2):
define i32 @ethertype_to_ppptype(i32 %0) {
switch i32 %0, label %10 [
i32 2048, label %2
i32 34525, label %3
i32 24579, label %4
i32 32923, label %5
i32 1536, label %6
i32 254, label %7
i32 66, label %8
i32 224, label %9
]
2: ; preds = %1
br label %10
3: ; preds = %1
br label %10
4: ; preds = %1
br label %10
5: ; preds = %1
br label %10
6: ; preds = %1
br label %10
7: ; preds = %1
br label %10
8: ; preds = %1
br label %10
9: ; preds = %1
br label %10
10: ; preds = %1, %9, %8, %7, %6, %5, %4, %3, %2
%11 = phi i32 [ %0, %1 ], [ 43, %9 ], [ 49, %8 ], [ 35, %7 ], [ 37, %6 ], [ 41, %5 ], [ 39, %4 ], [ 87, %3 ], [ 33, %2 ]
ret i32 %11
}