// File: /workspace/github_c_makefile_star2_O3/joncampbell123[P]swfhax/c4_swf2svg.c
// Function: do_dump_font_to_svg
void do_dump_font_to_svg(swf_reader *swf,FILE *fp) {
	unsigned int Xmin,Xmax,Ymin,Ymax;
	swf_SHAPE_reading r;
	unsigned int op=0;
	int pos_x,pos_y;

	Xmin = -20 * 50;
	Ymin = -20 * 50;
	Xmax =  20 * 50;
	Ymax =  20 * 50;

	fprintf(fp,"<?xml version=\"1.0\" standalone=\"no\"?>\n");
	fprintf(fp,"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
	fprintf(fp,"<svg width=\"%upx\" height=\"%upx\" viewBox=\"0 0 %u %u\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
		(Xmax - Xmin) / SWF_TWIPS_PER_PIXEL,
		(Ymax - Ymin) / SWF_TWIPS_PER_PIXEL,
		Xmax - Xmin,
		Ymax - Ymin);
	fprintf(fp,"  <style type=\"text/css\"><![CDATA[\n");
	if (outline_only)
		fprintf(fp,"   .blackpen { fill:none; stroke:black; stroke-width:20 }\n");
	else
		fprintf(fp,"   .blackpen { fill:black; stroke:none; }\n");

	fprintf(fp,"  ]]></style>\n");
#if 0
	fprintf(fp,"  <rect x=\"0\" y=\"0\" width=\"%u\" height=\"%u\" fill=\"none\" stroke=\"blue\" stroke-width=\"20\" /><!-- DEBUG BORDERLINE -->\n",
		Xmax - Xmin,
		Ymax - Ymin);
#endif

	pos_x = pos_y = 0;
	if (swf_reader_read_SHAPE_beginning(swf,&r) == 0) {
		while (swf_reader_read_SHAPE_record(swf,&r) == 0) {
			if (r.ShapeRecord_type == swf_shrec_EndShapeRecord)
				break;

			if (!op) {
				fprintf(fp,"  <path class=\"blackpen\" d=\"");
				op = 1;
			}

			if (r.ShapeRecord_type == swf_shrec_StraightEdgeRecord) {
				pos_x += r.shrec.edge.StraightEdgeRecord.DeltaX;
				pos_y += r.shrec.edge.StraightEdgeRecord.DeltaY;
				fprintf(fp,"L %d %d ",pos_x - Xmin,pos_y - Ymin);
			}
			else if (r.ShapeRecord_type == swf_shrec_CurvedEdgeRecord) {
				pos_x += r.shrec.edge.CurvedEdgeRecord.ControlDeltaX;
				pos_y += r.shrec.edge.CurvedEdgeRecord.ControlDeltaY;
				fprintf(fp,"Q %d %d ",pos_x - Xmin,pos_y - Ymin);
				pos_x += r.shrec.edge.CurvedEdgeRecord.AnchorDeltaX;
				pos_y += r.shrec.edge.CurvedEdgeRecord.AnchorDeltaY;
				fprintf(fp,"%d %d ",pos_x - Xmin,pos_y - Ymin);
			}
			else if (r.ShapeRecord_type == swf_shrec_StyleChangeRecord) {
				if (r.shrec.style.StyleChangeRecord.StateNewStyles) {
#if 0
					fprintf(stderr,"NewStyles in Font??\n");
#endif
					break;
				}

				if (r.shrec.style.StyleChangeRecord.StateMoveTo) {
					pos_x = r.shrec.style.StyleChangeRecord.MoveDeltaX;
					pos_y = r.shrec.style.StyleChangeRecord.MoveDeltaY;
				}

				fprintf(fp,"M %d %d ",pos_x - Xmin,pos_y - Ymin);
			}
		}

		if (op) {
			fprintf(fp,"\" />\n");
			op = 0;
		}
	}

	fprintf(fp,"</svg>\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x5916(%rip), %rdi      # 0x7020
movl $0x26, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11b0
leaq 0x5924(%rip), %rdi      # 0x7047
movl $0x63, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11b0
leaq 0x596f(%rip), %rsi      # 0x70ab
movq %rbx, %rdi
movl $0x64, %edx
movl $0x64, %ecx
movl $0x7d0, %r8d            # imm = 0x7D0
movl $0x7d0, %r9d            # imm = 0x7D0
xorl %eax, %eax
callq 0x10e0
leaq 0x59af(%rip), %rdi      # 0x7112
movl $0x23, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11b0
cmpb $0x1, 0x99fc(%rip)      # 0xb178
jne 0x178c
leaq 0x59b1(%rip), %rdi      # 0x7136
movl $0x3a, %esi
jmp 0x1798
leaq 0x59de(%rip), %rdi      # 0x7171
movl $0x2a, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11b0
leaq 0x59f0(%rip), %rdi      # 0x719c
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11b0
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x4765
testl %eax, %eax
jne 0x18dd
leaq -0x50(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x47b3
testl %eax, %eax
setne %cl
movb 0x10(%r15), %al
testb %al, %al
sete %dl
orb %cl, %dl
jne 0x18dd
movb $0x1, %cl
movl $0x3e8, %r13d           # imm = 0x3E8
xorl %r12d, %r12d
xorl %r15d, %r15d
testb $0x1, %cl
je 0x1826
movl $0x1c, %esi
movl $0x1, %edx
leaq 0x5990(%rip), %rdi      # 0x71ab
movq %rbx, %rcx
callq 0x11b0
movb -0x40(%rbp), %al
cmpb $0x1, %al
je 0x187a
movzbl %al, %eax
cmpl $0x3, %eax
je 0x1848
cmpl $0x2, %eax
jne 0x18a7
addl -0x38(%rbp), %r15d
addl -0x34(%rbp), %r12d
leaq 0x5982(%rip), %rsi      # 0x71c8
jmp 0x1895
addl -0x38(%rbp), %r15d
addl -0x34(%rbp), %r12d
leal (%r15,%r13), %edx
leal (%r12,%r13), %ecx
movq %rbx, %rdi
leaq 0x596f(%rip), %rsi      # 0x71d1
xorl %eax, %eax
callq 0x10e0
addl -0x30(%rbp), %r15d
addl -0x2c(%rbp), %r12d
leaq 0x5952(%rip), %rsi      # 0x71ca
jmp 0x1895
movzwl -0x3c(%rbp), %eax
testb $0x1, %al
jne 0x18c4
testb $0x10, %al
je 0x188e
movl -0x38(%rbp), %r15d
movl -0x34(%rbp), %r12d
leaq 0x5945(%rip), %rsi      # 0x71da
leal (%r15,%r13), %edx
leal (%r12,%r13), %ecx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10e0
movq %r14, %rdi
leaq -0x50(%rbp), %rsi
callq 0x47b3
testl %eax, %eax
jne 0x18c4
xorl %ecx, %ecx
movb -0x40(%rbp), %al
testb %al, %al
jne 0x1805
leaq 0x5ddc(%rip), %rdi      # 0x76a7
movl $0x5, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11b0
leaq 0x58ff(%rip), %rdi      # 0x71e3
movl $0x7, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11b0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq