int fftease_power_of_two(int test) {
  int limit = 1048576;
  int compare = 1;
  do {
    if (test == compare) {
      return 1;
    }
    compare *= 2;
  } while (compare <= limit);
  return 0;
}


x86 assembly (clang, -O0):
<fftease_power_of_two>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x100000,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    112d <fftease_power_of_two+0x2d>
movl   $0x1,-0x4(%rbp)
jmp    1149 <fftease_power_of_two+0x49>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1115 <fftease_power_of_two+0x15>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fftease_power_of_two>:
mov    $0x1,%eax
cmp    $0x3ff,%edi
jle    113a <fftease_power_of_two+0x3a>
cmp    $0x7fff,%edi
jle    1159 <fftease_power_of_two+0x59>
cmp    $0x3ffff,%edi
jg     1195 <fftease_power_of_two+0x95>
cmp    $0x8000,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x10000,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x20000,%edi
jne    11c3 <fftease_power_of_two+0xc3>
ret
cmp    $0x7f,%edi
jg     117b <fftease_power_of_two+0x7b>
add    $0xffffffff,%edi
cmp    $0x3f,%edi
ja     11c3 <fftease_power_of_two+0xc3>
movabs $0x800000008000808b,%rcx
bt     %rdi,%rcx
jb     1139 <fftease_power_of_two+0x39>
jmp    11c3 <fftease_power_of_two+0xc3>
cmp    $0xfff,%edi
jle    11af <fftease_power_of_two+0xaf>
cmp    $0x1000,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x2000,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x4000,%edi
je     1139 <fftease_power_of_two+0x39>
jmp    11c3 <fftease_power_of_two+0xc3>
cmp    $0x80,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x100,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x200,%edi
je     1139 <fftease_power_of_two+0x39>
jmp    11c3 <fftease_power_of_two+0xc3>
cmp    $0x40000,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x80000,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x100000,%edi
je     1139 <fftease_power_of_two+0x39>
jmp    11c3 <fftease_power_of_two+0xc3>
cmp    $0x400,%edi
je     1139 <fftease_power_of_two+0x39>
cmp    $0x800,%edi
je     1139 <fftease_power_of_two+0x39>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @fftease_power_of_two(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 1048576, i32* %4
store i32 1, i32* %5
br label %6
6: ; preds = %14, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %5
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %11
10: ; preds = %6
store i32 1, i32* %2
br label %19
11: ; preds = %6
%12 = load i32, i32* %5
%13 = mul nsw i32 %12, 2
store i32 %13, i32* %5
br label %14
14: ; preds = %11
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = icmp sle i32 %15, %16
br i1 %17, label %6, label %18
18: ; preds = %14
store i32 0, i32* %2
br label %19
19: ; preds = %18, %10
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @fftease_power_of_two(i32 %0) {
switch i32 %0, label %2 [
i32 1, label %3
i32 2, label %3
i32 4, label %3
i32 8, label %3
i32 16, label %3
i32 32, label %3
i32 64, label %3
i32 128, label %3
i32 256, label %3
i32 512, label %3
i32 1024, label %3
i32 2048, label %3
i32 4096, label %3
i32 8192, label %3
i32 16384, label %3
i32 32768, label %3
i32 65536, label %3
i32 131072, label %3
i32 262144, label %3
i32 524288, label %3
i32 1048576, label %3
]
2: ; preds = %1
br label %3
3: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %2
%4 = phi i32 [ 1, %1 ], [ 0, %2 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ]
ret i32 %4
}