#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int a = 1, n;
  printf("Enter the number: ");
  scanf("%d", &n);
  while (a < n) {
    a *= 2;
  }
  if (a == n)
    printf("The given number is power of two\n");
  else
    printf("Not power of two\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116c <main+0x4c>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x32>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1189 <main+0x69>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <main+0x75>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0x1,%ecx
mov    0x4(%rsp),%eax
nopw   0x0(%rax,%rax,1)
lea    (%rcx,%rcx,1),%edx
cmp    %eax,%ecx
mov    %edx,%ecx
jl     1160 <main+0x30>
lea    0xeb7(%rip),%rax
lea    0xe9f(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter the number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"The given number is power of two\0A\00"
@.str.3 = [18 x i8] c"Not power of two\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* %2
%12 = mul nsw i32 %11, 2
store i32 %12, i32* %2
br label %6
13: ; preds = %6
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %13
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter the number: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [17 x i8] c"Not power of two\00"
@str.4 = [33 x i8] c"The given number is power of two\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
br label %6
6: ; preds = %6, %0
%7 = phi i32 [ 1, %0 ], [ %9, %6 ]
%8 = icmp slt i32 %7, %5
%9 = shl nsw i32 %7, 1
br i1 %8, label %6, label %10
10: ; preds = %6
%11 = icmp eq i32 %7, %5
%12 = select i1 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0)
%13 = call i32 @puts(i8* dereferenceable(1) %12)
ret i32 0
}