#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_D8(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 & 0X1010101010100000ULL;
  opp_discs = (discs_opponent & 0X0010101010101000ULL) | 0X0FEFEFEFEFEFE000ULL;
  r = (opp_discs + 0X0000000000001000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0010101010101000ULL;
  }
  my_discs = discs_player & 0X0000000102040000ULL;
  opp_discs = (discs_opponent & 0X0000000002040800ULL) | 0X00000000FDFBF000ULL;
  r = (opp_discs + 0X0000000000000800ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000000002040800ULL;
  }
  my_discs = discs_player & 0X0000000080400000ULL;
  opp_discs = (discs_opponent & 0X0000000000402000ULL) | 0X000000007FBFC000ULL;
  r = (opp_discs + 0X0000000000002000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000000000402000ULL;
  }
  my_discs = discs_player & 0X0000000000000007ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000000010ULL;
  if (r != 0) {
    flipped |= 0X0000000000000010ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X00000000000000C0ULL;
  r = (discs_opponent + 0X0000000000000020ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X00000000000000E0ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_D8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x1010101010100000,%rax
10 10 10
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    -0x20(%rbp),%rax
add    $0x1000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1193 <flip_D8+0x83>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x10101010101000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x102040000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x2040800,%rax
movabs $0xfdfbf000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x800,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f3 <flip_D8+0xe3>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0x2040800,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x80400000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x402000,%rax
or     $0x7fbfc000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x2000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     124c <flip_D8+0x13c>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0x402000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x7,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x10,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     129f <flip_D8+0x18f>
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    $0x10,%eax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xc0,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12de <flip_D8+0x1ce>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0xe0,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_D8>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movabs $0x10101010101000,%rax
mov    %rsi,%rcx
and    %rax,%rcx
movabs $0xfefefefefeff000,%rdx
ef ef 0f
add    %rcx,%rdx
movabs $0x1010101010100000,%rcx
10 10 10
and    %rdi,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rdx
and    %rax,%rdx
test   %rcx,%rcx
cmove  %rcx,%rdx
mov    $0xfdfbf800,%eax
lea    0x4080800(%rax),%rcx
and    %rdi,%rcx
and    $0x2040800,%esi
add    %rax,%rsi
and    %rcx,%rsi
lea    -0x1(%rsi),%eax
and    $0x2040800,%eax
test   %rsi,%rsi
cmove  %rsi,%rax
or     %rdx,%rax
mov    %r15d,%ecx
and    $0x402000,%ecx
add    $0x7fbfe000,%ecx
and    %r14d,%ecx
and    $0x80400000,%ecx
lea    -0x1(%rcx),%ebx
and    $0x402000,%ebx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %rax,%rbx
and    $0x7,%edi
lea    (%r15,%rdi,2),%eax
test   $0x10,%al
je     11d1 <flip_D8+0xc1>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x10,%rdx
or     %rdx,%rbx
add    $0x20,%r15d
and    %r14d,%r15d
and    $0xc0,%r15d
lea    -0x1(%r15),%eax
and    $0xe0,%eax
test   %r15,%r15
cmove  %r15,%rax
or     %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_D8(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, 1157442765409222656
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* %6
%15 = add i64 %14, 4096
%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, 4521260802379776
%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, 4328783872
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 33818624
%31 = or i64 %30, 4261146624
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 2048
%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, 33818624
%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, 2151677952
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = and i64 %47, 4202496
%49 = or i64 %48, 2143272960
store i64 %49, i64* %6
%50 = load i64, i64* %6
%51 = add i64 %50, 8192
%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, 4202496
%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, 7
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, 16
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 16, %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, 192
store i64 %82, i64* %5
%83 = load i64, i64* %4
%84 = add i64 %83, 32
%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, 224
%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_D8(i64 %0, i64 %1) {
%3 = and i64 %0, 1157442765409222656
%4 = and i64 %1, 4521260802379776
%5 = add nuw nsw i64 %4, 1148400243804467200
%6 = and i64 %3, %5
%7 = icmp eq i64 %6, 0
%8 = add nuw nsw i64 %6, 9007199254740991
%9 = and i64 %8, 4521260802379776
%10 = select i1 %7, i64 0, i64 %9
%11 = and i64 %0, 4328783872
%12 = and i64 %1, 33818624
%13 = add nuw nsw i64 %12, 4261148672
%14 = and i64 %11, %13
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %14, 67108863
%17 = and i64 %16, 33818624
%18 = select i1 %15, i64 0, i64 %17
%19 = or i64 %10, %18
%20 = and i64 %0, 2151677952
%21 = and i64 %1, 4202496
%22 = add nuw nsw i64 %21, 2143281152
%23 = and i64 %20, %22
%24 = icmp eq i64 %23, 0
%25 = add nuw nsw i64 %23, 8388607
%26 = and i64 %25, 4202496
%27 = select i1 %24, i64 0, i64 %26
%28 = or i64 %19, %27
%29 = and i64 %0, 7
%30 = shl nuw nsw i64 %29, 1
%31 = add i64 %30, %1
%32 = and i64 %31, 16
%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, 16
%39 = or i64 %38, %28
br label %40
40: ; preds = %34, %2
%41 = phi i64 [ %39, %34 ], [ %28, %2 ]
%42 = and i64 %0, 192
%43 = add i64 %1, 32
%44 = and i64 %42, %43
%45 = icmp eq i64 %44, 0
%46 = add nuw nsw i64 %44, 255
%47 = and i64 %46, 224
%48 = select i1 %45, i64 0, i64 %47
%49 = or i64 %41, %48
ret i64 %49
}