LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: voxfree
void voxfree (voxmodel *m)
{
	if (!m) return;
	if (m->mytex) free(m->mytex);
	if (m->quad) free(m->quad);
	if (m->texid) free(m->texid);
	free(m);
}

// Assembly:
testq %rdi, %rdi
je 0x56db8
pushq %rbx
movq %rdi, %rbx
movq 0x48(%rdi), %rdi
callq 0x61c0
movq 0x20(%rbx), %rdi
callq 0x61c0
movq 0x18(%rbx), %rdi
callq 0x61c0
movq %rbx, %rdi
popq %rbx
jmp 0x61c0
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: md2free
static void md2free (md2model *m)
{
	mdanim_t *anim, *nanim = NULL;
	mdskinmap_t *sk, *nsk = NULL;

	if (!m) return;

	for(anim=m->animations; anim; anim=nanim)
	{
		nanim = anim->next;
		free(anim);
	}
	for(sk=m->skinmap; sk; sk=nsk)
	{
		nsk = sk->next;
		free(sk->fn);
		free(sk);
	}

	if (m->frames) free(m->frames);
	if (m->uvs) free(m->uvs);
	if (m->tris) free(m->tris);
	if (m->basepath) free(m->basepath);
	if (m->skinfn) free(m->skinfn);

	if (m->tex) free(m->tex);

	free(m);
}

// Assembly:
testq %rdi, %rdi
je 0x5aa90
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
testq %rdi, %rdi
je 0x5aa21
movq 0x10(%rdi), %r14
callq 0x61c0
movq %r14, %rdi
jmp 0x5aa0e
movq 0x48(%rbx), %r14
testq %r14, %r14
je 0x5aa44
movq 0x10(%r14), %rdi
movq 0x38(%r14), %r15
callq 0x61c0
movq %r14, %rdi
callq 0x61c0
movq %r15, %r14
jmp 0x5aa25
movq 0x70(%rbx), %rdi
callq 0x61c0
movq 0x78(%rbx), %rdi
callq 0x61c0
movq 0x80(%rbx), %rdi
callq 0x61c0
movq 0x88(%rbx), %rdi
callq 0x61c0
movq 0x90(%rbx), %rdi
callq 0x61c0
movq 0x18(%rbx), %rdi
callq 0x61c0
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x61c0
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: md3free
static void md3free (md3model *m)
{
	mdanim_t *anim, *nanim = NULL;
	mdskinmap_t *sk, *nsk = NULL;
	md3surf_t *s;
	int surfi;

	if (!m) return;

	for(anim=m->animations; anim; anim=nanim)
	{
		nanim = anim->next;
		free(anim);
	}
	for(sk=m->skinmap; sk; sk=nsk)
	{
		nsk = sk->next;
		free(sk->fn);
		free(sk);
	}

	if (m->head.surfs)
	{
		for(surfi=m->head.numsurfs-1;surfi>=0;surfi--)
		{
			s = &m->head.surfs[surfi];
			if (s->tris) free(s->tris);
		}
		free(m->head.surfs);
	}
	if (m->head.tags) free(m->head.tags);
	if (m->head.frames) free(m->head.frames);

	if (m->tex) free(m->tex);

	free(m);
}

// Assembly:
testq %rdi, %rdi
je 0x5ab50
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
testq %rdi, %rdi
je 0x5aab9
movq 0x10(%rdi), %r14
callq 0x61c0
movq %r14, %rdi
jmp 0x5aaa6
movq 0x48(%rbx), %r14
testq %r14, %r14
je 0x5aadc
movq 0x10(%r14), %rdi
movq 0x38(%r14), %r15
callq 0x61c0
movq %r14, %rdi
callq 0x61c0
movq %r15, %r14
jmp 0x5aabd
cmpq $0x0, 0xc8(%rbx)
je 0x5ab22
movl 0xac(%rbx), %r14d
movq %r14, %r15
shlq $0x7, %r15
addq $-0x28, %r15
testl %r14d, %r14d
jle 0x5ab16
movq 0xc8(%rbx), %rax
movq (%rax,%r15), %rdi
callq 0x61c0
decl %r14d
addq $-0x80, %r15
jmp 0x5aaf8
movq 0xc8(%rbx), %rdi
callq 0x61c0
movq 0xc0(%rbx), %rdi
callq 0x61c0
movq 0xb8(%rbx), %rdi
callq 0x61c0
movq 0x18(%rbx), %rdi
callq 0x61c0
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x61c0
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: putvox
static void putvox (int x, int y, int z, int col)
{
	if (vnum >= vmax) { vmax = max(vmax<<1,4096); vcol = (voxcol_t *)realloc(vcol,vmax*sizeof(voxcol_t)); }

	z += x*yzsiz + y*zsiz;
	vcol[vnum].p = z; z = ((z*214013)&vcolhashsizm1);
	vcol[vnum].c = col;
	vcol[vnum].n = vcolhashead[z]; vcolhashead[z] = vnum++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %r15d
movl %esi, %r14d
movl %edi, %ebp
movl 0x6524f8(%rip), %ecx    # 0x6ad060
movl 0x6524f6(%rip), %edx    # 0x6ad064
movq 0x65251b(%rip), %rax    # 0x6ad090
cmpl %edx, %ecx
jl 0x5aba8
addl %edx, %edx
cmpl $0x1001, %edx           # imm = 0x1001
movl $0x1000, %ecx           # imm = 0x1000
cmovgel %edx, %ecx
movl %ecx, 0x6524d5(%rip)    # 0x6ad064
imulq $0xc, %rcx, %rsi
movq %rax, %rdi
callq 0x6120
movq %rax, 0x6524ee(%rip)    # 0x6ad090
movl 0x6524b8(%rip), %ecx    # 0x6ad060
imull 0x6524fd(%rip), %ebp    # 0x6ad0ac
imull 0x6524b9(%rip), %r14d   # 0x6ad070
addl %r15d, %ebp
addl %r14d, %ebp
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
movl %ebp, (%rax,%rcx)
movslq %ebp, %rcx
imulq $0x343fd, %rcx, %rcx    # imm = 0x343FD
movslq 0x6524d0(%rip), %rdx    # 0x6ad0a8
andq %rcx, %rdx
movslq 0x65247e(%rip), %rcx    # 0x6ad060
imulq $0xc, %rcx, %rcx
movl %ebx, 0x4(%rax,%rcx)
movq 0x6524a7(%rip), %rcx    # 0x6ad098
movl (%rcx,%rdx,4), %esi
movslq 0x652465(%rip), %rdi    # 0x6ad060
imulq $0xc, %rdi, %rdi
movl %esi, 0x8(%rax,%rdi)
movl 0x652457(%rip), %eax    # 0x6ad060
leal 0x1(%rax), %esi
movl %esi, 0x65244e(%rip)    # 0x6ad060
movl %eax, (%rcx,%rdx,4)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: setzrange1
static void setzrange1 (int *lptr, int z0, int z1)
{
	int z, ze;
	if (!((z0^z1)&~31)) { lptr[z0>>5] |= (~(-(1<<SHIFTMOD32(z1))))&(-(1<<SHIFTMOD32(z0))); return; }
	z = (z0>>5); ze = (z1>>5);
	lptr[z] |= (-(1<<SHIFTMOD32(z0))); for(z++;z<ze;z++) lptr[z] = -1;
	lptr[z] |=~(-(1<<SHIFTMOD32(z1)));
}

// Assembly:
movl %edx, %r9d
xorl %esi, %r9d
pushq $-0x1
popq %rax
movl %eax, %r8d
movl %esi, %ecx
shll %cl, %r8d
cmpl $0x1f, %r9d
ja 0x5ac4c
movl %edx, %ecx
shll %cl, %eax
notl %eax
andl %eax, %r8d
sarl $0x5, %esi
movslq %esi, %rax
leaq (%rdi,%rax,4), %rsi
jmp 0x5ac83
sarl $0x5, %esi
movslq %esi, %rcx
leaq (%rdi,%rcx,4), %rsi
addq $0x4, %rsi
orl %r8d, -0x4(%rsi)
movl %edx, %r8d
sarl $0x5, %r8d
movslq %r8d, %r8
incq %rcx
cmpq %r8, %rcx
jge 0x5ac7a
orl $-0x1, (%rdi,%rcx,4)
addq $0x4, %rsi
jmp 0x5ac68
movl %edx, %ecx
shll %cl, %eax
notl %eax
movl %eax, %r8d
orl %r8d, (%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: cntquad
static void cntquad (int x0, int y0, int z0, int x1, int y1, int z1, int x2, int y2, int z2, int face)
{
	int x, y, z;
	(void)x1; (void)y1; (void)z1; (void)face;

	x = abs(x2-x0); y = abs(y2-y0); z = abs(z2-z0);
	if (!x) x = z; else if (!y) y = z;
	if (x < y) { z = x; x = y; y = z; }
	shcnt[y*shcntp+x]++;
	if (x > gmaxx) gmaxx = x;
	if (y > gmaxy) gmaxy = y;
	garea += (x+(VOXBORDWIDTH<<1))*(y+(VOXBORDWIDTH<<1));
	gvox->qcnt++;
}

// Assembly:
movl 0x18(%rsp), %eax
movl 0x10(%rsp), %ecx
movl %ecx, %r8d
subl %esi, %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
subl %edx, %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
cmpl %esi, %ecx
movl 0x8(%rsp), %ecx
movl %r9d, %esi
cmovel %edx, %esi
movl %ecx, %r8d
subl %edi, %r8d
cmovel %r9d, %esi
movl %r8d, %eax
negl %eax
cmovsl %r8d, %eax
cmpl %edi, %ecx
cmovel %edx, %eax
cmpl %esi, %eax
movl %esi, %ecx
cmoval %eax, %ecx
cmovael %esi, %eax
movq 0x6523e3(%rip), %rdx    # 0x6ad0c0
movl 0x6523d5(%rip), %esi    # 0x6ad0b8
imull %eax, %esi
addl %ecx, %esi
movslq %esi, %rsi
incl (%rdx,%rsi,4)
cmpl 0x6523dc(%rip), %ecx    # 0x6ad0d0
jle 0x5acfc
movl %ecx, 0x6523d4(%rip)    # 0x6ad0d0
cmpl 0x6523ca(%rip), %eax    # 0x6ad0cc
jle 0x5ad0a
movl %eax, 0x6523c2(%rip)    # 0x6ad0cc
addl $0x2, %ecx
addl $0x2, %eax
imull %ecx, %eax
addl %eax, 0x6523af(%rip)    # 0x6ad0c8
movq 0x652390(%rip), %rax    # 0x6ad0b0
incl 0x28(%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: isolid
static int isolid (int x, int y, int z)
{
	if ((unsigned int)x >= (unsigned int)xsiz) return(0);
	if ((unsigned int)y >= (unsigned int)ysiz) return(0);
	if ((unsigned int)z >= (unsigned int)zsiz) return(0);
	z += x*yzsiz + y*zsiz; return(vbit[z>>5]&(1<<SHIFTMOD32(z)));
}

// Assembly:
xorl %eax, %eax
cmpl %edi, 0x651be7(%rip)    # 0x6ad068
jbe 0x5b4ba
cmpl %esi, 0x651be3(%rip)    # 0x6ad06c
jbe 0x5b4ba
movl 0x651bdf(%rip), %ecx    # 0x6ad070
cmpl %edx, %ecx
jbe 0x5b4ba
imull 0x651c10(%rip), %edi    # 0x6ad0ac
imull %esi, %ecx
addl %edx, %ecx
addl %edi, %ecx
movq 0x651bde(%rip), %rdx    # 0x6ad088
movl %ecx, %esi
pushq $0x1
popq %rax
shll %cl, %eax
sarl $0x5, %esi
movslq %esi, %rcx
andl (%rdx,%rcx,4), %eax
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: isrectfree
static int isrectfree (int x0, int y0, int dx, int dy)
{
#if 0
	int i, j, x;
	i = y0*gvox->mytexx + x0;
	for(dy=0;dy;dy--,i+=gvox->mytexx)
		for(x=0;x<dx;x++) { j = i+x; if (zbit[j>>5]&(1<<SHIFTMOD32(j))) return(0); }
#else
	int i, c, m, m1, x;

	i = y0*mytexo5 + (x0>>5); dx += x0-1; c = (dx>>5) - (x0>>5);
	m = ~pow2m1[x0&31]; m1 = pow2m1[(dx&31)+1];
	if (!c) { for(m&=m1;dy;dy--,i+=mytexo5) if (zbit[i]&m) return(0); }
	else
	{  for(;dy;dy--,i+=mytexo5)
		{
			if (zbit[i]&m) return(0);
			for(x=1;x<c;x++) if (zbit[i+x]) return(0);
			if (zbit[i+x]&m1) return(0);
		}
	}
#endif
	return(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movslq 0x651ca4(%rip), %r8     # 0x6ad170
imull %r8d, %esi
movl %edi, %r9d
sarl $0x5, %r9d
addl %r9d, %esi
leal (%rdi,%rdx), %r10d
decl %r10d
movl %r10d, %eax
sarl $0x5, %eax
andl $0x1f, %edi
leaq 0x651bef(%rip), %r11    # 0x6ad0e0
movl (%r11,%rdi,4), %edx
notl %edx
andl $0x1f, %r10d
movl 0x4(%r11,%r10,4), %edi
subl %r9d, %eax
jne 0x5b535
movslq %esi, %rsi
shlq $0x2, %rsi
addq 0x651c65(%rip), %rsi    # 0x6ad178
shlq $0x2, %r8
movl $0x1, %eax
subl $0x1, %ecx
jb 0x5b5a5
movl (%rsi), %r9d
andl %edx, %r9d
testl %edi, %r9d
jne 0x5b5a3
addq %r8, %rsi
jmp 0x5b51c
movabsq $0x100000000, %r9       # imm = 0x100000000
movq 0x651c32(%rip), %r10    # 0x6ad178
movslq %eax, %r11
movslq %esi, %rsi
leaq (%r10,%rsi,4), %rbx
leaq (,%r8,4), %r14
movl $0x1, %ebp
movabsq $0x1, %r15
xorl %eax, %eax
subl $0x1, %ecx
jb 0x5b5b0
testl %edx, (%r10,%rsi,4)
jne 0x5b5a5
movq %r9, %r12
movq %r15, %r13
cmpq %r11, %r13
jge 0x5b58e
cmpl $0x0, (%rbx,%r13,4)
jne 0x5b5a5
incq %r13
addq %r9, %r12
jmp 0x5b57a
sarq $0x1e, %r12
addq %r10, %r12
testl %edi, (%r12,%rsi,4)
jne 0x5b5a5
addq %r8, %rsi
addq %r14, %rbx
jmp 0x5b569
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %eax
jmp 0x5b5a5
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PTM_InitIdent
void PTM_InitIdent(PTMIdent *id, PTHead *pth)
{
    memset(id, 0, sizeof(PTMIdent));

    if (!pth) {
        return;
    }

	if (pth->flags & PTH_HIGHTILE) {
        id->type = PTMIDENT_HIGHTILE;

		if (!pth->repldef) {
			if (polymosttexverbosity >= 1) {
				buildprintf("PolymostTex: cannot calculate texture id for pth with no repldef\n");
			}
			memset(id, 0, 16);
			return;
		}

		id->flags = pth->flags & (PTH_CLAMPED | PTH_SKYBOX);
		id->effects = (pth->palnum != pth->repldef->palnum)
            ? hictinting[pth->palnum].f : 0;
		if (pth->flags & PTH_SKYBOX) {
			// hightile + skybox + picnum ought to cover it
		    id->picnum = pth->picnum;
		} else {
		    strncpy(id->filename, pth->repldef->filename, BMAX_PATH);
		}
	} else {
		id->type = PTMIDENT_ART;
		id->flags = pth->flags & (PTH_CLAMPED);
		id->palnum = pth->palnum;
		id->picnum = pth->picnum;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl $0x418, %edx            # imm = 0x418
xorl %esi, %esi
callq 0x62f0
testq %r14, %r14
je 0x5b7a8
testb $0x2, 0x38(%r14)
jne 0x5b722
movzwl 0x38(%r14), %eax
andl $0x1, %eax
movl %eax, 0x4(%rbx)
movl 0x34(%r14), %eax
movl %eax, 0x8(%rbx)
jmp 0x5b782
movl $0x1, (%rbx)
cmpq $0x0, 0x40(%r14)
je 0x5b78b
movzwl 0x38(%r14), %eax
andl $0x5, %eax
movl %eax, 0x4(%rbx)
movslq 0x34(%r14), %rax
movq 0x40(%r14), %rcx
movzbl 0x8(%rcx), %edx
xorl %ecx, %ecx
cmpl %edx, %eax
je 0x5b758
leaq 0x5e64cd(%rip), %rcx    # 0x641c20
movzbl 0x3(%rcx,%rax,4), %ecx
movl %ecx, 0x14(%rbx)
testb $0x4, 0x38(%r14)
jne 0x5b782
addq $0x18, %rbx
movq 0x40(%r14), %rax
movq 0x10(%rax), %rsi
movl $0x400, %edx            # imm = 0x400
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x6190
movl 0x30(%r14), %eax
movl %eax, 0xc(%rbx)
jmp 0x5b7a8
cmpl $0x0, 0x42dfa(%rip)     # 0x9e58c
jle 0x5b7a2
leaq 0x157dd(%rip), %rdi     # 0x70f78
xorl %eax, %eax
callq 0x22427
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PTM_GetHead
PTMHead * PTM_GetHead(const PTMIdent *id)
{
	PTMHash * ptmh;
	int i;
    unsigned int idcrc;

    idcrc = crc32once((unsigned char *)id, sizeof(PTMIdent));

	i = ptm_gethashhead(idcrc);
	ptmh = ptmhashhead[i];

	while (ptmh) {
        if (ptmh->idcrc == idcrc &&
            memcmp(&ptmh->id, id, sizeof(PTMIdent)) == 0) {
			return &ptmh->head;
		}
		ptmh = ptmh->next;
	}

	ptmh = (PTMHash *) malloc(sizeof(PTMHash));
	if (ptmh) {
		memset(ptmh, 0, sizeof(PTMHash));

        ptmh->idcrc = idcrc;
		memcpy(&ptmh->id, id, sizeof(PTMIdent));
		ptmh->next = ptmhashhead[i];
		ptmhashhead[i] = ptmh;
	}

	return &ptmh->head;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x418, %esi            # imm = 0x418
callq 0x64918
movl %eax, %ebp
andl $0xfff, %eax            # imm = 0xFFF
leaq 0x6519ae(%rip), %rcx    # 0x6ad180
leaq (%rcx,%rax,8), %r15
movq %r15, %r14
movq (%r14), %r14
testq %r14, %r14
je 0x5b7fe
cmpl %ebp, 0x20(%r14)
jne 0x5b7d9
leaq 0x24(%r14), %rdi
movl $0x418, %edx            # imm = 0x418
movq %rbx, %rsi
callq 0x6720
testl %eax, %eax
jne 0x5b7d9
jmp 0x5b838
pushq $0x1
popq %rdi
movl $0x440, %esi            # imm = 0x440
callq 0x6930
testq %rax, %rax
je 0x5b835
movq %rax, %r14
movl %ebp, 0x20(%rax)
movq %rax, %rdi
addq $0x24, %rdi
movl $0x418, %edx            # imm = 0x418
movq %rbx, %rsi
callq 0x60c0
movq (%r15), %rax
movq %rax, (%r14)
movq %r14, (%r15)
jmp 0x5b838
xorl %r14d, %r14d
addq $0x8, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PTBeginPriming
void PTBeginPriming(void)
{
	PTHash * pth;
	int i;

	for (i=PTHASHHEADSIZ-1; i>=0; i--) {
		pth = pthashhead[i];
		while (pth) {
			pth->primecnt = 0;
			pth = pth->next;
		}
	}

	primecnt = 0;
	primedone = 0;
	primepos = 0;
}

// Assembly:
movl $0xfff, %eax            # imm = 0xFFF
leaq 0x658c2d(%rip), %rcx    # 0x6b5180
testl %eax, %eax
js 0x5c56f
movl %eax, %edx
leaq (%rcx,%rdx,8), %rdx
movq (%rdx), %rdx
testq %rdx, %rdx
je 0x5c56b
andl $0x0, 0x60(%rdx)
jmp 0x5c55d
decl %eax
jmp 0x5c553
andl $0x0, 0x660c0a(%rip)    # 0x6bd180
andl $0x0, 0x660c07(%rip)    # 0x6bd184
andl $0x0, 0x660c04(%rip)    # 0x6bd188
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PTMarkPrime
void PTMarkPrime(int picnum, int palnum, unsigned short flags)
{
	PTHash * pth;

	pth = pt_findhash(picnum, palnum, flags, 1);
	if (pth) {
		if (pth->primecnt == 0) {
			primecnt++;
		}
		pth->primecnt++;
	}
}

// Assembly:
pushq %rax
pushq $0x1
popq %rcx
callq 0x5c5a7
testq %rax, %rax
je 0x5c5a5
movl 0x60(%rax), %ecx
testl %ecx, %ecx
jne 0x5c5a0
incl 0x660be0(%rip)          # 0x6bd180
incl %ecx
movl %ecx, 0x60(%rax)
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PTDoPrime
int PTDoPrime(int* done, int* total)
{
	PTHash * pth;

	if (primepos >= PTHASHHEADSIZ) {
		// done
		return 0;
	}

	if (primepos == 0) {
		int i;

		// first, unload all the textures that are not marked
		for (i=PTHASHHEADSIZ-1; i>=0; i--) {
			pth = pthashhead[i];
			while (pth) {
				if (pth->primecnt == 0) {
					pt_unload(pth);
				}
				pth = pth->next;
			}
		}
	}

	pth = pthashhead[primepos];
	while (pth) {
		if (pth->primecnt > 0) {
			primedone++;
			pt_load(pth);
		}
		pth = pth->next;
	}

	*done = primedone;
	*total = primecnt;
	primepos++;

	return (primepos < PTHASHHEADSIZ);
}

// Assembly:
movl 0x660a9c(%rip), %ecx    # 0x6bd188
xorl %eax, %eax
cmpl $0xfff, %ecx            # imm = 0xFFF
jg 0x5c79e
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x658a71(%rip), %r12    # 0x6b5180
testl %ecx, %ecx
jne 0x5c745
movl $0xfff, %ebp            # imm = 0xFFF
testl %ebp, %ebp
js 0x5c73f
movl %ebp, %eax
leaq (%r12,%rax,8), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x5c73b
cmpl $0x0, 0x60(%r15)
jne 0x5c722
movq %r15, %rdi
callq 0x5c79f
jmp 0x5c722
decl %ebp
jmp 0x5c718
movl 0x660a43(%rip), %ecx    # 0x6bd188
movslq %ecx, %rax
leaq (%r12,%rax,8), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x5c76b
cmpl $0x0, 0x60(%r15)
jle 0x5c74c
incl 0x660a23(%rip)          # 0x6bd184
movq %r15, %rdi
callq 0x5c7ee
jmp 0x5c74c
movl 0x660a13(%rip), %eax    # 0x6bd184
movl %eax, (%r14)
movl 0x660a06(%rip), %eax    # 0x6bd180
movl %eax, (%rbx)
movl 0x660a06(%rip), %ecx    # 0x6bd188
leal 0x1(%rcx), %eax
movl %eax, 0x6609fd(%rip)    # 0x6bd188
xorl %eax, %eax
cmpl $0xfff, %ecx            # imm = 0xFFF
setl %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: pt_unload
static void pt_unload(PTHash * pth)
{
	int i;
	for (i = PTHPIC_SIZE - 1; i>=0; i--) {
		if (pth->head.pic[i] && pth->head.pic[i]->glpic) {
			glfunc.glDeleteTextures(1, &pth->head.pic[i]->glpic);
			pth->head.pic[i]->glpic = 0;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
pushq $0x5
popq %r14
leaq 0x596f8b(%rip), %r15    # 0x5f3740
pushq $0x1
popq %rbp
testl %r14d, %r14d
js 0x5c7e5
movl %r14d, %r12d
movq 0x8(%rbx,%r12,8), %rsi
testq %rsi, %rsi
je 0x5c7e0
cmpl $0x0, (%rsi)
je 0x5c7e0
movl %ebp, %edi
callq *0xc0(%r15)
movq 0x8(%rbx,%r12,8), %rax
andl $0x0, (%rax)
decl %r14d
jmp 0x5c7b8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: pt_load
static int pt_load(PTHash * pth)
{
	if (pth->head.pic[PTHPIC_BASE] &&
		pth->head.pic[PTHPIC_BASE]->glpic != 0 &&
		(pth->head.pic[PTHPIC_BASE]->flags & PTH_DIRTY) == 0) {
		return 1;	// loaded
	}

	if ((pth->head.flags & PTH_HIGHTILE)) {
		// try and load from a replacement
		if (pt_load_hightile(&pth->head)) {
			return 1;
		}

		// if that failed, get the hash for the ART version and
		//   defer this to there
		pth->deferto = pt_findhash(
				pth->head.picnum, pth->head.palnum,
				(pth->head.flags & ~PTH_HIGHTILE),
				1);
		if (!pth->deferto) {
			return 0;
		}
		return pt_load(pth->deferto);
	}

	if (pt_load_art(&pth->head)) {
		return 1;
	}

	// we're SOL
	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
pushq $0x1
popq %rbx
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x5c80c
cmpl $0x0, (%rax)
je 0x5c80c
testb $-0x80, 0x4(%rax)
je 0x5c845
leaq 0x8(%r14), %rdi
testb $0x2, 0x40(%r14)
je 0x5c84f
callq 0x5cf67
testl %eax, %eax
jne 0x5c845
movl 0x38(%r14), %edi
movl 0x3c(%r14), %esi
movzwl 0x40(%r14), %edx
andl $-0x3, %edx
movl %ebx, %ecx
callq 0x5c5a7
movq %rax, 0x58(%r14)
movq %rax, %r14
testq %rax, %rax
jne 0x5c7f8
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5d166
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PTReset
void PTReset(void)
{
	PTHash * pth;
	int i;

	for (i=PTHASHHEADSIZ-1; i>=0; i--) {
		pth = pthashhead[i];
		while (pth) {
			pt_unload(pth);
			pth = pth->next;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl $0xfff, %ebp            # imm = 0xFFF
leaq 0x658915(%rip), %r14    # 0x6b5180
testl %ebp, %ebp
js 0x5c88b
movl %ebp, %eax
leaq (%r14,%rax,8), %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x5c887
movq %rbx, %rdi
callq 0x5c79f
jmp 0x5c875
decl %ebp
jmp 0x5c86b
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PTClear
void PTClear(void)
{
	PTHash * pth, * next;
	PTMHash * ptmh, * mnext;
	int i;

	for (i=PTHASHHEADSIZ-1; i>=0; i--) {
		pth = pthashhead[i];
		while (pth) {
			next = pth->next;
			pt_unload(pth);
			free(pth);
			pth = next;
		}
		pthashhead[i] = 0;
	}

	for (i=PTMHASHHEADSIZ-1; i>=0; i--) {
		ptmh = ptmhashhead[i];
		while (ptmh) {
			mnext = ptmh->next;
			free(ptmh);
			ptmh = mnext;
		}
		ptmhashhead[i] = 0;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0xfff, %ebp            # imm = 0xFFF
leaq 0x6588dc(%rip), %r14    # 0x6b5180
testl %ebp, %ebp
js 0x5c8d5
movl %ebp, %r15d
movq (%r14,%r15,8), %rbx
testq %rbx, %rbx
je 0x5c8cc
movq (%rbx), %r12
movq %rbx, %rdi
callq 0x5c79f
movq %rbx, %rdi
callq 0x61c0
movq %r12, %rbx
jmp 0x5c8af
andq $0x0, (%r14,%r15,8)
decl %ebp
jmp 0x5c8a4
movl $0xfff, %ebx            # imm = 0xFFF
leaq 0x65089f(%rip), %r14    # 0x6ad180
testl %ebx, %ebx
js 0x5c907
movl %ebx, %r15d
movq (%r14,%r15,8), %rdi
testq %rdi, %rdi
je 0x5c8fe
movq (%rdi), %r12
callq 0x61c0
movq %r12, %rdi
jmp 0x5c8ec
andq $0x0, (%r14,%r15,8)
decl %ebx
jmp 0x5c8e1
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PT_GetHead
PTHead * PT_GetHead(int picnum, int palnum, unsigned short flags, int peek)
{
	PTHash * pth;

	pth = pt_findhash(picnum, palnum, flags, peek == 0);
	if (pth == 0) {
		return 0;
	}

	if (!pt_load(pth)) {
		return 0;
	}

	while (pth->deferto) {
		// this might happen if pt_load needs to defer to ART
		pth = pth->deferto;
	}

	return &pth->head;
}

// Assembly:
pushq %rbx
xorl %eax, %eax
testl %ecx, %ecx
sete %al
movl %eax, %ecx
callq 0x5c5a7
testq %rax, %rax
je 0x5c945
movq %rax, %rbx
movq %rax, %rdi
callq 0x5c7ee
testl %eax, %eax
je 0x5c945
movq %rbx, %rax
movq 0x58(%rbx), %rbx
testq %rbx, %rbx
jne 0x5c933
addq $0x8, %rax
jmp 0x5c947
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: PTIterNewMatch
PTIter PTIterNewMatch(int match, int picnum, int palnum, unsigned short flagsmask, unsigned short flags)
{
	PTIter iter;

	iter = (PTIter) malloc(sizeof(struct PTIter_typ));
	if (!iter) {
		return 0;
	}

	iter->i = 0;
	iter->pth = pthashhead[0];
	iter->match = match;
	iter->picnum = picnum;
	iter->palnum = palnum;
	iter->flagsmask = flagsmask;
	iter->flags = flags;

	if ((match & PTITER_PICNUM)) {
		iter->i = pt_gethashhead(picnum);
		iter->pth = pthashhead[iter->i];
		if (iter->pth == 0) {
			iter->pth = 0;
			return iter;
		}
	}

	ptiter_seekforward(iter);

	return iter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebp
movl %ecx, %r12d
movl %edx, %r13d
movl %esi, %r14d
movl %edi, %r15d
pushq $0x20
popq %rdi
callq 0x69a0
movq %rax, %rbx
testq %rax, %rax
je 0x5c9c2
andl $0x0, (%rbx)
movq 0x658803(%rip), %rax    # 0x6b5180
movq %rax, 0x8(%rbx)
movl %r15d, 0x10(%rbx)
movl %r14d, 0x14(%rbx)
movl %r13d, 0x18(%rbx)
movw %r12w, 0x1c(%rbx)
movw %bp, 0x1e(%rbx)
testb $0x1, %r15b
je 0x5c9ba
andl $0xfff, %r14d           # imm = 0xFFF
movl %r14d, (%rbx)
leaq 0x6587d3(%rip), %rax    # 0x6b5180
movq (%rax,%r14,8), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x5c9d4
movq %rbx, %rdi
callq 0x5c9db
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
andq $0x0, 0x8(%rbx)
jmp 0x5c9c2
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttex.c
// Function: ptiter_seekforward
static void ptiter_seekforward(PTIter iter)
{
	while (1) {
		if (iter->pth && ptiter_matches(iter)) {
			break;
		}
		if (iter->pth == 0) {
			if ((iter->match & PTITER_PICNUM)) {
				// because the hash key is based on picture number,
				// reaching the end of the hash chain means we need
				// not look further
				break;
			}
			iter->i++;
			if (iter->i >= PTHASHHEADSIZ) {
				// end of hash
				iter->pth = 0;
				iter->i = PTHASHHEADSIZ;
				break;
			}
			iter->pth = pthashhead[iter->i];
		} else {
			iter->pth = iter->pth->next;
		}
	}
}

// Assembly:
movq 0x8(%rdi), %rdx
movl 0x10(%rdi), %eax
leaq 0x658797(%rip), %rcx    # 0x6b5180
testq %rdx, %rdx
je 0x5ca1e
testl %eax, %eax
je 0x5ca41
testb $0x1, %al
je 0x5c9fe
movl 0x38(%rdx), %esi
cmpl 0x14(%rdi), %esi
jne 0x5ca38
testb $0x2, %al
je 0x5ca0a
movl 0x3c(%rdx), %esi
cmpl 0x18(%rdi), %esi
jne 0x5ca38
testb $0x4, %al
je 0x5ca41
movzwl 0x1c(%rdi), %esi
andw 0x40(%rdx), %si
cmpw 0x1e(%rdi), %si
jne 0x5ca38
jmp 0x5ca41
testb $0x1, %al
jne 0x5ca41
movslq (%rdi), %rsi
leaq 0x1(%rsi), %rdx
movl %edx, (%rdi)
cmpq $0xfff, %rsi            # imm = 0xFFF
jge 0x5ca42
leaq (%rcx,%rdx,8), %rdx
movq (%rdx), %rdx
movq %rdx, 0x8(%rdi)
jmp 0x5c9e9
retq
andq $0x0, 0x8(%rdi)
movl $0x1000, (%rdi)         # imm = 0x1000
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttexcache.c
// Function: PTCacheUnloadIndex
void PTCacheUnloadIndex(void)
{
	PTCacheIndex * pci, * next;
	int i;

	for (i = 0; i < PTCACHEHASHSIZ; i++) {
		pci = cachehead[i];
		while (pci) {
			next = pci->next;
			// we needn't free pci->filename since it was alloced with pci
			free(pci);
			pci = next;
		}
		cachehead[i] = 0;
	}

	buildprintf("PolymostTexCache: cache index unloaded\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
xorl %ebx, %ebx
leaq 0x65f796(%rip), %r14    # 0x6bd1a0
cmpq $0x200, %rbx            # imm = 0x200
je 0x5da34
movq (%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x5da2a
movq 0x18(%rdi), %r15
callq 0x61c0
movq %r15, %rdi
jmp 0x5da17
andq $0x0, (%r14,%rbx,8)
incq %rbx
jmp 0x5da0a
leaq 0x13852(%rip), %rdi     # 0x7128d
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x22427
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttexcache.c
// Function: ptcache_findhash
static PTCacheIndex * ptcache_findhash(const char * filename, int effects, int flags)
{
	PTCacheIndex * pci;

	pci = cachehead[ gethashhead(filename) ];
	if (!pci) {
		return 0;
	}

	flags &= PTH_CLAMPED;

	while (pci) {
		if (effects == pci->effects &&
		    flags == pci->flags &&
		    strcmp(pci->filename, filename) == 0) {
			return pci;
		}
		pci = pci->next;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r15
callq 0x5e21f
movl %eax, %eax
leaq 0x65f73d(%rip), %rcx    # 0x6bd1a0
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x5da95
andl $0x1, %ebx
testq %r14, %r14
je 0x5da95
cmpl %ebp, 0x8(%r14)
jne 0x5da8f
cmpl 0xc(%r14), %ebx
jne 0x5da8f
movq (%r14), %rdi
movq %r15, %rsi
callq 0x68d0
testl %eax, %eax
je 0x5da98
movq 0x18(%r14), %r14
jmp 0x5da6f
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttexcache.c
// Function: ptcache_addhash
static void ptcache_addhash(const char * filename, int effects, int flags, unsigned offset)
{
	unsigned int hash = gethashhead(filename);

	// to reduce memory fragmentation we tack the filename onto the end of the block
	PTCacheIndex * pci = (PTCacheIndex *) malloc(sizeof(PTCacheIndex) + strlen(filename) + 1);

	pci->filename = (char *) pci + sizeof(PTCacheIndex);
	strcpy(pci->filename, filename);
	pci->effects = effects;
	pci->flags   = flags & (PTH_CLAMPED);
	pci->offset  = offset;
	pci->next = cachehead[hash];

	cachehead[hash] = pci;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
callq 0x5e21f
movl %eax, %r12d
movq %r15, %rdi
callq 0x6420
leaq 0x21(%rax), %rdi
callq 0x69a0
movq %rax, %r13
leaq 0x20(%rax), %rdi
movq %rdi, (%rax)
movq %r15, %rsi
callq 0x6430
movl %r14d, 0x8(%r13)
andl $0x1, %ebp
movl %ebp, 0xc(%r13)
movl %ebx, 0x10(%r13)
movl %r12d, %eax
leaq 0x65f6a1(%rip), %rcx    # 0x6bd1a0
movq (%rcx,%rax,8), %rdx
movq %rdx, 0x18(%r13)
movq %r13, (%rcx,%rax,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttexcache.c
// Function: PTCacheFreeTile
void PTCacheFreeTile(PTCacheTile * tdef)
{
	int i;

	if (tdef->filename) {
		free(tdef->filename);
	}
	for (i = 0; i < tdef->nummipmaps; i++) {
		if (tdef->mipmap[i].data) {
			free(tdef->mipmap[i].data);
		}
	}
	free(tdef);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x61c0
leaq 0x30(%rbx), %r14
xorl %r15d, %r15d
movslq 0x1c(%rbx), %rax
cmpq %rax, %r15
jge 0x5ddeb
movq (%r14), %rdi
callq 0x61c0
incq %r15
addq $0x18, %r14
jmp 0x5ddd1
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x61c0
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttexcache.c
// Function: PTCacheAllocNewTile
PTCacheTile * PTCacheAllocNewTile(int nummipmaps)
{
	int size = sizeof(PTCacheTile) + (nummipmaps-1) * sizeof(PTCacheTileMip);
	PTCacheTile * tdef;

	tdef = (PTCacheTile *) malloc(size);
	memset(tdef, 0, size);

	tdef->nummipmaps = nummipmaps;

	return tdef;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
imull $0x18, %edi, %eax
addl $0x20, %eax
movslq %eax, %rsi
pushq $0x1
popq %rdi
callq 0x6930
movl %ebx, 0x1c(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymosttexcompress.cc
// Function: ptcompress_getstorage
int ptcompress_getstorage(int width, int height, int format)
{
	switch (format) {
		case PTCOMPRESS_DXT1:
		case PTCOMPRESS_DXT5:
			return squish::GetStorageRequirements(width, height, getsquishflags(format));
		case PTCOMPRESS_ETC1:
			return 8 * ((width + 3) / 4) * ((height + 3) / 4);
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %ebp
leal -0x1(%rdx), %eax
cmpl $0x2, %eax
jae 0x5e263
movl %edx, %edi
callq 0x5e28c
movl %ebp, %edi
movl %ebx, %esi
movl %eax, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x6187c
xorl %eax, %eax
cmpl $0x3, %edx
jne 0x5e285
addl $0x3, %ebp
pushq $0x4
popq %rsi
movl %ebp, %eax
cltd
idivl %esi
movl %eax, %ecx
addl $0x3, %ebx
movl %ebx, %eax
cltd
idivl %esi
imull %ecx, %eax
shll $0x3, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::pack_color5(unsigned int, unsigned int, unsigned int, bool, unsigned int)
uint16 etc1_block::pack_color5(uint r, uint g, uint b, bool scaled, uint bias)
   {
      if (scaled)
      {
         r = (r * 31U + bias) / 255U;
         g = (g * 31U + bias) / 255U;
         b = (b * 31U + bias) / 255U;
      }

      r = rg_etc1::minimum(r, 31U);
      g = rg_etc1::minimum(g, 31U);
      b = rg_etc1::minimum(b, 31U);

      return static_cast<uint16>(b | (g << 5U) | (r << 10U));
   }

// Assembly:
movl %edx, %r9d
testl %ecx, %ecx
je 0x5e55e
imull $0x1f, %edi, %eax
addl %r8d, %eax
movl $0xff, %r10d
xorl %edx, %edx
divl %r10d
imull $0x1f, %esi, %ecx
addl %r8d, %ecx
movl %eax, %edi
movl %ecx, %eax
xorl %edx, %edx
divl %r10d
imull $0x1f, %r9d, %ecx
addl %r8d, %ecx
movl %eax, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %r10d
movl %eax, %r9d
pushq $0x1f
popq %rax
cmpl %eax, %edi
cmovael %eax, %edi
cmpl %eax, %esi
cmovael %eax, %esi
cmpl %eax, %r9d
cmovbl %r9d, %eax
shll $0x5, %esi
orl %eax, %esi
shll $0xa, %edi
orl %esi, %edi
movl %edi, %eax
retq
nop
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::unpack_color5(unsigned short, bool, unsigned int)
color_quad_u8 etc1_block::unpack_color5(uint16 packed_color5, bool scaled, uint alpha)
   {
      uint b = packed_color5 & 31U;
      uint g = (packed_color5 >> 5U) & 31U;
      uint r = (packed_color5 >> 10U) & 31U;

      if (scaled)
      {
         b = (b << 3U) | (b >> 2U);
         g = (g << 3U) | (g >> 2U);
         r = (r << 3U) | (r >> 2U);
      }

      return color_quad_u8(cNoClamp, r, g, b, rg_etc1::minimum(alpha, 255U));
   }

// Assembly:
pushq %rbx
movl %edx, %r8d
movq %rdi, %rbx
movl %esi, %eax
andl $0x1f, %eax
movl %esi, %edx
shrl $0x5, %edx
andl $0x1f, %edx
shrl $0xa, %esi
andl $0x1f, %esi
testl %r8d, %r8d
je 0x5e5b7
movl %eax, %edi
shrl $0x2, %edi
leal (%rdi,%rax,8), %eax
movl %edx, %edi
shrl $0x2, %edi
leal (%rdi,%rdx,8), %edx
movl %esi, %edi
shrl $0x2, %edi
leal (%rdi,%rsi,8), %esi
movl $0xff, %r8d
cmpl %r8d, %ecx
cmovbl %ecx, %r8d
movq %rbx, %rdi
movl %eax, %ecx
callq 0x60fc2
movq %rbx, %rax
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::unpack_color5(unsigned int&, unsigned int&, unsigned int&, unsigned short, bool)
void etc1_block::unpack_color5(uint& r, uint& g, uint& b, uint16 packed_color5, bool scaled)
   {
      color_quad_u8 c(unpack_color5(packed_color5, scaled, 0));
      r = c.r;
      g = c.g;
      b = c.b;
   }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x4(%rsp), %r12
movq %r12, %rdi
movl %ecx, %esi
movl %r8d, %edx
xorl %ecx, %ecx
callq 0x5e580
movzbl (%r12), %eax
movl %eax, (%r15)
movzbl 0x1(%r12), %eax
movl %eax, (%r14)
movzbl 0x2(%r12), %eax
movl %eax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::unpack_color5(rg_etc1::color_quad_u8&, unsigned short, unsigned short, bool, unsigned int)
bool etc1_block::unpack_color5(color_quad_u8& result, uint16 packed_color5, uint16 packed_delta3, bool scaled, uint alpha)
   {
      int dc_r, dc_g, dc_b;
      unpack_delta3(dc_r, dc_g, dc_b, packed_delta3);
      
      int b = (packed_color5 & 31U) + dc_b;
      int g = ((packed_color5 >> 5U) & 31U) + dc_g;
      int r = ((packed_color5 >> 10U) & 31U) + dc_r;

      bool success = true;
      if (static_cast<uint>(r | g | b) > 31U)
      {
         success = false;
         r = rg_etc1::clamp<int>(r, 0, 31);
         g = rg_etc1::clamp<int>(g, 0, 31);
         b = rg_etc1::clamp<int>(b, 0, 31);
      }

      if (scaled)
      {
         b = (b << 3U) | (b >> 2U);
         g = (g << 3U) | (g >> 2U);
         r = (r << 3U) | (r >> 2U);
      }

      result.set_noclamp_rgba(r, g, b, rg_etc1::minimum(alpha, 255U));
      return success;
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %ebx
movl %ecx, %ebp
movl %edx, %ecx
movl %esi, %r14d
movq %rdi, (%rsp)
leaq 0x14(%rsp), %r12
leaq 0x10(%rsp), %r13
leaq 0xc(%rsp), %r15
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x5e70c
movl %r14d, %ecx
andl $0x1f, %ecx
addl (%r15), %ecx
movl %r14d, %edx
shrl $0x5, %edx
andl $0x1f, %edx
addl (%r13), %edx
shrl $0xa, %r14d
andl $0x1f, %r14d
addl (%r12), %r14d
movl %edx, %eax
orl %ecx, %eax
orl %r14d, %eax
cmpl $0x20, %eax
jb 0x5e6ae
pushq $0x1f
popq %rsi
cmpl %esi, %r14d
cmovgel %esi, %r14d
xorl %edi, %edi
testl %r14d, %r14d
cmovlel %edi, %r14d
cmpl %esi, %edx
cmovgel %esi, %edx
testl %edx, %edx
cmovlel %edi, %edx
cmpl %esi, %ecx
cmovll %ecx, %esi
testl %esi, %esi
cmovlel %edi, %esi
movl %esi, %ecx
testb %bpl, %bpl
je 0x5e6da
leal (,%rcx,8), %esi
shrl $0x2, %ecx
orl %esi, %ecx
leal (,%rdx,8), %esi
sarl $0x2, %edx
orl %esi, %edx
leal (,%r14,8), %esi
shrl $0x2, %r14d
orl %esi, %r14d
cmpl $0x20, %eax
setb %bpl
movl $0xff, %r8d
cmpl %r8d, %ebx
cmovbl %ebx, %r8d
movq (%rsp), %rdi
movl %r14d, %esi
callq 0x60fc2
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::unpack_delta3(int&, int&, int&, unsigned short)
void etc1_block::unpack_delta3(int& r, int& g, int& b, uint16 packed_delta3)
   {
      r = (packed_delta3 >> 6) & 7;
      g = (packed_delta3 >> 3) & 7;
      b = packed_delta3 & 7;
      if (r >= 4) r -= 8;
      if (g >= 4) g -= 8;
      if (b >= 4) b -= 8;
   }

// Assembly:
movl %ecx, %eax
shrl $0x6, %eax
andl $0x7, %eax
movl %eax, (%rdi)
movl %ecx, %eax
shrl $0x3, %eax
andl $0x7, %eax
movl %eax, (%rsi)
andl $0x7, %ecx
movl %ecx, (%rdx)
movl (%rdi), %eax
cmpl $0x4, %eax
jl 0x5e731
addl $-0x8, %eax
movl %eax, (%rdi)
movl (%rsi), %eax
cmpl $0x4, %eax
jl 0x5e73d
addl $-0x8, %eax
movl %eax, (%rsi)
movl (%rdx), %eax
cmpl $0x4, %eax
jl 0x5e749
addl $-0x8, %eax
movl %eax, (%rdx)
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::pack_delta3(int, int, int)
uint16 etc1_block::pack_delta3(int r, int g, int b)
   {
      RG_ETC1_ASSERT((r >= cETC1ColorDeltaMin) && (r <= cETC1ColorDeltaMax));
      RG_ETC1_ASSERT((g >= cETC1ColorDeltaMin) && (g <= cETC1ColorDeltaMax));
      RG_ETC1_ASSERT((b >= cETC1ColorDeltaMin) && (b <= cETC1ColorDeltaMax));
      if (r < 0) r += 8;
      if (g < 0) g += 8;
      if (b < 0) b += 8;
      return static_cast<uint16>(b | (g << 3) | (r << 6));
   }

// Assembly:
pushq %rax
leal 0x4(%rdi), %eax
cmpl $0x8, %eax
jae 0x5e7d9
leal 0x4(%rsi), %eax
cmpl $0x8, %eax
jae 0x5e7f8
leal 0x4(%rdx), %eax
cmpl $0x8, %eax
jae 0x5e817
movl %edi, %eax
shrl $0x1f, %eax
leal (%rdi,%rax,8), %eax
movl %esi, %ecx
shrl $0x1f, %ecx
leal (%rsi,%rcx,8), %ecx
movl %edx, %esi
shrl $0x1f, %esi
leal (%rdx,%rsi,8), %edx
shll $0x3, %ecx
shll $0x6, %eax
orl %ecx, %eax
orl %edx, %eax
popq %rcx
retq
leaq 0x12c18(%rip), %rdi     # 0x713f8
leaq 0x12c48(%rip), %rsi     # 0x7142f
leaq 0x12c51(%rip), %rcx     # 0x7143f
movl $0x3fc, %edx            # imm = 0x3FC
callq 0x61b0
leaq 0x12c7e(%rip), %rdi     # 0x7147d
leaq 0x12c29(%rip), %rsi     # 0x7142f
leaq 0x12c32(%rip), %rcx     # 0x7143f
movl $0x3fd, %edx            # imm = 0x3FD
callq 0x61b0
leaq 0x12c96(%rip), %rdi     # 0x714b4
leaq 0x12c0a(%rip), %rsi     # 0x7142f
leaq 0x12c13(%rip), %rcx     # 0x7143f
movl $0x3fe, %edx            # imm = 0x3FE
callq 0x61b0
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::pack_color4(unsigned int, unsigned int, unsigned int, bool, unsigned int)
uint16 etc1_block::pack_color4(uint r, uint g, uint b, bool scaled, uint bias)
   {
      if (scaled)
      {
         r = (r * 15U + bias) / 255U;
         g = (g * 15U + bias) / 255U;
         b = (b * 15U + bias) / 255U;
      }

      r = rg_etc1::minimum(r, 15U);
      g = rg_etc1::minimum(g, 15U);
      b = rg_etc1::minimum(b, 15U);

      return static_cast<uint16>(b | (g << 4U) | (r << 8U));
   }

// Assembly:
movl %edx, %r9d
testl %ecx, %ecx
je 0x5e888
imull $0xf, %edi, %eax
addl %r8d, %eax
movl $0xff, %r10d
xorl %edx, %edx
divl %r10d
imull $0xf, %esi, %ecx
addl %r8d, %ecx
movl %eax, %edi
movl %ecx, %eax
xorl %edx, %edx
divl %r10d
imull $0xf, %r9d, %ecx
addl %r8d, %ecx
movl %eax, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %r10d
movl %eax, %r9d
pushq $0xf
popq %rax
cmpl %eax, %edi
cmovael %eax, %edi
cmpl %eax, %esi
cmovael %eax, %esi
cmpl %eax, %r9d
cmovbl %r9d, %eax
shll $0x4, %esi
orl %eax, %esi
shll $0x8, %edi
orl %esi, %edi
movl %edi, %eax
retq
nop
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::unpack_color4(unsigned short, bool, unsigned int)
color_quad_u8 etc1_block::unpack_color4(uint16 packed_color4, bool scaled, uint alpha)
   {
      uint b = packed_color4 & 15U;
      uint g = (packed_color4 >> 4U) & 15U;
      uint r = (packed_color4 >> 8U) & 15U;

      if (scaled)
      {
         b = (b << 4U) | b;
         g = (g << 4U) | g;
         r = (r << 4U) | r;
      }

      return color_quad_u8(cNoClamp, r, g, b, rg_etc1::minimum(alpha, 255U));
   }

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl %esi, %edi
andl $0xf, %edi
movl %esi, %r8d
shrl $0x4, %r8d
andl $0xf, %r8d
shrl $0x8, %esi
andl $0xf, %esi
imull $0x11, %edi, %eax
imull $0x11, %r8d, %r9d
imull $0x11, %esi, %r10d
testl %edx, %edx
cmovel %edi, %eax
cmovel %r8d, %r9d
cmovnel %r10d, %esi
movl $0xff, %r8d
cmpl %r8d, %ecx
cmovbl %ecx, %r8d
movq %rbx, %rdi
movl %r9d, %edx
movl %eax, %ecx
callq 0x60fc2
movq %rbx, %rax
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::color_quad_u8::set_noclamp_rgba(int, int, int, int)
inline color_quad_u8& set_noclamp_rgba(parameter_t red, parameter_t green, parameter_t blue, parameter_t alpha)
      {
         RG_ETC1_ASSERT( (red >= component_traits::cMin) && (red <= component_traits::cMax) );
         RG_ETC1_ASSERT( (green >= component_traits::cMin) && (green <= component_traits::cMax) );
         RG_ETC1_ASSERT( (blue >= component_traits::cMin) && (blue <= component_traits::cMax) );
         RG_ETC1_ASSERT( (alpha >= component_traits::cMin) && (alpha <= component_traits::cMax) );

         r = static_cast<component_t>(red);
         g = static_cast<component_t>(green);
         b = static_cast<component_t>(blue);
         a = static_cast<component_t>(alpha);
         return *this;
      }

// Assembly:
pushq %rax
cmpl $0x100, %esi            # imm = 0x100
jae 0x60ff6
cmpl $0x100, %edx            # imm = 0x100
jae 0x61015
cmpl $0x100, %ecx            # imm = 0x100
jae 0x61034
cmpl $0x100, %r8d            # imm = 0x100
jae 0x61053
movb %sil, (%rdi)
movb %dl, 0x1(%rdi)
movb %cl, 0x2(%rdi)
movb %r8b, 0x3(%rdi)
movq %rdi, %rax
popq %rcx
retq
leaq 0x1078a(%rip), %rdi     # 0x71787
leaq 0x1042b(%rip), %rsi     # 0x7142f
leaq 0x107bf(%rip), %rcx     # 0x717ca
movl $0xb3, %edx
callq 0x61b0
leaq 0x1081a(%rip), %rdi     # 0x71836
leaq 0x1040c(%rip), %rsi     # 0x7142f
leaq 0x107a0(%rip), %rcx     # 0x717ca
movl $0xb4, %edx
callq 0x61b0
leaq 0x10842(%rip), %rdi     # 0x7187d
leaq 0x103ed(%rip), %rsi     # 0x7142f
leaq 0x10781(%rip), %rcx     # 0x717ca
movl $0xb5, %edx
callq 0x61b0
leaq 0x10868(%rip), %rdi     # 0x718c2
leaq 0x103ce(%rip), %rsi     # 0x7142f
leaq 0x10762(%rip), %rcx     # 0x717ca
movl $0xb6, %edx
callq 0x61b0
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::get_base4_color(unsigned int) const
inline uint get_byte_bits(uint ofs, uint num) const
      {
         RG_ETC1_ASSERT((ofs + num) <= 64U);
         RG_ETC1_ASSERT(num && (num <= 8U));
         RG_ETC1_ASSERT((ofs >> 3) == ((ofs + num - 1) >> 3));
         const uint byte_ofs = 7 - (ofs >> 3);
         const uint byte_bit_ofs = ofs & 7;
         return (m_bytes[byte_ofs] >> byte_bit_ofs) & ((1 << num) - 1);
      }

// Assembly:
movb (%rdi), %al
movb 0x1(%rdi), %cl
movb 0x2(%rdi), %dl
testl %esi, %esi
je 0x610dc
andb $0xf, %al
andb $0xf, %cl
andb $0xf, %dl
jmp 0x610e5
shrb $0x4, %al
shrb $0x4, %cl
shrb $0x4, %dl
movzbl %al, %eax
shlb $0x4, %cl
orb %dl, %cl
movzbl %cl, %ecx
shll $0x8, %eax
orl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::get_selector(unsigned int, unsigned int) const
inline uint get_selector(uint x, uint y) const
      {
         RG_ETC1_ASSERT((x | y) < 4);

         const uint bit_index = x * 4 + y;
         const uint byte_bit_ofs = bit_index & 7;
         const uint8 *p = &m_bytes[7 - (bit_index >> 3)];
         const uint lsb = (p[0] >> byte_bit_ofs) & 1;
         const uint msb = (p[-2] >> byte_bit_ofs) & 1;
         const uint val = lsb | (msb << 1);

         return g_etc1_to_selector_index[val];
      }

// Assembly:
movl %edx, %eax
orl %esi, %eax
cmpl $0x4, %eax
jae 0x61130
movl %esi, %eax
andl $0x1, %eax
leal (%rdx,%rax,4), %ecx
shrl %esi
subq %rsi, %rdi
movzbl 0x7(%rdi), %eax
xorl %edx, %edx
btl %ecx, %eax
setb %dl
movzbl 0x5(%rdi), %eax
shrl %cl, %eax
andl $0x1, %eax
leal (%rdx,%rax,2), %eax
leaq 0x10823(%rip), %rcx     # 0x7194e
movzbl (%rax,%rcx), %eax
retq
pushq %rax
leaq 0x107d1(%rip), %rdi     # 0x71909
leaq 0x102f0(%rip), %rsi     # 0x7142f
leaq 0x107cf(%rip), %rcx     # 0x71915
movl $0x260, %edx            # imm = 0x260
callq 0x61b0
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_solution_coordinates::get_scaled_color() const
inline color_quad_u8 get_scaled_color() const
      {
         int br, bg, bb;
         if (m_color4)
         {
            br = m_unscaled_color.r | (m_unscaled_color.r << 4);
            bg = m_unscaled_color.g | (m_unscaled_color.g << 4);
            bb = m_unscaled_color.b | (m_unscaled_color.b << 4);
         }
         else
         {
            br = (m_unscaled_color.r >> 2) | (m_unscaled_color.r << 3);
            bg = (m_unscaled_color.g >> 2) | (m_unscaled_color.g << 3);
            bb = (m_unscaled_color.b >> 2) | (m_unscaled_color.b << 3);
         }
         return color_quad_u8(br, bg, bb);
      }

// Assembly:
movq %rdi, %rax
movzbl (%rsi), %r8d
cmpb $0x1, 0x8(%rsi)
jne 0x6117e
movl %r8d, %edi
shll $0x4, %edi
orl %r8d, %edi
movzbl 0x1(%rsi), %edx
movl %edx, %ecx
shll $0x4, %ecx
orl %edx, %ecx
movzbl 0x2(%rsi), %esi
movl %esi, %edx
shll $0x4, %edx
orl %esi, %edx
jmp 0x611aa
movl %r8d, %ecx
shrl $0x2, %ecx
shll $0x3, %r8d
orl %ecx, %r8d
movzbl 0x1(%rsi), %ecx
movl %ecx, %edx
shrl $0x2, %edx
shll $0x3, %ecx
orl %edx, %ecx
movzbl 0x2(%rsi), %edx
movl %edx, %esi
shrl $0x2, %esi
shll $0x3, %edx
orl %esi, %edx
movl %r8d, %edi
movl $0xff, %esi
cmpl %esi, %edi
cmovael %esi, %edi
cmpl %esi, %ecx
cmovael %esi, %ecx
movb %dil, (%rax)
cmpl %esi, %edx
cmovbl %edx, %esi
movb %cl, 0x1(%rax)
movb %sil, 0x2(%rax)
movb $-0x1, 0x3(%rax)
retq
nop
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/libsquish/squish.cpp
// Function: squish::FixFlags(int)
static int FixFlags( int flags )
{
    // grab the flag bits
    int method = flags & ( kDxt1 | kDxt3 | kDxt5 | kBc4 | kBc5 );
    int fit = flags & ( kColourIterativeClusterFit | kColourClusterFit | kColourRangeFit );
    int extra = flags & (kWeightColourByAlpha | kSourceBGRA);   //JonoF

    // set defaults
    if ( method != kDxt3
    &&   method != kDxt5
    &&   method != kBc4
    &&   method != kBc5 )
    {
        method = kDxt1;
    }
    if( fit != kColourRangeFit && fit != kColourIterativeClusterFit )
        fit = kColourClusterFit;

    // done
    return method | fit | extra;
}

// Assembly:
movl %edi, %eax
andl $0x1f, %eax
movl %edi, %ecx
andl $0x160, %ecx            # imm = 0x160
andl $0x280, %edi            # imm = 0x280
movd %eax, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pcmpeqd 0x11d32(%rip), %xmm0    # 0x73530
movmskps %xmm0, %edx
testl %edx, %edx
pushq $0x1
popq %rdx
cmovnel %eax, %edx
cmpl $0x100, %ecx            # imm = 0x100
pushq $0x20
popq %rax
cmovel %ecx, %eax
cmpl $0x40, %ecx
cmovel %ecx, %eax
orl %edi, %eax
orl %edx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/libsquish/squish.cpp
// Function: squish::Decompress(unsigned char*, void const*, int)
void Decompress( u8* rgba, void const* block, int flags )
{
    // fix any bad flags
    flags = FixFlags( flags );

    // get the block locations
    void const* colourBlock = block;
    void const* alphaBlock = block;
    if( ( flags & ( kDxt3 | kDxt5 ) ) != 0 )
        colourBlock = reinterpret_cast< u8 const* >( block ) + 8;

    // decompress colour
    DecompressColour( rgba, colourBlock, ( flags & kDxt1 ) != 0 );

    // decompress alpha separately if necessary
    if( ( flags & kDxt3 ) != 0 )
        DecompressAlphaDxt3( rgba, alphaBlock );
    else if( ( flags & kDxt5 ) != 0 )
        DecompressAlphaDxt5( rgba, alphaBlock );
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl %edx, %edi
callq 0x617da
movl %eax, %ebp
xorl %eax, %eax
testb $0x6, %bpl
setne %al
leaq (%rbx,%rax,8), %rsi
movl %ebp, %edx
andl $0x1, %edx
movq %r14, %rdi
callq 0x66525
testb $0x2, %bpl
jne 0x6185e
testb $0x4, %bpl
jne 0x6186d
popq %rbx
popq %r14
popq %rbp
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x64a19
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x64d0c