#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_G4(const unsigned long long discs_player,
                           const unsigned long long discs_opponent) {
  unsigned long long my_discs, opp_discs, r, flipped = 0ULL;
  my_discs = discs_player & 0X000000F800000000ULL;
  r = (discs_opponent + 0X0000000400000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X000000FC00000000ULL;
  }
  my_discs = discs_player & 0X0000000000081020ULL;
  opp_discs = (discs_opponent & 0X0000000004081000ULL) | 0X00000001FBF7E000ULL;
  r = ((my_discs << 7) + opp_discs) & 0X0000000200000000ULL;
  if (r != 0) {
    flipped |= (0X0000000200000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000004081000ULL;
  }
  my_discs = discs_player & 0X1008000000000000ULL;
  opp_discs = (discs_opponent & 0X0008040000000000ULL) | 0X0FF7F80000000000ULL;
  r = (opp_discs + 0X0000040000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0008040000000000ULL;
  }
  my_discs = discs_player & 0X0000000000020202ULL;
  opp_discs = (discs_opponent & 0X0000000002020200ULL) | 0X00000001FDFDFC00ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000000200000000ULL;
  if (r != 0) {
    flipped |= (0X0000000200000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000002020200ULL;
  }
  my_discs = discs_player & 0X0202000000000000ULL;
  opp_discs = (discs_opponent & 0X0002020000000000ULL) | 0X01FDFC0000000000ULL;
  r = (opp_discs + 0X0000020000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0002020000000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_G4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0xf800000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x400000000,%rax
add    -0x10(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1178 <flip_G4+0x68>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0xfc00000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x81020,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x4081000,%rax
movabs $0x1fbf7e000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x7,%rax
add    -0x20(%rbp),%rax
movabs $0x200000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fc <flip_G4+0xec>
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 $0x200000000,%rax
sub    %rcx,%rax
and    $0x4081000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x1008000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x8040000000000,%rax
and    -0x10(%rbp),%rax
movabs $0xff7f80000000000,%rcx
f8 f7 0f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x40000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     126b <flip_G4+0x15b>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x8040000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x20202,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x2020200,%rax
movabs $0x1fdfdfc00,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x200000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12ef <flip_G4+0x1df>
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 $0x200000000,%rax
sub    %rcx,%rax
and    $0x2020200,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x202000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x2020000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfc0000000000,%rcx
fc fd 01
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x20000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     135e <flip_G4+0x24e>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x2020000000000,%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_G4>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
movabs $0x200000000,%r15
movabs $0x400000000,%rax
add    %rsi,%rax
movabs $0xf800000000,%rcx
and    %rdi,%rcx
and    %rax,%rcx
lea    -0x1(%rcx),%rax
movabs $0xfc00000000,%r13
and    %rax,%r13
test   %rcx,%rcx
cmove  %rcx,%r13
and    $0x81020,%edi
mov    %r12d,%eax
and    $0x4081000,%eax
or     %r15,%rax
mov    %rdi,%rcx
shl    $0x7,%rcx
add    %rcx,%rax
add    $0xfffffffffbf7e000,%rax
bt     $0x21,%rax
jae    11a0 <flip_G4+0x90>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x4081000,%edx
or     %rdx,%r13
movabs $0x8040000000000,%rax
mov    %r12,%rcx
and    %rax,%rcx
movabs $0xff7fc0000000000,%rdx
fc f7 0f
add    %rcx,%rdx
and    %r14,%rdx
movabs $0x1008000000000000,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rbx
and    %rax,%rbx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %r13,%rbx
mov    %r14d,%edi
and    $0x20202,%edi
mov    %r12d,%eax
and    $0x2020200,%eax
lea    -0x2020400(%r15),%rcx
or     %rax,%rcx
mov    %rdi,%rax
shl    $0x8,%rax
add    %rcx,%rax
test   %r15,%rax
je     1222 <flip_G4+0x112>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x2020200,%edx
or     %rdx,%rbx
movabs $0x2020000000000,%rcx
and    %rcx,%r12
movabs $0x1fdfe0000000000,%rax
fe fd 01
add    %r12,%rax
and    %rax,%r14
movabs $0x202000000000000,%rdx
and    %r14,%rdx
lea    -0x1(%rdx),%rax
and    %rcx,%rax
test   %rdx,%rdx
cmove  %rdx,%rax
or     %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_G4(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
store i64 0, i64* %8
%9 = load i64, i64* %3
%10 = and i64 %9, 1065151889408
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = add i64 %11, 17179869184
%13 = load i64, i64* %5
%14 = and i64 %12, %13
store i64 %14, i64* %7
%15 = load i64, i64* %7
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i64, i64* %7
%19 = sub i64 %18, 1
%20 = and i64 %19, 1082331758592
%21 = load i64, i64* %8
%22 = or i64 %21, %20
store i64 %22, i64* %8
br label %23
23: ; preds = %17, %2
%24 = load i64, i64* %3
%25 = and i64 %24, 528416
store i64 %25, i64* %5
%26 = load i64, i64* %4
%27 = and i64 %26, 67637248
%28 = or i64 %27, 8522293248
store i64 %28, i64* %6
%29 = load i64, i64* %5
%30 = shl i64 %29, 7
%31 = load i64, i64* %6
%32 = add i64 %30, %31
%33 = and i64 %32, 8589934592
store i64 %33, i64* %7
%34 = load i64, i64* %7
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %45
36: ; preds = %23
%37 = load i64, i64* %5
%38 = call i32 @last_bit(i64 %37)
%39 = zext i32 %38 to i64
%40 = shl i64 2, %39
%41 = sub i64 8589934592, %40
%42 = and i64 %41, 67637248
%43 = load i64, i64* %8
%44 = or i64 %43, %42
store i64 %44, i64* %8
br label %45
45: ; preds = %36, %23
%46 = load i64, i64* %3
%47 = and i64 %46, 1155173304420532224
store i64 %47, i64* %5
%48 = load i64, i64* %4
%49 = and i64 %48, 2256197860196352
%50 = or i64 %49, 1150660908700139520
store i64 %50, i64* %6
%51 = load i64, i64* %6
%52 = add i64 %51, 4398046511104
%53 = load i64, i64* %5
%54 = and i64 %52, %53
store i64 %54, i64* %7
%55 = load i64, i64* %7
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %63
57: ; preds = %45
%58 = load i64, i64* %7
%59 = sub i64 %58, 1
%60 = and i64 %59, 2256197860196352
%61 = load i64, i64* %8
%62 = or i64 %61, %60
store i64 %62, i64* %8
br label %63
63: ; preds = %57, %45
%64 = load i64, i64* %3
%65 = and i64 %64, 131586
store i64 %65, i64* %5
%66 = load i64, i64* %4
%67 = and i64 %66, 33686016
%68 = or i64 %67, 8556248064
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, 8589934592
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 8589934592, %80
%82 = and i64 %81, 33686016
%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, 144678138029277184
store i64 %87, i64* %5
%88 = load i64, i64* %4
%89 = and i64 %88, 565148976676864
%90 = or i64 %89, 143547840075923456
store i64 %90, i64* %6
%91 = load i64, i64* %6
%92 = add i64 %91, 2199023255552
%93 = load i64, i64* %5
%94 = and i64 %92, %93
store i64 %94, i64* %7
%95 = load i64, i64* %7
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %103
97: ; preds = %85
%98 = load i64, i64* %7
%99 = sub i64 %98, 1
%100 = and i64 %99, 565148976676864
%101 = load i64, i64* %8
%102 = or i64 %101, %100
store i64 %102, i64* %8
br label %103
103: ; preds = %97, %85
%104 = load i64, i64* %8
ret i64 %104
}

LLVM IR (-O2):
define i64 @flip_G4(i64 %0, i64 %1) {
%3 = and i64 %0, 1065151889408
%4 = add i64 %1, 17179869184
%5 = and i64 %3, %4
%6 = icmp eq i64 %5, 0
%7 = add nuw nsw i64 %5, 1099511627775
%8 = and i64 %7, 1082331758592
%9 = select i1 %6, i64 0, i64 %8
%10 = and i64 %0, 528416
%11 = and i64 %1, 67637248
%12 = or i64 %11, 8522293248
%13 = shl nuw nsw i64 %10, 7
%14 = add nuw nsw i64 %12, %13
%15 = and i64 %14, 8589934592
%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, 67637248
%22 = or i64 %21, %9
br label %23
23: ; preds = %17, %2
%24 = phi i64 [ %22, %17 ], [ %9, %2 ]
%25 = and i64 %0, 1155173304420532224
%26 = and i64 %1, 2256197860196352
%27 = add nuw nsw i64 %26, 1150665306746650624
%28 = and i64 %25, %27
%29 = icmp eq i64 %28, 0
%30 = add nuw nsw i64 %28, 4503599627370495
%31 = and i64 %30, 2256197860196352
%32 = select i1 %29, i64 0, i64 %31
%33 = or i64 %24, %32
%34 = and i64 %0, 131586
%35 = and i64 %1, 33686016
%36 = or i64 %35, 8556248064
%37 = shl nuw nsw i64 %34, 8
%38 = add nuw nsw i64 %36, %37
%39 = and i64 %38, 8589934592
%40 = icmp eq i64 %39, 0
br i1 %40, label %47, label %41
41: ; preds = %23
%42 = tail call i32 @last_bit(i64 %34)
%43 = zext i32 %42 to i64
%44 = shl i64 -2, %43
%45 = and i64 %44, 33686016
%46 = or i64 %45, %33
br label %47
47: ; preds = %41, %23
%48 = phi i64 [ %46, %41 ], [ %33, %23 ]
%49 = and i64 %0, 144678138029277184
%50 = and i64 %1, 565148976676864
%51 = add nuw nsw i64 %50, 143550039099179008
%52 = and i64 %49, %51
%53 = icmp eq i64 %52, 0
%54 = add nuw nsw i64 %52, 1125899906842623
%55 = and i64 %54, 565148976676864
%56 = select i1 %53, i64 0, i64 %55
%57 = or i64 %48, %56
ret i64 %57
}