#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 count_bit(int);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  int i;
  int nums[] = {256, 1159, 82991, 7182, 882001};
  for (i = 0; i < 5; i++)
    printf("bit count of %d: %d\n", nums[i], count_bit(nums[i]));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1196 <main+0x76>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x24(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1030 <count_bit@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <main+0x35>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x100,%edi
call   1030 <count_bit@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x487,%edi
call   1030 <count_bit@plt>
mov    %rbx,%rdi
mov    $0x487,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x1442f,%edi
call   1030 <count_bit@plt>
mov    %rbx,%rdi
mov    $0x1442f,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x1c0e,%edi
call   1030 <count_bit@plt>
mov    %rbx,%rdi
mov    $0x1c0e,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0xd7551,%edi
call   1030 <count_bit@plt>
mov    %rbx,%rdi
mov    $0xd7551,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.nums = [5 x i32] [i32 256, i32 1159, i32 82991, i32 7182, i32 882001]
@.str = [21 x i8] c"bit count of %d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
store i32 0, i32* %1
%4 = bitcast [5 x i32]* %3 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %19, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 @count_bit(i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %17)
br label %19
19: ; preds = %8
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %5
22: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"bit count of %d: %d\0A\00"
define i32 @main() {
%1 = tail call i32 @count_bit(i32 256)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 256, i32 %1)
%3 = tail call i32 @count_bit(i32 1159)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1159, i32 %3)
%5 = tail call i32 @count_bit(i32 82991)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 82991, i32 %5)
%7 = tail call i32 @count_bit(i32 7182)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 7182, i32 %7)
%9 = tail call i32 @count_bit(i32 882001)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 882001, i32 %9)
ret i32 0
}