// File: /workspace/github_c_makefile_star2_O0/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
subq $0xc0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x18b0
cmpl $0x0, %eax
je 0x1666
movl $0x1, -0x4(%rbp)
jmp 0x18a3
movq 0xbb23(%rip), %rdi      # 0xd190
xorl %esi, %esi
movb $0x0, %al
callq 0x1160
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x16ab
movq 0xb972(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x7b97(%rip), %rsi      # 0x922f
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x4(%rbp)
jmp 0x18a3
movb $0x0, %al
callq 0x48e0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x16e0
movq 0xb935(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x7b7a(%rip), %rsi      # 0x9247
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x4(%rbp)
jmp 0x18a3
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x4b00
cmpl $0x0, %eax
je 0x1715
movq 0xb900(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x7b5f(%rip), %rsi      # 0x9261
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x4(%rbp)
jmp 0x18a3
movq -0x18(%rbp), %rdi
callq 0x4970
movq -0x18(%rbp), %rdi
callq 0x4b80
cmpl $0x0, %eax
je 0x1750
movq 0xb8c5(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x7b36(%rip), %rsi      # 0x9273
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x4(%rbp)
jmp 0x18a3
jmp 0x1752
movq -0x18(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4990
cmpl $0x0, %eax
je 0x188f
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rcx
movq %rcx, 0x60(%rax)
movzwl -0x30(%rbp), %eax
movl %eax, -0xb4(%rbp)
subl $0x2, %eax
je 0x17bc
jmp 0x1785
movl -0xb4(%rbp), %eax
subl $0xa, %eax
je 0x180f
jmp 0x1792
movl -0xb4(%rbp), %eax
subl $0x16, %eax
je 0x17bc
jmp 0x179f
movl -0xb4(%rbp), %eax
subl $0x20, %eax
je 0x17bc
jmp 0x17ac
movl -0xb4(%rbp), %eax
subl $0x53, %eax
je 0x17e4
jmp 0x187e
movq -0x18(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x58b0
cmpl $0x0, %eax
jne 0x17df
movq -0x18(%rbp), %rdi
movzwl -0x30(%rbp), %edx
leaq -0x64(%rbp), %rsi
callq 0x1a50
jmp 0x187e
movq -0x18(%rbp), %rdi
leaq -0x94(%rbp), %rsi
callq 0x58f0
cmpl $0x0, %eax
jne 0x180d
movq -0x18(%rbp), %rdi
movzwl -0x30(%rbp), %edx
leaq -0x94(%rbp), %rsi
callq 0x1a50
jmp 0x187e
leaq -0xb0(%rbp), %rdi
callq 0x5480
movq -0x18(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x54f0
cmpl $0x0, %eax
jne 0x1872
movzwl -0xae(%rbp), %eax
cmpl $0x0, %eax
je 0x1872
leaq -0xb0(%rbp), %rdi
callq 0x5560
cmpl $0x0, %eax
jne 0x1872
movq -0x18(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x55d0
cmpl $0x0, %eax
jne 0x1872
movq -0x18(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x1540
leaq -0xb0(%rbp), %rdi
callq 0x54b0
movq -0x18(%rbp), %rax
movq $0x0, 0x60(%rax)
jmp 0x1752
movq -0x18(%rbp), %rdi
callq 0x4940
movq %rax, -0x18(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nop