// File: thierry7100[P]CutOptim/include/nanosvg.h
// Function: nsvg__parseGradientStop(NSVGparser*, char const**)
static void nsvg__parseGradientStop(NSVGparser* p, const char** attr)
{
	NSVGattrib* curAttr = nsvg__getAttr(p);
	NSVGgradientData* grad;
	NSVGgradientStop* stop;
	int i, idx;

	curAttr->stopOffset = 0;
	curAttr->stopColor = 0;
	curAttr->stopOpacity = 1.0;

	for (i = 0; attr[i]; i += 2) {
		nsvg__parseAttr(p, attr[i], attr[i + 1]);
	}

	// Add stop to the last gradient.
	grad = p->gradients;
	if (grad == NULL) return;

	grad->nstops++;
	grad->stops = (NSVGgradientStop*)realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops);
	if (grad->stops == NULL) return;

	// Insert
	idx = grad->nstops-1;
	for (i = 0; i < grad->nstops-1; i++) {
		if (curAttr->stopOffset < grad->stops[i].offset) {
			idx = i;
			break;
		}
	}
	if (idx != grad->nstops-1) {
		for (i = grad->nstops-1; i > idx; i--)
			grad->stops[i] = grad->stops[i-1];
	}

	stop = &grad->stops[idx];
	stop->color = curAttr->stopColor;
	stop->color |= (unsigned int)(curAttr->stopOpacity*255) << 24;
	stop->offset = curAttr->stopOffset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7a330
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x190(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x180(%rax)
movq -0x18(%rbp), %rax
movsd 0xc822(%rip), %xmm0     # 0x840f8
movsd %xmm0, 0x188(%rax)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x77925
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
callq 0x79b90
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
jmp 0x778e5
movq -0x8(%rbp), %rax
movq 0xd040(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x77940
jmp 0x77ae0
movq -0x20(%rbp), %rax
movl 0x110(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x110(%rax)
movq -0x20(%rbp), %rax
movq 0x118(%rax), %rdi
movq -0x20(%rbp), %rax
movslq 0x110(%rax), %rsi
shlq $0x4, %rsi
callq 0x98a0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x118(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x118(%rax)
jne 0x77993
jmp 0x77ae0
movq -0x20(%rbp), %rax
movl 0x110(%rax), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
movl 0x110(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x77a00
movq -0x18(%rbp), %rax
movsd 0x190(%rax), %xmm1
movq -0x20(%rbp), %rax
movq 0x118(%rax), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x779f3
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x77a00
jmp 0x779f5
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x779aa
movl -0x30(%rbp), %eax
movq -0x20(%rbp), %rcx
movl 0x110(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x77a77
movq -0x20(%rbp), %rax
movl 0x110(%rax), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jle 0x77a75
movq -0x20(%rbp), %rax
movq 0x118(%rax), %rcx
movl -0x2c(%rbp), %eax
subl $0x1, %eax
cltq
shlq $0x4, %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq 0x118(%rax), %rax
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x77a24
jmp 0x77a77
movq -0x20(%rbp), %rax
movq 0x118(%rax), %rax
movslq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl 0x180(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movsd 0x188(%rax), %xmm0
movsd 0xc733(%rip), %xmm1     # 0x841e8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
shll $0x18, %ecx
movq -0x28(%rbp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movsd 0x190(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x8(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)