#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_C8(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 & 0X0000000000004000ULL) & (discs_player >> 9);
  flipped |= (discs_opponent & 0X0000000000000040ULL) & (discs_player >> 1);
  my_discs = discs_player & 0X2020202020200000ULL;
  opp_discs = (discs_opponent & 0X0020202020202000ULL) | 0X1FDFDFDFDFDFC000ULL;
  r = (opp_discs + 0X0000000000002000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0020202020202000ULL;
  }
  my_discs = discs_player & 0X0000010204080000ULL;
  opp_discs = (discs_opponent & 0X0000000204081000ULL) | 0X000000FDFBF7E000ULL;
  r = (opp_discs + 0X0000000000001000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000000204081000ULL;
  }
  my_discs = discs_player & 0X000000000000000FULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000000020ULL;
  if (r != 0) {
    flipped |= 0X0000000000000020ULL - (0X2ULL << last_bit(my_discs));
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_C8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0x4000,%rax
mov    -0x8(%rbp),%rcx
shr    $0x9,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
and    $0x40,%rax
mov    -0x8(%rbp),%rcx
shr    $0x1,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x2020202020200000,%rax
20 20 20
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x20202020202000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfdfdfdfdfc000,%rcx
df df 1f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x2000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11bf <flip_C8+0xaf>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x20202020202000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x10204080000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x204081000,%rax
and    -0x10(%rbp),%rax
movabs $0xfdfbf7e000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     122a <flip_C8+0x11a>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x204081000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xf,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x20,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     127d <flip_C8+0x16d>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
mov    $0x20,%eax
sub    %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_C8>:
push   %rbx
mov    %edi,%eax
shr    $0x9,%eax
and    %esi,%eax
and    $0x4000,%eax
mov    %edi,%ecx
shr    %ecx
and    %esi,%ecx
and    $0x40,%ecx
or     %rax,%rcx
movabs $0x20202020202000,%r8
mov    %rsi,%rdx
and    %r8,%rdx
movabs $0x1fdfdfdfdfdfe000,%rbx
df df 1f
add    %rdx,%rbx
movabs $0x2020202020200000,%rdx
20 20 20
and    %rdi,%rdx
and    %rbx,%rdx
lea    -0x1(%rdx),%rax
and    %r8,%rax
test   %rdx,%rdx
cmove  %rdx,%rax
or     %rcx,%rax
movabs $0x204081000,%rcx
mov    %rsi,%rdx
and    %rcx,%rdx
movabs $0xfdfbf7f000,%rbx
add    %rdx,%rbx
movabs $0x10204080000,%rdx
and    %rdi,%rdx
and    %rbx,%rdx
lea    -0x1(%rdx),%rbx
and    %rcx,%rbx
test   %rdx,%rdx
cmove  %rdx,%rbx
or     %rax,%rbx
and    $0xf,%edi
lea    (%rsi,%rdi,2),%eax
test   $0x20,%al
je     11c7 <flip_C8+0xb7>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x20,%rdx
or     %rdx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @flip_C8(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, 16384
%11 = load i64, i64* %3
%12 = lshr i64 %11, 9
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %4
%15 = and i64 %14, 64
%16 = load i64, i64* %3
%17 = lshr 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* %3
%22 = and i64 %21, 2314885530818445312
store i64 %22, i64* %5
%23 = load i64, i64* %4
%24 = and i64 %23, 9042521604759552
%25 = or i64 %24, 2296800487608926208
store i64 %25, i64* %6
%26 = load i64, i64* %6
%27 = add i64 %26, 8192
%28 = load i64, i64* %5
%29 = and i64 %27, %28
store i64 %29, i64* %7
%30 = load i64, i64* %7
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %2
%33 = load i64, i64* %7
%34 = sub i64 %33, 1
%35 = and i64 %34, 9042521604759552
%36 = load i64, i64* %8
%37 = or i64 %36, %35
store i64 %37, i64* %8
br label %38
38: ; preds = %32, %2
%39 = load i64, i64* %3
%40 = and i64 %39, 1108169195520
store i64 %40, i64* %5
%41 = load i64, i64* %4
%42 = and i64 %41, 8657571840
%43 = or i64 %42, 1090854051840
store i64 %43, i64* %6
%44 = load i64, i64* %6
%45 = add i64 %44, 4096
%46 = load i64, i64* %5
%47 = and i64 %45, %46
store i64 %47, i64* %7
%48 = load i64, i64* %7
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %56
50: ; preds = %38
%51 = load i64, i64* %7
%52 = sub i64 %51, 1
%53 = and i64 %52, 8657571840
%54 = load i64, i64* %8
%55 = or i64 %54, %53
store i64 %55, i64* %8
br label %56
56: ; preds = %50, %38
%57 = load i64, i64* %3
%58 = and i64 %57, 15
store i64 %58, i64* %5
%59 = load i64, i64* %5
%60 = shl i64 %59, 1
%61 = load i64, i64* %4
%62 = add i64 %60, %61
%63 = and i64 %62, 32
store i64 %63, i64* %7
%64 = load i64, i64* %7
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %74
66: ; preds = %56
%67 = load i64, i64* %5
%68 = call i32 @last_bit(i64 %67)
%69 = zext i32 %68 to i64
%70 = shl i64 2, %69
%71 = sub i64 32, %70
%72 = load i64, i64* %8
%73 = or i64 %72, %71
store i64 %73, i64* %8
br label %74
74: ; preds = %66, %56
%75 = load i64, i64* %8
ret i64 %75
}

LLVM IR (-O2):
define i64 @flip_C8(i64 %0, i64 %1) {
%3 = and i64 %1, 16384
%4 = lshr i64 %0, 9
%5 = and i64 %3, %4
%6 = and i64 %1, 64
%7 = lshr i64 %0, 1
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %0, 2314885530818445312
%11 = and i64 %1, 9042521604759552
%12 = add nuw nsw i64 %11, 2296800487608934400
%13 = and i64 %10, %12
%14 = icmp eq i64 %13, 0
%15 = add nuw nsw i64 %13, 18014398509481983
%16 = and i64 %15, 9042521604759552
%17 = select i1 %14, i64 0, i64 %16
%18 = or i64 %9, %17
%19 = and i64 %0, 1108169195520
%20 = and i64 %1, 8657571840
%21 = add nuw nsw i64 %20, 1090854055936
%22 = and i64 %19, %21
%23 = icmp eq i64 %22, 0
%24 = add nuw nsw i64 %22, 17179869183
%25 = and i64 %24, 8657571840
%26 = select i1 %23, i64 0, i64 %25
%27 = or i64 %18, %26
%28 = and i64 %0, 15
%29 = shl nuw nsw i64 %28, 1
%30 = add i64 %29, %1
%31 = and i64 %30, 32
%32 = icmp eq i64 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %2
%34 = tail call i32 @last_bit(i64 %28)
%35 = zext i32 %34 to i64
%36 = shl i64 -2, %35
%37 = add i64 %36, 32
%38 = or i64 %37, %27
br label %39
39: ; preds = %33, %2
%40 = phi i64 [ %38, %33 ], [ %27, %2 ]
ret i64 %40
}