// File: thierry7100[P]CutOptim/include/nanosvg.h
// Function: nsvg__getLocalBounds(double*, NSVGshape*, double*)
static void nsvg__getLocalBounds(double* bounds, NSVGshape *shape, double* xform)
{
	NSVGpath* path;
	NSVGPathElt *Elt;

	double curve[4*2], curveBounds[4];
	int first = 1;
	for (path = shape->paths; path != NULL; path = path->next)
	{
		nsvg__xformPoint(&curve[0], &curve[1], path->StartX, path->StartY, xform);
		Elt = path->PathElts;
		while ( Elt )
		{
            if ( Elt->Type == NSVG_PATH_LINE )      //Segment, bounding is easy to compute
            {
                nsvg__xformPoint(&curve[6], &curve[7], Elt->EndX, Elt->EndY, xform);
                curveBounds[0] = fmin(curve[0], curve[6]);
                curveBounds[0] = fmin(curve[1], curve[7]);
                curveBounds[0] = fmax(curve[0], curve[6]);
                curveBounds[0] = fmax(curve[1], curve[7]);
            }
            else if ( Elt->Type == NSVG_PATH_BEZIER_C )
            {
                nsvg__xformPoint(&curve[2], &curve[3], Elt->BzCtrl1X, Elt->BzCtrl1Y, xform);
                nsvg__xformPoint(&curve[4], &curve[5], Elt->BzCtrl2X, Elt->BzCtrl2Y, xform);
                nsvg__xformPoint(&curve[6], &curve[7], Elt->EndX, Elt->EndY, xform);
                nsvg__curveBounds(curveBounds, curve);
            }
            else
            {
                fprintf(stderr, "Non supported PathElt type :%d\n", Elt->Type);

            }
			if (first) {
				bounds[0] = curveBounds[0];
				bounds[1] = curveBounds[1];
				bounds[2] = curveBounds[2];
				bounds[3] = curveBounds[3];
				first = 0;
			} else {
				bounds[0] = nsvg__minf(bounds[0], curveBounds[0]);
				bounds[1] = nsvg__minf(bounds[1], curveBounds[1]);
				bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]);
				bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]);
			}
			curve[0] = curve[6];
			curve[1] = curve[7];
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x1, -0x94(%rbp)
movq -0x10(%rbp), %rax
movq 0xf0(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7f327
leaq -0x70(%rbp), %rdi
leaq -0x70(%rbp), %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
movq -0x20(%rbp), %rax
movsd 0x8(%rax), %xmm1
movq -0x18(%rbp), %rdx
callq 0x7e4f0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x7f314
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x7f175
leaq -0x70(%rbp), %rdi
addq $0x30, %rdi
leaq -0x70(%rbp), %rsi
addq $0x38, %rsi
movq -0x28(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd 0x10(%rax), %xmm1
movq -0x18(%rbp), %rdx
callq 0x7e4f0
movsd -0x70(%rbp), %xmm3
movsd -0x40(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm0
cmpunordsd %xmm0, %xmm0
movaps %xmm0, %xmm1
pand %xmm4, %xmm1
minsd %xmm3, %xmm2
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x68(%rbp), %xmm3
movsd -0x38(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm0
cmpunordsd %xmm0, %xmm0
movaps %xmm0, %xmm1
pand %xmm4, %xmm1
minsd %xmm3, %xmm2
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x70(%rbp), %xmm3
movsd -0x40(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm0
cmpunordsd %xmm0, %xmm0
movaps %xmm0, %xmm1
pand %xmm4, %xmm1
maxsd %xmm3, %xmm2
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x68(%rbp), %xmm3
movsd -0x38(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm0
cmpunordsd %xmm0, %xmm0
movaps %xmm0, %xmm1
pand %xmm4, %xmm1
maxsd %xmm3, %xmm2
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x7f235
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x7f215
leaq -0x70(%rbp), %rdi
addq $0x10, %rdi
leaq -0x70(%rbp), %rsi
addq $0x18, %rsi
movq -0x28(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd 0x20(%rax), %xmm1
movq -0x18(%rbp), %rdx
callq 0x7e4f0
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq -0x70(%rbp), %rsi
addq $0x28, %rsi
movq -0x28(%rbp), %rax
movsd 0x28(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd 0x30(%rax), %xmm1
movq -0x18(%rbp), %rdx
callq 0x7e4f0
leaq -0x70(%rbp), %rdi
addq $0x30, %rdi
leaq -0x70(%rbp), %rsi
addq $0x38, %rsi
movq -0x28(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd 0x10(%rax), %xmm1
movq -0x18(%rbp), %rdx
callq 0x7e4f0
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x7e740
jmp 0x7f233
movq 0x38d84(%rip), %rax     # 0xb7fa0
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movl (%rax), %edx
leaq 0x6d33(%rip), %rsi      # 0x85f5f
movb $0x0, %al
callq 0x97c0
jmp 0x7f235
cmpl $0x0, -0x94(%rbp)
je 0x7f287
movsd -0x90(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x88(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movsd -0x80(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movsd -0x78(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movl $0x0, -0x94(%rbp)
jmp 0x7f2fb
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
movsd -0x90(%rbp), %xmm1
callq 0x7e6c0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd -0x88(%rbp), %xmm1
callq 0x7e6c0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0x7e700
movq -0x8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd -0x78(%rbp), %xmm1
callq 0x7e700
movq -0x8(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0x7f06d
jmp 0x7f316
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x7f030
addq $0xa0, %rsp
popq %rbp
retq