#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, long long);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int t, n, k, x, j;
  long long i, sum;
  scanf("%d", &t);
  for (j = 1; j <= t; j++) {
    scanf("%d %d %d", &n, &k, &x);
    sum = 0;
    for (i = 1; i <= n; i++) {
      if (i == x) {
        i += k - 1;
        continue;
      }
      sum += i;
    }
    printf("Case %d: %lld\n", j, sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11f3 <main+0xd3>
lea    0xea5(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x0,-0x28(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jg     11d2 <main+0xb2>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jne    11b5 <main+0x95>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11c1 <main+0xa1>
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    117e <main+0x5e>
mov    -0x18(%rbp),%esi
mov    -0x28(%rbp),%rdx
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1148 <main+0x28>
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
lea    0xed1(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11fb <main+0xdb>
mov    $0x1,%r12d
xor    %r14d,%r14d
lea    0xc(%rsp),%r13
lea    0xea8(%rip),%r15
jmp    118c <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edx,%edx
mov    %r15,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
lea    0x1(%r12),%eax
cmp    0x8(%rsp),%r12d
mov    %eax,%r12d
jge    11fb <main+0xdb>
lea    0xe6d(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
movslq 0x14(%rsp),%r8
test   %r8,%r8
jle    1170 <main+0x50>
movslq 0xc(%rsp),%rcx
movslq 0x10(%rsp),%rsi
add    $0xffffffffffffffff,%rsi
mov    $0x1,%edi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
cmp    %rcx,%rdi
mov    $0x0,%ebp
cmove  %rsi,%rbp
mov    %rdi,%rbx
cmove  %r14,%rbx
lea    (%rdi,%rbp,1),%rax
add    %rbx,%rdx
add    %rbp,%rdi
add    $0x1,%rdi
cmp    %r8,%rax
jl     11d0 <main+0xb0>
jmp    1172 <main+0x52>
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 = [9 x i8] c"%d %d %d\00"
@.str.2 = [15 x i8] c"Case %d: %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %6
br label %10
10: ; preds = %43, %0
%11 = load i32, i32* %6
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %46
14: ; preds = %10
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
store i64 0, i64* %8
store i64 1, i64* %7
br label %16
16: ; preds = %36, %14
%17 = load i64, i64* %7
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = icmp sle i64 %17, %19
br i1 %20, label %21, label %39
21: ; preds = %16
%22 = load i64, i64* %7
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = icmp eq i64 %22, %24
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = load i64, i64* %7
%31 = add nsw i64 %30, %29
store i64 %31, i64* %7
br label %36
32: ; preds = %21
%33 = load i64, i64* %7
%34 = load i64, i64* %8
%35 = add nsw i64 %34, %33
store i64 %35, i64* %8
br label %36
36: ; preds = %32, %26
%37 = load i64, i64* %7
%38 = add nsw i64 %37, 1
store i64 %38, i64* %7
br label %16
39: ; preds = %16
%40 = load i32, i32* %6
%41 = load i64, i64* %8
%42 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %40, i64 %41)
br label %43
43: ; preds = %39
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %10
46: ; preds = %10
ret i32 0
}

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