#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 */

/* Variables and functions */
int last_bit(unsigned long long);
unsigned long long flip_B4(const unsigned long long discs_player,
                           const unsigned long long discs_opponent) {
  unsigned long long my_discs, opp_discs, r, flipped = 0ULL;
  my_discs = discs_player & 0X0000001F00000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000004000000000ULL;
  if (r != 0) {
    flipped |= 0X0000004000000000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X0810000000000000ULL;
  opp_discs = (discs_opponent & 0X0010200000000000ULL) | 0X07EFC00000000000ULL;
  r = (opp_discs + 0X0000200000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0010200000000000ULL;
  }
  my_discs = discs_player & 0X0000000000100804ULL;
  opp_discs = (discs_opponent & 0X0000000020100800ULL) | 0X0000003FDFEFF000ULL;
  r = ((my_discs << 9) + opp_discs) & 0X0000004000000000ULL;
  if (r != 0) {
    flipped |= (0X0000004000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000020100800ULL;
  }
  my_discs = discs_player & 0X4040000000000000ULL;
  opp_discs = (discs_opponent & 0X0040400000000000ULL) | 0X3FBF800000000000ULL;
  r = (opp_discs + 0X0000400000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0040400000000000ULL;
  }
  my_discs = discs_player & 0X0000000000404040ULL;
  opp_discs = (discs_opponent & 0X0000000040404000ULL) | 0X0000003FBFBF8000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000004000000000ULL;
  if (r != 0) {
    flipped |= (0X0000004000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000040404000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_B4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x1f00000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x4000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     118f <flip_B4+0x7f>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
movabs $0x4000000000,%rax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x810000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x10200000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x7efc00000000000,%rcx
c0 ef 07
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x200000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fe <flip_B4+0xee>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x10200000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x100804,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x20100800,%rax
movabs $0x3fdfeff000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x4000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1282 <flip_B4+0x172>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
movabs $0x4000000000,%rax
sub    %rcx,%rax
and    $0x20100800,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x4040000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x40400000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbf800000000000,%rcx
80 bf 3f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x400000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12f1 <flip_B4+0x1e1>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x40400000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x404040,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x40404000,%rax
movabs $0x3fbfbf8000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x4000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1375 <flip_B4+0x265>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
movabs $0x4000000000,%rax
sub    %rcx,%rax
and    $0x40404000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_B4>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
movabs $0x4000000000,%r12
movabs $0x1f00000000,%rdi
and    %r15,%rdi
lea    (%rsi,%rdi,2),%rax
bt     $0x26,%rax
jb     1145 <flip_B4+0x35>
xor    %edx,%edx
jmp    1159 <flip_B4+0x49>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    %r12,%rdx
movabs $0x10200000000000,%rax
mov    %r14,%rcx
and    %rax,%rcx
movabs $0x7efe00000000000,%rsi
e0 ef 07
add    %rcx,%rsi
and    %r15,%rsi
movabs $0x810000000000000,%rcx
and    %rsi,%rcx
lea    -0x1(%rcx),%r13
and    %rax,%r13
test   %rcx,%rcx
cmove  %rcx,%r13
or     %rdx,%r13
mov    %r15d,%edi
and    $0x100804,%edi
mov    %r14d,%eax
and    $0x20100800,%eax
lea    -0x20101000(%r12),%rcx
df
or     %rax,%rcx
mov    %rdi,%rax
shl    $0x9,%rax
add    %rcx,%rax
test   %r12,%rax
je     11dc <flip_B4+0xcc>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x20100800,%edx
or     %rdx,%r13
movabs $0x40400000000000,%rax
mov    %r14,%rcx
and    %rax,%rcx
movabs $0x3fbfc00000000000,%rdx
c0 bf 3f
add    %rcx,%rdx
and    %r15,%rdx
movabs $0x4040000000000000,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rbx
and    %rax,%rbx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %r13,%rbx
and    $0x404040,%r15d
and    $0x40404000,%r14d
lea    -0x40408000(%r12),%rax
bf
or     %r14,%rax
mov    %r15,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
test   %r12,%rcx
je     125f <flip_B4+0x14f>
mov    %r15,%rdi
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x40404000,%edx
or     %rdx,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_B4(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
store i64 0, i64* %8
%9 = load i64, i64* %3
%10 = and i64 %9, 133143986176
store i64 %10, i64* %5
%11 = load i64, i64* %5
%12 = shl i64 %11, 1
%13 = load i64, i64* %4
%14 = add i64 %12, %13
%15 = and i64 %14, 274877906944
store i64 %15, i64* %7
%16 = load i64, i64* %7
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i64, i64* %5
%20 = call i32 @last_bit(i64 %19)
%21 = zext i32 %20 to i64
%22 = shl i64 2, %21
%23 = sub i64 274877906944, %22
%24 = load i64, i64* %8
%25 = or i64 %24, %23
store i64 %25, i64* %8
br label %26
26: ; preds = %18, %2
%27 = load i64, i64* %3
%28 = and i64 %27, 580964351930793984
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 4538783999459328
%31 = or i64 %30, 571886783931875328
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 35184372088832
%34 = load i64, i64* %5
%35 = and i64 %33, %34
store i64 %35, i64* %7
%36 = load i64, i64* %7
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %26
%39 = load i64, i64* %7
%40 = sub i64 %39, 1
%41 = and i64 %40, 4538783999459328
%42 = load i64, i64* %8
%43 = or i64 %42, %41
store i64 %43, i64* %8
br label %44
44: ; preds = %38, %26
%45 = load i64, i64* %3
%46 = and i64 %45, 1050628
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = and i64 %47, 537921536
%49 = or i64 %48, 274339983360
store i64 %49, i64* %6
%50 = load i64, i64* %5
%51 = shl i64 %50, 9
%52 = load i64, i64* %6
%53 = add i64 %51, %52
%54 = and i64 %53, 274877906944
store i64 %54, i64* %7
%55 = load i64, i64* %7
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %66
57: ; preds = %44
%58 = load i64, i64* %5
%59 = call i32 @last_bit(i64 %58)
%60 = zext i32 %59 to i64
%61 = shl i64 2, %60
%62 = sub i64 274877906944, %61
%63 = and i64 %62, 537921536
%64 = load i64, i64* %8
%65 = or i64 %64, %63
store i64 %65, i64* %8
br label %66
66: ; preds = %57, %44
%67 = load i64, i64* %3
%68 = and i64 %67, 4629700416936869888
store i64 %68, i64* %5
%69 = load i64, i64* %4
%70 = and i64 %69, 18084767253659648
%71 = or i64 %70, 4593530882429550592
store i64 %71, i64* %6
%72 = load i64, i64* %6
%73 = add i64 %72, 70368744177664
%74 = load i64, i64* %5
%75 = and i64 %73, %74
store i64 %75, i64* %7
%76 = load i64, i64* %7
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %84
78: ; preds = %66
%79 = load i64, i64* %7
%80 = sub i64 %79, 1
%81 = and i64 %80, 18084767253659648
%82 = load i64, i64* %8
%83 = or i64 %82, %81
store i64 %83, i64* %8
br label %84
84: ; preds = %78, %66
%85 = load i64, i64* %3
%86 = and i64 %85, 4210752
store i64 %86, i64* %5
%87 = load i64, i64* %4
%88 = and i64 %87, 1077952512
%89 = or i64 %88, 273799938048
store i64 %89, i64* %6
%90 = load i64, i64* %5
%91 = shl i64 %90, 8
%92 = load i64, i64* %6
%93 = add i64 %91, %92
%94 = and i64 %93, 274877906944
store i64 %94, i64* %7
%95 = load i64, i64* %7
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %106
97: ; preds = %84
%98 = load i64, i64* %5
%99 = call i32 @last_bit(i64 %98)
%100 = zext i32 %99 to i64
%101 = shl i64 2, %100
%102 = sub i64 274877906944, %101
%103 = and i64 %102, 1077952512
%104 = load i64, i64* %8
%105 = or i64 %104, %103
store i64 %105, i64* %8
br label %106
106: ; preds = %97, %84
%107 = load i64, i64* %8
ret i64 %107
}

LLVM IR (-O2):
define i64 @flip_B4(i64 %0, i64 %1) {
%3 = and i64 %0, 133143986176
%4 = shl nuw nsw i64 %3, 1
%5 = add i64 %4, %1
%6 = and i64 %5, 274877906944
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = tail call i32 @last_bit(i64 %3)
%10 = zext i32 %9 to i64
%11 = shl i64 -2, %10
%12 = add i64 %11, 274877906944
br label %13
13: ; preds = %8, %2
%14 = phi i64 [ %12, %8 ], [ 0, %2 ]
%15 = and i64 %0, 580964351930793984
%16 = and i64 %1, 4538783999459328
%17 = add nuw nsw i64 %16, 571921968303964160
%18 = and i64 %15, %17
%19 = icmp eq i64 %18, 0
%20 = add nuw nsw i64 %18, 9007199254740991
%21 = and i64 %20, 4538783999459328
%22 = select i1 %19, i64 0, i64 %21
%23 = or i64 %14, %22
%24 = and i64 %0, 1050628
%25 = and i64 %1, 537921536
%26 = or i64 %25, 274339983360
%27 = shl nuw nsw i64 %24, 9
%28 = add nuw nsw i64 %26, %27
%29 = and i64 %28, 274877906944
%30 = icmp eq i64 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %13
%32 = tail call i32 @last_bit(i64 %24)
%33 = zext i32 %32 to i64
%34 = shl i64 -2, %33
%35 = and i64 %34, 537921536
%36 = or i64 %35, %23
br label %37
37: ; preds = %31, %13
%38 = phi i64 [ %36, %31 ], [ %23, %13 ]
%39 = and i64 %0, 4629700416936869888
%40 = and i64 %1, 18084767253659648
%41 = add nuw nsw i64 %40, 4593601251173728256
%42 = and i64 %39, %41
%43 = icmp eq i64 %42, 0
%44 = add nuw nsw i64 %42, 36028797018963967
%45 = and i64 %44, 18084767253659648
%46 = select i1 %43, i64 0, i64 %45
%47 = or i64 %38, %46
%48 = and i64 %0, 4210752
%49 = and i64 %1, 1077952512
%50 = or i64 %49, 273799938048
%51 = shl nuw nsw i64 %48, 8
%52 = add nuw nsw i64 %50, %51
%53 = and i64 %52, 274877906944
%54 = icmp eq i64 %53, 0
br i1 %54, label %61, label %55
55: ; preds = %37
%56 = tail call i32 @last_bit(i64 %48)
%57 = zext i32 %56 to i64
%58 = shl i64 -2, %57
%59 = and i64 %58, 1077952512
%60 = or i64 %59, %47
br label %61
61: ; preds = %55, %37
%62 = phi i64 [ %60, %55 ], [ %47, %37 ]
ret i64 %62
}