#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_F2(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 & 0X0002000000000000ULL) & (discs_player << 1);
  flipped |= (discs_opponent & 0X0000020000000000ULL) & (discs_player << 9);
  my_discs = discs_player & 0X0000000404040404ULL;
  opp_discs = (discs_opponent & 0X0000040404040400ULL) | 0X0003FBFBFBFBF800ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0004000000000000ULL;
  if (r != 0) {
    flipped |= (0X0004000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000040404040400ULL;
  }
  my_discs = discs_player & 0X0000001020408000ULL;
  opp_discs = (discs_opponent & 0X0000081020400000ULL) | 0X0003F7EFDF800000ULL;
  r = ((my_discs << 7) + opp_discs) & 0X0004000000000000ULL;
  if (r != 0) {
    flipped |= (0X0004000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000081020400000ULL;
  }
  my_discs = discs_player & 0X00F0000000000000ULL;
  r = (discs_opponent + 0X0008000000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X00F8000000000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_F2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x2000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shl    $0x1,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
movabs $0x20000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shl    $0x9,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x404040404,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x40404040400,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbfbfbfbf800,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x4000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f1 <flip_F2+0xe1>
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 $0x4000000000000,%rax
sub    %rcx,%rax
movabs $0x40404040400,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x1020408000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x81020400000,%rax
and    -0x10(%rbp),%rax
movabs $0x3f7efdf800000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x7,%rax
add    -0x20(%rbp),%rax
movabs $0x4000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1284 <flip_F2+0x174>
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 $0x4000000000000,%rax
sub    %rcx,%rax
movabs $0x81020400000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0xf0000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x8000000000000,%rax
add    -0x10(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12d4 <flip_F2+0x1c4>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0xf8000000000000,%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_F2>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movabs $0x4000000000000,%r12
movabs $0x40404040400,%r13
lea    (%rdi,%rdi,1),%rax
and    %rsi,%rax
movabs $0x2000000000000,%rcx
and    %rax,%rcx
mov    %rdi,%rax
shl    $0x9,%rax
and    %rsi,%rax
movabs $0x20000000000,%rbx
and    %rax,%rbx
or     %rcx,%rbx
movabs $0x404040404,%rdi
and    %r14,%rdi
mov    %rsi,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
movabs $0x3fbfbfbfbf800,%rax
add    %rcx,%rax
bt     $0x32,%rax
jae    11a9 <flip_F2+0x99>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%rbx
movabs $0x81020400000,%r13
movabs $0x1020408000,%rdi
and    %r14,%rdi
mov    %r15,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x7,%rcx
add    %rax,%rcx
movabs $0x3f7efdf800000,%rax
add    %rcx,%rax
test   %r12,%rax
je     11f9 <flip_F2+0xe9>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%rbx
movabs $0x8000000000000,%rax
add    %rax,%r15
and    %r15,%r14
movabs $0xf0000000000000,%rcx
and    %r14,%rcx
lea    -0x1(%rcx),%rdx
movabs $0xf8000000000000,%rax
and    %rdx,%rax
test   %rcx,%rcx
cmove  %rcx,%rax
or     %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_F2(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, 562949953421312
%11 = load i64, i64* %3
%12 = shl i64 %11, 1
%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, 9
%18 = and i64 %15, %17
%19 = load i64, i64* %8
%20 = or i64 %19, %18
store i64 %20, i64* %8
%21 = load i64, i64* %3
%22 = and i64 %21, 17247241220
store i64 %22, i64* %5
%23 = load i64, i64* %4
%24 = and i64 %23, 4415293752320
%25 = or i64 %24, 1121484613089280
store i64 %25, i64* %6
%26 = load i64, i64* %5
%27 = shl i64 %26, 8
%28 = load i64, i64* %6
%29 = add i64 %27, %28
%30 = and i64 %29, 1125899906842624
store i64 %30, i64* %7
%31 = load i64, i64* %7
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %2
%34 = load i64, i64* %5
%35 = call i32 @last_bit(i64 %34)
%36 = zext i32 %35 to i64
%37 = shl i64 2, %36
%38 = sub i64 1125899906842624, %37
%39 = and i64 %38, 4415293752320
%40 = load i64, i64* %8
%41 = or i64 %40, %39
store i64 %41, i64* %8
br label %42
42: ; preds = %33, %2
%43 = load i64, i64* %3
%44 = and i64 %43, 69260574720
store i64 %44, i64* %5
%45 = load i64, i64* %4
%46 = and i64 %45, 8865353564160
%47 = or i64 %46, 1117034549084160
store i64 %47, i64* %6
%48 = load i64, i64* %5
%49 = shl i64 %48, 7
%50 = load i64, i64* %6
%51 = add i64 %49, %50
%52 = and i64 %51, 1125899906842624
store i64 %52, i64* %7
%53 = load i64, i64* %7
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %64
55: ; preds = %42
%56 = load i64, i64* %5
%57 = call i32 @last_bit(i64 %56)
%58 = zext i32 %57 to i64
%59 = shl i64 2, %58
%60 = sub i64 1125899906842624, %59
%61 = and i64 %60, 8865353564160
%62 = load i64, i64* %8
%63 = or i64 %62, %61
store i64 %63, i64* %8
br label %64
64: ; preds = %55, %42
%65 = load i64, i64* %3
%66 = and i64 %65, 67553994410557440
store i64 %66, i64* %5
%67 = load i64, i64* %4
%68 = add i64 %67, 2251799813685248
%69 = load i64, i64* %5
%70 = and i64 %68, %69
store i64 %70, i64* %7
%71 = load i64, i64* %7
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %64
%74 = load i64, i64* %7
%75 = sub i64 %74, 1
%76 = and i64 %75, 69805794224242688
%77 = load i64, i64* %8
%78 = or i64 %77, %76
store i64 %78, i64* %8
br label %79
79: ; preds = %73, %64
%80 = load i64, i64* %8
ret i64 %80
}

LLVM IR (-O2):
define i64 @flip_F2(i64 %0, i64 %1) {
%3 = and i64 %1, 562949953421312
%4 = shl i64 %0, 1
%5 = and i64 %3, %4
%6 = and i64 %1, 2199023255552
%7 = shl i64 %0, 9
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %0, 17247241220
%11 = and i64 %1, 4415293752320
%12 = or i64 %11, 1121484613089280
%13 = shl nuw nsw i64 %10, 8
%14 = add nuw nsw i64 %12, %13
%15 = and i64 %14, 1125899906842624
%16 = icmp eq i64 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %2
%18 = tail call i32 @last_bit(i64 %10)
%19 = zext i32 %18 to i64
%20 = shl i64 -2, %19
%21 = and i64 %20, 4415293752320
%22 = or i64 %21, %9
br label %23
23: ; preds = %17, %2
%24 = phi i64 [ %22, %17 ], [ %9, %2 ]
%25 = and i64 %0, 69260574720
%26 = and i64 %1, 8865353564160
%27 = or i64 %26, 1117034549084160
%28 = shl nuw nsw i64 %25, 7
%29 = add nuw nsw i64 %27, %28
%30 = and i64 %29, 1125899906842624
%31 = icmp eq i64 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %23
%33 = tail call i32 @last_bit(i64 %25)
%34 = zext i32 %33 to i64
%35 = shl i64 -2, %34
%36 = and i64 %35, 8865353564160
%37 = or i64 %36, %24
br label %38
38: ; preds = %32, %23
%39 = phi i64 [ %37, %32 ], [ %24, %23 ]
%40 = and i64 %0, 67553994410557440
%41 = add i64 %1, 2251799813685248
%42 = and i64 %40, %41
%43 = icmp eq i64 %42, 0
%44 = add nuw nsw i64 %42, 72057594037927935
%45 = and i64 %44, 69805794224242688
%46 = select i1 %43, i64 0, i64 %45
%47 = or i64 %39, %46
ret i64 %47
}