#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*/ printf(char *, char);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n, count = 0, i, s, s1;
  char str[100];
  scanf("%s", str);
  scanf("%d", &n);
  count = 0;
  while (str[count] != '\0')
    count++;
  n = n % count;
  for (int i = 0; i < count; i++) {
    if (i + n < count)
      printf("%c", str[count - i + n]);
    else
      printf("%c", str[count - (i + n) % count]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x80(%rbp),%rsi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1184 <main+0x64>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x44>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x8(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1227 <main+0x107>
mov    -0x84(%rbp),%eax
add    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dd <main+0xbd>
mov    -0xc(%rbp),%eax
sub    -0x84(%rbp),%eax
add    -0x8(%rbp),%eax
cltq
lea    0xe38(%rip),%rdi
movsbl -0x80(%rbp,%rax,1),%esi
call   1030 <printf@plt>
jmp    120e <main+0xee>
mov    -0xc(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x84(%rbp),%eax
add    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    -0x88(%rbp),%eax
sub    %edx,%eax
cltq
lea    0xe02(%rip),%rdi
movsbl -0x80(%rbp,%rax,1),%esi
call   1030 <printf@plt>
jmp    1213 <main+0xf3>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1198 <main+0x78>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
lea    0xeca(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xeb7(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    $0x2,%ebp
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%ebp
add    $0xffffffff,%ecx
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <main+0x50>
mov    %ecx,%r15d
neg    %r15d
mov    0xc(%rsp),%eax
cltd
idiv   %r15d
mov    %edx,0xc(%rsp)
test   %ecx,%ecx
je     11ed <main+0xcd>
neg    %ebp
xor    %ebx,%ebx
lea    0xe66(%rip),%r14
mov    %r15d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%rdx,%rbx,1),%eax
cmp    %r15d,%eax
jge    11c0 <main+0xa0>
add    %r12d,%edx
jmp    11cb <main+0xab>
nopl   (%rax)
cltd
idiv   %r15d
mov    %edx,%eax
mov    %r15d,%edx
sub    %eax,%edx
movslq %edx,%rax
movsbl 0x10(%rsp,%rax,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
sub    $0x1,%ebp
jb     11ed <main+0xcd>
mov    0xc(%rsp),%edx
add    $0xffffffff,%r12d
add    $0x1,%ebx
jmp    11b0 <main+0x90>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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