char Size_endpoint(unsigned short wMaxPacketSize) {
  unsigned char sizeEpt = 0;
  if (wMaxPacketSize == 8) {
    sizeEpt = (0x0);
  } else if (wMaxPacketSize == 16) {
    sizeEpt = (0x1);
  } else if (wMaxPacketSize == 32) {
    sizeEpt = (0x2);
  } else if (wMaxPacketSize == 64) {
    sizeEpt = (0x3);
  } else if (wMaxPacketSize == 128) {
    sizeEpt = (0x4);
  } else if (wMaxPacketSize == 256) {
    sizeEpt = (0x5);
  } else if (wMaxPacketSize == 512) {
    sizeEpt = (0x6);
  } else if (wMaxPacketSize == 1024) {
    sizeEpt = (0x7);
  }
  return (sizeEpt);
}


x86 assembly (clang, -O0):
<Size_endpoint>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movb   $0x0,-0x3(%rbp)
movzwl -0x2(%rbp),%eax
cmp    $0x8,%eax
jne    1125 <Size_endpoint+0x25>
movb   $0x0,-0x3(%rbp)
jmp    11e5 <Size_endpoint+0xe5>
movzwl -0x2(%rbp),%eax
cmp    $0x10,%eax
jne    113b <Size_endpoint+0x3b>
movb   $0x1,-0x3(%rbp)
jmp    11e0 <Size_endpoint+0xe0>
movzwl -0x2(%rbp),%eax
cmp    $0x20,%eax
jne    1151 <Size_endpoint+0x51>
movb   $0x2,-0x3(%rbp)
jmp    11db <Size_endpoint+0xdb>
movzwl -0x2(%rbp),%eax
cmp    $0x40,%eax
jne    1167 <Size_endpoint+0x67>
movb   $0x3,-0x3(%rbp)
jmp    11d6 <Size_endpoint+0xd6>
movzwl -0x2(%rbp),%eax
cmp    $0x80,%eax
jne    117f <Size_endpoint+0x7f>
movb   $0x4,-0x3(%rbp)
jmp    11d1 <Size_endpoint+0xd1>
movzwl -0x2(%rbp),%eax
cmp    $0x100,%eax
jne    1197 <Size_endpoint+0x97>
movb   $0x5,-0x3(%rbp)
jmp    11cc <Size_endpoint+0xcc>
movzwl -0x2(%rbp),%eax
cmp    $0x200,%eax
jne    11af <Size_endpoint+0xaf>
movb   $0x6,-0x3(%rbp)
jmp    11c7 <Size_endpoint+0xc7>
movzwl -0x2(%rbp),%eax
cmp    $0x400,%eax
jne    11c2 <Size_endpoint+0xc2>
movb   $0x7,-0x3(%rbp)
jmp    11c7 <Size_endpoint+0xc7>
jmp    11cc <Size_endpoint+0xcc>
jmp    11d1 <Size_endpoint+0xd1>
jmp    11d6 <Size_endpoint+0xd6>
jmp    11db <Size_endpoint+0xdb>
jmp    11e0 <Size_endpoint+0xe0>
jmp    11e5 <Size_endpoint+0xe5>
movsbl -0x3(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Size_endpoint>:
xor    %eax,%eax
cmp    $0x7f,%di
jle    1129 <Size_endpoint+0x29>
movswl %di,%edx
movzwl %di,%ecx
cmp    $0x1ff,%edx
jg     113e <Size_endpoint+0x3e>
cmp    $0x80,%ecx
je     1151 <Size_endpoint+0x51>
cmp    $0x100,%ecx
jne    1159 <Size_endpoint+0x59>
mov    $0x5,%al
ret
cmp    $0x10,%di
je     1154 <Size_endpoint+0x54>
cmp    $0x20,%di
je     115a <Size_endpoint+0x5a>
cmp    $0x40,%di
jne    1159 <Size_endpoint+0x59>
mov    $0x3,%al
ret
cmp    $0x200,%ecx
je     1157 <Size_endpoint+0x57>
cmp    $0x400,%ecx
jne    1159 <Size_endpoint+0x59>
mov    $0x7,%al
ret
mov    $0x4,%al
ret
mov    $0x1,%al
ret
mov    $0x6,%al
ret
mov    $0x2,%al
ret

LLVM IR (-O0):
define signext i8 @Size_endpoint(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca i8
store i16 %0, i16* %2
store i8 0, i8* %3
%4 = load i16, i16* %2
%5 = zext i16 %4 to i32
%6 = icmp eq i32 %5, 8
br i1 %6, label %7, label %8
7: ; preds = %1
store i8 0, i8* %3
br label %50
8: ; preds = %1
%9 = load i16, i16* %2
%10 = zext i16 %9 to i32
%11 = icmp eq i32 %10, 16
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 1, i8* %3
br label %49
13: ; preds = %8
%14 = load i16, i16* %2
%15 = zext i16 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %18
17: ; preds = %13
store i8 2, i8* %3
br label %48
18: ; preds = %13
%19 = load i16, i16* %2
%20 = zext i16 %19 to i32
%21 = icmp eq i32 %20, 64
br i1 %21, label %22, label %23
22: ; preds = %18
store i8 3, i8* %3
br label %47
23: ; preds = %18
%24 = load i16, i16* %2
%25 = zext i16 %24 to i32
%26 = icmp eq i32 %25, 128
br i1 %26, label %27, label %28
27: ; preds = %23
store i8 4, i8* %3
br label %46
28: ; preds = %23
%29 = load i16, i16* %2
%30 = zext i16 %29 to i32
%31 = icmp eq i32 %30, 256
br i1 %31, label %32, label %33
32: ; preds = %28
store i8 5, i8* %3
br label %45
33: ; preds = %28
%34 = load i16, i16* %2
%35 = zext i16 %34 to i32
%36 = icmp eq i32 %35, 512
br i1 %36, label %37, label %38
37: ; preds = %33
store i8 6, i8* %3
br label %44
38: ; preds = %33
%39 = load i16, i16* %2
%40 = zext i16 %39 to i32
%41 = icmp eq i32 %40, 1024
br i1 %41, label %42, label %43
42: ; preds = %38
store i8 7, i8* %3
br label %43
43: ; preds = %42, %38
br label %44
44: ; preds = %43, %37
br label %45
45: ; preds = %44, %32
br label %46
46: ; preds = %45, %27
br label %47
47: ; preds = %46, %22
br label %48
48: ; preds = %47, %17
br label %49
49: ; preds = %48, %12
br label %50
50: ; preds = %49, %7
%51 = load i8, i8* %3
ret i8 %51
}

LLVM IR (-O2):
define signext i8 @Size_endpoint(i16 zeroext %0) {
switch i16 %0, label %9 [
i16 1024, label %8
i16 16, label %2
i16 32, label %3
i16 64, label %4
i16 128, label %5
i16 256, label %6
i16 512, label %7
]
2: ; preds = %1
br label %9
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %2, %4, %6, %8, %7, %5, %3
%10 = phi i8 [ 1, %2 ], [ 2, %3 ], [ 3, %4 ], [ 4, %5 ], [ 5, %6 ], [ 6, %7 ], [ 7, %8 ], [ 0, %1 ]
ret i8 %10
}