#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 main() {
  int T;
  scanf("%d", &T);
  char arrayOfWords[T][30];
  int i, j, len = 0;
  for (i = 0; i < T; i++) {
    scanf("%s", arrayOfWords[i]);
  }
  for (i = 0; i < T; ++i) {
    for (j = 0; arrayOfWords[i][j] != '\0'; ++j) {
      len++;
    }
    for (j = len - 1; j >= 0; --j)
      printf("%c", arrayOfWords[i][j]);
    len = 0;
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
shl    $0x5,%rdx
sub    %rax,%rdx
sub    %rax,%rdx
add    $0xf,%rdx
movabs $0x3ffffffff0,%rcx
and    %rcx,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bf <main+0x9f>
mov    -0x30(%rbp),%rsi
movslq -0x1c(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1188 <main+0x68>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1279 <main+0x159>
movl   $0x0,-0x20(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1210 <main+0xf0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d9 <main+0xb9>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     1256 <main+0x136>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1219 <main+0xf9>
movl   $0x0,-0x24(%rbp)
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c6 <main+0xa6>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rax,%rcx
shl    $0x5,%rcx
sub    %rax,%rcx
sub    %rax,%rcx
add    $0xf,%rcx
movabs $0x3ffffffff0,%rax
and    %rcx,%rax
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    1247 <main+0x127>
lea    0xe81(%rip),%r14
mov    %r12,%r13
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x1e,%r13
cmp    %rax,%rbx
jl     1190 <main+0x70>
test   %eax,%eax
jle    1247 <main+0x127>
lea    0x1(%r12),%rbx
xor    %r14d,%r14d
mov    %r12,%r13
jmp    11ef <main+0xcf>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
movslq -0x2c(%rbp),%rax
add    $0x1e,%rbx
add    $0x1e,%r13
cmp    %rax,%r14
jge    1247 <main+0x127>
mov    %r14,%rax
shl    $0x5,%rax
sub    %r14,%rax
sub    %r14,%rax
cmpb   $0x0,(%r12,%rax,1)
je     11d0 <main+0xb0>
mov    $0x1,%ecx
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cmpb   $0x0,(%rbx,%rdx,1)
lea    0x1(%rdx),%rdx
lea    0x1(%rax),%ecx
jne    1210 <main+0xf0>
test   %edx,%edx
jle    11d0 <main+0xb0>
mov    %eax,%r15d
add    $0x1,%r15
nopw   0x0(%rax,%rax,1)
movsbl -0x2(%r13,%r15,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%r15
cmp    $0x1,%r15
ja     1230 <main+0x110>
jmp    11d0 <main+0xb0>
mov    -0x38(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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