#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*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  freopen("game.in", "r", stdin);
  freopen("game.out", "w+", stdout);
  int n, o, i, p;
  scanf("%i", &n);
  for (i = 1; i <= n; i++) {
    long long a, b;
    o = 0, p = 0;
    scanf("%lli %lli", &a, &b);
    while (a > b) {
      p++;
      a -= a / 2;
      if (!(a % 2))
        a++;
    }
    printf("Case %i: %i\n", i, p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
lea    0xeaa(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
lea    0xe98(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe91(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1243 <main+0x113>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe61(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jle    1223 <main+0xf3>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    121e <main+0xee>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11c7 <main+0x97>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1197 <main+0x67>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2ea3(%rip),%rax
mov    (%rax),%edx
lea    0xeb2(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
lea    0xea0(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe99(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    122c <main+0xfc>
mov    $0x1,%ebx
lea    0xe79(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe72(%rip),%r13
jmp    11d7 <main+0xa7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
lea    0x1(%rbx),%eax
cmp    0x4(%rsp),%ebx
mov    %eax,%ebx
jge    122c <main+0xfc>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
cmp    %rax,%rcx
jle    11c0 <main+0x90>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %rcx,%rdx
shr    $0x3f,%rdx
add    %rcx,%rdx
sar    %rdx
mov    %rcx,%rsi
sub    %rdx,%rsi
mov    %esi,%ecx
not    %ecx
and    $0x1,%ecx
add    %rsi,%rcx
cmp    %rax,%rcx
jg     1200 <main+0xd0>
mov    %rcx,0x8(%rsp)
jmp    11c0 <main+0x90>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"game.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"game.out\00"
@.str.3 = [3 x i8] c"w+\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [10 x i8] c"%lli %lli\00"
@.str.6 = [13 x i8] c"Case %i: %i\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
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @stdin
%13 = call i32 @freopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
store i32 1, i32* %8
br label %17
17: ; preds = %45, %2
%18 = load i32, i32* %8
%19 = load i32, i32* %6
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %48
21: ; preds = %17
store i32 0, i32* %7
store i32 0, i32* %9
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i64* %10, i64* %11)
br label %23
23: ; preds = %40, %21
%24 = load i64, i64* %10
%25 = load i64, i64* %11
%26 = icmp sgt i64 %24, %25
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
%30 = load i64, i64* %10
%31 = sdiv i64 %30, 2
%32 = load i64, i64* %10
%33 = sub nsw i64 %32, %31
store i64 %33, i64* %10
%34 = load i64, i64* %10
%35 = srem i64 %34, 2
%36 = icmp ne i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %27
%38 = load i64, i64* %10
%39 = add nsw i64 %38, 1
store i64 %39, i64* %10
br label %40
40: ; preds = %37, %27
br label %23
41: ; preds = %23
%42 = load i32, i32* %8
%43 = load i32, i32* %9
%44 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %42, i32 %43)
br label %45
45: ; preds = %41
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %17
48: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"game.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"game.out\00"
@.str.3 = [3 x i8] c"w+\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [10 x i8] c"%lli %lli\00"
@.str.6 = [13 x i8] c"Case %i: %i\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = load i32, i32* @stdin
%7 = tail call i32 @freopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @stdout
%9 = tail call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = bitcast i32* %3 to i8*
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 1
br i1 %13, label %40, label %14
14: ; preds = %2
%15 = bitcast i64* %4 to i8*
%16 = bitcast i64* %5 to i8*
br label %17
17: ; preds = %14, %34
%18 = phi i32 [ 1, %14 ], [ %37, %34 ]
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i64* %4, i64* %5)
%20 = load i64, i64* %5
%21 = load i64, i64* %4
%22 = icmp sgt i64 %21, %20
br i1 %22, label %23, label %34
23: ; preds = %17, %23
%24 = phi i32 [ %26, %23 ], [ 0, %17 ]
%25 = phi i64 [ %31, %23 ], [ %21, %17 ]
%26 = add nuw nsw i32 %24, 1
%27 = sdiv i64 %25, -2
%28 = add i64 %27, %25
%29 = and i64 %28, 1
%30 = xor i64 %29, 1
%31 = add nsw i64 %30, %28
%32 = icmp sgt i64 %31, %20
br i1 %32, label %23, label %33
33: ; preds = %23
store i64 %31, i64* %4
br label %34
34: ; preds = %33, %17
%35 = phi i32 [ %26, %33 ], [ 0, %17 ]
%36 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %18, i32 %35)
%37 = add nuw nsw i32 %18, 1
%38 = load i32, i32* %3
%39 = icmp slt i32 %18, %38
br i1 %39, label %17, label %40
40: ; preds = %34, %2
ret i32 0
}