#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 *, ...);
void checkValue(int value) {
  if (0 == (value & (value - 1))) {
    printf("%d is (2 power n)\n", value);
  } else {
    printf("%d is NOT (2 power n)\n", value);
  }
  if (0 == (value & (value + 1))) {
    printf("%d is (2 power n) - 1\n", value);
  } else {
    printf("%d is NOT (2 power n) - 1\n", value);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<checkValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
and    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1146 <checkValue+0x36>
mov    -0x4(%rbp),%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1157 <checkValue+0x47>
mov    -0x4(%rbp),%esi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x1,%eax
and    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1182 <checkValue+0x72>
mov    -0x4(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1193 <checkValue+0x83>
mov    -0x4(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkValue>:
push   %rbx
mov    %edi,%ebx
lea    -0x1(%rbx),%eax
test   %eax,%edi
lea    0xed1(%rip),%rax
lea    0xedd(%rip),%rdi
cmove  %rax,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rbx),%eax
test   %ebx,%eax
lea    0xedb(%rip),%rax
lea    0xeeb(%rip),%rdi
cmove  %rax,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"%d is (2 power n)\0A\00"
@.str.1 = [23 x i8] c"%d is NOT (2 power n)\0A\00"
@.str.2 = [23 x i8] c"%d is (2 power n) - 1\0A\00"
@.str.3 = [27 x i8] c"%d is NOT (2 power n) - 1\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @checkValue(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = sub nsw i32 %4, 1
%6 = and i32 %3, %5
%7 = icmp eq i32 0, %6
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %14
11: ; preds = %1
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %11, %8
%15 = load i32, i32* %2
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
%18 = and i32 %15, %17
%19 = icmp eq i32 0, %18
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %26
23: ; preds = %14
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %20
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"%d is (2 power n)\0A\00"
@.str.1 = [23 x i8] c"%d is NOT (2 power n)\0A\00"
@.str.2 = [23 x i8] c"%d is (2 power n) - 1\0A\00"
@.str.3 = [27 x i8] c"%d is NOT (2 power n) - 1\0A\00"
define void @checkValue(i32 %0) {
%2 = tail call i32 @llvm.ctpop.i32(i32 %0)
%3 = icmp ult i32 %2, 2
%4 = select i1 %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %4, i32 %0)
%6 = add nsw i32 %0, 1
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %9, i32 %0)
%11 = tail call i32 @putchar(i32 10)
ret void
}