int main() {
  int mem[27000] = {[0 ... 26999] = -1};
  int tc, c, n, m, k;
  scanf("%d", &tc);
  while (tc--) {
    scanf("%d %d %d %d", &c, &n, &m, &k);
    printf("%d %d\n", c, compositions(n, m, k, (int *)mem));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a610,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a5f0(%rbp),%rdi
mov    $0xff,%esi
mov    $0x1a5e0,%edx
call   1040 <memset@plt>
lea    0xe9a(%rip),%rdi
lea    -0x1a5f4(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x1a5f4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1a5f4(%rbp)
cmp    $0x0,%eax
je     1208 <main+0xc8>
lea    0xe62(%rip),%rdi
lea    -0x1a5f8(%rbp),%rsi
lea    -0x1a5fc(%rbp),%rdx
lea    -0x1a600(%rbp),%rcx
lea    -0x1a604(%rbp),%r8
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x1a5f8(%rbp),%eax
mov    %eax,-0x1a608(%rbp)
mov    -0x1a5fc(%rbp),%edi
mov    -0x1a600(%rbp),%esi
mov    -0x1a604(%rbp),%edx
lea    -0x1a5f0(%rbp),%rcx
mov    $0x0,%al
call   1050 <compositions@plt>
mov    -0x1a608(%rbp),%esi
mov    %eax,%edx
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117d <main+0x3d>
xor    %eax,%eax
add    $0x1a610,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a608,%rsp
lea    0x20(%rsp),%rdi
mov    $0x1a5e0,%edx
mov    $0xff,%esi
call   1040 <memset@plt>
lea    0xe9d(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     11ed <main+0xad>
lea    0x18(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0x20(%rsp),%rbp
lea    0xe72(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    0xe59(%rip),%rdi
lea    0x1c(%rsp),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x1c(%rsp),%r15d
mov    0x18(%rsp),%edi
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <compositions@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jae    11a0 <main+0x60>
xor    %eax,%eax
add    $0x1a608,%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 = [12 x i8] c"%d %d %d %d\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [27000 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [27000 x i32]* %2 to i8*
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %10
10: ; preds = %14, %0
%11 = load i32, i32* %3
%12 = add nsw i32 %11, -1
store i32 %12, i32* %3
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7)
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = getelementptr inbounds [27000 x i32], [27000 x i32]* %2, i64 0, i64 0
%21 = call i32 (i32, i32, i32, i32*, ...) bitcast (i32 (...)* @compositions to i32 (i32, i32, i32, i32*, ...)*)(i32 %17, i32 %18, i32 %19, i32* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %21)
br label %10
23: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [12 x i8] c"%d %d %d %d\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca [27000 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [27000 x i32]* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = add nsw i32 %14, -1
store i32 %15, i32* %2
%16 = icmp eq i32 %14, 0
br i1 %16, label %30, label %17
17: ; preds = %0
%18 = getelementptr inbounds [27000 x i32], [27000 x i32]* %1, i64 0, i64 0
br label %19
19: ; preds = %17, %19
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 (i32, i32, i32, i32*, ...) bitcast (i32 (...)* @compositions to i32 (i32, i32, i32, i32*, ...)*)(i32 %22, i32 %23, i32 %24, i32* %18)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %25)
%27 = load i32, i32* %2
%28 = add nsw i32 %27, -1
store i32 %28, i32* %2
%29 = icmp eq i32 %27, 0
br i1 %29, label %30, label %19
30: ; preds = %19, %0
ret i32 0
}