#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_D1(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 & 0X0000101010101010ULL;
  opp_discs = (discs_opponent & 0X0010101010101000ULL) | 0X0FEFEFEFEFEFE000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X1000000000000000ULL;
  if (r != 0) {
    flipped |= (0X1000000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0010101010101000ULL;
  }
  my_discs = discs_player & 0X0000040201000000ULL;
  opp_discs = (discs_opponent & 0X0008040200000000ULL) | 0X0FF7FBFC00000000ULL;
  r = ((my_discs << 9) + opp_discs) & 0X1000000000000000ULL;
  if (r != 0) {
    flipped |= (0X1000000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0008040200000000ULL;
  }
  my_discs = discs_player & 0X0000408000000000ULL;
  opp_discs = (discs_opponent & 0X0020400000000000ULL) | 0X0FDF800000000000ULL;
  r = ((my_discs << 7) + opp_discs) & 0X1000000000000000ULL;
  if (r != 0) {
    flipped |= (0X1000000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0020400000000000ULL;
  }
  my_discs = discs_player & 0X0700000000000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X1000000000000000ULL;
  if (r != 0) {
    flipped |= 0X1000000000000000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0XC000000000000000ULL;
  r = (discs_opponent + 0X2000000000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0XE000000000000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_D1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x101010101010,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x10101010101000,%rax
and    -0x10(%rbp),%rax
movabs $0xfefefefefefe000,%rcx
ef ef 0f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x1000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11bb <flip_D1+0xab>
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 $0x1000000000000000,%rax
sub    %rcx,%rax
movabs $0x10101010101000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x40201000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x8040200000000,%rax
and    -0x10(%rbp),%rax
movabs $0xff7fbfc00000000,%rcx
fb f7 0f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x1000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     124e <flip_D1+0x13e>
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 $0x1000000000000000,%rax
sub    %rcx,%rax
movabs $0x8040200000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x408000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x20400000000000,%rax
and    -0x10(%rbp),%rax
movabs $0xfdf800000000000,%rcx
80 df 0f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x7,%rax
add    -0x20(%rbp),%rax
movabs $0x1000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12e1 <flip_D1+0x1d1>
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 $0x1000000000000000,%rax
sub    %rcx,%rax
movabs $0x20400000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x700000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x1000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1348 <flip_D1+0x238>
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 $0x1000000000000000,%rax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0xc000000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x2000000000000000,%rax
add    -0x10(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1398 <flip_D1+0x288>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0xe000000000000000,%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_D1>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
movabs $0x1000000000000000,%r12
movabs $0x10101010101000,%r13
movabs $0x101010101010,%rdi
and    %r14,%rdi
mov    %rsi,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
movabs $0xfefefefefefe000,%rax
ef ef 0f
add    %rcx,%rax
bt     $0x3c,%rax
jb     1169 <flip_D1+0x59>
xor    %r15d,%r15d
jmp    117d <flip_D1+0x6d>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%r15
mov    %eax,%ecx
shl    %cl,%r15
and    %r13,%r15
movabs $0x8040200000000,%r13
movabs $0x40201000000,%rdi
and    %r14,%rdi
mov    %rbx,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x9,%rcx
add    %rax,%rcx
movabs $0xff7fbfc00000000,%rax
fb f7 0f
add    %rcx,%rax
test   %r12,%rax
je     11cd <flip_D1+0xbd>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r15
movabs $0x20400000000000,%r13
movabs $0x408000000000,%rdi
and    %r14,%rdi
mov    %rbx,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x7,%rcx
add    %rax,%rcx
movabs $0xfdf800000000000,%rax
80 df 0f
add    %rcx,%rax
test   %r12,%rax
je     121d <flip_D1+0x10d>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r15
movabs $0x700000000000000,%rdi
and    %r14,%rdi
lea    (%rbx,%rdi,2),%rax
test   %r12,%rax
je     124a <flip_D1+0x13a>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    %r12,%rdx
or     %rdx,%r15
movabs $0x2000000000000000,%rax
add    %rax,%rbx
and    %rbx,%r14
movabs $0xc000000000000000,%rcx
and    %r14,%rcx
lea    -0x1(%rcx),%rax
movabs $0xe000000000000000,%rdx
and    %rax,%rdx
xor    %eax,%eax
cmp    $0x1,%rcx
cmovae %rdx,%rax
or     %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_D1(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, 17661175009296
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = and i64 %11, 4521260802379776
%13 = or i64 %12, 1148400243804463104
store i64 %13, i64* %6
%14 = load i64, i64* %5
%15 = shl i64 %14, 8
%16 = load i64, i64* %6
%17 = add i64 %15, %16
%18 = and i64 %17, 1152921504606846976
store i64 %18, i64* %7
%19 = load i64, i64* %7
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %2
%22 = load i64, i64* %5
%23 = call i32 @last_bit(i64 %22)
%24 = zext i32 %23 to i64
%25 = shl i64 2, %24
%26 = sub i64 1152921504606846976, %25
%27 = and i64 %26, 4521260802379776
%28 = load i64, i64* %8
%29 = or i64 %28, %27
store i64 %29, i64* %8
br label %30
30: ; preds = %21, %2
%31 = load i64, i64* %3
%32 = and i64 %31, 4406653222912
store i64 %32, i64* %5
%33 = load i64, i64* %4
%34 = and i64 %33, 2256206450130944
%35 = or i64 %34, 1150665289566781440
store i64 %35, i64* %6
%36 = load i64, i64* %5
%37 = shl i64 %36, 9
%38 = load i64, i64* %6
%39 = add i64 %37, %38
%40 = and i64 %39, 1152921504606846976
store i64 %40, i64* %7
%41 = load i64, i64* %7
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %52
43: ; preds = %30
%44 = load i64, i64* %5
%45 = call i32 @last_bit(i64 %44)
%46 = zext i32 %45 to i64
%47 = shl i64 2, %46
%48 = sub i64 1152921504606846976, %47
%49 = and i64 %48, 2256206450130944
%50 = load i64, i64* %8
%51 = or i64 %50, %49
store i64 %51, i64* %8
br label %52
52: ; preds = %43, %30
%53 = load i64, i64* %3
%54 = and i64 %53, 70918499991552
store i64 %54, i64* %5
%55 = load i64, i64* %4
%56 = and i64 %55, 9077567998918656
%57 = or i64 %56, 1143773567863750656
store i64 %57, i64* %6
%58 = load i64, i64* %5
%59 = shl i64 %58, 7
%60 = load i64, i64* %6
%61 = add i64 %59, %60
%62 = and i64 %61, 1152921504606846976
store i64 %62, i64* %7
%63 = load i64, i64* %7
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %74
65: ; preds = %52
%66 = load i64, i64* %5
%67 = call i32 @last_bit(i64 %66)
%68 = zext i32 %67 to i64
%69 = shl i64 2, %68
%70 = sub i64 1152921504606846976, %69
%71 = and i64 %70, 9077567998918656
%72 = load i64, i64* %8
%73 = or i64 %72, %71
store i64 %73, i64* %8
br label %74
74: ; preds = %65, %52
%75 = load i64, i64* %3
%76 = and i64 %75, 504403158265495552
store i64 %76, i64* %5
%77 = load i64, i64* %5
%78 = shl i64 %77, 1
%79 = load i64, i64* %4
%80 = add i64 %78, %79
%81 = and i64 %80, 1152921504606846976
store i64 %81, i64* %7
%82 = load i64, i64* %7
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %92
84: ; preds = %74
%85 = load i64, i64* %5
%86 = call i32 @last_bit(i64 %85)
%87 = zext i32 %86 to i64
%88 = shl i64 2, %87
%89 = sub i64 1152921504606846976, %88
%90 = load i64, i64* %8
%91 = or i64 %90, %89
store i64 %91, i64* %8
br label %92
92: ; preds = %84, %74
%93 = load i64, i64* %3
%94 = and i64 %93, -4611686018427387904
store i64 %94, i64* %5
%95 = load i64, i64* %4
%96 = add i64 %95, 2305843009213693952
%97 = load i64, i64* %5
%98 = and i64 %96, %97
store i64 %98, i64* %7
%99 = load i64, i64* %7
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %92
%102 = load i64, i64* %7
%103 = sub i64 %102, 1
%104 = and i64 %103, -2305843009213693952
%105 = load i64, i64* %8
%106 = or i64 %105, %104
store i64 %106, i64* %8
br label %107
107: ; preds = %101, %92
%108 = load i64, i64* %8
ret i64 %108
}

LLVM IR (-O2):
define i64 @flip_D1(i64 %0, i64 %1) {
%3 = and i64 %0, 17661175009296
%4 = and i64 %1, 4521260802379776
%5 = or i64 %4, 1148400243804463104
%6 = shl nuw nsw i64 %3, 8
%7 = add nuw nsw i64 %5, %6
%8 = and i64 %7, 1152921504606846976
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = tail call i32 @last_bit(i64 %3)
%12 = zext i32 %11 to i64
%13 = shl i64 -2, %12
%14 = and i64 %13, 4521260802379776
br label %15
15: ; preds = %10, %2
%16 = phi i64 [ %14, %10 ], [ 0, %2 ]
%17 = and i64 %0, 4406653222912
%18 = and i64 %1, 2256206450130944
%19 = or i64 %18, 1150665289566781440
%20 = shl nuw nsw i64 %17, 9
%21 = add nuw nsw i64 %19, %20
%22 = and i64 %21, 1152921504606846976
%23 = icmp eq i64 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %15
%25 = tail call i32 @last_bit(i64 %17)
%26 = zext i32 %25 to i64
%27 = shl i64 -2, %26
%28 = and i64 %27, 2256206450130944
%29 = or i64 %28, %16
br label %30
30: ; preds = %24, %15
%31 = phi i64 [ %29, %24 ], [ %16, %15 ]
%32 = and i64 %0, 70918499991552
%33 = and i64 %1, 9077567998918656
%34 = or i64 %33, 1143773567863750656
%35 = shl nuw nsw i64 %32, 7
%36 = add nuw nsw i64 %34, %35
%37 = and i64 %36, 1152921504606846976
%38 = icmp eq i64 %37, 0
br i1 %38, label %45, label %39
39: ; preds = %30
%40 = tail call i32 @last_bit(i64 %32)
%41 = zext i32 %40 to i64
%42 = shl i64 -2, %41
%43 = and i64 %42, 9077567998918656
%44 = or i64 %43, %31
br label %45
45: ; preds = %39, %30
%46 = phi i64 [ %44, %39 ], [ %31, %30 ]
%47 = and i64 %0, 504403158265495552
%48 = shl nuw nsw i64 %47, 1
%49 = add i64 %48, %1
%50 = and i64 %49, 1152921504606846976
%51 = icmp eq i64 %50, 0
br i1 %51, label %58, label %52
52: ; preds = %45
%53 = tail call i32 @last_bit(i64 %47)
%54 = zext i32 %53 to i64
%55 = shl i64 -2, %54
%56 = add i64 %55, 1152921504606846976
%57 = or i64 %56, %46
br label %58
58: ; preds = %52, %45
%59 = phi i64 [ %57, %52 ], [ %46, %45 ]
%60 = and i64 %0, -4611686018427387904
%61 = add i64 %1, 2305843009213693952
%62 = and i64 %60, %61
%63 = icmp eq i64 %62, 0
%64 = add i64 %62, -1
%65 = and i64 %64, -2305843009213693952
%66 = select i1 %63, i64 0, i64 %65
%67 = or i64 %59, %66
ret i64 %67
}