#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_A5(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 & 0X000000003F000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000000080000000ULL;
  if (r != 0) {
    flipped |= 0X0000000080000000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X0810200000000000ULL;
  opp_discs = (discs_opponent & 0X0010204000000000ULL) | 0X07EFDF8000000000ULL;
  r = (opp_discs + 0X0000004000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0010204000000000ULL;
  }
  my_discs = discs_player & 0X0000000000002010ULL;
  opp_discs = (discs_opponent & 0X0000000000402000ULL) | 0X000000007FBFC000ULL;
  r = ((my_discs << 9) + opp_discs) & 0X0000000080000000ULL;
  if (r != 0) {
    flipped |= (0X0000000080000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000000402000ULL;
  }
  my_discs = discs_player & 0X8080800000000000ULL;
  opp_discs = (discs_opponent & 0X0080808000000000ULL) | 0X7F7F7F0000000000ULL;
  r = (opp_discs + 0X0000008000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0080808000000000ULL;
  }
  my_discs = discs_player & 0X0000000000008080ULL;
  opp_discs = (discs_opponent & 0X0000000000808000ULL) | 0X000000007F7F0000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000000080000000ULL;
  if (r != 0) {
    flipped |= (0X0000000080000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000000808000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_A5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x3f000000,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x80000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1186 <flip_A5+0x76>
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    $0x80000000,%eax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x810200000000000,%rax
20 10 08
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x10204000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x7efdf8000000000,%rcx
df ef 07
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x4000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f5 <flip_A5+0xe5>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x10204000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x2010,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x402000,%rax
or     $0x7fbfc000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x80000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     126d <flip_A5+0x15d>
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    $0x80000000,%eax
sub    %rcx,%rax
and    $0x402000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x8080800000000000,%rax
80 80 80
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x80808000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x7f7f7f0000000000,%rcx
7f 7f 7f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x8000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12dc <flip_A5+0x1cc>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x80808000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x8080,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x808000,%rax
or     $0x7f7f0000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x80000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1354 <flip_A5+0x244>
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    $0x80000000,%eax
sub    %rcx,%rax
and    $0x808000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flip_A5>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
and    $0x3f000000,%edi
lea    (%rsi,%rdi,2),%eax
test   $0x80000000,%eax
jne    1132 <flip_A5+0x22>
xor    %edx,%edx
jmp    114a <flip_A5+0x3a>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
sub    $0xffffffff80000000,%rdx
movabs $0x10204000000000,%rax
mov    %r14,%rcx
and    %rax,%rcx
movabs $0x7efdfc000000000,%rsi
df ef 07
add    %rcx,%rsi
and    %r15,%rsi
movabs $0x810200000000000,%rcx
20 10 08
and    %rsi,%rcx
lea    -0x1(%rcx),%r12
and    %rax,%r12
test   %rcx,%rcx
cmove  %rcx,%r12
or     %rdx,%r12
mov    %r15d,%edi
and    $0x2010,%edi
mov    %r14d,%eax
and    $0x402000,%eax
mov    %edi,%ecx
shl    $0x9,%ecx
add    %ecx,%eax
add    $0x7fbfc000,%eax
test   $0x80000000,%eax
je     11c6 <flip_A5+0xb6>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x402000,%edx
or     %rdx,%r12
movabs $0x80808000000000,%rax
mov    %r14,%rcx
and    %rax,%rcx
movabs $0x7f7f7f8000000000,%rdx
7f 7f 7f
add    %rcx,%rdx
and    %r15,%rdx
movabs $0x8080800000000000,%rcx
80 80 80
and    %rdx,%rcx
lea    -0x1(%rcx),%rbx
and    %rax,%rbx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %r12,%rbx
and    $0x8080,%r15d
and    $0x808000,%r14d
mov    %r15d,%eax
shl    $0x8,%eax
add    %r14d,%eax
add    $0x7f7f0000,%eax
test   $0x80000000,%eax
je     1244 <flip_A5+0x134>
mov    %r15,%rdi
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x808000,%edx
or     %rdx,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @flip_A5(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, 1056964608
store i64 %10, i64* %5
%11 = load i64, i64* %5
%12 = shl i64 %11, 1
%13 = load i64, i64* %4
%14 = add i64 %12, %13
%15 = and i64 %14, 2147483648
store i64 %15, i64* %7
%16 = load i64, i64* %7
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i64, i64* %5
%20 = call i32 @last_bit(i64 %19)
%21 = zext i32 %20 to i64
%22 = shl i64 2, %21
%23 = sub i64 2147483648, %22
%24 = load i64, i64* %8
%25 = or i64 %24, %23
store i64 %25, i64* %8
br label %26
26: ; preds = %18, %2
%27 = load i64, i64* %3
%28 = and i64 %27, 580999536302882816
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 4539058877366272
%31 = or i64 %30, 571921418548150272
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 274877906944
%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, 4539058877366272
%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, 8208
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = and i64 %47, 4202496
%49 = or i64 %48, 2143272960
store i64 %49, i64* %6
%50 = load i64, i64* %5
%51 = shl i64 %50, 9
%52 = load i64, i64* %6
%53 = add i64 %51, %52
%54 = and i64 %53, 2147483648
store i64 %54, i64* %7
%55 = load i64, i64* %7
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %66
57: ; preds = %44
%58 = load i64, i64* %5
%59 = call i32 @last_bit(i64 %58)
%60 = zext i32 %59 to i64
%61 = shl i64 2, %60
%62 = sub i64 2147483648, %61
%63 = and i64 %62, 4202496
%64 = load i64, i64* %8
%65 = or i64 %64, %63
store i64 %65, i64* %8
br label %66
66: ; preds = %57, %44
%67 = load i64, i64* %3
%68 = and i64 %67, -9187202502347456512
store i64 %68, i64* %5
%69 = load i64, i64* %4
%70 = and i64 %69, 36170084263133184
%71 = or i64 %70, 9187201402835828736
store i64 %71, i64* %6
%72 = load i64, i64* %6
%73 = add i64 %72, 549755813888
%74 = load i64, i64* %5
%75 = and i64 %73, %74
store i64 %75, i64* %7
%76 = load i64, i64* %7
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %84
78: ; preds = %66
%79 = load i64, i64* %7
%80 = sub i64 %79, 1
%81 = and i64 %80, 36170084263133184
%82 = load i64, i64* %8
%83 = or i64 %82, %81
store i64 %83, i64* %8
br label %84
84: ; preds = %78, %66
%85 = load i64, i64* %3
%86 = and i64 %85, 32896
store i64 %86, i64* %5
%87 = load i64, i64* %4
%88 = and i64 %87, 8421376
%89 = or i64 %88, 2139029504
store i64 %89, i64* %6
%90 = load i64, i64* %5
%91 = shl i64 %90, 8
%92 = load i64, i64* %6
%93 = add i64 %91, %92
%94 = and i64 %93, 2147483648
store i64 %94, i64* %7
%95 = load i64, i64* %7
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %106
97: ; preds = %84
%98 = load i64, i64* %5
%99 = call i32 @last_bit(i64 %98)
%100 = zext i32 %99 to i64
%101 = shl i64 2, %100
%102 = sub i64 2147483648, %101
%103 = and i64 %102, 8421376
%104 = load i64, i64* %8
%105 = or i64 %104, %103
store i64 %105, i64* %8
br label %106
106: ; preds = %97, %84
%107 = load i64, i64* %8
ret i64 %107
}

LLVM IR (-O2):
define i64 @flip_A5(i64 %0, i64 %1) {
%3 = and i64 %0, 1056964608
%4 = shl nuw nsw i64 %3, 1
%5 = add i64 %4, %1
%6 = and i64 %5, 2147483648
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = tail call i32 @last_bit(i64 %3)
%10 = zext i32 %9 to i64
%11 = shl i64 -2, %10
%12 = add i64 %11, 2147483648
br label %13
13: ; preds = %8, %2
%14 = phi i64 [ %12, %8 ], [ 0, %2 ]
%15 = and i64 %0, 580999536302882816
%16 = and i64 %1, 4539058877366272
%17 = add nuw nsw i64 %16, 571921693426057216
%18 = and i64 %15, %17
%19 = icmp eq i64 %18, 0
%20 = add nuw nsw i64 %18, 9007199254740991
%21 = and i64 %20, 4539058877366272
%22 = select i1 %19, i64 0, i64 %21
%23 = or i64 %14, %22
%24 = and i64 %0, 8208
%25 = and i64 %1, 4202496
%26 = or i64 %25, 2143272960
%27 = shl nuw nsw i64 %24, 9
%28 = add nuw nsw i64 %26, %27
%29 = and i64 %28, 2147483648
%30 = icmp eq i64 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %13
%32 = tail call i32 @last_bit(i64 %24)
%33 = zext i32 %32 to i64
%34 = shl i64 -2, %33
%35 = and i64 %34, 4202496
%36 = or i64 %35, %23
br label %37
37: ; preds = %31, %13
%38 = phi i64 [ %36, %31 ], [ %23, %13 ]
%39 = and i64 %0, -9187202502347456512
%40 = and i64 %1, 36170084263133184
%41 = add nuw i64 %40, 9187201952591642624
%42 = and i64 %39, %41
%43 = icmp eq i64 %42, 0
%44 = add nuw nsw i64 %42, 72057594037927935
%45 = and i64 %44, 36170084263133184
%46 = select i1 %43, i64 0, i64 %45
%47 = or i64 %38, %46
%48 = and i64 %0, 32896
%49 = and i64 %1, 8421376
%50 = or i64 %49, 2139029504
%51 = shl nuw nsw i64 %48, 8
%52 = add nuw nsw i64 %50, %51
%53 = and i64 %52, 2147483648
%54 = icmp eq i64 %53, 0
br i1 %54, label %61, label %55
55: ; preds = %37
%56 = tail call i32 @last_bit(i64 %48)
%57 = zext i32 %56 to i64
%58 = shl i64 -2, %57
%59 = and i64 %58, 8421376
%60 = or i64 %59, %47
br label %61
61: ; preds = %55, %37
%62 = phi i64 [ %60, %55 ], [ %47, %37 ]
ret i64 %62
}