#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_E7(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 & 0X0808080808000000ULL;
  opp_discs = (discs_opponent & 0X0008080808080000ULL) | 0X07F7F7F7F7F00000ULL;
  r = (opp_discs + 0X0000000000080000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0008080808080000ULL;
  }
  my_discs = discs_player & 0X0000000102000000ULL;
  opp_discs = (discs_opponent & 0X0000000002040000ULL) | 0X00000000FDF80000ULL;
  r = (opp_discs + 0X0000000000040000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000000002040000ULL;
  }
  my_discs = discs_player & 0X0000804020000000ULL;
  opp_discs = (discs_opponent & 0X0000004020100000ULL) | 0X00007FBFDFE00000ULL;
  r = (opp_discs + 0X0000000000100000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000004020100000ULL;
  }
  my_discs = discs_player & 0X0000000000000300ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000000800ULL;
  if (r != 0) {
    flipped |= 0X0000000000000800ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X000000000000E000ULL;
  r = (discs_opponent + 0X0000000000001000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X000000000000F000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_E7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x808080808000000,%rax
08 08 08
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x8080808080000,%rax
and    -0x10(%rbp),%rax
movabs $0x7f7f7f7f7f00000,%rcx
f7 f7 07
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     1193 <flip_E7+0x83>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x8080808080000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x102000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x2040000,%rax
movabs $0xfdf80000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x40000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f3 <flip_E7+0xe3>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0x2040000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x804020000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x4020100000,%rax
and    -0x10(%rbp),%rax
movabs $0x7fbfdfe00000,%rcx
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     125e <flip_E7+0x14e>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x4020100000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x300,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x800,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12b5 <flip_E7+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    $0x800,%eax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xe000,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12f6 <flip_E7+0x1e6>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
and    $0xf000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_E7>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movabs $0x8080808080000,%rax
mov    %rsi,%rcx
and    %rax,%rcx
movabs $0x7f7f7f7f7f80000,%rdx
f7 f7 07
add    %rcx,%rdx
movabs $0x808080808000000,%rcx
08 08 08
and    %rdi,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rdx
and    %rax,%rdx
test   %rcx,%rcx
cmove  %rcx,%rdx
mov    $0xfdfc0000,%eax
lea    0x4040000(%rax),%rcx
and    %rdi,%rcx
and    $0x2040000,%esi
add    %rax,%rsi
and    %rcx,%rsi
lea    -0x1(%rsi),%eax
and    $0x2040000,%eax
test   %rsi,%rsi
cmove  %rsi,%rax
or     %rdx,%rax
movabs $0x4020100000,%rcx
mov    %r15,%rdx
and    %rcx,%rdx
movabs $0x7fbfdff00000,%rsi
add    %rdx,%rsi
movabs $0x804020000000,%rdx
and    %rdi,%rdx
and    %rsi,%rdx
lea    -0x1(%rdx),%rbx
and    %rcx,%rbx
test   %rdx,%rdx
cmove  %rdx,%rbx
or     %rax,%rbx
and    $0x300,%edi
lea    (%r15,%rdi,2),%eax
test   $0x800,%eax
je     11ed <flip_E7+0xdd>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x800,%rdx
or     %rdx,%rbx
add    $0x1000,%r15d
and    %r14d,%r15d
and    $0xe000,%r15d
lea    -0x1(%r15),%eax
and    $0xf000,%eax
test   %r15,%r15
cmove  %r15,%rax
or     %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_E7(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, 578721382704087040
store i64 %10, i64* %5
%11 = load i64, i64* %4
%12 = and i64 %11, 2260630401187840
%13 = or i64 %12, 574200121901711360
store i64 %13, i64* %6
%14 = load i64, i64* %6
%15 = add i64 %14, 524288
%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, 2260630401187840
%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, 4328521728
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 33816576
%31 = or i64 %30, 4260888576
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 262144
%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, 33816576
%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, 141012903133184
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = and i64 %47, 275415826432
%49 = or i64 %48, 140462071480320
store i64 %49, i64* %6
%50 = load i64, i64* %6
%51 = add i64 %50, 1048576
%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, 275415826432
%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, 768
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, 2048
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 2048, %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, 57344
store i64 %82, i64* %5
%83 = load i64, i64* %4
%84 = add i64 %83, 4096
%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, 61440
%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_E7(i64 %0, i64 %1) {
%3 = and i64 %0, 578721382704087040
%4 = and i64 %1, 2260630401187840
%5 = add nuw nsw i64 %4, 574200121902235648
%6 = and i64 %3, %5
%7 = icmp eq i64 %6, 0
%8 = add nuw nsw i64 %6, 4503599627370495
%9 = and i64 %8, 2260630401187840
%10 = select i1 %7, i64 0, i64 %9
%11 = and i64 %0, 4328521728
%12 = and i64 %1, 33816576
%13 = add nuw nsw i64 %12, 4261150720
%14 = and i64 %11, %13
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %14, 67108863
%17 = and i64 %16, 33816576
%18 = select i1 %15, i64 0, i64 %17
%19 = or i64 %10, %18
%20 = and i64 %0, 141012903133184
%21 = and i64 %1, 275415826432
%22 = add nuw nsw i64 %21, 140462072528896
%23 = and i64 %20, %22
%24 = icmp eq i64 %23, 0
%25 = add nuw nsw i64 %23, 549755813887
%26 = and i64 %25, 275415826432
%27 = select i1 %24, i64 0, i64 %26
%28 = or i64 %19, %27
%29 = and i64 %0, 768
%30 = shl nuw nsw i64 %29, 1
%31 = add i64 %30, %1
%32 = and i64 %31, 2048
%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, 2048
%39 = or i64 %38, %28
br label %40
40: ; preds = %34, %2
%41 = phi i64 [ %39, %34 ], [ %28, %2 ]
%42 = and i64 %0, 57344
%43 = add i64 %1, 4096
%44 = and i64 %42, %43
%45 = icmp eq i64 %44, 0
%46 = add nuw nsw i64 %44, 65535
%47 = and i64 %46, 61440
%48 = select i1 %45, i64 0, i64 %47
%49 = or i64 %41, %48
ret i64 %49
}