#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 */

/* Variables and functions */
int count_ones(unsigned int);
unsigned int hamming84_dec_symbol(unsigned int _r) {
  unsigned int z0 = count_ones(_r & 0xaa) % 2;
  unsigned int z1 = count_ones(_r & 0x66) % 2;
  unsigned int z2 = count_ones(_r & 0x1e) % 2;
  unsigned int z = (z0 << 0) | (z1 << 1) | (z2 << 2);
  unsigned int r_hat = _r;
  if (z) {
    r_hat ^= 1 << (8 - z);
  }
  unsigned int p0 = count_ones(r_hat & 0x20) % 2;
  unsigned int p1 = count_ones(r_hat & 0x08) % 2;
  unsigned int p2 = count_ones(r_hat & 0x04) % 2;
  unsigned int p3 = count_ones(r_hat & 0x02) % 2;
  unsigned int p = (p0 << 3) | (p1 << 2) | (p2 << 1) | (p3 << 0);
  return p;
}


x86 assembly (clang, -O0):
<hamming84_dec_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
and    $0xaa,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x4(%rbp),%edi
and    $0x66,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
and    $0x1e,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x0,%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     119e <hamming84_dec_symbol+0x8e>
mov    $0x8,%ecx
sub    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
and    $0x20,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
and    $0x8,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x18(%rbp),%edi
and    $0x4,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x18(%rbp),%edi
and    $0x2,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x3,%eax
mov    -0x20(%rbp),%ecx
shl    $0x2,%ecx
or     %ecx,%eax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%ecx
shl    $0x0,%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamming84_dec_symbol>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
and    $0xaa,%edi
call   1030 <count_ones@plt>
mov    %eax,%ebp
shr    $0x1f,%eax
add    %ebp,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebp
mov    %r14d,%edi
and    $0x66,%edi
call   1030 <count_ones@plt>
mov    %eax,%ebx
shr    $0x1f,%eax
add    %ebx,%eax
and    $0x7ffffffe,%eax
sub    %eax,%ebx
mov    %r14d,%edi
and    $0x1e,%edi
call   1030 <count_ones@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0x3ffffffe,%ecx
sub    %ecx,%eax
add    %ebx,%ebx
or     %ebp,%ebx
lea    0x0(,%rax,4),%eax
or     %ebx,%eax
mov    $0x8,%cl
sub    %al,%cl
mov    $0x1,%ebp
shl    %cl,%ebp
test   %eax,%eax
cmove  %eax,%ebp
xor    %r14d,%ebp
mov    %ebp,%edi
and    $0x20,%edi
call   1030 <count_ones@plt>
mov    %eax,%r14d
shr    $0x1f,%eax
add    %r14d,%eax
and    $0x1ffffffe,%eax
sub    %eax,%r14d
mov    %ebp,%edi
and    $0x8,%edi
call   1030 <count_ones@plt>
mov    %eax,%r15d
shr    $0x1f,%eax
add    %r15d,%eax
and    $0x3ffffffe,%eax
sub    %eax,%r15d
mov    %ebp,%edi
and    $0x4,%edi
call   1030 <count_ones@plt>
mov    %eax,%ebx
shr    $0x1f,%eax
add    %ebx,%eax
and    $0x7ffffffe,%eax
sub    %eax,%ebx
and    $0x2,%ebp
mov    %ebp,%edi
call   1030 <count_ones@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
shl    $0x3,%r14d
shl    $0x2,%r15d
or     %r14d,%r15d
add    %ebx,%ebx
or     %ebx,%eax
or     %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hamming84_dec_symbol(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %2
%13 = load i32, i32* %2
%14 = and i32 %13, 170
%15 = call i32 @count_ones(i32 %14)
%16 = srem i32 %15, 2
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = and i32 %17, 102
%19 = call i32 @count_ones(i32 %18)
%20 = srem i32 %19, 2
store i32 %20, i32* %4
%21 = load i32, i32* %2
%22 = and i32 %21, 30
%23 = call i32 @count_ones(i32 %22)
%24 = srem i32 %23, 2
store i32 %24, i32* %5
%25 = load i32, i32* %3
%26 = shl i32 %25, 0
%27 = load i32, i32* %4
%28 = shl i32 %27, 1
%29 = or i32 %26, %28
%30 = load i32, i32* %5
%31 = shl i32 %30, 2
%32 = or i32 %29, %31
store i32 %32, i32* %6
%33 = load i32, i32* %2
store i32 %33, i32* %7
%34 = load i32, i32* %6
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %1
%37 = load i32, i32* %6
%38 = sub i32 8, %37
%39 = shl i32 1, %38
%40 = load i32, i32* %7
%41 = xor i32 %40, %39
store i32 %41, i32* %7
br label %42
42: ; preds = %36, %1
%43 = load i32, i32* %7
%44 = and i32 %43, 32
%45 = call i32 @count_ones(i32 %44)
%46 = srem i32 %45, 2
store i32 %46, i32* %8
%47 = load i32, i32* %7
%48 = and i32 %47, 8
%49 = call i32 @count_ones(i32 %48)
%50 = srem i32 %49, 2
store i32 %50, i32* %9
%51 = load i32, i32* %7
%52 = and i32 %51, 4
%53 = call i32 @count_ones(i32 %52)
%54 = srem i32 %53, 2
store i32 %54, i32* %10
%55 = load i32, i32* %7
%56 = and i32 %55, 2
%57 = call i32 @count_ones(i32 %56)
%58 = srem i32 %57, 2
store i32 %58, i32* %11
%59 = load i32, i32* %8
%60 = shl i32 %59, 3
%61 = load i32, i32* %9
%62 = shl i32 %61, 2
%63 = or i32 %60, %62
%64 = load i32, i32* %10
%65 = shl i32 %64, 1
%66 = or i32 %63, %65
%67 = load i32, i32* %11
%68 = shl i32 %67, 0
%69 = or i32 %66, %68
store i32 %69, i32* %12
%70 = load i32, i32* %12
ret i32 %70
}

LLVM IR (-O2):
define i32 @hamming84_dec_symbol(i32 %0) {
%2 = and i32 %0, 170
%3 = tail call i32 @count_ones(i32 %2)
%4 = srem i32 %3, 2
%5 = and i32 %0, 102
%6 = tail call i32 @count_ones(i32 %5)
%7 = srem i32 %6, 2
%8 = and i32 %0, 30
%9 = tail call i32 @count_ones(i32 %8)
%10 = srem i32 %9, 2
%11 = shl nsw i32 %7, 1
%12 = or i32 %11, %4
%13 = shl nsw i32 %10, 2
%14 = or i32 %12, %13
%15 = icmp eq i32 %14, 0
%16 = sub nsw i32 8, %14
%17 = shl nuw i32 1, %16
%18 = select i1 %15, i32 0, i32 %17
%19 = xor i32 %18, %0
%20 = and i32 %19, 32
%21 = tail call i32 @count_ones(i32 %20)
%22 = srem i32 %21, 2
%23 = and i32 %19, 8
%24 = tail call i32 @count_ones(i32 %23)
%25 = srem i32 %24, 2
%26 = and i32 %19, 4
%27 = tail call i32 @count_ones(i32 %26)
%28 = srem i32 %27, 2
%29 = and i32 %19, 2
%30 = tail call i32 @count_ones(i32 %29)
%31 = srem i32 %30, 2
%32 = shl nsw i32 %22, 3
%33 = shl nsw i32 %25, 2
%34 = or i32 %33, %32
%35 = shl nsw i32 %28, 1
%36 = or i32 %34, %35
%37 = or i32 %36, %31
ret i32 %37
}