#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_D3(const unsigned long long discs_player,
                           const unsigned long long discs_opponent) {
  unsigned long long my_discs, opp_discs, r;
  unsigned long long flipped =
      (discs_opponent & 0X0008000000000000ULL) & (discs_player >> 7);
  flipped |= (discs_opponent & 0X0010000000000000ULL) & (discs_player >> 8);
  flipped |= (discs_opponent & 0X0020000000000000ULL) & (discs_player >> 9);
  my_discs = discs_player & 0X0000000004020100ULL;
  opp_discs = (discs_opponent & 0X0000000804020000ULL) | 0X00000FF7FBFC0000ULL;
  r = ((my_discs << 9) + opp_discs) & 0X0000100000000000ULL;
  if (r != 0) {
    flipped |= (0X0000100000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000804020000ULL;
  }
  my_discs = discs_player & 0X0000000010101010ULL;
  opp_discs = (discs_opponent & 0X0000001010101000ULL) | 0X00000FEFEFEFE000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000100000000000ULL;
  if (r != 0) {
    flipped |= (0X0000100000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000001010101000ULL;
  }
  my_discs = discs_player & 0X0000070000000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000100000000000ULL;
  if (r != 0) {
    flipped |= 0X0000100000000000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X0000000040800000ULL;
  opp_discs = (discs_opponent & 0X0000002040000000ULL) | 0X00000FDF80000000ULL;
  r = ((my_discs << 7) + opp_discs) & 0X0000100000000000ULL;
  if (r != 0) {
    flipped |= (0X0000100000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000002040000000ULL;
  }
  my_discs = discs_player & 0X0000C00000000000ULL;
  r = (discs_opponent + 0X0000200000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000E00000000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_D3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x8000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x7,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
movabs $0x10000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x8,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x20000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x9,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x4020100,%rax
mov    %rax,-0x18(%rbp)
movabs $0x804020000,%rax
and    -0x10(%rbp),%rax
movabs $0xff7fbfc0000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x100000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     120e <flip_D3+0xfe>
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 $0x100000000000,%rax
sub    %rcx,%rax
movabs $0x804020000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x10101010,%rax
mov    %rax,-0x18(%rbp)
movabs $0x1010101000,%rax
and    -0x10(%rbp),%rax
movabs $0xfefefefe000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x100000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     129d <flip_D3+0x18d>
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 $0x100000000000,%rax
sub    %rcx,%rax
movabs $0x1010101000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x70000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x100000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1304 <flip_D3+0x1f4>
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 $0x100000000000,%rax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x40800000,%rax
mov    %rax,-0x18(%rbp)
movabs $0x2040000000,%rax
and    -0x10(%rbp),%rax
movabs $0xfdf80000000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x7,%rax
add    -0x20(%rbp),%rax
movabs $0x100000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1393 <flip_D3+0x283>
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 $0x100000000000,%rax
sub    %rcx,%rax
movabs $0x2040000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0xc00000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x200000000000,%rax
add    -0x10(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     13e3 <flip_D3+0x2d3>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0xe00000000000,%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_D3>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
movabs $0x100000000000,%r12
movabs $0x804020000,%r13
mov    %rdi,%rax
shr    $0x7,%rax
and    %rsi,%rax
movabs $0x8000000000000,%rcx
and    %rax,%rcx
mov    %rdi,%rax
shr    $0x8,%rax
and    %rsi,%rax
movabs $0x10000000000000,%rdx
and    %rax,%rdx
or     %rcx,%rdx
mov    %rdi,%rax
shr    $0x9,%rax
and    %rsi,%rax
movabs $0x20000000000000,%r15
and    %rax,%r15
or     %rdx,%r15
and    $0x4020100,%edi
mov    %rsi,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x9,%rcx
add    %rax,%rcx
movabs $0xff7fbfc0000,%rax
add    %rcx,%rax
bt     $0x2c,%rax
jae    11bf <flip_D3+0xaf>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r15
movabs $0x1010101000,%r13
mov    %r14d,%edi
and    $0x10101010,%edi
mov    %rbx,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
movabs $0xfefefefe000,%rax
add    %rcx,%rax
test   %r12,%rax
je     120b <flip_D3+0xfb>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r15
movabs $0x70000000000,%rdi
and    %r14,%rdi
lea    (%rbx,%rdi,2),%rax
test   %r12,%rax
je     1238 <flip_D3+0x128>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    %r12,%rdx
or     %rdx,%r15
movabs $0x2040000000,%r13
mov    %r14d,%edi
and    $0x40800000,%edi
mov    %rbx,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x7,%rcx
add    %rax,%rcx
movabs $0xfdf80000000,%rax
add    %rcx,%rax
test   %r12,%rax
je     1284 <flip_D3+0x174>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%r15
movabs $0x200000000000,%rax
add    %rax,%rbx
and    %rbx,%r14
movabs $0xc00000000000,%rcx
and    %r14,%rcx
lea    -0x1(%rcx),%rdx
movabs $0xe00000000000,%rax
and    %rdx,%rax
test   %rcx,%rcx
cmove  %rcx,%rax
or     %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_D3(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
%9 = load i64, i64* %4
%10 = and i64 %9, 2251799813685248
%11 = load i64, i64* %3
%12 = lshr i64 %11, 7
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %4
%15 = and i64 %14, 4503599627370496
%16 = load i64, i64* %3
%17 = lshr i64 %16, 8
%18 = and i64 %15, %17
%19 = load i64, i64* %8
%20 = or i64 %19, %18
store i64 %20, i64* %8
%21 = load i64, i64* %4
%22 = and i64 %21, 9007199254740992
%23 = load i64, i64* %3
%24 = lshr i64 %23, 9
%25 = and i64 %22, %24
%26 = load i64, i64* %8
%27 = or i64 %26, %25
store i64 %27, i64* %8
%28 = load i64, i64* %3
%29 = and i64 %28, 67240192
store i64 %29, i64* %5
%30 = load i64, i64* %4
%31 = and i64 %30, 34426978304
%32 = or i64 %31, 17557758935040
store i64 %32, i64* %6
%33 = load i64, i64* %5
%34 = shl i64 %33, 9
%35 = load i64, i64* %6
%36 = add i64 %34, %35
%37 = and i64 %36, 17592186044416
store i64 %37, i64* %7
%38 = load i64, i64* %7
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %49
40: ; preds = %2
%41 = load i64, i64* %5
%42 = call i32 @last_bit(i64 %41)
%43 = zext i32 %42 to i64
%44 = shl i64 2, %43
%45 = sub i64 17592186044416, %44
%46 = and i64 %45, 34426978304
%47 = load i64, i64* %8
%48 = or i64 %47, %46
store i64 %48, i64* %8
br label %49
49: ; preds = %40, %2
%50 = load i64, i64* %3
%51 = and i64 %50, 269488144
store i64 %51, i64* %5
%52 = load i64, i64* %4
%53 = and i64 %52, 68988964864
%54 = or i64 %53, 17523197075456
store i64 %54, i64* %6
%55 = load i64, i64* %5
%56 = shl i64 %55, 8
%57 = load i64, i64* %6
%58 = add i64 %56, %57
%59 = and i64 %58, 17592186044416
store i64 %59, i64* %7
%60 = load i64, i64* %7
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %71
62: ; preds = %49
%63 = load i64, i64* %5
%64 = call i32 @last_bit(i64 %63)
%65 = zext i32 %64 to i64
%66 = shl i64 2, %65
%67 = sub i64 17592186044416, %66
%68 = and i64 %67, 68988964864
%69 = load i64, i64* %8
%70 = or i64 %69, %68
store i64 %70, i64* %8
br label %71
71: ; preds = %62, %49
%72 = load i64, i64* %3
%73 = and i64 %72, 7696581394432
store i64 %73, i64* %5
%74 = load i64, i64* %5
%75 = shl i64 %74, 1
%76 = load i64, i64* %4
%77 = add i64 %75, %76
%78 = and i64 %77, 17592186044416
store i64 %78, i64* %7
%79 = load i64, i64* %7
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %89
81: ; preds = %71
%82 = load i64, i64* %5
%83 = call i32 @last_bit(i64 %82)
%84 = zext i32 %83 to i64
%85 = shl i64 2, %84
%86 = sub i64 17592186044416, %85
%87 = load i64, i64* %8
%88 = or i64 %87, %86
store i64 %88, i64* %8
br label %89
89: ; preds = %81, %71
%90 = load i64, i64* %3
%91 = and i64 %90, 1082130432
store i64 %91, i64* %5
%92 = load i64, i64* %4
%93 = and i64 %92, 138512695296
%94 = or i64 %93, 17452599607296
store i64 %94, i64* %6
%95 = load i64, i64* %5
%96 = shl i64 %95, 7
%97 = load i64, i64* %6
%98 = add i64 %96, %97
%99 = and i64 %98, 17592186044416
store i64 %99, i64* %7
%100 = load i64, i64* %7
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %111
102: ; preds = %89
%103 = load i64, i64* %5
%104 = call i32 @last_bit(i64 %103)
%105 = zext i32 %104 to i64
%106 = shl i64 2, %105
%107 = sub i64 17592186044416, %106
%108 = and i64 %107, 138512695296
%109 = load i64, i64* %8
%110 = or i64 %109, %108
store i64 %110, i64* %8
br label %111
111: ; preds = %102, %89
%112 = load i64, i64* %3
%113 = and i64 %112, 211106232532992
store i64 %113, i64* %5
%114 = load i64, i64* %4
%115 = add i64 %114, 35184372088832
%116 = load i64, i64* %5
%117 = and i64 %115, %116
store i64 %117, i64* %7
%118 = load i64, i64* %7
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %126
120: ; preds = %111
%121 = load i64, i64* %7
%122 = sub i64 %121, 1
%123 = and i64 %122, 246290604621824
%124 = load i64, i64* %8
%125 = or i64 %124, %123
store i64 %125, i64* %8
br label %126
126: ; preds = %120, %111
%127 = load i64, i64* %8
ret i64 %127
}

LLVM IR (-O2):
define i64 @flip_D3(i64 %0, i64 %1) {
%3 = and i64 %1, 2251799813685248
%4 = lshr i64 %0, 7
%5 = and i64 %3, %4
%6 = and i64 %1, 4503599627370496
%7 = lshr i64 %0, 8
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %1, 9007199254740992
%11 = lshr i64 %0, 9
%12 = and i64 %10, %11
%13 = or i64 %9, %12
%14 = and i64 %0, 67240192
%15 = and i64 %1, 34426978304
%16 = or i64 %15, 17557758935040
%17 = shl nuw nsw i64 %14, 9
%18 = add nuw nsw i64 %16, %17
%19 = and i64 %18, 17592186044416
%20 = icmp eq i64 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %2
%22 = tail call i32 @last_bit(i64 %14)
%23 = zext i32 %22 to i64
%24 = shl i64 -2, %23
%25 = and i64 %24, 34426978304
%26 = or i64 %25, %13
br label %27
27: ; preds = %21, %2
%28 = phi i64 [ %26, %21 ], [ %13, %2 ]
%29 = and i64 %0, 269488144
%30 = and i64 %1, 68988964864
%31 = or i64 %30, 17523197075456
%32 = shl nuw nsw i64 %29, 8
%33 = add nuw nsw i64 %31, %32
%34 = and i64 %33, 17592186044416
%35 = icmp eq i64 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %27
%37 = tail call i32 @last_bit(i64 %29)
%38 = zext i32 %37 to i64
%39 = shl i64 -2, %38
%40 = and i64 %39, 68988964864
%41 = or i64 %40, %28
br label %42
42: ; preds = %36, %27
%43 = phi i64 [ %41, %36 ], [ %28, %27 ]
%44 = and i64 %0, 7696581394432
%45 = shl nuw nsw i64 %44, 1
%46 = add i64 %45, %1
%47 = and i64 %46, 17592186044416
%48 = icmp eq i64 %47, 0
br i1 %48, label %55, label %49
49: ; preds = %42
%50 = tail call i32 @last_bit(i64 %44)
%51 = zext i32 %50 to i64
%52 = shl i64 -2, %51
%53 = add i64 %52, 17592186044416
%54 = or i64 %53, %43
br label %55
55: ; preds = %49, %42
%56 = phi i64 [ %54, %49 ], [ %43, %42 ]
%57 = and i64 %0, 1082130432
%58 = and i64 %1, 138512695296
%59 = or i64 %58, 17452599607296
%60 = shl nuw nsw i64 %57, 7
%61 = add nuw nsw i64 %59, %60
%62 = and i64 %61, 17592186044416
%63 = icmp eq i64 %62, 0
br i1 %63, label %70, label %64
64: ; preds = %55
%65 = tail call i32 @last_bit(i64 %57)
%66 = zext i32 %65 to i64
%67 = shl i64 -2, %66
%68 = and i64 %67, 138512695296
%69 = or i64 %68, %56
br label %70
70: ; preds = %64, %55
%71 = phi i64 [ %69, %64 ], [ %56, %55 ]
%72 = and i64 %0, 211106232532992
%73 = add i64 %1, 35184372088832
%74 = and i64 %72, %73
%75 = icmp eq i64 %74, 0
%76 = add nuw nsw i64 %74, 281474976710655
%77 = and i64 %76, 246290604621824
%78 = select i1 %75, i64 0, i64 %77
%79 = or i64 %71, %78
ret i64 %79
}