#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_B7(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 & 0X0102040810000000ULL;
  opp_discs = (discs_opponent & 0X0002040810200000ULL) | 0X00FDFBF7EFC00000ULL;
  r = (opp_discs + 0X0000000000200000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0002040810200000ULL;
  }
  my_discs = discs_player & 0X4040404040000000ULL;
  opp_discs = (discs_opponent & 0X0040404040400000ULL) | 0X3FBFBFBFBF800000ULL;
  r = (opp_discs + 0X0000000000400000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0040404040400000ULL;
  }
  my_discs = discs_player & 0X0000000000001F00ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000004000ULL;
  if (r != 0) {
    flipped |= 0X0000000000004000ULL - (0X2ULL << last_bit(my_discs));
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_B7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x102040810000000,%rax
04 02 01
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x2040810200000,%rax
and    -0x10(%rbp),%rax
movabs $0xfdfbf7efc00000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x200000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1193 <flip_B7+0x83>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x2040810200000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x4040404040000000,%rax
40 40 40
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x40404040400000,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbfbfbfbf800000,%rcx
bf bf 3f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x400000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fe <flip_B7+0xee>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x40404040400000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1f00,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x4000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1255 <flip_B7+0x145>
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    $0x4000,%eax
sub    %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_B7>:
push   %rbx
movabs $0x2040810200000,%rax
mov    %rsi,%rcx
and    %rax,%rcx
movabs $0xfdfbf7efe00000,%rdx
add    %rcx,%rdx
movabs $0x102040810000000,%rcx
04 02 01
and    %rdi,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rdx
and    %rax,%rdx
test   %rcx,%rcx
cmove  %rcx,%rdx
movabs $0x40404040400000,%rax
mov    %rsi,%rcx
and    %rax,%rcx
movabs $0x3fbfbfbfbfc00000,%rbx
bf bf 3f
add    %rcx,%rbx
movabs $0x4040404040000000,%rcx
40 40 40
and    %rdi,%rcx
and    %rbx,%rcx
lea    -0x1(%rcx),%rbx
and    %rax,%rbx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %rdx,%rbx
and    $0x1f00,%edi
lea    (%rsi,%rdi,2),%eax
test   $0x4000,%eax
je     11b5 <flip_B7+0xa5>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x4000,%rdx
or     %rdx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @flip_B7(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, 72624976666034176
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = and i64 %11, 567382630203392
%13 = or i64 %12, 71490211405627392
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = add i64 %14, 2097152
%16 = load i64, i64* %5
%17 = and i64 %15, %16
store i64 %17, i64* %7
%18 = load i64, i64* %7
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i64, i64* %7
%22 = sub i64 %21, 1
%23 = and i64 %22, 567382630203392
%24 = load i64, i64* %8
%25 = or i64 %24, %23
store i64 %25, i64* %8
br label %26
26: ; preds = %20, %2
%27 = load i64, i64* %3
%28 = and i64 %27, 4629771061632696320
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 18085043209502720
%31 = or i64 %30, 4593600975213690880
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 4194304
%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, 18085043209502720
%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, 7936
store i64 %46, i64* %5
%47 = load i64, i64* %5
%48 = shl i64 %47, 1
%49 = load i64, i64* %4
%50 = add i64 %48, %49
%51 = and i64 %50, 16384
store i64 %51, i64* %7
%52 = load i64, i64* %7
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %44
%55 = load i64, i64* %5
%56 = call i32 @last_bit(i64 %55)
%57 = zext i32 %56 to i64
%58 = shl i64 2, %57
%59 = sub i64 16384, %58
%60 = load i64, i64* %8
%61 = or i64 %60, %59
store i64 %61, i64* %8
br label %62
62: ; preds = %54, %44
%63 = load i64, i64* %8
ret i64 %63
}

LLVM IR (-O2):
define i64 @flip_B7(i64 %0, i64 %1) {
%3 = and i64 %0, 72624976666034176
%4 = and i64 %1, 567382630203392
%5 = add nuw nsw i64 %4, 71490211407724544
%6 = and i64 %3, %5
%7 = icmp eq i64 %6, 0
%8 = add nuw nsw i64 %6, 1125899906842623
%9 = and i64 %8, 567382630203392
%10 = select i1 %7, i64 0, i64 %9
%11 = and i64 %0, 4629771061632696320
%12 = and i64 %1, 18085043209502720
%13 = add nuw nsw i64 %12, 4593600975217885184
%14 = and i64 %11, %13
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %14, 36028797018963967
%17 = and i64 %16, 18085043209502720
%18 = select i1 %15, i64 0, i64 %17
%19 = or i64 %10, %18
%20 = and i64 %0, 7936
%21 = shl nuw nsw i64 %20, 1
%22 = add i64 %21, %1
%23 = and i64 %22, 16384
%24 = icmp eq i64 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %2
%26 = tail call i32 @last_bit(i64 %20)
%27 = zext i32 %26 to i64
%28 = shl i64 -2, %27
%29 = add i64 %28, 16384
%30 = or i64 %29, %19
br label %31
31: ; preds = %25, %2
%32 = phi i64 [ %30, %25 ], [ %19, %2 ]
ret i64 %32
}