// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movq %r9, %rbx
movl %r8d, 0x1c(%rsp)
movl %ecx, 0xc(%rsp)
movq %rdx, 0x28(%rsp)
movl %esi, %r15d
movl 0xb0(%rsp), %r10d
movl 0xb8(%rsp), %eax
movl 0xa0(%rsp), %r13d
movl 0xa8(%rsp), %ecx
movl (%r9), %r14d
movl 0x4(%r9), %r8d
movl %ecx, %ebp
subl %r13d, %ebp
movl %ebp, 0x18(%rsp)
subl %ecx, %r14d
movl %eax, %ecx
subl %r10d, %ecx
movl %ecx, 0x24(%rsp)
subl %eax, %r8d
movq %r8, 0x40(%rsp)
movq %rdi, %r12
movq %rdi, 0x48(%rsp)
movq %r9, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r10
pushq %r13
callq 0xb0f2
popq %rax
popq %rcx
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movl %r13d, %edx
xorl %ecx, %ecx
movl %ebp, %r8d
movl 0xb0(%rsp), %r9d
callq 0xb140
movq %r15, 0x38(%rsp)
leal (%r15,%r13), %esi
movl %esi, 0x14(%rsp)
leal (%r14,%r13), %eax
movl 0xc(%rsp), %r13d
movl %r13d, %ecx
subl %eax, %ecx
movl %ecx, 0x10(%rsp)
movq %r12, %rdi
movq 0x28(%rsp), %rbp
movl %ebp, %edx
movl 0xb0(%rsp), %r8d
leaq 0x50(%rsp), %r9
callq 0xa7a2
addl %r15d, %r13d
movq %r14, 0x30(%rsp)
subl %r14d, %r13d
movl %r13d, 0xc(%rsp)
movq %r12, %rdi
movl %r13d, %esi
movl %ebp, %edx
movq %rbx, %rcx
movl 0xa8(%rsp), %r8d
xorl %r9d, %r9d
movl 0xb0(%rsp), %r12d
pushq %r12
pushq %r14
callq 0xb0f2
popq %rax
popq %rcx
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r12, %r14
movl %r14d, %ecx
movl 0xa0(%rsp), %r13d
movl %r13d, %r8d
movl 0x24(%rsp), %r12d
movl %r12d, %r9d
callq 0xb140
leal (%r14,%rbp), %edx
movl %edx, 0x20(%rsp)
movq 0x40(%rsp), %rax
addl %r14d, %eax
movl 0x1c(%rsp), %r14d
subl %eax, %r14d
movq 0x48(%rsp), %rbp
movq %rbp, %rdi
movq 0x38(%rsp), %rsi
movl %r13d, %ecx
movl %r14d, %r8d
movq %r15, %r9
callq 0xa7a2
movq %r15, %rdi
movq %rbx, %rsi
movl %r13d, %edx
movl 0xb0(%rsp), %ecx
movl 0x18(%rsp), %r8d
movl %r12d, %r9d
callq 0xb140
movq %rbp, %r13
movq %rbp, %rdi
movl 0x14(%rsp), %esi
movl 0x20(%rsp), %ebp
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl %r14d, %r8d
movq %r15, %r9
callq 0xa7a2
movq %r15, %rdi
movq %rbx, %rsi
movl 0xa8(%rsp), %edx
movl 0xb0(%rsp), %ecx
movq 0x30(%rsp), %r15
movl %r15d, %r8d
movl %r12d, %r9d
callq 0xb140
movq %r13, %rdi
movl 0xc(%rsp), %esi
movl %ebp, %edx
movl %r15d, %ecx
movl %r14d, %r8d
leaq 0x50(%rsp), %r9
callq 0xa7a2
movl 0x1c(%rsp), %ebp
addl 0x28(%rsp), %ebp
movq 0x40(%rsp), %r15
subl %r15d, %ebp
movq %r13, %rdi
movq %r13, %r12
movq 0x38(%rsp), %rsi
movl %ebp, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
movl 0xb8(%rsp), %r14d
movl %r14d, %r9d
pushq %r15
movl 0xa8(%rsp), %r13d
pushq %r13
callq 0xb0f2
popq %rax
popq %rcx
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movl %r13d, %edx
movl %r14d, %ecx
movl 0x18(%rsp), %r8d
movl %r15d, %r9d
callq 0xb140
movq %r12, %rdi
movl 0x14(%rsp), %esi
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl %r15d, %r8d
leaq 0x50(%rsp), %r9
callq 0xa7a2
movq %r12, %rdi
movl 0xc(%rsp), %esi
movl %ebp, %edx
movq %rbx, %rcx
movl 0xa8(%rsp), %r8d
movl %r14d, %r9d
pushq %r15
pushq 0x38(%rsp)
callq 0xb0f2
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop