// File: /workspace/github_c_makefile_star2_O3/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, %r13
cmpl $0x2, %edi
jl 0x1a52
movl %edi, %r15d
xorl %eax, %eax
movl $0x1, %r12d
movq (%r13,%r12,8), %r14
cmpb $0x2d, (%r14)
jne 0x1a2a
movl %eax, -0x2c(%rbp)
movb 0x1(%r14), %bl
incq %r14
cmpb $0x2d, %bl
je 0x19eb
movq %r14, %rdi
leaq 0x58ab(%rip), %rsi      # 0x72ac
callq 0x10d0
testl %eax, %eax
je 0x1a40
movq %r14, %rdi
leaq 0x58a4(%rip), %rsi      # 0x72b8
callq 0x10d0
testl %eax, %eax
jne 0x1bf4
movb $0x1, 0x9770(%rip)      # 0xb198
jmp 0x1a47
testl %eax, %eax
jne 0x1bc5
movq %r14, 0x9747(%rip)      # 0xb180
movl $0x1, %eax
jmp 0x1a4a
movb $0x1, 0x9731(%rip)      # 0xb178
movl -0x2c(%rbp), %eax
incq %r12
cmpq %r15, %r12
jne 0x19dd
movq 0x9727(%rip), %rdi      # 0xb180
testq %rdi, %rdi
je 0x1b9f
xorl %esi, %esi
xorl %eax, %eax
callq 0x1170
testl %eax, %eax
js 0x1ba6
movl %eax, %r14d
xorl %eax, %eax
callq 0x3b76
testq %rax, %rax
je 0x1bb0
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
callq 0x3cd7
testl %eax, %eax
jne 0x1bb7
movq %rbx, %rdi
callq 0x3bbb
movq %rbx, %rdi
callq 0x3d1d
testl %eax, %eax
jne 0x1bbe
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x3bcb
testl %eax, %eax
je 0x1b93
leaq -0x78(%rbp), %r14
leaq -0x48(%rbp), %r15
movq 0x68(%rbx), %rax
movq %rax, 0x60(%rbx)
movzwl -0x48(%rbp), %eax
cmpl $0x15, %eax
jle 0x1af5
cmpl $0x16, %eax
je 0x1b4d
cmpl $0x53, %eax
je 0x1b5a
cmpl $0x20, %eax
je 0x1b4d
jmp 0x1b78
cmpl $0x2, %eax
je 0x1b4d
cmpl $0xa, %eax
jne 0x1b78
movq %r14, %rdi
callq 0x4303
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4343
testl %eax, %eax
jne 0x1b43
cmpw $0x0, -0x76(%rbp)
je 0x1b43
movq %r14, %rdi
callq 0x43bc
testl %eax, %eax
jne 0x1b43
movq %rbx, %rdi
movq %r14, %rsi
callq 0x43f5
testl %eax, %eax
jne 0x1b43
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1905
movq %r14, %rdi
callq 0x4317
jmp 0x1b78
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4660
jmp 0x1b65
movq %rbx, %rdi
movq %r14, %rsi
callq 0x46ae
testl %eax, %eax
jne 0x1b78
movzwl -0x48(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1c2d
movq $0x0, 0x60(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3bcb
testl %eax, %eax
jne 0x1ad0
movq %rbx, %rdi
callq 0x3b97
xorl %eax, %eax
jmp 0x1be5
callq 0x1304
jmp 0x1be0
movq %r13, %rdi
callq 0x12e0
jmp 0x1be0
callq 0x12b1
jmp 0x1be0
callq 0x1253
jmp 0x1be0
callq 0x1282
jmp 0x1be0
movq 0x942c(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x570f(%rip), %rsi      # 0x72e5
movq %r14, %rdx
xorl %eax, %eax
callq 0x10e0
movl $0x1, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x68, %bl
jne 0x1c00
cmpb $0x0, 0x1(%r14)
je 0x1c13
leaq 0x56c6(%rip), %rsi      # 0x72cd
movq %r14, %rdi
callq 0x10d0
testl %eax, %eax
jne 0x1c1a
callq 0x11ff
jmp 0x1be0
movq 0x93d7(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x56a7(%rip), %rsi      # 0x72d2
jmp 0x1bd6