#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 /*<<< orphan*/ uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int Crc32(int, int /*<<< orphan*/ *, int);
uint32_t EMACVLANHashFilterBitCalculate(uint16_t ui16Tag) {
  uint32_t ui32CRC, ui32Mask, ui32Loop;
  ui32CRC = Crc32(0xFFFFFFFF, (uint8_t *)&ui16Tag, 2);
  ui32CRC ^= 0xFFFFFFFF;
  ui32Mask = 0;
  for (ui32Loop = 0; ui32Loop < 4; ui32Loop++) {
    ui32Mask <<= 1;
    ui32Mask |= (ui32CRC & 1);
    ui32CRC >>= 1;
  }
  return (ui32Mask);
}


x86 assembly (clang, -O0):
<EMACVLANHashFilterBitCalculate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0xffffffff,%edi
lea    -0x4(%rbp),%rsi
mov    $0x2,%edx
call   1030 <Crc32@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    117e <EMACVLANHashFilterBitCalculate+0x6e>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <EMACVLANHashFilterBitCalculate+0x38>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACVLANHashFilterBitCalculate>:
push   %rax
mov    %edi,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0xffffffff,%edi
mov    $0x2,%edx
call   1030 <Crc32@plt>
not    %al
rol    $0x4,%al
mov    %eax,%ecx
and    $0x33,%cl
shl    $0x2,%cl
shr    $0x2,%al
and    $0x33,%al
or     %cl,%al
mov    %eax,%ecx
and    $0x50,%cl
add    %cl,%cl
shr    %al
and    $0x50,%al
or     %cl,%al
shr    $0x4,%al
movzbl %al,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @EMACVLANHashFilterBitCalculate(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32 @Crc32(i32 -1, i32* %2, i32 2)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = xor i32 %7, -1
store i32 %8, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %21, %1
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i32, i32* %4
%14 = shl i32 %13, 1
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = and i32 %15, 1
%17 = load i32, i32* %4
%18 = or i32 %17, %16
store i32 %18, i32* %4
%19 = load i32, i32* %3
%20 = ashr i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %12
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %9
24: ; preds = %9
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
define i32 @EMACVLANHashFilterBitCalculate(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @Crc32(i32 -1, i32* %2, i32 2)
%4 = xor i32 %3, -1
%5 = trunc i32 %4 to i4
%6 = call i4 @llvm.bitreverse.i4(i4 %5)
%7 = zext i4 %6 to i32
ret i32 %7
}