#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_C1(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 & 0X4000000000000000ULL) & (discs_player >> 1);
  flipped |= (discs_opponent & 0X0040000000000000ULL) & (discs_player << 7);
  my_discs = discs_player & 0X0000202020202020ULL;
  opp_discs = (discs_opponent & 0X0020202020202000ULL) | 0X1FDFDFDFDFDFC000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X2000000000000000ULL;
  if (r != 0) {
    flipped |= (0X2000000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0020202020202000ULL;
  }
  my_discs = discs_player & 0X0000080402010000ULL;
  opp_discs = (discs_opponent & 0X0010080402000000ULL) | 0X1FEFF7FBFC000000ULL;
  r = ((my_discs << 9) + opp_discs) & 0X2000000000000000ULL;
  if (r != 0) {
    flipped |= (0X2000000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0010080402000000ULL;
  }
  my_discs = discs_player & 0X0F00000000000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X2000000000000000ULL;
  if (r != 0) {
    flipped |= 0X2000000000000000ULL - (0X2ULL << last_bit(my_discs));
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_C1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x4000000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shr    $0x1,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
movabs $0x40000000000000,%rax
and    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
shl    $0x7,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x202020202020,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x20202020202000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fdfdfdfdfdfc000,%rcx
df df 1f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x2000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f1 <flip_C1+0xe1>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
movabs $0x2000000000000000,%rax
sub    %rcx,%rax
movabs $0x20202020202000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x80402010000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x10080402000000,%rax
and    -0x10(%rbp),%rax
movabs $0x1feff7fbfc000000,%rcx
f7 ef 1f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x2000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1284 <flip_C1+0x174>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
movabs $0x2000000000000000,%rax
sub    %rcx,%rax
movabs $0x10080402000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0xf00000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x2000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12eb <flip_C1+0x1db>
mov    -0x18(%rbp),%rdi
call   1030 <last_bit@plt>
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x2,%eax
shl    %cl,%rax
mov    %rax,%rcx
movabs $0x2000000000000000,%rax
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_C1>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movabs $0x2000000000000000,%r12
movabs $0x20202020202000,%r13
mov    %rdi,%rax
shr    %rax
and    %rsi,%rax
movabs $0x4000000000000000,%rcx
and    %rax,%rcx
mov    %rdi,%rax
shl    $0x7,%rax
and    %rsi,%rax
movabs $0x40000000000000,%rbx
and    %rax,%rbx
or     %rcx,%rbx
movabs $0x202020202020,%rdi
and    %r14,%rdi
mov    %rsi,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
movabs $0x1fdfdfdfdfdfc000,%rax
df df 1f
add    %rcx,%rax
bt     $0x3d,%rax
jae    11ab <flip_C1+0x9b>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%rbx
movabs $0x10080402000000,%r13
movabs $0x80402010000,%rdi
and    %r14,%rdi
mov    %r15,%rax
and    %r13,%rax
mov    %rdi,%rcx
shl    $0x9,%rcx
add    %rax,%rcx
movabs $0x1feff7fbfc000000,%rax
f7 ef 1f
add    %rcx,%rax
test   %r12,%rax
je     11fb <flip_C1+0xeb>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r13,%rdx
or     %rdx,%rbx
movabs $0xf00000000000000,%rax
and    %rax,%r14
lea    (%r15,%r14,2),%rax
test   %r12,%rax
je     122b <flip_C1+0x11b>
mov    %r14,%rdi
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    %r12,%rdx
or     %rdx,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_C1(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, 4611686018427387904
%11 = load i64, i64* %3
%12 = lshr i64 %11, 1
%13 = and i64 %10, %12
store i64 %13, i64* %8
%14 = load i64, i64* %4
%15 = and i64 %14, 18014398509481984
%16 = load i64, i64* %3
%17 = shl i64 %16, 7
%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, 35322350018592
store i64 %22, i64* %5
%23 = load i64, i64* %4
%24 = and i64 %23, 9042521604759552
%25 = or i64 %24, 2296800487608926208
store i64 %25, i64* %6
%26 = load i64, i64* %5
%27 = shl i64 %26, 8
%28 = load i64, i64* %6
%29 = add i64 %27, %28
%30 = and i64 %29, 2305843009213693952
store i64 %30, i64* %7
%31 = load i64, i64* %7
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %2
%34 = load i64, i64* %5
%35 = call i32 @last_bit(i64 %34)
%36 = zext i32 %35 to i64
%37 = shl i64 2, %36
%38 = sub i64 2305843009213693952, %37
%39 = and i64 %38, 9042521604759552
%40 = load i64, i64* %8
%41 = or i64 %40, %39
store i64 %41, i64* %8
br label %42
42: ; preds = %33, %2
%43 = load i64, i64* %3
%44 = and i64 %43, 8813306511360
store i64 %44, i64* %5
%45 = load i64, i64* %4
%46 = and i64 %45, 4512412933816320
%47 = or i64 %46, 2301330596246323200
store i64 %47, i64* %6
%48 = load i64, i64* %5
%49 = shl i64 %48, 9
%50 = load i64, i64* %6
%51 = add i64 %49, %50
%52 = and i64 %51, 2305843009213693952
store i64 %52, i64* %7
%53 = load i64, i64* %7
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %64
55: ; preds = %42
%56 = load i64, i64* %5
%57 = call i32 @last_bit(i64 %56)
%58 = zext i32 %57 to i64
%59 = shl i64 2, %58
%60 = sub i64 2305843009213693952, %59
%61 = and i64 %60, 4512412933816320
%62 = load i64, i64* %8
%63 = or i64 %62, %61
store i64 %63, i64* %8
br label %64
64: ; preds = %55, %42
%65 = load i64, i64* %3
%66 = and i64 %65, 1080863910568919040
store i64 %66, i64* %5
%67 = load i64, i64* %5
%68 = shl i64 %67, 1
%69 = load i64, i64* %4
%70 = add i64 %68, %69
%71 = and i64 %70, 2305843009213693952
store i64 %71, i64* %7
%72 = load i64, i64* %7
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %82
74: ; preds = %64
%75 = load i64, i64* %5
%76 = call i32 @last_bit(i64 %75)
%77 = zext i32 %76 to i64
%78 = shl i64 2, %77
%79 = sub i64 2305843009213693952, %78
%80 = load i64, i64* %8
%81 = or i64 %80, %79
store i64 %81, i64* %8
br label %82
82: ; preds = %74, %64
%83 = load i64, i64* %8
ret i64 %83
}

LLVM IR (-O2):
define i64 @flip_C1(i64 %0, i64 %1) {
%3 = and i64 %1, 4611686018427387904
%4 = lshr i64 %0, 1
%5 = and i64 %3, %4
%6 = and i64 %1, 18014398509481984
%7 = shl i64 %0, 7
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %0, 35322350018592
%11 = and i64 %1, 9042521604759552
%12 = or i64 %11, 2296800487608926208
%13 = shl nuw nsw i64 %10, 8
%14 = add nuw nsw i64 %12, %13
%15 = and i64 %14, 2305843009213693952
%16 = icmp eq i64 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %2
%18 = tail call i32 @last_bit(i64 %10)
%19 = zext i32 %18 to i64
%20 = shl i64 -2, %19
%21 = and i64 %20, 9042521604759552
%22 = or i64 %21, %9
br label %23
23: ; preds = %17, %2
%24 = phi i64 [ %22, %17 ], [ %9, %2 ]
%25 = and i64 %0, 8813306511360
%26 = and i64 %1, 4512412933816320
%27 = or i64 %26, 2301330596246323200
%28 = shl nuw nsw i64 %25, 9
%29 = add nuw nsw i64 %27, %28
%30 = and i64 %29, 2305843009213693952
%31 = icmp eq i64 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %23
%33 = tail call i32 @last_bit(i64 %25)
%34 = zext i32 %33 to i64
%35 = shl i64 -2, %34
%36 = and i64 %35, 4512412933816320
%37 = or i64 %36, %24
br label %38
38: ; preds = %32, %23
%39 = phi i64 [ %37, %32 ], [ %24, %23 ]
%40 = and i64 %0, 1080863910568919040
%41 = shl nuw nsw i64 %40, 1
%42 = add i64 %41, %1
%43 = and i64 %42, 2305843009213693952
%44 = icmp eq i64 %43, 0
br i1 %44, label %51, label %45
45: ; preds = %38
%46 = tail call i32 @last_bit(i64 %40)
%47 = zext i32 %46 to i64
%48 = shl i64 -2, %47
%49 = add i64 %48, 2305843009213693952
%50 = or i64 %49, %39
br label %51
51: ; preds = %45, %38
%52 = phi i64 [ %50, %45 ], [ %39, %38 ]
ret i64 %52
}