#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 */
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, ...);
int scanf(char *, int *, int *);
int solve(int, int);
int main() {
  int64_t a, limit;
  int64_t round = 0;
  int64_t ans;
  while (scanf("%ld%ld", &a, &limit), a != -1 && limit != -1) {
    printf("Case %ld: A = %ld, limit = %ld, number of terms = ", ++round, a,
           limit);
    ans = solve(a, limit);
    printf("%ld\n", ans);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
xor    %eax,%eax
cmpl   $0xffffffff,-0x8(%rbp)
mov    %al,-0x15(%rbp)
je     1173 <main+0x43>
cmpl   $0xffffffff,-0xc(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1183 <main+0x53>
jmp    11c4 <main+0x94>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <solve@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
cmp    $0xffffffff,%edx
je     11d6 <main+0xa6>
mov    (%rsp),%ecx
cmp    $0xffffffff,%ecx
je     11d6 <main+0xa6>
mov    $0x1,%ebx
lea    0xe9b(%rip),%r14
lea    0xec7(%rip),%r15
lea    0xe86(%rip),%r12
lea    0x4(%rsp),%r13
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1030 <solve@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
cmp    $0xffffffff,%edx
je     11d6 <main+0xa6>
add    $0x1,%ebx
mov    (%rsp),%ecx
cmp    $0xffffffff,%ecx
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%ld%ld\00"
@.str.1 = [51 x i8] c"Case %ld: A = %ld, limit = %ld, number of terms = \00"
@.str.2 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %15, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, -1
br label %13
13: ; preds = %10, %6
%14 = phi i1 [ false, %6 ], [ %12, %10 ]
br i1 %14, label %15, label %26
15: ; preds = %13
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call i32 @solve(i32 %21, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %6
26: ; preds = %13
ret i32 0
}

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