// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
cmpl $0x0, 0xd028(%rdi)
jle 0x3a5f7
movq %rdi, %rbx
movslq 0xd000(%rdi), %r15
movq 0xd010(%rdi), %rax
movsd 0x8(%rax), %xmm1
movsd 0xd018(%rdi), %xmm0
subsd %xmm0, %xmm1
andpd 0x3d88(%rip), %xmm1     # 0x3e030
testb %sil, %sil
je 0x3a2c1
ucomisd 0x401b(%rip), %xmm1     # 0x3e2d0
jbe 0x3a2f2
movsd 0xd020(%rbx), %xmm1
jmp 0x3a31a
xorl %ebp, %ebp
movsd 0x3d95(%rip), %xmm2     # 0x3e060
ucomisd %xmm1, %xmm2
jbe 0x3a339
movsd 0x10(%rax), %xmm3
movsd 0xd020(%rbx), %xmm1
subsd %xmm1, %xmm3
andpd 0x3d46(%rip), %xmm3     # 0x3e030
ucomisd %xmm3, %xmm2
ja 0x3a31a
jmp 0x3a339
movsd 0x10(%rax), %xmm2
movsd 0xd020(%rbx), %xmm1
subsd %xmm1, %xmm2
andpd 0x3d25(%rip), %xmm2     # 0x3e030
movl $0x1, %ebp
ucomisd 0x3fb8(%rip), %xmm2     # 0x3e2d0
jbe 0x3a339
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3a969
movl $0x1, %ebp
movl $0x1, %edi
movl $0xf8, %esi
callq 0x72e0
testq %rax, %rax
je 0x3a5f7
movq %rax, %r14
movl %ebp, 0xc(%rsp)
movl 0xd028(%rbx), %ebp
movl %ebp, 0x18(%rax)
imulq $0x1a0, %r15, %rax      # imm = 0x1A0
movupd 0x40(%rbx,%rax), %xmm2
movupd 0x50(%rbx,%rax), %xmm3
movupd 0x60(%rbx,%rax), %xmm4
movsd 0xd018(%rbx), %xmm1
movsd 0xd020(%rbx), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm3, 0x20(%rsp)
mulpd %xmm3, %xmm0
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
movapd %xmm2, 0x30(%rsp)
mulpd %xmm2, %xmm1
addpd %xmm0, %xmm1
movapd %xmm4, 0x10(%rsp)
addpd %xmm4, %xmm1
movapd %xmm1, 0x70(%rsp)
movupd %xmm1, (%r14)
movq %rbx, 0x68(%rsp)
movq 0xd008(%rbx), %r13
testq %r13, %r13
je 0x3a4ad
leaq 0x10(%r14), %r12
xorl %r15d, %r15d
xorl %ebx, %ebx
movl $0x40, %edi
callq 0x7590
testq %rax, %rax
je 0x3a609
movl (%r13), %ecx
movl %ecx, (%rax)
movsd 0x8(%r13), %xmm0
movsd 0x10(%r13), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
movapd 0x20(%rsp), %xmm3
mulpd %xmm3, %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0x30(%rsp), %xmm2
mulpd %xmm2, %xmm0
addpd %xmm1, %xmm0
movapd 0x10(%rsp), %xmm4
addpd %xmm4, %xmm0
movupd %xmm0, 0x8(%rax)
movsd 0x18(%r13), %xmm0
movsd 0x20(%r13), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm3, %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm2, %xmm0
addpd %xmm1, %xmm0
addpd %xmm4, %xmm0
movupd %xmm0, 0x18(%rax)
movsd 0x28(%r13), %xmm0
movsd 0x30(%r13), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm3, %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm2, %xmm0
addpd %xmm1, %xmm0
addpd %xmm4, %xmm0
movupd %xmm0, 0x28(%rax)
movq $0x0, 0x38(%rax)
leaq 0x38(%rbx), %rcx
testq %rbx, %rbx
cmoveq %r12, %rcx
cmoveq %rax, %r15
movq %rax, (%rcx)
movq 0x38(%r13), %r13
movq %rax, %rbx
testq %r13, %r13
jne 0x3a3dd
movl 0xc(%rsp), %eax
movl %eax, 0x1c(%r14)
testl %ebp, %ebp
movq 0x68(%rsp), %rbx
jle 0x3a5e5
movq %r14, %r13
addq $0x10, %r13
xorpd %xmm4, %xmm4
xorl %r15d, %r15d
xorpd %xmm3, %xmm3
leaq 0x80(%rsp), %r12
xorpd %xmm5, %xmm5
movq (%r13), %r13
cmpl $0x0, (%r13)
je 0x3a55c
movaps 0x70(%rsp), %xmm0
movaps %xmm0, 0x80(%rsp)
movups 0x18(%r13), %xmm0
movaps %xmm0, 0x90(%rsp)
movups 0x28(%r13), %xmm0
movaps %xmm0, 0xa0(%rsp)
movupd 0x8(%r13), %xmm0
movapd %xmm0, 0xb0(%rsp)
movl $0x1, 0x20(%r14)
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
movsd %xmm3, 0x30(%rsp)
movapd %xmm4, 0x20(%rsp)
movsd %xmm5, 0x10(%rsp)
callq 0x3aa33
movsd 0x10(%rsp), %xmm5
movapd 0x20(%rsp), %xmm4
movsd 0x30(%rsp), %xmm3
jmp 0x3a584
movupd 0x8(%r13), %xmm0
movapd 0x70(%rsp), %xmm2
movapd %xmm2, %xmm1
minpd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
movapd %xmm2, %xmm1
maxpd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
movsd 0x40(%rsp), %xmm0
testl %r15d, %r15d
je 0x3a5ad
minsd %xmm0, %xmm5
minsd 0x48(%rsp), %xmm3
movsd %xmm5, 0x28(%r14)
movsd %xmm3, 0x30(%r14)
maxpd 0x50(%rsp), %xmm4
jmp 0x3a5c9
movsd %xmm0, 0x28(%r14)
movsd 0x48(%rsp), %xmm3
movsd %xmm3, 0x30(%r14)
movapd 0x50(%rsp), %xmm4
movapd %xmm0, %xmm5
movsd %xmm4, 0x38(%r14)
movhpd %xmm4, 0x40(%r14)
addq $0x38, %r13
incl %r15d
cmpl %ebp, %r15d
jl 0x3a4e0
movq 0xd030(%rbx), %rax
movq %rax, 0x48(%r14)
movq %r14, 0xd030(%rbx)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r15, %r15
je 0x3a622
movq 0x38(%r15), %rbx
movq %r15, %rdi
callq 0x7530
movq %rbx, %r15
testq %rbx, %rbx
jne 0x3a60e
movq %r14, %rdi
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7530