#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_C7(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 & 0X0000000000400000ULL) & (discs_player >> 9);
  flipped |= (discs_opponent & 0X0000000000004000ULL) & (discs_player >> 1);
  my_discs = discs_player & 0X2020202020000000ULL;
  opp_discs = (discs_opponent & 0X0020202020200000ULL) | 0X1FDFDFDFDFC00000ULL;
  r = (opp_discs + 0X0000000000200000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0020202020200000ULL;
  }
  my_discs = discs_player & 0X0001020408000000ULL;
  opp_discs = (discs_opponent & 0X0000020408100000ULL) | 0X0000FDFBF7E00000ULL;
  r = (opp_discs + 0X0000000000100000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0000020408100000ULL;
  }
  my_discs = discs_player & 0X0000000000000F00ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000002000ULL;
  if (r != 0) {
    flipped |= 0X0000000000002000ULL - (0X2ULL << last_bit(my_discs));
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_C7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0x400000,%rax
mov    -0x8(%rbp),%rcx
shr    $0x9,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
and    $0x4000,%rax
mov    -0x8(%rbp),%rcx
shr    $0x1,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x2020202020000000,%rax
20 20 20
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x20202020200000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfdfdfdfc00000,%rcx
df df 1f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x200000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c1 <flip_C7+0xb1>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x20202020200000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x1020408000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x20408100000,%rax
and    -0x10(%rbp),%rax
movabs $0xfdfbf7e00000,%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     122c <flip_C7+0x11c>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x20408100000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xf00,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x2000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1283 <flip_C7+0x173>
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    $0x2000,%eax
sub    %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_C7>:
push   %rbx
mov    %edi,%eax
shr    $0x9,%eax
and    %esi,%eax
and    $0x400000,%eax
mov    %edi,%ecx
shr    %ecx
and    %esi,%ecx
and    $0x4000,%ecx
or     %rax,%rcx
movabs $0x20202020200000,%r8
mov    %rsi,%rdx
and    %r8,%rdx
movabs $0x1fdfdfdfdfe00000,%rbx
df df 1f
add    %rdx,%rbx
movabs $0x2020202020000000,%rdx
20 20 20
and    %rdi,%rdx
and    %rbx,%rdx
lea    -0x1(%rdx),%rax
and    %r8,%rax
test   %rdx,%rdx
cmove  %rdx,%rax
or     %rcx,%rax
movabs $0x20408100000,%rcx
mov    %rsi,%rdx
and    %rcx,%rdx
movabs $0xfdfbf7f00000,%rbx
add    %rdx,%rbx
movabs $0x1020408000000,%rdx
and    %rdi,%rdx
and    %rbx,%rdx
lea    -0x1(%rdx),%rbx
and    %rcx,%rbx
test   %rdx,%rdx
cmove  %rdx,%rbx
or     %rax,%rbx
and    $0xf00,%edi
lea    (%rsi,%rdi,2),%eax
test   $0x2000,%eax
je     11d3 <flip_C7+0xc3>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x2000,%rdx
or     %rdx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @flip_C7(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, 4194304
%11 = load i64, i64* %3
%12 = lshr i64 %11, 9
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %4
%15 = and i64 %14, 16384
%16 = load i64, i64* %3
%17 = lshr i64 %16, 1
%18 = and i64 %15, %17
%19 = load i64, i64* %8
%20 = or i64 %19, %18
store i64 %20, i64* %8
%21 = load i64, i64* %3
%22 = and i64 %21, 2314885530816348160
store i64 %22, i64* %5
%23 = load i64, i64* %4
%24 = and i64 %23, 9042521604751360
%25 = or i64 %24, 2296800487606845440
store i64 %25, i64* %6
%26 = load i64, i64* %6
%27 = add i64 %26, 2097152
%28 = load i64, i64* %5
%29 = and i64 %27, %28
store i64 %29, i64* %7
%30 = load i64, i64* %7
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %2
%33 = load i64, i64* %7
%34 = sub i64 %33, 1
%35 = and i64 %34, 9042521604751360
%36 = load i64, i64* %8
%37 = or i64 %36, %35
store i64 %37, i64* %8
br label %38
38: ; preds = %32, %2
%39 = load i64, i64* %3
%40 = and i64 %39, 283691314053120
store i64 %40, i64* %5
%41 = load i64, i64* %4
%42 = and i64 %41, 2216338391040
%43 = or i64 %42, 279258637271040
store i64 %43, i64* %6
%44 = load i64, i64* %6
%45 = add i64 %44, 1048576
%46 = load i64, i64* %5
%47 = and i64 %45, %46
store i64 %47, i64* %7
%48 = load i64, i64* %7
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %56
50: ; preds = %38
%51 = load i64, i64* %7
%52 = sub i64 %51, 1
%53 = and i64 %52, 2216338391040
%54 = load i64, i64* %8
%55 = or i64 %54, %53
store i64 %55, i64* %8
br label %56
56: ; preds = %50, %38
%57 = load i64, i64* %3
%58 = and i64 %57, 3840
store i64 %58, i64* %5
%59 = load i64, i64* %5
%60 = shl i64 %59, 1
%61 = load i64, i64* %4
%62 = add i64 %60, %61
%63 = and i64 %62, 8192
store i64 %63, i64* %7
%64 = load i64, i64* %7
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %74
66: ; preds = %56
%67 = load i64, i64* %5
%68 = call i32 @last_bit(i64 %67)
%69 = zext i32 %68 to i64
%70 = shl i64 2, %69
%71 = sub i64 8192, %70
%72 = load i64, i64* %8
%73 = or i64 %72, %71
store i64 %73, i64* %8
br label %74
74: ; preds = %66, %56
%75 = load i64, i64* %8
ret i64 %75
}

LLVM IR (-O2):
define i64 @flip_C7(i64 %0, i64 %1) {
%3 = and i64 %1, 4194304
%4 = lshr i64 %0, 9
%5 = and i64 %3, %4
%6 = and i64 %1, 16384
%7 = lshr i64 %0, 1
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %0, 2314885530816348160
%11 = and i64 %1, 9042521604751360
%12 = add nuw nsw i64 %11, 2296800487608942592
%13 = and i64 %10, %12
%14 = icmp eq i64 %13, 0
%15 = add nuw nsw i64 %13, 18014398509481983
%16 = and i64 %15, 9042521604751360
%17 = select i1 %14, i64 0, i64 %16
%18 = or i64 %9, %17
%19 = and i64 %0, 283691314053120
%20 = and i64 %1, 2216338391040
%21 = add nuw nsw i64 %20, 279258638319616
%22 = and i64 %19, %21
%23 = icmp eq i64 %22, 0
%24 = add nuw nsw i64 %22, 4398046511103
%25 = and i64 %24, 2216338391040
%26 = select i1 %23, i64 0, i64 %25
%27 = or i64 %18, %26
%28 = and i64 %0, 3840
%29 = shl nuw nsw i64 %28, 1
%30 = add i64 %29, %1
%31 = and i64 %30, 8192
%32 = icmp eq i64 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %2
%34 = tail call i32 @last_bit(i64 %28)
%35 = zext i32 %34 to i64
%36 = shl i64 -2, %35
%37 = add i64 %36, 8192
%38 = or i64 %37, %27
br label %39
39: ; preds = %33, %2
%40 = phi i64 [ %38, %33 ], [ %27, %2 ]
ret i64 %40
}