#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_E8(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 & 0X0808080808080000ULL;
  opp_discs = (discs_opponent & 0X0008080808080800ULL) | 0X07F7F7F7F7F7F000ULL;
  r = (opp_discs + 0X0000000000000800ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0008080808080800ULL;
  }
  my_discs = discs_player & 0X0000000001020000ULL;
  opp_discs = (discs_opponent & 0X0000000000020400ULL) | 0X0000000000FDF800ULL;
  r = (opp_discs + 0X0000000000000400ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000000000020400ULL;
  }
  my_discs = discs_player & 0X0000008040200000ULL;
  opp_discs = (discs_opponent & 0X0000000040201000ULL) | 0X0000007FBFDFE000ULL;
  r = (opp_discs + 0X0000000000001000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000000040201000ULL;
  }
  my_discs = discs_player & 0X0000000000000003ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000000008ULL;
  if (r != 0) {
    flipped |= 0X0000000000000008ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X00000000000000E0ULL;
  r = (discs_opponent + 0X0000000000000010ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X00000000000000F0ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_E8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x808080808080000,%rax
08 08 08
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x8080808080800,%rax
and    -0x10(%rbp),%rax
movabs $0x7f7f7f7f7f7f000,%rcx
f7 f7 07
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     1193 <flip_E8+0x83>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x8080808080800,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1020000,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x20400,%rax
or     $0xfdf800,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x400,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11e8 <flip_E8+0xd8>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0x20400,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x8040200000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x40201000,%rax
movabs $0x7fbfdfe000,%rcx
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     1248 <flip_E8+0x138>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0x40201000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x8,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     129b <flip_E8+0x18b>
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    $0x8,%eax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xe0,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12da <flip_E8+0x1ca>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0xf0,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_E8>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movabs $0x8080808080800,%rax
mov    %rsi,%rcx
and    %rax,%rcx
movabs $0x7f7f7f7f7f7f800,%rdx
f7 f7 07
add    %rcx,%rdx
movabs $0x808080808080000,%rsi
08 08 08
and    %rdi,%rsi
and    %rdx,%rsi
lea    -0x1(%rsi),%rcx
and    %rax,%rcx
test   %rsi,%rsi
cmove  %rsi,%rcx
mov    %r15d,%edx
and    $0x20400,%edx
add    $0xfdfc00,%edx
and    %r14d,%edx
and    $0x1020000,%edx
lea    -0x1(%rdx),%eax
and    $0x20400,%eax
test   %rdx,%rdx
cmove  %rdx,%rax
or     %rcx,%rax
mov    %r15d,%ecx
and    $0x40201000,%ecx
movabs $0x7fbfdff000,%rdx
add    %rcx,%rdx
movabs $0x8040200000,%rcx
and    %rdi,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%ebx
and    $0x40201000,%ebx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %rax,%rbx
and    $0x3,%edi
lea    (%r15,%rdi,2),%eax
test   $0x8,%al
je     11dc <flip_E8+0xcc>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x8,%rdx
or     %rdx,%rbx
add    $0x10,%r15d
and    %r14d,%r15d
and    $0xe0,%r15d
lea    -0x1(%r15),%eax
and    $0xf0,%eax
test   %r15,%r15
cmove  %r15,%rax
or     %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_E8(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, 578721382704611328
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = and i64 %11, 2260630401189888
%13 = or i64 %12, 574200121902231552
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = add i64 %14, 2048
%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, 2260630401189888
%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, 16908288
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 132096
%31 = or i64 %30, 16644096
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 1024
%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, 132096
%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, 550831652864
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = and i64 %47, 1075843072
%49 = or i64 %48, 548679966720
store i64 %49, i64* %6
%50 = load i64, i64* %6
%51 = add i64 %50, 4096
%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, 1075843072
%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, 3
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, 8
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 8, %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, 224
store i64 %82, i64* %5
%83 = load i64, i64* %4
%84 = add i64 %83, 16
%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, 240
%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_E8(i64 %0, i64 %1) {
%3 = and i64 %0, 578721382704611328
%4 = and i64 %1, 2260630401189888
%5 = add nuw nsw i64 %4, 574200121902233600
%6 = and i64 %3, %5
%7 = icmp eq i64 %6, 0
%8 = add nuw nsw i64 %6, 4503599627370495
%9 = and i64 %8, 2260630401189888
%10 = select i1 %7, i64 0, i64 %9
%11 = and i64 %0, 16908288
%12 = and i64 %1, 132096
%13 = add nuw nsw i64 %12, 16645120
%14 = and i64 %11, %13
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %14, 262143
%17 = and i64 %16, 132096
%18 = select i1 %15, i64 0, i64 %17
%19 = or i64 %10, %18
%20 = and i64 %0, 550831652864
%21 = and i64 %1, 1075843072
%22 = add nuw nsw i64 %21, 548679970816
%23 = and i64 %20, %22
%24 = icmp eq i64 %23, 0
%25 = add nuw nsw i64 %23, 2147483647
%26 = and i64 %25, 1075843072
%27 = select i1 %24, i64 0, i64 %26
%28 = or i64 %19, %27
%29 = and i64 %0, 3
%30 = shl nuw nsw i64 %29, 1
%31 = add i64 %30, %1
%32 = and i64 %31, 8
%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, 8
%39 = or i64 %38, %28
br label %40
40: ; preds = %34, %2
%41 = phi i64 [ %39, %34 ], [ %28, %2 ]
%42 = and i64 %0, 224
%43 = add i64 %1, 16
%44 = and i64 %42, %43
%45 = icmp eq i64 %44, 0
%46 = add nuw nsw i64 %44, 255
%47 = and i64 %46, 240
%48 = select i1 %45, i64 0, i64 %47
%49 = or i64 %41, %48
ret i64 %49
}