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

/* Variables and functions */
int GetRSSHash(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
               int /*<<< orphan*/);
int GetRSSCPUCore(in_addr_t sip, in_addr_t dip, in_port_t sp, in_port_t dp,
                  int num_queues, uint8_t endian_check) {
  uint32_t masked = GetRSSHash(sip, dip, sp, dp) & 0x0000007F;
  if (endian_check) {
    static const uint32_t off[4] = {3, 1, -1, -3};
    masked += off[masked & 0x3];
  }
  return (masked % num_queues);
}


x86 assembly (clang, -O0):
<GetRSSCPUCore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <GetRSSHash@plt>
and    $0x7f,%eax
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1167 <GetRSSCPUCore+0x57>
mov    -0x24(%rbp),%eax
and    $0x3,%eax
movslq %eax,%rcx
lea    0xea2(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetRSSCPUCore>:
push   %rbp
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8d,%ebp
call   1030 <GetRSSHash@plt>
mov    %eax,%ecx
and    $0x7f,%eax
test   %rbx,%rbx
je     1135 <GetRSSCPUCore+0x25>
and    $0x3,%ecx
lea    0xece(%rip),%rdx
add    (%rdx,%rcx,4),%eax
cltd
idiv   %ebp
mov    %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@GetRSSCPUCore.off = internal constant [4 x i32] [i32 3, i32 1, i32 -1, i32 -3]
define i32 @GetRSSCPUCore(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i64 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i64 %5, i64* %12
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = load i32, i32* %9
%17 = load i32, i32* %10
%18 = call i32 @GetRSSHash(i32 %14, i32 %15, i32 %16, i32 %17)
%19 = and i32 %18, 127
store i32 %19, i32* %13
%20 = load i64, i64* %12
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %6
%23 = load i32, i32* %13
%24 = and i32 %23, 3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i32], [4 x i32]* @GetRSSCPUCore.off, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32, i32* %13
%29 = add nsw i32 %28, %27
store i32 %29, i32* %13
br label %30
30: ; preds = %22, %6
%31 = load i32, i32* %13
%32 = load i32, i32* %11
%33 = srem i32 %31, %32
ret i32 %33
}

LLVM IR (-O2):
@GetRSSCPUCore.off = internal unnamed_addr constant [4 x i32] [i32 3, i32 1, i32 -1, i32 -3]
define i32 @GetRSSCPUCore(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i64 %5) {
%7 = tail call i32 @GetRSSHash(i32 %0, i32 %1, i32 %2, i32 %3)
%8 = and i32 %7, 127
%9 = icmp eq i64 %5, 0
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = and i32 %7, 3
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [4 x i32], [4 x i32]* @GetRSSCPUCore.off, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = add nsw i32 %14, %8
br label %16
16: ; preds = %10, %6
%17 = phi i32 [ %15, %10 ], [ %8, %6 ]
%18 = srem i32 %17, %4
ret i32 %18
}