// File: /workspace/github_c_makefile_star2_O2/FirestonnneTFM[P]tfm_key_parser/src/main_dumper.cpp
// Function: main
int main(int argc, char **argv) {
	std::ios_base::sync_with_stdio(true);
	try {
		if (argc < 2) {
			fatal("Needs input file name");
		}
		if (argc < 3) {
			fatal("Needs output file name");
		}
		init_as3_op();
		swf_file *swf = new swf_file(argv[1]);
		swf_tag tags[12];
		swf_tag_DefineBinaryData btags[12];
		swf->get_tags(87, tags, 12);
		for (int i = 0; i < 12; ++i) {
			btags[i] = swf_tag_DefineBinaryData(tags + i);
			if (btags[i].ch_id != i + 1)
				fatal("Tag and position mismatch");
		}
		swf->get_tags(76, tags, 1);
		swf_tag_SymbolClass sym(tags);
		char *order[12];
		go(order);
		char *unorder[12];
		for (int i = 0; i < 12; ++i) {
			unorder[sym.ch_ids[i] - 1] = prune(sym.names[i]);
		}
		FILE *out_file = fopen(argv[2], "wb");
		for (int i = 0; i < 12; ++i) {
			for (int j = 0; j < 12; ++j) {
				if (strcmp(order[i], unorder[j]) == 0) {
					fwrite(btags[j].binary_data, 1, btags[j].length, out_file);
				}
			}
		}
		fclose(out_file);
		for (int i = 0; i < 12; ++i) {
			delete [] order[i];
		}
		delete swf;
		return 0;
	} catch (fatal_error e) {
		e.print();
	} catch (const char *e) {
		std::cout << "DEPRECATED -- instead of throwing string, use macro"<< std::endl;
		fprintf(stderr, "Fatal: %s\n", e);
		return 1;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rsi, %r15
movl %edi, %ebp
pushq $0x1
popq %r14
movl %r14d, %edi
callq 0x20c0
cmpl $0x2, %ebp
jl 0x51fa
je 0x5205
callq 0x31e8
pushq $0x30
popq %rdi
callq 0x21a0
movq 0x8(%r15), %rsi
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x46d2
xorl %ebx, %ebx
leaq (%rsp,%rbx), %rdi
addq $0xe0, %rdi
callq 0x4b48
addq $0x10, %rbx
cmpq $0xc0, %rbx
jne 0x5005
xorl %ebx, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x269c
addq $0x18, %rbx
cmpq $0x120, %rbx            # imm = 0x120
jne 0x5024
pushq $0x57
popq %rsi
leaq 0xe0(%rsp), %r12
pushq $0xc
popq %rcx
movq (%rsp), %rdi
movq %r12, %rdx
callq 0x4928
leaq 0x1a0(%rsp), %rbp
xorl %ebx, %ebx
leaq 0x20(%rsp), %r13
cmpq $0xc, %rbx
je 0x50d7
movq %r13, %rdi
movq %r12, %rsi
callq 0x26aa
movl 0x30(%rsp), %eax
movl %eax, 0x10(%rbp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rbp)
movzwl (%rbp), %eax
incq %rbx
addq $0x18, %rbp
addq $0x10, %r12
cmpq %rax, %rbx
je 0x506a
movl %r14d, %ebx
pushq $0x18
popq %rdi
callq 0x20f0
movl $0x6c, (%rax)
leaq 0x128e(%rip), %rcx      # 0x6345
movq %rcx, 0x8(%rax)
leaq 0x12c4(%rip), %rcx      # 0x6386
movq %rcx, 0x10(%rax)
leaq 0x3cc3(%rip), %rsi      # 0x8d90
movq %rax, %rdi
xorl %edx, %edx
callq 0x2280
pushq $0x4c
popq %rsi
leaq 0xe0(%rsp), %rdx
pushq $0x1
popq %rcx
movq (%rsp), %rdi
callq 0x4928
leaq 0x8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x26c8
leaq 0x20(%rsp), %rdi
callq 0x4e4a
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
xorl %edx, %edx
cmpq $0xc, %rdx
je 0x5137
movq (%rcx,%rdx,8), %rsi
cmpb $0x5f, (%rsi)
leaq 0x1(%rsi), %rsi
jne 0x5120
movzwl (%rax,%rdx,2), %edi
movq %rsi, 0x78(%rsp,%rdi,8)
incq %rdx
jmp 0x5116
movq 0x10(%r15), %rdi
leaq 0x125e(%rip), %rsi      # 0x63a0
callq 0x2200
movq %rax, %rbx
xorl %ebp, %ebp
pushq $0x1
popq %r15
cmpq $0xc, %rbp
je 0x51a1
movq 0x20(%rsp,%rbp,8), %r12
leaq 0x1b0(%rsp), %r13
xorl %r14d, %r14d
cmpq $0xc, %r14
je 0x519c
movq 0x80(%rsp,%r14,8), %rsi
movq %r12, %rdi
callq 0x2230
testl %eax, %eax
jne 0x5193
movq -0x8(%r13), %rdi
movl (%r13), %edx
movq %r15, %rsi
movq %rbx, %rcx
callq 0x22c0
incq %r14
addq $0x18, %r13
jmp 0x5166
incq %rbp
jmp 0x5150
movq %rbx, %rdi
callq 0x2190
xorl %ebx, %ebx
movq (%rsp), %r14
cmpq $0xc, %rbx
je 0x51c9
movq 0x20(%rsp,%rbx,8), %rdi
testq %rdi, %rdi
je 0x51c4
callq 0x2220
incq %rbx
jmp 0x51af
movq %r14, %rdi
callq 0x4990
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x21b0
leaq 0x8(%rsp), %rdi
callq 0x274a
xorl %eax, %eax
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1158(%rip), %rbx      # 0x6359
pushq $0x5f
jmp 0x520e
leaq 0x1163(%rip), %rbx      # 0x636f
pushq $0x62
popq %rbp
pushq $0x18
popq %rdi
callq 0x20f0
movl %ebp, (%rax)
leaq 0x1125(%rip), %rcx      # 0x6345
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
leaq 0x3b61(%rip), %rsi      # 0x8d90
movq %rax, %rdi
xorl %edx, %edx
callq 0x2280
movl %r14d, %ebx
movq %rdx, %r12
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0x274a
jmp 0x527c
jmp 0x5273
movl %r14d, %ebx
movq %rdx, %r12
movq %rax, %r15
pushq $0x30
popq %rsi
movq (%rsp), %rdi
callq 0x21b0
jmp 0x527c
jmp 0x5273
jmp 0x5273
jmp 0x5273
jmp 0x5273
jmp 0x5276
jmp 0x5273
movl %r14d, %ebx
movq %rdx, %r12
movq %rax, %r15
cmpl $0x2, %r12d
jne 0x52af
movq %r15, %rdi
callq 0x20b0
movups (%rax), %xmm0
leaq 0x1a0(%rsp), %rdi
movaps %xmm0, (%rdi)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rdi)
callq 0x5324
callq 0x2260
jmp 0x51e6
cmpl $0x1, %r12d
jne 0x531c
movq %r15, %rdi
callq 0x20b0
movq %rax, %r14
movq 0x3d09(%rip), %rdi      # 0x8fd0
leaq 0x10d5(%rip), %rsi      # 0x63a3
callq 0x2180
movq %rax, %rdi
callq 0x20e0
movq 0x3cf6(%rip), %rax      # 0x8fd8
movq (%rax), %rdi
leaq 0x10eb(%rip), %rsi      # 0x63d7
movq %r14, %rdx
xorl %eax, %eax
callq 0x2240
callq 0x2260
movl %ebx, %eax
jmp 0x51e8
movq %rax, %r15
callq 0x2260
jmp 0x531c
movq %rax, %rdi
callq 0x2f8c
movq %rax, %r15
callq 0x2260
movq %r15, %rdi
callq 0x22b0