// File: /workspace/github_cpp_makefile_star2_O3/Alcaro[P]bridges/arlib/image.cpp
// Function: image::insert_tile_with_border(int, int, unsigned int, unsigned int, image const&, unsigned int, unsigned int, unsigned int, unsigned int)
void image::insert_tile_with_border(int32_t x, int32_t y, uint32_t width, uint32_t height,
                                    const image& other, uint32_t x1, uint32_t x2, uint32_t y1, uint32_t y2)
{
	uint32_t x3 = other.width;
	uint32_t y3 = other.height;
	
	uint32_t w1 = x1-0;
	uint32_t w2 = x2-x1;
	uint32_t w3 = x3-x2;
	uint32_t h1 = y1-0;
	uint32_t h2 = y2-y1;
	uint32_t h3 = y3-y2;
	
	image sub;
	
	insert_sub(x,          y,           other, 0,  0,  x1, y1); // top left
	sub.init_ref_sub(other, x1, 0,  w2, h1); insert_tile(x+x1,       y,           width-w1-w3, h1,           sub); // top
	insert_sub(x+width-w3, y,           other, x2, 0,  w3, y1); // top right
	
	sub.init_ref_sub(other, 0,  y1, w1, h2); insert_tile(x,          y+y1,        w1,          height-h1-h3, sub); // left
	sub.init_ref_sub(other, x1, y1, w2, h2); insert_tile(x+x1,       y+y1,        width-w1-w3, height-h1-h3, sub); // middle
	sub.init_ref_sub(other, x2, y1, w3, h2); insert_tile(x+width-w3, y+y1,        w3,          height-h1-h3, sub); // right
	
	insert_sub(x,          y+height-h3, other, 0,  y2, x1, h3); // bottom left
	sub.init_ref_sub(other, x1, y2, w2, h3); insert_tile(x+x1,       y+height-h3, width-w1-w3, h3,           sub); // bottom
	insert_sub(x+width-w3, y+height-h3, other, x2, y2, w3, h3); // bottom right
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %r15
movl %r8d, 0x8(%rsp)
movl %ecx, 0x4(%rsp)
movl %edx, %r12d
movq %rsi, 0x30(%rsp)
movl 0xc0(%rsp), %r9d
movl 0xc8(%rsp), %ecx
movl 0xb0(%rsp), %ebx
movl 0xb8(%rsp), %eax
movl (%r15), %r11d
movl 0x4(%r15), %r10d
movl %eax, %r13d
subl %ebx, %r13d
movl %r13d, 0x14(%rsp)
subl %eax, %r11d
movq %r11, %rbp
movq %r11, 0x18(%rsp)
movq 0x8(%r15), %rax
leaq 0x48(%rsp), %r8
movq %rax, 0x8(%r8)
movq 0x10(%r15), %rax
movq %rax, 0x10(%r8)
movl %ecx, %eax
subl %r9d, %eax
movl %eax, 0x24(%rsp)
subl %ecx, %r10d
movq %r10, 0x38(%rsp)
movl %ebx, (%r8)
movl %r9d, 0x4(%r8)
movq %rdi, %r14
movq %rdi, 0x28(%rsp)
movq %r8, %rcx
callq 0xbe76
movq 0x8(%r15), %rcx
leaq 0x60(%rsp), %rbx
movq %rcx, 0x8(%rbx)
addl %ecx, %ecx
movl $0x157fff8, %eax        # imm = 0x157FFF8
shrl %cl, %eax
andl $0x3, %eax
incl %eax
movl 0xb0(%rsp), %ecx
imull %ecx, %eax
addq 0x10(%r15), %rax
movq %rax, 0x10(%rbx)
movl %r13d, (%rbx)
movl 0xc0(%rsp), %r8d
movl %r8d, 0x4(%rbx)
movq 0x30(%rsp), %r13
leal (%rcx,%r13), %esi
movl %esi, 0x10(%rsp)
leal (%rcx,%rbp), %eax
movl 0x4(%rsp), %ebp
movl %ebp, %ecx
subl %eax, %ecx
movl %ecx, 0xc(%rsp)
movq %r14, %rdi
movl %r12d, %edx
movq %rbx, %r9
callq 0xc52c
movl %ebp, %esi
addl %r13d, %esi
movq %r13, %rbp
movq 0x8(%r15), %rcx
leaq 0x48(%rsp), %rdx
movq %rcx, 0x8(%rdx)
addl %ecx, %ecx
movl $0x157fff8, %eax        # imm = 0x157FFF8
shrl %cl, %eax
andl $0x3, %eax
incl %eax
imull 0xb8(%rsp), %eax
addq 0x10(%r15), %rax
movq 0x18(%rsp), %r14
subl %r14d, %esi
movl %esi, 0x4(%rsp)
movq %rax, 0x10(%rdx)
movl %r14d, (%rdx)
movl 0xc0(%rsp), %r13d
movl %r13d, 0x4(%rdx)
leaq 0x48(%rsp), %rcx
movq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r12, 0x40(%rsp)
movl %r12d, %edx
callq 0xbe76
movl 0x8(%r15), %eax
movl %eax, 0x8(%rbx)
movl 0xc(%r15), %eax
movl %eax, 0xc(%rbx)
movq %r13, %rsi
imull %esi, %eax
addq 0x10(%r15), %rax
movq %rax, 0x10(%rbx)
movl 0xb0(%rsp), %ecx
movl %ecx, (%rbx)
movl 0x24(%rsp), %r13d
movl %r13d, 0x4(%rbx)
leal (%rsi,%r12), %edx
movq 0x38(%rsp), %rax
addl %esi, %eax
movl 0x8(%rsp), %r12d
subl %eax, %r12d
movq %r14, %rdi
movl %ebp, %esi
movl %edx, %ebp
movq %rcx, %r14
movl %r12d, %r8d
movq %rbx, %r9
callq 0xc52c
movl 0x8(%r15), %ecx
movl %ecx, 0x8(%rbx)
movl 0xc(%r15), %eax
addl %ecx, %ecx
movl $0x157fff8, %edx        # imm = 0x157FFF8
shrl %cl, %edx
movl %eax, 0xc(%rbx)
andl $0x3, %edx
incl %edx
imull %r14d, %edx
movl 0xc0(%rsp), %ecx
imull %ecx, %eax
addl %edx, %eax
addq 0x10(%r15), %rax
movq %rax, 0x10(%rbx)
movl 0x14(%rsp), %eax
movl %eax, (%rbx)
movl %r13d, %r14d
movl %r13d, 0x4(%rbx)
movq 0x28(%rsp), %r13
movq %r13, %rdi
movl 0x10(%rsp), %esi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movl %r12d, %r8d
movq %rbx, %r9
callq 0xc52c
movl 0x8(%r15), %ecx
movl %ecx, 0x8(%rbx)
movl 0xc(%r15), %eax
addl %ecx, %ecx
movl $0x157fff8, %edx        # imm = 0x157FFF8
shrl %cl, %edx
movl %eax, 0xc(%rbx)
andl $0x3, %edx
incl %edx
imull 0xb8(%rsp), %edx
movl 0xc0(%rsp), %ecx
imull %ecx, %eax
addl %edx, %eax
addq 0x10(%r15), %rax
movq %rax, 0x10(%rbx)
movq 0x18(%rsp), %rcx
movl %ecx, (%rbx)
movl %r14d, 0x4(%rbx)
movq %r13, %rdi
movl 0x4(%rsp), %esi
movl %ebp, %edx
movl %r12d, %r8d
movq %rbx, %r9
callq 0xc52c
movl 0x8(%rsp), %edx
addl 0x40(%rsp), %edx
movl 0x8(%r15), %eax
leaq 0x48(%rsp), %rcx
movl %eax, 0x8(%rcx)
movl 0xc(%r15), %eax
movl %eax, 0xc(%rcx)
movl 0xc8(%rsp), %ebp
imull %ebp, %eax
addq 0x10(%r15), %rax
movq 0x38(%rsp), %r14
subl %r14d, %edx
movq %rax, 0x10(%rcx)
movl 0xb0(%rsp), %eax
movl %eax, (%rcx)
movl %r14d, 0x4(%rcx)
leaq 0x48(%rsp), %r12
movq %r13, %rdi
movq 0x30(%rsp), %rsi
movl %edx, %ebp
movq %r12, %rcx
callq 0xbe76
movl 0x8(%r15), %ecx
movl %ecx, 0x8(%rbx)
movl 0xc(%r15), %eax
addl %ecx, %ecx
movl $0x157fff8, %edx        # imm = 0x157FFF8
shrl %cl, %edx
movl %eax, 0xc(%rbx)
andl $0x3, %edx
incl %edx
movl 0xb0(%rsp), %ecx
imull %ecx, %edx
imull 0xc8(%rsp), %eax
addl %edx, %eax
addq 0x10(%r15), %rax
movq %rax, 0x10(%rbx)
movl 0x14(%rsp), %eax
movl %eax, (%rbx)
movl %r14d, 0x4(%rbx)
movq %r13, %rdi
movl 0x10(%rsp), %esi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movl %r14d, %r8d
movq %rbx, %r9
callq 0xc52c
movl 0x8(%r15), %ecx
movl %ecx, 0x8(%r12)
movl 0xc(%r15), %eax
addl %ecx, %ecx
movl $0x157fff8, %edx        # imm = 0x157FFF8
shrl %cl, %edx
movl %eax, 0xc(%r12)
andl $0x3, %edx
incl %edx
imull 0xb8(%rsp), %edx
imull 0xc8(%rsp), %eax
addl %edx, %eax
addq 0x10(%r15), %rax
movq %rax, 0x10(%r12)
movq 0x18(%rsp), %rax
movl %eax, (%r12)
movl %r14d, 0x4(%r12)
leaq 0x48(%rsp), %rcx
movq %r13, %rdi
movl 0x4(%rsp), %esi
movl %ebp, %edx
callq 0xbe76
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq