#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*/ decode(char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ encode(char *, int /*<<< orphan*/, char *, char **);
int /*<<< orphan*/ init_encode_table(char **);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int main() {
  int n;
  char str[200];
  char buf[3000];
  char encode_table[256][8];
  init_encode_table(encode_table);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", str);
    encode(str, strlen(str), buf, encode_table);
    decode(buf, strlen(buf), str);
    printf("%d: %s\n", i + 1, str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x14b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1490(%rbp),%rdi
call   1080 <init_encode_table@plt>
lea    0xe7b(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movl   $0x0,-0x1494(%rbp)
mov    -0x1494(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1253 <main+0xf3>
lea    -0xd0(%rbp),%rsi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0xd0(%rbp),%rax
mov    %rax,-0x14a8(%rbp)
lea    -0xd0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x14a8(%rbp),%rdi
mov    %eax,%esi
lea    -0xc90(%rbp),%rdx
lea    -0x1490(%rbp),%rcx
call   1030 <encode@plt>
lea    -0xc90(%rbp),%rax
mov    %rax,-0x14a0(%rbp)
lea    -0xc90(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x14a0(%rbp),%rdi
mov    %eax,%esi
lea    -0xd0(%rbp),%rdx
call   1060 <decode@plt>
mov    -0x1494(%rbp),%esi
add    $0x1,%esi
lea    -0xd0(%rbp),%rdx
lea    0xdcc(%rip),%rdi
call   1050 <printf@plt>
mov    -0x1494(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1494(%rbp)
jmp    119a <main+0x3a>
xor    %eax,%eax
add    $0x14b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1498,%rsp
lea    0xe0(%rsp),%rdi
call   1080 <init_encode_table@plt>
lea    0xe7b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1210 <main+0xb0>
lea    0xe64(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0x8e0(%rsp),%r15
lea    0xe0(%rsp),%r12
lea    0xe4b(%rip),%r13
xor    %ebp,%ebp
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
mov    %r12,%rcx
call   1030 <encode@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1060 <decode@plt>
add    $0x1,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1050 <printf@plt>
cmp    0xc(%rsp),%ebp
jl     11c0 <main+0x60>
xor    %eax,%eax
add    $0x1498,%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 = [8 x i8] c"%d: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [200 x i8]
%4 = alloca [3000 x i8]
%5 = alloca [256 x [8 x i8]]
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [256 x [8 x i8]], [256 x [8 x i8]]* %5, i64 0, i64 0
%8 = bitcast [8 x i8]* %7 to i8**
%9 = call i32 @init_encode_table(i8** %8)
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %6
br label %11
11: ; preds = %34, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %37
15: ; preds = %11
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = getelementptr inbounds [3000 x i8], [3000 x i8]* %4, i64 0, i64 0
%22 = getelementptr inbounds [256 x [8 x i8]], [256 x [8 x i8]]* %5, i64 0, i64 0
%23 = bitcast [8 x i8]* %22 to i8**
%24 = call i32 @encode(i8* %18, i32 %20, i8* %21, i8** %23)
%25 = getelementptr inbounds [3000 x i8], [3000 x i8]* %4, i64 0, i64 0
%26 = getelementptr inbounds [3000 x i8], [3000 x i8]* %4, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%29 = call i32 @decode(i8* %25, i32 %27, i8* %28)
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %31, i8* %32)
br label %34
34: ; preds = %15
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %11
37: ; preds = %11
ret i32 0
}

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