#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ reverse(int *, int, int);
int scanf(char *, int *, ...);
int main(int argc, char *argv[]) {
  int n, m;
  if (scanf("%d%d", &n, &m) != 2)
    return EXIT_FAILURE;
  int nums[n];
  for (int i = 0; i < n; i++) {
    if (scanf("%d", &nums[i]) != 1)
      return EXIT_FAILURE;
  }
  m = m % n;
  reverse(nums, 0, n);
  reverse(nums, 0, m);
  reverse(nums, m, n);
  for (int i = 0; i < n; i++) {
    printf("%d%s", nums[i], i == n - 1 ? "" : " ");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x2,%eax
je     1176 <main+0x46>
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a5 <main+0x175>
mov    -0x14(%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,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1201 <main+0xd1>
mov    -0x40(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     11ee <main+0xbe>
mov    0x2e03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    129e <main+0x16e>
jmp    11f3 <main+0xc3>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a4 <main+0x74>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1030 <reverse@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%edx
xor    %esi,%esi
call   1030 <reverse@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <reverse@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128b <main+0x15b>
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x34(%rbp),%ecx
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
lea    0xda6(%rip),%rdx
lea    0xda0(%rip),%rax
cmp    %edi,%ecx
cmove  %rax,%rdx
lea    0xd8d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    123d <main+0x10d>
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%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    0xeb8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    1243 <main+0x113>
mov    %rsp,%r13
mov    -0x2c(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
jle    11b7 <main+0x87>
lea    0xe79(%rip),%r14
mov    %r15,%r12
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    124e <main+0x11e>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rcx
add    $0x4,%r12
cmp    %rcx,%rbx
jl     1190 <main+0x60>
mov    -0x30(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
mov    %r15,%rdi
xor    %esi,%esi
mov    %ecx,%edx
call   1030 <reverse@plt>
mov    -0x30(%rbp),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <reverse@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    %r15,%rdi
call   1030 <reverse@plt>
mov    -0x2c(%rbp),%eax
mov    0x2de7(%rip),%rcx
test   %eax,%eax
jle    1255 <main+0x125>
mov    %r13,-0x38(%rbp)
xor    %ebx,%ebx
lea    0xe09(%rip),%r12
lea    0xe01(%rip),%r13
lea    0xdf5(%rip),%r14
mov    (%r15,%rbx,4),%esi
add    $0xffffffff,%eax
cmp    %rax,%rbx
mov    %r13,%rdx
cmove  %r12,%rdx
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1210 <main+0xe0>
mov    -0x38(%rbp),%r13
mov    0x2d97(%rip),%rcx
jmp    1255 <main+0x125>
mov    0x2d96(%rip),%rax
mov    (%rax),%eax
jmp    125a <main+0x12a>
mov    0x2d8b(%rip),%rcx
mov    (%rcx),%eax
mov    %r13,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%d%s\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c" \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %7)
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %72
17: ; preds = %2
%18 = load i32, i32* %6
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %8
%21 = alloca i32, i64 %19
store i64 %19, i64* %9
store i32 0, i32* %10
br label %22
22: ; preds = %35, %17
%23 = load i32, i32* %10
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %21, i64 %28
%30 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
%31 = icmp ne i32 %30, 1
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = load i32, i32* @EXIT_FAILURE
store i32 %33, i32* %3
store i32 1, i32* %11
br label %70
34: ; preds = %26
br label %35
35: ; preds = %34
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
br label %22
38: ; preds = %22
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = srem i32 %39, %40
store i32 %41, i32* %7
%42 = load i32, i32* %6
%43 = call i32 @reverse(i32* %21, i32 0, i32 %42)
%44 = load i32, i32* %7
%45 = call i32 @reverse(i32* %21, i32 0, i32 %44)
%46 = load i32, i32* %7
%47 = load i32, i32* %6
%48 = call i32 @reverse(i32* %21, i32 %46, i32 %47)
store i32 0, i32* %12
br label %49
49: ; preds = %65, %38
%50 = load i32, i32* %12
%51 = load i32, i32* %6
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %68
53: ; preds = %49
%54 = load i32, i32* %12
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %21, i64 %55
%57 = load i32, i32* %56
%58 = load i32, i32* %12
%59 = load i32, i32* %6
%60 = sub nsw i32 %59, 1
%61 = icmp eq i32 %58, %60
%62 = zext i1 %61 to i64
%63 = select i1 %61, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%64 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %57, i8* %63)
br label %65
65: ; preds = %53
%66 = load i32, i32* %12
%67 = add nsw i32 %66, 1
store i32 %67, i32* %12
br label %49
68: ; preds = %49
%69 = load i32, i32* @EXIT_SUCCESS
store i32 %69, i32* %3
store i32 1, i32* %11
br label %70
70: ; preds = %68, %32
%71 = load i8*, i8** %8
br label %72
72: ; preds = %70, %15
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%d%s\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c" \00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%8 = icmp eq i32 %7, 2
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = load i32, i32* @EXIT_FAILURE
br label %57
11: ; preds = %2
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
%15 = alloca i32, i64 %13
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 0
br i1 %17, label %22, label %28
18: ; preds = %22
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %27, %20
br i1 %21, label %22, label %28
22: ; preds = %11, %18
%23 = phi i64 [ %27, %18 ], [ 0, %11 ]
%24 = getelementptr inbounds i32, i32* %15, i64 %23
%25 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
%26 = icmp eq i32 %25, 1
%27 = add nuw nsw i64 %23, 1
br i1 %26, label %18, label %54
28: ; preds = %18, %11
%29 = phi i32 [ %16, %11 ], [ %19, %18 ]
%30 = load i32, i32* %4
%31 = srem i32 %30, %29
store i32 %31, i32* %4
%32 = call i32 @reverse(i32* %15, i32 0, i32 %29)
%33 = load i32, i32* %4
%34 = call i32 @reverse(i32* %15, i32 0, i32 %33)
%35 = load i32, i32* %4
%36 = load i32, i32* %3
%37 = call i32 @reverse(i32* %15, i32 %35, i32 %36)
%38 = load i32, i32* %3
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %54
40: ; preds = %28, %40
%41 = phi i64 [ %50, %40 ], [ 0, %28 ]
%42 = phi i32 [ %51, %40 ], [ %38, %28 ]
%43 = getelementptr inbounds i32, i32* %15, i64 %41
%44 = load i32, i32* %43
%45 = add nsw i32 %42, -1
%46 = zext i32 %45 to i64
%47 = icmp eq i64 %41, %46
%48 = select i1 %47, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%49 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %44, i8* %48)
%50 = add nuw nsw i64 %41, 1
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = icmp slt i64 %50, %52
br i1 %53, label %40, label %54
54: ; preds = %22, %40, %28
%55 = phi i32* [ @EXIT_SUCCESS, %28 ], [ @EXIT_SUCCESS, %40 ], [ @EXIT_FAILURE, %22 ]
%56 = load i32, i32* %55
br label %57
57: ; preds = %54, %9
%58 = phi i32 [ %10, %9 ], [ %56, %54 ]
ret i32 %58
}