#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 get_parity(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long, int, int);
int main() {
  int result = 0;
  unsigned long test1 = 0b11110000111;
  unsigned long test2 = 0b111100001111;
  unsigned long test3 = 0;
  unsigned long test4 = 0xffffffff;
  result = get_parity(test1);
  printf("Parity for test1: %ld is %d with bits %d\n", test1, result % 2,
         result);
  result = get_parity(test2);
  printf("Parity for test1: %ld is %d with bits %d\n", test2, result % 2,
         result);
  result = get_parity(test3);
  printf("Parity for test1: %ld is %d with bits %d\n", test3, result % 2,
         result);
  result = get_parity(test4);
  printf("Parity for test1: %lx is %d with bits %d\n", test4, result % 2,
         result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x787,-0x10(%rbp)
movq   $0xf0f,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0xffffffff,%eax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <get_parity@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%ecx
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <get_parity@plt>
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%ecx
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <get_parity@plt>
mov    %eax,-0x8(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%ecx
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <get_parity@plt>
mov    %eax,-0x8(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%ecx
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x787,%edi
call   1040 <get_parity@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
mov    %eax,%edx
sub    %ecx,%edx
lea    0xec0(%rip),%rbx
mov    $0x787,%esi
mov    %rbx,%rdi
mov    %eax,%ecx
call   1030 <printf@plt>
mov    $0xf0f,%edi
call   1040 <get_parity@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
mov    %eax,%edx
sub    %ecx,%edx
mov    $0xf0f,%esi
mov    %rbx,%rdi
mov    %eax,%ecx
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <get_parity@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
mov    %eax,%edx
sub    %ecx,%edx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%ecx
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <get_parity@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
mov    %eax,%edx
sub    %ecx,%edx
lea    0xe74(%rip),%rdi
mov    $0xffffffff,%esi
mov    %eax,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Parity for test1: %ld is %d with bits %d\0A\00"
@.str.1 = [42 x i8] c"Parity for test1: %lx is %d with bits %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
store i64 1927, i64* %3
store i64 3855, i64* %4
store i64 0, i64* %5
store i64 4294967295, i64* %6
%7 = load i64, i64* %3
%8 = call i32 @get_parity(i64 %7)
store i32 %8, i32* %2
%9 = load i64, i64* %3
%10 = load i32, i32* %2
%11 = srem i32 %10, 2
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %9, i32 %11, i32 %12)
%14 = load i64, i64* %4
%15 = call i32 @get_parity(i64 %14)
store i32 %15, i32* %2
%16 = load i64, i64* %4
%17 = load i32, i32* %2
%18 = srem i32 %17, 2
%19 = load i32, i32* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %16, i32 %18, i32 %19)
%21 = load i64, i64* %5
%22 = call i32 @get_parity(i64 %21)
store i32 %22, i32* %2
%23 = load i64, i64* %5
%24 = load i32, i32* %2
%25 = srem i32 %24, 2
%26 = load i32, i32* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %23, i32 %25, i32 %26)
%28 = load i64, i64* %6
%29 = call i32 @get_parity(i64 %28)
store i32 %29, i32* %2
%30 = load i64, i64* %6
%31 = load i32, i32* %2
%32 = srem i32 %31, 2
%33 = load i32, i32* %2
%34 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i64 %30, i32 %32, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Parity for test1: %ld is %d with bits %d\0A\00"
@.str.1 = [42 x i8] c"Parity for test1: %lx is %d with bits %d\0A\00"
define i32 @main() {
%1 = tail call i32 @get_parity(i64 1927)
%2 = srem i32 %1, 2
%3 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 1927, i32 %2, i32 %1)
%4 = tail call i32 @get_parity(i64 3855)
%5 = srem i32 %4, 2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 3855, i32 %5, i32 %4)
%7 = tail call i32 @get_parity(i64 0)
%8 = srem i32 %7, 2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 0, i32 %8, i32 %7)
%10 = tail call i32 @get_parity(i64 4294967295)
%11 = srem i32 %10, 2
%12 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i64 4294967295, i32 %11, i32 %10)
ret i32 0
}