#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_B6(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 & 0X0000000000004000ULL) & (discs_player << 8);
  flipped |= (discs_opponent & 0X0000000000002000ULL) & (discs_player << 9);
  my_discs = discs_player & 0X00000000001F0000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000000400000ULL;
  if (r != 0) {
    flipped |= 0X0000000000400000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X0204081000000000ULL;
  opp_discs = (discs_opponent & 0X0004081020000000ULL) | 0X01FBF7EFC0000000ULL;
  r = (opp_discs + 0X0000000020000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0004081020000000ULL;
  }
  my_discs = discs_player & 0X4040404000000000ULL;
  opp_discs = (discs_opponent & 0X0040404040000000ULL) | 0X3FBFBFBF80000000ULL;
  r = (opp_discs + 0X0000000040000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0040404040000000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_B6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0x4000,%rax
mov    -0x8(%rbp),%rcx
shl    $0x8,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
and    $0x2000,%rax
mov    -0x8(%rbp),%rcx
shl    $0x9,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1f0000,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
and    $0x400000,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ad <flip_B6+0x9d>
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    $0x400000,%eax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x204081000000000,%rax
08 04 02
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x4081020000000,%rax
and    -0x10(%rbp),%rax
movabs $0x1fbf7efc0000000,%rcx
f7 fb 01
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     1218 <flip_B6+0x108>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x4081020000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x4040404000000000,%rax
40 40 40
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x40404040000000,%rax
and    -0x10(%rbp),%rax
movabs $0x3fbfbfbf80000000,%rcx
bf bf 3f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x40000000,%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1283 <flip_B6+0x173>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x40404040000000,%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_B6>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %r14d,%eax
shl    $0x8,%eax
and    %r15d,%eax
and    $0x4000,%eax
mov    %r14d,%ebx
shl    $0x9,%ebx
and    %r15d,%ebx
and    $0x2000,%ebx
or     %rax,%rbx
and    $0x1f0000,%edi
lea    (%rsi,%rdi,2),%eax
test   $0x400000,%eax
je     1166 <flip_B6+0x56>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    $0x400000,%rdx
or     %rdx,%rbx
movabs $0x4081020000000,%rax
mov    %r15,%rcx
and    %rax,%rcx
movabs $0x1fbf7efe0000000,%rdx
f7 fb 01
add    %rcx,%rdx
and    %r14,%rdx
movabs $0x204081000000000,%rcx
08 04 02
and    %rdx,%rcx
lea    -0x1(%rcx),%rdx
and    %rax,%rdx
test   %rcx,%rcx
cmove  %rcx,%rdx
movabs $0x40404040000000,%rcx
and    %rcx,%r15
movabs $0x3fbfbfbfc0000000,%rax
bf bf 3f
add    %r15,%rax
and    %r14,%rax
movabs $0x4040404000000000,%rsi
40 40 40
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_B6(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, 16384
%11 = load i64, i64* %3
%12 = shl i64 %11, 8
%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, 9
%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, 2031616
store i64 %22, i64* %5
%23 = load i64, i64* %5
%24 = shl i64 %23, 1
%25 = load i64, i64* %4
%26 = add i64 %24, %25
%27 = and i64 %26, 4194304
store i64 %27, i64* %7
%28 = load i64, i64* %7
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %2
%31 = load i64, i64* %5
%32 = call i32 @last_bit(i64 %31)
%33 = zext i32 %32 to i64
%34 = shl i64 2, %33
%35 = sub i64 4194304, %34
%36 = load i64, i64* %8
%37 = or i64 %36, %35
store i64 %37, i64* %8
br label %38
38: ; preds = %30, %2
%39 = load i64, i64* %3
%40 = and i64 %39, 145249952795197440
store i64 %40, i64* %5
%41 = load i64, i64* %4
%42 = and i64 %41, 1134765256212480
%43 = or i64 %42, 142980422282772480
store i64 %43, i64* %6
%44 = load i64, i64* %6
%45 = add i64 %44, 536870912
%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, 1134765256212480
%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, 4629771060558954496
store i64 %58, i64* %5
%59 = load i64, i64* %4
%60 = and i64 %59, 18085043205308416
%61 = or i64 %60, 4593600974148337664
store i64 %61, i64* %6
%62 = load i64, i64* %6
%63 = add i64 %62, 1073741824
%64 = load i64, i64* %5
%65 = and i64 %63, %64
store i64 %65, i64* %7
%66 = load i64, i64* %7
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %56
%69 = load i64, i64* %7
%70 = sub i64 %69, 1
%71 = and i64 %70, 18085043205308416
%72 = load i64, i64* %8
%73 = or i64 %72, %71
store i64 %73, i64* %8
br label %74
74: ; preds = %68, %56
%75 = load i64, i64* %8
ret i64 %75
}

LLVM IR (-O2):
define i64 @flip_B6(i64 %0, i64 %1) {
%3 = and i64 %1, 16384
%4 = shl i64 %0, 8
%5 = and i64 %3, %4
%6 = and i64 %1, 8192
%7 = shl i64 %0, 9
%8 = and i64 %6, %7
%9 = or i64 %5, %8
%10 = and i64 %0, 2031616
%11 = shl nuw nsw i64 %10, 1
%12 = add i64 %11, %1
%13 = and i64 %12, 4194304
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %2
%16 = tail call i32 @last_bit(i64 %10)
%17 = zext i32 %16 to i64
%18 = shl i64 -2, %17
%19 = add i64 %18, 4194304
%20 = or i64 %19, %9
br label %21
21: ; preds = %15, %2
%22 = phi i64 [ %20, %15 ], [ %9, %2 ]
%23 = and i64 %0, 145249952795197440
%24 = and i64 %1, 1134765256212480
%25 = add nuw nsw i64 %24, 142980422819643392
%26 = and i64 %23, %25
%27 = icmp eq i64 %26, 0
%28 = add nuw nsw i64 %26, 2251799813685247
%29 = and i64 %28, 1134765256212480
%30 = select i1 %27, i64 0, i64 %29
%31 = and i64 %0, 4629771060558954496
%32 = and i64 %1, 18085043205308416
%33 = add nuw nsw i64 %32, 4593600975222079488
%34 = and i64 %31, %33
%35 = icmp eq i64 %34, 0
%36 = add nuw nsw i64 %34, 36028797018963967
%37 = and i64 %36, 18085043205308416
%38 = select i1 %35, i64 0, i64 %37
%39 = or i64 %38, %30
%40 = or i64 %39, %22
ret i64 %40
}