int main(int argc, char *argv[]) {
  int index = 1, n, print;
  while (~scanf("%d", &n) && n != -1) {
    if (n <= 0 || n >= 1001)
      return 1;
    print = ceil(log2(n));
    printf("Case %d¡G %d\n", index++, print);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,%ecx
xor    $0xffffffff,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     118c <main+0x4c>
cmpl   $0xffffffff,-0x18(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    119c <main+0x5c>
jmp    11f6 <main+0xb6>
cmpl   $0x0,-0x18(%rbp)
jle    11b3 <main+0x73>
cmpl   $0x3e9,-0x18(%rbp)
jl     11bf <main+0x7f>
movl   $0x1,-0x4(%rbp)
jmp    11fd <main+0xbd>
cvtsi2sdl -0x18(%rbp),%xmm0
call   1030 <log2@plt>
call   1040 <ceil@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%edx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    115d <main+0x1d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0xffffffff,%eax
je     11e4 <main+0xa4>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     11e4 <main+0xa4>
lea    0xe8d(%rip),%r14
lea    0xe83(%rip),%r15
lea    0xc(%rsp),%r12
mov    $0x1,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    -0x3e9(%rax),%ecx
cmp    $0xfffffc18,%ecx
jb     11df <main+0x9f>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1030 <log2@plt>
call   1040 <ceil@plt>
cvttsd2si %xmm0,%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0xffffffff,%eax
je     11e4 <main+0xa4>
add    $0x1,%ebp
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
jne    1190 <main+0x50>
jmp    11e4 <main+0xa4>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [15 x i8] c"Case %d\C2\A1G %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %25, %2
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%11 = xor i32 %10, -1
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, -1
br label %16
16: ; preds = %13, %9
%17 = phi i1 [ false, %9 ], [ %15, %13 ]
br i1 %17, label %18, label %35
18: ; preds = %16
%19 = load i32, i32* %7
%20 = icmp sle i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %7
%23 = icmp sge i32 %22, 1001
br i1 %23, label %24, label %25
24: ; preds = %21, %18
store i32 1, i32* %3
br label %36
25: ; preds = %21
%26 = load i32, i32* %7
%27 = sitofp i32 %26 to double
%28 = call double @log2(double %27)
%29 = call double @llvm.ceil.f64(double %28)
%30 = fptosi double %29 to i32
store i32 %30, i32* %8
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
%33 = load i32, i32* %8
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %33)
br label %9
35: ; preds = %16
store i32 0, i32* %3
br label %36
36: ; preds = %35, %24
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [15 x i8] c"Case %d\C2\A1G %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = icmp ne i32 %5, -1
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, -1
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %27
10: ; preds = %2, %15
%11 = phi i32 [ %24, %15 ], [ %7, %2 ]
%12 = phi i32 [ %20, %15 ], [ 1, %2 ]
%13 = add i32 %11, -1001
%14 = icmp ult i32 %13, -1000
br i1 %14, label %27, label %15
15: ; preds = %10
%16 = sitofp i32 %11 to double
%17 = call double @log2(double %16)
%18 = call double @llvm.ceil.f64(double %17)
%19 = fptosi double %18 to i32
%20 = add nuw nsw i32 %12, 1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %19)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%23 = icmp ne i32 %22, -1
%24 = load i32, i32* %3
%25 = icmp ne i32 %24, -1
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %10, label %27
27: ; preds = %10, %15, %2
%28 = phi i32 [ 0, %2 ], [ 0, %15 ], [ 1, %10 ]
ret i32 %28
}