#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ imprimirDecodificado(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main(void) {
  int casos, chave;
  char str[64];
  scanf("%d\n", &casos);
  while (casos-- > 0) {
    fgets(str, 64, stdin);
    scanf("%d\n", &chave);
    imprimirDecodificado(str, chave);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    119b <main+0x6b>
lea    -0x50(%rbp),%rdi
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1040 <fgets@plt>
lea    0xe7f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x50(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <imprimirDecodificado@plt>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xebe(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
test   %eax,%eax
jle    11b7 <main+0x87>
mov    0x2e86(%rip),%r12
lea    0x10(%rsp),%rbx
lea    0xe92(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1040 <fgets@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <imprimirDecodificado@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
test   %eax,%eax
jg     1180 <main+0x50>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [64 x i8]
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 64, i32 %12)
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%16 = load i32, i32* %3
%17 = call i32 @imprimirDecodificado(i8* %15, i32 %16)
br label %6
18: ; preds = %6
ret i32 0
}

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