// File: Alcaro[P]bridges/arlib/image.cpp
// Function: image::insert(int, int, image const&)
void image::insert(int32_t x, int32_t y, const image& other)
{
	if (UNLIKELY(x < 0 || y < 0 || x+other.width > width || y+other.height > height))
	{
		struct image part;
		part.init_ref(other);
		if (x < 0)
		{
			part.pixels8 = part.pixels8 + (-x)*byteperpix(part.fmt);
			if ((uint32_t)-x >= part.width) return;
			part.width -= -x;
			x = 0;
		}
		if (y < 0)
		{
			part.pixels8 = part.pixels8 + (-y)*part.stride;
			if ((uint32_t)-y >= part.height) return;
			part.height -= -y;
			y = 0;
		}
		if (x+part.width > width)
		{
			if ((uint32_t)x >= width) return;
			part.width = width-x;
		}
		if (y+part.height > height)
		{
			if ((uint32_t)y >= height) return;
			part.height = height-y;
		}
		image_insert_noov(*this, x, y, part);
	}
	else
	{
		image_insert_noov(*this, x, y, other);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movb $0x1, %al
cmpl $0x0, -0xc(%rbp)
movb %al, -0x31(%rbp)
jl 0x18451
movb $0x1, %al
cmpl $0x0, -0x10(%rbp)
movb %al, -0x31(%rbp)
jl 0x18451
movq -0x40(%rbp), %rdx
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %rax
addl (%rax), %ecx
movb $0x1, %al
cmpl (%rdx), %ecx
movb %al, -0x31(%rbp)
ja 0x18451
movq -0x40(%rbp), %rcx
movl -0x10(%rbp), %eax
movq -0x18(%rbp), %rdx
addl 0x4(%rdx), %eax
cmpl 0x4(%rcx), %eax
seta %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
xorb $-0x1, %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x18461
jmp 0x1856d
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x1af30
cmpl $0x0, -0xc(%rbp)
jge 0x184c8
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
xorl %eax, %eax
subl -0xc(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x28(%rbp), %edi
callq 0x1ae50
movl -0x4c(%rbp), %ecx
movb %al, %dl
movq -0x48(%rbp), %rax
movzbl %dl, %edx
imull %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
subl -0xc(%rbp), %eax
cmpl -0x30(%rbp), %eax
jb 0x184b4
jmp 0x18580
xorl %ecx, %ecx
subl -0xc(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x0, -0x10(%rbp)
jge 0x18507
movq -0x20(%rbp), %rax
xorl %ecx, %ecx
subl -0x10(%rbp), %ecx
imull -0x24(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
subl -0x10(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jb 0x184f3
jmp 0x18580
xorl %ecx, %ecx
subl -0x10(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x40(%rbp), %rcx
movl -0xc(%rbp), %eax
addl -0x30(%rbp), %eax
cmpl (%rcx), %eax
jbe 0x1852e
movq -0x40(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl (%rcx), %eax
jb 0x18522
jmp 0x18580
movq -0x40(%rbp), %rax
movl (%rax), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x40(%rbp), %rcx
movl -0x10(%rbp), %eax
addl -0x2c(%rbp), %eax
cmpl 0x4(%rcx), %eax
jbe 0x18558
movq -0x40(%rbp), %rcx
movl -0x10(%rbp), %eax
cmpl 0x4(%rcx), %eax
jb 0x1854b
jmp 0x18580
movq -0x40(%rbp), %rax
movl 0x4(%rax), %eax
subl -0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
leaq -0x30(%rbp), %rcx
callq 0x18590
jmp 0x18580
movq -0x40(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x18(%rbp), %rcx
callq 0x18590
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)