#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 */
scalar_t__ EOF;
int INT_MAX;
int ceil(double);
int floor(int);
int log10(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, unsigned long *);
int main() {
  unsigned long n;
  double lower, upper;
  int num_digits, i;
  int found, E;
  while (scanf("%lu\n", &n) != EOF) {
    num_digits = floor(log10(n)) + 1;
    found = 0;
    for (i = num_digits + 1; i <= INT_MAX; i++) {
      upper = (log10(n + 1) + i) / log10(2);
      lower = (log10(n) + i) / log10(2);
      if ((E = ceil(lower)) <= upper) {
        found = 1;
        break;
      }
    }
    if (found) {
      printf("%d\n", E);
    } else {
      printf("no power of 2\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%rax
je     1287 <main+0x137>
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1060 <log10@plt>
mov    %eax,%edi
call   1070 <floor@plt>
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    0x2e37(%rip),%rcx
cmp    (%rcx),%eax
jg     1254 <main+0x104>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %eax,%edi
call   1060 <log10@plt>
add    -0x28(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    $0x2,%edi
call   1060 <log10@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1060 <log10@plt>
add    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x2,%edi
call   1060 <log10@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x30(%rbp)
cvtsi2sd %eax,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1241 <main+0xf1>
movl   $0x1,-0x2c(%rbp)
jmp    1254 <main+0x104>
jmp    1246 <main+0xf6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a7 <main+0x57>
cmpl   $0x0,-0x2c(%rbp)
je     1274 <main+0x124>
mov    -0x30(%rbp),%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1282 <main+0x132>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115f <main+0xf>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    0x2e5f(%rip),%r14
cmp    (%r14),%rax
jne    1197 <main+0x37>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e4a(%rip),%r15
mov    %rsp,%r13
jmp    11d0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
cmp    (%r14),%rax
je     1186 <main+0x26>
mov    (%rsp),%edi
call   1070 <log10@plt>
mov    %eax,%edi
call   1080 <floor@plt>
mov    %eax,%ebx
add    $0x2,%ebx
cmp    (%r15),%ebx
jg     11b0 <main+0x50>
nopl   0x0(%rax)
mov    (%rsp),%edi
add    $0x1,%edi
call   1070 <log10@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    $0x2,%edi
call   1070 <log10@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%ebp
mov    (%rsp),%edi
call   1070 <log10@plt>
mov    %eax,%r12d
add    %ebx,%r12d
mov    $0x2,%edi
call   1070 <log10@plt>
mov    %eax,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1040 <ceil@plt>
cmp    %ebp,%eax
jle    1260 <main+0x100>
lea    0x1(%rbx),%eax
cmp    (%r15),%ebx
mov    %eax,%ebx
jl     11f0 <main+0x90>
jmp    11b0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd9e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11bc <main+0x5c>

LLVM IR (-O0):
@.str = [5 x i8] c"%lu\0A\00"
@EOF = global i64 0
@INT_MAX = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [15 x i8] c"no power of 2\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
br label %9
9: ; preds = %61, %0
%10 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %62
13: ; preds = %9
%14 = load i64, i64* %2
%15 = trunc i64 %14 to i32
%16 = call i32 @log10(i32 %15)
%17 = call i32 @floor(i32 %16)
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
store i32 0, i32* %7
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %21
21: ; preds = %50, %13
%22 = load i32, i32* %6
%23 = load i32, i32* @INT_MAX
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %53
25: ; preds = %21
%26 = load i64, i64* %2
%27 = add i64 %26, 1
%28 = trunc i64 %27 to i32
%29 = call i32 @log10(i32 %28)
%30 = load i32, i32* %6
%31 = add nsw i32 %29, %30
%32 = call i32 @log10(i32 2)
%33 = sdiv i32 %31, %32
%34 = sitofp i32 %33 to double
store double %34, double* %4
%35 = load i64, i64* %2
%36 = trunc i64 %35 to i32
%37 = call i32 @log10(i32 %36)
%38 = load i32, i32* %6
%39 = add nsw i32 %37, %38
%40 = call i32 @log10(i32 2)
%41 = sdiv i32 %39, %40
%42 = sitofp i32 %41 to double
store double %42, double* %3
%43 = load double, double* %3
%44 = call i32 @ceil(double %43)
store i32 %44, i32* %8
%45 = sitofp i32 %44 to double
%46 = load double, double* %4
%47 = fcmp ole double %45, %46
br i1 %47, label %48, label %49
48: ; preds = %25
store i32 1, i32* %7
br label %53
49: ; preds = %25
br label %50
50: ; preds = %49
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %21
53: ; preds = %48, %21
%54 = load i32, i32* %7
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i32, i32* %8
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %57)
br label %61
59: ; preds = %53
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %61
61: ; preds = %59, %56
br label %9
62: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lu\0A\00"
@EOF = global i64 0
@INT_MAX = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [14 x i8] c"no power of 2\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %44, label %6
6: ; preds = %0, %40
%7 = load i64, i64* %1
%8 = trunc i64 %7 to i32
%9 = call i32 @log10(i32 %8)
%10 = call i32 @floor(i32 %9)
%11 = add nsw i32 %10, 2
%12 = load i32, i32* @INT_MAX
%13 = icmp sgt i32 %11, %12
br i1 %13, label %38, label %18
14: ; preds = %18
%15 = add nsw i32 %19, 1
%16 = load i32, i32* @INT_MAX
%17 = icmp slt i32 %19, %16
br i1 %17, label %18, label %38
18: ; preds = %6, %14
%19 = phi i32 [ %15, %14 ], [ %11, %6 ]
%20 = load i64, i64* %1
%21 = trunc i64 %20 to i32
%22 = add i32 %21, 1
%23 = call i32 @log10(i32 %22)
%24 = add nsw i32 %23, %19
%25 = call i32 @log10(i32 2)
%26 = sdiv i32 %24, %25
%27 = load i64, i64* %1
%28 = trunc i64 %27 to i32
%29 = call i32 @log10(i32 %28)
%30 = add nsw i32 %29, %19
%31 = call i32 @log10(i32 2)
%32 = sdiv i32 %30, %31
%33 = sitofp i32 %32 to double
%34 = call i32 @ceil(double %33)
%35 = icmp sgt i32 %34, %26
br i1 %35, label %14, label %36
36: ; preds = %18
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %40
38: ; preds = %14, %6
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
%41 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%42 = load i64, i64* @EOF
%43 = icmp eq i64 %41, %42
br i1 %43, label %44, label %6
44: ; preds = %40, %0
ret i32 0
}