unsigned long long flip_G7(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 & 0X8040201008000000ULL;
  opp_discs = (discs_opponent & 0X0040201008040000ULL) | 0X7FBFDFEFF7F80000ULL;
  r = (opp_discs + 0X0000000000040000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0040201008040000ULL;
  }
  my_discs = discs_player & 0X0202020202000000ULL;
  opp_discs = (discs_opponent & 0X0002020202020000ULL) | 0X01FDFDFDFDFC0000ULL;
  r = (opp_discs + 0X0000000000020000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0002020202020000ULL;
  }
  my_discs = discs_player & 0X000000000000F800ULL;
  r = (discs_opponent + 0X0000000000000400ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X000000000000FC00ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_G7>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x8040201008000000,%rax
20 40 80
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x40201008040000,%rax
and    -0x10(%rbp),%rax
movabs $0x7fbfdfeff7f80000,%rcx
df bf 7f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x40000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117f <flip_G7+0x7f>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x40201008040000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x202020202000000,%rax
02 02 02
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x2020202020000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfdfdfdfc0000,%rcx
fd fd 01
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ea <flip_G7+0xea>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x2020202020000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xf800,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x400,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     122b <flip_G7+0x12b>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0xfc00,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_G7>:
movabs $0x40201008040000,%r8
mov    %rsi,%r9
lea    0x400(%rsi),%edx
and    %r8,%rsi
movabs $0x7fbfdfeff7fc0000,%rax
df bf 7f
add    %rsi,%rax
movabs $0x8040201008000000,%rsi
20 40 80
and    %rdi,%rsi
and    %rax,%rsi
lea    -0x1(%rsi),%rcx
and    %r8,%rcx
test   %rsi,%rsi
cmove  %rsi,%rcx
movabs $0x2020202020000,%r8
and    %r8,%r9
movabs $0x1fdfdfdfdfe0000,%rsi
fd fd 01
add    %r9,%rsi
movabs $0x202020202000000,%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    $0xf800,%edx
lea    -0x1(%rdx),%eax
and    $0xfc00,%eax
test   %rdx,%rdx
cmove  %rdx,%rax
or     %rsi,%rax
or     %rcx,%rax
ret

LLVM IR (-O0):
define i64 @flip_G7(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, -9205322385119510528
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = and i64 %11, 18049651735527424
%13 = or i64 %12, 9205322385118986240
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = add i64 %14, 262144
%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, 18049651735527424
%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, 144680345676021760
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 565157600296960
%31 = or i64 %30, 143550030475427840
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 131072
%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, 565157600296960
%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, 63488
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = add i64 %47, 1024
%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, 64512
%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_G7(i64 %0, i64 %1) {
%3 = and i64 %0, -9205322385119510528
%4 = and i64 %1, 18049651735527424
%5 = add nuw i64 %4, 9205322385119248384
%6 = and i64 %3, %5
%7 = icmp eq i64 %6, 0
%8 = add nuw nsw i64 %6, 36028797018963967
%9 = and i64 %8, 18049651735527424
%10 = select i1 %7, i64 0, i64 %9
%11 = and i64 %0, 144680345676021760
%12 = and i64 %1, 565157600296960
%13 = add nuw nsw i64 %12, 143550030475558912
%14 = and i64 %11, %13
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %14, 1125899906842623
%17 = and i64 %16, 565157600296960
%18 = select i1 %15, i64 0, i64 %17
%19 = and i64 %0, 63488
%20 = add i64 %1, 1024
%21 = and i64 %19, %20
%22 = icmp eq i64 %21, 0
%23 = add nuw nsw i64 %21, 65535
%24 = and i64 %23, 64512
%25 = select i1 %22, i64 0, i64 %24
%26 = or i64 %18, %25
%27 = or i64 %26, %10
ret i64 %27
}