// File: /workspace/github_c_makefile_star2_O3/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, %r14
movl %edi, %ebx
movl $0x1, %edi
callq 0x20d0
cmpl $0x2, %ebx
jl 0x53ad
je 0x53bb
callq 0x32a4
movl $0x30, %edi
callq 0x21e0
movq 0x8(%r14), %rsi
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x4846
xorl %ebx, %ebx
leaq (%rsp,%rbx), %rdi
addq $0xe0, %rdi
callq 0x4ce0
addq $0x10, %rbx
cmpq $0xc0, %rbx
jne 0x51b2
xorl %ebx, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x271c
addq $0x18, %rbx
cmpq $0x120, %rbx            # imm = 0x120
jne 0x51d1
leaq 0xe0(%rsp), %r15
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0x57, %esi
movq %r15, %rdx
movl $0xc, %ecx
callq 0x4b0a
leaq 0x1a0(%rsp), %r13
xorl %ebp, %ebp
leaq 0x20(%rsp), %r12
cmpq $0xc, %rbp
je 0x528d
movq %r12, %rdi
movq %r15, %rsi
callq 0x2732
movl 0x30(%rsp), %eax
movl %eax, 0x10(%r13)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%r13)
movzwl (%r13), %eax
incq %rbp
addq $0x18, %r13
addq $0x10, %r15
cmpq %rax, %rbp
je 0x521e
movl $0x18, %edi
callq 0x2100
movl $0x6c, (%rax)
leaq 0x10d8(%rip), %rcx      # 0x6345
movq %rcx, 0x8(%rax)
leaq 0x110e(%rip), %rcx      # 0x6386
movq %rcx, 0x10(%rax)
leaq 0x3b0d(%rip), %rsi      # 0x8d90
movq %rax, %rdi
xorl %edx, %edx
callq 0x22d0
leaq 0xe0(%rsp), %rdx
movq %rbx, %rdi
movl $0x4c, %esi
movl $0x1, %ecx
callq 0x4b0a
leaq 0x8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2750
leaq 0x20(%rsp), %rdi
callq 0x4ff8
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
cmpb $0x5f, (%rsi)
leaq 0x1(%rsi), %rsi
jne 0x52d3
movzwl (%rax,%rdx,2), %edi
movq %rsi, 0x78(%rsp,%rdi,8)
incq %rdx
cmpq $0xc, %rdx
jne 0x52cf
movq 0x10(%r14), %rdi
leaq 0x10a7(%rip), %rsi      # 0x63a0
callq 0x2250
movq %rax, %r14
leaq 0x1b0(%rsp), %r12
xorl %r13d, %r13d
movq 0x20(%rsp,%r13,8), %r15
movq %r12, %rbp
xorl %ebx, %ebx
movq 0x80(%rsp,%rbx,8), %rsi
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
jne 0x533e
movq -0x8(%rbp), %rdi
movl (%rbp), %edx
movl $0x1, %esi
movq %r14, %rcx
callq 0x2310
incq %rbx
addq $0x18, %rbp
cmpq $0xc, %rbx
jne 0x5316
incq %r13
cmpq $0xc, %r13
jne 0x530c
movq %r14, %rdi
callq 0x21d0
xorl %ebx, %ebx
movq 0x20(%rsp,%rbx,8), %rdi
testq %rdi, %rdi
je 0x536d
callq 0x2270
incq %rbx
cmpq $0xc, %rbx
jne 0x535e
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x4b76
movl $0x30, %esi
movq %rbx, %rdi
callq 0x21f0
leaq 0x8(%rsp), %rdi
callq 0x27d4
xorl %eax, %eax
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfa5(%rip), %rbx       # 0x6359
movl $0x5f, %ebp
jmp 0x53c7
leaq 0xfad(%rip), %rbx       # 0x636f
movl $0x62, %ebp
movl $0x18, %edi
callq 0x2100
movl %ebp, (%rax)
leaq 0xf6b(%rip), %rcx       # 0x6345
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
leaq 0x39a7(%rip), %rsi      # 0x8d90
movq %rax, %rdi
xorl %edx, %edx
callq 0x22d0
movq %rdx, %r15
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x27d4
jmp 0x542f
jmp 0x5429
movq %rdx, %r15
movq %rax, %r14
movl $0x30, %esi
movq (%rsp), %rdi
callq 0x21f0
jmp 0x542f
jmp 0x5429
jmp 0x5429
jmp 0x5429
jmp 0x5429
jmp 0x5429
jmp 0x5429
movq %rdx, %r15
movq %rax, %r14
cmpl $0x2, %r15d
jne 0x5462
movq %r14, %rdi
callq 0x20c0
movups (%rax), %xmm0
leaq 0x1a0(%rsp), %rdi
movaps %xmm0, (%rdi)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rdi)
callq 0x54cc
callq 0x22b0
jmp 0x5399
cmpl $0x1, %r15d
jne 0x54c3
movq %r14, %rdi
callq 0x20c0
movq %rax, %rbx
movq 0x3b56(%rip), %rdi      # 0x8fd0
leaq 0xf22(%rip), %rsi       # 0x63a3
movl $0x33, %edx
callq 0x2230
movq 0x3b3e(%rip), %rdi      # 0x8fd0
callq 0x20f0
movq %rbx, %rdi
callq 0x2341
movl $0x1, %eax
jmp 0x539b
movq %rax, %r14
callq 0x22b0
jmp 0x54c3
movq %rax, %rdi
callq 0x55f4
movq %rax, %r14
callq 0x22b0
movq %r14, %rdi
callq 0x2300
nop