#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_enc_symbol(unsigned int _p) {
  unsigned int x0 = count_ones(_p & 0x0d) % 2;
  unsigned int x1 = count_ones(_p & 0x0b) % 2;
  unsigned int x2 = count_ones(_p & 0x08) % 2;
  unsigned int x3 = count_ones(_p & 0x07) % 2;
  unsigned int x4 = count_ones(_p & 0x04) % 2;
  unsigned int x5 = count_ones(_p & 0x02) % 2;
  unsigned int x6 = count_ones(_p & 0x01) % 2;
  unsigned int x7 = count_ones(_p & 0x0e) % 2;
  unsigned int x = (x0 << 7) | (x1 << 6) | (x2 << 5) | (x3 << 4) | (x4 << 3) |
                   (x5 << 2) | (x6 << 1) | (x7);
  return x;
}


x86 assembly (clang, -O0):
<hamming84_enc_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
and    $0xd,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x4(%rbp),%edi
and    $0xb,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
and    $0x8,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
and    $0x7,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
and    $0x4,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
and    $0x2,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
and    $0x1,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x4(%rbp),%edi
and    $0xe,%edi
call   1030 <count_ones@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x7,%eax
mov    -0xc(%rbp),%ecx
shl    $0x6,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%ecx
shl    $0x5,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%ecx
shl    $0x3,%ecx
or     %ecx,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
or     %ecx,%eax
mov    -0x20(%rbp),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamming84_enc_symbol>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r15d
and    $0xd,%edi
call   1030 <count_ones@plt>
mov    %eax,%r14d
mov    %r15d,%edi
and    $0xb,%edi
call   1030 <count_ones@plt>
mov    %eax,%ebp
mov    %r15d,%edi
and    $0x8,%edi
call   1030 <count_ones@plt>
mov    %eax,%ebx
mov    %r15d,%edi
and    $0x7,%edi
call   1030 <count_ones@plt>
movd   %r14d,%xmm0
movd   %ebp,%xmm2
punpckldq %xmm0,%xmm2
movd   %ebx,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
punpcklqdq %xmm0,%xmm2
movdqa %xmm2,%xmm0
psrld  $0x1f,%xmm0
paddd  %xmm2,%xmm0
psrad  $0x1,%xmm0
paddd  %xmm0,%xmm0
psubd  %xmm0,%xmm2
movdqa %xmm2,(%rsp)
mov    %r15d,%edi
and    $0x4,%edi
call   1030 <count_ones@plt>
mov    %eax,%r14d
shr    $0x1f,%eax
add    %r14d,%eax
and    $0x1ffffffe,%eax
sub    %eax,%r14d
mov    %r15d,%edi
and    $0x2,%edi
call   1030 <count_ones@plt>
mov    %eax,%ebp
shr    $0x1f,%eax
add    %ebp,%eax
and    $0x3ffffffe,%eax
sub    %eax,%ebp
mov    %r15d,%edi
and    $0x1,%edi
call   1030 <count_ones@plt>
mov    %eax,%ebx
shr    $0x1f,%eax
add    %ebx,%eax
and    $0x7ffffffe,%eax
sub    %eax,%ebx
and    $0xe,%r15d
mov    %r15d,%edi
call   1030 <count_ones@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
movdqa (%rsp),%xmm1
pshufd $0xf5,%xmm1,%xmm0
pmuludq 0xdff(%rip),%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq 0xe02(%rip),%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
shl    $0x3,%r14d
shl    $0x2,%ebp
or     %r14d,%ebp
add    %ebx,%ebx
or     %ebp,%ebx
or     %ebx,%eax
pshufd $0xee,%xmm1,%xmm0
por    %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
por    %xmm0,%xmm1
movd   %xmm1,%ecx
or     %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hamming84_enc_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
store i32 %0, i32* %2
%12 = load i32, i32* %2
%13 = and i32 %12, 13
%14 = call i32 @count_ones(i32 %13)
%15 = srem i32 %14, 2
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = and i32 %16, 11
%18 = call i32 @count_ones(i32 %17)
%19 = srem i32 %18, 2
store i32 %19, i32* %4
%20 = load i32, i32* %2
%21 = and i32 %20, 8
%22 = call i32 @count_ones(i32 %21)
%23 = srem i32 %22, 2
store i32 %23, i32* %5
%24 = load i32, i32* %2
%25 = and i32 %24, 7
%26 = call i32 @count_ones(i32 %25)
%27 = srem i32 %26, 2
store i32 %27, i32* %6
%28 = load i32, i32* %2
%29 = and i32 %28, 4
%30 = call i32 @count_ones(i32 %29)
%31 = srem i32 %30, 2
store i32 %31, i32* %7
%32 = load i32, i32* %2
%33 = and i32 %32, 2
%34 = call i32 @count_ones(i32 %33)
%35 = srem i32 %34, 2
store i32 %35, i32* %8
%36 = load i32, i32* %2
%37 = and i32 %36, 1
%38 = call i32 @count_ones(i32 %37)
%39 = srem i32 %38, 2
store i32 %39, i32* %9
%40 = load i32, i32* %2
%41 = and i32 %40, 14
%42 = call i32 @count_ones(i32 %41)
%43 = srem i32 %42, 2
store i32 %43, i32* %10
%44 = load i32, i32* %3
%45 = shl i32 %44, 7
%46 = load i32, i32* %4
%47 = shl i32 %46, 6
%48 = or i32 %45, %47
%49 = load i32, i32* %5
%50 = shl i32 %49, 5
%51 = or i32 %48, %50
%52 = load i32, i32* %6
%53 = shl i32 %52, 4
%54 = or i32 %51, %53
%55 = load i32, i32* %7
%56 = shl i32 %55, 3
%57 = or i32 %54, %56
%58 = load i32, i32* %8
%59 = shl i32 %58, 2
%60 = or i32 %57, %59
%61 = load i32, i32* %9
%62 = shl i32 %61, 1
%63 = or i32 %60, %62
%64 = load i32, i32* %10
%65 = or i32 %63, %64
store i32 %65, i32* %11
%66 = load i32, i32* %11
ret i32 %66
}

LLVM IR (-O2):
define i32 @hamming84_enc_symbol(i32 %0) {
%2 = and i32 %0, 13
%3 = tail call i32 @count_ones(i32 %2)
%4 = and i32 %0, 11
%5 = tail call i32 @count_ones(i32 %4)
%6 = and i32 %0, 8
%7 = tail call i32 @count_ones(i32 %6)
%8 = and i32 %0, 7
%9 = tail call i32 @count_ones(i32 %8)
%10 = insertelement <4 x i32> poison, i32 %5, i64 0
%11 = insertelement <4 x i32> %10, i32 %3, i64 1
%12 = insertelement <4 x i32> %11, i32 %7, i64 2
%13 = insertelement <4 x i32> %12, i32 %9, i64 3
%14 = srem <4 x i32> %13, <i32 2, i32 2, i32 2, i32 2>
%15 = and i32 %0, 4
%16 = tail call i32 @count_ones(i32 %15)
%17 = srem i32 %16, 2
%18 = and i32 %0, 2
%19 = tail call i32 @count_ones(i32 %18)
%20 = srem i32 %19, 2
%21 = and i32 %0, 1
%22 = tail call i32 @count_ones(i32 %21)
%23 = srem i32 %22, 2
%24 = and i32 %0, 14
%25 = tail call i32 @count_ones(i32 %24)
%26 = srem i32 %25, 2
%27 = shl nsw <4 x i32> %14, <i32 6, i32 7, i32 5, i32 4>
%28 = shl nsw i32 %17, 3
%29 = shl nsw i32 %20, 2
%30 = shl nsw i32 %23, 1
%31 = call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %27)
%32 = or i32 %31, %28
%33 = or i32 %32, %29
%34 = or i32 %33, %30
%35 = or i32 %34, %26
ret i32 %35
}