// File: /workspace/github_c_makefile_star2_O2/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 %rcx, -0x28(%rsp)
movl %r9d, %eax
negl %eax
movl %eax, -0x40(%rsp)
movslq %eax, %r10
movslq %r9d, %r11
addl %r9d, %r9d
movl %edx, %eax
movq %rax, -0x20(%rsp)
movapd %xmm1, %xmm2
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
movl %esi, %eax
notl %eax
imull %r11d, %eax
leal (%rax,%rax,2), %eax
addl $0x2, %eax
movl %eax, -0x48(%rsp)
leal (%rsi,%rsi,2), %r14d
leaq (%r11,%r10), %rax
movslq %r9d, %rcx
leaq 0x1(%rcx), %r9
imulq %r9, %rax
leaq (,%r11,8), %r9
leaq (%r9,%rax,8), %rax
movq %r10, -0x38(%rsp)
leaq (%rax,%r10,8), %rax
addq %r8, %rax
movq %rax, -0x30(%rsp)
leaq 0x8(,%rcx,8), %r8
xorl %r13d, %r13d
movsd 0x14b82(%rip), %xmm3    # 0x1ba80
xorpd %xmm4, %xmm4
cmpl %esi, %r13d
je 0x70bb
movl -0x48(%rsp), %r12d
movl -0x40(%rsp), %eax
movl %eax, -0x44(%rsp)
xorl %ebp, %ebp
movq %r13, -0x10(%rsp)
cmpq -0x20(%rsp), %rbp
je 0x70ae
movq %rbp, -0x18(%rsp)
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
movq -0x30(%rsp), %r9
movl %r12d, -0x3c(%rsp)
movq -0x38(%rsp), %r10
cmpq %r11, %r10
jg 0x7027
leal (%r10,%r13), %ebx
movq %r9, -0x8(%rsp)
movl %r12d, %eax
movl -0x44(%rsp), %r13d
movq -0x38(%rsp), %r15
cmpq %r11, %r15
jg 0x700d
cmpl %esi, %ebx
setb %cl
cmpl %edx, %r13d
setb %bpl
andb %cl, %bpl
xorpd %xmm7, %xmm7
cmpb $0x1, %bpl
jne 0x6f92
leal -0x2(%rax), %ecx
movzbl (%rdi,%rcx), %ecx
cvtsi2sd %ecx, %xmm7
movsd (%r9), %xmm8
divsd %xmm0, %xmm8
testb %bpl, %bpl
je 0x6fd4
leal -0x1(%rax), %ecx
movzbl (%rdi,%rcx), %ecx
movl %eax, %ebp
movzbl (%rdi,%rbp), %ebp
movd %ecx, %xmm9
pinsrw $0x2, %ebp, %xmm9
cvtdq2pd %xmm9, %xmm10
movapd %xmm8, %xmm9
unpcklpd %xmm8, %xmm9            # xmm9 = xmm9[0],xmm8[0]
mulpd %xmm10, %xmm9
addpd %xmm2, %xmm9
jmp 0x6fe8
movapd %xmm8, %xmm9
mulsd %xmm4, %xmm9
addsd %xmm1, %xmm9
unpcklpd %xmm9, %xmm9            # xmm9 = xmm9[0,0]
mulsd %xmm7, %xmm8
addsd %xmm1, %xmm8
addsd %xmm8, %xmm6
addpd %xmm9, %xmm5
incq %r15
incl %r13d
addl %r14d, %eax
addq %r8, %r9
jmp 0x6f65
incq %r10
addl $0x3, %r12d
movq -0x8(%rsp), %r9
addq $0x8, %r9
movq -0x10(%rsp), %r13
jmp 0x6f46
movb $-0x1, %al
ucomisd %xmm3, %xmm6
movb $-0x1, %cl
ja 0x703d
xorpd %xmm7, %xmm7
maxsd %xmm6, %xmm7
cvttsd2si %xmm7, %ecx
ucomisd %xmm3, %xmm5
movl -0x3c(%rsp), %r12d
ja 0x7054
xorpd %xmm6, %xmm6
maxsd %xmm5, %xmm6
cvttsd2si %xmm6, %eax
unpckhpd %xmm5, %xmm5            # xmm5 = xmm5[1,1]
movb $-0x1, %r9b
ucomisd %xmm3, %xmm5
ja 0x706e
xorpd %xmm6, %xmm6
maxsd %xmm5, %xmm6
cvttsd2si %xmm6, %r9d
movq -0x18(%rsp), %rbp
movl %ebp, %r10d
imull %esi, %r10d
addl %r13d, %r10d
leal (%r10,%r10,2), %ebx
movq -0x28(%rsp), %r15
movb %cl, (%r15,%rbx)
leal (%r10,%r10,2), %ecx
incl %ecx
movb %al, (%r15,%rcx)
leal (%r10,%r10,2), %eax
addl $0x2, %eax
movb %r9b, (%r15,%rax)
incq %rbp
incl -0x44(%rsp)
addl %r14d, %r12d
jmp 0x6f1f
incl %r13d
addl $0x3, -0x48(%rsp)
jmp 0x6f02
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq