// File: /workspace/github_cpp_makefile_star2_O1/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), %eax
movl %eax, %r9d
xorl $0x8, %r9d
movl 0x8(%rdi), %r8d
movl %r8d, %r10d
xorl $0x7, %r10d
orl %r9d, %r10d
jne 0xbcf1
cmpl $0x0, 0x4(%rcx)
je 0xc176
movslq %esi, %rax
shlq $0x2, %rax
xorl %esi, %esi
movdqa 0x23d91(%rip), %xmm0    # 0x2f9b0
movq 0x10(%rdi), %r11
movl 0xc(%rdi), %r8d
movq 0x10(%rcx), %r9
movl (%rcx), %ebx
movl 0xc(%rcx), %r10d
cmpq $0x4, %rbx
jb 0xbc98
leaq (,%rbx,4), %r14
andq $-0x10, %r14
movl %r8d, %r15d
imull %edx, %r15d
andl $-0x4, %r15d
addq %r11, %r15
addq %rax, %r15
movl %r10d, %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 0xbc65
andl $-0x4, %ebx
cmpl (%rcx), %ebx
jae 0xbcdf
movl %ebx, %ebx
addq %rax, %r11
imull %edx, %r8d
andl $-0x4, %r8d
addq %r11, %r8
imull %esi, %r10d
andl $-0x4, %r10d
addq %r10, %r9
movl (%r9,%rbx,4), %r10d
testl %r10d, %r10d
js 0xbcc9
movl (%r8,%rbx,4), %r10d
jmp 0xbcd0
andl $0xffffff, %r10d        # imm = 0xFFFFFF
movl %r10d, (%r8,%rbx,4)
incq %rbx
movl (%rcx), %r10d
cmpq %r10, %rbx
jb 0xbcba
incl %esi
incl %edx
cmpl 0x4(%rcx), %esi
jb 0xbc1f
jmp 0xc176
cmpl $0x5, %eax
je 0xbddb
cmpl $0x8, %eax
jne 0xbfca
cmpl $0x0, 0x4(%rcx)
je 0xc176
movslq %esi, %rax
shlq $0x2, %rax
xorl %esi, %esi
movq 0x10(%rdi), %r11
movl 0xc(%rdi), %r8d
movq 0x10(%rcx), %r9
movl (%rcx), %ebx
movl 0xc(%rcx), %r10d
cmpq $0x4, %rbx
jb 0xbd8b
leaq (,%rbx,4), %r14
andq $-0x10, %r14
movl %r8d, %r15d
imull %edx, %r15d
andl $-0x4, %r15d
addq %r11, %r15
addq %rax, %r15
movl %r10d, %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 0xbd5c
andl $-0x4, %ebx
cmpl (%rcx), %ebx
jae 0xbdc9
movl %ebx, %ebx
addq %rax, %r11
imull %edx, %r8d
andl $-0x4, %r8d
addq %r11, %r8
imull %esi, %r10d
andl $-0x4, %r10d
addq %r10, %r9
movl (%r9,%rbx,4), %r10d
testl %r10d, %r10d
js 0xbdba
movl (%r8,%rbx,4), %r10d
movl %r10d, (%r8,%rbx,4)
incq %rbx
movl (%rcx), %r10d
cmpq %r10, %rbx
jb 0xbdad
incl %esi
incl %edx
cmpl 0x4(%rcx), %esi
jb 0xbd16
jmp 0xc176
cmpl $0x7, %r8d
jne 0xbed5
cmpl $0x0, 0x4(%rcx)
je 0xc176
movslq %esi, %rax
shlq $0x2, %rax
xorl %esi, %esi
pxor %xmm0, %xmm0
movq 0x23b6c(%rip), %xmm1    # 0x2f970
movdqa 0x23b74(%rip), %xmm2    # 0x2f980
movdqa 0x23b7c(%rip), %xmm3    # 0x2f990
cmpl $0x0, (%rcx)
je 0xbec3
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 0xbead
cmpl $0x1000000, %r11d       # imm = 0x1000000
jb 0xbeb8
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 0xbe46
incl %esi
incl %edx
cmpl 0x4(%rcx), %esi
jb 0xbe14
jmp 0xc176
cmpl $0x5, %eax
jne 0xbfca
cmpl $0x0, 0x4(%rcx)
je 0xc176
movslq %esi, %rax
shlq $0x2, %rax
xorl %esi, %esi
pxor %xmm0, %xmm0
movq 0x23a73(%rip), %xmm1    # 0x2f970
movdqa 0x23a7b(%rip), %xmm2    # 0x2f980
movdqa 0x23a83(%rip), %xmm3    # 0x2f990
cmpl $0x0, (%rcx)
je 0xbfb8
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 0xbf52
movl %r11d, (%r8,%r10,4)
jmp 0xbfad
cmpl $0x1000000, %r11d       # imm = 0x1000000
jb 0xbfad
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 0xbf3f
incl %esi
incl %edx
cmpl 0x4(%rcx), %esi
jb 0xbf0d
jmp 0xc176
cmpl $0x8, %r8d
je 0xbfe4
cmpl $0x7, %r8d
je 0xc0b2
cmpl $0x5, %r8d
jne 0xc0c6
cmpl $0x0, 0x4(%rcx)
je 0xc176
movslq %esi, %rax
shlq $0x2, %rax
xorl %esi, %esi
movl $0xff000000, %r8d       # imm = 0xFF000000
movdqa 0x2399b(%rip), %xmm0    # 0x2f9a0
movq 0x10(%rdi), %rbx
movl 0xc(%rdi), %r9d
movq 0x10(%rcx), %r10
movl (%rcx), %r14d
movl 0xc(%rcx), %r11d
cmpq $0x4, %r14
jb 0xc065
leaq (,%r14,4), %r15
andq $-0x10, %r15
movl %r9d, %r12d
imull %edx, %r12d
andl $-0x4, %r12d
addq %rbx, %r12
addq %rax, %r12
movl %r11d, %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 0xc04b
andl $-0x4, %r14d
cmpl (%rcx), %r14d
jae 0xc0a0
movl %r14d, %r14d
addq %rax, %rbx
imull %edx, %r9d
andl $-0x4, %r9d
addq %rbx, %r9
imull %esi, %r11d
andl $-0x4, %r11d
addq %r11, %r10
movl (%r10,%r14,4), %r11d
orl %r8d, %r11d
movl %r11d, (%r9,%r14,4)
incq %r14
movl (%rcx), %r11d
cmpq %r11, %r14
jb 0xc08a
incl %esi
incl %edx
cmpl 0x4(%rcx), %esi
jb 0xc005
jmp 0xc176
cmpl $0x6, %eax
jne 0xc0c6
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xccc9
cmpl $0x0, 0x4(%rcx)
je 0xc176
movslq %esi, %rax
shlq $0x2, %rax
xorl %esi, %esi
movq 0x10(%rdi), %r11
movl 0xc(%rdi), %r8d
movq 0x10(%rcx), %r9
movl (%rcx), %ebx
movl 0xc(%rcx), %r10d
cmpq $0x4, %rbx
jb 0xc134
leaq (,%rbx,4), %r14
andq $-0x10, %r14
movl %r8d, %r15d
imull %edx, %r15d
andl $-0x4, %r15d
addq %r11, %r15
addq %rax, %r15
movl %r10d, %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 0xc11f
andl $-0x4, %ebx
cmpl (%rcx), %ebx
jae 0xc169
movl %ebx, %ebx
addq %rax, %r11
imull %edx, %r8d
andl $-0x4, %r8d
addq %r11, %r8
imull %esi, %r10d
andl $-0x4, %r10d
addq %r10, %r9
movl (%r9,%rbx,4), %r10d
movl %r10d, (%r8,%rbx,4)
incq %rbx
movl (%rcx), %r10d
cmpq %r10, %rbx
jb 0xc156
incl %esi
incl %edx
cmpl 0x4(%rcx), %esi
jb 0xc0d9
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop