unsigned int LIBTLV_OPT_TSZMAX(unsigned int opt) {
  unsigned int ret;
  switch (opt & 0x00000003U) {
  case 0:
    if (opt & 0x00000400U)
      ret = 0xFE;
    else
      ret = 0xFF;
    break;
  case 0x00000001U:
    if (opt & 0x00000400U)
      ret = 0xFEFF;
    else
      ret = 0xFFFF;
    break;
  case 0x00000002U:
    if (opt & 0x00000400U)
      ret = 0xFDFFFFF;
    else
      ret = 0xFFFFFFF;
    break;
  default:
    ret = 0;
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<LIBTLV_OPT_TSZMAX>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0xc(%rbp)
je     113d <LIBTLV_OPT_TSZMAX+0x3d>
jmp    111b <LIBTLV_OPT_TSZMAX+0x1b>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     1166 <LIBTLV_OPT_TSZMAX+0x66>
jmp    112c <LIBTLV_OPT_TSZMAX+0x2c>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     118f <LIBTLV_OPT_TSZMAX+0x8f>
jmp    11b8 <LIBTLV_OPT_TSZMAX+0xb8>
mov    -0x4(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     115a <LIBTLV_OPT_TSZMAX+0x5a>
movl   $0xfe,-0x8(%rbp)
jmp    1161 <LIBTLV_OPT_TSZMAX+0x61>
movl   $0xff,-0x8(%rbp)
jmp    11bf <LIBTLV_OPT_TSZMAX+0xbf>
mov    -0x4(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     1183 <LIBTLV_OPT_TSZMAX+0x83>
movl   $0xfeff,-0x8(%rbp)
jmp    118a <LIBTLV_OPT_TSZMAX+0x8a>
movl   $0xffff,-0x8(%rbp)
jmp    11bf <LIBTLV_OPT_TSZMAX+0xbf>
mov    -0x4(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     11ac <LIBTLV_OPT_TSZMAX+0xac>
movl   $0xfdfffff,-0x8(%rbp)
jmp    11b3 <LIBTLV_OPT_TSZMAX+0xb3>
movl   $0xfffffff,-0x8(%rbp)
jmp    11bf <LIBTLV_OPT_TSZMAX+0xbf>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<LIBTLV_OPT_TSZMAX>:
mov    %edi,%ecx
and    $0x3,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
je     1126 <LIBTLV_OPT_TSZMAX+0x26>
cmp    $0x1,%ecx
je     1138 <LIBTLV_OPT_TSZMAX+0x38>
test   %ecx,%ecx
jne    1137 <LIBTLV_OPT_TSZMAX+0x37>
xor    %eax,%eax
test   $0x400,%edi
sete   %al
or     $0xfe,%eax
ret
test   $0x400,%edi
sete   %al
shl    $0x15,%eax
or     $0xfdfffff,%eax
ret
test   $0x400,%edi
sete   %al
shl    $0x8,%eax
or     $0xfeff,%eax
ret

LLVM IR (-O0):
define i32 @LIBTLV_OPT_TSZMAX(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 3
switch i32 %5, label %27 [
i32 0, label %6
i32 1, label %13
i32 2, label %20
]
6: ; preds = %1
%7 = load i32, i32* %2
%8 = and i32 %7, 1024
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
store i32 254, i32* %3
br label %12
11: ; preds = %6
store i32 255, i32* %3
br label %12
12: ; preds = %11, %10
br label %28
13: ; preds = %1
%14 = load i32, i32* %2
%15 = and i32 %14, 1024
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 65279, i32* %3
br label %19
18: ; preds = %13
store i32 65535, i32* %3
br label %19
19: ; preds = %18, %17
br label %28
20: ; preds = %1
%21 = load i32, i32* %2
%22 = and i32 %21, 1024
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 266338303, i32* %3
br label %26
25: ; preds = %20
store i32 268435455, i32* %3
br label %26
26: ; preds = %25, %24
br label %28
27: ; preds = %1
store i32 0, i32* %3
br label %28
28: ; preds = %27, %26, %19, %12
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @LIBTLV_OPT_TSZMAX(i32 %0) {
%2 = and i32 %0, 3
switch i32 %2, label %15 [
i32 0, label %3
i32 1, label %7
i32 2, label %11
]
3: ; preds = %1
%4 = and i32 %0, 1024
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i32 255, i32 254
br label %15
7: ; preds = %1
%8 = and i32 %0, 1024
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 65535, i32 65279
br label %15
11: ; preds = %1
%12 = and i32 %0, 1024
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i32 268435455, i32 266338303
br label %15
15: ; preds = %1, %11, %7, %3
%16 = phi i32 [ %6, %3 ], [ %10, %7 ], [ %14, %11 ], [ 0, %1 ]
ret i32 %16
}