#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 */
scalar_t__ isPerfact(long long, long long);
scalar_t__ isSquare(long long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
long long sqrt(long long);
int main() {
  int t, i, temp;
  long long n, denu, numa, pre, x;
  scanf("%d", &t);
  for (i = 1; i <= t; i++) {
    scanf("%lld", &n);
    temp = 0;
    x = sqrt(n - 1);
    printf("Case %d: ", i);
    while (x < n) {
      numa = x;
      denu = n - x;
      if (isSquare(denu) == 0) {
        denu = sqrt(denu);
        if (isPerfact(numa, denu) == 0) {
          if (temp > 0)
            printf(" ");
          printf("%lld", x);
          temp++;
        }
      }
      x++;
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     127d <main+0x12d>
lea    0xe78(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
sub    $0x1,%rdi
call   1070 <sqrt@plt>
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1261 <main+0x111>
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <isSquare@plt>
cmp    $0x0,%rax
jne    1250 <main+0x100>
mov    -0x20(%rbp),%rdi
call   1070 <sqrt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <isPerfact@plt>
cmp    $0x0,%rax
jne    124b <main+0xfb>
cmpl   $0x0,-0x10(%rbp)
jle    1230 <main+0xe0>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1250 <main+0x100>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11bf <main+0x6f>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <main+0x28>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    126f <main+0x10f>
mov    $0x1,%r13d
lea    0xe6a(%rip),%r14
jmp    11bc <main+0x5c>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r13),%eax
cmp    0xc(%rsp),%r13d
mov    %eax,%r13d
jge    126f <main+0x10f>
mov    %r14,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x10(%rsp),%rdi
add    $0xffffffffffffffff,%rdi
call   1080 <sqrt@plt>
mov    %rax,%r15
lea    0xe25(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%rbp
cmp    %r15,%rbp
jle    11a0 <main+0x40>
mov    %r15,%rbx
neg    %rbx
xor    %r12d,%r12d
jmp    1236 <main+0xd6>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r15
mov    0x10(%rsp),%rbp
add    $0xffffffffffffffff,%rbx
cmp    %r15,%rbp
jle    11a0 <main+0x40>
add    %rbx,%rbp
mov    %rbp,%rdi
call   1070 <isSquare@plt>
test   %rax,%rax
jne    1220 <main+0xc0>
mov    %rbp,%rdi
call   1080 <sqrt@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1050 <isPerfact@plt>
test   %rax,%rax
jne    1220 <main+0xc0>
test   %r12d,%r12d
jle    1202 <main+0xa2>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1202 <main+0xa2>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [10 x i8] c"Case %d: \00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %11
11: ; preds = %57, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %60
15: ; preds = %11
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %5)
store i32 0, i32* %4
%17 = load i64, i64* %5
%18 = sub nsw i64 %17, 1
%19 = call i64 @sqrt(i64 %18)
store i64 %19, i64* %9
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %52, %15
%23 = load i64, i64* %9
%24 = load i64, i64* %5
%25 = icmp slt i64 %23, %24
br i1 %25, label %26, label %55
26: ; preds = %22
%27 = load i64, i64* %9
store i64 %27, i64* %7
%28 = load i64, i64* %5
%29 = load i64, i64* %9
%30 = sub nsw i64 %28, %29
store i64 %30, i64* %6
%31 = load i64, i64* %6
%32 = call i64 @isSquare(i64 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %52
34: ; preds = %26
%35 = load i64, i64* %6
%36 = call i64 @sqrt(i64 %35)
store i64 %36, i64* %6
%37 = load i64, i64* %7
%38 = load i64, i64* %6
%39 = call i64 @isPerfact(i64 %37, i64 %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %51
41: ; preds = %34
%42 = load i32, i32* %4
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %41
%47 = load i64, i64* %9
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %47)
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %51
51: ; preds = %46, %34
br label %52
52: ; preds = %51, %26
%53 = load i64, i64* %9
%54 = add nsw i64 %53, 1
store i64 %54, i64* %9
br label %22
55: ; preds = %22
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %55
%58 = load i32, i32* %3
%59 = add nsw i32 %58, 1
store i32 %59, i32* %3
br label %11
60: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [10 x i8] c"Case %d: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %45, label %8
8: ; preds = %0, %40
%9 = phi i32 [ %42, %40 ], [ 1, %0 ]
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %2
%12 = add nsw i64 %11, -1
%13 = call i64 @sqrt(i64 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%15 = load i64, i64* %2
%16 = icmp sgt i64 %15, %13
br i1 %16, label %17, label %40
17: ; preds = %8, %35
%18 = phi i64 [ %38, %35 ], [ %15, %8 ]
%19 = phi i64 [ %37, %35 ], [ %13, %8 ]
%20 = phi i32 [ %36, %35 ], [ 0, %8 ]
%21 = sub nsw i64 %18, %19
%22 = call i64 @isSquare(i64 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %35
24: ; preds = %17
%25 = call i64 @sqrt(i64 %21)
%26 = call i64 @isPerfact(i64 %19, i64 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = icmp sgt i32 %20, 0
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = call i32 @putchar(i32 32)
br label %32
32: ; preds = %30, %28
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%34 = add nsw i32 %20, 1
br label %35
35: ; preds = %24, %32, %17
%36 = phi i32 [ %34, %32 ], [ %20, %24 ], [ %20, %17 ]
%37 = add nsw i64 %19, 1
%38 = load i64, i64* %2
%39 = icmp sgt i64 %38, %37
br i1 %39, label %17, label %40
40: ; preds = %35, %8
%41 = call i32 @putchar(i32 10)
%42 = add nuw nsw i32 %9, 1
%43 = load i32, i32* %1
%44 = icmp slt i32 %9, %43
br i1 %44, label %8, label %45
45: ; preds = %40, %0
ret i32 0
}