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

/* Variables and functions */
uint8_t get_parity(uint32_t instr) {
  uint8_t alias[] = {3,  5,  6,  7,  9,  10, 11, 12, 13, 14, 15,
                     17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
                     28, 29, 30, 31, 33, 34, 35, 36, 37, 38};
  int i;
  int temp;
  uint8_t parity;
  parity = 0x0;
  for (i = 0; i < 32; i++) {
    if (instr & (1 << i))
      parity = parity ^ alias[i];
  }
  return parity;
}


x86 assembly (clang, -O0):
<get_parity>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xed4(%rip),%rsi
mov    $0x80,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x9c(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x20,-0x94(%rbp)
jge    11a7 <get_parity+0x97>
mov    -0x4(%rbp),%eax
mov    -0x94(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     118e <get_parity+0x7e>
mov    -0x9c(%rbp),%eax
movslq -0x94(%rbp),%rcx
xor    -0x90(%rbp,%rcx,4),%eax
mov    %eax,-0x9c(%rbp)
jmp    1193 <get_parity+0x83>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    114a <get_parity+0x3a>
mov    -0x9c(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_parity>:
xor    %edx,%edx
lea    0xef7(%rip),%rcx
xor    %eax,%eax
jmp    111d <get_parity+0x1d>
nopl   (%rax)
add    $0x1,%rsi
mov    %rsi,%rdx
cmp    $0x20,%rsi
je     1134 <get_parity+0x34>
bt     %edx,%edi
jae    1125 <get_parity+0x25>
xor    (%rcx,%rdx,4),%eax
lea    0x1(%rdx),%rsi
bt     %esi,%edi
jae    1110 <get_parity+0x10>
xor    0x4(%rcx,%rdx,4),%eax
jmp    1110 <get_parity+0x10>
ret

LLVM IR (-O0):
@__const.get_parity.alias = [32 x i32] [i32 3, i32 5, i32 6, i32 7, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38]
define i32 @get_parity(i32 %0) {
%2 = alloca i32
%3 = alloca [32 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = bitcast [32 x i32]* %3 to i8*
store i32 0, i32* %6
store i32 0, i32* %4
br label %8
8: ; preds = %25, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = shl i32 1, %13
%15 = and i32 %12, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = xor i32 %18, %22
store i32 %23, i32* %6
br label %24
24: ; preds = %17, %11
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %8
28: ; preds = %8
%29 = load i32, i32* %6
ret i32 %29
}

LLVM IR (-O2):
@__const.get_parity.alias = [32 x i32] [i32 3, i32 5, i32 6, i32 7, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38]
define i32 @get_parity(i32 %0) {
br label %2
2: ; preds = %24, %1
%3 = phi i64 [ 0, %1 ], [ %26, %24 ]
%4 = phi i32 [ 0, %1 ], [ %25, %24 ]
%5 = trunc i64 %3 to i32
%6 = shl nuw i32 1, %5
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = getelementptr inbounds [32 x i32], [32 x i32]* @__const.get_parity.alias, i64 0, i64 %3
%11 = load i32, i32* %10
%12 = xor i32 %11, %4
br label %13
13: ; preds = %2, %9
%14 = phi i32 [ %12, %9 ], [ %4, %2 ]
%15 = or i64 %3, 1
%16 = trunc i64 %15 to i32
%17 = shl nuw i32 1, %16
%18 = and i32 %17, %0
%19 = icmp eq i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %13
%21 = getelementptr inbounds [32 x i32], [32 x i32]* @__const.get_parity.alias, i64 0, i64 %15
%22 = load i32, i32* %21
%23 = xor i32 %22, %14
br label %24
24: ; preds = %20, %13
%25 = phi i32 [ %23, %20 ], [ %14, %13 ]
%26 = add nuw nsw i64 %3, 2
%27 = icmp eq i64 %26, 32
br i1 %27, label %28, label %2
28: ; preds = %24
ret i32 %25
}