#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 uint64_t;

/* Variables and functions */
int parity(uint64_t x) {
  x = (x & 0x5555555555555555) ^ ((x >> 1) & 0x5555555555555555);
  x = (x & 0x3333333333333333) ^ ((x >> 2) & 0x3333333333333333);
  x = (x & 0x0f0f0f0f0f0f0f0f) ^ ((x >> 4) & 0x0f0f0f0f0f0f0f0f);
  x = (x & 0x00ff00ff00ff00ff) ^ ((x >> 8) & 0x00ff00ff00ff00ff);
  x = (x & 0x0000ffff0000ffff) ^ ((x >> 16) & 0x0000ffff0000ffff);
  x = (x & 0x00000000ffffffff) ^ ((x >> 32) & 0x00000000ffffffff);
  return (int)x;
}


x86 assembly (clang, -O0):
<parity>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0x5555555555555555,%rcx
55 55 55
and    %rcx,%rax
mov    -0x4(%rbp),%ecx
sar    $0x1,%ecx
movslq %ecx,%rcx
movabs $0x5555555555555555,%rdx
55 55 55
and    %rdx,%rcx
xor    %rcx,%rax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0x3333333333333333,%rcx
33 33 33
and    %rcx,%rax
mov    -0x4(%rbp),%ecx
sar    $0x2,%ecx
movslq %ecx,%rcx
movabs $0x3333333333333333,%rdx
33 33 33
and    %rdx,%rcx
xor    %rcx,%rax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0xf0f0f0f0f0f0f0f,%rcx
0f 0f 0f
and    %rcx,%rax
mov    -0x4(%rbp),%ecx
sar    $0x4,%ecx
movslq %ecx,%rcx
movabs $0xf0f0f0f0f0f0f0f,%rdx
0f 0f 0f
and    %rdx,%rcx
xor    %rcx,%rax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0xff00ff00ff00ff,%rcx
and    %rcx,%rax
mov    -0x4(%rbp),%ecx
sar    $0x8,%ecx
movslq %ecx,%rcx
movabs $0xff00ff00ff00ff,%rdx
and    %rdx,%rcx
xor    %rcx,%rax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0xffff0000ffff,%rcx
and    %rcx,%rax
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
movslq %ecx,%rcx
movabs $0xffff0000ffff,%rdx
and    %rdx,%rcx
xor    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffffffff,%eax
mov    -0x4(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0xffffffff,%ecx
xor    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<parity>:
ret

LLVM IR (-O0):
define i32 @parity(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = and i64 %4, 6148914691236517205
%6 = load i32, i32* %2
%7 = ashr i32 %6, 1
%8 = sext i32 %7 to i64
%9 = and i64 %8, 6148914691236517205
%10 = xor i64 %5, %9
%11 = trunc i64 %10 to i32
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = and i64 %13, 3689348814741910323
%15 = load i32, i32* %2
%16 = ashr i32 %15, 2
%17 = sext i32 %16 to i64
%18 = and i64 %17, 3689348814741910323
%19 = xor i64 %14, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = and i64 %22, 1085102592571150095
%24 = load i32, i32* %2
%25 = ashr i32 %24, 4
%26 = sext i32 %25 to i64
%27 = and i64 %26, 1085102592571150095
%28 = xor i64 %23, %27
%29 = trunc i64 %28 to i32
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = and i64 %31, 71777214294589695
%33 = load i32, i32* %2
%34 = ashr i32 %33, 8
%35 = sext i32 %34 to i64
%36 = and i64 %35, 71777214294589695
%37 = xor i64 %32, %36
%38 = trunc i64 %37 to i32
store i32 %38, i32* %2
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = and i64 %40, 281470681808895
%42 = load i32, i32* %2
%43 = ashr i32 %42, 16
%44 = sext i32 %43 to i64
%45 = and i64 %44, 281470681808895
%46 = xor i64 %41, %45
%47 = trunc i64 %46 to i32
store i32 %47, i32* %2
%48 = load i32, i32* %2
%49 = and i32 %48, -1
%50 = load i32, i32* %2
%51 = ashr i32 %50, 32
%52 = and i32 %51, -1
%53 = xor i32 %49, %52
store i32 %53, i32* %2
%54 = load i32, i32* %2
ret i32 %54
}

LLVM IR (-O2):
define i32 @parity(i32 %0) {
ret i32 poison
}