// File: /workspace/github_cpp_makefile_star2_O1/thierry7100[P]CutOptim/include/nanosvg.h
// Function: nsvg__addPath(NSVGparser*, char)
static void nsvg__addPath(NSVGparser* p, char closed)
{
	NSVGattrib* attr = nsvg__getAttr(p);
	NSVGpath* path = NULL;
	NSVGPathElt *sElt;
	NSVGPathElt *dElt, *oldElt;
	double bounds[4];
	double curve[8];
	double LastX, LastY;

	int i;

	if (p->nElts < 1)       //  No element in path !
		return;

	if (closed )
	{
        if ( fabs(p->LastElt->EndX - p->StartX) > NSVG_EPSILON || fabs(p->LastElt->EndY - p->StartY) > NSVG_EPSILON )
            nsvg__lineTo(p, p->StartX, p->StartY);      //  Add segment to first point if not yet in this point
	}
	else
	{
        //  Check for closed path, even if 'z' is not used, but start and end points are close
        if ( fabs(p->LastElt->EndX - p->StartX) < NSVG_EPSILON2 && fabs(p->LastElt->EndY - p->StartY) < NSVG_EPSILON2 )
        {
            nsvg__lineTo(p, p->StartX, p->StartY);      //  Add segment to first point
            closed = 1;
        }
	}
	//  Allocate path
	path = (NSVGpath*)malloc(sizeof(NSVGpath));
	if (path == NULL) goto error;
	memset(path, 0, sizeof(NSVGpath));
    //
    path->nElts = p->nElts;
    nsvg__xformPoint(&path->StartX, &path->StartY, p->StartX, p->StartY, attr->xform);
    oldElt = NULL;
    for (sElt = p->FirstElt; sElt != NULL; sElt = sElt->next)
    {
        dElt =(NSVGPathElt *)malloc(sizeof(NSVGPathElt));
        if ( dElt == NULL)
        {
            goto error;
        }
        //  Apply transform from parser to path
        dElt->Type = sElt->Type;
        nsvg__xformPoint(&dElt->EndX, &dElt->EndY, sElt->EndX, sElt->EndY, attr->xform);
        nsvg__xformPoint(&dElt->BzCtrl1X, &dElt->BzCtrl1Y, sElt->BzCtrl1X, sElt->BzCtrl1Y, attr->xform);
        nsvg__xformPoint(&dElt->BzCtrl2X, &dElt->BzCtrl2Y, sElt->BzCtrl2X, sElt->BzCtrl2Y, attr->xform);
        dElt->next = NULL;
        if ( oldElt != NULL)
            oldElt->next = dElt;
        else
            path->PathElts = dElt;
        oldElt = dElt;
    }
	path->closed = closed;

	// Find path bounds
	LastX = path->StartX;
	LastY = path->StartY;
	for (dElt = path->PathElts, i = 0; i < path->nElts; dElt = dElt->next, i++)
	{
        if ( dElt->Type == NSVG_PATH_LINE )
        {
            bounds[0] = nsvg__minf(LastX, dElt->EndX);
            bounds[1] = nsvg__minf(LastY, dElt->EndY);
            bounds[2] = nsvg__maxf(LastX, dElt->EndX);
            bounds[3] = nsvg__maxf(LastY, dElt->EndY);
        }
        else
        {
            curve[0] = LastX;
            curve[1] = LastY;
            curve[2] = dElt->BzCtrl1X;
            curve[3] = dElt->BzCtrl1Y;
            curve[4] = dElt->BzCtrl2X;
            curve[5] = dElt->BzCtrl2Y;
            curve[6] = dElt->EndX;
            curve[7] = dElt->EndY;
            path->hasBezier = true;
            nsvg__curveBounds(bounds, curve);
        }
		if (i == 0)
		{
			path->bounds[0] = bounds[0];
			path->bounds[1] = bounds[1];
			path->bounds[2] = bounds[2];
			path->bounds[3] = bounds[3];
		} else
		{
			path->bounds[0] = nsvg__minf(path->bounds[0], bounds[0]);
			path->bounds[1] = nsvg__minf(path->bounds[1], bounds[1]);
			path->bounds[2] = nsvg__maxf(path->bounds[2], bounds[2]);
			path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]);
		}
	}

	path->next = p->plist;
	p->plist = path;

	return;

error:
	if (path != NULL) {
		if (path->PathElts != NULL) nsvg__deletePathElts(path->PathElts);
		free(path);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
cmpl $0x0, 0xd028(%rdi)
jle 0x3b568
movq %rdi, %rbx
movslq 0xd000(%rdi), %r15
movq 0xd010(%rdi), %rax
movsd 0x8(%rax), %xmm1
movsd 0xd018(%rdi), %xmm0
subsd %xmm0, %xmm1
andpd 0x3efc(%rip), %xmm1     # 0x3f030
testb %sil, %sil
je 0x3b190
ucomisd 0x40ef(%rip), %xmm1     # 0x3f230
ja 0x3b167
movsd 0x10(%rax), %xmm1
subsd 0xd020(%rbx), %xmm1
andpd 0x3ed8(%rip), %xmm1     # 0x3f030
movl $0x1, %ebp
ucomisd 0x40cb(%rip), %xmm1     # 0x3f230
jbe 0x3b1bf
movsd 0xd020(%rbx), %xmm1
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3b95a
movl $0x1, %ebp
jmp 0x3b1bf
xorl %ebp, %ebp
movsd 0x3f2e(%rip), %xmm2     # 0x3f0c8
ucomisd %xmm1, %xmm2
jbe 0x3b1bf
movsd 0x10(%rax), %xmm3
movsd 0xd020(%rbx), %xmm1
subsd %xmm1, %xmm3
andpd 0x3e77(%rip), %xmm3     # 0x3f030
ucomisd %xmm3, %xmm2
ja 0x3b16f
movl $0xf8, %edi
callq 0x7580
testq %rax, %rax
je 0x3b568
movq %rax, %r14
movl $0xf8, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x7270
movl 0xd028(%rbx), %eax
movl %eax, 0x18(%r14)
movsd 0xd018(%rbx), %xmm3
movsd 0xd020(%rbx), %xmm0
imulq $0x1a0, %r15, %rax      # imm = 0x1A0
movsd 0x40(%rbx,%rax), %xmm4
movsd 0x50(%rbx,%rax), %xmm2
movapd %xmm0, %xmm1
movsd %xmm2, 0x58(%rsp)
mulsd %xmm2, %xmm1
movapd %xmm3, %xmm2
movsd %xmm4, 0x8(%rsp)
mulsd %xmm4, %xmm2
addsd %xmm1, %xmm2
movsd 0x60(%rbx,%rax), %xmm1
movsd %xmm1, 0x50(%rsp)
addsd %xmm1, %xmm2
movsd %xmm2, (%r14)
movsd 0x48(%rbx,%rax), %xmm1
movsd 0x58(%rbx,%rax), %xmm2
movsd %xmm2, 0x40(%rsp)
mulsd %xmm2, %xmm0
movsd %xmm1, 0x48(%rsp)
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
movsd 0x68(%rbx,%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
addsd %xmm0, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd %xmm3, 0x8(%r14)
movq 0xd008(%rbx), %r15
testq %r15, %r15
je 0x3b3c1
leaq 0x10(%r14), %r12
xorl %r13d, %r13d
movl $0x40, %edi
callq 0x7580
testq %rax, %rax
je 0x3b57a
movl (%r15), %ecx
movl %ecx, (%rax)
movsd 0x8(%r15), %xmm0
movsd 0x10(%r15), %xmm1
movsd 0x58(%rsp), %xmm5
movapd %xmm5, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm0, %xmm3
movsd 0x8(%rsp), %xmm4
mulsd %xmm4, %xmm3
addsd %xmm2, %xmm3
movsd 0x50(%rsp), %xmm6
addsd %xmm6, %xmm3
movsd %xmm3, 0x8(%rax)
movsd 0x40(%rsp), %xmm8
mulsd %xmm8, %xmm1
movsd 0x48(%rsp), %xmm7
mulsd %xmm7, %xmm0
addsd %xmm1, %xmm0
movsd 0x38(%rsp), %xmm9
addsd %xmm9, %xmm0
movsd %xmm0, 0x10(%rax)
movsd 0x18(%r15), %xmm0
movsd 0x20(%r15), %xmm1
movapd %xmm5, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm4, %xmm3
addsd %xmm2, %xmm3
addsd %xmm6, %xmm3
movsd %xmm3, 0x18(%rax)
mulsd %xmm8, %xmm1
mulsd %xmm7, %xmm0
addsd %xmm1, %xmm0
addsd %xmm9, %xmm0
movsd %xmm0, 0x20(%rax)
movsd 0x28(%r15), %xmm0
movsd 0x30(%r15), %xmm1
movapd %xmm5, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm4, %xmm3
addsd %xmm2, %xmm3
addsd %xmm6, %xmm3
movsd %xmm3, 0x28(%rax)
mulsd %xmm8, %xmm1
mulsd %xmm7, %xmm0
addsd %xmm1, %xmm0
addsd %xmm9, %xmm0
movsd %xmm0, 0x30(%rax)
movq $0x0, 0x38(%rax)
leaq 0x38(%r13), %rcx
testq %r13, %r13
cmoveq %r12, %rcx
movq %rax, (%rcx)
movq 0x38(%r15), %r15
movq %rax, %r13
testq %r15, %r15
jne 0x3b29d
movl %ebp, 0x1c(%r14)
cmpl $0x0, 0x18(%r14)
jle 0x3b556
movsd (%r14), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, %r13
addq $0x10, %r13
xorl %ebp, %ebp
leaq 0x10(%rsp), %r15
leaq 0x60(%rsp), %r12
movq (%r13), %r13
cmpl $0x0, (%r13)
je 0x3b47e
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x18(%r13), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x20(%r13), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x28(%r13), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x30(%r13), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x8(%r13), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x10(%r13), %xmm0
movsd %xmm0, 0x98(%rsp)
movl $0x1, 0x20(%r14)
movq %r15, %rdi
movq %r12, %rsi
callq 0x3ba24
jmp 0x3b4ce
movsd 0x8(%r13), %xmm0
movsd 0x8(%rsp), %xmm4
movapd %xmm4, %xmm1
minsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x10(%r13), %xmm1
movsd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm2
minsd %xmm1, %xmm2
movsd %xmm2, 0x18(%rsp)
movapd %xmm4, %xmm2
maxsd %xmm0, %xmm2
movsd %xmm2, 0x20(%rsp)
movapd %xmm3, %xmm0
maxsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
testl %ebp, %ebp
je 0x3b516
movsd 0x28(%r14), %xmm0
movsd 0x30(%r14), %xmm1
minsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x28(%r14)
minsd 0x18(%rsp), %xmm1
movsd %xmm1, 0x30(%r14)
movsd 0x38(%r14), %xmm0
maxsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x38(%r14)
movsd 0x40(%r14), %xmm0
maxsd 0x28(%rsp), %xmm0
jmp 0x3b540
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x28(%r14)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x30(%r14)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x38(%r14)
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x40(%r14)
addq $0x38, %r13
incl %ebp
cmpl 0x18(%r14), %ebp
jl 0x3b3ee
movq 0xd030(%rbx), %rax
movq %rax, 0x48(%r14)
movq %r14, 0xd030(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x3b594
movq 0x38(%rdi), %rbx
callq 0x7520
movq %rbx, %rdi
testq %rbx, %rbx
jne 0x3b583
movq %r14, %rdi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7520