// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: pt_load_hightile
static int pt_load_hightile(PTHead * pth)
{
	const char *filename = 0;
	int effects = 0;
	int err = 0;
	int texture = 0, loaded[PTHPIC_SIZE] = { 0,0,0,0,0,0, };
    PTMIdent id;

	if (!pth->repldef) {
		return 0;
	} else if ((pth->flags & PTH_SKYBOX) && (pth->repldef->skybox == 0 || pth->repldef->skybox->ignore)) {
		return 0;
	} else if (pth->repldef->ignore) {
		return 0;
	}

	effects = (pth->palnum != pth->repldef->palnum) ? hictinting[pth->palnum].f : 0;

	pth->flags &= ~(PTH_NOCOMPRESS | PTH_HASALPHA);
	if (pth->repldef->flags & HIC_NOCOMPRESS) {
		pth->flags |= PTH_NOCOMPRESS;
	}

	for (texture = 0; texture < PTHPIC_SIZE; texture++) {
		if (pth->flags & PTH_SKYBOX) {
			if (texture >= 6) {
				texture = PTHPIC_SIZE;
				continue;
			}
			filename = pth->repldef->skybox->face[texture];
		} else {
			switch (texture) {
				case PTHPIC_BASE:
					filename = pth->repldef->filename;
					break;
				default:
					// future developments may use the other indices
					texture = PTHPIC_SIZE;
					continue;
			}
		}

		if (!filename) {
			continue;
		}

        PTM_InitIdent(&id, pth);
        id.layer = texture;
        pth->pic[texture] = PTM_GetHead(&id);

		if ((err = PTM_LoadTextureFile(filename, pth->pic[texture], pth->flags, effects))) {
			if (polymosttexverbosity >= 1) {
				const char * errstr = PTM_GetLoadTextureFileErrorString(err);
				buildprintf("PolymostTex: %s (pic %d pal %d) %s\n",
						   filename, pth->picnum, pth->palnum, errstr);
			}
			continue;
		}

		if (texture == 0) {
			if (pth->flags & PTH_SKYBOX) {
				pth->scalex = (float)pth->pic[texture]->tsizx / 64.0;
				pth->scaley = (float)pth->pic[texture]->tsizy / 64.0;
			} else {
				pth->scalex = (float)pth->pic[texture]->tsizx / (float)tilesizx[pth->picnum];
				pth->scaley = (float)pth->pic[texture]->tsizy / (float)tilesizy[pth->picnum];
			}
		}

		loaded[texture] = 1;
	}

	pt_load_applyparameters(pth);

	if (pth->flags & PTH_SKYBOX) {
		int i = 0;
		for (texture = 0; texture < 6; texture++) i += loaded[texture];
		return (i == 6);
	} else {
		return loaded[PTHPIC_BASE];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x470, %rsp            # imm = 0x470
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x62d0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x9b393
movl $0x0, -0x4(%rbp)
jmp 0x9b6e4
movq -0x10(%rbp), %rax
movzwl 0x38(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x9b3d0
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
cmpq $0x0, 0x20(%rax)
je 0x9b3c4
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x20(%rax), %rax
cmpq $0x0, (%rax)
je 0x9b3d0
movl $0x0, -0x4(%rbp)
jmp 0x9b6e4
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
cmpb $0x0, 0x9(%rax)
je 0x9b3ea
movl $0x0, -0x4(%rbp)
jmp 0x9b6e4
jmp 0x9b3ec
jmp 0x9b3ee
movq -0x10(%rbp), %rax
movl 0x34(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movzbl 0x8(%rcx), %ecx
cmpl %ecx, %eax
je 0x9b421
movq -0x10(%rbp), %rax
movslq 0x34(%rax), %rcx
leaq 0x5a07ec(%rip), %rax    # 0x63bc00
movzbl 0x3(%rax,%rcx,4), %eax
movl %eax, -0x468(%rbp)
jmp 0x9b42b
xorl %eax, %eax
movl %eax, -0x468(%rbp)
jmp 0x9b42b
movl -0x468(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x38(%rax), %ecx
andl $-0x19, %ecx
movw %cx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movzbl 0xa(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x9b466
movq -0x10(%rbp), %rax
movzwl 0x38(%rax), %ecx
orl $0x10, %ecx
movw %cx, 0x38(%rax)
movl $0x0, -0x24(%rbp)
cmpl $0x6, -0x24(%rbp)
jge 0x9b67b
movq -0x10(%rbp), %rax
movzwl 0x38(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x9b4b4
cmpl $0x6, -0x24(%rbp)
jl 0x9b499
movl $0x6, -0x24(%rbp)
jmp 0x9b66d
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
jmp 0x9b4dd
movl -0x24(%rbp), %eax
testl %eax, %eax
jne 0x9b4cf
jmp 0x9b4bd
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x9b4db
movl $0x6, -0x24(%rbp)
jmp 0x9b66d
jmp 0x9b4dd
cmpq $0x0, -0x18(%rbp)
jne 0x9b4e9
jmp 0x9b66d
movq -0x10(%rbp), %rsi
leaq -0x458(%rbp), %rdi
callq 0x98920
movl -0x24(%rbp), %eax
movl %eax, -0x448(%rbp)
leaq -0x458(%rbp), %rdi
callq 0x98a80
movq %rax, %rdx
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rax
movzwl 0x38(%rax), %edx
movl -0x1c(%rbp), %ecx
callq 0x98bb0
movl %eax, -0x20(%rbp)
cmpl $0x0, %eax
je 0x9b589
cmpl $0x1, 0x46684(%rip)     # 0xe1bd0
jl 0x9b584
movl -0x20(%rbp), %edi
callq 0x99fe0
movq %rax, -0x460(%rbp)
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x34(%rax), %ecx
movq -0x460(%rbp), %r8
leaq 0x1cb32(%rip), %rdi     # 0xb80af
movb $0x0, %al
callq 0x37c90
jmp 0x9b66d
cmpl $0x0, -0x24(%rbp)
jne 0x9b661
movq -0x10(%rbp), %rax
movzwl 0x38(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x9b601
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cvtsi2ssl 0x10(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x17730(%rip), %xmm1    # 0xb2cf0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x48(%rax)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cvtsi2ssl 0x14(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x17702(%rip), %xmm1    # 0xb2cf0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x4c(%rax)
jmp 0x9b65f
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
cvtsi2ssl 0x10(%rcx), %xmm0
movslq 0x30(%rax), %rdx
leaq 0x3af763(%rip), %rcx    # 0x44ad80
movswl (%rcx,%rdx,2), %ecx
cvtsi2ss %ecx, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x48(%rax)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
cvtsi2ssl 0x14(%rcx), %xmm0
movslq 0x30(%rax), %rcx
leaq 0x3a0ef6(%rip), %rax    # 0x43c540
movswl (%rax,%rcx,2), %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x4c(%rax)
jmp 0x9b661
movslq -0x24(%rbp), %rax
movl $0x1, -0x40(%rbp,%rax,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9b46d
movq -0x10(%rbp), %rdi
callq 0x9bcd0
movq -0x10(%rbp), %rax
movzwl 0x38(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x9b6de
movl $0x0, -0x464(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x6, -0x24(%rbp)
jge 0x9b6ca
movslq -0x24(%rbp), %rax
movl -0x40(%rbp,%rax,4), %eax
addl -0x464(%rbp), %eax
movl %eax, -0x464(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9b6a5
cmpl $0x6, -0x464(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x9b6e4
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x470, %rsp            # imm = 0x470
popq %rbp
retq