#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 countingNumberofOnesIn1toN(int);
int /*<<< orphan*/ printf(char *, int, int);
void countingNumberofOnesIn1toN_test() {
  int n = 5;
  printf("Number of set bits in all numbers from 1 to %d is/are %d\n", n,
         countingNumberofOnesIn1toN(n));
  n = 5;
  printf("Number of set bits in all numbers from 1 to %d is/are %d\n", n,
         countingNumberofOnesIn1toN(n));
  n = 100;
  printf("Number of set bits in all numbers from 1 to %d is/are %d\n", n,
         countingNumberofOnesIn1toN(n));
  n = 1;
  printf("Number of set bits in all numbers from 1 to %d is/are %d\n", n,
         countingNumberofOnesIn1toN(n));
  n = 0;
  printf("Number of set bits in all numbers from 1 to %d is/are %d\n", n,
         countingNumberofOnesIn1toN(n));
}


x86 assembly (clang, -O0):
<countingNumberofOnesIn1toN_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
movl   $0x64,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    -0x8(%rbp),%esi
mov    %eax,%edx
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countingNumberofOnesIn1toN_test>:
push   %rbx
mov    $0x5,%edi
call   1040 <countingNumberofOnesIn1toN@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x5,%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x64,%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <countingNumberofOnesIn1toN@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"Number of set bits in all numbers from 1 to %d is/are %d\0A\00"
define void @countingNumberofOnesIn1toN_test() {
%1 = alloca i32
store i32 5, i32* %1
%2 = load i32, i32* %1
%3 = load i32, i32* %1
%4 = call i32 @countingNumberofOnesIn1toN(i32 %3)
%5 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %4)
store i32 5, i32* %1
%6 = load i32, i32* %1
%7 = load i32, i32* %1
%8 = call i32 @countingNumberofOnesIn1toN(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8)
store i32 100, i32* %1
%10 = load i32, i32* %1
%11 = load i32, i32* %1
%12 = call i32 @countingNumberofOnesIn1toN(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12)
store i32 1, i32* %1
%14 = load i32, i32* %1
%15 = load i32, i32* %1
%16 = call i32 @countingNumberofOnesIn1toN(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %16)
store i32 0, i32* %1
%18 = load i32, i32* %1
%19 = load i32, i32* %1
%20 = call i32 @countingNumberofOnesIn1toN(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %20)
ret void
}

LLVM IR (-O2):
@.str = [58 x i8] c"Number of set bits in all numbers from 1 to %d is/are %d\0A\00"
define void @countingNumberofOnesIn1toN_test() {
%1 = tail call i32 @countingNumberofOnesIn1toN(i32 5)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 5, i32 %1)
%3 = tail call i32 @countingNumberofOnesIn1toN(i32 5)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 5, i32 %3)
%5 = tail call i32 @countingNumberofOnesIn1toN(i32 100)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 100, i32 %5)
%7 = tail call i32 @countingNumberofOnesIn1toN(i32 1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 1, i32 %7)
%9 = tail call i32 @countingNumberofOnesIn1toN(i32 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 0, i32 %9)
ret void
}