unsigned long long flip_F7(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 & 0X0000000000000200ULL) & (discs_player << 1);
  my_discs = discs_player & 0X0404040404000000ULL;
  opp_discs = (discs_opponent & 0X0004040404040000ULL) | 0X03FBFBFBFBF80000ULL;
  r = (opp_discs + 0X0000000000040000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0004040404040000ULL;
  }
  flipped |= (discs_opponent & 0X0000000000020000ULL) & (discs_player >> 7);
  my_discs = discs_player & 0X0080402010000000ULL;
  opp_discs = (discs_opponent & 0X0000402010080000ULL) | 0X007FBFDFEFF00000ULL;
  r = (opp_discs + 0X0000000000080000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000402010080000ULL;
  }
  my_discs = discs_player & 0X000000000000F000ULL;
  r = (discs_opponent + 0X0000000000000800ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X000000000000F800ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_F7>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0x200,%rax
mov    -0x8(%rbp),%rcx
shl    $0x1,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
movabs $0x404040404000000,%rax
04 04 04
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x4040404040000,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbfbfbfbf80000,%rcx
fb fb 03
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     1190 <flip_F7+0x90>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x4040404040000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
and    $0x20000,%rax
mov    -0x8(%rbp),%rcx
shr    $0x7,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x80402010000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x402010080000,%rax
and    -0x10(%rbp),%rax
movabs $0x7fbfdfeff00000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x80000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1218 <flip_F7+0x118>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x402010080000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xf000,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x800,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1259 <flip_F7+0x159>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0xf800,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_F7>:
lea    (%rdi,%rdi,1),%r8d
and    %esi,%r8d
and    $0x200,%r8d
movabs $0x4040404040000,%rax
mov    %rsi,%rcx
and    %rax,%rcx
movabs $0x3fbfbfbfbfc0000,%rdx
fb fb 03
add    %rcx,%rdx
movabs $0x404040404000000,%rcx
04 04 04
and    %rdi,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%r10
and    %rax,%r10
test   %rcx,%rcx
cmove  %rcx,%r10
mov    %edi,%eax
shr    $0x7,%eax
and    %esi,%eax
and    $0x20000,%eax
movabs $0x402010080000,%r9
mov    %rsi,%rcx
and    %r9,%rcx
movabs $0x7fbfdfeff80000,%rdx
add    %rcx,%rdx
movabs $0x80402010000000,%rcx
and    %rdi,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rdx
and    %r9,%rdx
test   %rcx,%rcx
cmove  %rcx,%rdx
lea    0x800(%rsi),%ecx
and    %edi,%ecx
and    $0xf000,%ecx
lea    -0x1(%rcx),%esi
and    $0xf800,%esi
test   %rcx,%rcx
cmove  %rcx,%rsi
or     %r8,%rax
or     %rsi,%rax
or     %r10,%rax
or     %rdx,%rax
ret

LLVM IR (-O0):
define i64 @flip_F7(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, 512
%11 = load i64, i64* %3
%12 = shl i64 %11, 1
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %3
%15 = and i64 %14, 289360691352043520
store i64 %15, i64* %5
%16 = load i64, i64* %4
%17 = and i64 %16, 1130315200593920
%18 = or i64 %17, 287100060950855680
store i64 %18, i64* %6
%19 = load i64, i64* %6
%20 = add i64 %19, 262144
%21 = load i64, i64* %5
%22 = and i64 %20, %21
store i64 %22, i64* %7
%23 = load i64, i64* %7
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %2
%26 = load i64, i64* %7
%27 = sub i64 %26, 1
%28 = and i64 %27, 1130315200593920
%29 = load i64, i64* %8
%30 = or i64 %29, %28
store i64 %30, i64* %8
br label %31
31: ; preds = %25, %2
%32 = load i64, i64* %4
%33 = and i64 %32, 131072
%34 = load i64, i64* %3
%35 = lshr i64 %34, 7
%36 = and i64 %33, %35
%37 = load i64, i64* %8
%38 = or i64 %37, %36
store i64 %38, i64* %8
%39 = load i64, i64* %3
%40 = and i64 %39, 36099303470530560
store i64 %40, i64* %5
%41 = load i64, i64* %4
%42 = and i64 %41, 70506452090880
%43 = or i64 %42, 35958290566348800
store i64 %43, i64* %6
%44 = load i64, i64* %6
%45 = add i64 %44, 524288
%46 = load i64, i64* %5
%47 = and i64 %45, %46
store i64 %47, i64* %7
%48 = load i64, i64* %7
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %56
50: ; preds = %31
%51 = load i64, i64* %7
%52 = sub i64 %51, 1
%53 = and i64 %52, 70506452090880
%54 = load i64, i64* %8
%55 = or i64 %54, %53
store i64 %55, i64* %8
br label %56
56: ; preds = %50, %31
%57 = load i64, i64* %3
%58 = and i64 %57, 61440
store i64 %58, i64* %5
%59 = load i64, i64* %4
%60 = add i64 %59, 2048
%61 = load i64, i64* %5
%62 = and i64 %60, %61
store i64 %62, i64* %7
%63 = load i64, i64* %7
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %56
%66 = load i64, i64* %7
%67 = sub i64 %66, 1
%68 = and i64 %67, 63488
%69 = load i64, i64* %8
%70 = or i64 %69, %68
store i64 %70, i64* %8
br label %71
71: ; preds = %65, %56
%72 = load i64, i64* %8
ret i64 %72
}

LLVM IR (-O2):
define i64 @flip_F7(i64 %0, i64 %1) {
%3 = and i64 %1, 512
%4 = shl i64 %0, 1
%5 = and i64 %3, %4
%6 = and i64 %0, 289360691352043520
%7 = and i64 %1, 1130315200593920
%8 = add nuw nsw i64 %7, 287100060951117824
%9 = and i64 %6, %8
%10 = icmp eq i64 %9, 0
%11 = add nuw nsw i64 %9, 2251799813685247
%12 = and i64 %11, 1130315200593920
%13 = select i1 %10, i64 0, i64 %12
%14 = and i64 %1, 131072
%15 = lshr i64 %0, 7
%16 = and i64 %14, %15
%17 = and i64 %0, 36099303470530560
%18 = and i64 %1, 70506452090880
%19 = add nuw nsw i64 %18, 35958290566873088
%20 = and i64 %17, %19
%21 = icmp eq i64 %20, 0
%22 = add nuw nsw i64 %20, 140737488355327
%23 = and i64 %22, 70506452090880
%24 = select i1 %21, i64 0, i64 %23
%25 = and i64 %0, 61440
%26 = add i64 %1, 2048
%27 = and i64 %25, %26
%28 = icmp eq i64 %27, 0
%29 = add nuw nsw i64 %27, 65535
%30 = and i64 %29, 63488
%31 = select i1 %28, i64 0, i64 %30
%32 = or i64 %16, %5
%33 = or i64 %32, %31
%34 = or i64 %33, %13
%35 = or i64 %34, %24
ret i64 %35
}