int my_is_good_fftw2_size(int size) {
  while ((size % 2) == 0) {
    size /= 2;
  }
  while ((size % 3) == 0) {
    size /= 3;
  }
  while ((size % 5) == 0) {
    size /= 5;
  }
  while ((size % 7) == 0) {
    size /= 7;
  }
  return (size == 1);
}


x86 assembly (clang, -O0):
<my_is_good_fftw2_size>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    112e <my_is_good_fftw2_size+0x2e>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1107 <my_is_good_fftw2_size+0x7>
jmp    1133 <my_is_good_fftw2_size+0x33>
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115a <my_is_good_fftw2_size+0x5a>
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1133 <my_is_good_fftw2_size+0x33>
jmp    115f <my_is_good_fftw2_size+0x5f>
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1186 <my_is_good_fftw2_size+0x86>
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    115f <my_is_good_fftw2_size+0x5f>
jmp    118b <my_is_good_fftw2_size+0x8b>
mov    -0x4(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b2 <my_is_good_fftw2_size+0xb2>
mov    -0x4(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    118b <my_is_good_fftw2_size+0x8b>
cmpl   $0x1,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_is_good_fftw2_size>:
test   $0x1,%dil
jne    1122 <my_is_good_fftw2_size+0x22>
cs nopw 0x0(%rax,%rax,1)
mov    %edi,%ecx
shr    $0x1f,%ecx
add    %edi,%ecx
sar    %ecx
mov    %ecx,%edi
test   $0x1,%cl
je     1110 <my_is_good_fftw2_size+0x10>
jmp    1124 <my_is_good_fftw2_size+0x24>
mov    %edi,%ecx
imul   $0xaaaaaaab,%ecx,%eax
add    $0x2aaaaaaa,%eax
cmp    $0x55555554,%eax
ja     1169 <my_is_good_fftw2_size+0x69>
cs nopw 0x0(%rax,%rax,1)
movslq %ecx,%rax
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
shr    $0x20,%rcx
add    %eax,%ecx
imul   $0xaaaaaaab,%ecx,%eax
add    $0x2aaaaaaa,%eax
cmp    $0x55555555,%eax
jb     1140 <my_is_good_fftw2_size+0x40>
imul   $0xcccccccd,%ecx,%eax
add    $0x19999999,%eax
cmp    $0x33333332,%eax
ja     11a9 <my_is_good_fftw2_size+0xa9>
nopl   0x0(%rax,%rax,1)
movslq %ecx,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x21,%rcx
add    %eax,%ecx
imul   $0xcccccccd,%ecx,%eax
add    $0x19999999,%eax
cmp    $0x33333333,%eax
jb     1180 <my_is_good_fftw2_size+0x80>
imul   $0xb6db6db7,%ecx,%eax
add    $0x12492492,%eax
cmp    $0x24924924,%eax
ja     11ec <my_is_good_fftw2_size+0xec>
nopl   0x0(%rax,%rax,1)
movslq %ecx,%rcx
imul   $0xffffffff92492493,%rcx,%rax
shr    $0x20,%rax
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x2,%ecx
add    %eax,%ecx
imul   $0xb6db6db7,%ecx,%eax
add    $0x12492492,%eax
cmp    $0x24924925,%eax
jb     11c0 <my_is_good_fftw2_size+0xc0>
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
ret

LLVM IR (-O0):
define i32 @my_is_good_fftw2_size(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
br label %3
3: ; preds = %7, %1
%4 = load i32, i32* %2
%5 = srem i32 %4, 2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = load i32, i32* %2
%9 = sdiv i32 %8, 2
store i32 %9, i32* %2
br label %3
10: ; preds = %3
br label %11
11: ; preds = %15, %10
%12 = load i32, i32* %2
%13 = srem i32 %12, 3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 3
store i32 %17, i32* %2
br label %11
18: ; preds = %11
br label %19
19: ; preds = %23, %18
%20 = load i32, i32* %2
%21 = srem i32 %20, 5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %2
%25 = sdiv i32 %24, 5
store i32 %25, i32* %2
br label %19
26: ; preds = %19
br label %27
27: ; preds = %31, %26
%28 = load i32, i32* %2
%29 = srem i32 %28, 7
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %2
%33 = sdiv i32 %32, 7
store i32 %33, i32* %2
br label %27
34: ; preds = %27
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 1
%37 = zext i1 %36 to i32
ret i32 %37
}

LLVM IR (-O2):
define i32 @my_is_good_fftw2_size(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %8, %1
%5 = phi i32 [ %0, %1 ], [ %10, %8 ]
%6 = srem i32 %5, 3
%7 = icmp eq i32 %6, 0
br i1 %7, label %17, label %13
8: ; preds = %1, %8
%9 = phi i32 [ %10, %8 ], [ %0, %1 ]
%10 = sdiv i32 %9, 2
%11 = and i32 %10, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %8, label %4
13: ; preds = %17, %4
%14 = phi i32 [ %5, %4 ], [ %19, %17 ]
%15 = srem i32 %14, 5
%16 = icmp eq i32 %15, 0
br i1 %16, label %26, label %22
17: ; preds = %4, %17
%18 = phi i32 [ %19, %17 ], [ %5, %4 ]
%19 = sdiv i32 %18, 3
%20 = srem i32 %19, 3
%21 = icmp eq i32 %20, 0
br i1 %21, label %17, label %13
22: ; preds = %26, %13
%23 = phi i32 [ %14, %13 ], [ %28, %26 ]
%24 = srem i32 %23, 7
%25 = icmp eq i32 %24, 0
br i1 %25, label %31, label %36
26: ; preds = %13, %26
%27 = phi i32 [ %28, %26 ], [ %14, %13 ]
%28 = sdiv i32 %27, 5
%29 = srem i32 %28, 5
%30 = icmp eq i32 %29, 0
br i1 %30, label %26, label %22
31: ; preds = %22, %31
%32 = phi i32 [ %33, %31 ], [ %23, %22 ]
%33 = sdiv i32 %32, 7
%34 = srem i32 %33, 7
%35 = icmp eq i32 %34, 0
br i1 %35, label %31, label %36
36: ; preds = %31, %22
%37 = phi i32 [ %23, %22 ], [ %33, %31 ]
%38 = icmp eq i32 %37, 1
%39 = zext i1 %38 to i32
ret i32 %39
}