#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*/ getchar();
int /*<<< orphan*/ printQuery(int *, unsigned int);
int scanf(char *, ...);
int /*<<< orphan*/ swapQuery(int *, unsigned int, unsigned int);
scalar_t__ verifyInputNumber(int, int *);
void main(void) {
  unsigned n, k;
  int u[60] = {0};
  unsigned i;
  int buf;
  while (scanf("%u %u", &n, &k) == 2 && 0 < k && k < n && n <= 60) {
    getchar();
    for (i = 0; i < n; ++i) {
      scanf("%d", &buf);
      if (verifyInputNumber(buf, u + i)) {
        ;
      } else {
        return;
      }
    }
    swapQuery(u, k, n);
    printQuery(u, n);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0xf0,%edx
call   1040 <memset@plt>
lea    0xe7b(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
mov    %al,-0x109(%rbp)
jne    11db <main+0x7b>
xor    %eax,%eax
xor    %ecx,%ecx
cmp    -0x8(%rbp),%ecx
mov    %al,-0x109(%rbp)
jae    11db <main+0x7b>
mov    -0x8(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0x109(%rbp)
jae    11db <main+0x7b>
cmpl   $0x3c,-0x4(%rbp)
setbe  %al
mov    %al,-0x109(%rbp)
mov    -0x109(%rbp),%al
test   $0x1,%al
jne    11ee <main+0x8e>
jmp    1295 <main+0x135>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x0,-0x104(%rbp)
mov    -0x104(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    126f <main+0x10f>
lea    0xdf1(%rip),%rdi
lea    -0x108(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x108(%rbp),%edi
lea    -0x100(%rbp),%rsi
mov    -0x104(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <verifyInputNumber@plt>
cmp    $0x0,%rax
je     1251 <main+0xf1>
jmp    1256 <main+0xf6>
jmp    1295 <main+0x135>
jmp    125b <main+0xfb>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    11ff <main+0x9f>
lea    -0x100(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1080 <swapQuery@plt>
lea    -0x100(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1060 <printQuery@plt>
jmp    117e <main+0x1e>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe32(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    12b4 <main+0x164>
mov    0x8(%rsp),%eax
test   %eax,%eax
je     12b4 <main+0x164>
lea    0x10(%rsp),%r14
lea    0xe06(%rip),%rbx
lea    0xc(%rsp),%rbp
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
jae    12b4 <main+0x164>
cmp    $0x3c,%ecx
ja     12b4 <main+0x164>
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
cmpl   $0x0,0x4(%rsp)
je     1270 <main+0x120>
mov    %r14,%r13
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
mov    %r13,%rsi
call   1030 <verifyInputNumber@plt>
test   %rax,%rax
je     12b4 <main+0x164>
add    $0x1,%r12
mov    0x4(%rsp),%r15d
add    $0x4,%r13
cmp    %r15,%r12
jb     1240 <main+0xf0>
mov    0x8(%rsp),%esi
mov    %r14,%rdi
mov    %r15d,%edx
call   1070 <swapQuery@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1050 <printQuery@plt>
lea    0xd6e(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    12b4 <main+0x164>
mov    0x8(%rsp),%eax
test   %eax,%eax
jne    1205 <main+0xb5>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%u %u\00"
@.str.1 = [3 x i8] c"%d\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [60 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [60 x i32]* %3 to i8*
br label %7
7: ; preds = %43, %0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp ult i32 0, %11
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %2
%15 = load i32, i32* %1
%16 = icmp ult i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %1
%19 = icmp ule i32 %18, 60
br label %20
20: ; preds = %17, %13, %10, %7
%21 = phi i1 [ false, %13 ], [ false, %10 ], [ false, %7 ], [ %19, %17 ]
br i1 %21, label %22, label %51
22: ; preds = %20
%23 = call i32 (...) @getchar()
store i32 0, i32* %4
br label %24
24: ; preds = %40, %22
%25 = load i32, i32* %4
%26 = load i32, i32* %1
%27 = icmp ult i32 %25, %26
br i1 %27, label %28, label %43
28: ; preds = %24
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%30 = load i32, i32* %5
%31 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 0
%32 = load i32, i32* %4
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = call i64 @verifyInputNumber(i32 %30, i32* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %28
br label %39
38: ; preds = %28
br label %51
39: ; preds = %37
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add i32 %41, 1
store i32 %42, i32* %4
br label %24
43: ; preds = %24
%44 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 0
%45 = load i32, i32* %2
%46 = load i32, i32* %1
%47 = call i32 @swapQuery(i32* %44, i32 %45, i32 %46)
%48 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 0
%49 = load i32, i32* %1
%50 = call i32 @printQuery(i32* %48, i32 %49)
br label %7
51: ; preds = %38, %20
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%u %u\00"
@.str.1 = [3 x i8] c"%d\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [60 x i32]
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [60 x i32]* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%10 = icmp eq i32 %9, 2
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %14, label %49
14: ; preds = %0
%15 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 0
br label %16
16: ; preds = %14, %38
%17 = phi i32 [ %11, %14 ], [ %46, %38 ]
%18 = load i32, i32* %1
%19 = icmp ult i32 %17, %18
%20 = icmp ult i32 %18, 61
%21 = and i1 %19, %20
br i1 %21, label %22, label %49
22: ; preds = %16
%23 = call i32 (...) @getchar()
%24 = load i32, i32* %1
%25 = icmp eq i32 %24, 0
br i1 %25, label %38, label %30
26: ; preds = %30
%27 = load i32, i32* %1
%28 = zext i32 %27 to i64
%29 = icmp ult i64 %37, %28
br i1 %29, label %30, label %38
30: ; preds = %22, %26
%31 = phi i64 [ %37, %26 ], [ 0, %22 ]
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%33 = load i32, i32* %4
%34 = getelementptr inbounds [60 x i32], [60 x i32]* %3, i64 0, i64 %31
%35 = call i64 @verifyInputNumber(i32 %33, i32* %34)
%36 = icmp eq i64 %35, 0
%37 = add nuw nsw i64 %31, 1
br i1 %36, label %49, label %26
38: ; preds = %26, %22
%39 = phi i32 [ 0, %22 ], [ %27, %26 ]
%40 = load i32, i32* %2
%41 = call i32 @swapQuery(i32* %15, i32 %40, i32 %39)
%42 = load i32, i32* %1
%43 = call i32 @printQuery(i32* %15, i32 %42)
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%45 = icmp eq i32 %44, 2
%46 = load i32, i32* %2
%47 = icmp ne i32 %46, 0
%48 = select i1 %45, i1 %47, i1 false
br i1 %48, label %16, label %49
49: ; preds = %38, %16, %30, %0
ret void
}