#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 read(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char a[100];
  int m, n;
  int i, j;
  scanf("%s", a);
  scanf("%d", &n);
  m = read(a);
  n = n % m;
  for (i = m - n; i < m; i++) {
    printf("%c", a[i]);
  }
  for (j = 0; j < m - n; j++) {
    printf("%c", a[j]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xea8(%rip),%rdi
lea    -0x78(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <read@plt>
mov    %eax,-0x74(%rbp)
mov    -0x78(%rbp),%eax
cltd
idivl  -0x74(%rbp)
mov    %edx,-0x78(%rbp)
mov    -0x74(%rbp),%eax
sub    -0x78(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    11b4 <main+0x84>
movslq -0x7c(%rbp),%rax
lea    0xe6a(%rip),%rdi
movsbl -0x70(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1185 <main+0x55>
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    -0x74(%rbp),%ecx
sub    -0x78(%rbp),%ecx
cmp    %ecx,%eax
jge    11ef <main+0xbf>
movslq -0x80(%rbp),%rax
lea    0xe2f(%rip),%rdi
movsbl -0x70(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    11bb <main+0x8b>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xebf(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeac(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1040 <read@plt>
mov    %eax,%r14d
mov    0xc(%rsp),%eax
cltd
idiv   %r14d
mov    %edx,0xc(%rsp)
movslq %r14d,%rbp
test   %edx,%edx
jle    11aa <main+0x7a>
mov    %r14d,%eax
sub    %edx,%eax
movslq %eax,%rbx
lea    0xe76(%rip),%r15
movsbl 0x10(%rsp,%rbx,1),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbp,%rbx
jl     1190 <main+0x60>
mov    0xc(%rsp),%edx
cmp    %edx,%r14d
jle    11e1 <main+0xb1>
xor    %ebx,%ebx
lea    0xe4e(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsbl 0x10(%rsp,%rbx,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
mov    %rbp,%rcx
sub    %rax,%rcx
cmp    %rcx,%rbx
jl     11c0 <main+0x90>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
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 [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @read(i8* %10)
store i32 %11, i32* %3
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = srem i32 %12, %13
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = sub nsw i32 %15, %16
store i32 %17, i32* %5
br label %18
18: ; preds = %28, %0
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %18
31: ; preds = %18
store i32 0, i32* %6
br label %32
32: ; preds = %44, %31
%33 = load i32, i32* %6
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = sub nsw i32 %34, %35
%37 = icmp slt i32 %33, %36
br i1 %37, label %38, label %47
38: ; preds = %32
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %32
47: ; preds = %32
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 [100 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 @read(i8* %3)
%8 = load i32, i32* %2
%9 = srem i32 %8, %7
store i32 %9, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = sub i32 %7, %9
%13 = sext i32 %12 to i64
%14 = sext i32 %7 to i64
br label %20
15: ; preds = %20
%16 = load i32, i32* %2
br label %17
17: ; preds = %15, %0
%18 = phi i32 [ %16, %15 ], [ %9, %0 ]
%19 = icmp sgt i32 %7, %18
br i1 %19, label %27, label %37
20: ; preds = %11, %20
%21 = phi i64 [ %13, %11 ], [ %25, %20 ]
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %23)
%25 = add nsw i64 %21, 1
%26 = icmp slt i64 %25, %14
br i1 %26, label %20, label %15
27: ; preds = %17, %27
%28 = phi i64 [ %32, %27 ], [ 0, %17 ]
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %30)
%32 = add nuw nsw i64 %28, 1
%33 = load i32, i32* %2
%34 = sub nsw i32 %7, %33
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %32, %35
br i1 %36, label %27, label %37
37: ; preds = %27, %17
ret i32 0
}