#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_F1(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 & 0X0200000000000000ULL) & (discs_player << 1);
  my_discs = discs_player & 0X0000040404040404ULL;
  opp_discs = (discs_opponent & 0X0004040404040400ULL) | 0X03FBFBFBFBFBF800ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0400000000000000ULL;
  if (r != 0) {
    flipped |= (0X0400000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0004040404040400ULL;
  }
  flipped |= (discs_opponent & 0X0002000000000000ULL) & (discs_player << 9);
  my_discs = discs_player & 0X0000102040800000ULL;
  opp_discs = (discs_opponent & 0X0008102040000000ULL) | 0X03F7EFDF80000000ULL;
  r = ((my_discs << 7) + opp_discs) & 0X0400000000000000ULL;
  if (r != 0) {
    flipped |= (0X0400000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0008102040000000ULL;
  }
  my_discs = discs_player & 0XF000000000000000ULL;
  r = (discs_opponent + 0X0800000000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0XF800000000000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_F1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x200000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shl    $0x1,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
movabs $0x40404040404,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x4040404040400,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbfbfbfbfbf800,%rcx
fb fb 03
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x400000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11d0 <flip_F1+0xc0>
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 $0x400000000000000,%rax
sub    %rcx,%rax
movabs $0x4040404040400,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x2000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shl    $0x9,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x102040800000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x8102040000000,%rax
and    -0x10(%rbp),%rax
movabs $0x3f7efdf80000000,%rcx
ef f7 03
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x7,%rax
add    -0x20(%rbp),%rax
movabs $0x400000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1284 <flip_F1+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 $0x400000000000000,%rax
sub    %rcx,%rax
movabs $0x8102040000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0xf000000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x800000000000000,%rax
add    -0x10(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12d4 <flip_F1+0x1c4>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0xf800000000000000,%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_F1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
movabs $0x400000000000000,%r15
movabs $0x4040404040400,%rbx
lea    (%rdi,%rdi,1),%rax
and    %rsi,%rax
movabs $0x200000000000000,%r13
and    %rax,%r13
movabs $0x40404040404,%rdi
and    %r14,%rdi
mov    %rsi,%rax
and    %rbx,%rax
mov    %rdi,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
movabs $0x3fbfbfbfbfbf800,%rax
fb fb 03
add    %rcx,%rax
bt     $0x3a,%rax
jae    1191 <flip_F1+0x81>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %rbx,%rdx
or     %rdx,%r13
movabs $0x8102040000000,%rbp
mov    %r14,%rax
shl    $0x9,%rax
and    %r12,%rax
movabs $0x2000000000000,%rbx
and    %rax,%rbx
or     %r13,%rbx
movabs $0x102040800000,%rdi
and    %r14,%rdi
mov    %r12,%rax
and    %rbp,%rax
mov    %rdi,%rcx
shl    $0x7,%rcx
add    %rax,%rcx
movabs $0x3f7efdf80000000,%rax
ef f7 03
add    %rcx,%rax
test   %r15,%rax
je     11fb <flip_F1+0xeb>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %rbp,%rdx
or     %rdx,%rbx
movabs $0x800000000000000,%rax
add    %rax,%r12
and    %r12,%r14
movabs $0xf000000000000000,%rcx
and    %r14,%rcx
lea    -0x1(%rcx),%rax
movabs $0xf800000000000000,%rdx
and    %rax,%rdx
xor    %eax,%eax
cmp    $0x1,%rcx
cmovae %rdx,%rax
or     %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @flip_F1(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, 144115188075855872
%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, 4415293752324
store i64 %15, i64* %5
%16 = load i64, i64* %4
%17 = and i64 %16, 1130315200594944
%18 = or i64 %17, 287100060951115776
store i64 %18, i64* %6
%19 = load i64, i64* %5
%20 = shl i64 %19, 8
%21 = load i64, i64* %6
%22 = add i64 %20, %21
%23 = and i64 %22, 288230376151711744
store i64 %23, i64* %7
%24 = load i64, i64* %7
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %2
%27 = load i64, i64* %5
%28 = call i32 @last_bit(i64 %27)
%29 = zext i32 %28 to i64
%30 = shl i64 2, %29
%31 = sub i64 288230376151711744, %30
%32 = and i64 %31, 1130315200594944
%33 = load i64, i64* %8
%34 = or i64 %33, %32
store i64 %34, i64* %8
br label %35
35: ; preds = %26, %2
%36 = load i64, i64* %4
%37 = and i64 %36, 562949953421312
%38 = load i64, i64* %3
%39 = shl i64 %38, 9
%40 = and i64 %37, %39
%41 = load i64, i64* %8
%42 = or i64 %41, %40
store i64 %42, i64* %8
%43 = load i64, i64* %3
%44 = and i64 %43, 17730707128320
store i64 %44, i64* %5
%45 = load i64, i64* %4
%46 = and i64 %45, 2269530512424960
%47 = or i64 %46, 285960844565544960
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, 288230376151711744
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 = %35
%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 288230376151711744, %59
%61 = and i64 %60, 2269530512424960
%62 = load i64, i64* %8
%63 = or i64 %62, %61
store i64 %63, i64* %8
br label %64
64: ; preds = %55, %35
%65 = load i64, i64* %3
%66 = and i64 %65, -1152921504606846976
store i64 %66, i64* %5
%67 = load i64, i64* %4
%68 = add i64 %67, 576460752303423488
%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, -576460752303423488
%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_F1(i64 %0, i64 %1) {
%3 = and i64 %1, 144115188075855872
%4 = shl i64 %0, 1
%5 = and i64 %3, %4
%6 = and i64 %0, 4415293752324
%7 = and i64 %1, 1130315200594944
%8 = or i64 %7, 287100060951115776
%9 = shl nuw nsw i64 %6, 8
%10 = add nuw nsw i64 %8, %9
%11 = and i64 %10, 288230376151711744
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %2
%14 = tail call i32 @last_bit(i64 %6)
%15 = zext i32 %14 to i64
%16 = shl i64 -2, %15
%17 = and i64 %16, 1130315200594944
%18 = or i64 %17, %5
br label %19
19: ; preds = %13, %2
%20 = phi i64 [ %18, %13 ], [ %5, %2 ]
%21 = and i64 %1, 562949953421312
%22 = shl i64 %0, 9
%23 = and i64 %21, %22
%24 = or i64 %20, %23
%25 = and i64 %0, 17730707128320
%26 = and i64 %1, 2269530512424960
%27 = or i64 %26, 285960844565544960
%28 = shl nuw nsw i64 %25, 7
%29 = add nuw nsw i64 %27, %28
%30 = and i64 %29, 288230376151711744
%31 = icmp eq i64 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %19
%33 = tail call i32 @last_bit(i64 %25)
%34 = zext i32 %33 to i64
%35 = shl i64 -2, %34
%36 = and i64 %35, 2269530512424960
%37 = or i64 %36, %24
br label %38
38: ; preds = %32, %19
%39 = phi i64 [ %37, %32 ], [ %24, %19 ]
%40 = and i64 %0, -1152921504606846976
%41 = add i64 %1, 576460752303423488
%42 = and i64 %40, %41
%43 = icmp eq i64 %42, 0
%44 = add i64 %42, -1
%45 = and i64 %44, -576460752303423488
%46 = select i1 %43, i64 0, i64 %45
%47 = or i64 %39, %46
ret i64 %47
}