#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*/ L_ShiftString(char *, char *);
int /*<<< orphan*/ R_ShiftString(char *, char *);
int /*<<< orphan*/ StringSet(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char word[10], strShifted[26] = "", strToFind[26], aux[26];
  int n, BoolFounded = 0;
  while (1) {
    scanf("%s", word);
    if (word[0] == '.')
      break;
    scanf("%d", &n);
    BoolFounded = 0;
    StringSet(word, strShifted, n);
    R_ShiftString(strShifted, strToFind);
    while (!BoolFounded) {
      if (strcmp(strShifted, strToFind) == 0)
        BoolFounded = 1;
      printf("%s\n", strShifted);
      strcpy(aux, strShifted);
      L_ShiftString(aux, strShifted);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1a,%edx
call   1050 <memset@plt>
movl   $0x0,-0x78(%rbp)
lea    -0xe(%rbp),%rsi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
movsbl -0xe(%rbp),%eax
cmp    $0x2e,%eax
jne    11cd <main+0x4d>
jmp    126b <main+0xeb>
lea    0xe2f(%rip),%rdi
lea    -0x74(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
movl   $0x0,-0x78(%rbp)
lea    -0xe(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x74(%rbp),%edx
call   10a0 <StringSet@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <R_ShiftString@plt>
cmpl   $0x0,-0x78(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1219 <main+0x99>
jmp    1266 <main+0xe6>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1237 <main+0xb7>
movl   $0x1,-0x78(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xdc4(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1090 <L_ShiftString@plt>
jmp    1203 <main+0x83>
jmp    11a9 <main+0x29>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x1a(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe6e(%rip),%rdi
lea    0x6(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpb   $0x2e,0x6(%rsp)
je     124c <main+0xdc>
lea    0x6(%rsp),%r12
lea    0x10(%rsp),%rbx
lea    0x50(%rsp),%r13
lea    0xe47(%rip),%rbp
lea    0x30(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe2c(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    (%rsp),%edx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1090 <StringSet@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <R_ShiftString@plt>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
mov    %rax,%r15
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <L_ShiftString@plt>
test   %r15,%r15
jne    1200 <main+0x90>
lea    0xdc5(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpb   $0x2e,0x6(%rsp)
jne    11d0 <main+0x60>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [26 x i8]
%4 = alloca [26 x i8]
%5 = alloca [26 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [26 x i8]* %3 to i8*
store i32 0, i32* %7
br label %9
9: ; preds = %0, %45
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 46
br i1 %15, label %16, label %17
16: ; preds = %9
br label %46
17: ; preds = %9
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store i32 0, i32* %7
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%20 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%21 = load i32, i32* %6
%22 = call i32 @StringSet(i8* %19, i8* %20, i32 %21)
%23 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%24 = getelementptr inbounds [26 x i8], [26 x i8]* %4, i64 0, i64 0
%25 = call i32 @R_ShiftString(i8* %23, i8* %24)
br label %26
26: ; preds = %36, %17
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br i1 %29, label %30, label %45
30: ; preds = %26
%31 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%32 = getelementptr inbounds [26 x i8], [26 x i8]* %4, i64 0, i64 0
%33 = call i64 @strcmp(i8* %31, i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 1, i32* %7
br label %36
36: ; preds = %35, %30
%37 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%40 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%41 = call i32 @strcpy(i8* %39, i8* %40)
%42 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%43 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%44 = call i32 @L_ShiftString(i8* %42, i8* %43)
br label %26
45: ; preds = %26
br label %9
46: ; preds = %16
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [26 x i8]
%3 = alloca [26 x i8]
%4 = alloca [26 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [26 x i8], [26 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [26 x i8], [26 x i8]* %4, i64 0, i64 0
%10 = bitcast i32* %5 to i8*
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%12 = load i8, i8* %6
%13 = icmp eq i8 %12, 46
br i1 %13, label %29, label %18
14: ; preds = %23
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%16 = load i8, i8* %6
%17 = icmp eq i8 %16, 46
br i1 %17, label %29, label %18
18: ; preds = %0, %14
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%20 = load i32, i32* %5
%21 = call i32 @StringSet(i8* %6, i8* %7, i32 %20)
%22 = call i32 @R_ShiftString(i8* %7, i8* %8)
br label %23
23: ; preds = %18, %23
%24 = call i64 @strcmp(i8* %7, i8* %8)
%25 = icmp eq i64 %24, 0
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%27 = call i32 @strcpy(i8* %9, i8* %7)
%28 = call i32 @L_ShiftString(i8* %9, i8* %7)
br i1 %25, label %14, label %23
29: ; preds = %14, %0
ret i32 0
}