#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 */
scalar_t__ EOF;
int /*<<< orphan*/ putchar(char);
scalar_t__ scanf(char *, ...);
long strlen(char *);
int main() {
  long int n, i, lengthS;
  char s[1000];
  while (scanf("%s", s) != EOF) {
    scanf("%li", &n);
    lengthS = strlen(s);
    n = n % lengthS;
    for (i = n; i < lengthS; i++) {
      putchar(s[i]);
    }
    for (i = 0; i < n; i++) {
      putchar(s[i]);
    }
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%rax
je     1216 <main+0xe6>
lea    0xe95(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11cf <main+0x9f>
mov    -0x18(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119f <main+0x6f>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1207 <main+0xd7>
mov    -0x18(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11d7 <main+0xa7>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f8,%rsp
lea    0xeb8(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x2e8d(%rip),%r14
cmp    (%r14),%rax
jne    1174 <main+0x44>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r13
lea    0xe7b(%rip),%r12
jmp    11ac <main+0x7c>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    (%r14),%rax
je     1160 <main+0x30>
lea    0xe50(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rax
mov    %rax,%rcx
or     %rbx,%rcx
shr    $0x20,%rcx
je     11f0 <main+0xc0>
cqto
idiv   %rbx
mov    %rdx,%rbp
jmp    11f6 <main+0xc6>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edx,%edx
div    %ebx
mov    %edx,%ebp
mov    %rbp,0x8(%rsp)
test   %rbx,%rbx
js     1218 <main+0xe8>
movsbl 0x10(%rsp,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbx,%rbp
jl     1200 <main+0xd0>
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
jle    1190 <main+0x60>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x10(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    0x8(%rsp),%rbx
jl     1230 <main+0x100>
jmp    1190 <main+0x60>

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

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