#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*/ get_min_time(int *, int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int cases;
  scanf("%d", &cases);
  for (int i = 1; i <= cases; ++i) {
    int len, mark;
    scanf("%d %d", &len, &mark);
    int arr[len];
    for (int pos = 0; pos < len; ++pos)
      scanf("%d", &arr[pos]);
    get_min_time(arr, len, mark);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1030 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11f3 <main+0xd3>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11cf <main+0xaf>
mov    -0x38(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1198 <main+0x78>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <get_min_time@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1148 <main+0x28>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
cmpl   $0x0,-0x30(%rbp)
jle    11e7 <main+0xc7>
mov    $0x1,%r15d
lea    0xea9(%rip),%rbx
jmp    117b <main+0x5b>
nopl   0x0(%rax)
mov    -0x34(%rbp),%edx
mov    %r14,%rdi
call   1040 <get_min_time@plt>
mov    %r12,%rsp
lea    0x1(%r15),%eax
cmp    -0x30(%rbp),%r15d
mov    %eax,%r15d
jge    11e7 <main+0xc7>
lea    0xe7e(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x34(%rbp),%rdx
xor    %eax,%eax
call   1030 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    1160 <main+0x40>
mov    %r12,-0x40(%rbp)
mov    %r14,%r13
xor    %r12d,%r12d
nopl   (%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rsi
add    $0x4,%r13
cmp    %rsi,%r12
jl     11c0 <main+0xa0>
mov    -0x40(%rbp),%r12
jmp    1160 <main+0x40>
xor    %eax,%eax
lea    -0x28(%rbp),%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 = [6 x i8] c"%d %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
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* %3
br label %10
10: ; preds = %37, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %40
14: ; preds = %10
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%16 = load i32, i32* %4
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %6
%19 = alloca i32, i64 %17
store i64 %17, i64* %7
store i32 0, i32* %8
br label %20
20: ; preds = %29, %14
%21 = load i32, i32* %8
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %19, i64 %26
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %27)
br label %29
29: ; preds = %24
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %20
32: ; preds = %20
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = call i32 @get_min_time(i32* %19, i32 %33, i32 %34)
%36 = load i8*, i8** %6
br label %37
37: ; preds = %32
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %10
40: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = call i32 (i8*, i32*, ...) @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 %11, label %8
8: ; preds = %0
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
br label %12
11: ; preds = %21, %0
ret i32 0
12: ; preds = %8, %21
%13 = phi i32 [ 1, %8 ], [ %25, %21 ]
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%15 = load i32, i32* %2
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
%18 = alloca i32, i64 %16
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %28, %12
%22 = phi i32 [ %19, %12 ], [ %33, %28 ]
%23 = load i32, i32* %3
%24 = call i32 @get_min_time(i32* %18, i32 %22, i32 %23)
%25 = add nuw nsw i32 %13, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %13, %26
br i1 %27, label %12, label %11
28: ; preds = %12, %28
%29 = phi i64 [ %32, %28 ], [ 0, %12 ]
%30 = getelementptr inbounds i32, i32* %18, i64 %29
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %30)
%32 = add nuw nsw i64 %29, 1
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %28, label %21
}