#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*/ printf(char *, ...);
scalar_t__ scanf(char *, char **, int *);
int strlen(char *);
int main() {
  char line1[1000];
  int k, len, i;
  while (scanf("%s%d", &line1, &k) != EOF) {
    len = strlen(line1);
    k = k % len;
    for (i = k; i < len; i++)
      printf("%c", line1[i]);
    for (i = 0; i < k; i++)
      printf("%c", line1[i]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rsi
lea    0xeb0(%rip),%rdi
lea    -0x3f4(%rbp),%rdx
call   1050 <scanf@plt>
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%rax
je     1240 <main+0x110>
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3f8(%rbp)
mov    -0x3f4(%rbp),%eax
cltd
idivl  -0x3f8(%rbp)
mov    %edx,-0x3f4(%rbp)
mov    -0x3f4(%rbp),%eax
mov    %eax,-0x3fc(%rbp)
mov    -0x3fc(%rbp),%eax
cmp    -0x3f8(%rbp),%eax
jge    11e0 <main+0xb0>
movslq -0x3fc(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%esi
ff
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3fc(%rbp)
jmp    119d <main+0x6d>
movl   $0x0,-0x3fc(%rbp)
mov    -0x3fc(%rbp),%eax
cmp    -0x3f4(%rbp),%eax
jge    122d <main+0xfd>
movslq -0x3fc(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%esi
ff
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3fc(%rbp)
jmp    11ea <main+0xba>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x400,%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
lea    0xc(%rsp),%rdx
call   1050 <scanf@plt>
mov    0x2e8a(%rip),%r12
cmp    (%r12),%rax
jne    1178 <main+0x48>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r13
lea    0xe7c(%rip),%r14
lea    0xc(%rsp),%r15
jmp    11ae <main+0x7e>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1050 <scanf@plt>
cmp    (%r12),%rax
je     1164 <main+0x34>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    0xc(%rsp),%eax
cltd
idiv   %ecx
mov    %edx,0xc(%rsp)
test   %ecx,%ecx
js     11e7 <main+0xb7>
movslq %edx,%rbx
mov    %ecx,%ebp
nopl   0x0(%rax)
movsbl 0x10(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbp,%rbx
jl     11d0 <main+0xa0>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    1190 <main+0x60>
xor    %ebx,%ebx
nopl   (%rax)
movsbl 0x10(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11f0 <main+0xc0>
jmp    1190 <main+0x60>

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

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