#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_B3(const unsigned long long discs_player,
                           const unsigned long long discs_opponent) {
  unsigned long long my_discs, opp_discs, r;
  unsigned long long flipped =
      (discs_opponent & 0X0020000000000000ULL) & (discs_player >> 7);
  flipped |= (discs_opponent & 0X0040000000000000ULL) & (discs_player >> 8);
  my_discs = discs_player & 0X00001F0000000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000400000000000ULL;
  if (r != 0) {
    flipped |= 0X0000400000000000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X0000000010080402ULL;
  opp_discs = (discs_opponent & 0X0000002010080400ULL) | 0X00003FDFEFF7F800ULL;
  r = ((my_discs << 9) + opp_discs) & 0X0000400000000000ULL;
  if (r != 0) {
    flipped |= (0X0000400000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000002010080400ULL;
  }
  my_discs = discs_player & 0X0000000040404040ULL;
  opp_discs = (discs_opponent & 0X0000004040404000ULL) | 0X00003FBFBFBF8000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000400000000000ULL;
  if (r != 0) {
    flipped |= (0X0000400000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000004040404000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_B3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x20000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x7,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
movabs $0x40000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x8,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x1f0000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x400000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c5 <flip_B3+0xb5>
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 $0x400000000000,%rax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x10080402,%rax
mov    %rax,-0x18(%rbp)
movabs $0x2010080400,%rax
and    -0x10(%rbp),%rax
movabs $0x3fdfeff7f800,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x400000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1254 <flip_B3+0x144>
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 $0x400000000000,%rax
sub    %rcx,%rax
movabs $0x2010080400,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x40404040,%rax
mov    %rax,-0x18(%rbp)
movabs $0x4040404000,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbfbfbf8000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x400000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12e3 <flip_B3+0x1d3>
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 $0x400000000000,%rax
sub    %rcx,%rax
movabs $0x4040404000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_B3>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movabs $0x400000000000,%r12
mov    %rdi,%rax
shr    $0x7,%rax
and    %rsi,%rax
movabs $0x20000000000000,%rcx
and    %rax,%rcx
mov    %rdi,%rax
shr    $0x8,%rax
and    %rsi,%rax
movabs $0x40000000000000,%rbx
and    %rax,%rbx
or     %rcx,%rbx
movabs $0x1f0000000000,%rdi
and    %r14,%rdi
lea    (%rsi,%rdi,2),%rax
bt     $0x2e,%rax
jae    1189 <flip_B3+0x79>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    %r12,%rdx
or     %rdx,%rbx
movabs $0x2010080400,%r13
mov    %r14d,%edi
and    $0x10080402,%edi
mov    %r15,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x9,%rcx
add    %rax,%rcx
movabs $0x3fdfeff7f800,%rax
add    %rcx,%rax
test   %r12,%rax
je     11d5 <flip_B3+0xc5>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%rbx
movabs $0x4040404000,%r13
and    $0x40404040,%r14d
and    %r13,%r15
mov    %r14,%rax
shl    $0x8,%rax
add    %r15,%rax
movabs $0x3fbfbfbf8000,%rcx
add    %rax,%rcx
test   %r12,%rcx
je     121f <flip_B3+0x10f>
mov    %r14,%rdi
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_B3(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
%9 = load i64, i64* %4
%10 = and i64 %9, 9007199254740992
%11 = load i64, i64* %3
%12 = lshr i64 %11, 7
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %4
%15 = and i64 %14, 18014398509481984
%16 = load i64, i64* %3
%17 = lshr i64 %16, 8
%18 = and i64 %15, %17
%19 = load i64, i64* %8
%20 = or i64 %19, %18
store i64 %20, i64* %8
%21 = load i64, i64* %3
%22 = and i64 %21, 34084860461056
store i64 %22, i64* %5
%23 = load i64, i64* %5
%24 = shl i64 %23, 1
%25 = load i64, i64* %4
%26 = add i64 %24, %25
%27 = and i64 %26, 70368744177664
store i64 %27, i64* %7
%28 = load i64, i64* %7
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %2
%31 = load i64, i64* %5
%32 = call i32 @last_bit(i64 %31)
%33 = zext i32 %32 to i64
%34 = shl i64 2, %33
%35 = sub i64 70368744177664, %34
%36 = load i64, i64* %8
%37 = or i64 %36, %35
store i64 %37, i64* %8
br label %38
38: ; preds = %30, %2
%39 = load i64, i64* %3
%40 = and i64 %39, 268960770
store i64 %40, i64* %5
%41 = load i64, i64* %4
%42 = and i64 %41, 137707914240
%43 = or i64 %42, 70231036262400
store i64 %43, i64* %6
%44 = load i64, i64* %5
%45 = shl i64 %44, 9
%46 = load i64, i64* %6
%47 = add i64 %45, %46
%48 = and i64 %47, 70368744177664
store i64 %48, i64* %7
%49 = load i64, i64* %7
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %38
%52 = load i64, i64* %5
%53 = call i32 @last_bit(i64 %52)
%54 = zext i32 %53 to i64
%55 = shl i64 2, %54
%56 = sub i64 70368744177664, %55
%57 = and i64 %56, 137707914240
%58 = load i64, i64* %8
%59 = or i64 %58, %57
store i64 %59, i64* %8
br label %60
60: ; preds = %51, %38
%61 = load i64, i64* %3
%62 = and i64 %61, 1077952576
store i64 %62, i64* %5
%63 = load i64, i64* %4
%64 = and i64 %63, 275955859456
%65 = or i64 %64, 70092788301824
store i64 %65, i64* %6
%66 = load i64, i64* %5
%67 = shl i64 %66, 8
%68 = load i64, i64* %6
%69 = add i64 %67, %68
%70 = and i64 %69, 70368744177664
store i64 %70, i64* %7
%71 = load i64, i64* %7
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %82
73: ; preds = %60
%74 = load i64, i64* %5
%75 = call i32 @last_bit(i64 %74)
%76 = zext i32 %75 to i64
%77 = shl i64 2, %76
%78 = sub i64 70368744177664, %77
%79 = and i64 %78, 275955859456
%80 = load i64, i64* %8
%81 = or i64 %80, %79
store i64 %81, i64* %8
br label %82
82: ; preds = %73, %60
%83 = load i64, i64* %8
ret i64 %83
}

LLVM IR (-O2):
define i64 @flip_B3(i64 %0, i64 %1) {
%3 = and i64 %1, 9007199254740992
%4 = lshr i64 %0, 7
%5 = and i64 %3, %4
%6 = and i64 %1, 18014398509481984
%7 = lshr i64 %0, 8
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %0, 34084860461056
%11 = shl nuw nsw i64 %10, 1
%12 = add i64 %11, %1
%13 = and i64 %12, 70368744177664
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %2
%16 = tail call i32 @last_bit(i64 %10)
%17 = zext i32 %16 to i64
%18 = shl i64 -2, %17
%19 = add i64 %18, 70368744177664
%20 = or i64 %19, %9
br label %21
21: ; preds = %15, %2
%22 = phi i64 [ %20, %15 ], [ %9, %2 ]
%23 = and i64 %0, 268960770
%24 = and i64 %1, 137707914240
%25 = or i64 %24, 70231036262400
%26 = shl nuw nsw i64 %23, 9
%27 = add nuw nsw i64 %25, %26
%28 = and i64 %27, 70368744177664
%29 = icmp eq i64 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %21
%31 = tail call i32 @last_bit(i64 %23)
%32 = zext i32 %31 to i64
%33 = shl i64 -2, %32
%34 = and i64 %33, 137707914240
%35 = or i64 %34, %22
br label %36
36: ; preds = %30, %21
%37 = phi i64 [ %35, %30 ], [ %22, %21 ]
%38 = and i64 %0, 1077952576
%39 = and i64 %1, 275955859456
%40 = or i64 %39, 70092788301824
%41 = shl nuw nsw i64 %38, 8
%42 = add nuw nsw i64 %40, %41
%43 = and i64 %42, 70368744177664
%44 = icmp eq i64 %43, 0
br i1 %44, label %51, label %45
45: ; preds = %36
%46 = tail call i32 @last_bit(i64 %38)
%47 = zext i32 %46 to i64
%48 = shl i64 -2, %47
%49 = and i64 %48, 275955859456
%50 = or i64 %49, %37
br label %51
51: ; preds = %45, %36
%52 = phi i64 [ %50, %45 ], [ %37, %36 ]
ret i64 %52
}