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

/* Variables and functions */
int hashword(int *, int, int /*<<< orphan*/);
int getUnicastChannelIndex(uint16_t slotNumber, uint8_t MACAddr[8],
                           int nChannels) {
  uint16_t channelNumber;
  uint32_t x[3];
  x[0] = (uint32_t)slotNumber;
  x[1] = MACAddr[4] << 24 | MACAddr[5] << 16 | MACAddr[6] << 8 | MACAddr[7];
  x[2] = MACAddr[0] << 24 | MACAddr[1] << 16 | MACAddr[2] << 8 | MACAddr[3];
  channelNumber = hashword(x, 3, 0) % nChannels;
  return (channelNumber);
}


x86 assembly (clang, -O0):
<getUnicastChannelIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
shl    $0x18,%eax
mov    -0x10(%rbp),%rcx
mov    0x14(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x18(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
or     0x1c(%rcx),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x18,%eax
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
or     0xc(%rcx),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x24(%rbp),%rdi
mov    $0x3,%esi
xor    %edx,%edx
call   1030 <hashword@plt>
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getUnicastChannelIndex>:
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %edi,0x4(%rsp)
mov    0x10(%rsi),%eax
mov    0x14(%rsi),%ecx
shl    $0x18,%eax
shl    $0x10,%ecx
or     %eax,%ecx
mov    0x18(%rsi),%eax
shl    $0x8,%eax
or     %ecx,%eax
or     0x1c(%rsi),%eax
mov    %eax,0x8(%rsp)
mov    (%rsi),%eax
mov    0x4(%rsi),%ecx
shl    $0x18,%eax
shl    $0x10,%ecx
or     %eax,%ecx
mov    0x8(%rsi),%eax
shl    $0x8,%eax
or     %ecx,%eax
or     0xc(%rsi),%eax
mov    %eax,0xc(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x3,%esi
xor    %edx,%edx
call   1030 <hashword@plt>
cltd
idiv   %ebx
mov    %edx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @getUnicastChannelIndex(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [3 x i32]
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
store i32 %9, i32* %10
%11 = load i32*, i32** %5
%12 = getelementptr inbounds i32, i32* %11, i64 4
%13 = load i32, i32* %12
%14 = shl i32 %13, 24
%15 = load i32*, i32** %5
%16 = getelementptr inbounds i32, i32* %15, i64 5
%17 = load i32, i32* %16
%18 = shl i32 %17, 16
%19 = or i32 %14, %18
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 6
%22 = load i32, i32* %21
%23 = shl i32 %22, 8
%24 = or i32 %19, %23
%25 = load i32*, i32** %5
%26 = getelementptr inbounds i32, i32* %25, i64 7
%27 = load i32, i32* %26
%28 = or i32 %24, %27
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 1
store i32 %28, i32* %29
%30 = load i32*, i32** %5
%31 = getelementptr inbounds i32, i32* %30, i64 0
%32 = load i32, i32* %31
%33 = shl i32 %32, 24
%34 = load i32*, i32** %5
%35 = getelementptr inbounds i32, i32* %34, i64 1
%36 = load i32, i32* %35
%37 = shl i32 %36, 16
%38 = or i32 %33, %37
%39 = load i32*, i32** %5
%40 = getelementptr inbounds i32, i32* %39, i64 2
%41 = load i32, i32* %40
%42 = shl i32 %41, 8
%43 = or i32 %38, %42
%44 = load i32*, i32** %5
%45 = getelementptr inbounds i32, i32* %44, i64 3
%46 = load i32, i32* %45
%47 = or i32 %43, %46
%48 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 2
store i32 %47, i32* %48
%49 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%50 = call i32 @hashword(i32* %49, i32 3, i32 0)
%51 = load i32, i32* %6
%52 = srem i32 %50, %51
store i32 %52, i32* %7
%53 = load i32, i32* %7
ret i32 %53
}

LLVM IR (-O2):
define i32 @getUnicastChannelIndex(i32 %0, i32* nocapture %1, i32 %2) {
%4 = alloca [3 x i32]
%5 = bitcast [3 x i32]* %4 to i8*
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
store i32 %0, i32* %6
%7 = getelementptr inbounds i32, i32* %1, i64 4
%8 = load i32, i32* %7
%9 = shl i32 %8, 24
%10 = getelementptr inbounds i32, i32* %1, i64 5
%11 = load i32, i32* %10
%12 = shl i32 %11, 16
%13 = or i32 %12, %9
%14 = getelementptr inbounds i32, i32* %1, i64 6
%15 = load i32, i32* %14
%16 = shl i32 %15, 8
%17 = or i32 %13, %16
%18 = getelementptr inbounds i32, i32* %1, i64 7
%19 = load i32, i32* %18
%20 = or i32 %17, %19
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 1
store i32 %20, i32* %21
%22 = load i32, i32* %1
%23 = shl i32 %22, 24
%24 = getelementptr inbounds i32, i32* %1, i64 1
%25 = load i32, i32* %24
%26 = shl i32 %25, 16
%27 = or i32 %26, %23
%28 = getelementptr inbounds i32, i32* %1, i64 2
%29 = load i32, i32* %28
%30 = shl i32 %29, 8
%31 = or i32 %27, %30
%32 = getelementptr inbounds i32, i32* %1, i64 3
%33 = load i32, i32* %32
%34 = or i32 %31, %33
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 2
store i32 %34, i32* %35
%36 = call i32 @hashword(i32* %6, i32 3, i32 0)
%37 = srem i32 %36, %2
ret i32 %37
}