#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 bitcount(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, int);
int main() {
  int i;
  unsigned test[4] = {51, 65535, 256, 10834};
  for (i = 0; i < 4; i++) {
    printf("%6u has %2d ones in its binary representation.\n", test[i],
           bitcount(test[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)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    118d <main+0x6d>
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   1040 <bitcount@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114c <main+0x2c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@__const.main.test = [4 x i32] [i32 51, i32 65535, i32 256, i32 10834]
@.str = [48 x i8] c"%6u has %2d ones in its binary representation.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i32]
store i32 0, i32* %1
%4 = bitcast [4 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, 4
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [4 x i32], [4 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 [4 x i32], [4 x i32]* %3, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 @bitcount(i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 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 = [48 x i8] c"%6u has %2d ones in its binary representation.\0A\00"
define i32 @main() {
%1 = tail call i32 @bitcount(i32 51)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 51, i32 %1)
%3 = tail call i32 @bitcount(i32 65535)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 65535, i32 %3)
%5 = tail call i32 @bitcount(i32 256)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 256, i32 %5)
%7 = tail call i32 @bitcount(i32 10834)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 10834, i32 %7)
ret i32 0
}