#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_C3(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 & 0X0010000000000000ULL) & (discs_player >> 7);
  flipped |= (discs_opponent & 0X0020000000000000ULL) & (discs_player >> 8);
  flipped |= (discs_opponent & 0X0040000000000000ULL) & (discs_player >> 9);
  flipped |= (discs_opponent & 0X0000004000000000ULL) & (discs_player << 7);
  flipped |= (discs_opponent & 0X0000400000000000ULL) & (discs_player >> 1);
  my_discs = discs_player & 0X0000000008040201ULL;
  opp_discs = (discs_opponent & 0X0000001008040200ULL) | 0X00001FEFF7FBFC00ULL;
  r = ((my_discs << 9) + opp_discs) & 0X0000200000000000ULL;
  if (r != 0) {
    flipped |= (0X0000200000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000001008040200ULL;
  }
  my_discs = discs_player & 0X0000000020202020ULL;
  opp_discs = (discs_opponent & 0X0000002020202000ULL) | 0X00001FDFDFDFC000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000200000000000ULL;
  if (r != 0) {
    flipped |= (0X0000200000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000002020202000ULL;
  }
  my_discs = discs_player & 0X00000F0000000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000200000000000ULL;
  if (r != 0) {
    flipped |= 0X0000200000000000ULL - (0X2ULL << last_bit(my_discs));
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_C3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x10000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x7,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
movabs $0x20000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x8,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x40000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x9,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x4000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shl    $0x7,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x400000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x1,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x8040201,%rax
mov    %rax,-0x18(%rbp)
movabs $0x1008040200,%rax
and    -0x10(%rbp),%rax
movabs $0x1feff7fbfc00,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x200000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1250 <flip_C3+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 $0x200000000000,%rax
sub    %rcx,%rax
movabs $0x1008040200,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x20202020,%rax
mov    %rax,-0x18(%rbp)
movabs $0x2020202000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfdfdfc000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x200000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12df <flip_C3+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 $0x200000000000,%rax
sub    %rcx,%rax
movabs $0x2020202000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0xf0000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x200000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1346 <flip_C3+0x236>
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 $0x200000000000,%rax
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_C3>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movabs $0x200000000000,%r12
movabs $0x1008040200,%r13
mov    %rdi,%rax
shr    $0x7,%rax
and    %rsi,%rax
movabs $0x10000000000000,%rcx
and    %rax,%rcx
mov    %rdi,%rax
shr    $0x8,%rax
and    %rsi,%rax
movabs $0x20000000000000,%rdx
and    %rax,%rdx
or     %rcx,%rdx
mov    %rdi,%rax
shr    $0x9,%rax
and    %rsi,%rax
movabs $0x40000000000000,%rcx
and    %rax,%rcx
or     %rdx,%rcx
mov    %rdi,%rax
shl    $0x7,%rax
and    %rsi,%rax
movabs $0x4000000000,%rdx
and    %rax,%rdx
or     %rcx,%rdx
mov    %rdi,%rax
shr    %rax
and    %rsi,%rax
movabs $0x400000000000,%r15
and    %rax,%r15
or     %rdx,%r15
and    $0x8040201,%edi
mov    %rsi,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x9,%rcx
add    %rax,%rcx
movabs $0x1feff7fbfc00,%rax
add    %rcx,%rax
bt     $0x2d,%rax
jae    11f2 <flip_C3+0xe2>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r15
movabs $0x2020202000,%r13
mov    %ebx,%edi
and    $0x20202020,%edi
mov    %r14,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
movabs $0x1fdfdfdfc000,%rax
add    %rcx,%rax
test   %r12,%rax
je     123d <flip_C3+0x12d>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r15
movabs $0xf0000000000,%rax
and    %rax,%rbx
lea    (%r14,%rbx,2),%rax
test   %r12,%rax
je     126d <flip_C3+0x15d>
mov    %rbx,%rdi
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    %r12,%rdx
or     %rdx,%r15
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_C3(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, 4503599627370496
%11 = load i64, i64* %3
%12 = lshr i64 %11, 7
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %4
%15 = and i64 %14, 9007199254740992
%16 = load i64, i64* %3
%17 = lshr i64 %16, 8
%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, 18014398509481984
%23 = load i64, i64* %3
%24 = lshr i64 %23, 9
%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, 274877906944
%30 = load i64, i64* %3
%31 = shl i64 %30, 7
%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, 70368744177664
%37 = load i64, i64* %3
%38 = lshr i64 %37, 1
%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, 134480385
store i64 %43, i64* %5
%44 = load i64, i64* %4
%45 = and i64 %44, 68853957120
%46 = or i64 %45, 35115518131200
store i64 %46, i64* %6
%47 = load i64, i64* %5
%48 = shl i64 %47, 9
%49 = load i64, i64* %6
%50 = add i64 %48, %49
%51 = and i64 %50, 35184372088832
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 35184372088832, %58
%60 = and i64 %59, 68853957120
%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, 538976288
store i64 %65, i64* %5
%66 = load i64, i64* %4
%67 = and i64 %66, 137977929728
%68 = or i64 %67, 35046394150912
store i64 %68, i64* %6
%69 = load i64, i64* %5
%70 = shl i64 %69, 8
%71 = load i64, i64* %6
%72 = add i64 %70, %71
%73 = and i64 %72, 35184372088832
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 35184372088832, %80
%82 = and i64 %81, 137977929728
%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, 16492674416640
store i64 %87, i64* %5
%88 = load i64, i64* %5
%89 = shl i64 %88, 1
%90 = load i64, i64* %4
%91 = add i64 %89, %90
%92 = and i64 %91, 35184372088832
store i64 %92, i64* %7
%93 = load i64, i64* %7
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %103
95: ; preds = %85
%96 = load i64, i64* %5
%97 = call i32 @last_bit(i64 %96)
%98 = zext i32 %97 to i64
%99 = shl i64 2, %98
%100 = sub i64 35184372088832, %99
%101 = load i64, i64* %8
%102 = or i64 %101, %100
store i64 %102, i64* %8
br label %103
103: ; preds = %95, %85
%104 = load i64, i64* %8
ret i64 %104
}

LLVM IR (-O2):
define i64 @flip_C3(i64 %0, i64 %1) {
%3 = and i64 %1, 4503599627370496
%4 = lshr i64 %0, 7
%5 = and i64 %3, %4
%6 = and i64 %1, 9007199254740992
%7 = lshr i64 %0, 8
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %1, 18014398509481984
%11 = lshr i64 %0, 9
%12 = and i64 %10, %11
%13 = or i64 %9, %12
%14 = and i64 %1, 274877906944
%15 = shl i64 %0, 7
%16 = and i64 %14, %15
%17 = or i64 %13, %16
%18 = and i64 %1, 70368744177664
%19 = lshr i64 %0, 1
%20 = and i64 %18, %19
%21 = or i64 %17, %20
%22 = and i64 %0, 134480385
%23 = and i64 %1, 68853957120
%24 = or i64 %23, 35115518131200
%25 = shl nuw nsw i64 %22, 9
%26 = add nuw nsw i64 %24, %25
%27 = and i64 %26, 35184372088832
%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, 68853957120
%34 = or i64 %33, %21
br label %35
35: ; preds = %29, %2
%36 = phi i64 [ %34, %29 ], [ %21, %2 ]
%37 = and i64 %0, 538976288
%38 = and i64 %1, 137977929728
%39 = or i64 %38, 35046394150912
%40 = shl nuw nsw i64 %37, 8
%41 = add nuw nsw i64 %39, %40
%42 = and i64 %41, 35184372088832
%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, 137977929728
%49 = or i64 %48, %36
br label %50
50: ; preds = %44, %35
%51 = phi i64 [ %49, %44 ], [ %36, %35 ]
%52 = and i64 %0, 16492674416640
%53 = shl nuw nsw i64 %52, 1
%54 = add i64 %53, %1
%55 = and i64 %54, 35184372088832
%56 = icmp eq i64 %55, 0
br i1 %56, label %63, label %57
57: ; preds = %50
%58 = tail call i32 @last_bit(i64 %52)
%59 = zext i32 %58 to i64
%60 = shl i64 -2, %59
%61 = add i64 %60, 35184372088832
%62 = or i64 %61, %51
br label %63
63: ; preds = %57, %50
%64 = phi i64 [ %62, %57 ], [ %51, %50 ]
ret i64 %64
}