#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ strtok(char *, char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int main(void) {
  FILE *file = fopen("input.txt", "r");
  int i = 0;
  int outputIndex = 0;
  int codeLength;
  int numVariables;
  char code[1000];
  char variables[100];
  char output[1000];
  char temp[100];
  memset(temp, 0, sizeof(char) * 100);
  fgets(variables, sizeof variables, file);
  fgets(code, sizeof code, file);
  strtok(variables, "\n");
  codeLength = strlen(code);
  numVariables = strlen(variables);
  char *buffer = malloc(sizeof(char) * numVariables);
  memset(buffer, 0x30, sizeof(char) * numVariables);
  strcat(code, buffer);
  fclose(file);
  char LUT[128] = {'d', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
                   'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
                   'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'b',
                   'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b',
                   'b', 'b', 'b', 'b', 'e', 'e', 'e', 'e', 'e', 'e', 'e',
                   'e', 'c', 'c', 'c', 'c', 'f', 'f', 'a', 'a'};
  int codeLenLUT[128] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                         2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
                         3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6};
  while (i < codeLength) {
    strncpy(temp, code + i, numVariables);
    int index = (int)strtol(temp, NULL, 2);
    output[outputIndex++] = LUT[index];
    i += codeLenLUT[index];
  }
  printf("%s\n", output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe27(%rip),%rdi
lea    0xe2a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x8e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
lea    -0x480(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1080 <fgets@plt>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1080 <fgets@plt>
lea    -0x480(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   10d0 <strtok@plt>
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x480(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x8e8(%rbp)
mov    -0x8e8(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
mov    $0x30,%esi
call   1070 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    -0x8e8(%rbp),%rsi
call   10e0 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x970(%rbp),%rdi
lea    0xd50(%rip),%rsi
mov    $0x80,%edx
call   10a0 <memcpy@plt>
lea    -0xb70(%rbp),%rdi
lea    0xdb8(%rip),%rsi
mov    $0x200,%edx
call   10a0 <memcpy@plt>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1361 <main+0x1a1>
lea    -0x8e0(%rbp),%rdi
lea    -0x410(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0x8e0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x2,%edx
call   1090 <strtol@plt>
mov    %eax,-0xb74(%rbp)
movslq -0xb74(%rbp),%rax
mov    -0x970(%rbp,%rax,1),%cl
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
cltq
mov    %cl,-0x870(%rbp,%rax,1)
movslq -0xb74(%rbp),%rax
mov    -0xb70(%rbp,%rax,4),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    12e2 <main+0x122>
lea    -0x870(%rbp),%rsi
lea    0xc9d(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0xb80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8b8,%rsp
lea    0xe38(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
lea    0x4d0(%rsp),%r12
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
lea    0xdf2(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strtok@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x30,%esi
mov    %r13d,%edx
call   1070 <memset@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10d0 <strcat@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
test   %r15d,%r15d
jle    12c4 <main+0x114>
lea    0xe0(%rsp),%rbx
mov    %rsp,%r14
lea    0xe12(%rip),%r12
xchg   %ax,%ax
movslq %ebp,%rbp
lea    (%rsp,%rbp,1),%rsi
add    $0x4d0,%rsi
mov    %r14,%rdi
mov    %r13d,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1090 <strtol@plt>
cltq
lea    0xd5f(%rip),%rcx
movzbl (%rax,%rcx,1),%ecx
mov    %cl,(%rbx)
add    (%r12,%rax,4),%ebp
add    $0x1,%rbx
cmp    %r15d,%ebp
jl     1280 <main+0xd0>
lea    0xd41(%rip),%rdi
lea    0xe0(%rsp),%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"\0A\00"
@__const.main.LUT = <{ [64 x i8], [64 x i8] }> <{ [64 x i8] c"ddddddddddddddddddddddddddddddddbbbbbbbbbbbbbbbbeeeeeeeeccccffaa", [64 x i8] zeroinitializer }>
@__const.main.codeLenLUT = <{ [64 x i32], [64 x i32] }> <{ [64 x i32] [i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 4, i32 4, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6], [64 x i32] zeroinitializer }>
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1000 x i8]
%8 = alloca [100 x i8]
%9 = alloca [1000 x i8]
%10 = alloca [100 x i8]
%11 = alloca i8*
%12 = alloca [128 x i8]
%13 = alloca [128 x i32]
%14 = alloca i32
store i32 0, i32* %1
%15 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %2
store i32 0, i32* %3
store i32 0, i32* %4
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%17 = call i32 @memset(i8* %16, i32 0, i32 100)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%19 = load i32*, i32** %2
%20 = call i32 @fgets(i8* %18, i32 100, i32* %19)
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%22 = load i32*, i32** %2
%23 = call i32 @fgets(i8* %21, i32 1000, i32* %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%25 = call i32 @strtok(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
store i32 %27, i32* %5
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = mul i64 1, %31
%33 = trunc i64 %32 to i32
%34 = call i8* @malloc(i32 %33)
store i8* %34, i8** %11
%35 = load i8*, i8** %11
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = mul i64 1, %37
%39 = trunc i64 %38 to i32
%40 = call i32 @memset(i8* %35, i32 48, i32 %39)
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%42 = load i8*, i8** %11
%43 = call i32 @strcat(i8* %41, i8* %42)
%44 = load i32*, i32** %2
%45 = call i32 @fclose(i32* %44)
%46 = bitcast [128 x i8]* %12 to i8*
%47 = bitcast [128 x i32]* %13 to i8*
br label %48
48: ; preds = %52, %0
%49 = load i32, i32* %3
%50 = load i32, i32* %5
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %77
52: ; preds = %48
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%54 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i32, i32* %6
%59 = call i32 @strncpy(i8* %53, i8* %57, i32 %58)
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%61 = call i64 @strtol(i8* %60, i32* null, i32 2)
%62 = trunc i64 %61 to i32
store i32 %62, i32* %14
%63 = load i32, i32* %14
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = load i32, i32* %4
%68 = add nsw i32 %67, 1
store i32 %68, i32* %4
%69 = sext i32 %67 to i64
%70 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 %69
store i8 %66, i8* %70
%71 = load i32, i32* %14
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [128 x i32], [128 x i32]* %13, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = load i32, i32* %3
%76 = add nsw i32 %75, %74
store i32 %76, i32* %3
br label %48
77: ; preds = %48
%78 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%79 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %78)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"\0A\00"
@__const.main.LUT = <{ [64 x i8], [64 x i8] }> <{ [64 x i8] c"ddddddddddddddddddddddddddddddddbbbbbbbbbbbbbbbbeeeeeeeeccccffaa", [64 x i8] zeroinitializer }>
@__const.main.codeLenLUT = <{ [64 x i32], [64 x i32] }> <{ [64 x i32] [i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 4, i32 4, i32 4, i32 4, i32 5, i32 5, i32 6, i32 6], [64 x i32] zeroinitializer }>
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [100 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [100 x i8]
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 100)
%11 = call i32 @fgets(i8* %7, i32 100, i32* %5)
%12 = call i32 @fgets(i8* %6, i32 1000, i32* %5)
%13 = call i32 @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @strlen(i8* %6)
%15 = call i32 @strlen(i8* %7)
%16 = call i8* @malloc(i32 %15)
%17 = call i32 @memset(i8* %16, i32 48, i32 %15)
%18 = call i32 @strcat(i8* %6, i8* %16)
%19 = call i32 @fclose(i32* %5)
%20 = icmp sgt i32 %14, 0
br i1 %20, label %21, label %38
21: ; preds = %0, %21
%22 = phi i64 [ %32, %21 ], [ 0, %0 ]
%23 = phi i32 [ %36, %21 ], [ 0, %0 ]
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %24
%26 = call i32 @strncpy(i8* %9, i8* %25, i32 %15)
%27 = call i64 @strtol(i8* nocapture %9, i32* null, i32 2)
%28 = shl i64 %27, 32
%29 = ashr exact i64 %28, 32
%30 = getelementptr inbounds [128 x i8], [128 x i8]* bitcast (<{ [64 x i8], [64 x i8] }>* @__const.main.LUT to [128 x i8]*), i64 0, i64 %29
%31 = load i8, i8* %30
%32 = add nuw i64 %22, 1
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %22
store i8 %31, i8* %33
%34 = getelementptr inbounds [128 x i32], [128 x i32]* bitcast (<{ [64 x i32], [64 x i32] }>* @__const.main.codeLenLUT to [128 x i32]*), i64 0, i64 %29
%35 = load i32, i32* %34
%36 = add nsw i32 %35, %23
%37 = icmp slt i32 %36, %14
br i1 %37, label %21, label %38
38: ; preds = %21, %0
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %8)
ret i32 0
}