#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 */
scalar_t__ even_ones(int);
int /*<<< orphan*/ getchar();
scalar_t__ odd_ones(int);
scalar_t__ printf(char *);
int main(void) {
  int test_hex_0 = 0x10010001;
  (odd_ones(test_hex_0)) && (printf("x contains an odd number of 1s.\n"));
  (even_ones(test_hex_0)) && (printf("x contains an even number of 1s.\n"));
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x10010001,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <odd_ones@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x9(%rbp)
je     1186 <main+0x46>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%edi
call   1050 <even_ones@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xa(%rbp)
je     11b9 <main+0x79>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x10010001,%edi
call   1060 <odd_ones@plt>
test   %rax,%rax
je     115c <main+0x1c>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    $0x10010001,%edi
call   1050 <even_ones@plt>
test   %rax,%rax
je     1177 <main+0x37>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"x contains an odd number of 1s.\0A\00"
@.str.1 = [34 x i8] c"x contains an even number of 1s.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 268500993, i32* %2
%3 = load i32, i32* %2
%4 = call i64 @odd_ones(i32 %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i64 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br label %9
9: ; preds = %6, %0
%10 = phi i1 [ false, %0 ], [ %8, %6 ]
%11 = zext i1 %10 to i32
%12 = load i32, i32* %2
%13 = call i64 @even_ones(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = call i64 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br label %18
18: ; preds = %15, %9
%19 = phi i1 [ false, %9 ], [ %17, %15 ]
%20 = zext i1 %19 to i32
%21 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@str = [33 x i8] c"x contains an even number of 1s.\00"
@str.2 = [32 x i8] c"x contains an odd number of 1s.\00"
define i32 @main() {
%1 = tail call i64 @odd_ones(i32 268500993)
%2 = icmp eq i64 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.2, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i64 @even_ones(i32 268500993)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = tail call i32 (...) @getchar()
ret i32 0
}