#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;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int /*<<< orphan*/ *);
int Crc32(int, int /*<<< orphan*/ *, int);
uint32_t EMACHashFilterBitCalculate(uint8_t *pui8MACAddr) {
  uint32_t ui32CRC, ui32Mask, ui32Loop;
  ASSERT(pui8MACAddr);
  ui32CRC = Crc32(0xFFFFFFFF, pui8MACAddr, 6);
  ui32CRC ^= 0xFFFFFFFF;
  ui32Mask = 0;
  for (ui32Loop = 0; ui32Loop < 6; ui32Loop++) {
    ui32Mask <<= 1;
    ui32Mask |= (ui32CRC & 1);
    ui32CRC >>= 1;
  }
  return (ui32Mask);
}


x86 assembly (clang, -O0):
<EMACHashFilterBitCalculate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%rsi
mov    $0xffffffff,%edi
mov    $0x6,%edx
call   1040 <Crc32@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    1198 <EMACHashFilterBitCalculate+0x78>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <EMACHashFilterBitCalculate+0x42>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACHashFilterBitCalculate>:
push   %rbx
mov    %rdi,%rbx
call   1030 <ASSERT@plt>
mov    $0xffffffff,%edi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1040 <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    $0x54,%cl
add    %cl,%cl
shr    %al
and    $0x54,%al
or     %cl,%al
shr    $0x2,%al
movzbl %al,%eax
pop    %rbx
ret

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

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