// File: /workspace/github_cpp_makefile_star2_O3/Alcaro[P]bridges/arlib/image.cpp
// Function: image_insert_noov(image&, int, int, image const&)
static inline void image_insert_noov(image& target, int32_t x, int32_t y, const image& source)
{
	//dst\src  x  0  a   ba
	//  x      =  =  C0  ?=
	//  0      0  =  C0  ?=0
	//  a      1  1  Ca  ?=
	//  ba     1  1  C0  ?=
	// = - bitwise copy
	// 0 - bitwise copy, but set alpha to 0
	// 1 - bitwise copy, but set alpha to 1
	// ?= - bitwise copy if opaque, otherwise leave unchanged
	// ?=0 - if opaque, bitwise copy but set alpha to 0; otherwise leave unchanged
	// C0 - composite, but set output alpha to zero
	// Ca - composite
	// dst=ba src=a with non-ba-compliant src will yield shitty results,
	//  but there is no possible answer so the only real solution is banning it in the API.
	
	if (source.fmt == ifmt_bargb8888 && target.fmt == ifmt_0rgb8888)
		return image_insert_noov_8888_to_8888<true, 0x00000000>(target, x, y, source);
	if (source.fmt == ifmt_bargb8888)
		return image_insert_noov_8888_to_8888<true, (uint32_t)-1>(target, x, y, source);
	if (source.fmt == ifmt_argb8888 && target.fmt == ifmt_0rgb8888)
		return image_insert_noov_8888_to_8888_blend<0x00000000>(target, x, y, source);
	if (source.fmt == ifmt_argb8888)
		return image_insert_noov_8888_to_8888_blend<(uint32_t)-1>(target, x, y, source);
	if (target.fmt == ifmt_argb8888 || target.fmt == ifmt_bargb8888)
		return image_insert_noov_8888_to_8888<false, 0xFF000000>(target, x, y, source);
	if (target.fmt == ifmt_0rgb8888 && source.fmt == ifmt_xrgb8888)
		return image_insert_noov_8888_to_8888<false, 0x00000000>(target, x, y, source);
	else
		return image_insert_noov_8888_to_8888<false, (uint32_t)-1>(target, x, y, source);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x8(%rcx), %r8d
movl %r8d, %r9d
xorl $0x8, %r9d
movl 0x8(%rdi), %eax
movl %eax, %r10d
xorl $0x7, %r10d
orl %r9d, %r10d
jne 0xc06d
cmpl $0x0, 0x4(%rcx)
je 0xc521
movslq %esi, %rax
movl (%rcx), %r10d
shlq $0x2, %rax
xorl %esi, %esi
movdqa 0x23a0e(%rip), %xmm0    # 0x2f9a0
movq 0x10(%rdi), %rbx
movl 0xc(%rdi), %r8d
movq 0x10(%rcx), %r9
movl 0xc(%rcx), %r11d
movl %r10d, %r14d
cmpl $0x4, %r10d
jb 0xc00e
movl %r10d, %r14d
shrl $0x2, %r14d
shlq $0x4, %r14
movl %r8d, %r15d
imull %edx, %r15d
andl $-0x4, %r15d
addq %rbx, %r15
addq %rax, %r15
movl %r11d, %r12d
imull %esi, %r12d
andl $-0x4, %r12d
addq %r9, %r12
xorl %r13d, %r13d
movdqu (%r12,%r13), %xmm1
movdqu (%r15,%r13), %xmm2
pxor %xmm3, %xmm3
pcmpgtd %xmm1, %xmm3
pand %xmm0, %xmm1
pand %xmm3, %xmm1
pandn %xmm2, %xmm3
por %xmm1, %xmm3
movdqu %xmm3, (%r15,%r13)
addq $0x10, %r13
cmpq %r13, %r14
jne 0xbfd8
movl (%rcx), %r14d
andl $-0x4, %r10d
cmpl %r14d, %r10d
jae 0xc058
movl %r10d, %r10d
addq %rax, %rbx
imull %edx, %r8d
andl $-0x4, %r8d
addq %rbx, %r8
imull %esi, %r11d
andl $-0x4, %r11d
addq %r11, %r9
movl (%r9,%r10,4), %r11d
testl %r11d, %r11d
js 0xc042
movl (%r8,%r10,4), %r11d
jmp 0xc049
andl $0xffffff, %r11d        # imm = 0xFFFFFF
movl %r11d, (%r8,%r10,4)
incq %r10
movl (%rcx), %r14d
cmpq %r14, %r10
jb 0xc033
incl %esi
incl %edx
movl %r14d, %r10d
cmpl 0x4(%rcx), %esi
jb 0xbf92
jmp 0xc521
cmpl $0x5, %r8d
je 0xc165
cmpl $0x8, %r8d
jne 0xc26e
cmpl $0x0, 0x4(%rcx)
je 0xc521
movslq %esi, %rax
movl (%rcx), %r10d
shlq $0x2, %rax
xorl %esi, %esi
movq 0x10(%rdi), %rbx
movl 0xc(%rdi), %r8d
movq 0x10(%rcx), %r9
movl 0xc(%rcx), %r11d
movl %r10d, %r14d
cmpl $0x4, %r10d
jb 0xc10f
movl %r10d, %r14d
shrl $0x2, %r14d
shlq $0x4, %r14
movl %r8d, %r15d
imull %edx, %r15d
andl $-0x4, %r15d
addq %rbx, %r15
addq %rax, %r15
movl %r11d, %r12d
imull %esi, %r12d
andl $-0x4, %r12d
addq %r9, %r12
xorl %r13d, %r13d
movdqu (%r12,%r13), %xmm0
movdqu (%r15,%r13), %xmm1
pxor %xmm2, %xmm2
pcmpgtd %xmm0, %xmm2
pand %xmm2, %xmm0
pandn %xmm1, %xmm2
por %xmm0, %xmm2
movdqu %xmm2, (%r15,%r13)
addq $0x10, %r13
cmpq %r13, %r14
jne 0xc0dd
movl (%rcx), %r14d
andl $-0x4, %r10d
cmpl %r14d, %r10d
jae 0xc150
movl %r10d, %r10d
addq %rax, %rbx
imull %edx, %r8d
andl $-0x4, %r8d
addq %rbx, %r8
imull %esi, %r11d
andl $-0x4, %r11d
addq %r11, %r9
movl (%r9,%r10,4), %r11d
testl %r11d, %r11d
js 0xc141
movl (%r8,%r10,4), %r11d
movl %r11d, (%r8,%r10,4)
incq %r10
movl (%rcx), %r14d
cmpq %r14, %r10
jb 0xc134
incl %esi
incl %edx
movl %r14d, %r10d
cmpl 0x4(%rcx), %esi
jb 0xc097
jmp 0xc521
movl 0x4(%rcx), %r8d
cmpl $0x7, %eax
jne 0xc358
testl %r8d, %r8d
je 0xc521
movslq %esi, %rax
movl (%rcx), %r11d
shlq $0x2, %rax
xorl %esi, %esi
pxor %xmm0, %xmm0
movq 0x237cd(%rip), %xmm1    # 0x2f960
movdqa 0x237d5(%rip), %xmm2    # 0x2f970
movdqa 0x237dd(%rip), %xmm3    # 0x2f980
testl %r11d, %r11d
movl $0x0, %r11d
je 0xc25c
movq 0x10(%rdi), %r9
addq %rax, %r9
movl 0xc(%rdi), %r8d
imull %edx, %r8d
andl $-0x4, %r8d
addq %r9, %r8
movl 0xc(%rcx), %r9d
imull %esi, %r9d
andl $-0x4, %r9d
addq 0x10(%rcx), %r9
xorl %r10d, %r10d
movl (%r9,%r10,4), %r11d
cmpl $0xfeffffff, %r11d      # imm = 0xFEFFFFFF
ja 0xc242
cmpl $0x1000000, %r11d       # imm = 0x1000000
jb 0xc24d
movd (%r8,%r10,4), %xmm4
movd %r11d, %xmm5
punpckldq %xmm5, %xmm4    # xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
punpcklbw %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1],xmm4[2],xmm0[2],xmm4[3],xmm0[3],xmm4[4],xmm0[4],xmm4[5],xmm0[5],xmm4[6],xmm0[6],xmm4[7],xmm0[7]
shrl $0x18, %r11d
movd %r11d, %xmm5
pshuflw $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0]
pxor %xmm1, %xmm5
pmullw %xmm4, %xmm5
movdqa %xmm5, %xmm4
psrldq $0x8, %xmm4             # xmm4 = xmm4[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
paddw %xmm5, %xmm4
paddw %xmm2, %xmm4
pmulhuw %xmm3, %xmm4
psrlw $0x7, %xmm4
packuswb %xmm4, %xmm4
movd %xmm4, %r11d
andl $0xffffff, %r11d        # imm = 0xFFFFFF
movl %r11d, (%r8,%r10,4)
incq %r10
movl (%rcx), %r11d
cmpq %r11, %r10
jb 0xc1db
movl 0x4(%rcx), %r8d
incl %esi
incl %edx
cmpl %r8d, %esi
jb 0xc1a3
jmp 0xc521
cmpl $0x8, %eax
je 0xc285
cmpl $0x7, %eax
je 0xc450
cmpl $0x5, %eax
jne 0xc465
cmpl $0x0, 0x4(%rcx)
je 0xc521
movslq %esi, %rax
movl (%rcx), %r11d
shlq $0x2, %rax
xorl %esi, %esi
movl $0xff000000, %r8d       # imm = 0xFF000000
movdqa 0x236e7(%rip), %xmm0    # 0x2f990
movq 0x10(%rdi), %r14
movl 0xc(%rdi), %r9d
movq 0x10(%rcx), %r10
movl 0xc(%rcx), %ebx
movl %r11d, %r15d
cmpl $0x4, %r11d
jb 0xc30a
movl %r11d, %r15d
shrl $0x2, %r15d
shlq $0x4, %r15
movl %r9d, %r12d
imull %edx, %r12d
andl $-0x4, %r12d
addq %r14, %r12
addq %rax, %r12
movl %ebx, %r13d
imull %esi, %r13d
andl $-0x4, %r13d
addq %r10, %r13
xorl %ebp, %ebp
movdqu (%r13,%rbp), %xmm1
por %xmm0, %xmm1
movdqu %xmm1, (%r12,%rbp)
addq $0x10, %rbp
cmpq %rbp, %r15
jne 0xc2ed
movl (%rcx), %r15d
andl $-0x4, %r11d
cmpl %r15d, %r11d
jae 0xc343
movl %r11d, %r11d
addq %rax, %r14
imull %edx, %r9d
andl $-0x4, %r9d
addq %r14, %r9
imull %esi, %ebx
andl $-0x4, %ebx
addq %rbx, %r10
movl (%r10,%r11,4), %ebx
orl %r8d, %ebx
movl %ebx, (%r9,%r11,4)
incq %r11
movl (%rcx), %r15d
cmpq %r15, %r11
jb 0xc32d
incl %esi
incl %edx
movl %r15d, %r11d
cmpl 0x4(%rcx), %esi
jb 0xc2a9
jmp 0xc521
testl %r8d, %r8d
je 0xc521
movslq %esi, %rax
movl (%rcx), %r11d
shlq $0x2, %rax
xorl %esi, %esi
pxor %xmm0, %xmm0
movq 0x235e7(%rip), %xmm1    # 0x2f960
movdqa 0x235ef(%rip), %xmm2    # 0x2f970
movdqa 0x235f7(%rip), %xmm3    # 0x2f980
testl %r11d, %r11d
movl $0x0, %r11d
je 0xc43e
movq 0x10(%rdi), %r9
addq %rax, %r9
movl 0xc(%rdi), %r8d
imull %edx, %r8d
andl $-0x4, %r8d
addq %r9, %r8
movl 0xc(%rcx), %r9d
imull %esi, %r9d
andl $-0x4, %r9d
addq 0x10(%rcx), %r9
xorl %r10d, %r10d
movl (%r9,%r10,4), %r11d
cmpl $0xfeffffff, %r11d      # imm = 0xFEFFFFFF
jbe 0xc3d4
movl %r11d, (%r8,%r10,4)
jmp 0xc42f
cmpl $0x1000000, %r11d       # imm = 0x1000000
jb 0xc42f
movd (%r8,%r10,4), %xmm4
movd %r11d, %xmm5
punpckldq %xmm5, %xmm4    # xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
punpcklbw %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1],xmm4[2],xmm0[2],xmm4[3],xmm0[3],xmm4[4],xmm0[4],xmm4[5],xmm0[5],xmm4[6],xmm0[6],xmm4[7],xmm0[7]
shrl $0x18, %r11d
movd %r11d, %xmm5
pshuflw $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm5, %xmm5      # xmm5 = xmm5[0,0,0,0]
pxor %xmm1, %xmm5
pmullw %xmm4, %xmm5
movdqa %xmm5, %xmm4
psrldq $0x8, %xmm4             # xmm4 = xmm4[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
paddw %xmm5, %xmm4
paddw %xmm2, %xmm4
pmulhuw %xmm3, %xmm4
psrlw $0x7, %xmm4
packuswb %xmm4, %xmm4
movd %xmm4, (%r8,%r10,4)
incq %r10
movl (%rcx), %r11d
cmpq %r11, %r10
jb 0xc3c1
movl 0x4(%rcx), %r8d
incl %esi
incl %edx
cmpl %r8d, %esi
jb 0xc389
jmp 0xc521
cmpl $0x6, %r8d
jne 0xc465
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd171
cmpl $0x0, 0x4(%rcx)
je 0xc521
movslq %esi, %rax
movl (%rcx), %r10d
shlq $0x2, %rax
xorl %esi, %esi
movq 0x10(%rdi), %rbx
movl 0xc(%rdi), %r8d
movq 0x10(%rcx), %r9
movl 0xc(%rcx), %r11d
movl %r10d, %r14d
cmpl $0x4, %r10d
jb 0xc4d9
movl %r10d, %r14d
shrl $0x2, %r14d
shlq $0x4, %r14
movl %r8d, %r15d
imull %edx, %r15d
andl $-0x4, %r15d
addq %rbx, %r15
addq %rax, %r15
movl %r11d, %r12d
imull %esi, %r12d
andl $-0x4, %r12d
addq %r9, %r12
xorl %r13d, %r13d
movdqu (%r12,%r13), %xmm0
movdqu %xmm0, (%r15,%r13)
addq $0x10, %r13
cmpq %r13, %r14
jne 0xc4c1
movl (%rcx), %r14d
andl $-0x4, %r10d
cmpl %r14d, %r10d
jae 0xc511
movl %r10d, %r10d
addq %rax, %rbx
imull %edx, %r8d
andl $-0x4, %r8d
addq %rbx, %r8
imull %esi, %r11d
andl $-0x4, %r11d
addq %r11, %r9
movl (%r9,%r10,4), %r11d
movl %r11d, (%r8,%r10,4)
incq %r10
movl (%rcx), %r14d
cmpq %r14, %r10
jb 0xc4fe
incl %esi
incl %edx
movl %r14d, %r10d
cmpl 0x4(%rcx), %esi
jb 0xc47b
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq