#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_D7(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 & 0X1010101010000000ULL;
  opp_discs = (discs_opponent & 0X0010101010100000ULL) | 0X0FEFEFEFEFE00000ULL;
  r = (opp_discs + 0X0000000000100000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0010101010100000ULL;
  }
  my_discs = discs_player & 0X0000010204000000ULL;
  opp_discs = (discs_opponent & 0X0000000204080000ULL) | 0X000000FDFBF00000ULL;
  r = (opp_discs + 0X0000000000080000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000000204080000ULL;
  }
  my_discs = discs_player & 0X0000008040000000ULL;
  opp_discs = (discs_opponent & 0X0000000040200000ULL) | 0X0000007FBFC00000ULL;
  r = (opp_discs + 0X0000000000200000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000000040200000ULL;
  }
  my_discs = discs_player & 0X0000000000000700ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000001000ULL;
  if (r != 0) {
    flipped |= 0X0000000000001000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X000000000000C000ULL;
  r = (discs_opponent + 0X0000000000002000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X000000000000E000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_D7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x1010101010000000,%rax
10 10 10
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x10101010100000,%rax
and    -0x10(%rbp),%rax
movabs $0xfefefefefe00000,%rcx
ef ef 0f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x100000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1193 <flip_D7+0x83>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x10101010100000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x10204000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x204080000,%rax
and    -0x10(%rbp),%rax
movabs $0xfdfbf00000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x80000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fe <flip_D7+0xee>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x204080000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x8040000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x40200000,%rax
movabs $0x7fbfc00000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x200000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     125e <flip_D7+0x14e>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0x40200000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x700,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x1000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12b5 <flip_D7+0x1a5>
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    $0x1000,%eax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xc000,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12f6 <flip_D7+0x1e6>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0xe000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_D7>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
movabs $0x10101010100000,%rax
mov    %rsi,%rcx
and    %rax,%rcx
movabs $0xfefefefeff00000,%rdx
ef ef 0f
add    %rcx,%rdx
movabs $0x1010101010000000,%rcx
10 10 10
and    %rdi,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rdx
and    %rax,%rdx
test   %rcx,%rcx
cmove  %rcx,%rdx
movabs $0x204080000,%rcx
mov    %rsi,%rax
and    %rcx,%rax
movabs $0xfdfbf80000,%rsi
add    %rax,%rsi
movabs $0x10204000000,%rdi
and    %r14,%rdi
and    %rsi,%rdi
lea    -0x1(%rdi),%rax
and    %rcx,%rax
test   %rdi,%rdi
cmove  %rdi,%rax
or     %rdx,%rax
mov    %ebx,%ecx
and    $0x40200000,%ecx
movabs $0x7fbfe00000,%rdx
add    %rcx,%rdx
movabs $0x8040000000,%rcx
and    %r14,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%r15d
and    $0x40200000,%r15d
test   %rcx,%rcx
cmove  %rcx,%r15
or     %rax,%r15
mov    %r14d,%edi
and    $0x700,%edi
lea    (%rbx,%rdi,2),%eax
test   $0x1000,%eax
je     11fc <flip_D7+0xec>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x1000,%rdx
or     %rdx,%r15
add    $0x2000,%ebx
and    %r14d,%ebx
and    $0xc000,%ebx
lea    -0x1(%rbx),%eax
and    $0xe000,%eax
test   %rbx,%rbx
cmove  %rbx,%rax
or     %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_D7(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, 1157442765408174080
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = and i64 %11, 4521260802375680
%13 = or i64 %12, 1148400243803422720
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = add i64 %14, 1048576
%16 = load i64, i64* %5
%17 = and i64 %15, %16
store i64 %17, i64* %7
%18 = load i64, i64* %7
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i64, i64* %7
%22 = sub i64 %21, 1
%23 = and i64 %22, 4521260802375680
%24 = load i64, i64* %8
%25 = or i64 %24, %23
store i64 %25, i64* %8
br label %26
26: ; preds = %20, %2
%27 = load i64, i64* %3
%28 = and i64 %27, 1108168671232
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 8657567744
%31 = or i64 %30, 1090853535744
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 524288
%34 = load i64, i64* %5
%35 = and i64 %33, %34
store i64 %35, i64* %7
%36 = load i64, i64* %7
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %26
%39 = load i64, i64* %7
%40 = sub i64 %39, 1
%41 = and i64 %40, 8657567744
%42 = load i64, i64* %8
%43 = or i64 %42, %41
store i64 %43, i64* %8
br label %44
44: ; preds = %38, %26
%45 = load i64, i64* %3
%46 = and i64 %45, 550829555712
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = and i64 %47, 1075838976
%49 = or i64 %48, 548677877760
store i64 %49, i64* %6
%50 = load i64, i64* %6
%51 = add i64 %50, 2097152
%52 = load i64, i64* %5
%53 = and i64 %51, %52
store i64 %53, i64* %7
%54 = load i64, i64* %7
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %44
%57 = load i64, i64* %7
%58 = sub i64 %57, 1
%59 = and i64 %58, 1075838976
%60 = load i64, i64* %8
%61 = or i64 %60, %59
store i64 %61, i64* %8
br label %62
62: ; preds = %56, %44
%63 = load i64, i64* %3
%64 = and i64 %63, 1792
store i64 %64, i64* %5
%65 = load i64, i64* %5
%66 = shl i64 %65, 1
%67 = load i64, i64* %4
%68 = add i64 %66, %67
%69 = and i64 %68, 4096
store i64 %69, i64* %7
%70 = load i64, i64* %7
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %80
72: ; preds = %62
%73 = load i64, i64* %5
%74 = call i32 @last_bit(i64 %73)
%75 = zext i32 %74 to i64
%76 = shl i64 2, %75
%77 = sub i64 4096, %76
%78 = load i64, i64* %8
%79 = or i64 %78, %77
store i64 %79, i64* %8
br label %80
80: ; preds = %72, %62
%81 = load i64, i64* %3
%82 = and i64 %81, 49152
store i64 %82, i64* %5
%83 = load i64, i64* %4
%84 = add i64 %83, 8192
%85 = load i64, i64* %5
%86 = and i64 %84, %85
store i64 %86, i64* %7
%87 = load i64, i64* %7
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %95
89: ; preds = %80
%90 = load i64, i64* %7
%91 = sub i64 %90, 1
%92 = and i64 %91, 57344
%93 = load i64, i64* %8
%94 = or i64 %93, %92
store i64 %94, i64* %8
br label %95
95: ; preds = %89, %80
%96 = load i64, i64* %8
ret i64 %96
}

LLVM IR (-O2):
define i64 @flip_D7(i64 %0, i64 %1) {
%3 = and i64 %0, 1157442765408174080
%4 = and i64 %1, 4521260802375680
%5 = add nuw nsw i64 %4, 1148400243804471296
%6 = and i64 %3, %5
%7 = icmp eq i64 %6, 0
%8 = add nuw nsw i64 %6, 9007199254740991
%9 = and i64 %8, 4521260802375680
%10 = select i1 %7, i64 0, i64 %9
%11 = and i64 %0, 1108168671232
%12 = and i64 %1, 8657567744
%13 = add nuw nsw i64 %12, 1090854060032
%14 = and i64 %11, %13
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %14, 17179869183
%17 = and i64 %16, 8657567744
%18 = select i1 %15, i64 0, i64 %17
%19 = or i64 %10, %18
%20 = and i64 %0, 550829555712
%21 = and i64 %1, 1075838976
%22 = add nuw nsw i64 %21, 548679974912
%23 = and i64 %20, %22
%24 = icmp eq i64 %23, 0
%25 = add nuw nsw i64 %23, 2147483647
%26 = and i64 %25, 1075838976
%27 = select i1 %24, i64 0, i64 %26
%28 = or i64 %19, %27
%29 = and i64 %0, 1792
%30 = shl nuw nsw i64 %29, 1
%31 = add i64 %30, %1
%32 = and i64 %31, 4096
%33 = icmp eq i64 %32, 0
br i1 %33, label %40, label %34
34: ; preds = %2
%35 = tail call i32 @last_bit(i64 %29)
%36 = zext i32 %35 to i64
%37 = shl i64 -2, %36
%38 = add i64 %37, 4096
%39 = or i64 %38, %28
br label %40
40: ; preds = %34, %2
%41 = phi i64 [ %39, %34 ], [ %28, %2 ]
%42 = and i64 %0, 49152
%43 = add i64 %1, 8192
%44 = and i64 %42, %43
%45 = icmp eq i64 %44, 0
%46 = add nuw nsw i64 %44, 65535
%47 = and i64 %46, 57344
%48 = select i1 %45, i64 0, i64 %47
%49 = or i64 %41, %48
ret i64 %49
}