#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*/ print_permute(char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
long long strlen(char *);
int main() {
  long long int i, j, k;
  long long int t;
  char str[100];
  scanf("%lld", &t);
  while (t--) {
    scanf("%s", str);
    i = strlen(str);
    print_permute(str, i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x28(%rbp)
cmp    $0x0,%rax
je     11a7 <main+0x77>
lea    -0x90(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <print_permute@plt>
jmp    1154 <main+0x24>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xec2(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subq   $0x1,0x8(%rsp)
jb     1188 <main+0x58>
lea    0xeac(%rip),%r14
lea    0x10(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <print_permute@plt>
subq   $0x1,0x8(%rsp)
jae    1160 <main+0x30>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca [100 x i8]
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %5)
br label %8
8: ; preds = %12, %0
%9 = load i64, i64* %5
%10 = add nsw i64 %9, -1
store i64 %10, i64* %5
%11 = icmp ne i64 %9, 0
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = call i64 @strlen(i8* %15)
store i64 %16, i64* %2
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%18 = load i64, i64* %2
%19 = call i32 @print_permute(i8* %17, i64 %18)
br label %8
20: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca [100 x i8]
%3 = bitcast i64* %1 to i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = add nsw i64 %6, -1
store i64 %7, i64* %1
%8 = icmp eq i64 %6, 0
br i1 %8, label %16, label %9
9: ; preds = %0, %9
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = call i64 @strlen(i8* %4)
%12 = call i32 @print_permute(i8* %4, i64 %11)
%13 = load i64, i64* %1
%14 = add nsw i64 %13, -1
store i64 %14, i64* %1
%15 = icmp eq i64 %13, 0
br i1 %15, label %16, label %9
16: ; preds = %9, %0
ret i32 0
}