int eval(int piece_num[15]) {
  int w[14] = {2048,  512,  128,  32,  8,  128,  1,
               -2048, -512, -128, -32, -8, -128, -1};
  int i, score = 0;
  for (i = 0; i < 14; i++)
    score += w[i] * piece_num[i];
  return score;
}


x86 assembly (clang, -O0):
<eval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x38,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0xe,-0x44(%rbp)
jge    1171 <eval+0x61>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x44(%rbp),%rdx
imul   (%rcx,%rdx,4),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    113f <eval+0x2f>
mov    -0x48(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval>:
mov    (%rdi),%eax
mov    0x4(%rdi),%edx
shl    $0xb,%eax
shl    $0x9,%edx
movdqu 0x8(%rdi),%xmm0
movdqa 0xee8(%rip),%xmm1
pmuludq %xmm0,%xmm1
pshufd $0xf5,%xmm0,%xmm0
pmuludq 0xee7(%rip),%xmm0
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%ecx
add    %edx,%ecx
add    %eax,%ecx
add    0x18(%rdi),%ecx
mov    0x1c(%rdi),%edx
shl    $0xb,%edx
mov    0x20(%rdi),%esi
shl    $0x9,%esi
movdqu 0x24(%rdi),%xmm0
movdqa 0xeb3(%rip),%xmm1
pmuludq %xmm0,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm0
pmuludq 0xead(%rip),%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%eax
sub    %esi,%eax
sub    %edx,%eax
add    %ecx,%eax
sub    0x34(%rdi),%eax
ret

LLVM IR (-O0):
@__const.eval.w = [14 x i32] [i32 2048, i32 512, i32 128, i32 32, i32 8, i32 128, i32 1, i32 -2048, i32 -512, i32 -128, i32 -32, i32 -8, i32 -128, i32 -1]
define i32 @eval(i32* %0) {
%2 = alloca i32*
%3 = alloca [14 x i32]
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = bitcast [14 x i32]* %3 to i8*
store i32 0, i32* %5
store i32 0, i32* %4
br label %7
7: ; preds = %23, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 14
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [14 x i32], [14 x i32]* %3, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = load i32*, i32** %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = mul nsw i32 %14, %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, %20
store i32 %22, i32* %5
br label %23
23: ; preds = %10
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %7
26: ; preds = %7
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
define i32 @eval(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = shl nsw i32 %2, 11
%4 = getelementptr inbounds i32, i32* %0, i64 1
%5 = load i32, i32* %4
%6 = shl nsw i32 %5, 9
%7 = getelementptr inbounds i32, i32* %0, i64 2
%8 = bitcast i32* %7 to <4 x i32>*
%9 = load <4 x i32>, <4 x i32>* %8
%10 = shl nsw <4 x i32> %9, <i32 7, i32 5, i32 3, i32 7>
%11 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %10)
%12 = add nsw i32 %11, %6
%13 = add nsw i32 %12, %3
%14 = getelementptr inbounds i32, i32* %0, i64 6
%15 = load i32, i32* %14
%16 = add nsw i32 %15, %13
%17 = getelementptr inbounds i32, i32* %0, i64 7
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, -2048
%20 = getelementptr inbounds i32, i32* %0, i64 8
%21 = load i32, i32* %20
%22 = mul nsw i32 %21, -512
%23 = getelementptr inbounds i32, i32* %0, i64 9
%24 = bitcast i32* %23 to <4 x i32>*
%25 = load <4 x i32>, <4 x i32>* %24
%26 = mul nsw <4 x i32> %25, <i32 -128, i32 -32, i32 -8, i32 -128>
%27 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %26)
%28 = add nsw i32 %27, %22
%29 = add nsw i32 %28, %19
%30 = add nsw i32 %29, %16
%31 = getelementptr inbounds i32, i32* %0, i64 13
%32 = load i32, i32* %31
%33 = sub i32 %30, %32
ret i32 %33
}