LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GenerateNoiseTrack(DiskTrackInfo*)
int CCapsImageStd::GenerateNoiseTrack(PDISKTRACKINFO pti)
{
	UDWORD val=CIMG_MFMNOISE;

	for (int pos=0; pos < pti->tracklen; pos++) {
		pti->trackbuf[pos]=(UBYTE)val;
		val=val<<8|val>>24;
	}

	return imgeOk;
}

// Assembly:
cmpl $0x0, 0x50(%rsi)
jle 0xa68b
movl $0x10030f01, %eax       # imm = 0x10030F01
xorl %ecx, %ecx
movq 0x48(%rsi), %rdx
movb %al, (%rdx,%rcx)
roll $0x8, %eax
incq %rcx
movslq 0x50(%rsi), %rdx
cmpq %rdx, %rcx
jl 0xa675
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::DecodeDensity(DiskTrackInfo*, unsigned char*, unsigned int)
int CCapsImageStd::DecodeDensity(PDISKTRACKINFO pti, PUBYTE buf, UDWORD flag)
{
	// generate density
	switch (pti->ci.dentype) {
		case cpdenNoise:
			if (flag & DI_LOCK_DENNOISE)
				GenerateNoiseDensity(pti);
			break;

		case cpdenAuto:
			if (flag & DI_LOCK_DENAUTO)
				GenerateAutoDensity(pti);
			break;

		case cpdenCLAmiga:
			if (flag & DI_LOCK_DENVAR)
				GenerateCLA(pti, buf);
			break;

		case cpdenCLAmiga2:
			if (flag & DI_LOCK_DENVAR)
				GenerateCLA2(pti, buf);
			break;

		case cpdenCLST:
			if (flag & DI_LOCK_DENVAR)
				GenerateCLST(pti, buf);
			break;

		case cpdenSLAmiga:
			if (flag & DI_LOCK_DENVAR)
				GenerateSLA(pti, buf);
			break;

		case cpdenSLAmiga2:
			if (flag & DI_LOCK_DENVAR)
				GenerateSLA2(pti, buf);
			break;

		case cpdenABAmiga:
			if (flag & DI_LOCK_DENVAR)
				GenerateABA(pti, buf);
			break;

		case cpdenABAmiga2:
			if (flag & DI_LOCK_DENVAR)
				GenerateABA2(pti, buf);
			break;
	}

	// density map conversion
	if (flag & DI_LOCK_DENALT)
		ConvertDensity(pti);

	return imgeOk;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rsi, %rbx
movl 0x108(%rsi), %eax
decl %eax
cmpl $0x8, %eax
ja 0xa749
leaq 0x7b8a(%rip), %rcx      # 0x12238
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testb $0x10, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xa798
jmp 0xa749
testb $0x4, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xaeb0
jmp 0xa749
testb $0x4, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xac12
jmp 0xa749
testb $0x4, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xad5c
jmp 0xa749
testb $0x4, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xb0e4
jmp 0xa749
testb $0x8, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xaa94
jmp 0xa749
testb $0x4, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xaf5e
jmp 0xa749
testb $0x4, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xb036
jmp 0xa749
testb $0x4, %bpl
je 0xa749
movq %rbx, %rsi
callq 0xb25e
btl $0xa, %ebp
jae 0xa77d
movq 0xb0(%rbx), %rax
testq %rax, %rax
je 0xa77d
cmpl $0x0, 0xa8(%rbx)
jle 0xa77d
xorl %ecx, %ecx
xorl %edx, %edx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
movslq 0xa8(%rbx), %rsi
cmpq %rsi, %rcx
jl 0xa768
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GenerateAutoDensity(DiskTrackInfo*)
int CCapsImageStd::GenerateAutoDensity(PDISKTRACKINFO pti)
{
	// same size with track data
	if (pti->tracklen && pti->trackcnt)
		pti->timecnt=pti->tracklen/pti->trackcnt;
	else
		if (!(pti->timecnt=pti->ci.trksize))
			pti->timecnt=12500;

	pti->timebuf=new UDWORD[pti->timecnt+1];

	int pos;
	for (pos=0; pos < pti->timecnt; pos++) {
		pti->timebuf[pos]=1000;
	}

	pti->timebuf[pos]=0;

	return imgeOk;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movl 0x50(%rsi), %eax
testl %eax, %eax
je 0xaab9
movl 0x28(%r14), %ecx
testl %ecx, %ecx
je 0xaab9
cltd
idivl %ecx
movl %eax, %ebx
movl %eax, 0xa8(%r14)
jmp 0xaad1
movl 0x110(%r14), %eax
testl %eax, %eax
movl $0x30d4, %ebx           # imm = 0x30D4
cmovnel %eax, %ebx
movl %ebx, 0xa8(%r14)
movslq %ebx, %r15
leaq 0x4(,%r15,4), %rax
cmpl $-0x1, %r15d
movq $-0x1, %rdi
cmovgeq %rax, %rdi
callq 0x4040
movq %rax, 0xb0(%r14)
testl %r15d, %r15d
jle 0xac01
movl %ebx, %ecx
addl $0x3, %ebx
leaq -0x1(%rcx), %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %ebx
shlq $0x4, %rbx
movdqa 0x777e(%rip), %xmm1     # 0x122a0
movdqa 0x7786(%rip), %xmm2     # 0x122b0
xorl %edx, %edx
movdqa 0x779c(%rip), %xmm3     # 0x122d0
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x77fc(%rip), %xmm5     # 0x12340
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0xab80
movl $0x3e8, (%rax,%rdx)     # imm = 0x3E8
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0xab97
movl $0x3e8, 0x4(%rax,%rdx)  # imm = 0x3E8
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %esi
testb $0x1, %sil
je 0xabd7
movl $0x3e8, 0x8(%rax,%rdx)  # imm = 0x3E8
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0xabea
movl $0x3e8, 0xc(%rax,%rdx)  # imm = 0x3E8
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rdx
cmpq %rdx, %rbx
jne 0xab44
jmp 0xac03
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GenerateCLA(DiskTrackInfo*, unsigned char*)
int CCapsImageStd::GenerateCLA(PDISKTRACKINFO pti, PUBYTE buf)
{
	// set auto density
	GenerateAutoDensity(pti);

	// iterate block positions
	int lg = trackbuf.CalculateByteSize(di.block[3].gapbits);
	int pos=pti->sdpos, cp;

	for (unsigned blk=0; blk < pti->ci.blkcnt; blk++) {
		int bs = trackbuf.CalculateByteSize(di.block[blk].blockbits);
		int gs = trackbuf.CalculateByteSize(di.block[blk].gapbits);
		int xs=bs+gs;

		switch (blk) {
			case 4:
				for (cp=0-lg; cp < bs; cp++) {
					pti->timebuf[pos+cp]-=55;
				}
				break;

			case 5:
				for (cp=0-lg; cp < bs; cp++) {
					pti->timebuf[pos+cp]-=5;
				}
				break;

			case 6:
				for (cp=0-lg; cp < bs; cp++) {
					pti->timebuf[pos+cp]+=45;
				}
				break;
		}

		pos+=xs;
		if (pos >= pti->timecnt)
			pos-=pti->timecnt;
		lg=gs;
	}

	return imgeOk;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0xaa94
cmpl $0x0, 0x128(%rbx)
je 0xad51
movq 0x1f8(%r14), %rax
movl 0xc0(%rbx), %esi
movl 0x7c(%rax), %r8d
addl $0x7, %r8d
shrl $0x3, %r8d
xorl %ecx, %ecx
xorl %edx, %edx
leaq (%rdx,%rdx,4), %r9
movl (%rax,%r9,8), %edi
movl 0x4(%rax,%r9,8), %r9d
addl $0x7, %edi
shrl $0x3, %edi
cmpl $0x6, %edx
je 0xace9
cmpl $0x5, %edx
je 0xacb1
cmpl $0x4, %edx
jne 0xad1f
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xad1f
movslq %esi, %r10
shlq $0x2, %r10
movl %r8d, %r11d
shlq $0x2, %r11
subq %r11, %r10
addq 0xb0(%rbx), %r10
addl %edi, %r8d
xorl %r11d, %r11d
addl $-0x37, (%r10,%r11,4)
incq %r11
cmpl %r11d, %r8d
jne 0xaca2
jmp 0xad1f
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xad1f
movslq %esi, %r10
shlq $0x2, %r10
movl %r8d, %r11d
shlq $0x2, %r11
subq %r11, %r10
addq 0xb0(%rbx), %r10
addl %edi, %r8d
xorl %r11d, %r11d
addl $-0x5, (%r10,%r11,4)
incq %r11
cmpl %r11d, %r8d
jne 0xacda
jmp 0xad1f
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xad1f
movslq %esi, %r10
shlq $0x2, %r10
movl %r8d, %r11d
shlq $0x2, %r11
subq %r11, %r10
addq 0xb0(%rbx), %r10
addl %edi, %r8d
xorl %r11d, %r11d
addl $0x2d, (%r10,%r11,4)
incq %r11
cmpl %r11d, %r8d
jne 0xad12
addl $0x7, %r9d
shrl $0x3, %r9d
addl %esi, %edi
addl %r9d, %edi
movl 0xa8(%rbx), %esi
movl 0x128(%rbx), %r10d
cmpl %esi, %edi
cmovll %ecx, %esi
subl %esi, %edi
incq %rdx
movl %r9d, %r8d
movl %edi, %esi
cmpq %r10, %rdx
jb 0xac4b
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GenerateCLA2(DiskTrackInfo*, unsigned char*)
int CCapsImageStd::GenerateCLA2(PDISKTRACKINFO pti, PUBYTE buf)
{
	// set auto density
	GenerateAutoDensity(pti);

	// iterate block positions
	int lg = trackbuf.CalculateByteSize(di.block[di.blockcount - 1].gapbits);
	int pos=pti->sdpos, cp;

	for (unsigned blk=0; blk < pti->ci.blkcnt; blk++) {
		int bs = trackbuf.CalculateByteSize(di.block[blk].blockbits);
		int gs = trackbuf.CalculateByteSize(di.block[blk].gapbits);
		int xs=bs+gs;

		switch (blk) {
			case 0:
				for (cp=0-lg; cp < bs; cp++) {
					pti->timebuf[pos+cp]-=55;
				}
				break;

			case 1:
				for (cp=0-lg; cp < bs; cp++) {
					pti->timebuf[pos+cp]-=5;
				}
				break;

			case 2:
				for (cp=0-lg; cp < bs; cp++) {
					pti->timebuf[pos+cp]+=45;
				}
				break;
		}

		pos+=xs;
		if (pos >= pti->timecnt)
			pos-=pti->timecnt;
		lg=gs;
	}

	return imgeOk;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0xaa94
cmpl $0x0, 0x128(%rbx)
je 0xaea6
movq 0x1f8(%r14), %rax
movl 0xc0(%rbx), %esi
movslq 0x204(%r14), %rcx
leaq (%rcx,%rcx,4), %rcx
movl -0x24(%rax,%rcx,8), %r8d
addl $0x7, %r8d
shrl $0x3, %r8d
xorl %ecx, %ecx
xorl %edx, %edx
leaq (%rdx,%rdx,4), %r9
movl (%rax,%r9,8), %edi
movl 0x4(%rax,%r9,8), %r9d
addl $0x7, %edi
shrl $0x3, %edi
cmpl $0x2, %edx
je 0xae3e
cmpl $0x1, %edx
je 0xae06
testl %edx, %edx
jne 0xae74
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xae74
movslq %esi, %r10
shlq $0x2, %r10
movl %r8d, %r11d
shlq $0x2, %r11
subq %r11, %r10
addq 0xb0(%rbx), %r10
addl %edi, %r8d
xorl %r11d, %r11d
addl $-0x37, (%r10,%r11,4)
incq %r11
cmpl %r11d, %r8d
jne 0xadf7
jmp 0xae74
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xae74
movslq %esi, %r10
shlq $0x2, %r10
movl %r8d, %r11d
shlq $0x2, %r11
subq %r11, %r10
addq 0xb0(%rbx), %r10
addl %edi, %r8d
xorl %r11d, %r11d
addl $-0x5, (%r10,%r11,4)
incq %r11
cmpl %r11d, %r8d
jne 0xae2f
jmp 0xae74
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xae74
movslq %esi, %r10
shlq $0x2, %r10
movl %r8d, %r11d
shlq $0x2, %r11
subq %r11, %r10
addq 0xb0(%rbx), %r10
addl %edi, %r8d
xorl %r11d, %r11d
addl $0x2d, (%r10,%r11,4)
incq %r11
cmpl %r11d, %r8d
jne 0xae67
addl $0x7, %r9d
shrl $0x3, %r9d
addl %esi, %edi
addl %r9d, %edi
movl 0xa8(%rbx), %esi
movl 0x128(%rbx), %r10d
cmpl %esi, %edi
cmovll %ecx, %esi
subl %esi, %edi
incq %rdx
movl %r9d, %r8d
movl %edi, %esi
cmpq %r10, %rdx
jb 0xada1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GenerateCLST(DiskTrackInfo*, unsigned char*)
int CCapsImageStd::GenerateCLST(PDISKTRACKINFO pti, PUBYTE buf)
{
	// set auto density
	GenerateAutoDensity(pti);

	// iterate block positions
	int pos=pti->sdpos, cp;

	for (unsigned blk=0; blk < pti->ci.blkcnt; blk++) {
		int bs = trackbuf.CalculateByteSize(di.block[blk].blockbits);
		int gs = trackbuf.CalculateByteSize(di.block[blk].gapbits);
		int xs=bs+gs;

		switch (blk) {
			case 5:
				for (cp=0; cp < bs; cp++) {
					pti->timebuf[pos+cp]+=50;
				}
				break;
		}

		pos+=xs;
		if (pos >= pti->timecnt)
			pos-=pti->timecnt;
	}

	return imgeOk;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0xaa94
movl 0x128(%rbx), %esi
testl %esi, %esi
je 0xaf54
movl 0xc0(%rbx), %edi
movq 0x1f8(%r14), %rax
xorl %ecx, %ecx
xorl %edx, %edx
leaq (%rdx,%rdx,4), %r8
movl (%rax,%r8,8), %r10d
movl 0x4(%rax,%r8,8), %r9d
addl $0x7, %r10d
movl %r10d, %r8d
shrl $0x3, %r8d
cmpq $0x5, %rdx
jne 0xaf29
cmpl $0x8, %r10d
jb 0xaf29
movslq %edi, %rsi
movl %r8d, %r10d
shlq $0x2, %rsi
addq 0xb0(%rbx), %rsi
xorl %r11d, %r11d
addl $0x32, (%rsi,%r11,4)
incq %r11
cmpq %r11, %r10
jne 0xaf16
movl 0x128(%rbx), %esi
addl $0x7, %r9d
shrl $0x3, %r9d
addl %edi, %r8d
addl %r9d, %r8d
movl 0xa8(%rbx), %edi
cmpl %edi, %r8d
cmovll %ecx, %edi
subl %edi, %r8d
incq %rdx
movl %esi, %r9d
movl %r8d, %edi
cmpq %r9, %rdx
jb 0xaede
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GenerateSLA(DiskTrackInfo*, unsigned char*)
int CCapsImageStd::GenerateSLA(PDISKTRACKINFO pti, PUBYTE buf)
{
	// set auto density
	GenerateAutoDensity(pti);

	// iterate block positions
	int pos=pti->sdpos, cp;

	for (unsigned blk=0; blk < pti->ci.blkcnt; blk++) {
		int bs = trackbuf.CalculateByteSize(di.block[blk].blockbits);
		int gs = trackbuf.CalculateByteSize(di.block[blk].gapbits);
		int xs=bs+gs;

		switch (blk) {
			case 1:
				for (cp=0; cp < bs; cp++) {
					pti->timebuf[pos+cp]+=100;
				}
				break;

			case 2:
				for (cp=0; cp < bs; cp++) {
					pti->timebuf[pos+cp]-=100;
				}
				break;
		}

		pos+=xs;
		if (pos >= pti->timecnt)
			pos-=pti->timecnt;
	}

	return imgeOk;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0xaa94
cmpl $0x0, 0x128(%rbx)
je 0xb02b
movl 0xc0(%rbx), %esi
movq 0x1f8(%r14), %rax
xorl %ecx, %ecx
xorl %edx, %edx
leaq (%rdx,%rdx,4), %rdi
movl (%rax,%rdi,8), %r9d
movl 0x4(%rax,%rdi,8), %r8d
addl $0x7, %r9d
movl %r9d, %edi
shrl $0x3, %edi
cmpl $0x1, %edx
je 0xafd5
cmpl $0x2, %edx
jne 0xaffc
cmpl $0x8, %r9d
jb 0xaffc
movslq %esi, %r9
movl %edi, %r10d
shlq $0x2, %r9
addq 0xb0(%rbx), %r9
xorl %r11d, %r11d
addl $-0x64, (%r9,%r11,4)
incq %r11
cmpq %r11, %r10
jne 0xafc6
jmp 0xaffc
cmpl $0x8, %r9d
jb 0xaffc
movslq %esi, %r9
movl %edi, %r10d
shlq $0x2, %r9
addq 0xb0(%rbx), %r9
xorl %r11d, %r11d
addl $0x64, (%r9,%r11,4)
incq %r11
cmpq %r11, %r10
jne 0xafef
addl $0x7, %r8d
shrl $0x3, %r8d
addl %esi, %edi
addl %r8d, %edi
movl 0xa8(%rbx), %esi
movl 0x128(%rbx), %r8d
cmpl %esi, %edi
cmovll %ecx, %esi
subl %esi, %edi
incq %rdx
movl %edi, %esi
cmpq %r8, %rdx
jb 0xaf8b
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GenerateABA(DiskTrackInfo*, unsigned char*)
int CCapsImageStd::GenerateABA(PDISKTRACKINFO pti, PUBYTE buf)
{
	// set auto density
	GenerateAutoDensity(pti);

	// iterate block positions
	int pos=pti->sdpos, cp;

	for (unsigned blk=0; blk < pti->ci.blkcnt; blk++) {
		int bs = trackbuf.CalculateByteSize(di.block[blk].blockbits);
		int gs = trackbuf.CalculateByteSize(di.block[blk].gapbits);
		int xs=bs+gs;

		switch (blk) {
			case 1:
				for (cp=0; cp < bs; cp++) {
					pti->timebuf[pos+cp]+=100;
				}
				break;

			case 2:
				for (cp=0; cp < bs; cp++) {
					pti->timebuf[pos+cp]+=50;
				}
				break;

			case 4:
				for (cp=0; cp < bs; cp++) {
					pti->timebuf[pos+cp]-=50;
				}
				break;

			case 5:
				for (cp=0; cp < bs; cp++) {
					pti->timebuf[pos+cp]-=100;
				}
				break;

			case 6:
				for (cp=0; cp < bs; cp++) {
					pti->timebuf[pos+cp]-=150;
				}
				break;
		}

		pos+=xs;
		if (pos >= pti->timecnt)
			pos-=pti->timecnt;
	}

	return imgeOk;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0xaa94
cmpl $0x0, 0x128(%rbx)
je 0xb254
movl 0xc0(%rbx), %edi
movq 0x1f8(%r14), %rax
xorl %ecx, %ecx
leaq 0x7146(%rip), %rdx      # 0x1225c
xorl %esi, %esi
leaq (%rsi,%rsi,4), %r8
movl (%rax,%r8,8), %r10d
movl 0x4(%rax,%r8,8), %r9d
addl $0x7, %r10d
movl %r10d, %r8d
shrl $0x3, %r8d
leal -0x1(%rsi), %r11d
cmpl $0x5, %r11d
ja 0xb221
movslq (%rdx,%r11,4), %r11
addq %rdx, %r11
jmpq *%r11
cmpl $0x8, %r10d
jb 0xb221
movslq %edi, %r10
movl %r8d, %r11d
shlq $0x2, %r10
addq 0xb0(%rbx), %r10
xorl %r14d, %r14d
addl $0x64, (%r10,%r14,4)
incq %r14
cmpq %r14, %r11
jne 0xb166
jmp 0xb221
cmpl $0x8, %r10d
jb 0xb221
movslq %edi, %r10
movl %r8d, %r11d
shlq $0x2, %r10
addq 0xb0(%rbx), %r10
xorl %r14d, %r14d
addl $-0x32, (%r10,%r14,4)
incq %r14
cmpq %r14, %r11
jne 0xb196
jmp 0xb221
cmpl $0x8, %r10d
jb 0xb221
movslq %edi, %r10
movl %r8d, %r11d
shlq $0x2, %r10
addq 0xb0(%rbx), %r10
xorl %r14d, %r14d
addl $0x32, (%r10,%r14,4)
incq %r14
cmpq %r14, %r11
jne 0xb1bf
jmp 0xb221
cmpl $0x8, %r10d
jb 0xb221
movslq %edi, %r10
movl %r8d, %r11d
shlq $0x2, %r10
addq 0xb0(%rbx), %r10
xorl %r14d, %r14d
addl $-0x64, (%r10,%r14,4)
incq %r14
cmpq %r14, %r11
jne 0xb1e8
jmp 0xb221
cmpl $0x8, %r10d
jb 0xb221
movslq %edi, %r10
movl %r8d, %r11d
shlq $0x2, %r10
addq 0xb0(%rbx), %r10
xorl %r14d, %r14d
addl $0xffffff6a, (%r10,%r14,4) # imm = 0xFFFFFF6A
incq %r14
cmpq %r14, %r11
jne 0xb211
addl $0x7, %r9d
shrl $0x3, %r9d
addl %edi, %r8d
addl %r9d, %r8d
movl 0xa8(%rbx), %edi
movl 0x128(%rbx), %r9d
cmpl %edi, %r8d
cmovll %ecx, %edi
subl %edi, %r8d
incq %rsi
movl %r8d, %edi
cmpq %r9, %rsi
jb 0xb118
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GenerateABA2(DiskTrackInfo*, unsigned char*)
int CCapsImageStd::GenerateABA2(PDISKTRACKINFO pti, PUBYTE buf)
{
	// set auto density
	GenerateAutoDensity(pti);

	// iterate block positions
	int pos=pti->sdpos, cp;
	UDWORD key=0;
	UDWORD mask=1;

	for (unsigned blk=0; blk < pti->ci.blkcnt; blk++) {
		int bs = trackbuf.CalculateByteSize(di.block[blk].blockbits);
		int gs = trackbuf.CalculateByteSize(di.block[blk].gapbits);
		int xs=bs+gs;

		if (!blk) {
			key=ReadValue(buf+blk*sizeof(CapsBlock)+offsetof(CapsBlock, gapvalue), sizeof(UDWORD));
		} else {
			int dns=(key & mask) ? -50 : 50;
			mask<<=1;

			for (cp=0; cp < bs; cp++) {
				int val=pti->timebuf[pos+cp];
				val+=dns;
				pti->timebuf[pos+cp]=val;
			}
		}

		pos+=xs;
		if (pos >= pti->timecnt)
			pos-=pti->timecnt;
	}

	return imgeOk;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %rbp
callq 0xaa94
cmpl $0x0, 0x128(%r14)
je 0xb358
movl 0xc0(%r14), %r12d
addq $0x18, 0x8(%rsp)
movl $0x1, %r9d
xorl %r10d, %r10d
xorl %r13d, %r13d
xorl %eax, %eax
movq %r14, 0x10(%rsp)
movq 0x1f8(%rbp), %rcx
leaq (,%r13,4), %rsi
addq %r13, %rsi
movl (%rcx,%rsi,8), %edx
movl 0x4(%rcx,%rsi,8), %r15d
addl $0x7, %edx
movl %edx, %ebx
shrl $0x3, %ebx
testq %r13, %r13
je 0xb308
testl %r9d, %eax
movl $0xffffffce, %ecx       # imm = 0xFFFFFFCE
movl $0x32, %esi
cmovel %esi, %ecx
addl %r9d, %r9d
cmpl $0x8, %edx
jb 0xb325
movslq %r12d, %rdx
movl %ebx, %esi
shlq $0x2, %rdx
addq 0xb0(%r14), %rdx
xorl %edi, %edi
addl %ecx, (%rdx,%rdi,4)
incq %rdi
cmpq %rdi, %rsi
jne 0xb2fb
jmp 0xb325
movq 0x8(%rsp), %rdi
movl $0x4, %esi
movl %r9d, %r14d
callq 0xf1c0
xorl %r10d, %r10d
movl %r14d, %r9d
movq 0x10(%rsp), %r14
addl $0x7, %r15d
shrl $0x3, %r15d
addl %r12d, %ebx
addl %r15d, %ebx
movl 0xa8(%r14), %ecx
movl 0x128(%r14), %edx
cmpl %ecx, %ebx
cmovll %r10d, %ecx
subl %ecx, %ebx
incq %r13
movl %ebx, %r12d
cmpq %rdx, %r13
jb 0xb2aa
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ConvertDensity(DiskTrackInfo*)
int CCapsImageStd::ConvertDensity(PDISKTRACKINFO pti)
{
	// cancel if buffer not available
	if (!pti->timebuf || !pti->timecnt)
		return imgeOk;

	// sum fractions
	UDWORD sum=0;
	for (int pos=0; pos < pti->timecnt; pos++) {
		sum+=pti->timebuf[pos];
		pti->timebuf[pos]=sum;
	}

	return imgeOk;
}

// Assembly:
movq 0xb0(%rsi), %rax
testq %rax, %rax
je 0xb398
cmpl $0x0, 0xa8(%rsi)
jle 0xb398
xorl %ecx, %ecx
xorl %edx, %edx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
movslq 0xa8(%rsi), %rdi
cmpq %rdi, %rcx
jl 0xb383
xorl %eax, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::AllocImageBlock(int)
void CCapsImageStd::AllocImageBlock(int maxsize)
{
	if (di.blocksize < maxsize) {
		FreeImageBlock();

		di.block=new ImageBlockInfo[maxsize];
		di.blocksize=maxsize;
	}
}

// Assembly:
cmpl %esi, 0x200(%rdi)
jge 0xb432
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movq $0x0, 0x200(%rdi)
movq 0x1f8(%rdi), %rdi
testq %rdi, %rdi
je 0xb3f7
callq 0x4280
movq $0x0, 0x1f8(%rbx)
movslq %ebp, %r14
movl $0x28, %ecx
movq %r14, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x4040
movq %rax, 0x1f8(%rbx)
movl %r14d, 0x200(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GetBlock(CapsBlock*, int)
int CCapsImageStd::GetBlock(PCAPSBLOCK pb, int blk)
{
	// check errors
	if (!di.data || !pb || blk<0 || blk>=di.blockcount)
		return imgeGeneric;

	// check buffer overrun
	if (int((blk+1)*sizeof(CapsBlock)) > di.pdt->datasize)
		return imgeShort;

	// read block descriptor and convert it to host native endiannes
	memcpy(pb, di.data+blk*sizeof(CapsBlock), sizeof(CapsBlock));
	CCapsLoader::Swap((PUDWORD)pb, sizeof(CapsBlock));

	return imgeOk;
}

// Assembly:
movl $0x2, %eax
testl %edx, %edx
js 0xb535
testq %rsi, %rsi
je 0xb535
movq 0x1e8(%rdi), %rcx
testq %rcx, %rcx
je 0xb535
cmpl %edx, 0x204(%rdi)
jle 0xb535
movl %edx, %r8d
shll $0x5, %r8d
addl $0x20, %r8d
movq 0x210(%rdi), %rdi
movl $0x7, %eax
cmpl 0x24(%rdi), %r8d
jg 0xb535
pushq %rax
movl %edx, %eax
shlq $0x5, %rax
movups (%rcx,%rax), %xmm0
movups 0x10(%rcx,%rax), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
movq %rsi, %rdi
movl $0x20, %esi
callq 0xd1bc
xorl %eax, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::InitStream(ImageStreamInfo*, int, int)
int CCapsImageStd::InitStream(PIMAGESTREAMINFO pstr, int strtype, int blk)
{
	// check errors
	if (!pstr || blk<0 || blk>=di.blockcount)
		return imgeGeneric;

	// set parameters so all data is available in the stream descriptor
	pstr->strtype=strtype;
	pstr->actblock=blk;
	pstr->enctype=di.block[blk].enctype;

	// active encoding is set by the block descriptor, but can be changed later
	pstr->actenctype=pstr->enctype;

	int res;

	switch (strtype) {
		case isitData:
			res=InitDataStream(pstr);
			break;

		case isitGap0:
		case isitGap1:
			res=InitGapStream(pstr);
			break;

		default:
			res=imgeGeneric;
			break;
	}

	// stop if stream could not be initialized
	if (res != imgeOk)
		return res;

	// stop if stream is unreadable
	res=ResetStream(pstr);

	return res;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x2, %eax
testq %rsi, %rsi
je 0xb59a
testl %ecx, %ecx
js 0xb59a
movq %rdi, %r14
cmpl %ecx, 0x204(%rdi)
jle 0xb59a
movq %rsi, %rbx
movl %edx, (%rsi)
movl %ecx, 0x4(%rsi)
movq 0x1f8(%r14), %rsi
movl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
movl 0x10(%rsi,%rcx,8), %ecx
movl %ecx, 0x8(%rbx)
movl %ecx, 0xc(%rbx)
leal -0x1(%rdx), %ecx
cmpl $0x2, %ecx
jae 0xb587
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb626
jmp 0xb596
testl %edx, %edx
jne 0xb59a
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb5b4
testl %eax, %eax
je 0xb5a2
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xb75a
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::FindGapStreamEnd(ImageStreamInfo*, int)
int CCapsImageStd::FindGapStreamEnd(PIMAGESTREAMINFO pstr, int next)
{
	uint8_t *buf=di.data;
	int end=0;

	uint32_t ofs;
	for (ofs=pstr->strstart; !end && ofs < pstr->strend; ) {
		int code=buf[ofs++];

		// read code, sizeof(count), count
		int vc=code >> CAPS_SIZE_S;
		code&=CAPS_DATAMASK;
		uint32_t count;

		if (vc) {
			if (ofs+vc > pstr->strend)
				return imgeTrackData;

			count=ReadValue(buf+ofs, vc);
			ofs+=vc;
		} else
			count=0;

		switch (code) {
			// end of stream
			case cpgapEnd:
				end=1;
				break;

			// skip total bitcount setting, already at next element
			case cpgapCount:
				break;

			// add sample data size and go to next element
			case cpgapData:
				ofs += trackbuf.CalculateByteSize(count);
				break;

			// no other data is allowed
			default:
				return imgeTrackStream;
		}
	}

	// no cpgapEnd encountered, stream error
	if (!end)
		return imgeTrackData;

	// update stream start/end position
	if (next)
		pstr->strstart=ofs;
	else
		pstr->strend=ofs;

	// check buffer overrun for stream limit
	if (pstr->strstart >= pstr->strend)
		return imgeShort;

	// update stream pointer and maximum size
	pstr->strbase=di.data+pstr->strstart;
	pstr->strsize=pstr->strend-pstr->strstart;

	return imgeOk;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movl 0x14(%rsi), %ecx
movl 0x18(%rsi), %edi
movl $0xa, %ebp
cmpl %edi, %ecx
jae 0xb875
movq %rsi, %rbx
movl %edx, 0x4(%rsp)
movq 0x1e8(%r14), %r13
movl %ecx, %eax
incl %ecx
movzbl (%r13,%rax), %r15d
xorl %eax, %eax
cmpl $0x20, %r15d
jae 0xb7f4
movl %ecx, %r12d
jmp 0xb813
movl %r15d, %esi
shrl $0x5, %esi
leal (%rsi,%rcx), %r12d
cmpl %edi, %r12d
ja 0xb875
movl %ecx, %edi
addq %r13, %rdi
callq 0xf1c0
addl $0x7, %eax
shrl $0x3, %eax
andl $0x1f, %r15d
cmpl $0x1, %r15d
je 0xb826
cmpl $0x2, %r15d
jne 0xb833
addl %eax, %r12d
movl 0x18(%rbx), %edi
movl %r12d, %ecx
cmpl %edi, %r12d
jb 0xb7dd
jmp 0xb875
movl $0x9, %ebp
testl %r15d, %r15d
jne 0xb875
cmpl $0x0, 0x4(%rsp)
je 0xb84d
movl %r12d, 0x14(%rbx)
movl 0x18(%rbx), %eax
jmp 0xb858
movl %r12d, 0x18(%rbx)
movl %r12d, %eax
movl 0x14(%rbx), %r12d
movl $0x7, %ebp
subl %r12d, %eax
jbe 0xb875
movl %r12d, %ecx
addq 0x1e8(%r14), %rcx
movq %rcx, 0x28(%rbx)
movl %eax, 0x20(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ReadSample(ImageStreamInfo*, int)
int CCapsImageStd::ReadSample(PIMAGESTREAMINFO pstr, int maxbc)
{
	// number of bits read
	int actbc=0;

	// value read
	uint32_t readvalue=0;

	// process remaining bits from stream
	while (maxbc > 0) {
		// get new sample when needed
		if (!pstr->remstreambc)
			if (ReadSampleInit(pstr))
				break;

		// restore bitstream state
		uint32_t remstreambc=pstr->remstreambc;
		uint32_t remsamplebc=pstr->remsamplebc;

		// stop on invalid sample state
		if (!remsamplebc)
			break;

		// read next sample if stream is empty, e.g. loop size has been changed
		if (!remstreambc)
			continue;

		uint32_t sampleofs=pstr->sampleofs;
		uint32_t samplemask=pstr->samplemask;
		uint32_t sampledata=pstr->samplebase[sampleofs];

		// read remaining bits from sample
		while (maxbc > 0) {
			// add new bit
			readvalue<<=1;
			if (sampledata & samplemask)
				readvalue|=1;

			// bit added
			actbc++;
			maxbc--;

			// one less sample bit to process 
			if (!--remsamplebc) {
				// reset the sample data if all sample bits have been read
				remsamplebc=pstr->samplebc;
				sampleofs=0;
				samplemask=0x80;
				sampledata=pstr->samplebase[sampleofs];
			} else {
				// set next bit position to read
				if (!(samplemask>>=1)) {
					sampleofs++;
					samplemask=0x80;
					sampledata=pstr->samplebase[sampleofs];
				}
			}

			// stop reading the current sample if complete data size has been read
			if (!--remstreambc)
				break;
		}

		// save bitstream state
		pstr->remstreambc=remstreambc;
		pstr->remsamplebc=remsamplebc;
		pstr->sampleofs=sampleofs;
		pstr->samplemask=samplemask;
	}

	// store value read
	pstr->readvalue=readvalue;

	return actbc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
testl %edx, %edx
jle 0xba5e
movl %edx, %r15d
movq %rdi, %r14
movl 0x54(%rbx), %eax
xorl %r12d, %r12d
xorl %ebp, %ebp
testl %eax, %eax
jne 0xb9c7
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb922
testl %eax, %eax
jne 0xba63
movl 0x54(%rbx), %eax
movl 0x58(%rbx), %ecx
testl %ecx, %ecx
je 0xba63
testl %eax, %eax
je 0xba4d
movl 0x5c(%rbx), %edx
movl 0x60(%rbx), %r8d
movq 0x68(%rbx), %rsi
movzbl (%rsi,%rdx), %r9d
movl %r15d, %edi
xorl %r10d, %r10d
testl %r8d, %r9d
setne %r11b
decl %ecx
je 0xba05
cmpl $0x1, %r8d
ja 0xba19
incl %edx
leaq (%rsi,%rdx), %r8
jmp 0xba0d
movl 0x50(%rbx), %ecx
xorl %edx, %edx
movq %rsi, %r8
movzbl (%r8), %r9d
movl $0x80, %r8d
jmp 0xba1c
shrl %r8d
movb %r11b, %r10b
leal (%r10,%r12,2), %r12d
leal -0x1(%rax), %r10d
leal -0x1(%rdi), %r15d
incl %ebp
cmpl $0x1, %eax
je 0xba3d
movl %r10d, %eax
cmpl $0x1, %edi
movl %r15d, %edi
ja 0xb9e9
movl %r10d, 0x54(%rbx)
movl %ecx, 0x58(%rbx)
movl %edx, 0x5c(%rbx)
movl %r8d, 0x60(%rbx)
jmp 0xba50
xorl %r10d, %r10d
movl %r10d, %eax
testl %r15d, %r15d
jg 0xb9ad
jmp 0xba63
xorl %ebp, %ebp
xorl %r12d, %r12d
movl %r12d, 0x40(%rbx)
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ProcessStreamRaw(ImageStreamInfo*)
void CCapsImageStd::ProcessStreamRaw(PIMAGESTREAMINFO pstr)
{
	// get process state
	uint32_t bitpos=pstr->prcbitpos;
	int maxbc=pstr->prcrembc;
	int skipbc=pstr->prcskipbc;
	int actbc=0;

	// process remaining bits
	while (maxbc > 0) {
		// read the ipf stream
		int readbc=ReadSample(pstr, rawreadlen);

		// number of bits not read/missing
		int diffbc=rawreadlen-readbc;

		// write track data if anything was read
		if (readbc > 0) {
			// number of bits to be written
			int writebc=readbc;

			// skip bits if needed and write bitfield
			if (writebc > skipbc) {
				writebc-=skipbc;
				skipbc=0;

				// get value read
				uint32_t value=pstr->readvalue;

				// if less bits to write than available, right align field to bit#0
				if (writebc > maxbc) {
					value >>= (writebc-maxbc);
					writebc=maxbc;
				}

				trackbuf.WriteBitWrap(bitpos, value, writebc);

				// next write position
				actbc+=writebc;
				maxbc-=writebc;
				bitpos+=writebc;

				// handle track buffer wrap around (disk rotation)
				if (bitpos >= di.trackbc)
					bitpos-=di.trackbc;
			} else
				skipbc-=writebc;
		}

		// stop processing if encoding method changed or stream stopped 
		if (diffbc)
			break;
	}

	// set the type of the very first data
	if (!pstr->prcwritebc && pstr->prcencstate && actbc)
		di.block[pstr->actblock].fdenc=ibieRaw;

	// save process state
	pstr->prcbitpos=bitpos;
	pstr->prcrembc=maxbc;
	pstr->prcskipbc=skipbc;
	pstr->prcwritebc+=actbc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %r14
movl 0x70(%rsi), %eax
movl %eax, 0xc(%rsp)
movl 0x74(%rsi), %r13d
movl 0x78(%rsi), %ebp
movl $0x0, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
testl %r13d, %r13d
jle 0xbe9d
movl 0x21c(%r14), %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0xb98c
movl %eax, %r15d
movl 0x21c(%r14), %ebx
testl %eax, %eax
jle 0xbe94
movq %r12, %rax
movl %r15d, %r12d
subl %ebp, %r12d
jle 0xbe8e
movl 0x40(%rax), %eax
xorl %edx, %edx
movl %r12d, %ecx
subl %r13d, %ecx
cmovgel %r13d, %r12d
cmovlel %edx, %ecx
shrl %cl, %eax
movq 0xc0(%r14), %rdi
movl 0xcc(%r14), %esi
movl 0xc(%rsp), %ebp
movl %ebp, %edx
movl %eax, %ecx
movl %r12d, %r8d
callq 0x4a6a
addl %r12d, 0x8(%rsp)
subl %r12d, %r13d
addl %ebp, %r12d
xorl %ebp, %ebp
movl 0x1c0(%r14), %eax
cmpl %eax, %r12d
cmovbl %ebp, %eax
subl %eax, %r12d
movl %r12d, 0xc(%rsp)
movq 0x10(%rsp), %r12
jmp 0xbe94
subl %r15d, %ebp
movq %rax, %r12
cmpl %r15d, %ebx
je 0xbdff
movl 0x80(%r12), %eax
testl %eax, %eax
jne 0xbed0
cmpl $0x0, 0x7c(%r12)
je 0xbed0
cmpl $0x0, 0x8(%rsp)
je 0xbed0
movq 0x1f8(%r14), %rcx
movslq 0x4(%r12), %rdx
leaq (%rdx,%rdx,4), %rdx
movl $0x1, 0x20(%rcx,%rdx,8)
movl 0xc(%rsp), %ecx
movl %ecx, 0x70(%r12)
movl %r13d, 0x74(%r12)
movl %ebp, 0x78(%r12)
addl 0x8(%rsp), %eax
movl %eax, 0x80(%r12)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ProcessStreamWeak(ImageStreamInfo*)
void CCapsImageStd::ProcessStreamWeak(PIMAGESTREAMINFO pstr)
{
	// get process state
	uint32_t bitpos=pstr->prcbitpos;
	int maxbc=pstr->prcrembc;
	int skipbc=pstr->prcskipbc;
	int actbc=0;
		
	// process remaining bits
	if (maxbc > 0) {
		// get weak field size without encoding
		int writebc=pstr->remstreambc;

		// skip reading the sample associated with this field and get the next sample
		ReadSampleInit(pstr);

		// calculate field size after encoding
		switch (pstr->actenctype) {
			case cpencMFM:
				writebc <<= 1;
				break;
		}

		// skip bits if needed and write bitfield
		if (writebc > skipbc) {
			writebc-=skipbc;
			skipbc=0;

			// limit to available bit size
			if (writebc > maxbc)
				writebc=maxbc;

			// mark weak data, use group#0 for IPF image
			DiskDataMark ddm;
			ddm.group = 0;
			ddm.position=bitpos;
			ddm.size=writebc;
			AddFD(di.pdt, &ddm, 1, DEF_FDALLOC);

			// clear field
			trackbuf.ClearBitWrap(bitpos, writebc);

			// next write position
			actbc+=writebc;
			maxbc-=writebc;
			bitpos+=writebc;

			// handle track buffer wrap around (disk rotation)
			if (bitpos >= di.trackbc)
				bitpos-=di.trackbc;
		} else
			skipbc-=writebc;
	}

	// set the type of the very first data
	if (!pstr->prcwritebc && pstr->prcencstate && actbc)
		di.block[pstr->actblock].fdenc=ibieWeak;

	// save process state
	pstr->prcbitpos=bitpos;
	pstr->prcrembc=maxbc;
	pstr->prcskipbc=skipbc;
	pstr->prcwritebc+=actbc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl 0x70(%rsi), %ebp
movl 0x74(%rsi), %r12d
movl 0x78(%rsi), %r13d
xorl %r14d, %r14d
testl %r12d, %r12d
jle 0xc173
movl 0x54(%rbx), %r15d
movq %rdi, (%rsp)
movq %rbx, %rsi
callq 0xb922
cmpl $0x1, 0xc(%rbx)
sete %cl
shll %cl, %r15d
movl %r15d, %r14d
subl %r13d, %r14d
jle 0xc169
cmpl %r12d, %r14d
cmovgel %r12d, %r14d
xorl %r13d, %r13d
leaq 0xc(%rsp), %rsi
movl %r13d, (%rsi)
movl %ebp, 0x4(%rsi)
movl %r14d, 0x8(%rsi)
movq (%rsp), %r15
movq 0x210(%r15), %rdi
movl $0x1, %edx
movl $0x8, %ecx
callq 0xf1de
movq 0xc0(%r15), %rdi
movl 0xcc(%r15), %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x4b84
subl %r14d, %r12d
addl %r14d, %ebp
movl 0x1c0(%r15), %eax
cmpl %eax, %ebp
cmovbl %r13d, %eax
subl %eax, %ebp
movq %r15, %rdi
jmp 0xc173
subl %r15d, %r13d
movq (%rsp), %rdi
xorl %r14d, %r14d
movl 0x80(%rbx), %eax
testl %eax, %eax
jne 0xc19f
testl %r14d, %r14d
je 0xc19f
cmpl $0x0, 0x7c(%rbx)
je 0xc19f
movq 0x1f8(%rdi), %rcx
movslq 0x4(%rbx), %rdx
leaq (%rdx,%rdx,4), %rdx
movl $0x3, 0x20(%rcx,%rdx,8)
movl %ebp, 0x70(%rbx)
movl %r12d, 0x74(%rbx)
movl %r13d, 0x78(%rbx)
addl %r14d, %eax
movl %eax, 0x80(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::CalculateStreamSize(ImageStreamInfo*)
int CCapsImageStd::CalculateStreamSize(PIMAGESTREAMINFO pstr)
{
	// find loop point and loop type
	int res=FindLoopPoint(pstr);
	if (res != imgeOk)
		return res;

	// use a copy of the stream to parse data
	ImageStreamInfo isi=*pstr;

	// allbc: size without looping
	// fixbc: fixed bits
	// loopbc: loop bits
	int fixbc=0, loopbc=0;

	// sum all bit counts
	while (!isi.readend) {
		switch (isi.looptype) {
			// no loop
			case isiltNone:
				fixbc+=GetEncodedSize(&isi, isi.remstreambc);
				break;

			// auto-generated or stream loop
			case isiltAuto:
			case isiltStream:
				fixbc+=GetEncodedSize(&isi, isi.remstreambc);
				if (isi.strofs == isi.loopofs)
					loopbc+=GetEncodedSize(&isi, isi.samplebc);
				break;

			default:
				return imgeGeneric;
		}

		// get next sample
		if (GetSample(&isi) != imgeOk)
			return imgeGeneric;
	}

	// save results
	pstr->esfixbc=fixbc;
	pstr->esloopbc=loopbc;

	return imgeOk;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
callq 0xc2be
movl %eax, %ebp
testl %eax, %eax
jne 0xc2a9
movq %rsp, %r15
movl $0xa8, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4190
xorl %r12d, %r12d
xorl %r13d, %r13d
movl $0x2, %ebp
cmpl $0x0, 0x3c(%rsp)
jne 0xc299
movl 0x8c(%rsp), %eax
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
jae 0xc24e
movl 0x48(%rsp), %ecx
movl 0x54(%rsp), %eax
decl %ecx
cmpl $0x1, %ecx
ja 0xc26d
cmpl $0x1, 0xc(%rsp)
sete %cl
shll %cl, %eax
movl 0x1c(%rsp), %edx
cmpl 0x84(%rsp), %edx
jne 0xc281
movl 0x50(%rsp), %edx
shll %cl, %edx
jmp 0xc27e
testl %eax, %eax
jne 0xc2a9
movl 0x48(%rsp), %ecx
movl 0x54(%rsp), %eax
decl %ecx
cmpl $0x1, %ecx
ja 0xc281
cmpl $0x1, 0xc(%rsp)
sete %cl
shll %cl, %eax
jmp 0xc281
movl 0x1c(%rsp), %ecx
cmpl 0x84(%rsp), %ecx
jne 0xc281
movl 0x50(%rsp), %edx
addl %edx, %r13d
addl %eax, %r12d
movq %r14, %rdi
movq %r15, %rsi
callq 0xb886
testl %eax, %eax
je 0xc206
jmp 0xc2a9
movl %r12d, 0x90(%rbx)
movl %r13d, 0x94(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::FindLoopPoint(ImageStreamInfo*)
int CCapsImageStd::FindLoopPoint(PIMAGESTREAMINFO pstr)
{
	// no loop point if sample looping is not allowed
	if (!pstr->allowloop) {
		pstr->loopofs=0;
		pstr->loopsize=0;
		pstr->looptype=isiltNone;
		return imgeOk;
	}

	// use a copy of the stream to parse data
	ImageStreamInfo isi=*pstr;

	// no loop point
	uint32_t loopofs=0;
	int loopsize=0, loopfound=0, cnt=0;

	while (!isi.readend) {
		uint32_t ofs=isi.strofs;
		int bc=isi.samplebc;

		switch (isi.strtype) {
			// loop point is the last data in forward gap stream; any data after a loop is invalid
			case isitGap0:
				if (loopfound)
					return imgeGeneric;

				loopofs=ofs;
				loopsize=bc;
				break;

			// loop point is the first data in backward gap stream; any loop after first data is invalid
			case isitGap1:
				if (!cnt) {
					loopofs=ofs;
					loopsize=bc;
				} else
					if (!isi.streambc)
						return imgeGeneric;
				break;
		}

		// only allow 1 loop
		if (!isi.streambc) {
			if (loopfound)
				return imgeGeneric;

			loopfound++;
		}

		cnt++;

		// get next sample
		if (GetSample(&isi) != imgeOk)
			return imgeGeneric;
	}

	// set loop point information
	pstr->loopofs=loopofs;
	pstr->loopsize=loopsize;

	if (loopsize)
		pstr->looptype=loopfound ? isiltStream : isiltAuto;
	else
		pstr->looptype=isiltNone;

	return imgeOk;
}

// Assembly:
cmpl $0x0, 0x44(%rsi)
je 0xc376
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r14
leaq 0x10(%rsp), %r15
movl $0xa8, %edx
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
callq 0x4190
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %ebx, %ebx
cmpl $0x0, 0x4c(%rsp)
jne 0xc38e
movl 0x10(%rsp), %edx
movl 0x2c(%rsp), %eax
movl 0x60(%rsp), %ecx
cmpl $0x1, %edx
je 0xc32c
cmpl $0x2, %edx
jne 0xc344
movl 0x5c(%rsp), %edx
testl %ebp, %ebp
je 0xc34a
testl %edx, %edx
jne 0xc35e
jmp 0xc36f
testl %r13d, %r13d
jne 0xc36f
xorl %r13d, %r13d
cmpl $0x0, 0x5c(%rsp)
sete %r13b
movl %eax, %ebx
movl %ecx, %r12d
jmp 0xc35e
movl 0x5c(%rsp), %edx
jmp 0xc34f
movl %ecx, %r12d
movl %eax, %ebx
testl %edx, %edx
jne 0xc35e
testl %r13d, %r13d
movl $0x1, %r13d
jne 0xc36f
movq %r14, %rdi
movq %r15, %rsi
callq 0xb886
decl %ebp
testl %eax, %eax
je 0xc2fd
movl $0x2, %eax
jmp 0xc3bb
movq $0x0, 0x84(%rsi)
movl $0x0, 0x8c(%rsi)
xorl %eax, %eax
retq
movq 0x8(%rsp), %rcx
movl %ebx, 0x84(%rcx)
movl %r12d, 0x88(%rcx)
cmpl $0x1, %r13d
movl $0x2, %eax
sbbl $0x0, %eax
testl %r12d, %r12d
cmovel %r12d, %eax
movl %eax, 0x8c(%rcx)
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ProcessBlockData(int, int)
int CCapsImageStd::ProcessBlockData(int blk, int datasize)
{
	// stop if no data area
	if (!datasize)
		return imgeOk;

	int res;
	ImageStreamInfo dsi;

	// initialize the data stream
	res=InitStream(&dsi, isitData, blk);
	if (res != imgeOk)
		return res;

	// encode block data
	res=ProcessStream(&dsi, di.encbitpos, datasize, 0, !di.encwritebc);
	if (res != imgeOk)
		return res;

	// error if the requested data size was not filled
	if (dsi.prcwritebc != datasize)
		return imgeGeneric;

	// update bit position and bits written
	di.encbitpos=dsi.prcbitpos;
	di.encwritebc+=dsi.prcwritebc;

	return imgeOk;
}

// Assembly:
testl %edx, %edx
je 0xc45e
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movl %edx, %ebx
movl %esi, %ecx
movq %rdi, %r14
movq %rsp, %rsi
xorl %edx, %edx
callq 0xb536
testl %eax, %eax
jne 0xc453
movl 0x1d8(%r14), %edx
xorl %r9d, %r9d
cmpl $0x0, 0x1dc(%r14)
sete %r9b
movq %rsp, %rsi
movq %r14, %rdi
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0xbd40
testl %eax, %eax
jne 0xc453
movl $0x2, %eax
cmpl %ebx, 0x80(%rsp)
jne 0xc453
movl 0x70(%rsp), %eax
movl %eax, 0x1d8(%r14)
addl %ebx, 0x1dc(%r14)
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r14
retq
xorl %eax, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ProcessBlockGap(ImageStreamInfo*, int)
int CCapsImageStd::ProcessBlockGap(PIMAGESTREAMINFO pg, int gapsize)
{
	// stop if no gap area
	if (!gapsize)
		return imgeOk;

	int skip=0;

	if (pg->esfixbc >= gapsize) {
		// fixed size is enough to fill the gap; disable loop
		SetLoop(pg, 0);

		// if backwards stream, skip unneeded bits
		if (pg->strtype == isitGap1)
			skip=pg->esfixbc-gapsize;
	} else {
		// loop required to fill the gap; error if loop point is not found
		if (!pg->esloopbc)
			return imgeGeneric;

		// number of bits to be generated using the loop
		int miss=gapsize-pg->esfixbc;

		// number of new samples required to generate the bits
		int scnt=miss/pg->esloopbc;

		// partial new sample size, 0 if all samples are complete
		int smod=miss%pg->esloopbc;

		// if partial sample is required
		if (smod) {
			// add another sample
			scnt++;

			// if backwards stream, skip bits not required from the added sample
			if (pg->strtype == isitGap1)
				skip=pg->esloopbc-smod;
		}

		// enable loop
		SetLoop(pg, scnt);
	}

	// encode gap data
	int res=ProcessStream(pg, di.encbitpos, gapsize, skip, !di.encwritebc);
	if (res != imgeOk)
		return res;

	// error if the requested data size was not filled
	if (pg->prcwritebc != gapsize)
		return imgeGeneric;

	// update bit position and bits written
	di.encbitpos=pg->prcbitpos;
	di.encwritebc+=pg->prcwritebc;

	if (pg->strtype == isitGap0)
		di.pdt->sip[pg->actblock].gapsizews0=gapsize;
	else
		di.pdt->sip[pg->actblock].gapsizews1=gapsize;

	return imgeOk;
}

// Assembly:
xorl %eax, %eax
testl %edx, %edx
je 0xc6cf
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movl %edx, %eax
subl 0x90(%rsi), %eax
jle 0xc622
movl 0x94(%r14), %ecx
testl %ecx, %ecx
je 0xc63f
cltd
idivl %ecx
testl %edx, %edx
je 0xc646
incl %eax
subl %edx, %ecx
xorl %ebp, %ebp
cmpl $0x2, (%r14)
cmovel %ecx, %ebp
jmp 0xc648
xorl %ebp, %ebp
movq %r14, %rsi
xorl %edx, %edx
callq 0xc8c2
cmpl $0x2, (%r14)
jne 0xc652
movl 0x90(%r14), %ebp
subl %ebx, %ebp
jmp 0xc652
movl $0x2, %eax
jmp 0xc6c5
xorl %ebp, %ebp
movq %r14, %rsi
movl %eax, %edx
callq 0xc8c2
movl 0x1d8(%r15), %edx
xorl %r9d, %r9d
cmpl $0x0, 0x1dc(%r15)
sete %r9b
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %ecx
movl %ebp, %r8d
callq 0xbd40
testl %eax, %eax
jne 0xc6c5
movl $0x2, %eax
cmpl %ebx, 0x80(%r14)
jne 0xc6c5
movl 0x70(%r14), %eax
movl %eax, 0x1d8(%r15)
addl %ebx, 0x1dc(%r15)
xorl %eax, %eax
cmpl $0x1, (%r14)
setne %al
movq 0x210(%r15), %rcx
movslq 0x4(%r14), %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
addq 0xf8(%rcx), %rdx
movl %ebx, 0x18(%rdx,%rax,4)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ProcessBlockGap(ImageStreamInfo*, ImageStreamInfo*, int, int)
int CCapsImageStd::ProcessBlockGap(PIMAGESTREAMINFO pg0, PIMAGESTREAMINFO pg1, int gapsize, int loopsel)
{
	int gs0=pg0->esfixbc;
	int gs1=pg1->esfixbc;

	// fixed size stream uses its own size, the stream with the loop fills the remainder
	if (loopsel) {
		// 0: fix, 1: loop
		if (gs0 > gapsize)
			gs0=gapsize;

		gs1=gapsize-gs0;
	} else {
		// 0: loop, 1: fix
		if (gs1 > gapsize)
			gs1=gapsize;

		gs0=gapsize-gs1;
	}

	// encode forward stream
	int res=ProcessBlockGap(pg0, gs0);
	if (res != imgeOk)
		return res;

	// set gap split position
	di.encgsvalid=1;
	di.encgapsplit=di.encbitpos;

	// encode backwards stream
	ProcessBlockGap(pg1, gs1);
	if (res != imgeOk)
		return res;

	return imgeOk;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r14
movq %rdi, %r15
testl %r8d, %r8d
je 0xc6f3
movl 0x90(%rsi), %edx
cmpl %ebx, %edx
cmovgel %ebx, %edx
subl %edx, %ebx
jmp 0xc705
movl 0x90(%r14), %eax
cmpl %ebx, %eax
cmovgel %ebx, %eax
subl %eax, %ebx
movl %ebx, %edx
movl %eax, %ebx
movq %r15, %rdi
callq 0xc5de
movl %eax, %ebp
testl %eax, %eax
jne 0xc739
movl $0x1, 0x1e0(%r15)
movl 0x1d8(%r15), %eax
movl %eax, 0x1e4(%r15)
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0xc5de
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsLoader.cpp
// Function: CCapsLoader::Unlock()
void CCapsLoader::Unlock()
{
	file.Close();
	flen=0;
	chunk.type=ccidUnknown;
	readmode=true;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x10, %rdi
callq 0x84d6
movl $0x0, 0x20(%rbx)
movl $0x7, 0x84(%rbx)
movl $0x1, 0x8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsLoader.cpp
// Function: CCapsLoader::Lock(CapsFile*)
int CCapsLoader::Lock(PCAPSFILE pcf)
{
	// close previous file
	Unlock();

	// open file
	if (file.Open(pcf)) {
		Unlock();
		return ccidErrFile;
	}

	// set read mode
	readmode=(pcf->flag & CFF_WRITE) ? false : true;

	// get file size, no file skip
	flen=file.GetSize();

	// check for caps id
	if (ReadChunk(true) != ccidFile) {
		Unlock();
		return ccidErrType;
	}

	return ccidCaps;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10(%rdi), %r14
movq %r14, %rdi
callq 0x84d6
movl $0x0, 0x20(%rbx)
movl $0x7, 0x84(%rbx)
movl $0x1, 0x8(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x852a
movl $0x1, %ebp
testl %eax, %eax
jne 0xcf4d
movl 0x10(%r15), %eax
notl %eax
andl $0x1, %eax
movl %eax, 0x8(%rbx)
movq %r14, %rdi
callq 0x8646
movl %eax, 0x20(%rbx)
movq %rbx, %rdi
movl $0x1, %esi
callq 0xcf7a
movl %eax, %ecx
movl $0x2, %ebp
xorl %eax, %eax
cmpl $0x8, %ecx
je 0xcf6f
movq %r14, %rdi
callq 0x84d6
movl $0x0, 0x20(%rbx)
movl $0x7, 0x84(%rbx)
movl $0x1, 0x8(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsLoader.cpp
// Function: CCapsLoader::SkipData()
int CCapsLoader::SkipData()
{
	// handle file error
	if (!file.IsOpen())
		return 0;

	// do not skip next time, clear type
	int type=chunk.type;
	chunk.type=ccidUnknown;

	// skip only data area
	if (type != ccidData)
		return 0;

	// do not skip empty area
	int skip=chunk.cg.mod.data.size;
	if (!skip)
		return 0;

	// correct skip size if image is short
	int pos=file.GetPosition();
	if (flen-pos < skip)
		skip=flen-pos;

	// seek to new chunk
	file.Seek(skip, 0);
	return skip;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r15
leaq 0x10(%rdi), %r14
movq %r14, %rdi
callq 0x863e
xorl %ebx, %ebx
testl %eax, %eax
je 0xd171
movl 0x84(%r15), %eax
movl $0x7, 0x84(%r15)
cmpl $0xa, %eax
jne 0xd171
movl 0x94(%r15), %ebp
testl %ebp, %ebp
je 0xd171
movq %r14, %rdi
callq 0x8650
movl 0x20(%r15), %ebx
subl %eax, %ebx
cmpl %ebp, %ebx
cmovgel %ebp, %ebx
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x8624
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq