int main() {
  char s[100];
  int x, y, len;
  scanf("%s", s), len = (int)strlen(s);
  for (y = len - 1; y >= 0; y--)
    for (x = 0; x < len || 0 * printf("\n"); x++)
      printf("%c", s[(x + y) % len]);
}


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    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jl     11f6 <main+0xc6>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%ecx
mov    $0x1,%al
cmp    -0x7c(%rbp),%ecx
mov    %al,-0x7d(%rbp)
jl     11a5 <main+0x75>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
imul   $0x0,%eax,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x7d(%rbp)
mov    -0x7d(%rbp),%al
test   $0x1,%al
jne    11b5 <main+0x85>
jmp    11e3 <main+0xb3>
mov    -0x74(%rbp),%eax
add    -0x78(%rbp),%eax
cltd
idivl  -0x7c(%rbp)
movslq %edx,%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    117a <main+0x4a>
jmp    11e8 <main+0xb8>
mov    -0x78(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x78(%rbp)
jmp    1169 <main+0x39>
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    $0x68,%rsp
lea    0xebb(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
test   %r13d,%r13d
jle    11b1 <main+0x81>
lea    -0x1(%r13),%r14d
mov    %r13d,%r15d
nopl   0x0(%rax)
lea    -0x1(%r15),%r12d
mov    %r13d,%ebx
mov    %r14d,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%eax
cltd
idiv   %r13d
movslq %edx,%rax
movsbl (%rsp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
jne    1180 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r14d
cmp    $0x1,%r15d
mov    %r12d,%r15d
jg     1170 <main+0x40>
xor    %eax,%eax
add    $0x68,%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 = [2 x i8] c"\0A\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
store i32 0, i32* %1
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %4
br label %13
13: ; preds = %42, %0
%14 = load i32, i32* %4
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %45
16: ; preds = %13
store i32 0, i32* %3
br label %17
17: ; preds = %38, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = mul nsw i32 0, %22
%24 = icmp ne i32 %23, 0
br label %25
25: ; preds = %21, %17
%26 = phi i1 [ true, %17 ], [ %24, %21 ]
br i1 %26, label %27, label %41
27: ; preds = %25
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = add nsw i32 %28, %29
%31 = load i32, i32* %5
%32 = srem i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %27
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %17
41: ; preds = %25
br label %42
42: ; preds = %41
%43 = load i32, i32* %4
%44 = add nsw i32 %43, -1
store i32 %44, i32* %4
br label %13
45: ; preds = %13
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i64 @strlen(i8* %2)
%5 = trunc i64 %4 to i32
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %24
7: ; preds = %0, %10
%8 = phi i32 [ %9, %10 ], [ %5, %0 ]
%9 = add nsw i32 %8, -1
br label %13
10: ; preds = %13
%11 = call i32 @putchar(i32 10)
%12 = icmp sgt i32 %8, 1
br i1 %12, label %7, label %24
13: ; preds = %7, %13
%14 = phi i32 [ %22, %13 ], [ 0, %7 ]
%15 = add nsw i32 %14, %9
%16 = srem i32 %15, %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 @putchar(i32 %20)
%22 = add nuw nsw i32 %14, 1
%23 = icmp eq i32 %22, %5
br i1 %23, label %10, label %13
24: ; preds = %10, %0
ret i32 0
}