// File: /workspace/github_cpp_makefile_star2_O3/Alcaro[P]bridges/arlib/image.cpp
// Function: image_insert_tile_row(image&, int, int, unsigned int, unsigned int, image const&, unsigned int, unsigned int)
static void image_insert_tile_row(image& target, int32_t x, int32_t y, uint32_t width, uint32_t height,
                                  const image& other, uint32_t offx, uint32_t offy)
{
	if (offx + width <= other.width)
	{
		target.insert_sub(x, y, other, offx, offy, width, height);
		return;
	}
	
	if (offx != 0)
	{
		target.insert_sub(x, y, other, offx, offy, other.width-offx, height);
		x += other.width-offx;
		width -= other.width-offx;
	}
	uint32_t xx = 0;
	if (width >= other.width)
	{
		for (xx = 0; xx < width-other.width; xx += other.width)
		{
			target.insert_sub(x+xx, y, other, 0, offy, other.width, height);
		}
	}
	if (xx < width)
	{
		target.insert_sub(x+xx, y, other, 0, offy, width-xx, height);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %r11d
movl %esi, %ebp
movl 0x78(%rsp), %r12d
movl 0x70(%rsp), %ebx
leal (%rbx,%r11), %eax
movl (%r9), %r10d
cmpl %r10d, %eax
jbe 0xc94b
testl %ebx, %ebx
movl %edx, 0xc(%rsp)
movq %rdi, 0x10(%rsp)
movl %r8d, 0x8(%rsp)
movq %r9, 0x18(%rsp)
je 0xc896
movl 0x8(%r9), %ecx
leaq 0x20(%rsp), %rax
movl %ecx, 0x8(%rax)
movl 0xc(%r9), %esi
addl %ecx, %ecx
movl $0x157fff8, %r14d       # imm = 0x157FFF8
shrl %cl, %r14d
movl %esi, 0xc(%rax)
andl $0x3, %r14d
incl %r14d
imull %ebx, %r14d
imull %r12d, %esi
addl %r14d, %esi
addq 0x10(%r9), %rsi
subl %ebx, %r10d
movq %rsi, 0x10(%rax)
movl %r10d, (%rax)
movl %r8d, 0x4(%rax)
movl %ebp, %esi
movq %rax, %rcx
movq %r11, %r14
callq 0xbe76
movq %r14, %r11
movq 0x18(%rsp), %r9
movl (%r9), %r10d
movl %r10d, %eax
subl %ebx, %eax
addl %eax, %ebp
subl %eax, %r11d
xorl %ebx, %ebx
cmpl %r10d, %r11d
movl 0xc(%rsp), %r15d
movq 0x10(%rsp), %r13
movl 0x8(%rsp), %r14d
jbe 0xc90e
xorl %ebx, %ebx
movl 0x8(%r9), %eax
movl %eax, 0x28(%rsp)
movl 0xc(%r9), %eax
movl %eax, 0x2c(%rsp)
imull %r12d, %eax
addq 0x10(%r9), %rax
leal (%rbx,%rbp), %esi
movq %rax, 0x30(%rsp)
movl %r10d, 0x20(%rsp)
movl %r14d, 0x24(%rsp)
movq %r13, %rdi
movl %r15d, %edx
leaq 0x20(%rsp), %rcx
movq %rbp, %r12
movq %r11, %rbp
callq 0xbe76
movq %rbp, %r11
movq %r12, %rbp
movl 0x78(%rsp), %r12d
movq 0x18(%rsp), %r9
movl (%r9), %r10d
addl %r10d, %ebx
movl %r11d, %eax
subl %r10d, %eax
cmpl %eax, %ebx
jb 0xc8ae
subl %ebx, %r11d
jbe 0xc990
movl 0x8(%r9), %eax
leaq 0x20(%rsp), %rcx
movl %eax, 0x8(%rcx)
movl 0xc(%r9), %eax
movl %eax, 0xc(%rcx)
imull %eax, %r12d
addq 0x10(%r9), %r12
addl %ebp, %ebx
movq %r12, 0x10(%rcx)
movl %r11d, (%rcx)
movl 0x8(%rsp), %eax
movl %eax, 0x4(%rcx)
movq 0x10(%rsp), %rdi
movl %ebx, %esi
movl 0xc(%rsp), %edx
jmp 0xc98b
movl 0x8(%r9), %ecx
leaq 0x20(%rsp), %rax
movl %ecx, 0x8(%rax)
movl 0xc(%r9), %r10d
addl %ecx, %ecx
movl $0x157fff8, %esi        # imm = 0x157FFF8
shrl %cl, %esi
movl %r10d, 0xc(%rax)
andl $0x3, %esi
incl %esi
imull %ebx, %esi
imull %r10d, %r12d
addl %esi, %r12d
addq 0x10(%r9), %r12
movq %r12, 0x10(%rax)
movl %r11d, (%rax)
movl %r8d, 0x4(%rax)
movl %ebp, %esi
movq %rax, %rcx
callq 0xbe76
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop