#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_B5(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 & 0X000000001F000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000040000000ULL;
  if (r != 0) {
    flipped |= 0X0000000040000000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X0408100000000000ULL;
  opp_discs = (discs_opponent & 0X0008102000000000ULL) | 0X03F7EFC000000000ULL;
  r = (opp_discs + 0X0000002000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0008102000000000ULL;
  }
  my_discs = discs_player & 0X0000000000001008ULL;
  opp_discs = (discs_opponent & 0X0000000000201000ULL) | 0X000000003FDFE000ULL;
  r = ((my_discs << 9) + opp_discs) & 0X0000000040000000ULL;
  if (r != 0) {
    flipped |= (0X0000000040000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000000201000ULL;
  }
  my_discs = discs_player & 0X4040400000000000ULL;
  opp_discs = (discs_opponent & 0X0040404000000000ULL) | 0X3FBFBF8000000000ULL;
  r = (opp_discs + 0X0000004000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0040404000000000ULL;
  }
  my_discs = discs_player & 0X0000000000004040ULL;
  opp_discs = (discs_opponent & 0X0000000000404000ULL) | 0X000000003FBF8000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000000040000000ULL;
  if (r != 0) {
    flipped |= (0X0000000040000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000000404000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_B5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1f000000,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x40000000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117f <flip_B5+0x6f>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
mov    $0x40000000,%eax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x408100000000000,%rax
10 08 04
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x8102000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x3f7efc000000000,%rcx
ef f7 03
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x2000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ee <flip_B5+0xde>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x8102000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1008,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x201000,%rax
or     $0x3fdfe000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
and    $0x40000000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     125f <flip_B5+0x14f>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
mov    $0x40000000,%eax
sub    %rcx,%rax
and    $0x201000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x4040400000000000,%rax
40 40 40
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x40404000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbfbf8000000000,%rcx
bf bf 3f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x4000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12ce <flip_B5+0x1be>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x40404000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x4040,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x404000,%rax
or     $0x3fbf8000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
and    $0x40000000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     133f <flip_B5+0x22f>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
mov    $0x40000000,%eax
sub    %rcx,%rax
and    $0x404000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_B5>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
and    $0x1f000000,%edi
lea    (%rsi,%rdi,2),%eax
test   $0x40000000,%eax
jne    1132 <flip_B5+0x22>
xor    %edx,%edx
jmp    114a <flip_B5+0x3a>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x40000000,%rdx
movabs $0x8102000000000,%rax
mov    %r14,%rcx
and    %rax,%rcx
movabs $0x3f7efe000000000,%rsi
ef f7 03
add    %rcx,%rsi
and    %r15,%rsi
movabs $0x408100000000000,%rcx
10 08 04
and    %rsi,%rcx
lea    -0x1(%rcx),%r12
and    %rax,%r12
test   %rcx,%rcx
cmove  %rcx,%r12
or     %rdx,%r12
mov    %r15d,%edi
and    $0x1008,%edi
mov    %r14d,%eax
and    $0x201000,%eax
mov    %edi,%ecx
shl    $0x9,%ecx
add    %ecx,%eax
add    $0x3fdfe000,%eax
test   $0x40000000,%eax
je     11c6 <flip_B5+0xb6>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x201000,%edx
or     %rdx,%r12
movabs $0x40404000000000,%rax
mov    %r14,%rcx
and    %rax,%rcx
movabs $0x3fbfbfc000000000,%rdx
bf bf 3f
add    %rcx,%rdx
and    %r15,%rdx
movabs $0x4040400000000000,%rcx
40 40 40
and    %rdx,%rcx
lea    -0x1(%rcx),%rbx
and    %rax,%rbx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %r12,%rbx
and    $0x4040,%r15d
and    $0x404000,%r14d
mov    %r15d,%eax
shl    $0x8,%eax
add    %r14d,%eax
add    $0x3fbf8000,%eax
test   $0x40000000,%eax
je     1244 <flip_B5+0x134>
mov    %r15,%rdi
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x404000,%edx
or     %rdx,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_B5(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, 520093696
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, 1073741824
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 1073741824, %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, 290499768151441408
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 2269529438683136
%31 = or i64 %30, 285960709274075136
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 137438953472
%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, 2269529438683136
%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, 4104
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = and i64 %47, 2101248
%49 = or i64 %48, 1071636480
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, 1073741824
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 1073741824, %61
%63 = and i64 %62, 2101248
%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, 4629770785681047552
store i64 %68, i64* %5
%69 = load i64, i64* %4
%70 = and i64 %69, 18085042131566592
%71 = or i64 %70, 4593600701417914368
store i64 %71, i64* %6
%72 = load i64, i64* %6
%73 = add i64 %72, 274877906944
%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, 18085042131566592
%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, 16448
store i64 %86, i64* %5
%87 = load i64, i64* %4
%88 = and i64 %87, 4210688
%89 = or i64 %88, 1069514752
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, 1073741824
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 1073741824, %101
%103 = and i64 %102, 4210688
%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_B5(i64 %0, i64 %1) {
%3 = and i64 %0, 520093696
%4 = shl nuw nsw i64 %3, 1
%5 = add i64 %4, %1
%6 = and i64 %5, 1073741824
%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, 1073741824
br label %13
13: ; preds = %8, %2
%14 = phi i64 [ %12, %8 ], [ 0, %2 ]
%15 = and i64 %0, 290499768151441408
%16 = and i64 %1, 2269529438683136
%17 = add nuw nsw i64 %16, 285960846713028608
%18 = and i64 %15, %17
%19 = icmp eq i64 %18, 0
%20 = add nuw nsw i64 %18, 4503599627370495
%21 = and i64 %20, 2269529438683136
%22 = select i1 %19, i64 0, i64 %21
%23 = or i64 %14, %22
%24 = and i64 %0, 4104
%25 = and i64 %1, 2101248
%26 = or i64 %25, 1071636480
%27 = shl nuw nsw i64 %24, 9
%28 = add nuw nsw i64 %26, %27
%29 = and i64 %28, 1073741824
%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, 2101248
%36 = or i64 %35, %23
br label %37
37: ; preds = %31, %13
%38 = phi i64 [ %36, %31 ], [ %23, %13 ]
%39 = and i64 %0, 4629770785681047552
%40 = and i64 %1, 18085042131566592
%41 = add nuw nsw i64 %40, 4593600976295821312
%42 = and i64 %39, %41
%43 = icmp eq i64 %42, 0
%44 = add nuw nsw i64 %42, 36028797018963967
%45 = and i64 %44, 18085042131566592
%46 = select i1 %43, i64 0, i64 %45
%47 = or i64 %38, %46
%48 = and i64 %0, 16448
%49 = and i64 %1, 4210688
%50 = or i64 %49, 1069514752
%51 = shl nuw nsw i64 %48, 8
%52 = add nuw nsw i64 %50, %51
%53 = and i64 %52, 1073741824
%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, 4210688
%60 = or i64 %59, %47
br label %61
61: ; preds = %55, %37
%62 = phi i64 [ %60, %55 ], [ %47, %37 ]
ret i64 %62
}