#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 *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int main(int argc, char const *argv[]) {
  char word[500], ch;
  int n, l, i, k;
  while (1) {
    scanf("%s", word);
    if (!strcmp(word, "."))
      return 0;
    scanf("%d", &n);
    l = strlen(word);
    for (k = 0; k < l; k++) {
      for (i = 0; i < n; i++)
        printf("%s", word);
      printf("\n");
      ch = word[0];
      for (i = 0; i < l - 1; i++)
        word[i] = word[i + 1];
      word[l - 1] = ch;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x210(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x210(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1195 <main+0x55>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret
lea    0xe69(%rip),%rdi
lea    -0x218(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x21c(%rbp)
movl   $0x0,-0x224(%rbp)
mov    -0x224(%rbp),%eax
cmp    -0x21c(%rbp),%eax
jge    12b8 <main+0x178>
movl   $0x0,-0x220(%rbp)
mov    -0x220(%rbp),%eax
cmp    -0x218(%rbp),%eax
jge    121d <main+0xdd>
lea    -0x210(%rbp),%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x220(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x220(%rbp)
jmp    11e2 <main+0xa2>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x210(%rbp),%al
mov    %al,-0x211(%rbp)
movl   $0x0,-0x220(%rbp)
mov    -0x220(%rbp),%eax
mov    -0x21c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    128c <main+0x14c>
mov    -0x220(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x210(%rbp,%rax,1),%cl
movslq -0x220(%rbp),%rax
mov    %cl,-0x210(%rbp,%rax,1)
mov    -0x220(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x220(%rbp)
jmp    1241 <main+0x101>
mov    -0x211(%rbp),%cl
mov    -0x21c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0x210(%rbp,%rax,1)
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    11c6 <main+0x86>
jmp    1159 <main+0x19>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
lea    0xe98(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpw   $0x2e,0x10(%rsp)
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rbx
lea    0xe64(%rip),%r13
jmp    11b5 <main+0x65>
xchg   %ax,%ax
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpw   $0x2e,0x10(%rsp)
je     117c <main+0x2c>
lea    0xe47(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11a0 <main+0x50>
mov    %eax,%ebp
lea    -0x1(%rbp),%r14d
xor    %r15d,%r15d
jmp    11ee <main+0x9e>
nop
mov    %r12b,0x10(%rsp,%r14,1)
add    $0x1,%r15d
cmp    %ebp,%r15d
je     11a0 <main+0x50>
cmpl   $0x0,0xc(%rsp)
jle    1218 <main+0xc8>
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12d
cmp    0xc(%rsp),%r12d
jl     1200 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%r12b
cmp    $0x1,%ebp
je     11e0 <main+0x90>
mov    %rbx,%rdi
lea    0x11(%rsp),%rsi
mov    %r14,%rdx
call   1070 <memmove@plt>
jmp    11e0 <main+0x90>

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

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