// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x18, %rsp
movq %rcx, %rbx
movl %edx, %ebp
movl 0x8(%rcx), %ecx
movl %ecx, %edx
xorl $0x8, %edx
movl 0x8(%rdi), %eax
movl %eax, %r8d
xorl $0x7, %r8d
orl %edx, %r8d
jne 0xa3c6
movslq %esi, %rax
shlq $0x2, %rax
xorl %ecx, %ecx
movdqa 0x1e5db(%rip), %xmm0    # 0x288f0
cmpl 0x4(%rbx), %ecx
jae 0xa793
movq 0x10(%rbx), %rdx
movl (%rbx), %esi
shrl $0x2, %esi
movq 0x10(%rdi), %r12
addq %rax, %r12
movl 0xc(%rdi), %r8d
imull %ebp, %r8d
andl $-0x4, %r8d
leaq (%r8,%r12), %r10
movl 0xc(%rbx), %r9d
imull %ecx, %r9d
andl $-0x4, %r9d
leaq (%r9,%rdx), %r11
movq %rsi, %r14
shlq $0x4, %r14
xorl %r15d, %r15d
cmpq %r15, %r14
je 0xa38d
movdqu (%r11,%r15), %xmm1
movdqu (%r10,%r15), %xmm2
pxor %xmm3, %xmm3
pcmpgtd %xmm1, %xmm3
pand %xmm0, %xmm1
pand %xmm3, %xmm1
pandn %xmm2, %xmm3
por %xmm1, %xmm3
movdqu %xmm3, (%r10,%r15)
addq $0x10, %r15
jmp 0xa358
shll $0x2, %esi
addq %r8, %r12
addq %r9, %rdx
movl (%rbx), %r8d
cmpq %r8, %rsi
jae 0xa3bd
movl (%rdx,%rsi,4), %r8d
testl %r8d, %r8d
js 0xa3ad
movl (%r12,%rsi,4), %r8d
jmp 0xa3b4
andl $0xffffff, %r8d         # imm = 0xFFFFFF
movl %r8d, (%r12,%rsi,4)
incq %rsi
jmp 0xa396
incl %ecx
incl %ebp
jmp 0xa315
cmpl $0x5, %ecx
je 0xa485
cmpl $0x8, %ecx
jne 0xa52a
movslq %esi, %rax
shlq $0x2, %rax
xorl %ecx, %ecx
cmpl 0x4(%rbx), %ecx
jae 0xa793
movq 0x10(%rbx), %rdx
movl (%rbx), %esi
shrl $0x2, %esi
movq 0x10(%rdi), %r12
addq %rax, %r12
movl 0xc(%rdi), %r8d
imull %ebp, %r8d
andl $-0x4, %r8d
leaq (%r8,%r12), %r10
movl 0xc(%rbx), %r9d
imull %ecx, %r9d
andl $-0x4, %r9d
leaq (%r9,%rdx), %r11
movq %rsi, %r14
shlq $0x4, %r14
xorl %r15d, %r15d
cmpq %r15, %r14
je 0xa455
movdqu (%r11,%r15), %xmm0
movdqu (%r10,%r15), %xmm1
pxor %xmm2, %xmm2
pcmpgtd %xmm0, %xmm2
pand %xmm2, %xmm0
pandn %xmm1, %xmm2
por %xmm0, %xmm2
movdqu %xmm2, (%r10,%r15)
addq $0x10, %r15
jmp 0xa424
shll $0x2, %esi
addq %r8, %r12
addq %r9, %rdx
movl (%rbx), %r8d
cmpq %r8, %rsi
jae 0xa47c
movl (%rdx,%rsi,4), %r8d
testl %r8d, %r8d
js 0xa473
movl (%r12,%rsi,4), %r8d
movl %r8d, (%r12,%rsi,4)
incq %rsi
jmp 0xa45e
incl %ecx
incl %ebp
jmp 0xa3e1
movslq %esi, %rcx
cmpl $0x7, %eax
movq %rdi, 0x10(%rsp)
jne 0xa5e2
shlq $0x2, %rcx
xorl %r12d, %r12d
movq %rcx, 0x8(%rsp)
cmpl 0x4(%rbx), %r12d
jae 0xa793
movq 0x10(%rdi), %rax
addq %rcx, %rax
movl 0xc(%rdi), %r13d
imull %ebp, %r13d
andl $-0x4, %r13d
addq %rax, %r13
movl 0xc(%rbx), %r15d
imull %r12d, %r15d
andl $-0x4, %r15d
addq 0x10(%rbx), %r15
xorl %r14d, %r14d
movl (%rbx), %eax
cmpq %rax, %r14
jae 0xa516
movl (%r15,%r14,4), %esi
cmpl $0xfeffffff, %esi       # imm = 0xFEFFFFFF
jbe 0xa4f5
andl $0xffffff, %esi         # imm = 0xFFFFFF
movl %esi, (%r13,%r14,4)
jmp 0xa511
cmpl $0x1000000, %esi        # imm = 0x1000000
jb 0xa511
movl (%r13,%r14,4), %edi
callq 0xaf27
andl $0xffffff, %eax         # imm = 0xFFFFFF
movl %eax, (%r13,%r14,4)
incq %r14
jmp 0xa4d5
incl %r12d
incl %ebp
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rcx
jmp 0xa4a2
cmpl $0x8, %eax
je 0xa541
cmpl $0x7, %eax
je 0xa668
cmpl $0x5, %eax
jne 0xa712
movslq %esi, %rax
shlq $0x2, %rax
xorl %ecx, %ecx
movl $0xff000000, %edx       # imm = 0xFF000000
movdqa 0x1e3a9(%rip), %xmm0    # 0x28900
cmpl 0x4(%rbx), %ecx
jae 0xa793
movq 0x10(%rbx), %rsi
movl (%rbx), %r13d
shrl $0x2, %r13d
movq 0x10(%rdi), %r8
addq %rax, %r8
movl 0xc(%rdi), %r9d
imull %ebp, %r9d
andl $-0x4, %r9d
leaq (%r9,%r8), %r11
movl 0xc(%rbx), %r10d
imull %ecx, %r10d
andl $-0x4, %r10d
leaq (%r10,%rsi), %r14
movq %r13, %r15
shlq $0x4, %r15
xorl %r12d, %r12d
cmpq %r12, %r15
je 0xa5b7
movdqu (%r14,%r12), %xmm1
por %xmm0, %xmm1
movdqu %xmm1, (%r11,%r12)
addq $0x10, %r12
jmp 0xa59c
shll $0x2, %r13d
addq %r9, %r8
addq %r10, %rsi
movl (%rbx), %r9d
cmpq %r9, %r13
jae 0xa5d9
movl (%rsi,%r13,4), %r9d
orl %edx, %r9d
movl %r9d, (%r8,%r13,4)
incq %r13
jmp 0xa5c1
incl %ecx
incl %ebp
jmp 0xa557
shlq $0x2, %rcx
xorl %r12d, %r12d
movq %rcx, 0x8(%rsp)
cmpl 0x4(%rbx), %r12d
jae 0xa793
movq 0x10(%rdi), %rax
addq %rcx, %rax
movl 0xc(%rdi), %r13d
imull %ebp, %r13d
andl $-0x4, %r13d
addq %rax, %r13
movl 0xc(%rbx), %r15d
imull %r12d, %r15d
andl $-0x4, %r15d
addq 0x10(%rbx), %r15
xorl %r14d, %r14d
movl (%rbx), %eax
cmpq %rax, %r14
jae 0xa657
movl (%r15,%r14,4), %esi
cmpl $0xfeffffff, %esi       # imm = 0xFEFFFFFF
jbe 0xa63b
movl %esi, (%r13,%r14,4)
jmp 0xa652
cmpl $0x1000000, %esi        # imm = 0x1000000
jb 0xa652
movl (%r13,%r14,4), %edi
callq 0xaf27
movl %eax, (%r13,%r14,4)
incq %r14
jmp 0xa621
incl %r12d
incl %ebp
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rcx
jmp 0xa5ee
cmpl $0x6, %ecx
jne 0xa712
movslq %esi, %rax
shlq $0x2, %rax
xorl %ecx, %ecx
movl $0xffffff, %edx         # imm = 0xFFFFFF
movdqa 0x1e269(%rip), %xmm0    # 0x288f0
cmpl 0x4(%rbx), %ecx
jae 0xa793
movq 0x10(%rbx), %rsi
movl (%rbx), %r13d
shrl $0x2, %r13d
movq 0x10(%rdi), %r8
addq %rax, %r8
movl 0xc(%rdi), %r9d
imull %ebp, %r9d
andl $-0x4, %r9d
leaq (%r9,%r8), %r11
movl 0xc(%rbx), %r10d
imull %ecx, %r10d
andl $-0x4, %r10d
leaq (%r10,%rsi), %r14
movq %r13, %r15
shlq $0x4, %r15
xorl %r12d, %r12d
cmpq %r12, %r15
je 0xa6e7
movdqu (%r14,%r12), %xmm1
pand %xmm0, %xmm1
movdqu %xmm1, (%r11,%r12)
addq $0x10, %r12
jmp 0xa6cc
shll $0x2, %r13d
addq %r9, %r8
addq %r10, %rsi
movl (%rbx), %r9d
cmpq %r9, %r13
jae 0xa709
movl (%rsi,%r13,4), %r9d
andl %edx, %r9d
movl %r9d, (%r8,%r13,4)
incq %r13
jmp 0xa6f1
incl %ecx
incl %ebp
jmp 0xa687
movslq %esi, %rax
shlq $0x2, %rax
xorl %ecx, %ecx
cmpl 0x4(%rbx), %ecx
jae 0xa793
movq 0x10(%rbx), %rdx
movl (%rbx), %esi
shrl $0x2, %esi
movq 0x10(%rdi), %r12
addq %rax, %r12
movl 0xc(%rdi), %r8d
imull %ebp, %r8d
andl $-0x4, %r8d
leaq (%r8,%r12), %r10
movl 0xc(%rbx), %r9d
imull %ecx, %r9d
andl $-0x4, %r9d
leaq (%r9,%rdx), %r11
movq %rsi, %r14
shlq $0x4, %r14
xorl %r15d, %r15d
cmpq %r15, %r14
je 0xa76f
movups (%r11,%r15), %xmm0
movups %xmm0, (%r10,%r15)
addq $0x10, %r15
jmp 0xa75a
shll $0x2, %esi
addq %r8, %r12
addq %r9, %rdx
movl (%rbx), %r8d
cmpq %r8, %rsi
jae 0xa78d
movl (%rdx,%rsi,4), %r8d
movl %r8d, (%r12,%rsi,4)
incq %rsi
jmp 0xa778
incl %ecx
incl %ebp
jmp 0xa71b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq