#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 */
typedef int uint8_t;
typedef int uint16_t;

/* Variables and functions */
uint8_t parity(uint16_t p) {
  uint8_t amt = 0;
  uint16_t o = 1;
  for (int i = 0; i < 16; ++i) {
    if (p & (o << i))
      ++amt;
  }
  return (amt % 2 == 1);
}


x86 assembly (clang, -O0):
<parity>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    115a <parity+0x5a>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1147 <parity+0x47>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114c <parity+0x4c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    111c <parity+0x1c>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<parity>:
mov    %edi,%eax
and    $0x1,%eax
mov    %edi,%ecx
shr    %ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0x2,%eax
and    $0x1,%eax
add    %ecx,%eax
mov    %edi,%ecx
shr    $0x3,%ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0x4,%eax
and    $0x1,%eax
add    %ecx,%eax
mov    %edi,%ecx
shr    $0x5,%ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0x6,%eax
and    $0x1,%eax
add    %ecx,%eax
mov    %edi,%ecx
shr    $0x7,%ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0x8,%eax
and    $0x1,%eax
add    %ecx,%eax
mov    %edi,%ecx
shr    $0x9,%ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0xa,%eax
and    $0x1,%eax
add    %ecx,%eax
mov    %edi,%ecx
shr    $0xb,%ecx
and    $0x1,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0xc,%eax
add    %ecx,%eax
mov    %edi,%ecx
shr    $0xd,%ecx
add    %eax,%ecx
mov    %edi,%eax
shr    $0xe,%eax
add    %ecx,%eax
shr    $0xf,%edi
add    %edi,%eax
and    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @parity(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %20, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = shl i32 %11, %12
%14 = and i32 %10, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %6
23: ; preds = %6
%24 = load i32, i32* %3
%25 = srem i32 %24, 2
%26 = icmp eq i32 %25, 1
%27 = zext i1 %26 to i32
ret i32 %27
}

LLVM IR (-O2):
define i32 @parity(i32 %0) {
%2 = and i32 %0, 1
%3 = lshr i32 %0, 1
%4 = and i32 %3, 1
%5 = add nuw nsw i32 %4, %2
%6 = lshr i32 %0, 2
%7 = and i32 %6, 1
%8 = add nuw nsw i32 %7, %5
%9 = lshr i32 %0, 3
%10 = and i32 %9, 1
%11 = add nuw nsw i32 %10, %8
%12 = lshr i32 %0, 4
%13 = and i32 %12, 1
%14 = add nuw nsw i32 %13, %11
%15 = lshr i32 %0, 5
%16 = and i32 %15, 1
%17 = add nuw nsw i32 %16, %14
%18 = lshr i32 %0, 6
%19 = and i32 %18, 1
%20 = add nuw nsw i32 %19, %17
%21 = lshr i32 %0, 7
%22 = and i32 %21, 1
%23 = add nuw nsw i32 %22, %20
%24 = lshr i32 %0, 8
%25 = and i32 %24, 1
%26 = add nuw nsw i32 %25, %23
%27 = lshr i32 %0, 9
%28 = and i32 %27, 1
%29 = add nuw nsw i32 %28, %26
%30 = lshr i32 %0, 10
%31 = and i32 %30, 1
%32 = add nuw nsw i32 %31, %29
%33 = lshr i32 %0, 11
%34 = and i32 %33, 1
%35 = add nuw nsw i32 %34, %32
%36 = lshr i32 %0, 12
%37 = add nuw nsw i32 %36, %35
%38 = lshr i32 %0, 13
%39 = add nuw nsw i32 %38, %37
%40 = lshr i32 %0, 14
%41 = add nuw nsw i32 %40, %39
%42 = lshr i32 %0, 15
%43 = add nuw nsw i32 %42, %41
%44 = and i32 %43, 1
ret i32 %44
}