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


x86 assembly (clang, -O0):
<test_bit_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1030 <bit_count@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count+0xcf>
mov    $0x1,%edi
call   1030 <bit_count@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count+0xcf>
mov    $0x2,%edi
call   1030 <bit_count@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count+0xcf>
mov    $0x3,%edi
call   1030 <bit_count@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count+0xcf>
mov    $0x7,%edi
call   1030 <bit_count@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x3,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count+0xcf>
mov    $0xffffffff,%edi
call   1030 <bit_count@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x20,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11df <test_bit_count+0xcf>
mov    $0xfffffffe,%edi
call   1030 <bit_count@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_count>:
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <bit_count@plt>
test   %eax,%eax
jne    117b <test_bit_count+0x6b>
mov    $0x1,%edi
call   1030 <bit_count@plt>
cmp    $0x1,%eax
jne    117b <test_bit_count+0x6b>
mov    $0x2,%edi
call   1030 <bit_count@plt>
cmp    $0x1,%eax
jne    117b <test_bit_count+0x6b>
mov    $0x3,%edi
call   1030 <bit_count@plt>
cmp    $0x2,%eax
jne    117b <test_bit_count+0x6b>
mov    $0x7,%edi
call   1030 <bit_count@plt>
cmp    $0x3,%eax
jne    117b <test_bit_count+0x6b>
mov    $0xffffffff,%edi
call   1030 <bit_count@plt>
cmp    $0x20,%eax
jne    117b <test_bit_count+0x6b>
mov    $0xfffffffe,%edi
call   1030 <bit_count@plt>
xor    %ebx,%ebx
cmp    $0x1f,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @test_bit_count() {
%1 = call i32 @bit_count(i32 0)
%2 = icmp eq i32 0, %1
br i1 %2, label %3, label %21
3: ; preds = %0
%4 = call i32 @bit_count(i32 1)
%5 = icmp eq i32 1, %4
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = call i32 @bit_count(i32 2)
%8 = icmp eq i32 1, %7
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = call i32 @bit_count(i32 3)
%11 = icmp eq i32 2, %10
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = call i32 @bit_count(i32 7)
%14 = icmp eq i32 3, %13
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = call i32 @bit_count(i32 -1)
%17 = icmp eq i32 32, %16
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 @bit_count(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_count() {
%1 = tail call i32 @bit_count(i32 0)
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %22
3: ; preds = %0
%4 = tail call i32 @bit_count(i32 1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = tail call i32 @bit_count(i32 2)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = tail call i32 @bit_count(i32 3)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = tail call i32 @bit_count(i32 7)
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = tail call i32 @bit_count(i32 -1)
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call i32 @bit_count(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
}