unsigned long long flip_B1(const unsigned long long P,
                           const unsigned long long O) {
  unsigned long long flipped, outflank_v, outflank_h, outflank_d9;
  outflank_v = ((O | ~0x0202020202020200ULL) + 0x0000000000000200ULL) & P &
               0x0202020202020200ULL;
  flipped =
      (outflank_v - (unsigned int)(outflank_v != 0)) & 0x0202020202020200ULL;
  outflank_h = ((O & 0x000000000000007cULL) + 0x0000000000000004ULL) & P;
  flipped |=
      (outflank_h - (unsigned int)(outflank_h != 0)) & 0x000000000000007cULL;
  outflank_d9 = ((O | ~0x0080402010080400ULL) + 0x0000000000000400ULL) & P &
                0x0080402010080400ULL;
  flipped |=
      (outflank_d9 - (unsigned int)(outflank_d9 != 0)) & 0x0080402010080400ULL;
  return flipped;
}


x86 assembly (clang, -O0):
<flip_B1>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0xfdfdfdfdfdfdfdff,%rax
fd fd fd
or     -0x10(%rbp),%rax
add    $0x200,%rax
and    -0x8(%rbp),%rax
movabs $0x202020202020200,%rcx
02 02 02
and    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,-0x20(%rbp)
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
movabs $0x202020202020200,%rcx
02 02 02
and    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x7c,%rax
add    $0x4,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,-0x28(%rbp)
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
and    $0x7c,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0xff7fbfdfeff7fbff,%rax
bf 7f ff
or     -0x10(%rbp),%rax
add    $0x400,%rax
and    -0x8(%rbp),%rax
movabs $0x80402010080400,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpq   $0x0,-0x30(%rbp)
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
movabs $0x80402010080400,%rcx
and    %rcx,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_B1>:
movabs $0x1fdfdfdfdfdfdff,%rax
fd fd 01
or     %rsi,%rax
add    $0x200,%rax
movabs $0x202020202020200,%rcx
02 02 02
mov    %rdi,%rdx
and    %rcx,%rdx
and    %rax,%rdx
cmp    $0x1,%rdx
adc    $0xffffffffffffffff,%rdx
and    %rcx,%rdx
mov    %esi,%eax
and    $0x7c,%eax
add    $0x4,%eax
xor    %r8d,%r8d
mov    %edi,%ecx
and    %eax,%ecx
setne  %r8b
sub    %r8d,%ecx
and    $0x7c,%ecx
or     %rdx,%rcx
movabs $0x7fbfdfeff7fbff,%rax
or     %rsi,%rax
add    $0x400,%rax
movabs $0x80402010080400,%rdx
and    %rdx,%rdi
and    %rdi,%rax
cmp    $0x1,%rax
adc    $0xffffffffffffffff,%rax
and    %rdx,%rax
or     %rcx,%rax
ret

LLVM IR (-O0):
define i64 @flip_B1(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 = or i64 %9, -144680345676153345
%11 = add i64 %10, 512
%12 = load i64, i64* %3
%13 = and i64 %11, %12
%14 = and i64 %13, 144680345676153344
store i64 %14, i64* %6
%15 = load i64, i64* %6
%16 = load i64, i64* %6
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i32
%19 = zext i32 %18 to i64
%20 = sub i64 %15, %19
%21 = and i64 %20, 144680345676153344
store i64 %21, i64* %5
%22 = load i64, i64* %4
%23 = and i64 %22, 124
%24 = add i64 %23, 4
%25 = load i64, i64* %3
%26 = and i64 %24, %25
store i64 %26, i64* %7
%27 = load i64, i64* %7
%28 = load i64, i64* %7
%29 = icmp ne i64 %28, 0
%30 = zext i1 %29 to i32
%31 = zext i32 %30 to i64
%32 = sub i64 %27, %31
%33 = and i64 %32, 124
%34 = load i64, i64* %5
%35 = or i64 %34, %33
store i64 %35, i64* %5
%36 = load i64, i64* %4
%37 = or i64 %36, -36099303471055873
%38 = add i64 %37, 1024
%39 = load i64, i64* %3
%40 = and i64 %38, %39
%41 = and i64 %40, 36099303471055872
store i64 %41, i64* %8
%42 = load i64, i64* %8
%43 = load i64, i64* %8
%44 = icmp ne i64 %43, 0
%45 = zext i1 %44 to i32
%46 = zext i32 %45 to i64
%47 = sub i64 %42, %46
%48 = and i64 %47, 36099303471055872
%49 = load i64, i64* %5
%50 = or i64 %49, %48
store i64 %50, i64* %5
%51 = load i64, i64* %5
ret i64 %51
}

LLVM IR (-O2):
define i64 @flip_B1(i64 %0, i64 %1) {
%3 = or i64 %1, 143550030475558399
%4 = add i64 %3, 512
%5 = and i64 %0, 144680345676153344
%6 = and i64 %5, %4
%7 = icmp ne i64 %6, 0
%8 = sext i1 %7 to i64
%9 = add nsw i64 %6, %8
%10 = and i64 %9, 144680345676153344
%11 = and i64 %1, 124
%12 = add nuw nsw i64 %11, 4
%13 = and i64 %12, %0
%14 = icmp ne i64 %13, 0
%15 = sext i1 %14 to i64
%16 = add nsw i64 %13, %15
%17 = and i64 %16, 124
%18 = or i64 %10, %17
%19 = or i64 %1, 35958290566872063
%20 = add i64 %19, 1024
%21 = and i64 %0, 36099303471055872
%22 = and i64 %21, %20
%23 = icmp ne i64 %22, 0
%24 = sext i1 %23 to i64
%25 = add nsw i64 %22, %24
%26 = and i64 %25, 36099303471055872
%27 = or i64 %18, %26
ret i64 %27
}