// File: thierry7100[P]CutOptim/include/nanosvg.h
// Function: nsvg__addShape(NSVGparser*)
static void nsvg__addShape(NSVGparser* p)
{
	NSVGattrib* attr = nsvg__getAttr(p);
	double scale = 1.0;
	NSVGshape* shape;
	NSVGpath* path;
	int i;

	if (p->plist == NULL)
		return;

	shape = (NSVGshape*)malloc(sizeof(NSVGshape));
	if (shape == NULL) goto error;
	memset(shape, 0, sizeof(NSVGshape));

	memcpy(shape->id, attr->id, sizeof shape->id);
	scale = nsvg__getAverageScale(attr->xform);
	shape->strokeWidth = attr->strokeWidth * scale;
	shape->strokeDashOffset = attr->strokeDashOffset * scale;
	shape->strokeDashCount = (char)attr->strokeDashCount;
	for (i = 0; i < attr->strokeDashCount; i++)
		shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
	shape->strokeLineJoin = attr->strokeLineJoin;
	shape->strokeLineCap = attr->strokeLineCap;
	shape->miterLimit = attr->miterLimit;
	shape->fillRule = attr->fillRule;
	shape->opacity = attr->opacity;

	shape->paths = p->plist;
	p->plist = NULL;

	// Calculate shape bounds
	shape->bounds[0] = shape->paths->bounds[0];
	shape->bounds[1] = shape->paths->bounds[1];
	shape->bounds[2] = shape->paths->bounds[2];
	shape->bounds[3] = shape->paths->bounds[3];
	for (path = shape->paths->next; path != NULL; path = path->next) {
		shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]);
		shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]);
		shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]);
		shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]);
	}

	// Set fill
	if (attr->hasFill == 0) {
		shape->fill.type = NSVG_PAINT_NONE;
	} else if (attr->hasFill == 1) {
		shape->fill.type = NSVG_PAINT_COLOR;
		shape->fill.color = attr->fillColor;
		shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24;
	} else if (attr->hasFill == 2) {
		double inv[6], localBounds[4];
		nsvg__xformInverse(inv, attr->xform);
		nsvg__getLocalBounds(localBounds, shape, inv);
		shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type);
		if (shape->fill.gradient == NULL) {
			shape->fill.type = NSVG_PAINT_NONE;
		}
	}

	// Set stroke
	if (attr->hasStroke == 0) {
		shape->stroke.type = NSVG_PAINT_NONE;
	} else if (attr->hasStroke == 1) {
		shape->stroke.type = NSVG_PAINT_COLOR;
		shape->stroke.color = attr->strokeColor;
		shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24;
	} else if (attr->hasStroke == 2) {
		double inv[6], localBounds[4];
		nsvg__xformInverse(inv, attr->xform);
		nsvg__getLocalBounds(localBounds, shape, inv);
		shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type);
		if (shape->stroke.gradient == NULL)
			shape->stroke.type = NSVG_PAINT_NONE;
	}

	// Set flags
	shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00);

	// Add to tail
	if (p->image->shapes == NULL)
		p->image->shapes = shape;
	else
		p->shapesTail->next = shape;
	p->shapesTail = shape;

	return;

error:
	if (shape) free(shape);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7a330
movq %rax, -0x10(%rbp)
movsd 0x6434(%rip), %xmm0     # 0x840f8
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0xd030(%rax)
jne 0x7dcdc
jmp 0x7e1d9
movl $0x100, %edi            # imm = 0x100
callq 0x9730
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7dcf6
jmp 0x7e1c9
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x92f0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x40, %edx
callq 0x9490
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0x7ed90
movsd %xmm0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movsd 0x110(%rax), %xmm0
mulsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0x68(%rax)
movq -0x10(%rbp), %rax
movsd 0x118(%rax), %xmm0
mulsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0x70(%rax)
movq -0x10(%rbp), %rax
movl 0x160(%rax), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xb8(%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x160(%rcx), %eax
jge 0x7ddb9
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd 0x120(%rax,%rcx,8), %xmm0
mulsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, 0x78(%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7dd7b
movq -0x10(%rbp), %rax
movb 0x164(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0xb9(%rax)
movq -0x10(%rbp), %rax
movb 0x165(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0xba(%rax)
movq -0x10(%rbp), %rax
movsd 0x168(%rax), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xc0(%rax)
movq -0x10(%rbp), %rax
movb 0x170(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0xc8(%rax)
movq -0x10(%rbp), %rax
movsd 0x78(%rax), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0x60(%rax)
movq -0x8(%rbp), %rax
movq 0xd030(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0xf0(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0xd030(%rax)
movq -0x20(%rbp), %rax
movq 0xf0(%rax), %rax
movsd 0x28(%rax), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xd0(%rax)
movq -0x20(%rbp), %rax
movq 0xf0(%rax), %rax
movsd 0x30(%rax), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xd8(%rax)
movq -0x20(%rbp), %rax
movq 0xf0(%rax), %rax
movsd 0x38(%rax), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xe0(%rax)
movq -0x20(%rbp), %rax
movq 0xf0(%rax), %rax
movsd 0x40(%rax), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xe8(%rax)
movq -0x20(%rbp), %rax
movq 0xf0(%rax), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x7df7b
movq -0x20(%rbp), %rax
movsd 0xd0(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd 0x28(%rax), %xmm1
callq 0x7e6c0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xd0(%rax)
movq -0x20(%rbp), %rax
movsd 0xd8(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd 0x30(%rax), %xmm1
callq 0x7e6c0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xd8(%rax)
movq -0x20(%rbp), %rax
movsd 0xe0(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd 0x38(%rax), %xmm1
callq 0x7e700
movq -0x20(%rbp), %rax
movsd %xmm0, 0xe0(%rax)
movq -0x20(%rbp), %rax
movsd 0xe8(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd 0x40(%rax), %xmm1
callq 0x7e700
movq -0x20(%rbp), %rax
movsd %xmm0, 0xe8(%rax)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x7dec7
movq -0x10(%rbp), %rax
movsbl 0x198(%rax), %eax
cmpl $0x0, %eax
jne 0x7df98
movq -0x20(%rbp), %rax
movb $0x0, 0x40(%rax)
jmp 0x7e062
movq -0x10(%rbp), %rax
movsbl 0x198(%rax), %eax
cmpl $0x1, %eax
jne 0x7dfec
movq -0x20(%rbp), %rax
movb $0x1, 0x40(%rax)
movq -0x10(%rbp), %rax
movl 0x70(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rax
movsd 0x80(%rax), %xmm0
movsd 0x6216(%rip), %xmm1     # 0x841e8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
shll $0x18, %ecx
movq -0x20(%rbp), %rax
orl 0x48(%rax), %ecx
movl %ecx, 0x48(%rax)
jmp 0x7e060
movq -0x10(%rbp), %rax
movsbl 0x198(%rax), %eax
cmpl $0x2, %eax
jne 0x7e05e
leaq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x40, %rsi
callq 0x7ee30
leaq -0x80(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x7f000
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x90, %rsi
leaq -0x80(%rbp), %rdx
movq -0x20(%rbp), %rcx
addq $0x40, %rcx
callq 0x7f330
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x7e05c
movq -0x20(%rbp), %rax
movb $0x0, 0x40(%rax)
jmp 0x7e05e
jmp 0x7e060
jmp 0x7e062
movq -0x10(%rbp), %rax
movsbl 0x199(%rax), %eax
cmpl $0x0, %eax
jne 0x7e07f
movq -0x20(%rbp), %rax
movb $0x0, 0x50(%rax)
jmp 0x7e158
movq -0x10(%rbp), %rax
movsbl 0x199(%rax), %eax
cmpl $0x1, %eax
jne 0x7e0d6
movq -0x20(%rbp), %rax
movb $0x1, 0x50(%rax)
movq -0x10(%rbp), %rax
movl 0x74(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x10(%rbp), %rax
movsd 0x88(%rax), %xmm0
movsd 0x612f(%rip), %xmm1     # 0x841e8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
shll $0x18, %ecx
movq -0x20(%rbp), %rax
orl 0x58(%rax), %ecx
movl %ecx, 0x58(%rax)
jmp 0x7e156
movq -0x10(%rbp), %rax
movsbl 0x199(%rax), %eax
cmpl $0x2, %eax
jne 0x7e154
leaq -0xb0(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x40, %rsi
callq 0x7ee30
leaq -0xd0(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x7f000
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0xd0, %rsi
leaq -0xd0(%rbp), %rdx
movq -0x20(%rbp), %rcx
addq $0x50, %rcx
callq 0x7f330
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0x7e152
movq -0x20(%rbp), %rax
movb $0x0, 0x50(%rax)
jmp 0x7e154
jmp 0x7e156
jmp 0x7e158
movq -0x10(%rbp), %rax
movb 0x19a(%rax), %dl
xorl %eax, %eax
movl $0x1, %ecx
cmpb $0x0, %dl
cmovnel %ecx, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xc9(%rax)
movq -0x8(%rbp), %rax
movq 0xd038(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x7e1a2
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0xd038(%rax), %rax
movq %rcx, 0x10(%rax)
jmp 0x7e1b8
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0xd048(%rax), %rax
movq %rcx, 0xf8(%rax)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xd048(%rax)
jmp 0x7e1d9
cmpq $0x0, -0x20(%rbp)
je 0x7e1d9
movq -0x20(%rbp), %rdi
callq 0x9690
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)