#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*/ deslocamentoDireita(char *);
int /*<<< orphan*/ deslocamentoEsquerda(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ inversao(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main() {
  int qnt_entradas;
  int buffer_size = 1002;
  char texto[buffer_size];
  scanf("%d", &qnt_entradas);
  getchar();
  while (qnt_entradas > 0) {
    fgets(texto, buffer_size, stdin);
    deslocamentoDireita(texto);
    inversao(texto);
    deslocamentoEsquerda(texto);
    printf("%s", texto);
    qnt_entradas -= 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3ea,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe4d(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
cmpl   $0x0,-0x8(%rbp)
jle    121b <main+0xab>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e0d(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
mov    -0x28(%rbp),%rdi
call   1030 <deslocamentoDireita@plt>
mov    -0x28(%rbp),%rdi
call   1090 <inversao@plt>
mov    -0x28(%rbp),%rdi
call   1070 <deslocamentoEsquerda@plt>
mov    -0x28(%rbp),%rsi
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <main+0x53>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%r15
lea    0xe78(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    1204 <main+0x94>
mov    0x2e41(%rip),%r12
lea    0x10(%rsp),%rbx
lea    0xe50(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x3ea,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <deslocamentoDireita@plt>
mov    %rbx,%rdi
call   1090 <inversao@plt>
mov    %rbx,%rdi
call   1070 <deslocamentoEsquerda@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0xc(%rsp)
cmp    $0x1,%eax
jg     11c0 <main+0x50>
mov    %r15,%rsp
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i32 0, i32* %1
store i32 1002, i32* %3
%6 = load i32, i32* %3
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %4
%9 = alloca i8, i64 %7
store i64 %7, i64* %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = call i32 (...) @getchar()
br label %12
12: ; preds = %15, %0
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %3
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %9, i32 %16, i32 %17)
%19 = call i32 @deslocamentoDireita(i8* %9)
%20 = call i32 @inversao(i8* %9)
%21 = call i32 @deslocamentoEsquerda(i8* %9)
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%23 = load i32, i32* %2
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %2
br label %12
25: ; preds = %12
%26 = load i8*, i8** %4
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i8* @llvm.stacksave()
%4 = alloca [1002 x i8]
%5 = getelementptr inbounds [1002 x i8], [1002 x i8]* %4, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = call i32 (...) @getchar()
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %0, %10
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %5, i32 1002, i32 %11)
%13 = call i32 @deslocamentoDireita(i8* %5)
%14 = call i32 @inversao(i8* %5)
%15 = call i32 @deslocamentoEsquerda(i8* %5)
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%17 = load i32, i32* %1
%18 = add nsw i32 %17, -1
store i32 %18, i32* %1
%19 = icmp sgt i32 %17, 1
br i1 %19, label %10, label %20
20: ; preds = %10, %0
ret i32 0
}