#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int last_bit(unsigned long long);
unsigned long long flip_F3(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 & 0X0000000200000000ULL) & (discs_player << 9);
  flipped |= (discs_opponent & 0X0000020000000000ULL) & (discs_player << 1);
  flipped |= (discs_opponent & 0X0002000000000000ULL) & (discs_player >> 7);
  flipped |= (discs_opponent & 0X0004000000000000ULL) & (discs_player >> 8);
  flipped |= (discs_opponent & 0X0008000000000000ULL) & (discs_player >> 9);
  my_discs = discs_player & 0X0000000004040404ULL;
  opp_discs = (discs_opponent & 0X0000000404040400ULL) | 0X000003FBFBFBF800ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000040000000000ULL;
  if (r != 0) {
    flipped |= (0X0000040000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000404040400ULL;
  }
  my_discs = discs_player & 0X0000000010204080ULL;
  opp_discs = (discs_opponent & 0X0000000810204000ULL) | 0X000003F7EFDF8000ULL;
  r = ((my_discs << 7) + opp_discs) & 0X0000040000000000ULL;
  if (r != 0) {
    flipped |= (0X0000040000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000810204000ULL;
  }
  my_discs = discs_player & 0X0000F00000000000ULL;
  r = (discs_opponent + 0X0000080000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000F80000000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_F3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x200000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shl    $0x9,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
movabs $0x20000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shl    $0x1,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x2000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x7,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x4000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x8,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x8000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x9,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x4040404,%rax
mov    %rax,-0x18(%rbp)
movabs $0x404040400,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbfbfbf800,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x40000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1250 <flip_F3+0x140>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
movabs $0x40000000000,%rax
sub    %rcx,%rax
movabs $0x404040400,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x10204080,%rax
mov    %rax,-0x18(%rbp)
movabs $0x810204000,%rax
and    -0x10(%rbp),%rax
movabs $0x3f7efdf8000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x7,%rax
add    -0x20(%rbp),%rax
movabs $0x40000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12df <flip_F3+0x1cf>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
movabs $0x40000000000,%rax
sub    %rcx,%rax
movabs $0x810204000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0xf00000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x80000000000,%rax
add    -0x10(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     132f <flip_F3+0x21f>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0xf80000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_F3>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
movabs $0x40000000000,%r15
movabs $0x404040400,%r13
mov    %rdi,%rax
shl    $0x9,%rax
and    %rsi,%rax
movabs $0x200000000,%rcx
and    %rax,%rcx
lea    (%rdi,%rdi,1),%rax
and    %rsi,%rax
movabs $0x20000000000,%rdx
and    %rax,%rdx
or     %rcx,%rdx
mov    %rdi,%rax
shr    $0x7,%rax
and    %rsi,%rax
movabs $0x2000000000000,%rcx
and    %rax,%rcx
or     %rdx,%rcx
mov    %rdi,%rax
shr    $0x8,%rax
and    %rsi,%rax
movabs $0x4000000000000,%rdx
and    %rax,%rdx
or     %rcx,%rdx
mov    %rdi,%rax
shr    $0x9,%rax
and    %rsi,%rax
movabs $0x8000000000000,%r12
and    %rax,%r12
or     %rdx,%r12
and    $0x4040404,%edi
mov    %rsi,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
movabs $0x3fbfbfbf800,%rax
add    %rcx,%rax
bt     $0x2a,%rax
jae    11f0 <flip_F3+0xe0>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r12
movabs $0x810204000,%r13
mov    %r14d,%edi
and    $0x10204080,%edi
mov    %rbx,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x7,%rcx
add    %rax,%rcx
movabs $0x3f7efdf8000,%rax
add    %rcx,%rax
test   %r15,%rax
je     123c <flip_F3+0x12c>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r12
movabs $0x80000000000,%rax
add    %rax,%rbx
and    %rbx,%r14
movabs $0xf00000000000,%rcx
and    %r14,%rcx
lea    -0x1(%rcx),%rdx
movabs $0xf80000000000,%rax
and    %rdx,%rax
test   %rcx,%rcx
cmove  %rcx,%rax
or     %r12,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_F3(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, 8589934592
%11 = load i64, i64* %3
%12 = shl i64 %11, 9
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %4
%15 = and i64 %14, 2199023255552
%16 = load i64, i64* %3
%17 = shl i64 %16, 1
%18 = and i64 %15, %17
%19 = load i64, i64* %8
%20 = or i64 %19, %18
store i64 %20, i64* %8
%21 = load i64, i64* %4
%22 = and i64 %21, 562949953421312
%23 = load i64, i64* %3
%24 = lshr i64 %23, 7
%25 = and i64 %22, %24
%26 = load i64, i64* %8
%27 = or i64 %26, %25
store i64 %27, i64* %8
%28 = load i64, i64* %4
%29 = and i64 %28, 1125899906842624
%30 = load i64, i64* %3
%31 = lshr i64 %30, 8
%32 = and i64 %29, %31
%33 = load i64, i64* %8
%34 = or i64 %33, %32
store i64 %34, i64* %8
%35 = load i64, i64* %4
%36 = and i64 %35, 2251799813685248
%37 = load i64, i64* %3
%38 = lshr i64 %37, 9
%39 = and i64 %36, %38
%40 = load i64, i64* %8
%41 = or i64 %40, %39
store i64 %41, i64* %8
%42 = load i64, i64* %3
%43 = and i64 %42, 67372036
store i64 %43, i64* %5
%44 = load i64, i64* %4
%45 = and i64 %44, 17247241216
%46 = or i64 %45, 4380799268864
store i64 %46, i64* %6
%47 = load i64, i64* %5
%48 = shl i64 %47, 8
%49 = load i64, i64* %6
%50 = add i64 %48, %49
%51 = and i64 %50, 4398046511104
store i64 %51, i64* %7
%52 = load i64, i64* %7
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %63
54: ; preds = %2
%55 = load i64, i64* %5
%56 = call i32 @last_bit(i64 %55)
%57 = zext i32 %56 to i64
%58 = shl i64 2, %57
%59 = sub i64 4398046511104, %58
%60 = and i64 %59, 17247241216
%61 = load i64, i64* %8
%62 = or i64 %61, %60
store i64 %62, i64* %8
br label %63
63: ; preds = %54, %2
%64 = load i64, i64* %3
%65 = and i64 %64, 270549120
store i64 %65, i64* %5
%66 = load i64, i64* %4
%67 = and i64 %66, 34630287360
%68 = or i64 %67, 4363416207360
store i64 %68, i64* %6
%69 = load i64, i64* %5
%70 = shl i64 %69, 7
%71 = load i64, i64* %6
%72 = add i64 %70, %71
%73 = and i64 %72, 4398046511104
store i64 %73, i64* %7
%74 = load i64, i64* %7
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %85
76: ; preds = %63
%77 = load i64, i64* %5
%78 = call i32 @last_bit(i64 %77)
%79 = zext i32 %78 to i64
%80 = shl i64 2, %79
%81 = sub i64 4398046511104, %80
%82 = and i64 %81, 34630287360
%83 = load i64, i64* %8
%84 = or i64 %83, %82
store i64 %84, i64* %8
br label %85
85: ; preds = %76, %63
%86 = load i64, i64* %3
%87 = and i64 %86, 263882790666240
store i64 %87, i64* %5
%88 = load i64, i64* %4
%89 = add i64 %88, 8796093022208
%90 = load i64, i64* %5
%91 = and i64 %89, %90
store i64 %91, i64* %7
%92 = load i64, i64* %7
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %100
94: ; preds = %85
%95 = load i64, i64* %7
%96 = sub i64 %95, 1
%97 = and i64 %96, 272678883688448
%98 = load i64, i64* %8
%99 = or i64 %98, %97
store i64 %99, i64* %8
br label %100
100: ; preds = %94, %85
%101 = load i64, i64* %8
ret i64 %101
}

LLVM IR (-O2):
define i64 @flip_F3(i64 %0, i64 %1) {
%3 = and i64 %1, 8589934592
%4 = shl i64 %0, 9
%5 = and i64 %3, %4
%6 = and i64 %1, 2199023255552
%7 = shl i64 %0, 1
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %1, 562949953421312
%11 = lshr i64 %0, 7
%12 = and i64 %10, %11
%13 = or i64 %9, %12
%14 = and i64 %1, 1125899906842624
%15 = lshr i64 %0, 8
%16 = and i64 %14, %15
%17 = or i64 %13, %16
%18 = and i64 %1, 2251799813685248
%19 = lshr i64 %0, 9
%20 = and i64 %18, %19
%21 = or i64 %17, %20
%22 = and i64 %0, 67372036
%23 = and i64 %1, 17247241216
%24 = or i64 %23, 4380799268864
%25 = shl nuw nsw i64 %22, 8
%26 = add nuw nsw i64 %24, %25
%27 = and i64 %26, 4398046511104
%28 = icmp eq i64 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %2
%30 = tail call i32 @last_bit(i64 %22)
%31 = zext i32 %30 to i64
%32 = shl i64 -2, %31
%33 = and i64 %32, 17247241216
%34 = or i64 %33, %21
br label %35
35: ; preds = %29, %2
%36 = phi i64 [ %34, %29 ], [ %21, %2 ]
%37 = and i64 %0, 270549120
%38 = and i64 %1, 34630287360
%39 = or i64 %38, 4363416207360
%40 = shl nuw nsw i64 %37, 7
%41 = add nuw nsw i64 %39, %40
%42 = and i64 %41, 4398046511104
%43 = icmp eq i64 %42, 0
br i1 %43, label %50, label %44
44: ; preds = %35
%45 = tail call i32 @last_bit(i64 %37)
%46 = zext i32 %45 to i64
%47 = shl i64 -2, %46
%48 = and i64 %47, 34630287360
%49 = or i64 %48, %36
br label %50
50: ; preds = %44, %35
%51 = phi i64 [ %49, %44 ], [ %36, %35 ]
%52 = and i64 %0, 263882790666240
%53 = add i64 %1, 8796093022208
%54 = and i64 %52, %53
%55 = icmp eq i64 %54, 0
%56 = add nuw nsw i64 %54, 281474976710655
%57 = and i64 %56, 272678883688448
%58 = select i1 %55, i64 0, i64 %57
%59 = or i64 %51, %58
ret i64 %59
}