// File: /workspace/github_c_makefile_star2_O1/joncampbell123[P]swfhax/c4_swf2svg.c
// Function: main
int main(int argc,char **argv) {
	swf_reader *swf;
	swf_tag tag;
	int fd;

	if (parse_argv(argc,argv))
		return 1;

	fd = open(swf_file,O_RDONLY);
	if (fd < 0) {
		fprintf(stderr,"Unable to open file %s\n",argv[1]);
		return 1;
	}
	if ((swf=swf_reader_create()) == NULL) {
		fprintf(stderr,"Cannot create SWF reader\n");
		return 1;
	}
	if (swf_reader_assign_fd(swf,fd)) {
		fprintf(stderr,"Cannot assign fd\n");
		return 1;
	}
	swf_reader_assign_fd_ownership(swf);
	if (swf_reader_get_file_header(swf)) {
		fprintf(stderr,"Unable to read file header.\n");
		return 1;
	}

	while (swf_reader_read_record(swf,&tag)) {
		/* set read stop, so we can read the bitfields */
		swf->read_stop = swf->next_tag;

		switch (tag.record.TagCode) {
			case swftag_DefineShape:
			case swftag_DefineShape2:
			case swftag_DefineShape3: {
				swf_DefineShape nfo;

				if (swf_reader_read_DefineShape_header(swf,&nfo) == 0)
					dump_shape_to_svg(swf,&nfo,tag.record.TagCode);

				} break;
			case swftag_DefineShape4: {
				swf_DefineShape nfo;

				if (swf_reader_read_DefineShape4_header(swf,&nfo) == 0)
					dump_shape_to_svg(swf,&nfo,tag.record.TagCode);

				} break;
			case swftag_DefineFont: {
				swf_DefineFont nfo;

				swf_DefineFont_init(&nfo);
				if (swf_reader_read_DefineFont_step1(swf,&nfo) == 0 && nfo.nGlyphs != 0 &&
					swf_reader_read_DefineFont_alloc_OffsetTable(&nfo) == 0 &&
					swf_reader_read_DefineFont_read_OffsetTable(swf,&nfo) == 0)
					dump_font_to_svg(swf,&nfo);

				swf_DefineFont_free(&nfo);
				} break;
		}

		/* clear read stop */
		swf->read_stop = 0;
	}

	swf = swf_reader_destroy(swf);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
cmpl $0x2, %edi
jl 0x1b0e
movl %edi, %r13d
xorl %r15d, %r15d
movl $0x1, %r12d
movq (%rbx,%r12,8), %r14
cmpb $0x2d, (%r14)
jne 0x1ae7
cmpb $0x2d, 0x1(%r14)
leaq 0x1(%r14), %r14
je 0x1aa9
movq %r14, %rdi
leaq 0x57ee(%rip), %rsi      # 0x72ac
callq 0x10c0
testl %eax, %eax
je 0x1aff
movq %r14, %rdi
leaq 0x57e7(%rip), %rsi      # 0x72b8
callq 0x10c0
testl %eax, %eax
jne 0x1cb5
movb $0x1, 0x96b3(%rip)      # 0xb198
jmp 0x1b06
testl %r15d, %r15d
jne 0x1c86
movq %r14, 0x9689(%rip)      # 0xb180
movl $0x1, %r15d
jmp 0x1b06
movb $0x1, 0x9672(%rip)      # 0xb178
incq %r12
cmpq %r13, %r12
jne 0x1a9f
cmpq $0x0, 0x966a(%rip)      # 0xb180
je 0x1c60
movq 0x965d(%rip), %rdi      # 0xb180
xorl %esi, %esi
xorl %eax, %eax
callq 0x1160
testl %eax, %eax
js 0x1c67
movl %eax, %r14d
xorl %eax, %eax
callq 0x3c1d
testq %rax, %rax
je 0x1c71
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
callq 0x3da3
testl %eax, %eax
jne 0x1c78
movq %rbx, %rdi
callq 0x3c7d
movq %rbx, %rdi
callq 0x3de9
testl %eax, %eax
jne 0x1c7f
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x3c8d
testl %eax, %eax
je 0x1c54
leaq -0x70(%rbp), %r14
leaq -0x40(%rbp), %r15
movq 0x68(%rbx), %rax
movq %rax, 0x60(%rbx)
movzwl -0x40(%rbp), %eax
cmpl $0x15, %eax
jle 0x1bb6
cmpl $0x16, %eax
je 0x1c0e
cmpl $0x53, %eax
je 0x1c1b
cmpl $0x20, %eax
je 0x1c0e
jmp 0x1c39
cmpl $0x2, %eax
je 0x1c0e
cmpl $0xa, %eax
jne 0x1c39
movq %r14, %rdi
callq 0x43cf
movq %rbx, %rdi
movq %r14, %rsi
callq 0x440f
testl %eax, %eax
jne 0x1c04
cmpw $0x0, -0x6e(%rbp)
je 0x1c04
movq %r14, %rdi
callq 0x4488
testl %eax, %eax
jne 0x1c04
movq %rbx, %rdi
movq %r14, %rsi
callq 0x44c1
testl %eax, %eax
jne 0x1c04
movq %rbx, %rdi
movq %r14, %rsi
callq 0x19ca
movq %r14, %rdi
callq 0x43e3
jmp 0x1c39
movq %rbx, %rdi
movq %r14, %rsi
callq 0x472e
jmp 0x1c26
movq %rbx, %rdi
movq %r14, %rsi
callq 0x477c
testl %eax, %eax
jne 0x1c39
movzwl -0x40(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1cf5
movq $0x0, 0x60(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3c8d
testl %eax, %eax
jne 0x1b91
movq %rbx, %rdi
callq 0x3c59
xorl %eax, %eax
jmp 0x1ca6
callq 0x12f4
jmp 0x1ca1
movq %rbx, %rdi
callq 0x12d0
jmp 0x1ca1
callq 0x12a1
jmp 0x1ca1
callq 0x1243
jmp 0x1ca1
callq 0x1272
jmp 0x1ca1
movq 0x936b(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x5650(%rip), %rsi      # 0x72e7
movq %r14, %rdx
xorl %eax, %eax
callq 0x10d0
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5611(%rip), %rsi      # 0x72cd
movq %r14, %rdi
callq 0x10c0
testl %eax, %eax
je 0x1cdb
leaq 0x5600(%rip), %rsi      # 0x72cf
movq %r14, %rdi
callq 0x10c0
testl %eax, %eax
jne 0x1ce2
callq 0x11ef
jmp 0x1ca1
movq 0x930f(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x55e1(%rip), %rsi      # 0x72d4
jmp 0x1c97