#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 *, int /*<<< orphan*/, int);
int scanf(char *, int *);
int main() {
  int n, j, i = 1, temp, mod;
  while (scanf("%d", &n) == 1) {
    if (n < 0)
      break;
    j = 0, mod = 0;
    while (n > 1) {
      temp = n / 2;
      mod = n % 2;
      n = temp + mod;
      j++;
    }
    printf("Case %d: %d\n", i++, j);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11c8 <main+0xa8>
cmpl   $0x0,-0x8(%rbp)
jge    115e <main+0x3e>
jmp    11c8 <main+0xa8>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11a9 <main+0x89>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116c <main+0x4c>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edx
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11aa <main+0x8a>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     11aa <main+0x8a>
mov    $0x1,%ebx
lea    0xeb1(%rip),%r14
lea    0xea7(%rip),%r15
lea    0x4(%rsp),%r12
xchg   %ax,%ax
xor    %edx,%edx
cmp    $0x2,%eax
jb     1185 <main+0x65>
xor    %edx,%edx
nopl   0x0(%rax)
mov    %eax,%ecx
shr    %ecx
and    $0x1,%eax
add    %ecx,%eax
add    $0x1,%edx
cmp    $0x1,%eax
ja     1170 <main+0x50>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11aa <main+0x8a>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
test   %eax,%eax
jns    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [13 x i8] c"Case %d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
br label %7
7: ; preds = %28, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %33
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
br label %33
14: ; preds = %10
store i32 0, i32* %3
store i32 0, i32* %6
br label %15
15: ; preds = %18, %14
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 2
store i32 %20, i32* %5
%21 = load i32, i32* %2
%22 = srem i32 %21, 2
store i32 %22, i32* %6
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = add nsw i32 %23, %24
store i32 %25, i32* %2
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %15
28: ; preds = %15
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
%31 = load i32, i32* %3
%32 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %31)
br label %7
33: ; preds = %13, %7
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [13 x i8] c"Case %d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp ne i32 %3, 1
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 0
%7 = select i1 %4, i1 true, i1 %6
br i1 %7, label %30, label %8
8: ; preds = %0, %21
%9 = phi i32 [ %27, %21 ], [ %5, %0 ]
%10 = phi i32 [ %23, %21 ], [ 1, %0 ]
%11 = icmp ugt i32 %9, 1
br i1 %11, label %12, label %21
12: ; preds = %8, %12
%13 = phi i32 [ %18, %12 ], [ 0, %8 ]
%14 = phi i32 [ %17, %12 ], [ %9, %8 ]
%15 = lshr i32 %14, 1
%16 = and i32 %14, 1
%17 = add nuw nsw i32 %15, %16
%18 = add nuw nsw i32 %13, 1
%19 = icmp ugt i32 %17, 1
br i1 %19, label %12, label %20
20: ; preds = %12
store i32 %17, i32* %1
br label %21
21: ; preds = %20, %8
%22 = phi i32 [ %18, %20 ], [ 0, %8 ]
%23 = add nuw nsw i32 %10, 1
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %22)
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%26 = icmp ne i32 %25, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %27, 0
%29 = select i1 %26, i1 true, i1 %28
br i1 %29, label %30, label %8
30: ; preds = %21, %0
ret i32 0
}