int eval(int s) {
  const int LINES[8] = {07, 070, 0700, 0111, 0222, 0444, 0124, 0421};
  int opp = (((s) >> 18) == 0x1 ? 0x2 : 0x1);
  int m = opp == 0x1 ? ((s)&0x1ff) : ((s) >> 9 & 0x1ff);
  int i;
  for (i = 0; i < 8; i++) {
    if ((LINES[i] & m) == LINES[i])
      return opp;
  }
  if (__builtin_popcount(s) == 10)
    return 4;
  return 0;
}


x86 assembly (clang, -O0):
<eval>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    0xef2(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeef(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeec(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xee9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edx
sar    $0x12,%edx
mov    $0x1,%eax
mov    $0x2,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
jne    1166 <eval+0x66>
mov    -0x8(%rbp),%eax
and    $0x1ff,%eax
mov    %eax,-0x40(%rbp)
jmp    1174 <eval+0x74>
mov    -0x8(%rbp),%eax
sar    $0x9,%eax
and    $0x1ff,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x8,-0x3c(%rbp)
jge    11c2 <eval+0xc2>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
and    -0x38(%rbp),%eax
movslq -0x3c(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jne    11af <eval+0xaf>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1213 <eval+0x113>
jmp    11b4 <eval+0xb4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1181 <eval+0x81>
mov    -0x8(%rbp),%ecx
mov    %ecx,%eax
shr    %eax
and    $0x55555555,%eax
sub    %eax,%ecx
mov    %ecx,%eax
and    $0x33333333,%eax
shr    $0x2,%ecx
and    $0x33333333,%ecx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x4,%ecx
add    %ecx,%eax
and    $0xf0f0f0f,%eax
imul   $0x1010101,%eax,%eax
shr    $0x18,%eax
cmp    $0xa,%eax
jne    120c <eval+0x10c>
movl   $0x4,-0x4(%rbp)
jmp    1213 <eval+0x113>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval>:
mov    %edi,%ecx
and    $0xfffc0000,%ecx
mov    %edi,%edx
shr    $0x9,%edx
xor    %eax,%eax
cmp    $0x40000,%ecx
cmovne %edi,%edx
sete   %cl
movd   %edx,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xed4(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
movdqa 0xed4(%rip),%xmm3
pand   %xmm3,%xmm0
pcmpeqd %xmm3,%xmm0
pcmpeqd %xmm1,%xmm2
packssdw %xmm0,%xmm2
pmovmskb %xmm2,%edx
test   %edx,%edx
je     115a <eval+0x5a>
mov    %cl,%al
add    $0x1,%eax
ret
mov    %edi,%eax
shr    %eax
and    $0x55555555,%eax
sub    %eax,%edi
mov    %edi,%eax
and    $0x33333333,%eax
shr    $0x2,%edi
and    $0x33333333,%edi
add    %eax,%edi
mov    %edi,%eax
shr    $0x4,%eax
add    %edi,%eax
and    $0xf0f0f0f,%eax
imul   $0x1010101,%eax,%ecx
shr    $0x18,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
sete   %al
shl    $0x2,%eax
ret

LLVM IR (-O0):
@__const.eval.LINES = [8 x i32] [i32 7, i32 56, i32 448, i32 73, i32 146, i32 292, i32 84, i32 273]
define i32 @eval(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
%8 = bitcast [8 x i32]* %4 to i8*
%9 = load i32, i32* %3
%10 = ashr i32 %9, 18
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i64
%13 = select i1 %11, i32 2, i32 1
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i32, i32* %3
%18 = and i32 %17, 511
br label %23
19: ; preds = %1
%20 = load i32, i32* %3
%21 = ashr i32 %20, 9
%22 = and i32 %21, 511
br label %23
23: ; preds = %19, %16
%24 = phi i32 [ %18, %16 ], [ %22, %19 ]
store i32 %24, i32* %6
store i32 0, i32* %7
br label %25
25: ; preds = %43, %23
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 8
br i1 %27, label %28, label %46
28: ; preds = %25
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = load i32, i32* %6
%34 = and i32 %32, %33
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp eq i32 %34, %38
br i1 %39, label %40, label %42
40: ; preds = %28
%41 = load i32, i32* %5
store i32 %41, i32* %2
br label %52
42: ; preds = %28
br label %43
43: ; preds = %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %25
46: ; preds = %25
%47 = load i32, i32* %3
%48 = call i32 @llvm.ctpop.i32(i32 %47)
%49 = icmp eq i32 %48, 10
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 4, i32* %2
br label %52
51: ; preds = %46
store i32 0, i32* %2
br label %52
52: ; preds = %51, %50, %40
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
define i32 @eval(i32 %0) {
%2 = and i32 %0, -262144
%3 = icmp eq i32 %2, 262144
%4 = select i1 %3, i32 2, i32 1
%5 = lshr i32 %0, 9
%6 = select i1 %3, i32 %5, i32 %0
%7 = insertelement <8 x i32> poison, i32 %6, i64 0
%8 = shufflevector <8 x i32> %7, <8 x i32> poison, <8 x i32> zeroinitializer
%9 = and <8 x i32> %8, <i32 7, i32 56, i32 448, i32 73, i32 146, i32 292, i32 84, i32 273>
%10 = icmp eq <8 x i32> %9, <i32 7, i32 56, i32 448, i32 73, i32 146, i32 292, i32 84, i32 273>
%11 = bitcast <8 x i1> %10 to i8
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = tail call i32 @llvm.ctpop.i32(i32 %0)
%15 = icmp eq i32 %14, 10
%16 = select i1 %15, i32 4, i32 0
br label %17
17: ; preds = %1, %13
%18 = phi i32 [ %16, %13 ], [ %4, %1 ]
ret i32 %18
}