LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: OpenFodder[P]SOS_Unpacker/capsimg/Core/CRC.cpp
// Function: CalcCRC16(unsigned char*, int, unsigned int)
UDWORD CalcCRC16(PUBYTE buf, int len, UDWORD seed)
{
	UWORD crc=(UWORD)seed;

	while (len--)
		crc=crctab_ccitt[*buf++^(crc>>8)] ^ (crc << 8);

	return crc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl -0x10(%rbp), %eax
movw %ax, -0x12(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0xc(%rbp)
cmpl $0x0, %eax
je 0x5a2d
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movzbl (%rax), %eax
movzwl -0x12(%rbp), %ecx
sarl $0x8, %ecx
xorl %ecx, %eax
movslq %eax, %rcx
leaq 0x22716(%rip), %rax     # 0x28130
movzwl (%rax,%rcx,2), %eax
movzwl -0x12(%rbp), %ecx
shll $0x8, %ecx
xorl %ecx, %eax
movw %ax, -0x12(%rbp)
jmp 0x59e5
movzwl -0x12(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/Core/CRC.cpp
// Function: CalcCRC_ANSI(unsigned char*, int)
UWORD CalcCRC_ANSI(PUBYTE buf, int len)
{
	UWORD crc=0;

	while (len--)
		crc=crctab_ansi[*buf++^(crc>>8)] ^ (crc << 8);

	return crc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movw $0x0, -0xe(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0xc(%rbp)
cmpl $0x0, %eax
je 0x5a99
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movzbl (%rax), %eax
movzwl -0xe(%rbp), %ecx
sarl $0x8, %ecx
xorl %ecx, %eax
movslq %eax, %rcx
leaq 0x228aa(%rip), %rax     # 0x28330
movzwl (%rax,%rcx,2), %eax
movzwl -0xe(%rbp), %ecx
shll $0x8, %ecx
xorl %ecx, %eax
movw %ax, -0xe(%rbp)
jmp 0x5a51
movw -0xe(%rbp), %ax
popq %rbp
retq
nop
// File: OpenFodder[P]SOS_Unpacker/capsimg/Codec/CTRawCodec.cpp
// Function: CCTRawCodec::Free()
void CCTRawCodec::Free()
{
	FreeCompressedDensity();
	FreeUncompressedDensity();
	FreeCompressedTrack();
	FreeUncompressedTrack();
	Clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x10(%rbp)
callq 0x5bb0
movq -0x10(%rbp), %rdi
callq 0x5c00
movq -0x10(%rbp), %rdi
callq 0x5c50
movq -0x10(%rbp), %rdi
callq 0x5ca0
movq -0x10(%rbp), %rdi
callq 0x5ad0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/Codec/CTRawCodec.cpp
// Function: CCTRawCodec::FreeUncompressedTrack(CapsWH*)
void CCTRawCodec::FreeUncompressedTrack(PCAPSWH w)
{
	delete[] w->rawbuf;
	w->rawbuf = NULL;
	w->rawlen = 0;

	for (int trk = 0; trk < CAPS_MTRS; trk++) {
		w->trkbuf[trk] = NULL;
		w->trklen[trk] = 0;
	}

	w->trkcnt = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x5ce7
movq -0x18(%rbp), %rdi
callq 0x42e0
movq -0x8(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
movl $0x0, -0xc(%rbp)
cmpl $0x5, -0xc(%rbp)
jge 0x5d37
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq $0x0, 0x40(%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl $0x0, 0x68(%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x5d05
movq -0x8(%rbp), %rax
movl $0x0, 0x7c(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/Codec/CTRawCodec.cpp
// Function: CCTRawCodec::Swap(unsigned int*, int)
void CCTRawCodec::Swap(PUDWORD buf, int cnt)
{
#ifdef INTEL
	for (cnt >>= 2; cnt > 0; cnt--, buf++) {
		UDWORD src = *buf;
		UDWORD dst = _lrotl(src, 8) & 0x00ff00ff | _lrotr(src, 8) & 0xff00ff00;
		*buf = dst;
	}
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
sarl $0x2, %eax
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jle 0x5dbf
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
shll $0x8, %eax
movl -0x10(%rbp), %ecx
shrl $0x18, %ecx
orl %ecx, %eax
andl $0xff00ff, %eax         # imm = 0xFF00FF
movl -0x10(%rbp), %ecx
shrl $0x8, %ecx
movl -0x10(%rbp), %edx
shll $0x18, %edx
orl %edx, %ecx
andl $0xff00ff00, %ecx       # imm = 0xFF00FF00
orl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x8(%rbp)
jmp 0x5d64
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/Codec/CTRawCodecDecompressor.cpp
// Function: CCTRawCodec::DecompressDump(unsigned char*, int)
int CCTRawCodec::DecompressDump(PUBYTE buf, int len)
{
	CapsPack cpk;
	PCAPSPACK pk;

	// free all buffers
	Free();

	// check dump header
	int hlen = sizeof(CapsRaw);
	if (len < hlen)
		return imgeShort;
	wh.cr = *(PCAPSRAW)buf;
	Swap((PUDWORD)&wh.cr, sizeof(CapsRaw));

	// check dump size
	int tlen = wh.cr.time;
	int rlen = wh.cr.raw;
	if (len < hlen + tlen + rlen)
		return imgeShort;

	// check density information
	PUBYTE denbuf = buf + hlen;
	pk = GetPackHeader(&cpk, denbuf, tlen);
	if (!pk)
		return imgeDensityHeader;

	// check track information
	PUBYTE trkbuf = denbuf + tlen;
	pk = GetPackHeader(&cpk, trkbuf, rlen);
	if (!pk)
		return imgeTrackHeader;

	int err;

	// decompress density information
	wh.cdbuf = denbuf;
	wh.cdlen = tlen;
	if (!(err = DecompressDensity(1)))
		err = DecompressDensity();
	wh.cdbuf = NULL;
	if (err)
		return err;

	// decompress track data
	wh.ctbuf = trkbuf;
	wh.ctlen = rlen;
	if (!(err = DecompressTrack(1)))
		err = DecompressTrack();
	wh.ctbuf = NULL;

	return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x5b30
movl $0x8, -0x44(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x5e1b
movl $0x7, -0x4(%rbp)
jmp 0x5f69
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rdi)
addq $0x8, %rdi
movl $0x8, %esi
callq 0x5d50
movq -0x70(%rbp), %rax
movl 0x8(%rax), %ecx
movl %ecx, -0x48(%rbp)
movl 0xc(%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x1c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl -0x48(%rbp), %ecx
addl -0x4c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x5e64
movl $0x7, -0x4(%rbp)
jmp 0x5f69
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rsi
movl -0x48(%rbp), %edx
leaq -0x34(%rbp), %rdi
callq 0x5f80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x5e9a
movl $0xb, -0x4(%rbp)
jmp 0x5f69
movq -0x58(%rbp), %rax
movslq -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rsi
movl -0x4c(%rbp), %edx
leaq -0x34(%rbp), %rdi
callq 0x5f80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x5ed0
movl $0x8, -0x4(%rbp)
jmp 0x5f69
movq -0x70(%rbp), %rdi
movq -0x58(%rbp), %rax
movq %rax, 0x20(%rdi)
movl -0x48(%rbp), %eax
movl %eax, 0x28(%rdi)
movl $0x1, %esi
callq 0x6090
movl %eax, -0x64(%rbp)
cmpl $0x0, %eax
jne 0x5f02
movq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x6090
movl %eax, -0x64(%rbp)
movq -0x70(%rbp), %rax
movq $0x0, 0x20(%rax)
cmpl $0x0, -0x64(%rbp)
je 0x5f1c
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5f69
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rax
movq %rax, 0x88(%rdi)
movl -0x4c(%rbp), %eax
movl %eax, 0x90(%rdi)
movl $0x1, %esi
callq 0x61c0
movl %eax, -0x64(%rbp)
cmpl $0x0, %eax
jne 0x5f54
movq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x61c0
movl %eax, -0x64(%rbp)
movq -0x70(%rbp), %rax
movq $0x0, 0x88(%rax)
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/Codec/CTRawCodecDecompressor.cpp
// Function: CCTRawCodec::GetPackHeader(CapsPack*, unsigned char*, int)
PCAPSPACK CCTRawCodec::GetPackHeader(PCAPSPACK cpk, PUBYTE src, int slen)
{
	// check header size
	if (!src || slen<sizeof(CapsPack))
		return NULL;

	// check signature
	if (memcmp(src, CAPS_IDPACK, sizeof(cpk->sign)))
		return NULL;

	// copy header to result
	memcpy(cpk, src, sizeof(CapsPack));

	// change header crc to host format and check crc
	Swap(&cpk->hcrc, sizeof(cpk->hcrc));
	UDWORD hcrc = cpk->hcrc;
	cpk->hcrc = 0;
	if (hcrc != CalcCRC((PUBYTE)cpk, sizeof(CapsPack)))
		return NULL;

	// change header to host format
	Swap(PUDWORD(PUBYTE(cpk) + sizeof(cpk->sign)), sizeof(CapsPack) - sizeof(cpk->sign));

	// buffer length must match the size of header and compressed data size
	if ((UDWORD)slen != sizeof(CapsPack) + cpk->csize)
		return NULL;

	return cpk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x5fa4
movslq -0x1c(%rbp), %rax
cmpq $0x18, %rax
jae 0x5fb1
movq $0x0, -0x8(%rbp)
jmp 0x6077
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x4b434150, %eax       # imm = 0x4B434150
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x5fd4
movq $0x0, -0x8(%rbp)
jmp 0x6077
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
addq $0x14, %rdi
movl $0x4, %esi
callq 0x5d50
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x14(%rax)
movl -0x20(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movl $0x18, %esi
callq 0x5890
movl %eax, %ecx
movl -0x24(%rbp), %eax
cmpl %ecx, %eax
je 0x6040
movq $0x0, -0x8(%rbp)
jmp 0x6077
movq -0x10(%rbp), %rdi
addq $0x4, %rdi
movl $0x14, %esi
callq 0x5d50
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
addq $0x18, %rcx
cmpq %rcx, %rax
je 0x606f
movq $0x0, -0x8(%rbp)
jmp 0x6077
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/Codec/CTRawCodecDecompressor.cpp
// Function: CCTRawCodec::DecompressDensity(int)
int CCTRawCodec::DecompressDensity(int verify)
{
	CapsPack cpk;

	// in decompress mode free result buffer first
	if (!verify)
		FreeUncompressedDensity();

	// get density header
	PCAPSPACK pk = GetPackHeader(&cpk, wh.cdbuf, wh.cdlen);
	if (!pk)
		return imgeDensityHeader;

	// check crc on compressed data in verify mode
	if (verify)
		if (pk->ccrc != CalcCRC(wh.cdbuf + sizeof(CapsPack), pk->csize))
			return imgeDensityStream;

	// decompress density data
	PUDWORD dst = DecompressDensity(wh.cdbuf, wh.cdlen);
	int res = imgeOk;

	if (verify) {
		// in verify mode get density data in target format
		Swap(dst, pk->usize);

		// check crc on uncompressed data
		if (pk->ucrc != CalcCRC((PUBYTE)dst, pk->usize))
			res = imgeDensityData;

		// free density data
		delete[] dst;
	}	else {
		// in decompress mode save density data
		wh.timbuf = dst;
		wh.timlen = pk->usize >> 2;
	}

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x60b6
movq -0x50(%rbp), %rdi
callq 0x5c00
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rsi
movl 0x28(%rax), %edx
leaq -0x2c(%rbp), %rdi
callq 0x5f80
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x60e1
movl $0xb, -0x4(%rbp)
jmp 0x61b7
cmpl $0x0, -0x14(%rbp)
je 0x6120
movq -0x50(%rbp), %rax
movq -0x38(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl %ecx, -0x54(%rbp)
movq 0x20(%rax), %rdi
addq $0x18, %rdi
movq -0x38(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x5890
movl %eax, %ecx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
je 0x611e
movl $0xc, -0x4(%rbp)
jmp 0x61b7
jmp 0x6120
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rdi
movl 0x28(%rax), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x63c0
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x6198
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x5d50
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x5890
movl %eax, %ecx
movl -0x58(%rbp), %eax
cmpl %ecx, %eax
je 0x617f
movl $0xd, -0x44(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x6196
movq -0x60(%rbp), %rdi
callq 0x42e0
jmp 0x61b1
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rcx
movl 0x4(%rcx), %ecx
shrl $0x2, %ecx
movl %ecx, 0x18(%rax)
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
// File: OpenFodder[P]SOS_Unpacker/capsimg/Codec/CTRawCodecDecompressor.cpp
// Function: CCTRawCodec::CTR(CapsWH*, int)
UDWORD CCTRawCodec::CTR(PCAPSWH w, int size)
{
	UDWORD res = 0;

	for (; size; size--) {
		res <<= 8;
		res |= *w->ctmem++;
	}

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x694e
movl -0x10(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x90(%rcx)
movzbl (%rax), %eax
orl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x6912
movl -0x10(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSExit()
SDWORD __cdecl CAPSExit()
{
	for (PCDISKIMAGE &actimg : img) {
		delete actimg;
		actimg = NULL;
	}

	return imgeOk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x219c1(%rip), %rax     # 0x28550
movq %rax, -0x8(%rbp)
leaq 0x219b6(%rip), %rdi     # 0x28550
callq 0x8020
movq %rax, -0x10(%rbp)
leaq 0x219a6(%rip), %rdi     # 0x28550
callq 0x8050
movq %rax, -0x18(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x8080
testb $0x1, %al
jne 0x6bc6
jmp 0x6c04
leaq -0x10(%rbp), %rdi
callq 0x80c0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x6bee
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
leaq -0x10(%rbp), %rdi
callq 0x80e0
jmp 0x6bb3
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSAddImage()
SDWORD __cdecl CAPSAddImage()
{
	// use the base image type as a placeholder, returning errors for the functions
	PCDISKIMAGE pi = new CDiskImage;
	unsigned pos;

	for (pos = 0; pos < img.size(); pos++) {
		if (img[pos])
			continue;

		img[pos] = pi;
		return pos;
	}

	img.push_back(pi);

	return pos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0xb8, %edi
callq 0x4240
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x28(%rbp)
callq 0x17ae0
jmp 0x6c33
movq -0x28(%rbp), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq %rax, -0x30(%rbp)
leaq 0x21900(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x6ccc
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq 0x218e3(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
je 0x6c96
jmp 0x6cbe
movq -0x28(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0xb8, %esi
callq 0x4250
jmp 0x6ceb
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq 0x218a6(%rip), %rdi     # 0x28550
callq 0x8120
movq -0x38(%rbp), %rcx
movq %rcx, (%rax)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6ce2
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x6c42
leaq 0x2187d(%rip), %rdi     # 0x28550
leaq -0x10(%rbp), %rsi
callq 0x8140
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x4420
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSRemImage(int)
SDWORD __cdecl CAPSRemImage(SDWORD id)
{
	if (id<0 || (unsigned)id>=img.size())
		return -1;

	delete img[id];
	img[id]=NULL;
	return id;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x6d30
movl -0x8(%rbp), %eax
movq %rax, -0x10(%rbp)
leaq 0x21831(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x10(%rbp), %rax
cmpq %rcx, %rax
jb 0x6d39
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6d7d
movslq -0x8(%rbp), %rsi
leaq 0x2180c(%rip), %rdi     # 0x28550
callq 0x8120
movq (%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x6d60
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movslq -0x8(%rbp), %rsi
leaq 0x217e5(%rip), %rdi     # 0x28550
callq 0x8120
movq $0x0, (%rax)
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSLockImage(int, char*)
SDWORD __cdecl CAPSLockImage(SDWORD id, PCHAR name)
{
	if (id<0 || (unsigned)id >= img.size() || !img[id])
		return imgeOutOfRange;

	CapsFile cf;
	memset(&cf, 0, sizeof(CapsFile));
	cf.name=name;

	return CAPSLockImage(id, &cf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x6dda
movl -0x8(%rbp), %eax
movq %rax, -0x30(%rbp)
leaq 0x2179d(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x6dda
movslq -0x8(%rbp), %rsi
leaq 0x21781(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
jne 0x6de3
movl $0x3, -0x4(%rbp)
jmp 0x6e0a
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4140
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x8(%rbp), %edi
leaq -0x28(%rbp), %rsi
callq 0x6e20
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSLockImage(int, CapsFile*)
int CAPSLockImage(int id, PCAPSFILE pcf)
{
	int res = imgeOk;

	// get the possible image type used by the file
	int type = imgfactory.GetImageType(pcf);

	// check for file errors
	switch (type) {
		// problem with the file
		case citError:
			res = imgeOpen;
			break;

		// unknown file content
		case citUnknown:
			res = imgeType;
			break;
	}

	// file type is known and supported
	if (res == imgeOk) {
		PCDISKIMAGE newimg = imgfactory.CreateImage(type);

		if (newimg) {
			// delete the existing image class regardless of type since it can no longer be used
			CAPSRemImage(id);

			// add the new image class
			img[id] = newimg;

			// try to lock the file; this can still give an error as the checks will be more thorough
			res = img[id]->Lock(pcf);
		} else
			res = imgeGeneric;
	}

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x18f60
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
testl %eax, %eax
je 0x6e58
jmp 0x6e4e
movl -0x24(%rbp), %eax
subl $0x1, %eax
je 0x6e61
jmp 0x6e68
movl $0x5, -0x14(%rbp)
jmp 0x6e68
movl $0x6, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x6ed3
movl -0x18(%rbp), %edi
callq 0x19560
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x6eca
movl -0x4(%rbp), %edi
callq 0x6d00
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movslq -0x4(%rbp), %rsi
leaq 0x216b4(%rip), %rdi     # 0x28550
callq 0x8120
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movslq -0x4(%rbp), %rsi
leaq 0x2169d(%rip), %rdi     # 0x28550
callq 0x8120
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq (%rdi), %rax
callq *0x10(%rax)
movl %eax, -0x14(%rbp)
jmp 0x6ed1
movl $0x2, -0x14(%rbp)
jmp 0x6ed3
movl -0x14(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSLockImageMemory(int, unsigned char*, unsigned int, unsigned int)
SDWORD __cdecl CAPSLockImageMemory(SDWORD id, PUBYTE buffer, UDWORD length, UDWORD flag)
{
	if (id<0 || (unsigned)id >= img.size() || !img[id])
		return imgeOutOfRange;

	CapsFile cf;
	memset(&cf, 0, sizeof(CapsFile));
	cf.memmap=buffer;
	cf.size=length;
	cf.flag|=CFF_MEMMAP;
	if (flag & DI_LOCK_MEMREF)
		cf.flag|=CFF_MEMREF;

	return CAPSLockImage(id, &cf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x6f30
movl -0x8(%rbp), %eax
movq %rax, -0x38(%rbp)
leaq 0x21647(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x38(%rbp), %rax
cmpq %rcx, %rax
jae 0x6f30
movslq -0x8(%rbp), %rsi
leaq 0x2162b(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
jne 0x6f39
movl $0x3, -0x4(%rbp)
jmp 0x6f89
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4140
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
orq $0x2, %rax
movl %eax, -0x20(%rbp)
movl -0x18(%rbp), %eax
andq $0x80, %rax
cmpq $0x0, %rax
je 0x6f7a
movl -0x20(%rbp), %eax
orq $0x4, %rax
movl %eax, -0x20(%rbp)
movl -0x8(%rbp), %edi
leaq -0x30(%rbp), %rsi
callq 0x6e20
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSUnlockImage(int)
SDWORD __cdecl CAPSUnlockImage(SDWORD id)
{
	if (id<0 || (unsigned)id >= img.size() || !img[id])
		return imgeOutOfRange;

	int res=img[id]->Unlock();

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x6fe6
movl -0x8(%rbp), %eax
movq %rax, -0x18(%rbp)
leaq 0x21591(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x18(%rbp), %rax
cmpq %rcx, %rax
jae 0x6fe6
movslq -0x8(%rbp), %rsi
leaq 0x21575(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
jne 0x6fef
movl $0x3, -0x4(%rbp)
jmp 0x7011
movslq -0x8(%rbp), %rsi
leaq 0x21556(%rip), %rdi     # 0x28550
callq 0x8120
movq (%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSLoadImage(int, unsigned int)
SDWORD __cdecl CAPSLoadImage(SDWORD id, UDWORD flag)
{
	if (id<0 || (unsigned)id >= img.size() || !img[id])
		return imgeOutOfRange;

	int res=img[id]->LoadImage(flag);

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x7069
movl -0x8(%rbp), %eax
movq %rax, -0x18(%rbp)
leaq 0x2150e(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x18(%rbp), %rax
cmpq %rcx, %rax
jae 0x7069
movslq -0x8(%rbp), %rsi
leaq 0x214f2(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
jne 0x7072
movl $0x3, -0x4(%rbp)
jmp 0x7099
movslq -0x8(%rbp), %rsi
leaq 0x214d3(%rip), %rdi     # 0x28550
callq 0x8120
movq (%rax), %rdi
movl -0xc(%rbp), %esi
movq (%rdi), %rax
xorl %edx, %edx
callq *0x20(%rax)
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSLockTrackT0(CapsTrackInfo*, DiskTrackInfo*, unsigned int, unsigned int)
void CAPSLockTrackT0(PCAPSTRACKINFO pi, PDISKTRACKINFO pt, UDWORD ttype, UDWORD flag)
{
	pi->type=ttype;
	pi->cylinder=pt->cylinder;
	pi->head=pt->head;
	pi->sectorcnt=pt->sectorcnt;
	pi->sectorsize=0;
	pi->trackcnt=pt->trackcnt;
	pi->trackbuf=pt->trackbuf;
	pi->tracklen=(flag & DI_LOCK_TRKBIT) ? pt->trackbc : pt->tracklen;
	pi->timelen=pt->timecnt;
	pi->timebuf=pt->timebuf;

	for (int trk=0; trk < pt->trackcnt; trk++) {
		pi->trackdata[trk]=pt->trackdata[trk];
		pi->tracksize[trk]=pt->tracksize[trk];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x18(%rbp), %eax
andq $0x1000, %rax           # imm = 0x1000
cmpq $0x0, %rax
je 0x75ec
movq -0x10(%rbp), %rax
movl 0xe8(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x75f6
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl 0xa8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x64(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x7677
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x58(%rax,%rcx,8), %rdx
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, 0x24(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl 0x80(%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, 0x4c(%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x762b
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSLockTrackT1(CapsTrackInfoT1*, DiskTrackInfo*, unsigned int, unsigned int)
void CAPSLockTrackT1(PCAPSTRACKINFOT1 pi, PDISKTRACKINFO pt, UDWORD ttype, UDWORD flag)
{
	pi->type=ttype;
	pi->cylinder=pt->cylinder;
	pi->head=pt->head;
	pi->sectorcnt=pt->sectorcnt;
	pi->sectorsize=0;
	pi->trackbuf=pt->trackbuf;
	pi->tracklen=(flag & DI_LOCK_TRKBIT) ? pt->trackbc : pt->tracklen;
	pi->timelen=pt->timecnt;
	pi->timebuf=pt->timebuf;
	pi->overlap=pt->overlap;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x14(%rax)
movl -0x18(%rbp), %eax
andq $0x1000, %rax           # imm = 0x1000
cmpq $0x0, %rax
je 0x76fe
movq -0x10(%rbp), %rax
movl 0xe8(%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x7708
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl 0xa8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x24(%rax)
movq -0x10(%rbp), %rax
movl 0xe0(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x2c(%rax)
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSLockTrackT2(CapsTrackInfoT2*, DiskTrackInfo*, unsigned int, unsigned int)
void CAPSLockTrackT2(PCAPSTRACKINFOT2 pi, PDISKTRACKINFO pt, UDWORD ttype, UDWORD flag)
{
	pi->type=ttype;
	pi->cylinder=pt->cylinder;
	pi->head=pt->head;
	pi->sectorcnt=pt->sectorcnt;
	pi->sectorsize=0;
	pi->trackbuf=pt->trackbuf;
	pi->tracklen=(flag & DI_LOCK_TRKBIT) ? pt->trackbc : pt->tracklen;
	pi->timelen=pt->timecnt;
	pi->timebuf=pt->timebuf;
	pi->overlap=pt->overlap;
	pi->startbit=pt->startbit;
	pi->wseed=pt->wseed;
	pi->weakcnt=pt->fdpsize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x14(%rax)
movl -0x18(%rbp), %eax
andq $0x1000, %rax           # imm = 0x1000
cmpq $0x0, %rax
je 0x77ce
movq -0x10(%rbp), %rax
movl 0xe8(%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x77d8
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl 0xa8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x24(%rax)
movq -0x10(%rbp), %rax
movl 0xe0(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x10(%rbp), %rax
movl 0xf0(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rax
movl 0xc4(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x10(%rbp), %rax
movl 0xd0(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x38(%rax)
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSUnlockTrack(int, unsigned int, unsigned int)
SDWORD __cdecl CAPSUnlockTrack(SDWORD id, UDWORD cylinder, UDWORD head)
{
	if (id<0 || (unsigned)id >= img.size() || !img[id])
		return imgeOutOfRange;

	PDISKTRACKINFO pt=img[id]->UnlockTrack(cylinder, head);

	return pt ? imgeOk : imgeOutOfRange;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x789c
movl -0x8(%rbp), %eax
movq %rax, -0x20(%rbp)
leaq 0x20cdb(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x20(%rbp), %rax
cmpq %rcx, %rax
jae 0x789c
movslq -0x8(%rbp), %rsi
leaq 0x20cbf(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
jne 0x78a5
movl $0x3, -0x4(%rbp)
jmp 0x78de
movslq -0x8(%rbp), %rsi
leaq 0x20ca0(%rip), %rdi     # 0x28550
callq 0x8120
movq (%rax), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
xorl %ecx, %ecx
callq 0x17f50
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdx
movl $0x3, %eax
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSUnlockAllTracks(int)
SDWORD __cdecl CAPSUnlockAllTracks(SDWORD id)
{
	if (id<0 || (unsigned)id >= img.size() || !img[id])
		return imgeOutOfRange;

	img[id]->UnlockTrack();

	return imgeOk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x7936
movl -0x8(%rbp), %eax
movq %rax, -0x10(%rbp)
leaq 0x20c41(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x10(%rbp), %rax
cmpq %rcx, %rax
jae 0x7936
movslq -0x8(%rbp), %rsi
leaq 0x20c25(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
jne 0x793f
movl $0x3, -0x4(%rbp)
jmp 0x7960
movslq -0x8(%rbp), %rsi
leaq 0x20c06(%rip), %rdi     # 0x28550
callq 0x8120
movq (%rax), %rdi
xorl %esi, %esi
callq 0x17e50
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSGetVersionInfo(void*, unsigned int)
SDWORD __cdecl CAPSGetVersionInfo(PVOID pversioninfo, UDWORD flag)
{
	if (!pversioninfo)
		return imgeGeneric;

	// structure revision is zero, unless newer one requested
	unsigned rev=0;
	if (flag & DI_LOCK_TYPE)
		rev=*(PUDWORD)pversioninfo;

	// if unsupported type set the highest supported version
	if (rev > 0) {
		*(PUDWORD)pversioninfo=0;
		return imgeUnsupportedType;
	}

	// clear structure
	memset(pversioninfo, 0, sizeversioninfo[rev]);

	// get the correct structure
	switch (rev) {
		case 0:
			CAPSGetVersionInfoT0((PCAPSVERSIONINFO)pversioninfo);
			break;
	}

	return imgeOk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x79af
movl $0x2, -0x4(%rbp)
jmp 0x7a1b
movl $0x0, -0x18(%rbp)
movl -0x14(%rbp), %eax
andq $0x200, %rax            # imm = 0x200
cmpq $0x0, %rax
je 0x79ce
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jbe 0x79e7
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl $0xf, -0x4(%rbp)
jmp 0x7a1b
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %ecx
leaq 0x1f879(%rip), %rax     # 0x27270
movslq (%rax,%rcx,4), %rdx
xorl %esi, %esi
callq 0x4140
movl -0x18(%rbp), %eax
testl %eax, %eax
jne 0x7a14
jmp 0x7a0b
movq -0x10(%rbp), %rdi
callq 0x7a30
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSGetInfo(void*, int, unsigned int, unsigned int, unsigned int, unsigned int)
SDWORD __cdecl CAPSGetInfo(PVOID pinfo, SDWORD id, UDWORD cylinder, UDWORD head, UDWORD inftype, UDWORD infid)
{
	if (!pinfo)
		return imgeGeneric;

	if (id<0 || (unsigned)id >= img.size() || !img[id])
		return imgeOutOfRange;

	PDISKIMAGEINFO pd = img[id]->GetInfo();
	PDISKTRACKINFO pt = img[id]->GetTrack(cylinder, head);

	int res=imgeUnsupportedType;

	switch (inftype) {
		case cgiitSector:
			res=CAPSGetSectorInfo((PCAPSSECTORINFO)pinfo, pd, pt, infid);
			break;

		case cgiitWeak:
			res=CAPSGetWeakInfo((PCAPSDATAINFO)pinfo, pd, pt, infid);
			break;

		case cgiitRevolution:
			res = CAPSGetRevolutionInfo((PCAPSREVOLUTIONINFO)pinfo, pd, pt, infid);
			break;
	}

	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x7a90
movl $0x2, -0x4(%rbp)
jmp 0x7b8d
cmpl $0x0, -0x14(%rbp)
jl 0x7acb
movl -0x14(%rbp), %eax
movq %rax, -0x48(%rbp)
leaq 0x20aac(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0x7acb
movslq -0x14(%rbp), %rsi
leaq 0x20a90(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
jne 0x7ad7
movl $0x3, -0x4(%rbp)
jmp 0x7b8d
movslq -0x14(%rbp), %rsi
leaq 0x20a6e(%rip), %rdi     # 0x28550
movq %rdi, -0x58(%rbp)
callq 0x8120
movq (%rax), %rdi
callq 0x81b0
movq -0x58(%rbp), %rdi
movq %rax, -0x30(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x8120
movq (%rax), %rdi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x182b0
movq %rax, -0x38(%rbp)
movl $0xf, -0x3c(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x4c(%rbp)
subl $0x1, %eax
je 0x7b3e
jmp 0x7b2a
movl -0x4c(%rbp), %eax
subl $0x2, %eax
je 0x7b57
jmp 0x7b34
movl -0x4c(%rbp), %eax
subl $0x3, %eax
je 0x7b70
jmp 0x7b87
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x7ba0
movl %eax, -0x3c(%rbp)
jmp 0x7b87
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x7cf0
movl %eax, -0x3c(%rbp)
jmp 0x7b87
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x7dc0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSGetSectorInfo(CapsSectorInfo*, DiskImageInfo*, DiskTrackInfo*, unsigned int)
int CAPSGetSectorInfo(PCAPSSECTORINFO pi, PDISKIMAGEINFO pd, PDISKTRACKINFO pt, UDWORD infid)
{
	memset(pi, 0, sizeof(CapsSectorInfo));

	if (!pt)
		return imgeOutOfRange;

	if (pt->sipsize <= 0 || !pt->sip)
		return imgeOutOfRange;

	if (infid >= (unsigned)pt->sipsize)
		return imgeOutOfRange;

	PDISKSECTORINFO si=pt->sip+infid;

	pi->descdatasize=si->descdatasize;
	pi->descgapsize=si->descgapsize;
	pi->datasize=si->datasize;
	pi->gapsize=si->gapsize;
	pi->datastart=si->datastart;
	pi->gapstart=si->gapstart;
	pi->gapsizews0=si->gapsizews0;
	pi->gapsizews1=si->gapsizews1;
	pi->gapws0mode=si->gapws0mode;
	pi->gapws1mode=si->gapws1mode;
	pi->celltype=si->celltype;
	pi->enctype=si->enctype;

	return imgeOk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x4140
cmpq $0x0, -0x20(%rbp)
jne 0x7bda
movl $0x3, -0x4(%rbp)
jmp 0x7ce2
movq -0x20(%rbp), %rax
cmpl $0x0, 0xf4(%rax)
jle 0x7bf5
movq -0x20(%rbp), %rax
cmpq $0x0, 0xf8(%rax)
jne 0x7c01
movl $0x3, -0x4(%rbp)
jmp 0x7ce2
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xf4(%rcx), %eax
jb 0x7c1c
movl $0x3, -0x4(%rbp)
jmp 0x7ce2
movq -0x20(%rbp), %rax
movq 0xf8(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x30(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x30(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x30(%rbp), %rax
movl 0x24(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x30(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x30(%rbp), %rax
movl 0x2c(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSGetWeakInfo(CapsDataInfo*, DiskImageInfo*, DiskTrackInfo*, unsigned int)
int CAPSGetWeakInfo(PCAPSDATAINFO pi, PDISKIMAGEINFO pd, PDISKTRACKINFO pt, UDWORD infid)
{
	memset(pi, 0, sizeof(CapsDataInfo));

	if (!pt)
		return imgeOutOfRange;

	if (pt->fdpsize <= 0 || !pt->fdp)
		return imgeOutOfRange;

	if (infid >= (unsigned)pt->fdpsize)
		return imgeOutOfRange;

	PDISKDATAMARK dm=pt->fdp+infid;

	pi->type=cditWeak;
	pi->start=dm->position;
	pi->size=dm->size;

	return imgeOk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x4140
cmpq $0x0, -0x20(%rbp)
jne 0x7d2a
movl $0x3, -0x4(%rbp)
jmp 0x7dac
movq -0x20(%rbp), %rax
cmpl $0x0, 0xd0(%rax)
jle 0x7d45
movq -0x20(%rbp), %rax
cmpq $0x0, 0xd8(%rax)
jne 0x7d4e
movl $0x3, -0x4(%rbp)
jmp 0x7dac
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xd0(%rcx), %eax
jb 0x7d66
movl $0x3, -0x4(%rbp)
jmp 0x7dac
movq -0x20(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSGetRevolutionInfo(CapsRevolutionInfo*, DiskImageInfo*, DiskTrackInfo*, unsigned int)
int CAPSGetRevolutionInfo(PCAPSREVOLUTIONINFO pi, PDISKIMAGEINFO pd, PDISKTRACKINFO pt, UDWORD infid)
{
	memset(pi, 0, sizeof(CapsRevolutionInfo));

	// set image data if image is valid
	if (pd) {
		// next, last and real revolution used by lock track
		pi->next = pd->nextrev;
		pi->last = pd->lastrev;
		pi->real = pd->realrev;
	}

	// set track data if track is valid
	if (pt) {
		// use the revolutions sampled for raw dumps, -1 (unlimited/randomized) otherwise
		pi->max = (pt->rawdump) ? pt->rawtrackcnt : -1;
	}

	return imgeOk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x4140
cmpq $0x0, -0x10(%rbp)
je 0x7e17
movq -0x10(%rbp), %rax
movl 0x34(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
cmpq $0x0, -0x18(%rbp)
je 0x7e48
movq -0x18(%rbp), %rax
cmpl $0x0, 0x44(%rax)
je 0x7e34
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x7e3e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x20(%rbp)
jmp 0x7e3e
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xc(%rax)
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSSetRevolution(int, unsigned int)
SDWORD __cdecl CAPSSetRevolution(SDWORD id, UDWORD value)
{
	if (id<0 || (unsigned)id >= img.size() || !img[id])
		return imgeOutOfRange;

	PDISKIMAGEINFO pd = img[id]->GetInfo();
	if (!pd)
		return imgeGeneric;

	// set revolution
	pd->nextrev = value;

	return imgeOk;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x7e99
movl -0x8(%rbp), %eax
movq %rax, -0x20(%rbp)
leaq 0x206de(%rip), %rdi     # 0x28550
callq 0x8100
movq %rax, %rcx
movq -0x20(%rbp), %rax
cmpq %rcx, %rax
jae 0x7e99
movslq -0x8(%rbp), %rsi
leaq 0x206c2(%rip), %rdi     # 0x28550
callq 0x8120
cmpq $0x0, (%rax)
jne 0x7ea2
movl $0x3, -0x4(%rbp)
jmp 0x7edf
movslq -0x8(%rbp), %rsi
leaq 0x206a3(%rip), %rdi     # 0x28550
callq 0x8120
movq (%rax), %rdi
callq 0x81b0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x7ece
movl $0x2, -0x4(%rbp)
jmp 0x7edf
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x34(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsAPI.cpp
// Function: CAPSGetImageTypeMemory(unsigned char*, unsigned int)
SDWORD __cdecl CAPSGetImageTypeMemory(PUBYTE buffer, UDWORD length)
{
	CapsFile cf;
	memset(&cf, 0, sizeof(CapsFile));
	cf.memmap = buffer;
	cf.size = length;
	cf.flag |= CFF_MEMMAP | CFF_MEMREF;

	// get the possible image type used by the file
	return imgfactory.GetImageType(&cf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4140
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
orq $0x6, %rax
movl %eax, -0x18(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x18f60
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT1_SpinupStart(CapsFdc*)
void FdcComT1_SpinupStart(PCAPSFDC pc)
{
	UDWORD lo=pc->lineout;

	// set motor line
	pc->lineout|=CAPSFDC_LO_MO;

	// if valid drive selected turn on its motor
	if (pc->driveprc)
		pc->driveprc->diskattr|=CAPSDRIVE_DA_MO;

	// set sr motor clear spin-up
	pc->r_st0=(pc->r_st0 & ~CAPSFDC_SR_SU_RT) | CAPSFDC_SR_MO;

	// reset spin-up counter
	pc->spinupcnt=0;

	// skip loop if no spin-up or motor running 
	if ((pc->r_command & DF_3) || (lo & CAPSFDC_LO_MO)) {
		pc->r_st0|=CAPSFDC_SR_SU_RT;
		pc->runstate+=2;
		return;
	}

	// set loop
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %ecx
orq $0x8, %rcx
movl %ecx, 0x24(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x100(%rax)
je 0x8ba3
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movl 0x20(%rax), %ecx
orq $0x4, %rcx
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
andq $-0x21, %rax
orq $0x80, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xa4(%rax)
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
andq $0x8, %rax
cmpq $0x0, %rax
jne 0x8be9
movl -0xc(%rbp), %eax
andq $0x8, %rax
cmpq $0x0, %rax
je 0x8c06
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
orq $0x20, %rcx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x2c(%rax)
jmp 0x8c13
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT1_SpinupLoop(CapsFdc*)
void FdcComT1_SpinupLoop(PCAPSFDC pc)
{
	// clock cycles to complete
	UDWORD cmax=pc->clockreq-pc->clockact;

	// if no drive selected run all cycles index can't happen
	if (!pc->driveprc) {
		FdcComIdle(pc, cmax);
		return;
	}

	// if index can't happen on enabled drive run all cycles
	PCAPSDRIVE pd=pc->driveprc;
	if ((pd->diskattr & CAPSDRIVE_DA_IPMASK) != CAPSDRIVE_DA_IPMASK) {
		FdcComIdle(pc, cmax);
		return;
	}

	// if index or spin-up event won't happen, run it all
	if ((pd->idistance+cmax<pd->clockrev) || (pc->spinupcnt+1 < pc->spinuplimit)){
		FdcComIdle(pc, cmax);
		return;
	}

	// cycles until index
	cmax=pd->clockrev-pd->idistance;

	// index and spin-up happens now, only run cycles until index
	if (FdcComIdle(pc, cmax) != cmax)
		return;

	// end loop, but only if wait was complete
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x8(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x100(%rax)
jne 0x8c5c
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
jmp 0x8cf5
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
andq $0x5, %rax
cmpq $0x5, %rax
je 0x8c8a
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
jmp 0x8cf5
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
addl -0xc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jb 0x8cb6
movq -0x8(%rbp), %rax
movl 0xa4(%rax), %eax
addl $0x1, %eax
movq -0x8(%rbp), %rcx
cmpl 0xa8(%rcx), %eax
jge 0x8cc4
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
jmp 0x8cf5
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x18(%rbp), %rcx
subl 0x24(%rcx), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xae40
cmpl -0xc(%rbp), %eax
je 0x8ce8
jmp 0x8cf5
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/CapsFDCEmulator.cpp
// Function: FdcComT1_StepStart(CapsFdc*)
void FdcComT1_StepStart(PCAPSFDC pc)
{
	// pre-process step
	switch ((pc->r_command>>4) & 0xf) {
		// restore
		case 0x0:
			// move from track#255 to 0 (ie step-out until stopped)
			pc->r_track=0xff;
			pc->r_data=0;
			break;

		// seek, step
		case 0x1:
		case 0x2:
		case 0x3:
			break;

		// step-in
		case 0x4:
		case 0x5:
			pc->lineout|=CAPSFDC_LO_DIRC;
			break;

		// step-out
		case 0x6:
		case 0x7:
			pc->lineout&=~CAPSFDC_LO_DIRC;
			break;

		default:
			NODEFAULT;
	}

	// set step
	pc->runstate++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
movl %eax, %ecx
movq %rcx, -0x10(%rbp)
subl $0x7, %eax
ja 0x8d6e
movq -0x10(%rbp), %rax
leaq 0x15331(%rip), %rcx     # 0x1e05c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movl $0xff, 0x40(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x48(%rax)
jmp 0x8d70
jmp 0x8d70
movq -0x8(%rbp), %rax
movl 0x24(%rax), %ecx
orq $0x10, %rcx
movl %ecx, 0x24(%rax)
jmp 0x8d70
movq -0x8(%rbp), %rax
movl 0x24(%rax), %ecx
andq $-0x11, %rcx
movl %ecx, 0x24(%rax)
jmp 0x8d70
jmp 0x8d70
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
popq %rbp
retq
nop