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

/* Variables and functions */
uint8_t parity(uint8_t d) {
  d &= 0x7f;
  uint8_t p = 1;
  uint8_t t = d;
  int i;
  for (i = 0; i < 7; i++) {
    p += t & 1;
    t = t >> 1;
  }
  p &= 1;
  return d | (p << 7);
}


x86 assembly (clang, -O0):
<parity>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x7,-0x10(%rbp)
jge    1151 <parity+0x51>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1124 <parity+0x24>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x7,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<parity>:
mov    %edi,%ecx
and    $0x7f,%ecx
mov    %edi,%eax
and    $0x1,%eax
mov    %edi,%edx
shr    %edx
and    $0x1,%edx
add    %eax,%edx
mov    %edi,%eax
shr    $0x2,%eax
and    $0x1,%eax
add    %edx,%eax
mov    %edi,%edx
shr    $0x3,%edx
and    $0x1,%edx
add    %eax,%edx
mov    %ecx,%eax
shr    $0x4,%eax
add    %edx,%eax
mov    %edi,%edx
shr    $0x5,%edx
add    %eax,%edx
shr    $0x6,%edi
add    %edx,%edi
shl    $0x7,%edi
sub    $0xffffff80,%edi
movzbl %dil,%eax
or     %ecx,%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
%6 = load i32, i32* %2
%7 = and i32 %6, 127
store i32 %7, i32* %2
store i32 1, i32* %3
%8 = load i32, i32* %2
store i32 %8, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %19, %1
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 7
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32, i32* %4
%14 = and i32 %13, 1
%15 = load i32, i32* %3
%16 = add nsw i32 %15, %14
store i32 %16, i32* %3
%17 = load i32, i32* %4
%18 = ashr i32 %17, 1
store i32 %18, i32* %4
br label %19
19: ; preds = %12
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %9
22: ; preds = %9
%23 = load i32, i32* %3
%24 = and i32 %23, 1
store i32 %24, i32* %3
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = shl i32 %26, 7
%28 = or i32 %25, %27
ret i32 %28
}

LLVM IR (-O2):
define i32 @parity(i32 %0) {
%2 = and i32 %0, 127
%3 = and i32 %0, 1
%4 = add nuw nsw i32 %3, 1
%5 = lshr i32 %0, 1
%6 = and i32 %5, 1
%7 = add nuw nsw i32 %6, %4
%8 = lshr i32 %0, 2
%9 = and i32 %8, 1
%10 = add nuw nsw i32 %9, %7
%11 = lshr i32 %0, 3
%12 = and i32 %11, 1
%13 = add nuw nsw i32 %12, %10
%14 = lshr i32 %2, 4
%15 = add nuw nsw i32 %14, %13
%16 = lshr i32 %0, 5
%17 = add nuw nsw i32 %16, %15
%18 = lshr i32 %0, 6
%19 = add nuw nsw i32 %18, %17
%20 = shl i32 %19, 7
%21 = and i32 %20, 128
%22 = or i32 %21, %2
ret i32 %22
}