// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movq %rsi, %rbx
movslq %edi, %r13
movb $0x1, %al
movl %eax, -0x2c(%rbp)
pushq $0x1
popq %r12
cmpq %r13, %r12
jge 0x1612
movq (%rbx,%r12,8), %r14
incq %r12
cmpb $0x2d, (%r14)
jne 0x15f8
movb 0x1(%r14), %r15b
incq %r14
cmpb $0x2d, %r15b
je 0x15af
movq %r14, %rdi
leaq 0x4ce6(%rip), %rsi      # 0x62ac
callq 0x10d0
testl %eax, %eax
je 0x15ef
movq %r14, %rdi
leaq 0x4cdf(%rip), %rsi      # 0x62b8
callq 0x10d0
testl %eax, %eax
jne 0x17c0
movb $0x1, 0x8bab(%rip)      # 0xa198
jmp 0x159d
movb $0x1, 0x8b82(%rip)      # 0xa178
jmp 0x159d
testb $0x1, -0x2c(%rbp)
je 0x1853
movq %r14, 0x8b77(%rip)      # 0xa180
movl $0x0, -0x2c(%rbp)
jmp 0x159d
movq 0x8b67(%rip), %rdi      # 0xa180
testq %rdi, %rdi
je 0x1746
xorl %esi, %esi
xorl %eax, %eax
callq 0x1170
testl %eax, %eax
js 0x175b
movl %eax, %r14d
xorl %eax, %eax
callq 0x3425
testq %rax, %rax
je 0x1775
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
callq 0x3548
testl %eax, %eax
jne 0x178a
movq %rbx, %rdi
callq 0x3465
movq %rbx, %rdi
callq 0x358e
testl %eax, %eax
jne 0x179f
leaq -0x48(%rbp), %r14
leaq -0x78(%rbp), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3475
testl %eax, %eax
je 0x1737
movq 0x68(%rbx), %rax
movq %rax, 0x60(%rbx)
movzwl -0x48(%rbp), %eax
cmpl $0x2, %eax
je 0x16b4
cmpl $0xa, %eax
je 0x16c1
cmpl $0x16, %eax
je 0x16b4
cmpl $0x53, %eax
je 0x170f
cmpl $0x20, %eax
jne 0x172d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3d29
jmp 0x171a
movq %r15, %rdi
callq 0x3ada
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3b0f
testl %eax, %eax
jne 0x1705
cmpw $0x0, -0x76(%rbp)
je 0x1705
movq %r15, %rdi
callq 0x3b48
testl %eax, %eax
jne 0x1705
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3b81
testl %eax, %eax
jne 0x1705
movq %rbx, %rdi
movq %r15, %rsi
callq 0x14c1
movq %r15, %rdi
callq 0x3aeb
jmp 0x172d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3d54
testl %eax, %eax
jne 0x172d
movzwl -0x48(%rbp), %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1866
andq $0x0, 0x60(%rbx)
jmp 0x167c
movq %rbx, %rdi
callq 0x3441
xorl %eax, %eax
jmp 0x1844
movq 0x88ab(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x4ba8(%rip), %rdi      # 0x62ff
pushq $0x24
jmp 0x17b2
movq 0x8896(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x8(%rbx), %rdx
leaq 0x4adb(%rip), %rsi      # 0x624b
jmp 0x183a
movq 0x887c(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x4add(%rip), %rdi      # 0x6263
pushq $0x19
jmp 0x17b2
movq 0x8867(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x4ae2(%rip), %rdi      # 0x627d
pushq $0x11
jmp 0x17b2
movq 0x8852(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x4adf(%rip), %rdi      # 0x628f
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x11b0
jmp 0x1841
cmpb $0x68, %r15b
jne 0x17cd
cmpb $0x0, 0x1(%r14)
je 0x17e0
leaq 0x4af9(%rip), %rsi      # 0x62cd
movq %r14, %rdi
callq 0x10d0
testl %eax, %eax
jne 0x1826
movq 0x8811(%rip), %r14      # 0x9ff8
movq (%r14), %rcx
leaq 0x4b33(%rip), %rdi      # 0x6324
pushq $0x1c
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x11b0
movq (%r14), %rcx
leaq 0x4b38(%rip), %rdi      # 0x6341
pushq $0x4c
popq %rsi
movq %rbx, %rdx
callq 0x11b0
movq (%r14), %rcx
leaq 0x4b70(%rip), %rdi      # 0x638e
pushq $0x5c
popq %rsi
movq %rbx, %rdx
jmp 0x17b6
movq 0x87cb(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x4a9b(%rip), %rsi      # 0x62d2
movq %r14, %rdx
xorl %eax, %eax
callq 0x10e0
pushq $0x1
popq %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x879e(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x4a81(%rip), %rsi      # 0x62e5
jmp 0x1837