#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_G5(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 & 0X00000000F8000000ULL;
  r = (discs_opponent + 0X0000000004000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X00000000FC000000ULL;
  }
  my_discs = discs_player & 0X0000000000000810ULL;
  opp_discs = (discs_opponent & 0X0000000000040800ULL) | 0X0000000001FBF000ULL;
  r = ((my_discs << 7) + opp_discs) & 0X0000000002000000ULL;
  if (r != 0) {
    flipped |= (0X0000000002000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000000040800ULL;
  }
  my_discs = discs_player & 0X2010080000000000ULL;
  opp_discs = (discs_opponent & 0X0010080400000000ULL) | 0X1FEFF7F800000000ULL;
  r = (opp_discs + 0X0000000400000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0010080400000000ULL;
  }
  my_discs = discs_player & 0X0000000000000202ULL;
  opp_discs = (discs_opponent & 0X0000000000020200ULL) | 0X0000000001FDFC00ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000000002000000ULL;
  if (r != 0) {
    flipped |= (0X0000000002000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000000020200ULL;
  }
  my_discs = discs_player & 0X0202020000000000ULL;
  opp_discs = (discs_opponent & 0X0002020200000000ULL) | 0X01FDFDFC00000000ULL;
  r = (opp_discs + 0X0000000200000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0002020200000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_G5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0xf8000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4000000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1174 <flip_G5+0x64>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0xfc000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x810,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x40800,%rax
or     $0x1fbf000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x7,%rax
add    -0x20(%rbp),%rax
and    $0x2000000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11e5 <flip_G5+0xd5>
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    $0x2000000,%eax
sub    %rcx,%rax
and    $0x40800,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x2010080000000000,%rax
08 10 20
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x10080400000000,%rax
and    -0x10(%rbp),%rax
movabs $0x1feff7f800000000,%rcx
f7 ef 1f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x400000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1254 <flip_G5+0x144>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x10080400000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x202,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x20200,%rax
or     $0x1fdfc00,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
and    $0x2000000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12c5 <flip_G5+0x1b5>
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    $0x2000000,%eax
sub    %rcx,%rax
and    $0x20200,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x202020000000000,%rax
02 02 02
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x2020200000000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfdfc00000000,%rcx
fd fd 01
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x200000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1334 <flip_G5+0x224>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x2020200000000,%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_G5>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x4000000(%rsi),%eax
and    %r14d,%eax
and    $0xf8000000,%eax
lea    -0x1(%rax),%r12d
and    $0xfc000000,%r12d
test   %rax,%rax
cmove  %rax,%r12
and    $0x810,%edi
mov    %r15d,%eax
and    $0x40800,%eax
mov    %edi,%ecx
shl    $0x7,%ecx
add    %ecx,%eax
add    $0x1fbf000,%eax
test   $0x2000000,%eax
je     1179 <flip_G5+0x69>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x40800,%edx
or     %rdx,%r12
movabs $0x10080400000000,%rax
mov    %r15,%rcx
and    %rax,%rcx
movabs $0x1feff7fc00000000,%rdx
f7 ef 1f
add    %rcx,%rdx
and    %r14,%rdx
movabs $0x2010080000000000,%rcx
08 10 20
and    %rdx,%rcx
lea    -0x1(%rcx),%rbx
and    %rax,%rbx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %r12,%rbx
mov    %r14d,%edi
and    $0x202,%edi
mov    %r15d,%eax
and    $0x20200,%eax
mov    %edi,%ecx
shl    $0x8,%ecx
add    %ecx,%eax
add    $0x1fdfc00,%eax
test   $0x2000000,%eax
je     11f5 <flip_G5+0xe5>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x20200,%edx
or     %rdx,%rbx
movabs $0x2020200000000,%rcx
and    %rcx,%r15
movabs $0x1fdfdfe00000000,%rax
fd fd 01
add    %r15,%rax
and    %rax,%r14
movabs $0x202020000000000,%rdx
02 02 02
and    %r14,%rdx
lea    -0x1(%rdx),%rax
and    %rcx,%rax
test   %rdx,%rdx
cmove  %rdx,%rax
or     %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_G5(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, 4160749568
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = add i64 %11, 67108864
%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, 4227858432
%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, 2064
store i64 %25, i64* %5
%26 = load i64, i64* %4
%27 = and i64 %26, 264192
%28 = or i64 %27, 33288192
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, 33554432
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 33554432, %40
%42 = and i64 %41, 264192
%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, 2310355404934086656
store i64 %47, i64* %5
%48 = load i64, i64* %4
%49 = and i64 %48, 4512412900261888
%50 = or i64 %49, 2301330579133562880
store i64 %50, i64* %6
%51 = load i64, i64* %6
%52 = add i64 %51, 17179869184
%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, 4512412900261888
%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, 514
store i64 %65, i64* %5
%66 = load i64, i64* %4
%67 = and i64 %66, 131584
%68 = or i64 %67, 33422336
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, 33554432
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 33554432, %80
%82 = and i64 %81, 131584
%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, 144680337052532736
store i64 %87, i64* %5
%88 = load i64, i64* %4
%89 = and i64 %88, 565157566611456
%90 = or i64 %89, 143550021919309824
store i64 %90, i64* %6
%91 = load i64, i64* %6
%92 = add i64 %91, 8589934592
%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, 565157566611456
%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_G5(i64 %0, i64 %1) {
%3 = and i64 %0, 4160749568
%4 = add i64 %1, 67108864
%5 = and i64 %3, %4
%6 = icmp eq i64 %5, 0
%7 = add nuw nsw i64 %5, 4294967295
%8 = and i64 %7, 4227858432
%9 = select i1 %6, i64 0, i64 %8
%10 = and i64 %0, 2064
%11 = and i64 %1, 264192
%12 = or i64 %11, 33288192
%13 = shl nuw nsw i64 %10, 7
%14 = add nuw nsw i64 %12, %13
%15 = and i64 %14, 33554432
%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, 264192
%22 = or i64 %21, %9
br label %23
23: ; preds = %17, %2
%24 = phi i64 [ %22, %17 ], [ %9, %2 ]
%25 = and i64 %0, 2310355404934086656
%26 = and i64 %1, 4512412900261888
%27 = add nuw nsw i64 %26, 2301330596313432064
%28 = and i64 %25, %27
%29 = icmp eq i64 %28, 0
%30 = add nuw nsw i64 %28, 9007199254740991
%31 = and i64 %30, 4512412900261888
%32 = select i1 %29, i64 0, i64 %31
%33 = or i64 %24, %32
%34 = and i64 %0, 514
%35 = and i64 %1, 131584
%36 = or i64 %35, 33422336
%37 = shl nuw nsw i64 %34, 8
%38 = add nuw nsw i64 %36, %37
%39 = and i64 %38, 33554432
%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, 131584
%46 = or i64 %45, %33
br label %47
47: ; preds = %41, %23
%48 = phi i64 [ %46, %41 ], [ %33, %23 ]
%49 = and i64 %0, 144680337052532736
%50 = and i64 %1, 565157566611456
%51 = add nuw nsw i64 %50, 143550030509244416
%52 = and i64 %49, %51
%53 = icmp eq i64 %52, 0
%54 = add nuw nsw i64 %52, 1125899906842623
%55 = and i64 %54, 565157566611456
%56 = select i1 %53, i64 0, i64 %55
%57 = or i64 %48, %56
ret i64 %57
}