#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 countingNumberofOneswithTogglingApproach(int);
int /*<<< orphan*/ printf(char *, int, int);
void countingNumberofOneswithTogglingApproach_test() {
  int i = 10;
  printf("Number of one's in %d is/are %d\n", i,
         countingNumberofOneswithTogglingApproach(i));
  i = 5;
  printf("Number of one's in %d is/are %d\n", i,
         countingNumberofOneswithTogglingApproach(i));
  i = 100;
  printf("Number of one's in %d is/are %d\n", i,
         countingNumberofOneswithTogglingApproach(i));
  i = 1;
  printf("Number of one's in %d is/are %d\n", i,
         countingNumberofOneswithTogglingApproach(i));
  i = 0;
  printf("Number of one's in %d is/are %d\n", i,
         countingNumberofOneswithTogglingApproach(i));
}


x86 assembly (clang, -O0):
<countingNumberofOneswithTogglingApproach_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <countingNumberofOneswithTogglingApproach@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 <countingNumberofOneswithTogglingApproach@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 <countingNumberofOneswithTogglingApproach@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 <countingNumberofOneswithTogglingApproach@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 <countingNumberofOneswithTogglingApproach@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):
<countingNumberofOneswithTogglingApproach_test>:
push   %rbx
mov    $0xa,%edi
call   1040 <countingNumberofOneswithTogglingApproach@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x5,%edi
call   1040 <countingNumberofOneswithTogglingApproach@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x64,%edi
call   1040 <countingNumberofOneswithTogglingApproach@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <countingNumberofOneswithTogglingApproach@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <countingNumberofOneswithTogglingApproach@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Number of one's in %d is/are %d\0A\00"
define void @countingNumberofOneswithTogglingApproach_test() {
%1 = alloca i32
store i32 10, i32* %1
%2 = load i32, i32* %1
%3 = load i32, i32* %1
%4 = call i32 @countingNumberofOneswithTogglingApproach(i32 %3)
%5 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 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 @countingNumberofOneswithTogglingApproach(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 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 @countingNumberofOneswithTogglingApproach(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 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 @countingNumberofOneswithTogglingApproach(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 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 @countingNumberofOneswithTogglingApproach(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %20)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Number of one's in %d is/are %d\0A\00"
define void @countingNumberofOneswithTogglingApproach_test() {
%1 = tail call i32 @countingNumberofOneswithTogglingApproach(i32 10)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 10, i32 %1)
%3 = tail call i32 @countingNumberofOneswithTogglingApproach(i32 5)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 5, i32 %3)
%5 = tail call i32 @countingNumberofOneswithTogglingApproach(i32 100)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 100, i32 %5)
%7 = tail call i32 @countingNumberofOneswithTogglingApproach(i32 1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 1, i32 %7)
%9 = tail call i32 @countingNumberofOneswithTogglingApproach(i32 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 0, i32 %9)
ret void
}