LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
movq %rsi, %rbx
movl 0x50(%rsi), %eax
testl %eax, %eax
je 0xabd5
movl 0x28(%rbx), %ecx
testl %ecx, %ecx
je 0xabd5
cltd
idivl %ecx
movl %eax, 0xa8(%rbx)
jmp 0xabeb
movl 0x110(%rbx), %eax
testl %eax, %eax
movl $0x30d4, %ecx           # imm = 0x30D4
cmovnel %eax, %ecx
movl %ecx, 0xa8(%rbx)
movslq 0xa8(%rbx), %rax
cmpq $-0x1, %rax
leaq 0x4(,%rax,4), %rax
movq $-0x1, %rdi
cmovgeq %rax, %rdi
callq 0x4040
movq %rax, 0xb0(%rbx)
cmpl $0x0, 0xa8(%rbx)
jle 0xac42
movl 0xa8(%rbx), %ecx
cmpl $0x2, %ecx
movl $0x1, %edx
cmovgel %ecx, %edx
xorl %ecx, %ecx
movl $0x3e8, (%rax,%rcx,4)   # imm = 0x3E8
incq %rcx
cmpq %rcx, %rdx
jne 0xac31
jmp 0xac44
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
xorl %eax, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xabb8
cmpl $0x0, 0x128(%rbx)
je 0xad8f
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 0xad27
cmpl $0x5, %edx
je 0xacef
cmpl $0x4, %edx
jne 0xad5d
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xad5d
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 0xace0
jmp 0xad5d
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xad5d
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 0xad18
jmp 0xad5d
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xad5d
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 0xad50
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 0xac89
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xabb8
cmpl $0x0, 0x128(%rbx)
je 0xaee4
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 0xae7c
cmpl $0x1, %edx
je 0xae44
testl %edx, %edx
jne 0xaeb2
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xaeb2
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 0xae35
jmp 0xaeb2
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xaeb2
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 0xae6d
jmp 0xaeb2
movl %r8d, %r10d
negl %r10d
cmpl %r10d, %edi
jle 0xaeb2
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 0xaea5
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 0xaddf
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0xabb8
cmpl $0x0, 0x128(%rbx)
je 0xaf8a
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
cmpq $0x5, %rdx
jne 0xaf5f
cmpl $0x8, %r9d
jb 0xaf5f
movslq %esi, %r9
movl %edi, %r10d
shlq $0x2, %r9
addq 0xb0(%rbx), %r9
xorl %r11d, %r11d
addl $0x32, (%r9,%r11,4)
incq %r11
cmpq %r11, %r10
jne 0xaf52
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 0xaf1b
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0xabb8
cmpl $0x0, 0x128(%rbx)
je 0xb061
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 0xb00b
cmpl $0x2, %edx
jne 0xb032
cmpl $0x8, %r9d
jb 0xb032
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 0xaffc
jmp 0xb032
cmpl $0x8, %r9d
jb 0xb032
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 0xb025
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 0xafc1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xabb8
cmpl $0x0, 0x128(%rbx)
je 0xb282
movl 0xc0(%rbx), %edi
movq 0x1f8(%r14), %rax
xorl %ecx, %ecx
leaq 0x70f8(%rip), %rdx      # 0x1223c
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 0xb24f
movslq (%rdx,%r11,4), %r11
addq %rdx, %r11
jmpq *%r11
cmpl $0x8, %r10d
jb 0xb24f
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 0xb194
jmp 0xb24f
cmpl $0x8, %r10d
jb 0xb24f
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 0xb1c4
jmp 0xb24f
cmpl $0x8, %r10d
jb 0xb24f
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 0xb1ed
jmp 0xb24f
cmpl $0x8, %r10d
jb 0xb24f
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 0xb216
jmp 0xb24f
cmpl $0x8, %r10d
jb 0xb24f
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 0xb23f
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 0xb146
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0xabb8
cmpl $0x0, 0x128(%r14)
je 0xb386
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 0xb336
testl %r9d, %eax
movl $0xffffffce, %ecx       # imm = 0xFFFFFFCE
movl $0x32, %esi
cmovel %esi, %ecx
addl %r9d, %r9d
cmpl $0x8, %edx
jb 0xb353
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 0xb329
jmp 0xb353
movq 0x8(%rsp), %rdi
movl $0x4, %esi
movl %r9d, %r14d
callq 0xf16e
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 0xb2d8
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_O1/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 0xb3cf
cmpl $0x0, 0xa8(%rsi)
je 0xb3cf
cmpl $0x0, 0xa8(%rsi)
jle 0xb3cf
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 0xb3ba
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0xb468
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movq $0x0, 0x200(%rdi)
movq 0x1f8(%rdi), %rdi
testq %rdi, %rdi
je 0xb42d
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_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::GetBlock(ImageBlockInfo*, int)
int CCapsImageStd::GetBlock(PIMAGEBLOCKINFO pi, int blk)
{
	// check errors
	if (!pi)
		return imgeGeneric;

	// get ipf block descriptor, stop on any error
	CapsBlock cb;
	int res=GetBlock(&cb, blk);
	if (res != imgeOk)
		return res;

	// set image descriptor
	pi->blockbits=cb.blockbits;
	pi->gapbits=cb.gapbits;
	pi->enctype=cb.enctype;
	pi->flag=cb.flag;
	pi->gapvalue=cb.gapvalue;
	pi->dataoffset=cb.dataoffset;

	// CAPS encoder support: no gap streams, no flags, 2us cells
	if (dii.ci.encoder == CAPS_ENCODER) {
		pi->gapoffset=0;
		pi->celltype=cpbct2us;
		pi->flag=0;
	} else {
		pi->gapoffset=cb.bt.sps.gapoffset;
		pi->celltype=cb.bt.sps.celltype;
	}

	// reset encoding information
	pi->fdenc=ibieNA;
	pi->fdbitpos=0;

	return imgeOk;
}

// Assembly:
testq %rsi, %rsi
je 0xb4ff
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x8(%rsp), %rsi
callq 0xb526
testl %eax, %eax
jne 0xb51d
movl 0x8(%rsp), %eax
movl %eax, (%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x10(%rbx)
movl 0x1c(%rsp), %eax
movl %eax, 0x14(%rbx)
movl 0x20(%rsp), %eax
movl %eax, 0x18(%rbx)
movl 0x24(%rsp), %eax
movl %eax, 0x1c(%rbx)
cmpl $0x1, 0x50(%r14)
jne 0xb505
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x8(%rbx)
movl $0x0, 0x14(%rbx)
jmp 0xb513
movl $0x2, %eax
retq
movl 0x10(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0x14(%rsp), %eax
movl %eax, 0xc(%rbx)
movq $0x0, 0x20(%rbx)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xb58f
testq %rsi, %rsi
je 0xb58f
movq 0x1e8(%rdi), %rcx
testq %rcx, %rcx
je 0xb58f
cmpl %edx, 0x204(%rdi)
jle 0xb58f
movl %edx, %r8d
shll $0x5, %r8d
addl $0x20, %r8d
movq 0x210(%rdi), %rdi
movl $0x7, %eax
cmpl 0x24(%rdi), %r8d
jg 0xb58f
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 0xd0e2
xorl %eax, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0xb5f9
testl %ecx, %ecx
js 0xb5f9
movq %rdi, %r14
cmpl %ecx, 0x204(%rdi)
jle 0xb5f9
movq %rsi, %rbx
movl %edx, (%rsi)
movl %ecx, 0x4(%rsi)
movq 0x1f8(%r14), %rax
movl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
movl 0x10(%rax,%rcx,8), %eax
movl %eax, 0x8(%rsi)
movl %eax, 0xc(%rsi)
leal -0x1(%rdx), %eax
cmpl $0x2, %eax
jae 0xb5e1
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb686
jmp 0xb5f5
movl $0x2, %eax
testl %edx, %edx
jne 0xb5f5
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb614
testl %eax, %eax
je 0xb601
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xb7c0
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x18, %rsp
movl %edx, 0xc(%rsp)
movq %rsi, %rbx
movq %rdi, 0x10(%rsp)
movq 0x1e8(%rdi), %r12
movl 0x14(%rsi), %eax
xorl %r13d, %r13d
testl %r13d, %r13d
jne 0xb8d2
movl 0x18(%rbx), %ecx
cmpl %ecx, %eax
jae 0xb8de
movl %eax, %edx
incl %eax
movzbl (%r12,%rdx), %r14d
xorl %r13d, %r13d
cmpl $0x20, %r14d
jae 0xb868
movl %eax, %r15d
xorl %eax, %eax
jmp 0xb891
movl %r14d, %esi
shrl $0x5, %esi
leal (%rsi,%rax), %r15d
cmpl %ecx, %r15d
jbe 0xb881
movl $0xa, %ebp
xorl %r13d, %r13d
jmp 0xb8c6
movl %eax, %edi
addq %r12, %rdi
callq 0xf16e
addl $0x7, %eax
shrl $0x3, %eax
andl $0x1f, %r14d
cmpl $0x2, %r14d
je 0xb8b7
cmpl $0x1, %r14d
je 0xb8b0
testl %r14d, %r14d
jne 0xb8be
movb $0x1, %cl
movl $0x1, %r13d
jmp 0xb8b2
movb $0x1, %cl
movl %r15d, %eax
jmp 0xb8c8
addl %r15d, %eax
movb $0x1, %cl
jmp 0xb8c8
movl $0x9, %ebp
movl %r15d, %eax
xorl %ecx, %ecx
testb %cl, %cl
jne 0xb83b
jmp 0xb911
cmpl $0x0, 0xc(%rsp)
je 0xb8e5
movl %eax, 0x14(%rbx)
jmp 0xb8e8
movl $0xa, %ebp
jmp 0xb911
movl %eax, 0x18(%rbx)
movl 0x14(%rbx), %eax
movl 0x18(%rbx), %ecx
movl $0x7, %ebp
cmpl %eax, %ecx
jbe 0xb911
movq %rax, %rdx
movq 0x10(%rsp), %rsi
addq 0x1e8(%rsi), %rdx
movq %rdx, 0x28(%rbx)
subl %eax, %ecx
movl %ecx, 0x20(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsImageStd.cpp
// Function: CCapsImageStd::ReadSampleInit(ImageStreamInfo*)
int CCapsImageStd::ReadSampleInit(PIMAGESTREAMINFO pstr)
{
	// signal on stream end
	if (pstr->readend)
		return 1;

	// support sample looping if looping is allowed and last sample size is undefined
	if (pstr->allowloop && !pstr->streambc) {
		// set countdown values same as the original sample size
		pstr->remstreambc=pstr->samplebc;
		pstr->remsamplebc=pstr->samplebc;

		// reset reading the actual sample data part
		pstr->sampleofs=0;
		pstr->samplemask=0x80;
	} else {
		// get current encoding mode
		int setencmode=pstr->setencmode;
		int actenctype=pstr->actenctype;

		// get next sample, signal on error
		if (GetSample(pstr) != imgeOk)
			return 1;

		// signal on stream end
		if (pstr->readend)
			return 1;

		// signal on any encoding change
		if (pstr->setencmode != setencmode)
			return 1;

		if (pstr->actenctype != actenctype)
			return 1;
	}

	// no processing change required
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl $0x1, %ebx
cmpl $0x0, 0x3c(%rsi)
jne 0xba23
movq %rsi, %r14
cmpl $0x0, 0x44(%rsi)
je 0xb9de
cmpl $0x0, 0x4c(%r14)
je 0xba07
movl 0xc(%r14), %ebp
movl 0x48(%r14), %r15d
movq %r14, %rsi
callq 0xb922
testl %eax, %eax
jne 0xba23
cmpl $0x0, 0x3c(%r14)
jne 0xba23
cmpl %r15d, 0x48(%r14)
jne 0xba23
cmpl %ebp, 0xc(%r14)
je 0xba21
jmp 0xba23
movl 0x50(%r14), %eax
movl %eax, 0x54(%r14)
movl %eax, 0x58(%r14)
movabsq $0x8000000000, %rax     # imm = 0x8000000000
movq %rax, 0x5c(%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
xorl %ebp, %ebp
xorl %r12d, %r12d
testl %r15d, %r15d
jle 0xbb03
cmpl $0x0, 0x54(%rbx)
jne 0xba68
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb9bc
testl %eax, %eax
jne 0xbb03
movl 0x54(%rbx), %ecx
movl 0x58(%rbx), %eax
testl %eax, %eax
sete %dl
testl %ecx, %ecx
sete %sil
orb %dl, %sil
je 0xba83
movl %r15d, %r10d
jmp 0xbaf8
movl 0x5c(%rbx), %edx
movl 0x60(%rbx), %r8d
movq 0x68(%rbx), %rsi
movzbl (%rsi,%rdx), %r9d
movl %eax, %edi
xorl %r10d, %r10d
testl %r8d, %r9d
setne %r11b
decl %edi
je 0xbab1
cmpl $0x1, %r8d
ja 0xbac5
incl %edx
leaq (%rsi,%rdx), %r8
jmp 0xbab9
movl 0x50(%rbx), %edi
xorl %edx, %edx
movq %rsi, %r8
movzbl (%r8), %r9d
movl $0x80, %r8d
jmp 0xbac8
shrl %r8d
movb %r11b, %r10b
leal (%r10,%r12,2), %r12d
leal -0x1(%rcx), %r11d
leal -0x1(%r15), %r10d
incl %ebp
cmpl $0x1, %ecx
je 0xbaea
movl %r11d, %ecx
cmpl $0x1, %r15d
movl %r10d, %r15d
jg 0xba95
movl %r11d, 0x54(%rbx)
movl %edi, 0x58(%rbx)
movl %edx, 0x5c(%rbx)
movl %r8d, 0x60(%rbx)
movl %r10d, %r15d
testl %eax, %eax
jne 0xba46
movl %r12d, 0x40(%rbx)
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0xbf6d
movl 0x21c(%r14), %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0xba30
movl %eax, %r15d
movl 0x21c(%r14), %ebx
testl %eax, %eax
jle 0xbf64
movq %r12, %rax
movl %r15d, %r12d
subl %ebp, %r12d
jle 0xbf5e
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 0xbf64
subl %r15d, %ebp
movq %rax, %r12
cmpl %r15d, %ebx
je 0xbecf
movl 0x80(%r12), %eax
testl %eax, %eax
jne 0xbfa0
cmpl $0x0, 0x7c(%r12)
je 0xbfa0
cmpl $0x0, 0x8(%rsp)
je 0xbfa0
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_O1/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 0xc243
movl 0x54(%rbx), %r15d
movq %rdi, (%rsp)
movq %rbx, %rsi
callq 0xb9bc
cmpl $0x1, 0xc(%rbx)
sete %cl
shll %cl, %r15d
movl %r15d, %r14d
subl %r13d, %r14d
jle 0xc239
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 0xf18c
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 0xc243
subl %r15d, %r13d
movq (%rsp), %rdi
xorl %r14d, %r14d
movl 0x80(%rbx), %eax
testl %eax, %eax
jne 0xc26f
testl %r14d, %r14d
je 0xc26f
cmpl $0x0, 0x7c(%rbx)
je 0xc26f
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_O1/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 0xc392
movl %eax, %ebp
testl %eax, %eax
jne 0xc37e
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 0xc36e
movl 0x8c(%rsp), %eax
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
jae 0xc336
movl 0x54(%rsp), %eax
movl 0x48(%rsp), %edx
decl %edx
cmpl $0x2, %edx
setb %sil
cmpl $0x1, 0xc(%rsp)
sete %cl
andb %sil, %cl
shll %cl, %eax
movl 0x1c(%rsp), %ecx
cmpl 0x84(%rsp), %ecx
jne 0xc356
cmpl $0x2, %edx
setb %dl
cmpl $0x1, 0xc(%rsp)
movl 0x50(%rsp), %esi
sete %cl
andb %dl, %cl
shll %cl, %esi
addl %esi, %r13d
jmp 0xc356
testl %eax, %eax
jne 0xc37e
movl 0x54(%rsp), %eax
movl 0x48(%rsp), %ecx
decl %ecx
cmpl $0x2, %ecx
setb %dl
cmpl $0x1, 0xc(%rsp)
sete %cl
andb %dl, %cl
shll %cl, %eax
addl %eax, %r12d
movq %r14, %rdi
movq %r15, %rsi
callq 0xb922
testl %eax, %eax
je 0xc2d6
jmp 0xc37e
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
// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
cmpl $0x0, 0x44(%rsi)
je 0xc452
movq %rdi, %r14
movq %rsp, %rdi
movl $0xa8, %edx
movq %rbx, %rsi
callq 0x4190
xorl %eax, %eax
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %ecx, %ecx
cmpl $0x0, 0x3c(%rsp)
jne 0xc469
movl (%rsp), %edx
movl 0x1c(%rsp), %r15d
movl 0x50(%rsp), %r13d
cmpl $0x2, %edx
je 0xc3fb
cmpl $0x1, %edx
jne 0xc406
testl %r12d, %r12d
je 0xc40c
movl $0x1, %r12d
jmp 0xc427
testl %ebp, %ebp
je 0xc40c
cmpl $0x0, 0x4c(%rsp)
je 0xc427
movl %eax, %r13d
movl %ecx, %r15d
cmpl $0x0, 0x4c(%rsp)
je 0xc431
incl %ebp
movq %r14, %rdi
movq %rsp, %rsi
callq 0xb922
testl %eax, %eax
sete %dl
jmp 0xc43e
xorl %edx, %edx
movl %eax, %r13d
movl %ecx, %r15d
jmp 0xc43e
testl %r12d, %r12d
je 0xc44a
xorl %edx, %edx
movl $0x1, %r12d
movl %r13d, %eax
movl %r15d, %ecx
testb %dl, %dl
jne 0xc3cc
jmp 0xc490
movl $0x1, %r12d
jmp 0xc413
movq $0x0, 0x84(%rbx)
movl $0x0, 0x8c(%rbx)
jmp 0xc48c
movl %ecx, 0x84(%rbx)
movl %eax, 0x88(%rbx)
cmpl $0x1, %r12d
movl $0x2, %ecx
sbbl $0x0, %ecx
testl %eax, %eax
cmovel %eax, %ecx
movl %ecx, 0x8c(%rbx)
xorl %eax, %eax
jmp 0xc495
movl $0x2, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xc534
pushq %rbp
pushq %rbx
subq $0xa8, %rsp
movl %edx, %ebp
movl %esi, %ecx
movq %rdi, %rbx
movq %rsp, %rsi
xorl %edx, %edx
callq 0xb590
testl %eax, %eax
jne 0xc52a
movl 0x1d8(%rbx), %edx
xorl %r9d, %r9d
cmpl $0x0, 0x1dc(%rbx)
sete %r9b
movq %rsp, %rsi
movq %rbx, %rdi
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0xbe10
testl %eax, %eax
jne 0xc52a
movl 0x80(%rsp), %ecx
movl $0x2, %eax
cmpl %ebp, %ecx
jne 0xc52a
movl 0x70(%rsp), %eax
movl %eax, 0x1d8(%rbx)
addl %ecx, 0x1dc(%rbx)
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %rbp
retq
xorl %eax, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xc7aa
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 0xc6f8
movl 0x94(%r14), %ecx
testl %ecx, %ecx
je 0xc715
cltd
idivl %ecx
testl %edx, %edx
je 0xc71f
incl %eax
subl %edx, %ecx
xorl %ebp, %ebp
cmpl $0x2, (%r14)
cmovel %ecx, %ebp
jmp 0xc721
xorl %ebp, %ebp
movq %r14, %rsi
xorl %edx, %edx
callq 0xc9ac
cmpl $0x2, (%r14)
jne 0xc72b
movl 0x90(%r14), %ebp
subl %ebx, %ebp
jmp 0xc72b
movl $0x2, %eax
jmp 0xc7a0
xorl %ebp, %ebp
movq %r14, %rsi
movl %eax, %edx
callq 0xc9ac
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 0xbe10
testl %eax, %eax
jne 0xc7a0
movl 0x80(%r14), %ecx
movl $0x2, %eax
cmpl %ebx, %ecx
jne 0xc7a0
movl 0x70(%r14), %eax
movl %eax, 0x1d8(%r15)
addl %ecx, 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
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movl %ecx, %ebx
movq %rdx, %r14
movq %rdi, %r15
testl %r8d, %r8d
je 0xc7cd
movl 0x90(%rsi), %edx
cmpl %ebx, %edx
cmovgel %ebx, %edx
subl %edx, %ebx
jmp 0xc7df
movl 0x90(%r14), %eax
cmpl %ebx, %eax
cmovgel %ebx, %eax
subl %eax, %ebx
movl %ebx, %edx
movl %eax, %ebx
movq %r15, %rdi
callq 0xc6b4
testl %eax, %eax
jne 0xc813
movl $0x1, 0x1e0(%r15)
movl 0x1d8(%r15), %eax
movl %eax, 0x1e4(%r15)
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0xc6b4
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x86b2
movl $0x0, 0x20(%rbx)
movl $0x7, 0x84(%rbx)
movl $0x1, 0x8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x86b2
movl $0x0, 0x20(%rbx)
movl $0x7, 0x84(%rbx)
movl $0x1, 0x8(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x8706
movl $0x1, %ebp
testl %eax, %eax
jne 0xce6d
movl 0x10(%r15), %eax
notl %eax
andl $0x1, %eax
movl %eax, 0x8(%rbx)
movq %r14, %rdi
callq 0x8822
movl %eax, 0x20(%rbx)
movq %rbx, %rdi
movl $0x1, %esi
callq 0xce9a
movl %eax, %ecx
movl $0x2, %ebp
xorl %eax, %eax
cmpl $0x8, %ecx
je 0xce8f
movq %r14, %rdi
callq 0x86b2
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_O1/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 0x881a
xorl %ebx, %ebx
testl %eax, %eax
je 0xd097
movl 0x84(%r15), %eax
movl $0x7, 0x84(%r15)
cmpl $0xa, %eax
jne 0xd097
movl 0x94(%r15), %ebp
testl %ebp, %ebp
je 0xd097
movq %r14, %rdi
callq 0x882c
movl 0x20(%r15), %ebx
subl %eax, %ebx
cmpl %ebp, %ebx
cmovgel %ebp, %ebx
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x8800
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsLoader.cpp
// Function: CCapsLoader::GetChunkType(CapsChunk*)
int CCapsLoader::GetChunkType(PCAPSCHUNK pc)
{
	int pos;

	for (pos=0; chunklist[pos].name; pos++)
		if (!memcmp(chunklist[pos].name, pc->cg.file.name, sizeof(pc->cg.file.name)))
			break;

	return pc->type=chunklist[pos].type;
}

// Assembly:
movq 0xc545(%rip), %rcx      # 0x195f0
leaq 0xc53e(%rip), %rax      # 0x195f0
testq %rcx, %rcx
je 0xd0db
movl (%rcx), %ecx
cmpl 0x4(%rdi), %ecx
je 0xd0db
leaq 0xc53b(%rip), %rcx      # 0x19600
movq %rcx, %rax
movq (%rcx), %rcx
testq %rcx, %rcx
je 0xd0db
movl (%rcx), %edx
leaq 0x10(%rax), %rcx
cmpl 0x4(%rdi), %edx
jne 0xd0c5
movl 0x8(%rax), %eax
movl %eax, (%rdi)
retq
nop