#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_C6(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 & 0X0000000000001000ULL) & (discs_player << 9);
  flipped |= (discs_opponent & 0X0000000000002000ULL) & (discs_player << 8);
  flipped |= (discs_opponent & 0X0000000040000000ULL) & (discs_player >> 9);
  flipped |= (discs_opponent & 0X0000000000004000ULL) & (discs_player << 7);
  flipped |= (discs_opponent & 0X0000000000400000ULL) & (discs_player >> 1);
  my_discs = discs_player & 0X00000000000F0000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000200000ULL;
  if (r != 0) {
    flipped |= 0X0000000000200000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X0102040800000000ULL;
  opp_discs = (discs_opponent & 0X0002040810000000ULL) | 0X00FDFBF7E0000000ULL;
  r = (opp_discs + 0X0000000010000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0002040810000000ULL;
  }
  my_discs = discs_player & 0X2020202000000000ULL;
  opp_discs = (discs_opponent & 0X0020202020000000ULL) | 0X1FDFDFDFC0000000ULL;
  r = (opp_discs + 0X0000000020000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0020202020000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_C6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0x1000,%rax
mov    -0x8(%rbp),%rcx
shl    $0x9,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
and    $0x2000,%rax
mov    -0x8(%rbp),%rcx
shl    $0x8,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
and    $0x40000000,%rax
mov    -0x8(%rbp),%rcx
shr    $0x9,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
and    $0x4000,%rax
mov    -0x8(%rbp),%rcx
shl    $0x7,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
and    $0x400000,%rax
mov    -0x8(%rbp),%rcx
shr    $0x1,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0xf0000,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x200000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1204 <flip_C6+0xf4>
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    $0x200000,%eax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x102040800000000,%rax
04 02 01
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x2040810000000,%rax
and    -0x10(%rbp),%rax
movabs $0xfdfbf7e0000000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x10000000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     126f <flip_C6+0x15f>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x2040810000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x2020202000000000,%rax
20 20 20
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x20202020000000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfdfdfc0000000,%rcx
df df 1f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20000000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12da <flip_C6+0x1ca>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x20202020000000,%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_C6>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %r14d,%eax
shl    $0x9,%eax
and    %r15d,%eax
and    $0x1000,%eax
mov    %r14d,%ecx
shl    $0x8,%ecx
and    %r15d,%ecx
and    $0x2000,%ecx
or     %rax,%rcx
mov    %rdi,%rax
shr    $0x9,%rax
and    %r15d,%eax
and    $0x40000000,%eax
or     %rcx,%rax
mov    %r14d,%ecx
shl    $0x7,%ecx
and    %r15d,%ecx
and    $0x4000,%ecx
or     %rax,%rcx
mov    %r14d,%ebx
shr    %ebx
and    %r15d,%ebx
and    $0x400000,%ebx
or     %rcx,%rbx
and    $0xf0000,%edi
lea    (%rsi,%rdi,2),%eax
test   $0x200000,%eax
je     119b <flip_C6+0x8b>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x200000,%rdx
or     %rdx,%rbx
movabs $0x2040810000000,%rax
mov    %r15,%rcx
and    %rax,%rcx
movabs $0xfdfbf7f0000000,%rdx
add    %rcx,%rdx
and    %r14,%rdx
movabs $0x102040800000000,%rcx
04 02 01
and    %rdx,%rcx
lea    -0x1(%rcx),%rdx
and    %rax,%rdx
test   %rcx,%rcx
cmove  %rcx,%rdx
movabs $0x20202020000000,%rcx
and    %rcx,%r15
movabs $0x1fdfdfdfe0000000,%rax
df df 1f
add    %r15,%rax
and    %r14,%rax
movabs $0x2020202000000000,%rsi
20 20 20
and    %rax,%rsi
lea    -0x1(%rsi),%rax
and    %rcx,%rax
test   %rsi,%rsi
cmove  %rsi,%rax
or     %rdx,%rax
or     %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_C6(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, 4096
%11 = load i64, i64* %3
%12 = shl i64 %11, 9
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %4
%15 = and i64 %14, 8192
%16 = load i64, i64* %3
%17 = shl 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, 1073741824
%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* %4
%29 = and i64 %28, 16384
%30 = load i64, i64* %3
%31 = shl i64 %30, 7
%32 = and i64 %29, %31
%33 = load i64, i64* %8
%34 = or i64 %33, %32
store i64 %34, i64* %8
%35 = load i64, i64* %4
%36 = and i64 %35, 4194304
%37 = load i64, i64* %3
%38 = lshr i64 %37, 1
%39 = and i64 %36, %38
%40 = load i64, i64* %8
%41 = or i64 %40, %39
store i64 %41, i64* %8
%42 = load i64, i64* %3
%43 = and i64 %42, 983040
store i64 %43, i64* %5
%44 = load i64, i64* %5
%45 = shl i64 %44, 1
%46 = load i64, i64* %4
%47 = add i64 %45, %46
%48 = and i64 %47, 2097152
store i64 %48, i64* %7
%49 = load i64, i64* %7
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %59
51: ; preds = %2
%52 = load i64, i64* %5
%53 = call i32 @last_bit(i64 %52)
%54 = zext i32 %53 to i64
%55 = shl i64 2, %54
%56 = sub i64 2097152, %55
%57 = load i64, i64* %8
%58 = or i64 %57, %56
store i64 %58, i64* %8
br label %59
59: ; preds = %51, %2
%60 = load i64, i64* %3
%61 = and i64 %60, 72624976397598720
store i64 %61, i64* %5
%62 = load i64, i64* %4
%63 = and i64 %62, 567382628106240
%64 = or i64 %63, 71490211141386240
store i64 %64, i64* %6
%65 = load i64, i64* %6
%66 = add i64 %65, 268435456
%67 = load i64, i64* %5
%68 = and i64 %66, %67
store i64 %68, i64* %7
%69 = load i64, i64* %7
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %59
%72 = load i64, i64* %7
%73 = sub i64 %72, 1
%74 = and i64 %73, 567382628106240
%75 = load i64, i64* %8
%76 = or i64 %75, %74
store i64 %76, i64* %8
br label %77
77: ; preds = %71, %59
%78 = load i64, i64* %3
%79 = and i64 %78, 2314885530279477248
store i64 %79, i64* %5
%80 = load i64, i64* %4
%81 = and i64 %80, 9042521602654208
%82 = or i64 %81, 2296800487074168832
store i64 %82, i64* %6
%83 = load i64, i64* %6
%84 = add i64 %83, 536870912
%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 = %77
%90 = load i64, i64* %7
%91 = sub i64 %90, 1
%92 = and i64 %91, 9042521602654208
%93 = load i64, i64* %8
%94 = or i64 %93, %92
store i64 %94, i64* %8
br label %95
95: ; preds = %89, %77
%96 = load i64, i64* %8
ret i64 %96
}

LLVM IR (-O2):
define i64 @flip_C6(i64 %0, i64 %1) {
%3 = and i64 %1, 4096
%4 = shl i64 %0, 9
%5 = and i64 %3, %4
%6 = and i64 %1, 8192
%7 = shl i64 %0, 8
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %1, 1073741824
%11 = lshr i64 %0, 9
%12 = and i64 %10, %11
%13 = or i64 %9, %12
%14 = and i64 %1, 16384
%15 = shl i64 %0, 7
%16 = and i64 %14, %15
%17 = or i64 %13, %16
%18 = and i64 %1, 4194304
%19 = lshr i64 %0, 1
%20 = and i64 %18, %19
%21 = or i64 %17, %20
%22 = and i64 %0, 983040
%23 = shl nuw nsw i64 %22, 1
%24 = add i64 %23, %1
%25 = and i64 %24, 2097152
%26 = icmp eq i64 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %2
%28 = tail call i32 @last_bit(i64 %22)
%29 = zext i32 %28 to i64
%30 = shl i64 -2, %29
%31 = add i64 %30, 2097152
%32 = or i64 %31, %21
br label %33
33: ; preds = %27, %2
%34 = phi i64 [ %32, %27 ], [ %21, %2 ]
%35 = and i64 %0, 72624976397598720
%36 = and i64 %1, 567382628106240
%37 = add nuw nsw i64 %36, 71490211409821696
%38 = and i64 %35, %37
%39 = icmp eq i64 %38, 0
%40 = add nuw nsw i64 %38, 1125899906842623
%41 = and i64 %40, 567382628106240
%42 = select i1 %39, i64 0, i64 %41
%43 = and i64 %0, 2314885530279477248
%44 = and i64 %1, 9042521602654208
%45 = add nuw nsw i64 %44, 2296800487611039744
%46 = and i64 %43, %45
%47 = icmp eq i64 %46, 0
%48 = add nuw nsw i64 %46, 18014398509481983
%49 = and i64 %48, 9042521602654208
%50 = select i1 %47, i64 0, i64 %49
%51 = or i64 %50, %42
%52 = or i64 %51, %34
ret i64 %52
}