#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_A4(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 & 0X0000003F00000000ULL;
  r = ((my_discs << 1) + discs_opponent) & 0X0000008000000000ULL;
  if (r != 0) {
    flipped |= 0X0000008000000000ULL - (0X2ULL << last_bit(my_discs));
  }
  my_discs = discs_player & 0X1020000000000000ULL;
  opp_discs = (discs_opponent & 0X0020400000000000ULL) | 0X0FDF800000000000ULL;
  r = (opp_discs + 0X0000400000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0020400000000000ULL;
  }
  my_discs = discs_player & 0X0000000000201008ULL;
  opp_discs = (discs_opponent & 0X0000000040201000ULL) | 0X0000007FBFDFE000ULL;
  r = ((my_discs << 9) + opp_discs) & 0X0000008000000000ULL;
  if (r != 0) {
    flipped |= (0X0000008000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000040201000ULL;
  }
  my_discs = discs_player & 0X8080000000000000ULL;
  opp_discs = (discs_opponent & 0X0080800000000000ULL) | 0X7F7F000000000000ULL;
  r = (opp_discs + 0X0000800000000000ULL) & my_discs;
  if (r != 0) {
    flipped |= (r - 1) & 0X0080800000000000ULL;
  }
  my_discs = discs_player & 0X0000000000808080ULL;
  opp_discs = (discs_opponent & 0X0000000080808000ULL) | 0X0000007F7F7F0000ULL;
  r = ((my_discs << 8) + opp_discs) & 0X0000008000000000ULL;
  if (r != 0) {
    flipped |= (0X0000008000000000ULL - (0X2ULL << last_bit(my_discs))) &
               0X0000000080808000ULL;
  }
  return flipped;
}


x86 assembly (clang, -O0):
<flip_A4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movabs $0x3f00000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
add    -0x10(%rbp),%rax
movabs $0x8000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     118f <flip_A4+0x7f>
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 $0x8000000000,%rax
sub    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x1020000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x20400000000000,%rax
and    -0x10(%rbp),%rax
movabs $0xfdf800000000000,%rcx
80 df 0f
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x400000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fe <flip_A4+0xee>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x20400000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x201008,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0x40201000,%rax
movabs $0x7fbfdfe000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x9,%rax
add    -0x20(%rbp),%rax
movabs $0x8000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1282 <flip_A4+0x172>
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 $0x8000000000,%rax
sub    %rcx,%rax
and    $0x40201000,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
movabs $0x8080000000000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x80800000000000,%rax
and    -0x10(%rbp),%rax
movabs $0x7f7f000000000000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
movabs $0x800000000000,%rax
add    -0x20(%rbp),%rax
and    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12f1 <flip_A4+0x1e1>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movabs $0x80800000000000,%rcx
and    %rcx,%rax
or     -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
and    $0x808080,%rax
mov    %rax,-0x18(%rbp)
movabs $0x80808000,%rax
and    -0x10(%rbp),%rax
movabs $0x7f7f7f0000,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
add    -0x20(%rbp),%rax
movabs $0x8000000000,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1380 <flip_A4+0x270>
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 $0x8000000000,%rax
sub    %rcx,%rax
movabs $0x80808000,%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_A4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
movabs $0x8000000000,%r12
movabs $0x3f00000000,%rdi
and    %r14,%rdi
lea    (%rsi,%rdi,2),%rax
bt     $0x27,%rax
jb     1147 <flip_A4+0x37>
xor    %edx,%edx
jmp    115b <flip_A4+0x4b>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
add    %r12,%rdx
movabs $0x20400000000000,%rax
mov    %r15,%rcx
and    %rax,%rcx
movabs $0xfdfc00000000000,%rsi
c0 df 0f
add    %rcx,%rsi
and    %r14,%rsi
movabs $0x1020000000000000,%rcx
and    %rsi,%rcx
lea    -0x1(%rcx),%rbp
and    %rax,%rbp
test   %rcx,%rcx
cmove  %rcx,%rbp
movabs $0x7f7f7f0000,%r13
or     %rdx,%rbp
mov    %r14d,%edi
and    $0x201008,%edi
mov    %r15d,%eax
and    $0x40201000,%eax
mov    %rdi,%rcx
shl    $0x9,%rcx
add    %rax,%rcx
lea    (%rcx,%r13,1),%rax
add    $0x4060e000,%rax
test   %r12,%rax
je     11e7 <flip_A4+0xd7>
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x40201000,%edx
or     %rdx,%rbp
movabs $0x80800000000000,%rax
mov    %r15,%rcx
and    %rax,%rcx
movabs $0x7f7f800000000000,%rdx
80 7f 7f
add    %rcx,%rdx
and    %r14,%rdx
movabs $0x8080000000000000,%rcx
and    %rdx,%rcx
lea    -0x1(%rcx),%rbx
and    %rax,%rbx
test   %rcx,%rcx
cmove  %rcx,%rbx
or     %rbp,%rbx
and    $0x808080,%r14d
and    $0x80808000,%r15d
or     %r13,%r15
mov    %r14,%rax
shl    $0x8,%rax
add    %r15,%rax
test   %r12,%rax
je     1262 <flip_A4+0x152>
mov    %r14,%rdi
call   1030 <last_bit@plt>
mov    $0xfffffffffffffffe,%rdx
mov    %eax,%ecx
shl    %cl,%rdx
and    $0x80808000,%edx
or     %rdx,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @flip_A4(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, 270582939648
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, 549755813888
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 549755813888, %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, 1161928703861587968
store i64 %28, i64* %5
%29 = load i64, i64* %4
%30 = and i64 %29, 9077567998918656
%31 = or i64 %30, 1143773567863750656
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = add i64 %32, 70368744177664
%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, 9077567998918656
%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, 2101256
store i64 %46, i64* %5
%47 = load i64, i64* %4
%48 = and i64 %47, 1075843072
%49 = or i64 %48, 548679966720
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, 549755813888
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 549755813888, %61
%63 = and i64 %62, 1075843072
%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, -9187343239835811840
store i64 %68, i64* %5
%69 = load i64, i64* %4
%70 = and i64 %69, 36169534507319296
%71 = or i64 %70, 9187061764859101184
store i64 %71, i64* %6
%72 = load i64, i64* %6
%73 = add i64 %72, 140737488355328
%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, 36169534507319296
%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, 8421504
store i64 %86, i64* %5
%87 = load i64, i64* %4
%88 = and i64 %87, 2155905024
%89 = or i64 %88, 547599876096
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, 549755813888
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 549755813888, %101
%103 = and i64 %102, 2155905024
%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_A4(i64 %0, i64 %1) {
%3 = and i64 %0, 270582939648
%4 = shl nuw nsw i64 %3, 1
%5 = add i64 %4, %1
%6 = and i64 %5, 549755813888
%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, 549755813888
br label %13
13: ; preds = %8, %2
%14 = phi i64 [ %12, %8 ], [ 0, %2 ]
%15 = and i64 %0, 1161928703861587968
%16 = and i64 %1, 9077567998918656
%17 = add nuw nsw i64 %16, 1143843936607928320
%18 = and i64 %15, %17
%19 = icmp eq i64 %18, 0
%20 = add nuw nsw i64 %18, 18014398509481983
%21 = and i64 %20, 9077567998918656
%22 = select i1 %19, i64 0, i64 %21
%23 = or i64 %14, %22
%24 = and i64 %0, 2101256
%25 = and i64 %1, 1075843072
%26 = or i64 %25, 548679966720
%27 = shl nuw nsw i64 %24, 9
%28 = add nuw nsw i64 %26, %27
%29 = and i64 %28, 549755813888
%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, 1075843072
%36 = or i64 %35, %23
br label %37
37: ; preds = %31, %13
%38 = phi i64 [ %36, %31 ], [ %23, %13 ]
%39 = and i64 %0, -9187343239835811840
%40 = and i64 %1, 36169534507319296
%41 = add nuw i64 %40, 9187202502347456512
%42 = and i64 %39, %41
%43 = icmp eq i64 %42, 0
%44 = add nuw nsw i64 %42, 72057594037927935
%45 = and i64 %44, 36169534507319296
%46 = select i1 %43, i64 0, i64 %45
%47 = or i64 %38, %46
%48 = and i64 %0, 8421504
%49 = and i64 %1, 2155905024
%50 = or i64 %49, 547599876096
%51 = shl nuw nsw i64 %48, 8
%52 = add nuw nsw i64 %50, %51
%53 = and i64 %52, 549755813888
%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, 2155905024
%60 = or i64 %59, %47
br label %61
61: ; preds = %55, %37
%62 = phi i64 [ %60, %55 ], [ %47, %37 ]
ret i64 %62
}