// File: /workspace/github_c_makefile_star2_O0/halcy[P]quasi_crystals_bot/Engine/Neuquant.c
// Function: NeuquantLearn
void NeuquantLearn(Neuquant *self,const void *data,NeuquantLookupFunction *func,int numpixels,int samplefac)
{
	int alphadec=30+((samplefac-1)/3);
	int samplepixels=numpixels/samplefac;
	int delta=samplepixels/ncycles;
	int alpha=initalpha;
	int radius=initradius;
	
	int rad=radius>>radiusbiasshift;
	if(rad<=1) rad=0;
	for(int i=0;i<rad;i++) self->radpower[i]=alpha*(((rad*rad-i*i)*radbias)/(rad*rad));

	int step;
	if(samplefac==1) step=1;
	else if(numpixels%prime1!=0) step=prime1;
	else if(numpixels%prime2!=0) step=prime2;
	else if(numpixels%prime3!=0) step=prime3;
	else step=prime4;

	int pixel=0;
	for(int i=0;i<samplepixels;i++)
	{
		int r,g,b;
		func(data,pixel,&r,&g,&b);
		b<<=netbiasshift;
		g<<=netbiasshift;
		r<<=netbiasshift;
		int j=contest(self,b,g,r);

		altersingle(self,alpha,j,b,g,r);
		if(rad) alterneigh(self,rad,j,b,g,r);

		pixel=(pixel+step)%numpixels;
	
		if((i+1)%delta==0)
		{	
			alpha-=alpha/alphadec;
			radius-=radius/radiusdec;
			rad=radius>>radiusbiasshift;
			if(rad<=1) rad=0;
	
			for(int j=0;j<rad;j++) self->radpower[j]=alpha*(((rad*rad-j*j)*radbias)/(rad*rad));
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq -0x70(%rsp), %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl $0x3, %ecx
cltd
idivl %ecx
addl $0x1e, %eax
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
cltd
idivl -0x20(%rbp)
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, -0x2c(%rbp)
movl $0x400, -0x30(%rbp)     # imm = 0x400
movl $0x800, -0x34(%rbp)     # imm = 0x800
movl -0x34(%rbp), %eax
sarl $0x6, %eax
movl %eax, -0x38(%rbp)
cmpl $0x1, -0x38(%rbp)
jg 0x444c
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x449e
movl -0x30(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x38(%rbp), %eax
imull -0x38(%rbp), %eax
movl -0x3c(%rbp), %ecx
imull -0x3c(%rbp), %ecx
subl %ecx, %eax
shll $0x8, %eax
movl -0x38(%rbp), %ecx
imull -0x38(%rbp), %ecx
cltd
idivl %ecx
movl -0x60(%rbp), %edx
imull %eax, %edx
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl %edx, 0x1c00(%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4453
cmpl $0x1, -0x20(%rbp)
jne 0x44ad
movl $0x1, -0x40(%rbp)
jmp 0x4505
movl -0x1c(%rbp), %eax
movl $0x1f3, %ecx            # imm = 0x1F3
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x44c6
movl $0x1f3, -0x40(%rbp)     # imm = 0x1F3
jmp 0x4503
movl -0x1c(%rbp), %eax
movl $0x1eb, %ecx            # imm = 0x1EB
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x44df
movl $0x1eb, -0x40(%rbp)     # imm = 0x1EB
jmp 0x4501
movl -0x1c(%rbp), %eax
movl $0x1e7, %ecx            # imm = 0x1E7
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x44f8
movl $0x1e7, -0x40(%rbp)     # imm = 0x1E7
jmp 0x44ff
movl $0x1f7, -0x40(%rbp)     # imm = 0x1F7
jmp 0x4501
jmp 0x4503
jmp 0x4505
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x4662
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
leaq -0x4c(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq *%rax
movl -0x54(%rbp), %eax
shll $0x4, %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
shll $0x4, %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
shll $0x4, %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x54(%rbp), %esi
movl -0x50(%rbp), %edx
movl -0x4c(%rbp), %ecx
callq 0x4670
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movl -0x30(%rbp), %esi
movl -0x58(%rbp), %edx
movl -0x54(%rbp), %ecx
movl -0x50(%rbp), %r8d
movl -0x4c(%rbp), %r9d
callq 0x4800
cmpl $0x0, -0x38(%rbp)
je 0x45a2
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x58(%rbp), %edx
movl -0x54(%rbp), %ecx
movl -0x50(%rbp), %r8d
movl -0x4c(%rbp), %r9d
callq 0x48b0
movl -0x44(%rbp), %eax
addl -0x40(%rbp), %eax
cltd
idivl -0x1c(%rbp)
movl %edx, -0x44(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0x2c(%rbp)
cmpl $0x0, %edx
jne 0x4652
movl -0x30(%rbp), %eax
cltd
idivl -0x24(%rbp)
movl %eax, %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %eax
movl $0x1e, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
sarl $0x6, %eax
movl %eax, -0x38(%rbp)
cmpl $0x1, -0x38(%rbp)
jg 0x45fe
movl $0x0, -0x38(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x4650
movl -0x30(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x38(%rbp), %eax
imull -0x38(%rbp), %eax
movl -0x5c(%rbp), %ecx
imull -0x5c(%rbp), %ecx
subl %ecx, %eax
shll $0x8, %eax
movl -0x38(%rbp), %ecx
imull -0x38(%rbp), %ecx
cltd
idivl %ecx
movl -0x64(%rbp), %edx
imull %eax, %edx
movq -0x8(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl %edx, 0x1c00(%rax,%rcx,4)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4605
jmp 0x4652
jmp 0x4654
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x4513
leaq 0x70(%rsp), %rsp
popq %rbp
retq
nopl (%rax)