unsigned long long flip_G8(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 & 0X0080402010080000ULL;
  opp_discs = (discs_opponent & 0X0000402010080400ULL) | 0X007FBFDFEFF7F800ULL;
  r = (opp_discs + 0X0000000000000400ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000402010080400ULL;
  }
  my_discs = discs_player & 0X0202020202020000ULL;
  opp_discs = (discs_opponent & 0X0002020202020200ULL) | 0X01FDFDFDFDFDFC00ULL;
  r = (opp_discs + 0X0000000000000200ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0002020202020200ULL;
  }
  my_discs = discs_player & 0X00000000000000F8ULL;
  r = (discs_opponent + 0X0000000000000004ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X00000000000000FCULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_G8>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x80402010080000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x402010080400,%rax
and    -0x10(%rbp),%rax
movabs $0x7fbfdfeff7f800,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x400,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117f <flip_G8+0x7f>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x402010080400,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x202020202020000,%rax
02 02 02
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x2020202020200,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfdfdfdfdfc00,%rcx
fd fd 01
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x200,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ea <flip_G8+0xea>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x2020202020200,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xf8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1229 <flip_G8+0x129>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0xfc,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_G8>:
movabs $0x402010080400,%r8
mov    %rsi,%r9
lea    0x4(%rsi),%edx
and    %r8,%rsi
movabs $0x7fbfdfeff7fc00,%rax
add    %rsi,%rax
movabs $0x80402010080000,%rsi
and    %rdi,%rsi
and    %rax,%rsi
lea    -0x1(%rsi),%rcx
and    %r8,%rcx
test   %rsi,%rsi
cmove  %rsi,%rcx
movabs $0x2020202020200,%r8
and    %r8,%r9
movabs $0x1fdfdfdfdfdfe00,%rsi
fd fd 01
add    %r9,%rsi
movabs $0x202020202020000,%rax
02 02 02
and    %rdi,%rax
and    %rsi,%rax
lea    -0x1(%rax),%rsi
and    %r8,%rsi
test   %rax,%rax
cmove  %rax,%rsi
and    %edi,%edx
and    $0xf8,%edx
lea    -0x1(%rdx),%eax
and    $0xfc,%eax
test   %rdx,%rdx
cmove  %rdx,%rax
or     %rsi,%rax
or     %rcx,%rax
ret

LLVM IR (-O0):
define i64 @flip_G8(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, 36099303471054848
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = and i64 %11, 70506452091904
%13 = or i64 %12, 35958290566871040
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = add i64 %14, 1024
%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, 70506452091904
%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, 144680345676152832
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 565157600297472
%31 = or i64 %30, 143550030475557888
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 512
%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, 565157600297472
%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, 248
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = add i64 %47, 4
%49 = load i64, i64* %5
%50 = and i64 %48, %49
store i64 %50, i64* %7
%51 = load i64, i64* %7
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %44
%54 = load i64, i64* %7
%55 = sub i64 %54, 1
%56 = and i64 %55, 252
%57 = load i64, i64* %8
%58 = or i64 %57, %56
store i64 %58, i64* %8
br label %59
59: ; preds = %53, %44
%60 = load i64, i64* %8
ret i64 %60
}

LLVM IR (-O2):
define i64 @flip_G8(i64 %0, i64 %1) {
%3 = and i64 %0, 36099303471054848
%4 = and i64 %1, 70506452091904
%5 = add nuw nsw i64 %4, 35958290566872064
%6 = and i64 %3, %5
%7 = icmp eq i64 %6, 0
%8 = add nuw nsw i64 %6, 140737488355327
%9 = and i64 %8, 70506452091904
%10 = select i1 %7, i64 0, i64 %9
%11 = and i64 %0, 144680345676152832
%12 = and i64 %1, 565157600297472
%13 = add nuw nsw i64 %12, 143550030475558400
%14 = and i64 %11, %13
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %14, 1125899906842623
%17 = and i64 %16, 565157600297472
%18 = select i1 %15, i64 0, i64 %17
%19 = and i64 %0, 248
%20 = add i64 %1, 4
%21 = and i64 %19, %20
%22 = icmp eq i64 %21, 0
%23 = add nuw nsw i64 %21, 255
%24 = and i64 %23, 252
%25 = select i1 %22, i64 0, i64 %24
%26 = or i64 %18, %25
%27 = or i64 %26, %10
ret i64 %27
}