// File: thierry7100[P]CutOptim/include/nanosvg.h
// Function: nsvg__curveBounds(double*, double*)
static void nsvg__curveBounds(double* bounds, double* curve)
{
	int i, j, count;
	double roots[2], a, b, c, b2ac, t, v;
	double* v0 = &curve[0];
	double* v1 = &curve[2];
	double* v2 = &curve[4];
	double* v3 = &curve[6];

	// Start the bounding box by end points
	bounds[0] = nsvg__minf(v0[0], v3[0]);
	bounds[1] = nsvg__minf(v0[1], v3[1]);
	bounds[2] = nsvg__maxf(v0[0], v3[0]);
	bounds[3] = nsvg__maxf(v0[1], v3[1]);

	// Bezier curve fits inside the convex hull of it's control points.
	// If control points are inside the bounds, we're done.
	if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds))
		return;

	// Add bezier curve inflection points in X and Y.
	for (i = 0; i < 2; i++) {
		a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i];
		b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i];
		c = 3.0 * v1[i] - 3.0 * v0[i];
		count = 0;
		if (fabs(a) < NSVG_EPSILON) {
			if (fabs(b) > NSVG_EPSILON) {
				t = -c / b;
				if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
					roots[count++] = t;
			}
		} else {
			b2ac = b*b - 4.0*c*a;
			if (b2ac > NSVG_EPSILON) {
				t = (-b + sqrt(b2ac)) / (2.0 * a);
				if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
					roots[count++] = t;
				t = (-b - sqrt(b2ac)) / (2.0 * a);
				if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
					roots[count++] = t;
			}
		}
		for (j = 0; j < count; j++) {
			v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]);
			bounds[0+i] = nsvg__minf(bounds[0+i], v);
			bounds[2+i] = nsvg__maxf(bounds[2+i], v);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x80(%rbp)
movq -0x68(%rbp), %rax
movsd (%rax), %xmm0
movq -0x80(%rbp), %rax
movsd (%rax), %xmm1
callq 0x7e6c0
movq -0x8(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x68(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm1
callq 0x7e6c0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x68(%rbp), %rax
movsd (%rax), %xmm0
movq -0x80(%rbp), %rax
movsd (%rax), %xmm1
callq 0x7e700
movq -0x8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x68(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm1
callq 0x7e700
movq -0x8(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movq -0x70(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x7ec60
cmpl $0x0, %eax
je 0x7e823
movq -0x78(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x7ec60
cmpl $0x0, %eax
je 0x7e823
jmp 0x7ec56
movl $0x0, -0x14(%rbp)
cmpl $0x2, -0x14(%rbp)
jge 0x7ec56
movq -0x68(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x70(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd 0x5a27(%rip), %xmm1     # 0x84278
mulsd (%rax,%rcx,8), %xmm1
movsd 0x5a12(%rip), %xmm2     # 0x84270
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x78(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x59ed(%rip), %xmm2     # 0x84268
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq -0x80(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x5868(%rip), %xmm2     # 0x84100
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x68(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x70(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd 0x599e(%rip), %xmm0     # 0x84260
mulsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x5832(%rip), %xmm2     # 0x84118
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq -0x78(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x5815(%rip), %xmm2     # 0x84118
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x70(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x68(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd 0x57d3(%rip), %xmm1     # 0x84100
mulsd (%rax,%rcx,8), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x57af(%rip), %xmm2     # 0x84100
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x1c(%rbp)
movsd -0x38(%rbp), %xmm1
movaps 0x573f(%rip), %xmm0     # 0x840b0
pand %xmm0, %xmm1
movsd 0x58db(%rip), %xmm0     # 0x84258
ucomisd %xmm1, %xmm0
jbe 0x7ea0c
movsd -0x40(%rbp), %xmm0
movaps 0x571d(%rip), %xmm1     # 0x840b0
pand %xmm1, %xmm0
movsd 0x58b9(%rip), %xmm1     # 0x84258
ucomisd %xmm1, %xmm0
jbe 0x7ea07
movsd -0x48(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd 0x5880(%rip), %xmm1     # 0x84258
ucomisd %xmm1, %xmm0
jbe 0x7ea05
movsd 0x589a(%rip), %xmm0     # 0x84280
ucomisd -0x58(%rbp), %xmm0
jbe 0x7ea05
movsd -0x58(%rbp), %xmm0
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
cltq
movsd %xmm0, -0x30(%rbp,%rax,8)
jmp 0x7ea07
jmp 0x7eb81
movsd -0x40(%rbp), %xmm0
movsd -0x40(%rbp), %xmm2
movsd 0x574a(%rip), %xmm1     # 0x84168
mulsd -0x48(%rbp), %xmm1
mulsd -0x38(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movsd 0x57ff(%rip), %xmm1     # 0x84258
ucomisd %xmm1, %xmm0
jbe 0x7eb7f
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x50(%rbp), %xmm0
callq 0x9460
movaps %xmm0, %xmm1
movsd -0x88(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd 0x55f8(%rip), %xmm1     # 0x840a0
mulsd -0x38(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd 0x5795(%rip), %xmm1     # 0x84258
ucomisd %xmm1, %xmm0
jbe 0x7eaf0
movsd 0x57af(%rip), %xmm0     # 0x84280
ucomisd -0x58(%rbp), %xmm0
jbe 0x7eaf0
movsd -0x58(%rbp), %xmm0
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
cltq
movsd %xmm0, -0x30(%rbp,%rax,8)
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x50(%rbp), %xmm0
callq 0x9460
movaps %xmm0, %xmm1
movsd -0x90(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd 0x556b(%rip), %xmm1     # 0x840a0
mulsd -0x38(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd 0x5708(%rip), %xmm1     # 0x84258
ucomisd %xmm1, %xmm0
jbe 0x7eb7d
movsd 0x5722(%rip), %xmm0     # 0x84280
ucomisd -0x58(%rbp), %xmm0
jbe 0x7eb7d
movsd -0x58(%rbp), %xmm0
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x1c(%rbp)
cltq
movsd %xmm0, -0x30(%rbp,%rax,8)
jmp 0x7eb7f
jmp 0x7eb81
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x7ec46
movslq -0x18(%rbp), %rax
movsd -0x30(%rbp,%rax,8), %xmm0
movq -0x68(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x70(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x78(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm3
movq -0x80(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm4
callq 0x7ece0
movsd %xmm0, -0x60(%rbp)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd -0x60(%rbp), %xmm1
callq 0x7e6c0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd -0x60(%rbp), %xmm1
callq 0x7e700
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x7eb88
jmp 0x7ec48
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7e82a
addq $0x90, %rsp
popq %rbp
retq
nop