unsigned long long flip_A1(const unsigned long long P,
                           const unsigned long long O) {
  unsigned long long flipped, outflank_v, outflank_h, outflank_d9;
  outflank_v = ((O | ~0x0101010101010100ULL) + 0x0000000000000100ULL) & P &
               0x0101010101010100ULL;
  flipped =
      (outflank_v - (unsigned int)(outflank_v != 0)) & 0x0101010101010100ULL;
  outflank_h = ((O & 0x000000000000007eULL) + 0x0000000000000002ULL) & P;
  flipped |=
      (outflank_h - (unsigned int)(outflank_h != 0)) & 0x000000000000007eULL;
  outflank_d9 = ((O | ~0x8040201008040200ULL) + 0x0000000000000200ULL) & P &
                0x8040201008040200ULL;
  flipped |=
      (outflank_d9 - (unsigned int)(outflank_d9 != 0)) & 0x8040201008040200ULL;
  return flipped;
}


x86 assembly (clang, -O0):
<flip_A1>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0xfefefefefefefeff,%rax
fe fe fe
or     -0x10(%rbp),%rax
add    $0x100,%rax
and    -0x8(%rbp),%rax
movabs $0x101010101010100,%rcx
01 01 01
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 $0x101010101010100,%rcx
01 01 01
and    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x7e,%rax
add    $0x2,%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    $0x7e,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x7fbfdfeff7fbfdff,%rax
df bf 7f
or     -0x10(%rbp),%rax
add    $0x200,%rax
and    -0x8(%rbp),%rax
movabs $0x8040201008040200,%rcx
20 40 80
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 $0x8040201008040200,%rcx
20 40 80
and    %rcx,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_A1>:
movabs $0xfefefefefefeff,%rax
or     %rsi,%rax
add    $0x100,%rax
movabs $0x101010101010100,%rcx
01 01 01
mov    %rdi,%rdx
and    %rcx,%rdx
and    %rax,%rdx
cmp    $0x1,%rdx
adc    $0xffffffffffffffff,%rdx
and    %rcx,%rdx
mov    %esi,%eax
and    $0x7e,%eax
add    $0x2,%eax
xor    %r8d,%r8d
mov    %edi,%ecx
and    %eax,%ecx
setne  %r8b
sub    %r8d,%ecx
and    $0x7e,%ecx
or     %rdx,%rcx
movabs $0x7fbfdfeff7fbfdff,%rax
df bf 7f
or     %rsi,%rax
add    $0x200,%rax
movabs $0x8040201008040200,%rdx
20 40 80
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_A1(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, -72340172838076673
%11 = add i64 %10, 256
%12 = load i64, i64* %3
%13 = and i64 %11, %12
%14 = and i64 %13, 72340172838076672
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, 72340172838076672
store i64 %21, i64* %5
%22 = load i64, i64* %4
%23 = and i64 %22, 126
%24 = add i64 %23, 2
%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, 126
%34 = load i64, i64* %5
%35 = or i64 %34, %33
store i64 %35, i64* %5
%36 = load i64, i64* %4
%37 = or i64 %36, 9205322385119247871
%38 = add i64 %37, 512
%39 = load i64, i64* %3
%40 = and i64 %38, %39
%41 = and i64 %40, -9205322385119247872
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, -9205322385119247872
%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_A1(i64 %0, i64 %1) {
%3 = or i64 %1, 71775015237779199
%4 = add i64 %3, 256
%5 = and i64 %0, 72340172838076672
%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, 72340172838076672
%11 = and i64 %1, 126
%12 = add nuw nsw i64 %11, 2
%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, 126
%18 = or i64 %10, %17
%19 = or i64 %1, 9205322385119247871
%20 = add i64 %19, 512
%21 = and i64 %0, -9205322385119247872
%22 = and i64 %21, %20
%23 = icmp ne i64 %22, 0
%24 = sext i1 %23 to i64
%25 = add i64 %22, %24
%26 = and i64 %25, -9205322385119247872
%27 = or i64 %18, %26
ret i64 %27
}