#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_A1(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 & 0X0000201008040201ULL;
  opp_discs = (discs_opponent & 0X0040201008040200ULL) | 0X7FBFDFEFF7FBFC00ULL;
  r = ((my_discs << 9) + opp_discs) & 0X8000000000000000ULL;
  if (r != 0) {
    flipped |= (0X8000000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0040201008040200ULL;
  }
  my_discs = discs_player & 0X0000808080808080ULL;
  opp_discs = (discs_opponent & 0X0080808080808000ULL) | 0X7F7F7F7F7F7F0000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X8000000000000000ULL;
  if (r != 0) {
    flipped |= (0X8000000000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0080808080808000ULL;
  }
  my_discs = discs_player & 0X3F00000000000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X8000000000000000ULL;
  if (r != 0) {
    flipped |= 0X8000000000000000ULL - (0X2ULL << last_bit(my_discs));
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_A1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x201008040201,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x40201008040200,%rax
and    -0x10(%rbp),%rax
movabs $0x7fbfdfeff7fbfc00,%rcx
df bf 7f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x8000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11bb <flip_A1+0xab>
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 $0x8000000000000000,%rax
sub    %rcx,%rax
movabs $0x40201008040200,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x808080808080,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x80808080808000,%rax
and    -0x10(%rbp),%rax
movabs $0x7f7f7f7f7f7f0000,%rcx
7f 7f 7f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x8000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     124e <flip_A1+0x13e>
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 $0x8000000000000000,%rax
sub    %rcx,%rax
movabs $0x80808080808000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x3f00000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x8000000000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12b5 <flip_A1+0x1a5>
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 $0x8000000000000000,%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_A1>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movabs $0x40201008040200,%r12
movabs $0x201008040201,%rdi
and    %rbx,%rdi
mov    %rsi,%rax
and    %r12,%rax
mov    %rdi,%rcx
shl    $0x9,%rcx
add    %rax,%rcx
movabs $0x7fbfdfeff7fbfc00,%rax
df bf 7f
add    %rcx,%rax
js     1159 <flip_A1+0x49>
xor    %r15d,%r15d
jmp    116d <flip_A1+0x5d>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%r15
mov    %eax,%ecx
shl    %cl,%r15
and    %r12,%r15
movabs $0x80808080808000,%r12
movabs $0x808080808080,%rdi
and    %rbx,%rdi
mov    %r14,%rax
and    %r12,%rax
mov    %rdi,%rcx
shl    $0x8,%rcx
add    %rax,%rcx
movabs $0x7f7f7f7f7f7f0000,%rax
7f 7f 7f
add    %rcx,%rax
jns    11ba <flip_A1+0xaa>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    %r12,%rdx
or     %rdx,%r15
movabs $0x3f00000000000000,%rax
and    %rax,%rbx
lea    (%rbx,%rbx,1),%rax
add    %rax,%r14
jns    11f4 <flip_A1+0xe4>
mov    %rbx,%rdi
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
movabs $0x8000000000000000,%rax
xor    %rdx,%rax
or     %rax,%r15
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @flip_A1(i64 %0, i64 %1) {
%3 = and i64 %0, 35253226045953
%4 = and i64 %1, 18049651735527936
%5 = or i64 %4, 9205322385119247360
%6 = shl nuw nsw i64 %3, 9
%7 = add nuw i64 %5, %6
%8 = icmp sgt i64 %7, -1
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = tail call i32 @last_bit(i64 %3)
%11 = zext i32 %10 to i64
%12 = shl i64 -2, %11
%13 = and i64 %12, 18049651735527936
br label %14
14: ; preds = %9, %2
%15 = phi i64 [ %13, %9 ], [ 0, %2 ]
%16 = and i64 %0, 141289400074368
%17 = and i64 %1, 36170086419038208
%18 = or i64 %17, 9187201950435704832
%19 = shl nuw nsw i64 %16, 8
%20 = add nuw i64 %18, %19
%21 = icmp sgt i64 %20, -1
br i1 %21, label %28, label %22
22: ; preds = %14
%23 = tail call i32 @last_bit(i64 %16)
%24 = zext i32 %23 to i64
%25 = shl i64 -2, %24
%26 = and i64 %25, 36170086419038208
%27 = or i64 %26, %15
br label %28
28: ; preds = %22, %14
%29 = phi i64 [ %27, %22 ], [ %15, %14 ]
%30 = and i64 %0, 4539628424389459968
%31 = shl nuw nsw i64 %30, 1
%32 = add i64 %31, %1
%33 = icmp sgt i64 %32, -1
br i1 %33, label %40, label %34
34: ; preds = %28
%35 = tail call i32 @last_bit(i64 %30)
%36 = zext i32 %35 to i64
%37 = shl i64 -2, %36
%38 = xor i64 %37, -9223372036854775808
%39 = or i64 %38, %29
br label %40
40: ; preds = %34, %28
%41 = phi i64 [ %39, %34 ], [ %29, %28 ]
ret i64 %41
}