#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_H4(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 & 0X000000FC00000000ULL;
  r = (discs_opponent + 0X0000000200000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X000000FE00000000ULL;
  }
  my_discs = discs_player & 0X0000000000040810ULL;
  opp_discs = (discs_opponent & 0X0000000002040800ULL) | 0X00000000FDFBF000ULL;
  r = ((my_discs << 7) + opp_discs) & 0X0000000100000000ULL;
  if (r != 0) {
    flipped |= (0X0000000100000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000002040800ULL;
  }
  my_discs = discs_player & 0X0804000000000000ULL;
  opp_discs = (discs_opponent & 0X0004020000000000ULL) | 0X07FBFC0000000000ULL;
  r = (opp_discs + 0X0000020000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0004020000000000ULL;
  }
  my_discs = discs_player & 0X0000000000010101ULL;
  opp_discs = (discs_opponent & 0X0000000001010100ULL) | 0X00000000FEFEFE00ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000000100000000ULL;
  if (r != 0) {
    flipped |= (0X0000000100000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000001010100ULL;
  }
  my_discs = discs_player & 0X0101000000000000ULL;
  opp_discs = (discs_opponent & 0X0001010000000000ULL) | 0X00FEFE0000000000ULL;
  r = (opp_discs + 0X0000010000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0001010000000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_H4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0xfc00000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x200000000,%rax
add    -0x10(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1178 <flip_H4+0x68>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0xfe00000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x40810,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x2040800,%rax
movabs $0xfdfbf000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x7,%rax
add    -0x20(%rbp),%rax
movabs $0x100000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fc <flip_H4+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 $0x100000000,%rax
sub    %rcx,%rax
and    $0x2040800,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x804000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x4020000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x7fbfc0000000000,%rcx
fc fb 07
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     126b <flip_H4+0x15b>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x4020000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x10101,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x1010100,%rax
movabs $0xfefefe00,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x100000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12ef <flip_H4+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 $0x100000000,%rax
sub    %rcx,%rax
and    $0x1010100,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x101000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x1010000000000,%rax
and    -0x10(%rbp),%rax
movabs $0xfefe0000000000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x10000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     135e <flip_H4+0x24e>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x1010000000000,%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_H4>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
movabs $0x100000000,%r15
movabs $0x200000000,%rax
add    %rsi,%rax
movabs $0xfc00000000,%rcx
and    %rdi,%rcx
and    %rax,%rcx
lea    -0x1(%rcx),%rax
movabs $0xfe00000000,%r13
and    %rax,%r13
test   %rcx,%rcx
cmove  %rcx,%r13
and    $0x40810,%edi
mov    %r12d,%eax
and    $0x2040800,%eax
or     %r15,%rax
mov    %rdi,%rcx
shl    $0x7,%rcx
add    %rcx,%rax
add    $0xfffffffffdfbf000,%rax
bt     $0x20,%rax
jae    11a0 <flip_H4+0x90>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x2040800,%edx
or     %rdx,%r13
movabs $0x4020000000000,%rax
mov    %r12,%rcx
and    %rax,%rcx
movabs $0x7fbfe0000000000,%rdx
fe fb 07
add    %rcx,%rdx
and    %r14,%rdx
movabs $0x804000000000000,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rbx
and    %rax,%rbx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %r13,%rbx
mov    %r14d,%edi
and    $0x10101,%edi
mov    %r12d,%eax
and    $0x1010100,%eax
lea    -0x1010200(%r15),%rcx
or     %rax,%rcx
mov    %rdi,%rax
shl    $0x8,%rax
add    %rcx,%rax
test   %r15,%rax
je     1222 <flip_H4+0x112>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x1010100,%edx
or     %rdx,%rbx
movabs $0x1010000000000,%rcx
and    %rcx,%r12
movabs $0xfeff0000000000,%rax
add    %r12,%rax
and    %rax,%r14
movabs $0x101000000000000,%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_H4(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, 1082331758592
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = add i64 %11, 8589934592
%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, 1090921693184
%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, 264208
store i64 %25, i64* %5
%26 = load i64, i64* %4
%27 = and i64 %26, 33818624
%28 = or i64 %27, 4261146624
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, 4294967296
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 4294967296, %40
%42 = and i64 %41, 33818624
%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, 577586652210266112
store i64 %47, i64* %5
%48 = load i64, i64* %4
%49 = and i64 %48, 1128098930098176
%50 = or i64 %49, 575330454350069760
store i64 %50, i64* %6
%51 = load i64, i64* %6
%52 = add i64 %51, 2199023255552
%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, 1128098930098176
%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, 65793
store i64 %65, i64* %5
%66 = load i64, i64* %4
%67 = and i64 %66, 16843008
%68 = or i64 %67, 4278124032
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, 4294967296
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 4294967296, %80
%82 = and i64 %81, 16843008
%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, 72339069014638592
store i64 %87, i64* %5
%88 = load i64, i64* %4
%89 = and i64 %88, 282574488338432
%90 = or i64 %89, 71773920037961728
store i64 %90, i64* %6
%91 = load i64, i64* %6
%92 = add i64 %91, 1099511627776
%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, 282574488338432
%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_H4(i64 %0, i64 %1) {
%3 = and i64 %0, 1082331758592
%4 = add i64 %1, 8589934592
%5 = and i64 %3, %4
%6 = icmp eq i64 %5, 0
%7 = add nuw nsw i64 %5, 1099511627775
%8 = and i64 %7, 1090921693184
%9 = select i1 %6, i64 0, i64 %8
%10 = and i64 %0, 264208
%11 = and i64 %1, 33818624
%12 = or i64 %11, 4261146624
%13 = shl nuw nsw i64 %10, 7
%14 = add nuw nsw i64 %12, %13
%15 = and i64 %14, 4294967296
%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, 33818624
%22 = or i64 %21, %9
br label %23
23: ; preds = %17, %2
%24 = phi i64 [ %22, %17 ], [ %9, %2 ]
%25 = and i64 %0, 577586652210266112
%26 = and i64 %1, 1128098930098176
%27 = add nuw nsw i64 %26, 575332653373325312
%28 = and i64 %25, %27
%29 = icmp eq i64 %28, 0
%30 = add nuw nsw i64 %28, 2251799813685247
%31 = and i64 %30, 1128098930098176
%32 = select i1 %29, i64 0, i64 %31
%33 = or i64 %24, %32
%34 = and i64 %0, 65793
%35 = and i64 %1, 16843008
%36 = or i64 %35, 4278124032
%37 = shl nuw nsw i64 %34, 8
%38 = add nuw nsw i64 %36, %37
%39 = and i64 %38, 4294967296
%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, 16843008
%46 = or i64 %45, %33
br label %47
47: ; preds = %41, %23
%48 = phi i64 [ %46, %41 ], [ %33, %23 ]
%49 = and i64 %0, 72339069014638592
%50 = and i64 %1, 282574488338432
%51 = add nuw nsw i64 %50, 71775019549589504
%52 = and i64 %49, %51
%53 = icmp eq i64 %52, 0
%54 = add nuw nsw i64 %52, 562949953421311
%55 = and i64 %54, 282574488338432
%56 = select i1 %53, i64 0, i64 %55
%57 = or i64 %48, %56
ret i64 %57
}