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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int hammingWeight_4(int);
int hammingWeight_8(int);
int hammingWeight_naive(int);
int /*<<< orphan*/ printf(char *, ...);
void test_case(uint32_t n) {
  printf("==============================\n");
  if (hammingWeight_4(n) != hammingWeight_naive(n) ||
      hammingWeight_8(n) != hammingWeight_naive(n)) {
    printf("error\n");
    exit(1);
  }
  printf("n=%d weight_8=%d weight_4=%d weight naive=%d\n", n,
         hammingWeight_8(n), hammingWeight_4(n), hammingWeight_naive(n));
}


x86 assembly (clang, -O0):
<test_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1070 <hammingWeight_4@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <hammingWeight_naive@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
cmp    %ecx,%eax
jne    11a9 <test_case+0x59>
mov    -0x4(%rbp),%edi
call   1060 <hammingWeight_8@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <hammingWeight_naive@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
je     11c1 <test_case+0x71>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <hammingWeight_8@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <hammingWeight_4@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <hammingWeight_naive@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    %eax,%r8d
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_case>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1080 <hammingWeight_4@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <hammingWeight_naive@plt>
cmp    %eax,%ebp
jne    11d0 <test_case+0x70>
mov    %ebx,%edi
call   1070 <hammingWeight_8@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <hammingWeight_naive@plt>
cmp    %eax,%ebp
jne    11d0 <test_case+0x70>
mov    %ebx,%edi
call   1070 <hammingWeight_8@plt>
mov    %eax,%r14d
mov    %ebx,%edi
call   1080 <hammingWeight_4@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <hammingWeight_naive@plt>
lea    0xe45(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"==============================\0A\00"
@.str.1 = [7 x i8] c"error\0A\00"
@.str.2 = [46 x i8] c"n=%d weight_8=%d weight_4=%d weight naive=%d\0A\00"
define void @test_case(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = call i32 @hammingWeight_4(i32 %4)
%6 = load i32, i32* %2
%7 = call i32 @hammingWeight_naive(i32 %6)
%8 = icmp ne i32 %5, %7
br i1 %8, label %15, label %9
9: ; preds = %1
%10 = load i32, i32* %2
%11 = call i32 @hammingWeight_8(i32 %10)
%12 = load i32, i32* %2
%13 = call i32 @hammingWeight_naive(i32 %12)
%14 = icmp ne i32 %11, %13
br i1 %14, label %15, label %18
15: ; preds = %9, %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %9
%19 = load i32, i32* %2
%20 = load i32, i32* %2
%21 = call i32 @hammingWeight_8(i32 %20)
%22 = load i32, i32* %2
%23 = call i32 @hammingWeight_4(i32 %22)
%24 = load i32, i32* %2
%25 = call i32 @hammingWeight_naive(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %21, i32 %23, i32 %25)
ret void
}

LLVM IR (-O2):
@.str.2 = [46 x i8] c"n=%d weight_8=%d weight_4=%d weight naive=%d\0A\00"
@str = [31 x i8] c"==============================\00"
@str.3 = [6 x i8] c"error\00"
define void @test_case(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @hammingWeight_4(i32 %0)
%4 = tail call i32 @hammingWeight_naive(i32 %0)
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = tail call i32 @hammingWeight_8(i32 %0)
%8 = tail call i32 @hammingWeight_naive(i32 %0)
%9 = icmp eq i32 %7, %8
br i1 %9, label %13, label %10
10: ; preds = %6, %1
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %6
%14 = tail call i32 @hammingWeight_8(i32 %0)
%15 = tail call i32 @hammingWeight_4(i32 %0)
%16 = tail call i32 @hammingWeight_naive(i32 %0)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %14, i32 %15, i32 %16)
ret void
}