// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0xfffffc18, -0x14(%rbp) # imm = 0xFFFFFC18
movl $0xfffffc18, -0x1c(%rbp) # imm = 0xFFFFFC18
movl $0x3e8, -0x18(%rbp)     # imm = 0x3E8
movl $0x3e8, -0x20(%rbp)     # imm = 0x3E8
movq -0x10(%rbp), %rdi
leaq 0x7d26(%rip), %rsi      # 0x9004
movb $0x0, %al
callq 0x10d0
movq -0x10(%rbp), %rdi
leaq 0x7d3b(%rip), %rsi      # 0x902b
movb $0x0, %al
callq 0x10d0
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl $0x14, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x58(%rbp)
movl -0x20(%rbp), %eax
subl -0x1c(%rbp), %eax
movl $0x14, %ecx
xorl %edx, %edx
divl %ecx
movl -0x58(%rbp), %edx
movl %eax, %ecx
movl -0x18(%rbp), %r8d
subl -0x14(%rbp), %r8d
movl -0x20(%rbp), %r9d
subl -0x1c(%rbp), %r9d
leaq 0x7d57(%rip), %rsi      # 0x908f
movb $0x0, %al
callq 0x10d0
movq -0x10(%rbp), %rdi
leaq 0x7dac(%rip), %rsi      # 0x90f6
movb $0x0, %al
callq 0x10d0
cmpl $0x0, 0xbe30(%rip)      # 0xd188
je 0x136e
movq -0x10(%rbp), %rdi
leaq 0x7db5(%rip), %rsi      # 0x911a
movb $0x0, %al
callq 0x10d0
jmp 0x1380
movq -0x10(%rbp), %rdi
leaq 0x7ddc(%rip), %rsi      # 0x9155
movb $0x0, %al
callq 0x10d0
movq -0x10(%rbp), %rdi
leaq 0x7df5(%rip), %rsi      # 0x9180
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x59c0
cmpl $0x0, %eax
jne 0x1527
jmp 0x13b8
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5a40
cmpl $0x0, %eax
jne 0x1506
movzbl -0x38(%rbp), %eax
cmpl $0x0, %eax
jne 0x13dc
jmp 0x1506
cmpl $0x0, -0x4c(%rbp)
jne 0x13fb
movq -0x10(%rbp), %rdi
leaq 0x7da2(%rip), %rsi      # 0x918f
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x4c(%rbp)
movzbl -0x38(%rbp), %eax
cmpl $0x2, %eax
jne 0x1439
movl -0x30(%rbp), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x2c(%rbp), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %edx
subl -0x14(%rbp), %edx
movl -0x54(%rbp), %ecx
subl -0x1c(%rbp), %ecx
leaq 0x7d7f(%rip), %rsi      # 0x91ac
movb $0x0, %al
callq 0x10d0
jmp 0x1501
movzbl -0x38(%rbp), %eax
cmpl $0x3, %eax
jne 0x14a4
movl -0x30(%rbp), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x2c(%rbp), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %edx
subl -0x14(%rbp), %edx
movl -0x54(%rbp), %ecx
subl -0x1c(%rbp), %ecx
leaq 0x7d4a(%rip), %rsi      # 0x91b5
movb $0x0, %al
callq 0x10d0
movl -0x28(%rbp), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x24(%rbp), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %edx
subl -0x14(%rbp), %edx
movl -0x54(%rbp), %ecx
subl -0x1c(%rbp), %ecx
leaq 0x7d13(%rip), %rsi      # 0x91ae
movb $0x0, %al
callq 0x10d0
jmp 0x14ff
movzbl -0x38(%rbp), %eax
cmpl $0x1, %eax
jne 0x14fd
movw -0x34(%rbp), %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x14bf
jmp 0x1506
movw -0x34(%rbp), %ax
shrw $0x4, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x14df
movl -0x30(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %edx
subl -0x14(%rbp), %edx
movl -0x54(%rbp), %ecx
subl -0x1c(%rbp), %ecx
leaq 0x7cc8(%rip), %rsi      # 0x91be
movb $0x0, %al
callq 0x10d0
jmp 0x14ff
jmp 0x1501
jmp 0x13b8
cmpl $0x0, -0x4c(%rbp)
je 0x1525
movq -0x10(%rbp), %rdi
leaq 0x8176(%rip), %rsi      # 0x968d
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x4c(%rbp)
jmp 0x1527
movq -0x10(%rbp), %rdi
leaq 0x7c95(%rip), %rsi      # 0x91c7
movb $0x0, %al
callq 0x10d0
addq $0x60, %rsp
popq %rbp
retq
nop