// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: initfastcolorlookup
static void initfastcolorlookup(int rscale, int gscale, int bscale)
{
	int i, j, x, y, z;
	unsigned char *pal1;

	j = 0;
	for(i=64;i>=0;i--)
	{
		//j = (i-64)*(i-64);
		rdist[i] = rdist[128-i] = j*rscale;
		gdist[i] = gdist[128-i] = j*gscale;
		bdist[i] = bdist[128-i] = j*bscale;
		j += 129-(i<<1);
	}

	//clearbufbyte(colhere,sizeof(colhere),0L);
	//clearbufbyte(colhead,sizeof(colhead),0L);
	Bmemset(colhere,0,sizeof(colhere));
	Bmemset(colhead,0,sizeof(colhead));

	pal1 = &palette[768-3];
	for(i=255;i>=0;i--,pal1-=3)
	{
		j = (pal1[0]>>3)*FASTPALGRIDSIZ*FASTPALGRIDSIZ+(pal1[1]>>3)*FASTPALGRIDSIZ+(pal1[2]>>3)+FASTPALGRIDSIZ*FASTPALGRIDSIZ+FASTPALGRIDSIZ+1;
		if (colhere[j>>3]&pow2char[j&7]) colnext[i] = colhead[j]; else colnext[i] = -1;
		colhead[j] = i;
		colhere[j>>3] |= pow2char[j&7];
	}

	i = 0;
	for(x=-FASTPALGRIDSIZ*FASTPALGRIDSIZ;x<=FASTPALGRIDSIZ*FASTPALGRIDSIZ;x+=FASTPALGRIDSIZ*FASTPALGRIDSIZ)
		for(y=-FASTPALGRIDSIZ;y<=FASTPALGRIDSIZ;y+=FASTPALGRIDSIZ)
			for(z=-1;z<=1;z++)
				colscan[i++] = x+y+z;
	i = colscan[13]; colscan[13] = colscan[26]; colscan[26] = i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x40, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jl 0x5ac17
movl -0x14(%rbp), %edx
imull -0x4(%rbp), %edx
movl $0x80, %eax
subl -0x10(%rbp), %eax
movslq %eax, %rcx
leaq 0x25da6e(%rip), %rax    # 0x2b8600
movl %edx, (%rax,%rcx,4)
movslq -0x10(%rbp), %rcx
leaq 0x25da60(%rip), %rax    # 0x2b8600
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %edx
imull -0x8(%rbp), %edx
movl $0x80, %eax
subl -0x10(%rbp), %eax
movslq %eax, %rcx
leaq 0x25dc54(%rip), %rax    # 0x2b8810
movl %edx, (%rax,%rcx,4)
movslq -0x10(%rbp), %rcx
leaq 0x25dc46(%rip), %rax    # 0x2b8810
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %edx
imull -0xc(%rbp), %edx
movl $0x80, %eax
subl -0x10(%rbp), %eax
movslq %eax, %rcx
leaq 0x25de3a(%rip), %rax    # 0x2b8a20
movl %edx, (%rax,%rcx,4)
movslq -0x10(%rbp), %rcx
leaq 0x25de2c(%rip), %rax    # 0x2b8a20
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %ecx
shll %ecx
movl $0x81, %eax
subl %ecx, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5ab6f
leaq 0x25e082(%rip), %rdi    # 0x2b8ca0
xorl %esi, %esi
movl $0x7d, %edx
callq 0x62d0
leaq 0x25e0ef(%rip), %rdi    # 0x2b8d20
xorl %esi, %esi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x62d0
leaq 0x25e4cc(%rip), %rax    # 0x2b9110
addq $0x2fd, %rax            # imm = 0x2FD
movq %rax, -0x28(%rbp)
movl $0xff, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jl 0x5ad5b
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
sarl $0x3, %eax
shll $0x3, %eax
shll $0x3, %eax
movq -0x28(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
sarl $0x3, %ecx
shll $0x3, %ecx
addl %ecx, %eax
movq -0x28(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
sarl $0x3, %ecx
addl %ecx, %eax
addl $0x40, %eax
addl $0x8, %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
sarl $0x3, %eax
movslq %eax, %rcx
leaq 0x25dff8(%rip), %rax    # 0x2b8ca0
movzbl (%rax,%rcx), %eax
movl -0x14(%rbp), %ecx
andl $0x7, %ecx
movslq %ecx, %rdx
leaq 0x85fd4(%rip), %rcx     # 0xe0c90
movzbl (%rcx,%rdx), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x5ace6
movslq -0x14(%rbp), %rcx
leaq 0x25e04e(%rip), %rax    # 0x2b8d20
movzbl (%rax,%rcx), %edx
movslq -0x10(%rbp), %rcx
leaq 0x25e72f(%rip), %rax    # 0x2b9410
movl %edx, (%rax,%rcx,4)
jmp 0x5acf8
movslq -0x10(%rbp), %rcx
leaq 0x25e71f(%rip), %rax    # 0x2b9410
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x10(%rbp), %eax
movb %al, %dl
movslq -0x14(%rbp), %rcx
leaq 0x25e018(%rip), %rax    # 0x2b8d20
movb %dl, (%rax,%rcx)
movl -0x14(%rbp), %eax
andl $0x7, %eax
movslq %eax, %rcx
leaq 0x85f75(%rip), %rax     # 0xe0c90
movzbl (%rax,%rcx), %edx
movl -0x14(%rbp), %eax
sarl $0x3, %eax
movslq %eax, %rcx
leaq 0x25df71(%rip), %rax    # 0x2b8ca0
movzbl (%rax,%rcx), %eax
orl %edx, %eax
movb %al, %dl
leaq 0x25df62(%rip), %rax    # 0x2b8ca0
movb %dl, (%rax,%rcx)
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
movq -0x28(%rbp), %rax
addq $-0x3, %rax
movq %rax, -0x28(%rbp)
jmp 0x5ac55
movl $0x0, -0x10(%rbp)
movl $0xffffffc0, -0x18(%rbp) # imm = 0xFFFFFFC0
cmpl $0x40, -0x18(%rbp)
jg 0x5adcf
movl $0xfffffff8, -0x1c(%rbp) # imm = 0xFFFFFFF8
cmpl $0x8, -0x1c(%rbp)
jg 0x5adc2
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
cmpl $0x1, -0x20(%rbp)
jg 0x5adb5
movl -0x18(%rbp), %edx
addl -0x1c(%rbp), %edx
addl -0x20(%rbp), %edx
movl -0x10(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x10(%rbp)
movslq %eax, %rcx
leaq 0x25de89(%rip), %rax    # 0x2b8c30
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x5ad83
jmp 0x5adb7
movl -0x1c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5ad76
jmp 0x5adc4
movl -0x18(%rbp), %eax
addl $0x40, %eax
movl %eax, -0x18(%rbp)
jmp 0x5ad69
movl 0x25de8f(%rip), %eax    # 0x2b8c64
movl %eax, -0x10(%rbp)
movl 0x25deba(%rip), %eax    # 0x2b8c98
movl %eax, 0x25de80(%rip)    # 0x2b8c64
movl -0x10(%rbp), %eax
movl %eax, 0x25deab(%rip)    # 0x2b8c98
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)