// File: /workspace/github_c_makefile_star2_O3/yui0[P]img2vec/./imgp.h
// Function: imgp_filter
void imgp_filter(uint8_t *im, int w, int h, uint8_t *o, double *K, int Ks, double divisor, double offset)
{
	unsigned int ix, iy, x, y;
	int kx, ky;
	double r, g, b, p;

	for (ix=0; ix<w; ix++) {
		for (iy=0; iy<h; iy++) {
			r = g = b = 0.0;
			for (kx=-Ks; kx<=Ks; kx++) {
				for (ky=-Ks; ky<=Ks; ky++) {
					x = ix+kx;
					y = iy+ky;
					p = ((x<0) || (x>=w) || (y<0) || (y>=h)) ? 0 : im[(ix+kx + (iy+ky)*w)*3];
					r += (K[(kx+Ks) + (ky+Ks)*(2*Ks+1)]/divisor) * p + offset;
					p = ((x<0) || (x>=w) || (y<0) || (y>=h)) ? 0 : im[(ix+kx + (iy+ky)*w)*3 +1];
					g += (K[(kx+Ks) + (ky+Ks)*(2*Ks+1)]/divisor) * p + offset;
					p = ((x<0) || (x>=w) || (y<0) || (y>=h)) ? 0 : im[(ix+kx + (iy+ky)*w)*3 +2];
					b += (K[(kx+Ks) + (ky+Ks)*(2*Ks+1)]/divisor) * p + offset;
				}
			}
			r = (r>255.0) ? 255.0 : ((r<0.0) ? 0.0 : r);
			g = (g>255.0) ? 255.0 : ((g<0.0) ? 0.0 : g);
			b = (b>255.0) ? 255.0 : ((b<0.0) ? 0.0 : b);
			o[(ix + iy*w)*3] = r;
			o[(ix + iy*w)*3 +1] = g;
			o[(ix + iy*w)*3 +2] = b;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r9, -0x28(%rsp)
movq %r8, -0x30(%rsp)
movq %rcx, -0x10(%rsp)
testl %esi, %esi
je 0x76f7
movq -0x28(%rsp), %r10
movl %r10d, %ecx
negl %ecx
leal (%r10,%r10), %eax
movl %ecx, -0x40(%rsp)
movslq %ecx, %r11
movslq %r10d, %rcx
leal 0x1(%rcx), %r8d
movl %r8d, -0x34(%rsp)
movl %edx, %r8d
movq %r8, -0x18(%rsp)
movapd %xmm1, %xmm2
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
leaq (%rcx,%r11), %r8
cltq
leaq 0x1(%rax), %r9
imulq %r9, %r8
leal 0x1(,%rcx,2), %r9d
movl %r9d, -0x38(%rsp)
shlq $0x3, %rcx
leaq (%rcx,%r8,8), %rcx
movq %r11, -0x20(%rsp)
leaq (%rcx,%r11,8), %rcx
addq %rcx, -0x30(%rsp)
leaq 0x8(,%rax,8), %r14
movl %esi, %eax
notl %eax
imull %r10d, %eax
leal (%rax,%rax,2), %eax
addl $0x2, %eax
movl %eax, -0x50(%rsp)
leal (%rsi,%rsi,2), %r12d
movq $0x0, -0x48(%rsp)
xorpd %xmm3, %xmm3
movsd 0x19663(%rip), %xmm4    # 0x20b90
testl %edx, %edx
je 0x76de
movl -0x50(%rsp), %r15d
movl -0x40(%rsp), %eax
movl %eax, -0x4c(%rsp)
xorl %ebx, %ebx
cmpl $0x0, -0x28(%rsp)
js 0x7655
movq %rbx, -0x8(%rsp)
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
movl %r15d, -0x3c(%rsp)
movq -0x30(%rsp), %rcx
movq -0x20(%rsp), %r9
movq -0x48(%rsp), %rax
leal (%rax,%r9), %r8d
movl -0x38(%rsp), %ebp
movl %r15d, %r10d
movl -0x4c(%rsp), %eax
movq %rcx, %rbx
cmpl %esi, %r8d
setb %r11b
cmpl %edx, %eax
setb %r13b
andb %r11b, %r13b
xorpd %xmm7, %xmm7
cmpb $0x1, %r13b
jne 0x75ad
leal -0x2(%r10), %r11d
movzbl (%rdi,%r11), %r11d
xorps %xmm7, %xmm7
cvtsi2sd %r11d, %xmm7
movsd (%rbx), %xmm8
divsd %xmm0, %xmm8
testb %r13b, %r13b
je 0x75f3
leal -0x1(%r10), %r11d
movzbl (%rdi,%r11), %r11d
movl %r10d, %r13d
movzbl (%rdi,%r13), %r13d
movd %r13d, %xmm9
pinsrw $0x2, %r11d, %xmm9
cvtdq2pd %xmm9, %xmm10
movapd %xmm8, %xmm9
unpcklpd %xmm8, %xmm9            # xmm9 = xmm9[0],xmm8[0]
mulpd %xmm10, %xmm9
addpd %xmm2, %xmm9
jmp 0x7607
movapd %xmm8, %xmm9
mulsd %xmm3, %xmm9
addsd %xmm1, %xmm9
unpcklpd %xmm9, %xmm9            # xmm9 = xmm9[0,0]
addpd %xmm9, %xmm5
mulsd %xmm7, %xmm8
addsd %xmm1, %xmm8
addsd %xmm8, %xmm6
addq %r14, %rbx
incl %eax
addl %r12d, %r10d
decl %ebp
jne 0x7582
incq %r9
addq $0x8, %rcx
addl $0x3, %r15d
cmpl %r9d, -0x34(%rsp)
jne 0x756b
movb $-0x1, %al
ucomisd %xmm4, %xmm6
movl -0x3c(%rsp), %r15d
movq -0x8(%rsp), %rbx
jbe 0x765d
jmp 0x7669
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
xorpd %xmm7, %xmm7
maxsd %xmm6, %xmm7
cvttsd2si %xmm7, %eax
movapd %xmm5, %xmm6
unpckhpd %xmm5, %xmm6            # xmm6 = xmm6[1],xmm5[1]
movb $-0x1, %cl
ucomisd %xmm4, %xmm6
movb $-0x1, %r8b
ja 0x7689
xorpd %xmm7, %xmm7
maxsd %xmm6, %xmm7
cvttsd2si %xmm7, %r8d
ucomisd %xmm4, %xmm5
ja 0x769b
xorpd %xmm6, %xmm6
maxsd %xmm5, %xmm6
cvttsd2si %xmm6, %ecx
movl %ebx, %r9d
imull %esi, %r9d
addl -0x48(%rsp), %r9d
leal (%r9,%r9,2), %r10d
movq -0x10(%rsp), %r11
movb %al, (%r11,%r10)
leal (%r9,%r9,2), %eax
incl %eax
movb %r8b, (%r11,%rax)
leal (%r9,%r9,2), %eax
addl $0x2, %eax
movb %cl, (%r11,%rax)
incq %rbx
incl -0x4c(%rsp)
addl %r12d, %r15d
cmpq -0x18(%rsp), %rbx
jne 0x7544
movq -0x48(%rsp), %rax
incl %eax
addl $0x3, -0x50(%rsp)
movq %rax, -0x48(%rsp)
cmpl %esi, %eax
jne 0x752d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq