// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_drawtilescreen
int polymost_drawtilescreen (int tilex, int tiley, int wallnum, int dimen)
{
	float xdime, ydime, xdimepad, ydimepad, scx, scy;
	PTHead *pth;
	palette_t bgcolour;
	struct polymostdrawauxcall draw;
	struct polymostvboitem vboitem[4];

	if ((rendmode != 3) || (qsetmode != 200)) return(-1);

	xdime = (float)tilesizx[wallnum];
	ydime = (float)tilesizy[wallnum];

	if ((xdime <= dimen) && (ydime <= dimen)) {
		scx = xdime;
		scy = ydime;
	} else {
		scx = (float)dimen;
		scy = (float)dimen;
		if (xdime < ydime) {
			scx *= xdime/ydime;
		} else {
			scy *= ydime/xdime;
		}
	}

	pth = PT_GetHead(wallnum, 0, (usehightile ? PTH_HIGHTILE : 0) | PTH_CLAMPED, 0);

	if (pth) {
		xdimepad = (float)pth->pic[PTHPIC_BASE]->tsizx / (float)pth->pic[PTHPIC_BASE]->sizx;
		ydimepad = (float)pth->pic[PTHPIC_BASE]->tsizy / (float)pth->pic[PTHPIC_BASE]->sizy;
	} else {
		xdimepad = 1.0;
		ydimepad = 1.0;
	}

	bgcolour = curpalette[255];
	if (!usegammabrightness) {
		bgcolour.r = britable[curbrightness][bgcolour.r];
		bgcolour.g = britable[curbrightness][bgcolour.g];
		bgcolour.b = britable[curbrightness][bgcolour.b];
	}

	draw.mode = 1;	// Tile.

	draw.texture0 = nulltexture;
	if (pth) {
		if (pth->pic[PTHPIC_BASE]) {
			draw.texture0 = pth->pic[PTHPIC_BASE]->glpic;
		}
	}

	draw.bgcolour.r = bgcolour.r / 255.f;
	draw.bgcolour.g = bgcolour.g / 255.f;
	draw.bgcolour.b = bgcolour.b / 255.f;
	draw.bgcolour.a = 1.f;

	vboitem[0].v.x = (GLfloat)tilex;
	vboitem[0].v.y = (GLfloat)tiley;
	vboitem[0].v.z = 0.f;
	vboitem[0].t.s = 0.f;
	vboitem[0].t.t = 0.f;

	vboitem[1].v.x = (GLfloat)tilex+scx;
	vboitem[1].v.y = (GLfloat)tiley;
	vboitem[1].v.z = 0.f;
	vboitem[1].t.s = xdimepad;
	vboitem[1].t.t = 0.f;

	vboitem[2].v.x = (GLfloat)tilex+scx;
	vboitem[2].v.y = (GLfloat)tiley+scy;
	vboitem[2].v.z = 0.f;
	vboitem[2].t.s = xdimepad;
	vboitem[2].t.t = ydimepad;

	vboitem[3].v.x = (GLfloat)tilex;
	vboitem[3].v.y = (GLfloat)tiley+scy;
	vboitem[3].v.z = 0.f;
	vboitem[3].t.s = 0.f;
	vboitem[3].t.t = ydimepad;

	draw.indexcount = 4;
	draw.indexes = NULL;
	draw.elementcount = 4;
	draw.elementvbo = vboitem;

	polymost_drawaux_glcall(GL_TRIANGLE_FAN, &draw);

	return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
cmpl $0x3, 0x563892(%rip)    # 0x5ed920
jne 0x8a09f
leaq 0x16b4f1(%rip), %rax    # 0x1f5588
cmpl $0xc8, (%rax)
je 0x8a0ab
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8a43c
movslq -0x10(%rbp), %rcx
leaq 0x3c0cca(%rip), %rax    # 0x44ad80
movswl (%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x18(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0x3b2472(%rip), %rax    # 0x43c540
movswl (%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x1c(%rbp)
movss -0x18(%rbp), %xmm1
cvtsi2ssl -0x14(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x8a10f
movss -0x1c(%rbp), %xmm1
cvtsi2ssl -0x14(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x8a10f
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
jmp 0x8a15e
cvtsi2ssl -0x14(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
cvtsi2ssl -0x14(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x18(%rbp), %xmm1
movss -0x1c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x8a148
movss -0x18(%rbp), %xmm0
divss -0x1c(%rbp), %xmm0
mulss -0x28(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
jmp 0x8a15c
movss -0x1c(%rbp), %xmm0
divss -0x18(%rbp), %xmm0
mulss -0x2c(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
jmp 0x8a15e
movl -0x10(%rbp), %edi
movl 0x579ed(%rip), %edx     # 0xe1b54
xorl %eax, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl $0x1, %eax
xorl %ecx, %ecx
movl %ecx, %esi
movzwl %ax, %edx
callq 0x9a790
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x8a1d2
movq -0x38(%rbp), %rax
movq (%rax), %rax
cvtsi2ssl 0x10(%rax), %xmm0
movq -0x38(%rbp), %rax
movq (%rax), %rax
cvtsi2ssl 0x8(%rax), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
cvtsi2ssl 0x14(%rax), %xmm0
movq -0x38(%rbp), %rax
movq (%rax), %rax
cvtsi2ssl 0xc(%rax), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x8a1ec
movss 0x28c26(%rip), %xmm0    # 0xb2e00
movss %xmm0, -0x20(%rbp)
movss 0x28c19(%rip), %xmm0    # 0xb2e00
movss %xmm0, -0x24(%rbp)
leaq 0x3e700d(%rip), %rax    # 0x471200
movl 0x3fc(%rax), %eax
movl %eax, -0x3c(%rbp)
leaq 0x56a79(%rip), %rax     # 0xe0c7c
cmpl $0x0, (%rax)
jne 0x8a26e
leaq 0x16b355(%rip), %rax    # 0x1f5564
movslq (%rax), %rcx
leaq 0x3e77e7(%rip), %rax    # 0x471a00
shlq $0x8, %rcx
addq %rcx, %rax
movzbl -0x3c(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x3c(%rbp)
leaq 0x16b333(%rip), %rax    # 0x1f5564
movslq (%rax), %rcx
leaq 0x3e77c5(%rip), %rax    # 0x471a00
shlq $0x8, %rcx
addq %rcx, %rax
movzbl -0x3b(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x3b(%rbp)
leaq 0x16b311(%rip), %rax    # 0x1f5564
movslq (%rax), %rcx
leaq 0x3e77a3(%rip), %rax    # 0x471a00
shlq $0x8, %rcx
addq %rcx, %rax
movzbl -0x3a(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x3a(%rbp)
movl $0x1, -0x64(%rbp)
movl 0x56379d(%rip), %eax    # 0x5eda18
movl %eax, -0x88(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x8a2a3
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
je 0x8a2a1
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x88(%rbp)
jmp 0x8a2a3
movzbl -0x3c(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x2c325(%rip), %xmm1    # 0xb65d8
divss %xmm1, %xmm0
movss %xmm0, -0x74(%rbp)
movzbl -0x3b(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x2c30c(%rip), %xmm1    # 0xb65d8
divss %xmm1, %xmm0
movss %xmm0, -0x70(%rbp)
movzbl -0x3a(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x2c2f3(%rip), %xmm1    # 0xb65d8
divss %xmm1, %xmm0
movss %xmm0, -0x6c(%rbp)
movss 0x28b0a(%rip), %xmm0    # 0xb2e00
movss %xmm0, -0x68(%rbp)
cvtsi2ssl -0x8(%rbp), %xmm0
movss %xmm0, -0xe0(%rbp)
cvtsi2ssl -0xc(%rbp), %xmm0
movss %xmm0, -0xdc(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xd8(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xd4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xd0(%rbp)
cvtsi2ssl -0x8(%rbp), %xmm0
addss -0x28(%rbp), %xmm0
movss %xmm0, -0xcc(%rbp)
cvtsi2ssl -0xc(%rbp), %xmm0
movss %xmm0, -0xc8(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xc4(%rbp)
movss -0x20(%rbp), %xmm0
movss %xmm0, -0xc0(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xbc(%rbp)
cvtsi2ssl -0x8(%rbp), %xmm0
addss -0x28(%rbp), %xmm0
movss %xmm0, -0xb8(%rbp)
cvtsi2ssl -0xc(%rbp), %xmm0
addss -0x2c(%rbp), %xmm0
movss %xmm0, -0xb4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xb0(%rbp)
movss -0x20(%rbp), %xmm0
movss %xmm0, -0xac(%rbp)
movss -0x24(%rbp), %xmm0
movss %xmm0, -0xa8(%rbp)
cvtsi2ssl -0x8(%rbp), %xmm0
movss %xmm0, -0xa4(%rbp)
cvtsi2ssl -0xc(%rbp), %xmm0
addss -0x2c(%rbp), %xmm0
movss %xmm0, -0xa0(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x9c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x98(%rbp)
movss -0x24(%rbp), %xmm0
movss %xmm0, -0x94(%rbp)
movl $0x4, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x4, -0x50(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x6, %edi
leaq -0x88(%rbp), %rsi
callq 0x8a450
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)