int parity6(unsigned *array, int len) {
  int i, j, val, result = 0;
  unsigned x;
  for (i = 0; i < len; i++) {
    x = array[i];
    asm("mov         %[x], %%edx     \n\t"
        "shr           $8, %%edx     \n\t"
        "xor        %%edx, %[x]      \n\t"
        "setnp        %%dl           \n\t"
        "shr           $8, %%edx     \n\t"
        "xor        %%edx, %[x]      \n\t"
        "setnp        %%dl           \n\t"
        "shr           $8, %%edx     \n\t"
        "xor        %%edx, %[x]      \n\t"
        "setnp        %%dl           \n\t"
        "shr           $8, %%edx     \n\t"
        "xor        %%edx, %[x]      \n\t"
        "setnp        %%dl           \n\t"
        "movzx       %%dl, %[x]      \n\t"
        : [x] "+r"(x)
        :
        : "edx");
    result += x;
  }
  return result;
}


x86 assembly (clang, -O0):
<parity6>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1175 <parity6+0x75>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,%edx
shr    $0x8,%edx
xor    %edx,%eax
setnp  %dl
shr    $0x8,%edx
xor    %edx,%eax
setnp  %dl
shr    $0x8,%edx
xor    %edx,%eax
setnp  %dl
shr    $0x8,%edx
xor    %edx,%eax
setnp  %dl
movzbl %dl,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1119 <parity6+0x19>
mov    -0x1c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<parity6>:
test   %esi,%esi
jle    1144 <parity6+0x44>
mov    %esi,%r8d
xor    %esi,%esi
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
mov    (%rdi,%rsi,4),%ecx
mov    %ecx,%edx
shr    $0x8,%edx
xor    %edx,%ecx
setnp  %dl
shr    $0x8,%edx
xor    %edx,%ecx
setnp  %dl
shr    $0x8,%edx
xor    %edx,%ecx
setnp  %dl
shr    $0x8,%edx
xor    %edx,%ecx
setnp  %dl
movzbl %dl,%ecx
add    %ecx,%eax
add    $0x1,%rsi
cmp    %rsi,%r8
jne    1110 <parity6+0x10>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @parity6(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %8
store i32 0, i32* %5
br label %10
10: ; preds = %25, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load i32*, i32** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = call i32 asm "mov $0, %edx \0A\09shr $$8, %edx \0A\09xor %edx, $0 \0A\09setnp %dl \0A\09shr $$8, %edx \0A\09xor %edx, $0 \0A\09setnp %dl \0A\09shr $$8, %edx \0A\09xor %edx, $0 \0A\09setnp %dl \0A\09shr $$8, %edx \0A\09xor %edx, $0 \0A\09setnp %dl \0A\09movzx %dl, $0 \0A\09", "=r,0,~{edx},~{dirflag},~{fpsr},~{flags}"(i32 %20)
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = load i32, i32* %8
%24 = add i32 %23, %22
store i32 %24, i32* %8
br label %25
25: ; preds = %14
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %10
28: ; preds = %10
%29 = load i32, i32* %8
ret i32 %29
}

LLVM IR (-O2):
define i32 @parity6(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %13, %6 ]
%8 = phi i32 [ 0, %4 ], [ %12, %6 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %7
%10 = load i32, i32* %9
%11 = tail call i32 asm "mov $0, %edx \0A\09shr $$8, %edx \0A\09xor %edx, $0 \0A\09setnp %dl \0A\09shr $$8, %edx \0A\09xor %edx, $0 \0A\09setnp %dl \0A\09shr $$8, %edx \0A\09xor %edx, $0 \0A\09setnp %dl \0A\09shr $$8, %edx \0A\09xor %edx, $0 \0A\09setnp %dl \0A\09movzx %dl, $0 \0A\09", "=r,0,~{edx},~{dirflag},~{fpsr},~{flags}"(i32 %10)
%12 = add i32 %11, %8
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %15, label %6
15: ; preds = %6, %2
%16 = phi i32 [ 0, %2 ], [ %12, %6 ]
ret i32 %16
}