// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl %r8d, -0x14(%rbp)
movl %r9d, -0x18(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x3fc5f3(%rip), %rax    # 0x44ad80
movswl (%rax,%rcx,2), %eax
movl %eax, -0x30(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x3edda1(%rip), %rax    # 0x43c540
movswl (%rax,%rcx,2), %eax
movl %eax, -0x34(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x3fc5cf(%rip), %rax    # 0x44ad80
movswl (%rax,%rcx,2), %eax
movl %eax, -0x38(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x3edd7d(%rip), %rax    # 0x43c540
movswl (%rax,%rcx,2), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x30(%rbp)
jle 0x4e956
cmpl $0x0, -0x34(%rbp)
jle 0x4e956
cmpl $0x0, -0x38(%rbp)
jle 0x4e956
cmpl $0x0, -0x3c(%rbp)
jle 0x4e956
movslq -0x4(%rbp), %rcx
leaq 0x387643(%rip), %rax    # 0x3d5e40
cmpq $0x0, (%rax,%rcx,8)
jne 0x4e80f
movl -0x4(%rbp), %eax
movswl %ax, %edi
callq 0x44df0
movslq -0x18(%rbp), %rcx
leaq 0x387626(%rip), %rax    # 0x3d5e40
cmpq $0x0, (%rax,%rcx,8)
jne 0x4e82c
movl -0x18(%rbp), %eax
movswl %ax, %edi
callq 0x44df0
movl -0x8(%rbp), %eax
movl %eax, -0x48(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x4e954
movl -0xc(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4e92c
movl 0x10(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x50(%rbp)
movl 0x18(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x50(%rbp)
jl 0x4e904
cmpl $0x0, -0x54(%rbp)
jl 0x4e904
movl -0x50(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x4e904
movl -0x54(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x4e904
movslq -0x4(%rbp), %rcx
leaq 0x3875a1(%rip), %rax    # 0x3d5e40
movq (%rax,%rcx,8), %rax
movl -0x48(%rbp), %ecx
imull -0x34(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movslq -0x4c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x38757a(%rip), %rax    # 0x3d5e40
movq (%rax,%rcx,8), %rax
movl -0x50(%rbp), %ecx
imull -0x3c(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movb (%rax), %al
movb %al, -0x29(%rbp)
movzbl -0x29(%rbp), %eax
cmpl $0xff, %eax
je 0x4e902
movq -0x20(%rbp), %rax
movb (%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
jmp 0x4e904
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x4e91c
movl $0x0, -0x4c(%rbp)
jmp 0x4e91e
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x4e852
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x30(%rbp), %eax
jl 0x4e944
movl $0x0, -0x48(%rbp)
jmp 0x4e946
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x4e839
jmp 0x4e956
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)