#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 bit_count2(int);
int test_bit_count2() {
  return 0 == bit_count2(0) && 1 == bit_count2(1) && 1 == bit_count2(2) &&
         2 == bit_count2(3) && 3 == bit_count2(7) && 32 == bit_count2(-1) &&
         31 == bit_count2(-2);
}


x86 assembly (clang, -O0):
<test_bit_count2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1030 <bit_count2@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count2+0xcf>
mov    $0x1,%edi
call   1030 <bit_count2@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count2+0xcf>
mov    $0x2,%edi
call   1030 <bit_count2@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count2+0xcf>
mov    $0x3,%edi
call   1030 <bit_count2@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count2+0xcf>
mov    $0x7,%edi
call   1030 <bit_count2@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x3,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count2+0xcf>
mov    $0xffffffff,%edi
call   1030 <bit_count2@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x20,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count2+0xcf>
mov    $0xfffffffe,%edi
call   1030 <bit_count2@plt>
mov    %eax,%ecx
mov    $0x1f,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bit_count2>:
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <bit_count2@plt>
test   %eax,%eax
jne    117b <test_bit_count2+0x6b>
mov    $0x1,%edi
call   1030 <bit_count2@plt>
cmp    $0x1,%eax
jne    117b <test_bit_count2+0x6b>
mov    $0x2,%edi
call   1030 <bit_count2@plt>
cmp    $0x1,%eax
jne    117b <test_bit_count2+0x6b>
mov    $0x3,%edi
call   1030 <bit_count2@plt>
cmp    $0x2,%eax
jne    117b <test_bit_count2+0x6b>
mov    $0x7,%edi
call   1030 <bit_count2@plt>
cmp    $0x3,%eax
jne    117b <test_bit_count2+0x6b>
mov    $0xffffffff,%edi
call   1030 <bit_count2@plt>
cmp    $0x20,%eax
jne    117b <test_bit_count2+0x6b>
mov    $0xfffffffe,%edi
call   1030 <bit_count2@plt>
xor    %ebx,%ebx
cmp    $0x1f,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @test_bit_count2() {
%1 = call i32 @bit_count2(i32 0)
%2 = icmp eq i32 0, %1
br i1 %2, label %3, label %21
3: ; preds = %0
%4 = call i32 @bit_count2(i32 1)
%5 = icmp eq i32 1, %4
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = call i32 @bit_count2(i32 2)
%8 = icmp eq i32 1, %7
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = call i32 @bit_count2(i32 3)
%11 = icmp eq i32 2, %10
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = call i32 @bit_count2(i32 7)
%14 = icmp eq i32 3, %13
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = call i32 @bit_count2(i32 -1)
%17 = icmp eq i32 32, %16
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 @bit_count2(i32 -2)
%20 = icmp eq i32 31, %19
br label %21
21: ; preds = %18, %15, %12, %9, %6, %3, %0
%22 = phi i1 [ false, %15 ], [ false, %12 ], [ false, %9 ], [ false, %6 ], [ false, %3 ], [ false, %0 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
ret i32 %23
}

LLVM IR (-O2):
define i32 @test_bit_count2() {
%1 = tail call i32 @bit_count2(i32 0)
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %22
3: ; preds = %0
%4 = tail call i32 @bit_count2(i32 1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = tail call i32 @bit_count2(i32 2)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = tail call i32 @bit_count2(i32 3)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = tail call i32 @bit_count2(i32 7)
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = tail call i32 @bit_count2(i32 -1)
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call i32 @bit_count2(i32 -2)
%20 = icmp eq i32 %19, 31
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %18, %15, %12, %9, %6, %3, %0
%23 = phi i32 [ 0, %15 ], [ 0, %12 ], [ 0, %9 ], [ 0, %6 ], [ 0, %3 ], [ 0, %0 ], [ %21, %18 ]
ret i32 %23
}