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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
size_t ZOBRIST_CASTLE_RIGHTS_INDEX(uint8_t castle_flag) {
  const size_t base = 64 * 12 + 1;
  const size_t off = castle_flag;
  assert(castle_flag == ((uint8_t)(1 << 0)) ||
         castle_flag == ((uint8_t)(1 << 1)) ||
         castle_flag == ((uint8_t)(1 << 2)) ||
         castle_flag == ((uint8_t)(1 << 3)));
  const size_t index = base + off;
  assert(index >= 64 * 12 + 1);
  assert(index < 64 * 12 + 1 + 16);
  return index;
}


x86 assembly (clang, -O0):
<ZOBRIST_CASTLE_RIGHTS_INDEX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x301,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x1,%al
cmpq   $0x1,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     1167 <ZOBRIST_CASTLE_RIGHTS_INDEX+0x57>
mov    $0x1,%al
cmpq   $0x2,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     1167 <ZOBRIST_CASTLE_RIGHTS_INDEX+0x57>
mov    $0x1,%al
cmpq   $0x4,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     1167 <ZOBRIST_CASTLE_RIGHTS_INDEX+0x57>
cmpq   $0x8,-0x8(%rbp)
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
add    $0x301,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x301,-0x20(%rbp)
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x311,-0x20(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ZOBRIST_CASTLE_RIGHTS_INDEX>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x4,%rdi
ja     112a <ZOBRIST_CASTLE_RIGHTS_INDEX+0x1a>
mov    $0x1,%edi
mov    $0x16,%eax
bt     %rbx,%rax
jb     1134 <ZOBRIST_CASTLE_RIGHTS_INDEX+0x24>
xor    %edi,%edi
cmp    $0x8,%rbx
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
sub    $0xfffffffffffffcff,%rbx
setb   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x311,%rbx
setb   %dil
call   1030 <assert@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @ZOBRIST_CASTLE_RIGHTS_INDEX(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %2
store i64 769, i64* %3
%6 = load i64, i64* %2
store i64 %6, i64* %4
%7 = load i64, i64* %2
%8 = icmp eq i64 %7, 1
br i1 %8, label %18, label %9
9: ; preds = %1
%10 = load i64, i64* %2
%11 = icmp eq i64 %10, 2
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = load i64, i64* %2
%14 = icmp eq i64 %13, 4
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i64, i64* %2
%17 = icmp eq i64 %16, 8
br label %18
18: ; preds = %15, %12, %9, %1
%19 = phi i1 [ true, %12 ], [ true, %9 ], [ true, %1 ], [ %17, %15 ]
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i64, i64* %4
%23 = add i64 769, %22
store i64 %23, i64* %5
%24 = load i64, i64* %5
%25 = icmp uge i64 %24, 769
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i64, i64* %5
%29 = icmp ult i64 %28, 785
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i64, i64* %5
ret i64 %32
}

LLVM IR (-O2):
define i64 @ZOBRIST_CASTLE_RIGHTS_INDEX(i64 %0) {
switch i64 %0, label %2 [
i64 4, label %5
i64 2, label %5
i64 1, label %5
]
2: ; preds = %1
%3 = icmp eq i64 %0, 8
%4 = zext i1 %3 to i32
br label %5
5: ; preds = %1, %1, %1, %2
%6 = phi i32 [ 1, %1 ], [ %4, %2 ], [ 1, %1 ], [ 1, %1 ]
%7 = tail call i32 @assert(i32 %6)
%8 = add i64 %0, 769
%9 = icmp ult i64 %0, -769
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = icmp ult i64 %8, 785
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
ret i64 %8
}