#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 */
long *malloc(int);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ scanf(char *, long *, ...);
int main() {
  long int n, r;
  scanf("%ld %ld", &n, &r);
  long int *arr = malloc(sizeof(long int) * n);
  for (int i = 0; i < n; i++) {
    scanf("%ld", &arr[i]);
  }
  for (int i = 0; i < n; i++) {
    printf("%ld ", arr[(i + r) % n]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11a8 <main+0x78>
mov    -0x20(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116f <main+0x3f>
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11f5 <main+0xc5>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
movslq -0x28(%rbp),%rax
add    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax,%rdx,8),%rsi
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11af <main+0x7f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebe(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%rbx
lea    0x0(,%rbx,8),%edi
call   1040 <malloc@plt>
test   %rbx,%rbx
jle    11e9 <main+0xb9>
mov    %rax,%r15
lea    0xe8d(%rip),%r14
mov    %rax,%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%rcx
add    $0x8,%r12
cmp    %rbx,%rcx
jg     1180 <main+0x50>
test   %rcx,%rcx
jle    11e9 <main+0xb9>
xor    %ebx,%ebx
lea    0xe5b(%rip),%r14
jmp    11cf <main+0x9f>
nop
cqto
idiv   %rcx
mov    (%r15,%rdx,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%rcx
cmp    %rbx,%rcx
jle    11e9 <main+0xb9>
mov    0x10(%rsp),%rax
add    %rbx,%rax
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    11b0 <main+0x80>
xor    %edx,%edx
div    %ecx
jmp    11b5 <main+0x85>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%ld %ld\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [5 x i8] c"%ld \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %2, i64* %3)
%8 = load i64, i64* %2
%9 = mul i64 8, %8
%10 = trunc i64 %9 to i32
%11 = call i64* @malloc(i32 %10)
store i64* %11, i64** %4
store i32 0, i32* %5
br label %12
12: ; preds = %23, %0
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = load i64, i64* %2
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %12
%18 = load i64*, i64** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i64, i64* %18, i64 %20
%22 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %12
26: ; preds = %12
store i32 0, i32* %6
br label %27
27: ; preds = %43, %26
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = load i64, i64* %2
%31 = icmp slt i64 %29, %30
br i1 %31, label %32, label %46
32: ; preds = %27
%33 = load i64*, i64** %4
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = load i64, i64* %3
%37 = add nsw i64 %35, %36
%38 = load i64, i64* %2
%39 = srem i64 %37, %38
%40 = getelementptr inbounds i64, i64* %33, i64 %39
%41 = load i64, i64* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %41)
br label %43
43: ; preds = %32
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %27
46: ; preds = %27
ret i32 0
}

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