// File: /workspace/github_c_makefile_star2_O0/halcy[P]quasi_crystals_bot/Engine/Neuquant.c
// Function: alterneigh
static void alterneigh(Neuquant *self,int rad,int i,int b,int g,int r)
{
	int j,k,lo,hi,a;
	int *p, *q;

	lo = i-rad;   if (lo<-1) lo=-1;
	hi = i+rad;   if (hi>NeuquantNetworkSize) hi=NeuquantNetworkSize;

	j = i+1;
	k = i-1;
	q = self->radpower;
	while ((j<hi) || (k>lo)) {
		a = (*(++q));
		if (j<hi) {
			p = self->network[j];
			*p -= (a*(*p - b)) / alpharadbias;
			p++;
			*p -= (a*(*p - g)) / alpharadbias;
			p++;
			*p -= (a*(*p - r)) / alpharadbias;
			j++;
		}
		if (k>lo) {
			p = self->network[k];
			*p -= (a*(*p - b)) / alpharadbias;
			p++;
			*p -= (a*(*p - g)) / alpharadbias;
			p++;
			*p -= (a*(*p - r)) / alpharadbias;
			k--;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movl %r9d, -0x1c(%rbp)
movl -0x10(%rbp), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x28(%rbp)
jge 0x48df
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movl -0x10(%rbp), %eax
addl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x100, -0x2c(%rbp)     # imm = 0x100
jle 0x48f8
movl $0x100, -0x2c(%rbp)     # imm = 0x100
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
addq $0x1c00, %rax           # imm = 0x1C00
movq %rax, -0x40(%rbp)
movl -0x20(%rbp), %ecx
movb $0x1, %al
cmpl -0x2c(%rbp), %ecx
movb %al, -0x41(%rbp)
jl 0x4931
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
setg %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x493d
jmp 0x4aa9
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x40(%rbp)
movl 0x4(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x49fb
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
subl -0x14(%rbp), %ecx
imull %ecx, %eax
movl $0x40000, %ecx          # imm = 0x40000
cltd
idivl %ecx
movl %eax, %edx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
subl -0x18(%rbp), %ecx
imull %ecx, %eax
movl $0x40000, %ecx          # imm = 0x40000
cltd
idivl %ecx
movl %eax, %edx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
subl -0x1c(%rbp), %ecx
imull %ecx, %eax
movl $0x40000, %ecx          # imm = 0x40000
cltd
idivl %ecx
movl %eax, %edx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jle 0x4aa4
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
subl -0x14(%rbp), %ecx
imull %ecx, %eax
movl $0x40000, %ecx          # imm = 0x40000
cltd
idivl %ecx
movl %eax, %edx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
subl -0x18(%rbp), %ecx
imull %ecx, %eax
movl $0x40000, %ecx          # imm = 0x40000
cltd
idivl %ecx
movl %eax, %edx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
subl -0x1c(%rbp), %ecx
imull %ecx, %eax
movl $0x40000, %ecx          # imm = 0x40000
cltd
idivl %ecx
movl %eax, %edx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4918
popq %rbp
retq
nopl (%rax,%rax)