#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 bitSwapRequired(int, int);
int /*<<< orphan*/ print_binary_of(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int swapOddEvenBits(int);
int main(int argc, char *argv[]) {
  int num = 0;
  int a, b;
  printf("Enter a number to check if its power of two:");
  scanf("%d", &num);
  printf("\n");
  if ((num & (num - 1)) == 0) {
    printf("its a power of two\n");
  } else {
    printf("its not a power of two\n");
  }
  printf("swapped Odd Even bits : %d\n", swapOddEvenBits(num));
  printf("Find number bit flip required to make two numbers equal: Enter two "
         "number:");
  scanf("%d", &a);
  printf("\n");
  scanf("%d", &b);
  printf("\nNum of bit flips needed to make them equal %d\n",
         bitSwapRequired(a, b));
  for (int i = 0; i < 56; i++) {
    printf("Binary value of %d is : ", i);
    print_binary_of(i);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    11c0 <main+0x70>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ce <main+0x7e>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <swapOddEvenBits@plt>
mov    %eax,%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe32(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe14(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <bitSwapRequired@plt>
mov    %eax,%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x38,-0x20(%rbp)
jge    1283 <main+0x133>
mov    -0x20(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1050 <print_binary_of@plt>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1244 <main+0xf4>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9a(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
test   %ecx,%eax
lea    0xf3d(%rip),%rax
lea    0xf1f(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
mov    0xc(%rsp),%edi
call   1030 <swapOddEvenBits@plt>
lea    0xe56(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <scanf@plt>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1080 <bitSwapRequired@plt>
lea    0xe6e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe8e(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%edi
call   1070 <print_binary_of@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%ebp
cmp    $0x38,%ebp
jne    1240 <main+0xd0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Enter a number to check if its power of two:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [20 x i8] c"its a power of two\0A\00"
@.str.4 = [24 x i8] c"its not a power of two\0A\00"
@.str.5 = [28 x i8] c"swapped Odd Even bits : %d\0A\00"
@.str.6 = [75 x i8] c"Find number bit flip required to make two numbers equal: Enter two number:\00"
@.str.7 = [48 x i8] c"\0ANum of bit flips needed to make them equal %d\0A\00"
@.str.8 = [25 x i8] c"Binary value of %d is : \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* %6
%14 = load i32, i32* %6
%15 = sub nsw i32 %14, 1
%16 = and i32 %13, %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %22
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = load i32, i32* %6
%24 = call i32 @swapOddEvenBits(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 @bitSwapRequired(i32 %30, i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i32 %32)
store i32 0, i32* %9
br label %34
34: ; preds = %43, %22
%35 = load i32, i32* %9
%36 = icmp slt i32 %35, 56
br i1 %36, label %37, label %46
37: ; preds = %34
%38 = load i32, i32* %9
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %9
%41 = call i32 @print_binary_of(i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %37
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %34
46: ; preds = %34
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [45 x i8] c"Enter a number to check if its power of two:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [28 x i8] c"swapped Odd Even bits : %d\0A\00"
@.str.6 = [75 x i8] c"Find number bit flip required to make two numbers equal: Enter two number:\00"
@.str.7 = [48 x i8] c"\0ANum of bit flips needed to make them equal %d\0A\00"
@.str.8 = [25 x i8] c"Binary value of %d is : \00"
@str = [23 x i8] c"its not a power of two\00"
@str.9 = [19 x i8] c"its a power of two\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32 @putchar(i32 10)
%12 = load i32, i32* %3
%13 = call i32 @llvm.ctpop.i32(i32 %12)
%14 = icmp ult i32 %13, 2
%15 = select i1 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
%17 = load i32, i32* %3
%18 = call i32 @swapOddEvenBits(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%22 = call i32 @putchar(i32 10)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 @bitSwapRequired(i32 %24, i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i32 %26)
br label %29
28: ; preds = %29
ret i32 0
29: ; preds = %2, %29
%30 = phi i32 [ 0, %2 ], [ %34, %29 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %30)
%32 = call i32 @print_binary_of(i32 %30)
%33 = call i32 @putchar(i32 10)
%34 = add nuw nsw i32 %30, 1
%35 = icmp eq i32 %34, 56
br i1 %35, label %28, label %29
}