// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: loadtile
void loadtile(short tilenume)
{
	char *ptr;
	int i, dasiz;

	if ((unsigned)tilenume >= (unsigned)MAXTILES) return;
	dasiz = tilesizx[tilenume]*tilesizy[tilenume];
	if (dasiz <= 0) return;

	i = tilefilenum[tilenume];
	if (i != artfilnum)
	{
		if (artfil != -1) kclose(artfil);
		artfilnum = i;
		artfilplc = 0L;

		artfilename[7] = (i%10)+48;
		artfilename[6] = ((i/10)%10)+48;
		artfilename[5] = ((i/100)%10)+48;
		artfil = kopen4load(artfilename,0);
		faketimerhandler();
	}

	if (cachedebug) buildprintf("Tile:%d\n",tilenume);

	if (waloff[tilenume] == 0)
	{
		walock[tilenume] = 199;
		allocache((void **)&waloff[tilenume],dasiz,&walock[tilenume]);
	}

	if (artfilplc != tilefileoffs[tilenume])
	{
		klseek(artfil,tilefileoffs[tilenume]-artfilplc,BSEEK_CUR);
		faketimerhandler();
	}
	ptr = (char *)waloff[tilenume];
	kread(artfil,ptr,dasiz);
	faketimerhandler();
	artfilplc = tilefileoffs[tilenume]+dasiz;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movw %di, %ax
movw %ax, -0x2(%rbp)
movswl -0x2(%rbp), %eax
cmpl $0x2400, %eax           # imm = 0x2400
jb 0x44e0f
jmp 0x44fe1
movswq -0x2(%rbp), %rcx
leaq 0x405f65(%rip), %rax    # 0x44ad80
movswl (%rax,%rcx,2), %eax
movswq -0x2(%rbp), %rdx
leaq 0x3f7715(%rip), %rcx    # 0x43c540
movswl (%rcx,%rdx,2), %ecx
imull %ecx, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jg 0x44e40
jmp 0x44fe1
movswq -0x2(%rbp), %rcx
leaq 0x4188a4(%rip), %rax    # 0x45d6f0
movzbl (%rax,%rcx), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x424114(%rip), %eax    # 0x468f70
je 0x44ef4
cmpl $-0x1, 0x9c2d3(%rip)    # 0xe113c
je 0x44e76
movl 0x9c2cb(%rip), %edi     # 0xe113c
callq 0x30960
movl -0x14(%rbp), %eax
movl %eax, 0x4240f1(%rip)    # 0x468f70
movl $0x0, 0x4240eb(%rip)    # 0x468f74
movl -0x14(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, 0x418838(%rip)     # 0x45d6d7
movl -0x14(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl $0xa, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, 0x418819(%rip)     # 0x45d6d6
movl -0x14(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl $0xa, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, 0x4187fa(%rip)     # 0x45d6d5
leaq 0x4187ee(%rip), %rdi    # 0x45d6d0
xorl %esi, %esi
callq 0x2fee0
movl %eax, 0x9c24d(%rip)     # 0xe113c
callq 0xc220
cmpb $0x0, 0x42407d(%rip)    # 0x468f78
je 0x44f0f
movswl -0x2(%rbp), %esi
leaq 0x6e46f(%rip), %rdi     # 0xb3377
movb $0x0, %al
callq 0x37c90
movswq -0x2(%rbp), %rcx
leaq 0x390f25(%rip), %rax    # 0x3d5e40
cmpq $0x0, (%rax,%rcx,8)
jne 0x44f5d
movswq -0x2(%rbp), %rcx
leaq 0x424052(%rip), %rax    # 0x468f80
movb $-0x39, (%rax,%rcx)
movswq -0x2(%rbp), %rax
leaq 0x390f02(%rip), %rdi    # 0x3d5e40
shlq $0x3, %rax
addq %rax, %rdi
movslq -0x18(%rbp), %rsi
movswq -0x2(%rbp), %rax
leaq 0x42402b(%rip), %rdx    # 0x468f80
addq %rax, %rdx
callq 0x2e6f0
movl 0x424011(%rip), %eax    # 0x468f74
movswq -0x2(%rbp), %rdx
leaq 0x41ab81(%rip), %rcx    # 0x45faf0
cmpl (%rcx,%rdx,4), %eax
je 0x44f9e
movl 0x9c1c2(%rip), %edi     # 0xe113c
movswq -0x2(%rbp), %rcx
leaq 0x41ab6a(%rip), %rax    # 0x45faf0
movl (%rax,%rcx,4), %esi
subl 0x423fe5(%rip), %esi    # 0x468f74
movl $0x1, %edx
callq 0x30590
callq 0xc220
movswq -0x2(%rbp), %rcx
leaq 0x390e96(%rip), %rax    # 0x3d5e40
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
movl 0x9c184(%rip), %edi     # 0xe113c
movq -0x10(%rbp), %rsi
movl -0x18(%rbp), %edx
callq 0x302b0
callq 0xc220
movswq -0x2(%rbp), %rcx
leaq 0x41ab1b(%rip), %rax    # 0x45faf0
movl (%rax,%rcx,4), %eax
addl -0x18(%rbp), %eax
movl %eax, 0x423f93(%rip)    # 0x468f74
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)