// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x5856(%rip), %rdi      # 0x7020
movl $0x26, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
leaq 0x5864(%rip), %rdi      # 0x7047
movl $0x63, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
leaq 0x58af(%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 0x10d0
leaq 0x58ef(%rip), %rdi      # 0x7112
movl $0x23, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
cmpb $0x1, 0x993c(%rip)      # 0xb178
jne 0x184c
leaq 0x58f1(%rip), %rdi      # 0x7136
movl $0x3a, %esi
jmp 0x1858
leaq 0x591e(%rip), %rdi      # 0x7171
movl $0x2a, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
leaq 0x5930(%rip), %rdi      # 0x719c
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x4833
testl %eax, %eax
jne 0x19a2
leaq -0x58(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x4881
testl %eax, %eax
setne %al
cmpb $0x0, 0x10(%r15)
sete %cl
orb %al, %cl
jne 0x19a2
movb %cl, -0x29(%rbp)
movb $0x1, %al
movl $0x3e8, %r13d           # imm = 0x3E8
xorl %r12d, %r12d
xorl %r15d, %r15d
testb $0x1, %al
je 0x18e4
movl $0x1c, %esi
movl $0x1, %edx
leaq 0x58cf(%rip), %rdi      # 0x71ab
movq %rbx, %rcx
callq 0x11a0
movzbl -0x48(%rbp), %eax
cmpl $0x1, %eax
je 0x193a
cmpl $0x3, %eax
je 0x1908
cmpl $0x2, %eax
jne 0x1967
addl -0x40(%rbp), %r15d
addl -0x3c(%rbp), %r12d
leaq 0x58c2(%rip), %rsi      # 0x71c8
jmp 0x1955
addl -0x40(%rbp), %r15d
addl -0x3c(%rbp), %r12d
leal (%r15,%r13), %edx
leal (%r12,%r13), %ecx
movq %rbx, %rdi
leaq 0x58af(%rip), %rsi      # 0x71d1
xorl %eax, %eax
callq 0x10d0
addl -0x38(%rbp), %r15d
addl -0x34(%rbp), %r12d
leaq 0x5892(%rip), %rsi      # 0x71ca
jmp 0x1955
movzwl -0x44(%rbp), %eax
testb $0x1, %al
jne 0x1983
testb $0x10, %al
je 0x194e
movl -0x40(%rbp), %r15d
movl -0x3c(%rbp), %r12d
leaq 0x5885(%rip), %rsi      # 0x71da
leal (%r15,%r13), %edx
leal (%r12,%r13), %ecx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movq %r14, %rdi
leaq -0x58(%rbp), %rsi
callq 0x4881
testl %eax, %eax
jne 0x1983
xorl %eax, %eax
cmpb $0x0, -0x48(%rbp)
jne 0x18c7
cmpb $0x0, -0x29(%rbp)
jne 0x19a2
leaq 0x5d19(%rip), %rdi      # 0x76a9
movl $0x5, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
leaq 0x583a(%rip), %rdi      # 0x71e3
movl $0x7, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11a0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq