// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: copytilepiece
void copytilepiece(int tilenume1, int sx1, int sy1, int xsiz, int ysiz,
		  int tilenume2, int sx2, int sy2)
{
	unsigned char *ptr1, *ptr2, dat;
	int xsiz1, ysiz1, xsiz2, ysiz2, i, j, x1, y1, x2, y2;

	xsiz1 = tilesizx[tilenume1]; ysiz1 = tilesizy[tilenume1];
	xsiz2 = tilesizx[tilenume2]; ysiz2 = tilesizy[tilenume2];
	if ((xsiz1 > 0) && (ysiz1 > 0) && (xsiz2 > 0) && (ysiz2 > 0))
	{
		if (waloff[tilenume1] == 0) loadtile(tilenume1);
		if (waloff[tilenume2] == 0) loadtile(tilenume2);

		x1 = sx1;
		for(i=0;i<xsiz;i++)
		{
			y1 = sy1;
			for(j=0;j<ysiz;j++)
			{
				x2 = sx2+i;
				y2 = sy2+j;
				if ((x2 >= 0) && (y2 >= 0) && (x2 < xsiz2) && (y2 < ysiz2))
				{
					ptr1 = (unsigned char *)(waloff[tilenume1] + x1*ysiz1 + y1);
					ptr2 = (unsigned char *)(waloff[tilenume2] + x2*ysiz2 + y2);
					dat = *ptr1;
					if (dat != 255)
						*ptr2 = *ptr1;
				}

				y1++; if (y1 >= ysiz1) y1 = 0;
			}
			x1++; if (x1 >= xsiz1) x1 = 0;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
movl %edx, 0x1c(%rsp)
movl %esi, %r15d
movslq %edi, %rsi
leaq 0x3d9ed7(%rip), %rax    # 0x40f020
movswl (%rax,%rsi,2), %ecx
movl %ecx, 0x24(%rsp)
testl %ecx, %ecx
setg %cl
leaq 0x3cb683(%rip), %rdx    # 0x4007e0
movq %rsi, 0x30(%rsp)
movzwl (%rdx,%rsi,2), %ebp
movslq %r9d, %rsi
movzwl (%rax,%rsi,2), %r14d
movq %rsi, 0x28(%rsp)
movzwl (%rdx,%rsi,2), %r12d
testw %bp, %bp
setg %al
andb %cl, %al
testw %r14w, %r14w
setg %cl
testw %r12w, %r12w
setg %dl
andb %cl, %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x352e4
movl %r9d, %ebx
leaq 0x36313b(%rip), %r13    # 0x3982e0
movq 0x30(%rsp), %rax
cmpq $0x0, (%r13,%rax,8)
jne 0x351ba
movswl %di, %edi
callq 0x2f106
movq 0x28(%rsp), %rax
cmpq $0x0, (%r13,%rax,8)
jne 0x351cf
movswl %bx, %edi
callq 0x2f106
cmpl $0x0, 0xc(%rsp)
jle 0x352e4
movl 0x88(%rsp), %eax
movl 0x80(%rsp), %esi
movswl %bp, %ecx
movswl %r14w, %edx
movswl %r12w, %edi
cltq
movl %edi, 0x20(%rsp)
movslq %edi, %r8
movl 0x8(%rsp), %edi
movq %rdi, 0x38(%rsp)
movl %r8d, %edi
imull %esi, %edi
movq %rax, 0x40(%rsp)
addl %eax, %edi
movl %edi, 0x4(%rsp)
xorl %r11d, %r11d
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0x8(%rsp)
jle 0x352b6
movl 0x80(%rsp), %eax
movq 0x10(%rsp), %rsi
leal (%rsi,%rax), %r9d
movl %r15d, %edi
imull %ecx, %edi
movslq %edi, %rdi
movq 0x38(%rsp), %rbp
movq 0x40(%rsp), %r12
movl 0x4(%rsp), %r10d
movl 0x1c(%rsp), %r14d
testl %r9d, %r9d
js 0x352a1
testq %r12, %r12
js 0x352a1
cmpl %edx, %r9d
jge 0x352a1
cmpq %r8, %r12
jge 0x352a1
movq 0x30(%rsp), %rsi
movq (%r13,%rsi,8), %rbx
movq %r13, %rax
movslq %r14d, %r13
addq %rdi, %r13
movb (%rbx,%r13), %bl
movq %rax, %r13
cmpb $-0x1, %bl
je 0x352a1
movq 0x28(%rsp), %rsi
movq (%rax,%rsi,8), %r13
movl %r10d, %esi
movb %bl, (%r13,%rsi)
movq %rax, %r13
incl %r14d
cmpl %ecx, %r14d
cmovgel %r11d, %r14d
incl %r10d
incq %r12
decq %rbp
jne 0x3525a
incl %r15d
cmpl 0x24(%rsp), %r15d
cmovgel %r11d, %r15d
movq 0x10(%rsp), %rsi
incl %esi
movl 0x4(%rsp), %eax
addl 0x20(%rsp), %eax
movl %eax, 0x4(%rsp)
movq %rsi, 0x10(%rsp)
cmpl 0xc(%rsp), %esi
jne 0x35222
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq