#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(int);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  int x0 = 0xf;
  int x1 = 0x1f;
  int x2 = 0x0;
  printf("0x%x has %d bit 1\n", x0, bitcount(x0));
  printf("0x%x has %d bit 1\n", x1, bitcount(x1));
  printf("0x%x has %d bit 1\n", x2, bitcount(x2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf,-0x8(%rbp)
movl   $0x1f,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <bitcount@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <bitcount@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <bitcount@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [19 x i8] c"0x%x has %d bit 1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 15, i32* %2
store i32 31, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @bitcount(i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7)
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = call i32 @bitcount(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11)
%13 = load i32, i32* %4
%14 = load i32, i32* %4
%15 = call i32 @bitcount(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"0x%x has %d bit 1\0A\00"
define i32 @main() {
%1 = tail call i32 @bitcount(i32 15)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 15, i32 %1)
%3 = tail call i32 @bitcount(i32 31)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 31, i32 %3)
%5 = tail call i32 @bitcount(i32 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 0, i32 %5)
ret i32 0
}