// File: /workspace/github_c_makefile_star2_O1/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 0x75fe
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)
leaq (%rcx,%r11), %r8
cltq
leaq 0x1(%rax), %r9
imulq %r8, %r9
leal 0x1(,%rcx,2), %r8d
movl %r8d, -0x38(%rsp)
shlq $0x3, %rcx
leaq (%rcx,%r9,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)
movsd 0x18626(%rip), %xmm2    # 0x1fa60
testl %edx, %edx
je 0x75e5
movl -0x50(%rsp), %r15d
movl -0x40(%rsp), %eax
movl %eax, -0x4c(%rsp)
xorl %ebx, %ebx
movq %rbx, -0x8(%rsp)
cmpl $0x0, -0x28(%rsp)
movl %r15d, -0x3c(%rsp)
js 0x754e
xorpd %xmm3, %xmm3
movq -0x30(%rsp), %rcx
movq -0x20(%rsp), %r9
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
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 %xmm6, %xmm6
xorpd %xmm7, %xmm7
cmpb $0x1, %r13b
jne 0x74c2
leal -0x2(%r10), %r11d
movzbl (%rdi,%r11), %r11d
xorps %xmm7, %xmm7
cvtsi2sd %r11d, %xmm7
testb %r13b, %r13b
je 0x74d8
leal -0x1(%r10), %r11d
movzbl (%rdi,%r11), %r11d
xorps %xmm6, %xmm6
cvtsi2sd %r11d, %xmm6
xorpd %xmm8, %xmm8
testb %r13b, %r13b
je 0x74f3
movl %r10d, %r11d
movzbl (%rdi,%r11), %r11d
xorps %xmm8, %xmm8
cvtsi2sd %r11d, %xmm8
movsd (%rbx), %xmm9
divsd %xmm0, %xmm9
mulsd %xmm9, %xmm7
addsd %xmm1, %xmm7
addsd %xmm7, %xmm5
mulsd %xmm9, %xmm6
addsd %xmm1, %xmm6
addsd %xmm6, %xmm4
mulsd %xmm8, %xmm9
addsd %xmm1, %xmm9
addsd %xmm9, %xmm3
addq %r14, %rbx
incl %eax
addl %r12d, %r10d
decl %ebp
jne 0x7493
incq %r9
addq $0x8, %rcx
addl $0x3, %r15d
cmpl %r9d, -0x34(%rsp)
jne 0x747c
jmp 0x755a
xorpd %xmm5, %xmm5
xorpd %xmm4, %xmm4
xorpd %xmm3, %xmm3
movb $-0x1, %al
ucomisd %xmm2, %xmm5
movb $-0x1, %cl
ja 0x7570
xorpd %xmm6, %xmm6
maxsd %xmm5, %xmm6
cvttsd2si %xmm6, %ecx
ucomisd %xmm2, %xmm4
movl -0x3c(%rsp), %r15d
movq -0x8(%rsp), %rbx
ja 0x758c
xorpd %xmm5, %xmm5
maxsd %xmm4, %xmm5
cvttsd2si %xmm5, %eax
movb $-0x1, %r8b
ucomisd %xmm2, %xmm3
ja 0x75a2
xorpd %xmm4, %xmm4
maxsd %xmm3, %xmm4
cvttsd2si %xmm4, %r8d
movl %ebx, %r9d
imull %esi, %r9d
addl -0x48(%rsp), %r9d
leal (%r9,%r9,2), %r10d
movq -0x10(%rsp), %r11
movb %cl, (%r11,%r10)
leal (%r9,%r9,2), %ecx
incl %ecx
movb %al, (%r11,%rcx)
leal (%r9,%r9,2), %eax
addl $0x2, %eax
movb %r8b, (%r11,%rax)
incq %rbx
incl -0x4c(%rsp)
addl %r12d, %r15d
cmpq -0x18(%rsp), %rbx
jne 0x7451
movq -0x48(%rsp), %rax
incl %eax
addl $0x3, -0x50(%rsp)
movq %rax, -0x48(%rsp)
cmpl %esi, %eax
jne 0x743a
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq