#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 */
unsigned long long ceil(double);
int /*<<< orphan*/ printf(char *, int, unsigned long long);
scalar_t__ scanf(char *, unsigned long long *);
double sqrt(double);
int main() {
  unsigned long long N, n;
  int count;
  count = 0;
  while (scanf("%llu\n", &N) && N != 0) {
    n = ceil((3.0 + sqrt(9.0 + 8.0 * N)) / 2.0);
    printf("Case %d: %llu\n", ++count, n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeec(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
je     1183 <main+0x43>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1193 <main+0x53>
jmp    1219 <main+0xd9>
movaps 0xe86(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe85(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe4e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe4a(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe26(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe12(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
mov    -0x18(%rbp),%rdx
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
jmp    1156 <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    0xf02(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     1227 <main+0xe7>
mov    (%rsp),%rax
test   %rax,%rax
je     1227 <main+0xe7>
mov    $0x1,%ebx
lea    0xecf(%rip),%r14
lea    0xed1(%rip),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movq   %rax,%xmm1
punpckldq 0xe63(%rip),%xmm1
subpd  0xe6b(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe67(%rip),%xmm0
addsd  0xe67(%rip),%xmm0
ucomisd 0xe77(%rip),%xmm0
jb     11e0 <main+0xa0>
sqrtsd %xmm0,%xmm0
jmp    11e5 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1060 <sqrt@plt>
addsd  0xe43(%rip),%xmm0
mulsd  0xe43(%rip),%xmm0
call   1030 <ceil@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     1227 <main+0xe7>
add    $0x1,%ebx
mov    (%rsp),%rax
test   %rax,%rax
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%llu\0A\00"
@.str.1 = [15 x i8] c"Case %d: %llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %13, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i64, i64* %2
%10 = icmp ne i64 %9, 0
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ false, %5 ], [ %10, %8 ]
br i1 %12, label %13, label %25
13: ; preds = %11
%14 = load i64, i64* %2
%15 = uitofp i64 %14 to double
%16 = call double @llvm.fmuladd.f64(double 8.000000e+00, double %15, double 9.000000e+00)
%17 = call double @sqrt(double %16)
%18 = fadd double 3.000000e+00, %17
%19 = fdiv double %18, 2.000000e+00
%20 = call i64 @ceil(double %19)
store i64 %20, i64* %3
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = load i64, i64* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %22, i64 %23)
br label %5
25: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%llu\0A\00"
@.str.1 = [15 x i8] c"Case %d: %llu\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = icmp ne i64 %3, 0
%5 = load i64, i64* %1
%6 = icmp ne i64 %5, 0
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %8, label %24
8: ; preds = %0, %8
%9 = phi i64 [ %21, %8 ], [ %5, %0 ]
%10 = phi i32 [ %17, %8 ], [ 0, %0 ]
%11 = uitofp i64 %9 to double
%12 = call double @llvm.fmuladd.f64(double %11, double 8.000000e+00, double 9.000000e+00)
%13 = call double @sqrt(double %12)
%14 = fadd double %13, 3.000000e+00
%15 = fmul double %14, 5.000000e-01
%16 = call i64 @ceil(double %15)
%17 = add nuw nsw i32 %10, 1
%18 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %17, i64 %16)
%19 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %1)
%20 = icmp ne i64 %19, 0
%21 = load i64, i64* %1
%22 = icmp ne i64 %21, 0
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %8, label %24
24: ; preds = %8, %0
ret i32 0
}