#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*/ printbits(char *, int);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int x = 11;
  int r = 0;
  r = bitcount(x);
  printbits("x", x);
  printf("bitcount(x = %i) returns: %i\n", x, r);
  x = 6345;
  r = 0;
  r = bitcount(x);
  printbits("x", x);
  printf("bitcount(x = %i) returns: %i\n", x, r);
  x = -6345;
  r = 0;
  r = bitcount(x);
  printbits("x", x);
  printf("bitcount(x = %i) returns: %i\n", x, r);
  x = -1;
  r = 0;
  r = bitcount(x);
  printbits("x", x);
  printf("bitcount(x = %i) returns: %i\n", x, r);
  x = 0;
  r = 0;
  r = bitcount(x);
  printbits("x", x);
  printf("bitcount(x = %i) returns: %i\n", x, r);
  x = 1234567;
  r = 0;
  r = bitcount(x);
  printbits("x", x);
  printf("bitcount(x = %i) returns: %i\n", x, r);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xb,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <bitcount@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea5(%rip),%rdi
call   1050 <printbits@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
movl   $0x18c9,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <bitcount@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe6b(%rip),%rdi
call   1050 <printbits@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffe737,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <bitcount@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1050 <printbits@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <bitcount@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xdf7(%rip),%rdi
call   1050 <printbits@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <bitcount@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xdbd(%rip),%rdi
call   1050 <printbits@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xdad(%rip),%rdi
call   1030 <printf@plt>
movl   $0x12d687,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <bitcount@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xd83(%rip),%rdi
call   1050 <printbits@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xd73(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xb,%edi
call   1040 <bitcount@plt>
mov    %eax,%ebp
lea    0xeb9(%rip),%r14
mov    %r14,%rdi
mov    $0xb,%esi
call   1050 <printbits@plt>
lea    0xea7(%rip),%rbx
mov    %rbx,%rdi
mov    $0xb,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    $0x18c9,%edi
call   1040 <bitcount@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0x18c9,%esi
call   1050 <printbits@plt>
mov    %rbx,%rdi
mov    $0x18c9,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    $0xffffe737,%edi
call   1040 <bitcount@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0xffffe737,%esi
call   1050 <printbits@plt>
mov    %rbx,%rdi
mov    $0xffffe737,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <bitcount@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0xffffffff,%esi
call   1050 <printbits@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <bitcount@plt>
mov    %eax,%ebp
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <printbits@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    $0x12d687,%edi
call   1040 <bitcount@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    $0x12d687,%esi
call   1050 <printbits@plt>
mov    %rbx,%rdi
mov    $0x12d687,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"x\00"
@.str.1 = [30 x i8] c"bitcount(x = %i) returns: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 11, i32* %1
store i32 0, i32* %2
%3 = load i32, i32* %1
%4 = call i32 @bitcount(i32 %3)
store i32 %4, i32* %2
%5 = load i32, i32* %1
%6 = call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8)
store i32 6345, i32* %1
store i32 0, i32* %2
%10 = load i32, i32* %1
%11 = call i32 @bitcount(i32 %10)
store i32 %11, i32* %2
%12 = load i32, i32* %1
%13 = call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15)
store i32 -6345, i32* %1
store i32 0, i32* %2
%17 = load i32, i32* %1
%18 = call i32 @bitcount(i32 %17)
store i32 %18, i32* %2
%19 = load i32, i32* %1
%20 = call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22)
store i32 -1, i32* %1
store i32 0, i32* %2
%24 = load i32, i32* %1
%25 = call i32 @bitcount(i32 %24)
store i32 %25, i32* %2
%26 = load i32, i32* %1
%27 = call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29)
store i32 0, i32* %1
store i32 0, i32* %2
%31 = load i32, i32* %1
%32 = call i32 @bitcount(i32 %31)
store i32 %32, i32* %2
%33 = load i32, i32* %1
%34 = call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %36)
store i32 1234567, i32* %1
store i32 0, i32* %2
%38 = load i32, i32* %1
%39 = call i32 @bitcount(i32 %38)
store i32 %39, i32* %2
%40 = load i32, i32* %1
%41 = call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %1
%43 = load i32, i32* %2
%44 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"x\00"
@.str.1 = [30 x i8] c"bitcount(x = %i) returns: %i\0A\00"
define i32 @main() {
%1 = tail call i32 @bitcount(i32 11)
%2 = tail call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 11)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 11, i32 %1)
%4 = tail call i32 @bitcount(i32 6345)
%5 = tail call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 6345)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 6345, i32 %4)
%7 = tail call i32 @bitcount(i32 -6345)
%8 = tail call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 -6345)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 -6345, i32 %7)
%10 = tail call i32 @bitcount(i32 -1)
%11 = tail call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 -1)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 -1, i32 %10)
%13 = tail call i32 @bitcount(i32 0)
%14 = tail call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %13)
%16 = tail call i32 @bitcount(i32 1234567)
%17 = tail call i32 @printbits(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1234567)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 1234567, i32 %16)
ret i32 0
}