LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/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 0x654db
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
testq %rdi, %rdi
je 0x65426
movq 0x10(%rdi), %r14
callq 0x61c0
movq %r14, %rdi
testq %r14, %r14
jne 0x65415
movq 0x48(%rbx), %r14
testq %r14, %r14
je 0x6544c
movq 0x10(%r14), %rdi
movq 0x38(%r14), %r15
callq 0x61c0
movq %r14, %rdi
callq 0x61c0
movq %r15, %r14
testq %r15, %r15
jne 0x6542f
movq 0xc8(%rbx), %rdi
testq %rdi, %rdi
je 0x6549e
movslq 0xac(%rbx), %r14
testq %r14, %r14
jle 0x65499
leaq 0x1(%r14), %r15
shlq $0x7, %r14
addq $-0x28, %r14
movq 0xc8(%rbx), %rax
movq (%rax,%r14), %rdi
testq %rdi, %rdi
je 0x65485
callq 0x61c0
decq %r15
addq $-0x80, %r14
cmpq $0x1, %r15
ja 0x65470
movq 0xc8(%rbx), %rdi
callq 0x61c0
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x654af
callq 0x61c0
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x654c0
callq 0x61c0
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x654ce
callq 0x61c0
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x61c0
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x64eb6d(%rip), %ecx    # 0x6b4060
movl 0x64eb6b(%rip), %edx    # 0x6b4064
movq 0x64eb90(%rip), %rax    # 0x6b4090
cmpl %edx, %ecx
jl 0x65537
addl %edx, %edx
cmpl $0x1001, %edx           # imm = 0x1001
movl $0x1000, %ecx           # imm = 0x1000
cmovgel %edx, %ecx
movl %ecx, 0x64eb4a(%rip)    # 0x6b4064
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0x6120
movq %rax, 0x64eb5f(%rip)    # 0x6b4090
movl 0x64eb29(%rip), %ecx    # 0x6b4060
imull 0x64eb6e(%rip), %ebp    # 0x6b40ac
imull 0x64eb2a(%rip), %r14d   # 0x6b4070
addl %r15d, %ebp
addl %r14d, %ebp
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movl %ebp, (%rax,%rcx,4)
movslq %ebp, %rcx
imulq $0x343fd, %rcx, %rcx    # imm = 0x343FD
movslq 0x64eb41(%rip), %rdx    # 0x6b40a8
andq %rcx, %rdx
movslq 0x64eaef(%rip), %rcx    # 0x6b4060
leaq (%rcx,%rcx,2), %rcx
movl %ebx, 0x4(%rax,%rcx,4)
movq 0x64eb18(%rip), %rcx    # 0x6b4098
movl (%rcx,%rdx,4), %esi
movslq 0x64ead6(%rip), %rdi    # 0x6b4060
leaq (%rdi,%rdi,2), %rdi
movl %esi, 0x8(%rax,%rdi,4)
movl 0x64eac8(%rip), %eax    # 0x6b4060
leal 0x1(%rax), %esi
movl %esi, 0x64eabf(%rip)    # 0x6b4060
movl %eax, (%rcx,%rdx,4)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rdi, %rbx
movl %edx, %edi
xorl %esi, %edi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %esi, %ecx
shll %cl, %eax
cmpl $0x1f, %edi
ja 0x655dc
movl %ebp, %ecx
shll %cl, %edx
notl %edx
andl %edx, %eax
sarl $0x5, %esi
jmp 0x65624
sarl $0x5, %esi
movslq %esi, %rcx
orl %eax, (%rbx,%rcx,4)
movl %ebp, %r14d
sarl $0x5, %r14d
leal 0x1(%rcx), %esi
cmpl %r14d, %esi
jge 0x65619
leaq (%rbx,%rcx,4), %rdi
addq $0x4, %rdi
movl %r14d, %eax
subl %ecx, %eax
addl $-0x2, %eax
leaq 0x4(,%rax,4), %rdx
movl $0xff, %esi
callq 0x62f0
movl %r14d, %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %ebp, %ecx
shll %cl, %eax
notl %eax
movslq %esi, %rcx
orl %eax, (%rbx,%rcx,4)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x64ea3b(%rip), %rdx    # 0x6b40c0
movl 0x64ea2d(%rip), %esi    # 0x6b40b8
imull %eax, %esi
addl %ecx, %esi
movslq %esi, %rsi
incl (%rdx,%rsi,4)
cmpl 0x64ea34(%rip), %ecx    # 0x6b40d0
jle 0x656a4
movl %ecx, 0x64ea2c(%rip)    # 0x6b40d0
cmpl 0x64ea22(%rip), %eax    # 0x6b40cc
jle 0x656b2
movl %eax, 0x64ea1a(%rip)    # 0x6b40cc
addl $0x2, %ecx
addl $0x2, %eax
imull %ecx, %eax
addl %eax, 0x64ea07(%rip)    # 0x6b40c8
movq 0x64e9e8(%rip), %rax    # 0x6b40b0
incl 0x28(%rax)
retq
// File: /workspace/github_c_makefile_star2_O3/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, 0x64e265(%rip)    # 0x6b4068
jbe 0x65e3e
cmpl %esi, 0x64e261(%rip)    # 0x6b406c
jbe 0x65e3e
movl 0x64e25d(%rip), %ecx    # 0x6b4070
cmpl %edx, %ecx
jbe 0x65e3e
imull 0x64e28e(%rip), %edi    # 0x6b40ac
imull %esi, %ecx
addl %edx, %ecx
addl %edi, %ecx
movq 0x64e25c(%rip), %rdx    # 0x6b4088
movl %ecx, %esi
movl $0x1, %eax
shll %cl, %eax
sarl $0x5, %esi
movslq %esi, %rcx
andl (%rdx,%rcx,4), %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %eax
leal (%rdi,%rdx), %r8d
decl %r8d
movl %r8d, %r9d
andl $0x1f, %edi
andl $0x1f, %r8d
leaq 0x64e280(%rip), %r10    # 0x6b40e0
movl (%r10,%rdi,4), %edx
movl 0x4(%r10,%r8,4), %edi
movslq 0x64e300(%rip), %r8     # 0x6b4170
imull %r8d, %esi
sarl $0x5, %eax
addl %eax, %esi
sarl $0x5, %r9d
notl %edx
subl %eax, %r9d
jne 0x65eb7
movl $0x1, %eax
testl %ecx, %ecx
je 0x65f1a
movslq %esi, %rsi
shlq $0x2, %rsi
addq 0x64e2d9(%rip), %rsi    # 0x6b4178
shlq $0x2, %r8
movl (%rsi), %r9d
andl %edx, %r9d
testl %edi, %r9d
jne 0x65f18
addq %r8, %rsi
decl %ecx
jne 0x65ea3
jmp 0x65f1a
testl %ecx, %ecx
je 0x65f11
movq 0x64e2b6(%rip), %r10    # 0x6b4178
movslq %esi, %rsi
movl %r9d, %r11d
movslq %r9d, %rbx
leaq (%r10,%rsi,4), %r14
leaq (,%r8,4), %r15
xorl %eax, %eax
testl %edx, (%r10,%rsi,4)
jne 0x65f1a
movl $0x1, %r12d
cmpl $0x2, %r9d
jl 0x65efd
cmpl $0x0, (%r14,%r12,4)
jne 0x65f1a
incq %r12
cmpq %r12, %r11
jne 0x65eeb
movq %rbx, %r12
leaq (%r10,%r12,4), %r12
testl %edi, (%r12,%rsi,4)
jne 0x65f1a
addq %r8, %rsi
addq %r15, %r14
decl %ecx
jne 0x65ed9
movl $0x1, %eax
jmp 0x65f1a
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: setrect
static void setrect (int x0, int y0, int dx, int dy)
{
#if 0
	int i, j, y;
	i = y0*gvox->mytexx + x0;
	for(y=0;y<dy;y++,i+=gvox->mytexx)
		for(x=0;x<dx;x++) { j = i+x; zbit[j>>5] |= (1<<SHIFTMOD32(j)); }
#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) zbit[i] |= m; }
	else
	{  for(;dy;dy--,i+=mytexo5)
		{
			zbit[i] |= m;
			for(x=1;x<c;x++) zbit[i+x] = -1;
			zbit[i+x] |= m1;
		}
	}
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebx
movslq 0x64e237(%rip), %rbp    # 0x6b4170
imull %ebp, %esi
movl %edi, %eax
sarl $0x5, %eax
leal (%rsi,%rax), %ecx
addl %edi, %edx
decl %edx
movl %edx, %r9d
sarl $0x5, %r9d
andl $0x1f, %edi
andl $0x1f, %edx
leaq 0x64e184(%rip), %r8     # 0x6b40e0
movl (%r8,%rdi,4), %edi
notl %edi
movl 0x4(%r8,%rdx,4), %r8d
subl %eax, %r9d
jne 0x65f98
testl %ebx, %ebx
je 0x6603f
andl %edi, %r8d
movslq %ecx, %rax
shlq $0x2, %rax
addq 0x64e1f3(%rip), %rax    # 0x6b4178
shlq $0x2, %rbp
orl %r8d, (%rax)
addq %rbp, %rax
decl %ebx
jne 0x65f89
jmp 0x6603f
testl %ebx, %ebx
je 0x6603f
movq %rbp, %r11
movq 0x64e1ce(%rip), %r14    # 0x6b4178
leal -0x2(%r9), %edx
leaq 0x4(,%rdx,4), %rdx
movq %rdx, 0x10(%rsp)
movslq %r9d, %rdx
cmpq $0x2, %rdx
movl $0x1, %r15d
cmovgeq %rdx, %r15
movslq %ecx, %rcx
movq %r14, 0x18(%rsp)
leaq (%r14,%rcx,4), %r13
shlq $0x2, %rbp
leal (%rax,%rsi), %r12d
incl %r12d
movl %edi, 0x4(%rsp)
movq %r9, 0x20(%rsp)
movq %r15, 0x8(%rsp)
orl %edi, (%r13)
cmpl $0x2, %r9d
jl 0x66030
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax,4), %rdi
movl $0xff, %esi
movq 0x10(%rsp), %rdx
movl %r8d, %r15d
movq %r11, %r14
callq 0x62f0
movq %r14, %r11
movl %r15d, %r8d
movq 0x8(%rsp), %r15
movl 0x4(%rsp), %edi
movq 0x20(%rsp), %r9
orl %r8d, (%r13,%r15,4)
addq %rbp, %r13
addl %r11d, %r12d
decl %ebx
jne 0x65ff1
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x66244
testb $0x2, 0x38(%r14)
jne 0x661be
movzwl 0x38(%r14), %eax
andl $0x1, %eax
movl %eax, 0x4(%rbx)
movl 0x34(%r14), %eax
movl %eax, 0x8(%rbx)
jmp 0x6621e
movl $0x1, (%rbx)
cmpq $0x0, 0x40(%r14)
je 0x66227
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 0x661f4
leaq 0x5e2a31(%rip), %rcx    # 0x648c20
movzbl 0x3(%rcx,%rax,4), %ecx
movl %ecx, 0x14(%rbx)
testb $0x4, 0x38(%r14)
jne 0x6621e
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 0x66244
cmpl $0x0, 0x3f35e(%rip)     # 0xa558c
jle 0x6623e
leaq 0x16015(%rip), %rdi     # 0x7c24c
xorl %eax, %eax
callq 0x25221
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x418, %esi            # imm = 0x418
callq 0x70277
movl %eax, %ebp
movl %eax, %r15d
andl $0xfff, %r15d           # imm = 0xFFF
leaq 0x64df09(%rip), %r12    # 0x6b4180
movq (%r12,%r15,8), %r13
testq %r13, %r13
je 0x662a6
movq %r13, %r14
cmpl %ebp, 0x20(%r14)
jne 0x6629e
leaq 0x24(%r14), %rdi
movl $0x418, %edx            # imm = 0x418
movq %rbx, %rsi
callq 0x6720
testl %eax, %eax
je 0x662e0
movq (%r14), %r14
testq %r14, %r14
jne 0x66283
movl $0x1, %edi
movl $0x440, %esi            # imm = 0x440
callq 0x6930
testq %rax, %rax
je 0x662dd
movq %rax, %r14
movl %ebp, 0x20(%rax)
movq %rax, %rdi
addq $0x24, %rdi
movl $0x418, %edx            # imm = 0x418
movq %rbx, %rsi
callq 0x60c0
movq %r13, (%r14)
movq %r14, (%r12,%r15,8)
jmp 0x662e0
xorl %r14d, %r14d
addq $0x8, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x1, %ecx
callq 0x67107
testq %rax, %rax
je 0x67105
movl 0x60(%rax), %ecx
testl %ecx, %ecx
jne 0x67100
incl 0x65d080(%rip)          # 0x6c4180
incl %ecx
movl %ecx, 0x60(%rax)
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x65cf2c(%rip), %ecx    # 0x6c4188
xorl %eax, %eax
cmpl $0xfff, %ecx            # imm = 0xFFF
jg 0x6734f
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x654efe(%rip), %r15    # 0x6bc180
testl %ecx, %ecx
jne 0x672ed
movq %rbx, (%rsp)
movl $0xfff, %r12d           # imm = 0xFFF
leaq 0x5934a9(%rip), %r13    # 0x5fa740
movq (%r15,%r12,8), %rbp
testq %rbp, %rbp
je 0x672dd
cmpl $0x0, 0x60(%rbp)
jne 0x672d7
movl $0x30, %ebx
movq (%rbp,%rbx), %rsi
testq %rsi, %rsi
je 0x672d1
cmpl $0x0, (%rsi)
je 0x672d1
movl $0x1, %edi
callq *0xc0(%r13)
movq (%rbp,%rbx), %rax
movl $0x0, (%rax)
addq $-0x8, %rbx
jne 0x672ab
movq (%rbp), %rbp
jmp 0x6729b
subq $0x1, %r12
jae 0x67297
movl 0x65ce9f(%rip), %ecx    # 0x6c4188
movq (%rsp), %rbx
movslq %ecx, %rax
movq (%r15,%rax,8), %r15
testq %r15, %r15
je 0x6731c
cmpl $0x0, 0x60(%r15)
jle 0x6730e
incl 0x65ce7e(%rip)          # 0x6c4184
movq %r15, %rdi
callq 0x67350
movq (%r15), %r15
testq %r15, %r15
jne 0x672f9
movl 0x65ce6c(%rip), %ecx    # 0x6c4188
movl 0x65ce62(%rip), %eax    # 0x6c4184
movl %eax, (%r14)
movl 0x65ce55(%rip), %eax    # 0x6c4180
movl %eax, (%rbx)
leal 0x1(%rcx), %eax
movl %eax, 0x65ce52(%rip)    # 0x6c4188
xorl %eax, %eax
cmpl $0xfff, %ecx            # imm = 0xFFF
setl %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 %rbx
movq %rdi, %rbx
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x67368
cmpl $0x0, (%rax)
je 0x67368
testb $-0x80, 0x4(%rax)
je 0x673a2
leaq 0x8(%rbx), %rdi
testb $0x2, 0x40(%rbx)
je 0x673a9
callq 0x67b46
testl %eax, %eax
jne 0x673a2
movl 0x38(%rbx), %edi
movl 0x3c(%rbx), %esi
movzwl 0x40(%rbx), %edx
andl $-0x3, %edx
movl $0x1, %ecx
callq 0x67107
movq %rax, 0x58(%rbx)
movq %rax, %rbx
testq %rax, %rax
jne 0x67354
xorl %eax, %eax
jmp 0x673a7
movl $0x1, %eax
popq %rbx
retq
popq %rbx
jmp 0x67d57
// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl $0xfff, %ebx            # imm = 0xFFF
leaq 0x654dbc(%rip), %r14    # 0x6bc180
leaq 0x593375(%rip), %r15    # 0x5fa740
movq (%r14,%rbx,8), %r12
testq %r12, %r12
je 0x6740a
movl $0x30, %r13d
movq (%r12,%r13), %rsi
testq %rsi, %rsi
je 0x673fe
cmpl $0x0, (%rsi)
je 0x673fe
movl $0x1, %edi
callq *0xc0(%r15)
movq (%r12,%r13), %rax
movl $0x0, (%rax)
addq $-0x8, %r13
jne 0x673da
movq (%r12), %r12
jmp 0x673cf
subq $0x1, %rbx
jae 0x673cb
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0xfff, %r14d           # imm = 0xFFF
leaq 0x654d4e(%rip), %r15    # 0x6bc180
leaq 0x593307(%rip), %r12    # 0x5fa740
movq (%r15,%r14,8), %rbx
testq %rbx, %rbx
je 0x67485
movq (%rbx), %r13
movl $0x30, %ebp
movq (%rbx,%rbp), %rsi
testq %rsi, %rsi
je 0x6746f
cmpl $0x0, (%rsi)
je 0x6746f
movl $0x1, %edi
callq *0xc0(%r12)
movq (%rbx,%rbp), %rax
movl $0x0, (%rax)
addq $-0x8, %rbp
jne 0x6744a
movq %rbx, %rdi
callq 0x61c0
movq %r13, %rbx
testq %r13, %r13
jne 0x67442
movq $0x0, (%r15,%r14,8)
subq $0x1, %r14
jae 0x67439
movl $0xfff, %ebx            # imm = 0xFFF
leaq 0x64cce1(%rip), %r14    # 0x6b4180
movq (%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x674b8
movq (%rdi), %r15
callq 0x61c0
movq %r15, %rdi
testq %r15, %r15
jne 0x674a8
movq $0x0, (%r14,%rbx,8)
subq $0x1, %rbx
jae 0x6749f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x67107
testq %rax, %rax
je 0x6750a
movq %rax, %rbx
movq %rax, %rdi
callq 0x67350
testl %eax, %eax
je 0x6750a
movq %rbx, %rax
movq 0x58(%rbx), %rbx
testq %rbx, %rbx
jne 0x674f8
addq $0x8, %rax
jmp 0x6750c
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x20, %edi
callq 0x69a0
movq %rax, %rbx
testq %rax, %rax
je 0x6758c
movl $0x0, (%rbx)
movq 0x654c39(%rip), %rax    # 0x6bc180
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 0x67584
andl $0xfff, %r14d           # imm = 0xFFF
movl %r14d, (%rbx)
leaq 0x654c09(%rip), %rax    # 0x6bc180
movq (%rax,%r14,8), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x6759e
movq %rbx, %rdi
callq 0x675a8
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x0, 0x8(%rbx)
jmp 0x6758c
// File: /workspace/github_c_makefile_star2_O3/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 0x654bca(%rip), %rcx    # 0x6bc180
testq %rdx, %rdx
je 0x675eb
testl %eax, %eax
je 0x6760e
testb $0x1, %al
je 0x675cb
movl 0x38(%rdx), %esi
cmpl 0x14(%rdi), %esi
jne 0x67605
testb $0x2, %al
je 0x675d7
movl 0x3c(%rdx), %esi
cmpl 0x18(%rdi), %esi
jne 0x67605
testb $0x4, %al
je 0x6760e
movzwl 0x1c(%rdi), %esi
andw 0x40(%rdx), %si
cmpw 0x1e(%rdi), %si
jne 0x67605
jmp 0x6760e
testb $0x1, %al
jne 0x6760e
movslq (%rdi), %rsi
leaq 0x1(%rsi), %rdx
movl %edx, (%rdi)
cmpq $0xfff, %rsi            # imm = 0xFFF
jge 0x6760f
leaq (%rcx,%rdx,8), %rdx
movq (%rdx), %rdx
movq %rdx, 0x8(%rdi)
jmp 0x675b6
retq
movq $0x0, 0x8(%rdi)
movl $0x1000, (%rdi)         # imm = 0x1000
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x65bb6b(%rip), %r14    # 0x6c41a0
movq (%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x6864f
movq 0x18(%rdi), %r15
callq 0x61c0
movq %r15, %rdi
testq %r15, %r15
jne 0x6863e
movq $0x0, (%r14,%rbx,8)
incq %rbx
cmpq $0x200, %rbx            # imm = 0x200
jne 0x68635
leaq 0x13ef3(%rip), %rdi     # 0x7c55d
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x25221
// File: /workspace/github_c_makefile_star2_O3/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, %r14
movb (%rdi), %cl
testb %cl, %cl
je 0x686af
leaq 0x1(%r14), %rdx
movl $0x1505, %eax           # imm = 0x1505
movl %eax, %esi
shll $0x5, %esi
addl %eax, %esi
movzbl %cl, %eax
xorl %esi, %eax
movb (%rdx), %cl
incq %rdx
testb %cl, %cl
jne 0x68693
andl $0x1ff, %eax            # imm = 0x1FF
jmp 0x686b4
movl $0x105, %eax            # imm = 0x105
leaq 0x65bae5(%rip), %rcx    # 0x6c41a0
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x686eb
andl $0x1, %ebx
cmpl %ebp, 0x8(%r15)
jne 0x686e2
cmpl 0xc(%r15), %ebx
jne 0x686e2
movq (%r15), %rdi
movq %r14, %rsi
callq 0x68d0
testl %eax, %eax
je 0x686ee
movq 0x18(%r15), %r15
testq %r15, %r15
jne 0x686c7
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
movb (%rdi), %al
testb %al, %al
je 0x68743
leaq 0x1(%r15), %rcx
movl $0x1505, %r13d          # imm = 0x1505
movl %r13d, %edx
shll $0x5, %edx
addl %r13d, %edx
movzbl %al, %r13d
xorl %edx, %r13d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x68721
andl $0x1ff, %r13d           # imm = 0x1FF
jmp 0x68749
movl $0x105, %r13d           # imm = 0x105
movq %r15, %rdi
callq 0x6420
leaq 0x21(%rax), %rdi
callq 0x69a0
movq %rax, %r12
leaq 0x20(%rax), %rdi
movq %rdi, (%rax)
movq %r15, %rsi
callq 0x6430
movl %r14d, 0x8(%r12)
andl $0x1, %ebp
movl %ebp, 0xc(%r12)
movl %ebx, 0x10(%r12)
leaq 0x65ba1b(%rip), %rax    # 0x6c41a0
movq (%rax,%r13,8), %rcx
movq %rcx, 0x18(%r12)
movq %r12, (%rax,%r13,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
testq %rdi, %rdi
je 0x68a76
callq 0x61c0
movl 0x1c(%rbx), %eax
testl %eax, %eax
jle 0x68aa3
leaq 0x30(%rbx), %r14
xorl %r15d, %r15d
movq (%r14), %rdi
testq %rdi, %rdi
je 0x68a94
callq 0x61c0
movl 0x1c(%rbx), %eax
incq %r15
movslq %eax, %rcx
addq $0x18, %r14
cmpq %rcx, %r15
jl 0x68a84
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x61c0
// File: /workspace/github_c_makefile_star2_O3/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:
leal -0x1(%rdx), %eax
cmpl $0x2, %eax
jae 0x68f62
leaq 0x591a59(%rip), %rax    # 0x5fa988
movl (%rax), %eax
xorl %ecx, %ecx
cmpl $0x1, %eax
setne %cl
shll $0x5, %ecx
addl $0x220, %ecx            # imm = 0x220
cmpl $0x2, %eax
movl $0x300, %eax            # imm = 0x300
cmovnel %ecx, %eax
xorl %ecx, %ecx
cmpl $0x1, %edx
setne %cl
leal (%rcx,%rcx,2), %ecx
leal (%rax,%rcx), %edx
incl %edx
jmp 0x6cd47
xorl %eax, %eax
cmpl $0x3, %edx
jne 0x68f8d
leal 0x3(%rdi), %eax
addl $0x6, %edi
testl %eax, %eax
cmovnsl %eax, %edi
shrl $0x2, %edi
leal 0x3(%rsi), %eax
addl $0x6, %esi
testl %eax, %eax
cmovnsl %eax, %esi
shrl $0x2, %esi
imull %edi, %esi
shll $0x3, %esi
movl %esi, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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:
movq %rdi, %rax
movl %esi, %edi
andl $0x1f, %edi
movl %esi, %r8d
shrl $0x5, %r8d
andl $0x1f, %r8d
shrl $0xa, %esi
andl $0x1f, %esi
testl %edx, %edx
je 0x6935a
movzwl %di, %edx
movl %edx, %edi
shrl $0x2, %edi
leal (%rdi,%rdx,8), %edi
movzwl %r8w, %edx
movl %edx, %r8d
shrl $0x2, %r8d
leal (%r8,%rdx,8), %r8d
movzwl %si, %edx
movl %edx, %esi
shrl $0x2, %esi
leal (%rsi,%rdx,8), %esi
movl $0xff, %edx
cmpl %edx, %ecx
cmovbl %ecx, %edx
movb %sil, (%rax)
movb %r8b, 0x1(%rax)
movb %dil, 0x2(%rax)
movb %dl, 0x3(%rax)
retq
nop
// File: /workspace/github_c_makefile_star2_O3/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)
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 %edx, %eax
shrl $0x6, %eax
andl $0x7, %eax
movl %edx, %r9d
shrl $0x3, %r9d
andl $0x7, %r9d
andl $0x7, %edx
xorl %r10d, %r10d
cmpl $0x4, %eax
setb %r10b
leal (%rax,%r10,8), %eax
xorl %r10d, %r10d
cmpl $0x4, %r9d
setb %r10b
leal (%r9,%r10,8), %r9d
xorl %r10d, %r10d
cmpl $0x4, %edx
setb %r10b
leal (%rdx,%r10,8), %edx
movl %esi, %r10d
andl $0x1f, %r10d
addl %r10d, %edx
addl $-0x8, %edx
movl %esi, %r10d
shrl $0x5, %r10d
andl $0x1f, %r10d
addl %r10d, %r9d
addl $-0x8, %r9d
shrl $0xa, %esi
andl $0x1f, %esi
addl %eax, %esi
addl $-0x8, %esi
movl %r9d, %eax
orl %edx, %eax
orl %esi, %eax
cmpl $0x20, %eax
jb 0x69488
movl $0x1f, %r10d
cmpl %r10d, %esi
cmovgel %r10d, %esi
xorl %r11d, %r11d
testl %esi, %esi
cmovlel %r11d, %esi
cmpl %r10d, %r9d
cmovgel %r10d, %r9d
testl %r9d, %r9d
cmovlel %r11d, %r9d
cmpl %r10d, %edx
cmovll %edx, %r10d
testl %r10d, %r10d
cmovlel %r11d, %r10d
movl %r10d, %edx
testb %cl, %cl
je 0x694b3
leal (,%rdx,8), %ecx
shrl $0x2, %edx
orl %ecx, %edx
leal (,%r9,8), %ecx
sarl $0x2, %r9d
orl %ecx, %r9d
leal (,%rsi,8), %ecx
shrl $0x2, %esi
orl %ecx, %esi
cmpl $0x100, %r9d            # imm = 0x100
jae 0x694dc
cmpl $0x20, %eax
setb %al
movl $0xff, %ecx
cmpl %ecx, %r8d
cmovbl %r8d, %ecx
movb %sil, (%rdi)
movb %r9b, 0x1(%rdi)
movb %dl, 0x2(%rdi)
movb %cl, 0x3(%rdi)
retq
pushq %rax
leaq 0x135bf(%rip), %rdi     # 0x7caa3
leaq 0x131f4(%rip), %rsi     # 0x7c6df
leaq 0x13545(%rip), %rcx     # 0x7ca37
movl $0xb4, %edx
callq 0x61b0
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::etc1_block::unpack_color5(unsigned int&, unsigned int&, unsigned int&, unsigned short, unsigned short, bool, unsigned int)
bool etc1_block::unpack_color5(uint& r, uint& g, uint& b, uint16 packed_color5, uint16 packed_delta3, bool scaled, uint alpha)
   {
      color_quad_u8 result;
      const bool success = unpack_color5(result, packed_color5, packed_delta3, scaled, alpha);
      r = result.r;
      g = result.g;
      b = result.b;
      return success;
   }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %eax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl 0x30(%rsp), %r8d
leaq 0x4(%rsp), %r12
movq %r12, %rdi
movl %ecx, %esi
movl %eax, %edx
movl %r9d, %ecx
callq 0x693dc
movzbl (%r12), %ecx
movl %ecx, (%r15)
movzbl 0x1(%r12), %ecx
movl %ecx, (%r14)
movzbl 0x2(%r12), %ecx
movl %ecx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x695c9
leal 0x4(%rsi), %eax
cmpl $0x8, %eax
jae 0x695e8
leal 0x4(%rdx), %eax
cmpl $0x8, %eax
jae 0x69607
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 0x130d8(%rip), %rdi     # 0x7c6a8
leaq 0x13108(%rip), %rsi     # 0x7c6df
leaq 0x13111(%rip), %rcx     # 0x7c6ef
movl $0x3fc, %edx            # imm = 0x3FC
callq 0x61b0
leaq 0x1313e(%rip), %rdi     # 0x7c72d
leaq 0x130e9(%rip), %rsi     # 0x7c6df
leaq 0x130f2(%rip), %rcx     # 0x7c6ef
movl $0x3fd, %edx            # imm = 0x3FD
callq 0x61b0
leaq 0x13156(%rip), %rdi     # 0x7c764
leaq 0x130ca(%rip), %rsi     # 0x7c6df
leaq 0x130d3(%rip), %rcx     # 0x7c6ef
movl $0x3fe, %edx            # imm = 0x3FE
callq 0x61b0
// File: /workspace/github_c_makefile_star2_O3/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
andl $0x1f, %edx
movd %edx, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pcmpeqd 0x119df(%rip), %xmm0    # 0x7e6d0
movq %rdi, %r14
movmskps %xmm0, %eax
testl %eax, %eax
movl $0x1, %ebp
cmovnel %edx, %ebp
xorl %eax, %eax
testb $0x6, %bpl
setne %al
leaq (%rsi,%rax,8), %rsi
movl %ebp, %edx
andl $0x1, %edx
callq 0x71dc3
testb $0x2, %bpl
jne 0x6cd29
testb $0x4, %bpl
jne 0x6cd38
popq %rbx
popq %r14
popq %rbp
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x70391
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x70839
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/libsquish/squish.cpp
// Function: squish::GetStorageRequirements(int, int, 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 %edx, %eax
andl $0x1f, %eax
movd %eax, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pcmpeqd 0x11973(%rip), %xmm0    # 0x7e6d0
movmskps %xmm0, %eax
testl %eax, %eax
setne %r8b
leal 0x3(%rdi), %eax
leal 0x6(%rdi), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x2, %ecx
leal 0x3(%rsi), %edi
leal 0x6(%rsi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
sarl $0x2, %eax
imull %ecx, %eax
testb $0x9, %dl
sete %cl
andb %r8b, %cl
addb $0x3, %cl
shll %cl, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/libsquish/squish.cpp
// Function: squish::CopyRGBA(unsigned char const*, unsigned char*, int)
void CopyRGBA( u8 const* source, u8* dest, int flags )
{
    if (flags & kSourceBGRA)
    {
        // convert from bgra to rgba
        dest[0] = source[2];
        dest[1] = source[1];
        dest[2] = source[0];
        dest[3] = source[3];
    }
    else
    {
        for( int i = 0; i < 4; ++i )
            *dest++ = *source++;
    }
}

// Assembly:
btl $0x9, %edx
jb 0x6cdab
xorl %eax, %eax
movb (%rdi,%rax), %cl
movb %cl, (%rsi,%rax)
incq %rax
cmpl $0x4, %eax
jne 0x6cd9c
retq
movb 0x2(%rdi), %al
movb %al, (%rsi)
movb 0x1(%rdi), %al
movb %al, 0x1(%rsi)
movb (%rdi), %al
movb %al, 0x2(%rsi)
movb 0x3(%rdi), %al
movb %al, 0x3(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/sdlayer2.c
// Function: wm_msgbox
int wm_msgbox(const char *name, const char *fmt, ...)
{
	char *buf = NULL;
	int rv;
	va_list va;

	if (!name) {
		name = apptitle;
	}

	va_start(va,fmt);
	rv = Bvasprintf(&buf,fmt,va);
	va_end(va);

	if (rv < 0) return -1;

	do {
		rv = 0;

#if defined HAVE_GTK
		if (wmgtk_msgbox(name, buf) >= 0) {
			rv = 1;
			break;
		}
#endif
		if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, name, buf, sdl_window) >= 0) {
			rv = 1;
			break;
		}

		puts(buf);
	} while(0);

	free(buf);

	return rv;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xe8, %rsp
leaq 0x30(%rsp), %r10
movq %rdx, 0x10(%r10)
movq %rcx, 0x18(%r10)
movq %r8, 0x20(%r10)
movq %r9, 0x28(%r10)
testb %al, %al
je 0x6d701
movaps %xmm0, 0x60(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm2, 0x80(%rsp)
movaps %xmm3, 0x90(%rsp)
movaps %xmm4, 0xa0(%rsp)
movaps %xmm5, 0xb0(%rsp)
movaps %xmm6, 0xc0(%rsp)
movaps %xmm7, 0xd0(%rsp)
leaq 0x8(%rsp), %rax
movq $0x0, (%rax)
testq %rdi, %rdi
leaq 0x37e89(%rip), %r14     # 0xa55a0
cmovneq %rdi, %r14
leaq 0x10(%rsp), %rdx
movq %r10, 0x10(%rdx)
leaq 0x100(%rsp), %rcx
movq %rcx, 0x8(%rdx)
movabsq $0x3000000010, %rcx     # imm = 0x3000000010
movq %rcx, (%rdx)
movq %rax, %rdi
callq 0x21ea4
testl %eax, %eax
js 0x6d794
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6f746
movl $0x1, %ebx
testl %eax, %eax
jns 0x6d788
movq 0x8(%rsp), %rdx
movq 0x65fb55(%rip), %rcx    # 0x6cd2c0
movl $0x40, %edi
movq %r14, %rsi
callq 0x6ad0
testl %eax, %eax
jns 0x6d788
movq 0x8(%rsp), %rdi
callq 0x6ab0
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
callq 0x61c0
jmp 0x6d799
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0xe8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/sdlayer2.c
// Function: wm_ynbox
int wm_ynbox(const char *name, const char *fmt, ...)
{
	char *buf = NULL;
	int rv;
	va_list va;

	if (!name) {
		name = apptitle;
	}

	va_start(va,fmt);
	rv = Bvasprintf(&buf,fmt,va);
	va_end(va);

	if (rv < 0) return -1;

	SDL_MessageBoxButtonData buttons[2] = {
		{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "Yes" },
		{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "No" },
	};
	SDL_MessageBoxData msgbox = {
		SDL_MESSAGEBOX_INFORMATION,
		sdl_window,
		name,
		buf,
		SDL_arraysize(buttons),
		buttons,
		NULL
	};

	do {
		rv = 0;

#if defined HAVE_GTK
		if ((rv = wmgtk_ynbox(name, buf)) >= 0) {
			break;
		}
#endif
		if (SDL_ShowMessageBox(&msgbox, &rv) >= 0) {
			rv = (rv == 1);
			break;
		}

		puts(buf);
		puts("   (assuming 'No')");
		rv = 0;
	} while(0);

	free(buf);

	return rv;
}

// Assembly:
pushq %rbx
subq $0x140, %rsp            # imm = 0x140
movq %rdi, %rbx
leaq 0x90(%rsp), %r10
movq %rdx, 0x10(%r10)
movq %rcx, 0x18(%r10)
movq %r8, 0x20(%r10)
movq %r9, 0x28(%r10)
testb %al, %al
je 0x6d80d
movaps %xmm0, 0xc0(%rsp)
movaps %xmm1, 0xd0(%rsp)
movaps %xmm2, 0xe0(%rsp)
movaps %xmm3, 0xf0(%rsp)
movaps %xmm4, 0x100(%rsp)
movaps %xmm5, 0x110(%rsp)
movaps %xmm6, 0x120(%rsp)
movaps %xmm7, 0x130(%rsp)
leaq 0x10(%rsp), %rdi
movq $0x0, (%rdi)
leaq 0x50(%rsp), %rdx
movq %r10, 0x10(%rdx)
leaq 0x150(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
callq 0x21ea4
testl %eax, %eax
js 0x6d8d9
testq %rbx, %rbx
leaq 0x37d4e(%rip), %rdi     # 0xa55a0
cmovneq %rbx, %rdi
movaps 0x25333(%rip), %xmm0    # 0x92b90
leaq 0x70(%rsp), %rax
movaps %xmm0, 0x10(%rax)
movaps 0x25313(%rip), %xmm0    # 0x92b80
movaps %xmm0, (%rax)
movl $0x40, 0x18(%rsp)
movq 0x65fa41(%rip), %rcx    # 0x6cd2c0
movq %rcx, 0x20(%rsp)
movq %rdi, 0x28(%rsp)
movq 0x10(%rsp), %rsi
movq %rsi, 0x30(%rsp)
movl $0x2, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
callq 0x6f7c8
movl %eax, 0xc(%rsp)
testl %eax, %eax
jns 0x6d8fe
leaq 0x18(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x6630
testl %eax, %eax
js 0x6d8e0
xorl %eax, %eax
cmpl $0x1, 0xc(%rsp)
sete %al
movl %eax, 0xc(%rsp)
jmp 0x6d8fe
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6d90c
movq 0x10(%rsp), %rdi
callq 0x6ab0
leaq 0x10e36(%rip), %rdi     # 0x7e727
callq 0x6ab0
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rdi
callq 0x61c0
movl 0xc(%rsp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/sdlayer2.c
// Function: wm_filechooser
int wm_filechooser(const char *initialdir, const char *initialfile, const char *type, int foropen, char **choice)
{
#if defined __APPLE__ || defined HAVE_GTK
    int rv;
    if (mouseacquired && moustat) {
        SDL_SetRelativeMouseMode(SDL_FALSE);
    }
#if defined __APPLE__
    rv = wmosx_filechooser(initialdir, initialfile, type, foropen, choice);
#elif defined HAVE_GTK
    rv = wmgtk_filechooser(initialdir, initialfile, type, foropen, choice);
#endif
    SDL_RaiseWindow(sdl_window);
    if (mouseacquired && moustat) {
        SDL_SetRelativeMouseMode(SDL_TRUE);
    }
    return rv;
#else
    (void)initialdir; (void)initialfile; (void)type; (void)foropen; (void)choice;
#endif
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %rbx
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
cmpb $0x0, 0x65f996(%rip)    # 0x6cd2c8
je 0x6d944
testb $0x1, 0x65f98e(%rip)    # 0x6cd2c9
je 0x6d944
xorl %edi, %edi
callq 0x6540
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
movq %rbx, %r8
callq 0x6f84a
movl %eax, %ebx
movq 0x65f960(%rip), %rdi    # 0x6cd2c0
callq 0x6890
cmpb $0x0, 0x65f95c(%rip)    # 0x6cd2c8
je 0x6d981
testb $0x1, 0x65f954(%rip)    # 0x6cd2c9
je 0x6d981
movl $0x1, %edi
callq 0x6540
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/sdlayer2.c
// Function: wm_setapptitle
void wm_setapptitle(const char *name)
{
	if (name) {
		Bstrncpy(apptitle, name, sizeof(apptitle)-1);
		apptitle[ sizeof(apptitle)-1 ] = 0;
	}
#if defined HAVE_GTK
	wmgtk_setapptitle(apptitle);
#endif
}

// Assembly:
testq %rdi, %rdi
je 0x6d9b6
pushq %rax
movq %rdi, %rsi
leaq 0x37bff(%rip), %rdi     # 0xa55a0
movl $0xff, %edx
callq 0x6190
movb $0x0, 0x37ced(%rip)     # 0xa569f
addq $0x8, %rsp
leaq 0x37be3(%rip), %rdi     # 0xa55a0
jmp 0x6f738
// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/sdlayer2.c
// Function: wm_setwindowtitle
void wm_setwindowtitle(const char *name)
{
	if (name) {
		Bstrncpy(wintitle, name, sizeof(wintitle)-1);
		wintitle[ sizeof(wintitle)-1 ] = 0;
	}

	if (sdl_window) {
		SDL_SetWindowTitle(sdl_window, wintitle);
	}
}

// Assembly:
testq %rdi, %rdi
je 0x6d9e7
pushq %rax
movq %rdi, %rsi
leaq 0x65f8fe(%rip), %rdi    # 0x6cd2d0
movl $0xff, %edx
callq 0x6190
movb $0x0, 0x65f9ec(%rip)    # 0x6cd3cf
addq $0x8, %rsp
movq 0x65f8d2(%rip), %rdi    # 0x6cd2c0
testq %rdi, %rdi
je 0x6d9ff
leaq 0x65f8d6(%rip), %rsi    # 0x6cd2d0
jmp 0x61d0
retq