LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::FreeTrackData(DiskTrackInfo*)
void CDiskImage::FreeTrackData(PDISKTRACKINFO pti)
{
	// cancel if invalid track data
	if (!pti)
		return;

	if (pti->rawdump)
		delete[] pti->trackdata[0];

	// clear track data
	for (int trk=0; trk < CAPS_MTRS; trk++) {
		pti->trackdata[trk]=NULL;
		pti->tracksize[trk]=0;
	}

	// free track buffer
	pti->trackcnt=0;

	if (!pti->rawdump)
		delete[] pti->trackbuf;

	pti->trackbuf=NULL;
	pti->tracklen=0;

	// free data specific buffers
	FreeTrackFD(pti);
	FreeTrackSI(pti);
}

// Assembly:
testq %rdi, %rdi
je 0xee67
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x44(%rdi)
je 0xeddf
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0xeddf
callq 0x4280
xorps %xmm0, %xmm0
movups %xmm0, 0x84(%rbx)
movups %xmm0, 0x78(%rbx)
movups %xmm0, 0x68(%rbx)
movups %xmm0, 0x58(%rbx)
movl $0x0, 0x28(%rbx)
cmpl $0x0, 0x44(%rbx)
jne 0xee10
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0xee10
callq 0x4280
xorl %eax, %eax
movq %rax, 0x48(%rbx)
movl $0x0, 0x50(%rbx)
movq %rax, 0xd0(%rbx)
movq 0xd8(%rbx), %rdi
testq %rdi, %rdi
je 0xee35
callq 0x4280
movq $0x0, 0xd8(%rbx)
movl $0x0, 0xf4(%rbx)
movq 0xf8(%rbx), %rdi
testq %rdi, %rdi
je 0xee5b
callq 0x4280
movq $0x0, 0xf8(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::FreeTrackTiming(DiskTrackInfo*)
void CDiskImage::FreeTrackTiming(PDISKTRACKINFO pti)
{
	// cancel if invalid track data
	if (!pti)
		return;

	// free timing buffer
	pti->timecnt=0;
	delete [] pti->timebuf;
	pti->timebuf=NULL;

	// free raw timing buffer
	pti->rawtimecnt = 0;
	delete[] pti->rawtimebuf;
	pti->rawtimebuf = NULL;
}

// Assembly:
testq %rdi, %rdi
je 0xeec1
pushq %rbx
movq %rdi, %rbx
movl $0x0, 0xa8(%rdi)
movq 0xb0(%rdi), %rdi
testq %rdi, %rdi
je 0xee98
callq 0x4280
movq $0x0, 0xb0(%rbx)
movl $0x0, 0x34(%rbx)
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0xeeb8
callq 0x4280
movq $0x0, 0x38(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::FreeTrackFD(DiskTrackInfo*)
void CDiskImage::FreeTrackFD(PDISKTRACKINFO pti)
{
	// cancel if invalid track data
	if (!pti)
		return;

	// free flakey buffer
	pti->fdpsize=0;
	pti->fdpmax=0;
	delete [] pti->fdp;
	pti->fdp=NULL;
}

// Assembly:
testq %rdi, %rdi
je 0xeef3
pushq %rbx
movq %rdi, %rbx
movq $0x0, 0xd0(%rdi)
movq 0xd8(%rdi), %rdi
testq %rdi, %rdi
je 0xeee7
callq 0x4280
movq $0x0, 0xd8(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::FreeTrackSI(DiskTrackInfo*)
void CDiskImage::FreeTrackSI(PDISKTRACKINFO pti)
{
	// cancel if invalid track data
	if (!pti)
		return;

	// free sector info buffer
	pti->sipsize=0;
	delete [] pti->sip;
	pti->sip=NULL;
}

// Assembly:
testq %rdi, %rdi
je 0xef24
pushq %rbx
movq %rdi, %rbx
movl $0x0, 0xf4(%rdi)
movq 0xf8(%rdi), %rdi
testq %rdi, %rdi
je 0xef18
callq 0x4280
movq $0x0, 0xf8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::CreateDateTime(CapsDateTime*)
void CDiskImage::CreateDateTime(PCAPSDATETIME pcd)
{
	// cancel on error
	if (!pcd)
		return;

	// read OS time, since time_t won't work in a few decades... :)
	SYSTEMTIME st;
	GetLocalTime(&st);

	// create date
	UDWORD t=0;
	t+=st.wYear*10000;
	t+=st.wMonth*100;
	t+=st.wDay;
	pcd->date=t;

	// create time
	t=0;
	t+=st.wHour*10000000;
	t+=st.wMinute*100000;
	t+=st.wSecond*1000;
	t+=st.wMilliseconds%1000;
	pcd->time=t;
}

// Assembly:
testq %rdi, %rdi
je 0xefb2
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x11426
movzwl (%r14), %eax
imull $0x2710, %eax, %eax     # imm = 0x2710
movzwl 0x2(%r14), %ecx
imull $0x64, %ecx, %ecx
addl %eax, %ecx
movzwl 0x6(%r14), %eax
addl %ecx, %eax
movl %eax, (%rbx)
movzwl 0x8(%r14), %eax
imull $0x989680, %eax, %eax   # imm = 0x989680
movzwl 0xa(%r14), %ecx
imull $0x186a0, %ecx, %ecx    # imm = 0x186A0
addl %eax, %ecx
movzwl 0xc(%r14), %eax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
addl %ecx, %eax
movzwl 0xe(%r14), %ecx
movl %ecx, %edx
shrl $0x3, %edx
imull $0x20c5, %edx, %edx     # imm = 0x20C5
shrl $0x14, %edx
imull $0x3e8, %edx, %edx      # imm = 0x3E8
subl %edx, %ecx
movzwl %cx, %ecx
addl %eax, %ecx
movl %ecx, 0x4(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::DecodeDateTime(CapsDateTimeExt*, CapsDateTime*)
void CDiskImage::DecodeDateTime(PCAPSDATETIMEEXT dec, PCAPSDATETIME pcd)
{
	// cancel if no result buffer
	if (!dec)
		return;

	// clear result
	memset(dec, 0, sizeof(CapsDateTimeExt));

	// cancel if no source
	if (!pcd)
		return;

	// decode date
	UDWORD t=pcd->date;
	dec->year=t/10000;
	t%=10000;
	dec->month=t/100;
	t%=100;
	dec->day=t;

	// decode time;
	t=pcd->time;
	dec->hour=t/10000000;
	t%=10000000;
	dec->min=t/100000;
	t%=100000;
	dec->sec=t/1000;
	t%=1000;
	dec->tick=t;
}

// Assembly:
testq %rdi, %rdi
je 0xf043
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rdi)
movups %xmm0, (%rdi)
testq %rsi, %rsi
je 0xf043
movl (%rsi), %eax
movl $0xd1b71759, %ecx       # imm = 0xD1B71759
imulq %rax, %rcx
shrq $0x2d, %rcx
movl %ecx, (%rdi)
imull $0x2710, %ecx, %ecx     # imm = 0x2710
subl %ecx, %eax
imulq $0x28f5c29, %rax, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
movl %ecx, 0x4(%rdi)
imull $0x64, %ecx, %ecx
subl %ecx, %eax
movl %eax, 0x8(%rdi)
movl 0x4(%rsi), %eax
imulq $0x6b5fca6b, %rax, %rcx # imm = 0x6B5FCA6B
shrq $0x36, %rcx
movl %ecx, 0xc(%rdi)
imull $0x989680, %ecx, %ecx   # imm = 0x989680
subl %ecx, %eax
imulq $0x14f8b59, %rax, %rcx  # imm = 0x14F8B59
shrq $0x29, %rcx
movl %ecx, 0x10(%rdi)
imull $0x186a0, %ecx, %ecx    # imm = 0x186A0
subl %ecx, %eax
imulq $0x418938, %rax, %rcx   # imm = 0x418938
shrq $0x20, %rcx
movl %ecx, 0x14(%rdi)
imull $0x3e8, %ecx, %ecx      # imm = 0x3E8
subl %ecx, %eax
movl %eax, 0x18(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::CrcFile(CapsFile*)
UDWORD CDiskImage::CrcFile(PCAPSFILE pcf)
{
	UDWORD crc=0;

	// shortcut for memory files
	if (pcf->flag & CFF_MEMMAP) {
		if (!pcf->memmap || pcf->size<0)
			return crc;

		return CalcCRC(pcf->memmap, pcf->size);
	}

	// open file
	CCapsFile file;
	if (file.Open(pcf))
		return crc;

	int len=file.GetSize();

	if (len) {
		int bufsize=DEF_CRCBUF;
		PUBYTE buf=new UBYTE[bufsize];

		// calculate CRC32 on file
		while (len) {
			int size=len > bufsize ? bufsize : len;
			if (file.Read(buf, size) != size) {
				crc=0;
				break;
			}

			crc=CalcCRC32(buf, size, crc);
			len-=size;
		}

		delete [] buf;
	}

	return crc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testb $0x2, 0x10(%rdi)
jne 0xf107
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x8660
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8706
xorl %ebp, %ebp
testl %eax, %eax
jne 0xf137
leaq 0x8(%rsp), %rdi
callq 0x8822
movl %eax, %ebx
testl %eax, %eax
je 0xf137
movl $0x10000, %edi          # imm = 0x10000
callq 0x4040
movq %rax, %r14
xorl %r13d, %r13d
testl %ebx, %ebx
je 0xf12c
movl $0x10000, %eax          # imm = 0x10000
cmpl %eax, %ebx
movl $0x10000, %r12d         # imm = 0x10000
cmovll %ebx, %r12d
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x87e0
movl %eax, %r15d
xorl %ebp, %ebp
cmpl %r12d, %eax
jne 0xf0fd
movq %r14, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x50a2
movl %eax, %ebp
subl %r12d, %ebx
movl %ebp, %r13d
cmpl %r12d, %r15d
je 0xf0bb
jmp 0xf12f
movq 0x8(%rbx), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0xf141
movl 0x14(%rbx), %esi
testl %esi, %esi
js 0xf141
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x506f
movl %r13d, %ebp
movq %r14, %rdi
callq 0x4280
leaq 0x8(%rsp), %rdi
callq 0x8674
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf158
jmp 0xf158
jmp 0xf158
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x8674
movq %rbx, %rdi
callq 0x43a0
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::ReadValue(unsigned char*, int)
UDWORD CDiskImage::ReadValue(PUBYTE buf, int cnt)
{
	UDWORD val;

	for (val=0; cnt > 0; cnt--) {
		val<<=8;
		val|=*buf++;
	}

	return val;
}

// Assembly:
testl %esi, %esi
jle 0xf189
incl %esi
xorl %eax, %eax
shll $0x8, %eax
movzbl (%rdi), %ecx
incq %rdi
orl %ecx, %eax
decl %esi
cmpl $0x1, %esi
jg 0xf176
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::AddFD(DiskTrackInfo*, DiskDataMark*, int, int)
PDISKDATAMARK CDiskImage::AddFD(PDISKTRACKINFO pti, PDISKDATAMARK src, int size, int units)
{
	// cancel if nothing to add
	if (!src || size<=0)
		return NULL;

	// allocate and copy to buffer
	PDISKDATAMARK alloc=AllocFD(pti, size, units);
	if (alloc)
		memcpy(alloc, src, size*sizeof(DiskDataMark));

	return alloc;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edx, %ebp
testq %rsi, %rsi
sete %al
testl %edx, %edx
setle %dl
orb %al, %dl
je 0xf1a4
xorl %eax, %eax
jmp 0xf1d0
movq %rsi, %rbx
movl %ebp, %esi
movl %ecx, %edx
callq 0xf1d8
testq %rax, %rax
je 0xf1d0
movl %ebp, %ecx
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rdx
movq %rax, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4190
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::AllocFD(DiskTrackInfo*, int, int)
PDISKDATAMARK CDiskImage::AllocFD(PDISKTRACKINFO pti, int size, int units)
{
	// cancel if invalid allocation
	if (!pti)
		return NULL;

	// get buffer mark
	if (size <= 0)
		return pti->fdp+pti->fdpsize;

	// grow buffer if necessary
	if (pti->fdpsize+size > pti->fdpmax) {
		units+=pti->fdpsize+size;
		PDISKDATAMARK fdp=pti->fdp;
		pti->fdp=new DiskDataMark[units];
		if (pti->fdpsize)
			memcpy(pti->fdp, fdp, pti->fdpsize*sizeof(DiskDataMark));
		delete [] fdp;
		pti->fdpmax=units;
	}

	// allocate new data
	PDISKDATAMARK alloc=pti->fdp+pti->fdpsize;
	memset(alloc, 0, size*sizeof(DiskDataMark));
	pti->fdpsize+=size;
	return alloc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0xf294
movl %esi, %r14d
movq %rdi, %rbx
testl %esi, %esi
jle 0xf299
movslq 0xd0(%rbx), %r12
leal (%r12,%r14), %ebp
cmpl 0xd4(%rbx), %ebp
jle 0xf260
addl %edx, %ebp
movq 0xd8(%rbx), %r15
movslq %ebp, %rax
movl $0xc, %ecx
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x4040
movq %rax, 0xd8(%rbx)
testl %r12d, %r12d
je 0xf24d
shlq $0x2, %r12
leaq (%r12,%r12,2), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x4190
testq %r15, %r15
je 0xf25a
movq %r15, %rdi
callq 0x4280
movl %ebp, 0xd4(%rbx)
movslq 0xd0(%rbx), %rax
leaq (%rax,%rax,2), %r15
shlq $0x2, %r15
addq 0xd8(%rbx), %r15
movl %r14d, %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x4140
addl %r14d, 0xd0(%rbx)
jmp 0xf2af
xorl %r15d, %r15d
jmp 0xf2af
movslq 0xd0(%rbx), %rax
leaq (%rax,%rax,2), %r15
shlq $0x2, %r15
addq 0xd8(%rbx), %r15
movq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImage.cpp
// Function: CDiskImage::AllocTrackSI(DiskTrackInfo*)
void CDiskImage::AllocTrackSI(PDISKTRACKINFO pti)
{
	// cancel if invalid allocation
	if (!pti)
		return;

	FreeTrackSI(pti);

	// allocate buffer if needed
	if (pti->sectorcnt > 0) {
		int size=pti->sectorcnt;
		pti->sip=new DiskSectorInfo[size];
		pti->sipsize=size;
		memset(pti->sip, 0, size*sizeof(DiskSectorInfo));
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0xf32b
movq %rdi, %rbx
movl $0x0, 0xf4(%rdi)
movq 0xf8(%rdi), %rdi
testq %rdi, %rdi
je 0xf2e4
callq 0x4280
movq $0x0, 0xf8(%rbx)
movslq 0x18(%rbx), %r15
testq %r15, %r15
jle 0xf32b
movq %r15, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %r14
movq %r14, %rdi
callq 0x4040
movq %rax, 0xf8(%rbx)
movl %r15d, 0xf4(%rbx)
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x4140
popq %rbx
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImageFactory.cpp
// Function: CDiskImageFactory::GetImageType(CapsFile*)
int CDiskImageFactory::GetImageType(PCAPSFILE pcf)
{
	// error if file cannot be opened
	CCapsFile file;
	if (file.Open(pcf))
		return citError;

	// check IPF or CT Raw
	int type = IsCAPSImage(pcf);
	if (type != citUnknown)
		return type;

	// check KryoFlux stream cue
	type = IsKFStreamCue(pcf);
	if (type != citUnknown)
		return type;

	// check KryoFlux stream
	type = IsKFStream(pcf);
	if (type != citUnknown)
		return type;

	// at this point it's none of the supported image types
	return citUnknown;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
callq 0x8660
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8706
xorl %ebp, %ebp
testl %eax, %eax
jne 0xf3cb
movq %rbx, %rdi
callq 0xf3f4
movl %eax, %ebp
cmpl $0x1, %eax
jne 0xf3cb
movq %rbx, %rdi
callq 0xf4a6
movl %eax, %ebp
cmpl $0x1, %eax
jne 0xf3cb
movq %rbx, %rdi
callq 0xf54c
movl %eax, %ebp
movq %rsp, %rdi
callq 0x8674
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0xf3e0
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8674
movq %rbx, %rdi
callq 0x43a0
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImageFactory.cpp
// Function: CDiskImageFactory::IsCAPSImage(CapsFile*)
int CDiskImageFactory::IsCAPSImage(PCAPSFILE pcf)
{
	// try to parse CT Raw or IPF
	CCapsLoader cload;
	int res = cload.Lock(pcf);

	// parser succeeded, check type in more detail
	if (res == CCapsLoader::ccidCaps) {
		for (int run = 1; run;) {
			// read the next chunk after the header
			int type = cload.ReadChunk();

			switch (type) {
				// end of file or error
				case CCapsLoader::ccidEof:
				case CCapsLoader::ccidErrFile:
				case CCapsLoader::ccidErrType:
				case CCapsLoader::ccidErrShort:
				case CCapsLoader::ccidErrHeader:
				case CCapsLoader::ccidErrData:
					run = 0;
					continue;

				// track header is used by CT Raw
				case CCapsLoader::ccidTrck:
					return citCTRaw;

				// track image is used by IPF
				case CCapsLoader::ccidImge:
					return citIPF;

				// ignore other types
				default:
					continue;
			}
		}
	}

	// unknown or unsupported image type
	return citUnknown;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xf0, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xcd0c
movq %r14, %rdi
movq %rbx, %rsi
callq 0xcdf6
testl %eax, %eax
je 0xf425
movl $0x1, %ebx
jmp 0xf477
movl $0x1, %ecx
leaq 0x8(%rsp), %r14
movl %ecx, %ebp
testl %ecx, %ecx
je 0xf473
movq %r14, %rdi
xorl %esi, %esi
callq 0xce9a
movb $0x1, %dl
xorl %ecx, %ecx
leal -0x1(%rax), %esi
cmpl $0x6, %esi
jb 0xf46f
cmpl $0xb, %eax
je 0xf45c
cmpl $0xd, %eax
jne 0xf46a
movl $0x2, %ebx
jmp 0xf461
movl $0x3, %ebx
movl $0x1, %ecx
xorl %edx, %edx
jmp 0xf46f
movl $0x1, %ecx
testb %dl, %dl
jne 0xf42f
testl %ebp, %ebp
je 0xf41e
leaq 0x8(%rsp), %rdi
callq 0xcd92
movl %ebx, %eax
addq $0xf0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0xf491
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xcd92
movq %rbx, %rdi
callq 0x43a0
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImageFactory.cpp
// Function: CDiskImageFactory::IsKFStreamCue(CapsFile*)
int CDiskImageFactory::IsKFStreamCue(PCAPSFILE pcf)
{
	// error if file can't be opened
	CCapsFile file;
	if (file.Open(pcf))
		return citError;

	// the ID string must be within this area from the beginning of the file
	uint8_t buf[256];

	// remaining file size
	int frem = file.GetSize();

	// buffer allowed, with room for terminating 0
	int bufmax = sizeof(buf)-1;

	int readsize = std::min(frem, bufmax);

	// read from the beginning of the file, stop on error
	if (file.Read(buf, readsize) != readsize)
		return citError;

	// add terminating 0
	buf[readsize] = 0;

	// success, if ID text found in info
	if (strstr((char *)buf, KF_STREAM_CUE_ID))
		return citKFStreamCue;

	// unknown or unsupported image type
	return citUnknown;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
callq 0x8660
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8706
xorl %ebp, %ebp
testl %eax, %eax
jne 0xf51f
movq %rsp, %rdi
callq 0x8822
movl $0xff, %ebx
cmpl %ebx, %eax
cmovll %eax, %ebx
movq %rsp, %rdi
leaq 0x10(%rsp), %rsi
movl %ebx, %edx
callq 0x87e0
xorl %ebp, %ebp
cmpl %ebx, %eax
jne 0xf51f
movslq %ebx, %rax
movb $0x0, 0x10(%rsp,%rax)
leaq 0x2e97(%rip), %rsi      # 0x1239d
leaq 0x10(%rsp), %rdi
callq 0x4070
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
leal 0x1(,%rcx,4), %ebp
movq %rsp, %rdi
callq 0x8674
movl %ebp, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %rbp
retq
jmp 0xf539
jmp 0xf539
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8674
movq %rbx, %rdi
callq 0x43a0
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImageFactory.cpp
// Function: CDiskImageFactory::IsKFStream(CapsFile*)
int CDiskImageFactory::IsKFStream(PCAPSFILE pcf)
{
	// error if file can't be opened
	CCapsFile file;
	if (file.Open(pcf))
		return citError;

	C2OOBHdr oob;
	uint8_t buf[512];

	// remaining file size
	int frem = file.GetSize();

	// process the file as long as the data read is an OOB info area
	while (true) {
		// stop if OOB header is longer than the remaining file size
		int rlen = sizeof(oob);
		if (rlen > frem)
			break;

		// read OOB header, stop on error
		if (file.Read((PUBYTE)&oob, rlen) != rlen)
			return citError;

		// update the remaining file size
		frem -= rlen;

		// check that OOB is Info
		if (oob.sign != c2eOOB || oob.type != c2otInfo)
			break;

		// read info size value as little-endian
		uint8_t *po = (uint8_t *)&oob;
		int so = offsetof(C2OOBHdr, size);
		int infosize = po[so+1] << 8 | po[so];

		// stop if info size is 0 or larger than remaining file size or larger than the buffer
		if (!infosize || infosize > frem || infosize > sizeof(buf))
			break;
		
		// read info, stop on error
		if (file.Read(buf, infosize) != infosize)
			return citError;

		// update the remaining file size
		frem -= infosize;

		// success, if KryoFlux text found in info
		if (strstr((char *)buf, "KryoFlux"))
			return citKFStream;
	}

	// file reading stopped somewhere, type is unknown
	return citUnknown;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdi, %rbx
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x8660
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8706
xorl %r13d, %r13d
testl %eax, %eax
jne 0xf671
leaq 0x20(%rsp), %rdi
callq 0x8822
movl %eax, %ebp
leaq 0x20(%rsp), %r12
leaq 0x10(%rsp), %rbx
movl %r13d, %r15d
cmpl $0x10, %ebp
jge 0xf5ac
movl $0x3, %r14d
movl %r15d, %r13d
jmp 0xf614
movq %r12, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x87e0
xorl %r13d, %r13d
movl $0x1, %r14d
cmpl $0x10, %eax
jne 0xf614
addl $-0x10, %ebp
cmpb $0xd, 0x10(%rsp)
jne 0xf5a1
cmpb $0x4, 0x11(%rsp)
jne 0xf5a1
movq %r12, %rbx
movzwl 0x12(%rsp), %r12d
testl %r12d, %r12d
je 0xf603
movl %ebp, %eax
subl %r12d, %eax
movl %eax, 0xc(%rsp)
setl %al
cmpl $0x201, %r12d           # imm = 0x201
setae %cl
orb %al, %cl
je 0xf61b
movl $0x3, %r14d
movl %r15d, %r13d
movq %rbx, %r12
leaq 0x10(%rsp), %rbx
testl %r14d, %r14d
je 0xf599
jmp 0xf665
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movl %r12d, %edx
callq 0x87e0
cmpl %r12d, %eax
movq %rbx, %r12
leaq 0x10(%rsp), %rbx
jne 0xf614
leaq 0x30(%rsp), %rdi
leaq 0x2d50(%rip), %rsi      # 0x12394
callq 0x4070
xorl %r14d, %r14d
testq %rax, %rax
setne %r14b
movl $0x4, %eax
cmovnel %eax, %r15d
movl 0xc(%rsp), %ebp
jmp 0xf5a7
cmpl $0x3, %r14d
jne 0xf671
movl $0x1, %r13d
leaq 0x20(%rsp), %rdi
callq 0x8674
movl %r13d, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf696
jmp 0xf696
jmp 0xf696
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x8674
movq %rbx, %rdi
callq 0x43a0
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/CAPSImg/DiskImageFactory.cpp
// Function: CDiskImageFactory::CreateImage(int)
PCDISKIMAGE CDiskImageFactory::CreateImage(int diftype)
{
	PCDISKIMAGE pdi = NULL;

	// create the image class required
	switch (diftype) {
		case citIPF:
			pdi = new CCapsImageStd;
			break;

		case citCTRaw:
			pdi = new CCapsImage;
			break;

		case citKFStream:
			pdi = new CStreamImage;
			break;

		case citKFStreamCue:
			pdi = new CStreamCueImage;
			break;
	}

	return pdi;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
addl $-0x2, %edi
cmpl $0x3, %edi
ja 0xf732
leaq 0x2cb1(%rip), %rax      # 0x12370
movslq (%rax,%rdi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x230, %edi            # imm = 0x230
callq 0x4200
movq %rax, %rbx
movq %rax, %rdi
callq 0x9800
jmp 0xf734
movl $0xb8, %edi
callq 0x4200
movq %rax, %rbx
movq %rax, %rdi
callq 0x110f4
jmp 0xf734
movl $0xb8, %edi
callq 0x4200
movq %rax, %rbx
movq %rax, %rdi
callq 0x110b8
jmp 0xf734
movl $0x230, %edi            # imm = 0x230
callq 0x4200
movq %rax, %rbx
movq %rax, %rdi
callq 0x9800
leaq 0x9327(%rip), %rax      # 0x18a50
addq $0x10, %rax
movq %rax, (%rbx)
jmp 0xf734
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
jmp 0xf741
movq %rax, %r14
movl $0x230, %esi            # imm = 0x230
jmp 0xf755
jmp 0xf74d
movq %rax, %r14
movl $0xb8, %esi
movq %rbx, %rdi
callq 0x4210
movq %r14, %rdi
callq 0x43a0
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/Core/MemoryFile.cpp
// Function: CMemoryFile::Open(void*, unsigned long, unsigned int)
int CMemoryFile::Open(void *buf, size_t size, unsigned int mode)
{
	// reset buffers
	Clear(0);

	// create new buffer or reference user supplied buffer
	if (mode & BFFLAG_CREATE) {
		// create new buffer
		if (size) {
			// allocate initial buffer with the size specified when opening the file
			AllocBuffer(size);

			// copy buffer content if specified
			if (buf) {
				memcpy(filebuf[mtAlloc], buf, size*sizeof(uint8_t));
				filecount=size;
			}
		}

		// set class owned buffer
		filemt=mtAlloc;
	} else {
		// reference user supplied buffer
		if (size) {
			// error if buffer size is defined, but area is not
			if (!buf)
				return 1;
		} else
			buf=NULL;

		// set user buffer reference
		filemt=mtUser;
		filebuf[mtUser]=(uint8_t *)buf;
		filesize[mtUser]=size;
		filecount=size;
	}

	// rewind stream position
	filepos=0;

	// success
	fileopen=1;
	filemode=mode;

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rdi)
movl $0x2, 0x10(%rdi)
callq 0x4950
testb $0x2, %bl
jne 0xf8a2
testq %r15, %r15
je 0xf8d4
testq %r12, %r12
jne 0xf8d7
movl $0x1, %eax
jmp 0xf901
testq %r15, %r15
je 0xf8ca
movq %r14, %rdi
movq %r15, %rsi
callq 0xf90e
testq %r12, %r12
je 0xf8ca
movq 0x18(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x4190
movq %r15, 0x38(%r14)
movl $0x0, 0x10(%r14)
jmp 0xf8eb
xorl %r12d, %r12d
movl $0x1, 0x10(%r14)
movq %r12, 0x20(%r14)
movq %r15, 0x30(%r14)
movq %r15, 0x38(%r14)
movq $0x0, 0x40(%r14)
movl $0x1, 0x8(%r14)
movl %ebx, 0xc(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/Core/MemoryFile.cpp
// Function: CMemoryFile::AllocBuffer(unsigned long)
void CMemoryFile::AllocBuffer(size_t maxsize)
{
	if (filesize[mtAlloc] < maxsize) {
		maxsize+=DEF_MEMORYFILEALLOC;
		uint8_t *newfile=new uint8_t[maxsize];
		size_t oldcount=filecount;
		size_t oldpos=filepos;

		if (oldcount)
			memcpy(newfile, filebuf[mtAlloc], oldcount*sizeof(uint8_t));

		FreeBuffer();

		filebuf[mtAlloc]=newfile;
		filesize[mtAlloc]=maxsize;
		filecount=oldcount;
		filepos=oldpos;
	}
}

// Assembly:
cmpq %rsi, 0x28(%rdi)
jae 0xf992
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
addq $0x200, %r14            # imm = 0x200
movq %r14, %rdi
callq 0x4040
movq %rax, %r15
leaq 0x38(%rbx), %rbp
movq 0x38(%rbx), %r12
movq 0x40(%rbx), %r13
testq %r12, %r12
je 0xf957
movq 0x18(%rbx), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x4190
movq $0x0, 0x28(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0xf974
callq 0x4280
movq %r15, 0x18(%rbx)
movq %r14, 0x28(%rbx)
movq %r12, 0x38(%rbx)
movq %r13, 0x40(%rbx)
addq $0x8, %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/Core/MemoryFile.cpp
// Function: CMemoryFile::Close()
int CMemoryFile::Close()
{
	// reset buffers, free resources if already closed
	if (filemt == mtLast)
		Free();
	else
		Clear(0);

	return 0;
}

// Assembly:
pushq %rax
cmpl $0x2, 0x10(%rdi)
jne 0xf9a2
callq 0xf7fe
jmp 0xf9b5
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rdi)
movl $0x2, 0x10(%rdi)
callq 0x4950
xorl %eax, %eax
popq %rcx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/Core/MemoryFile.cpp
// Function: CMemoryFile::FreeBuffer()
void CMemoryFile::FreeBuffer()
{
	filesize[mtAlloc]=0;
	filecount=0;
	filepos=0;

	delete [] filebuf[mtAlloc];
	filebuf[mtAlloc]=NULL;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq $0x0, 0x28(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rdi)
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0xf9db
callq 0x4280
movq $0x0, 0x18(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/Core/MemoryFile.cpp
// Function: CMemoryFile::Read(void*, unsigned long)
size_t CMemoryFile::Read(void *buf, size_t size)
{
	// stop if: nothing to read; buffer is invalid; file is not open
	if (!buf || !size || filemt == mtLast)
		return 0;

	// limit readable size to remaining valid content
	if (filecount-filepos < size)
		size=filecount-filepos;

	// read from file, update stream position
	if (size) {
		memcpy(buf, filebuf[filemt]+filepos, size);
		filepos+=size;
	}

	return size;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
jne 0xfa07
movq %rdi, %rbx
movslq 0x10(%rdi), %rcx
cmpq $0x2, %rcx
jne 0xfa15
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rax
movq %rdi, %r14
subq %rax, %r14
cmpq %rdx, %r14
cmovaeq %rdx, %r14
cmpq %rax, %rdi
je 0xfa0a
addq 0x18(%rbx,%rcx,8), %rax
movq %rsi, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x4190
addq %r14, 0x40(%rbx)
jmp 0xfa0a
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/capsimg/Core/MemoryFile.cpp
// Function: CMemoryFile::Write(void*, unsigned long)
size_t CMemoryFile::Write(void *buf, size_t size)
{
	// stop if: nothing to write; buffer is invalid; file is not open; file is read-only
	if (!buf || !size || filemt == mtLast || !(filemode & BFFLAG_WRITE))
		return 0;

	// grow class owned file buffer if needed
	if (filemt == mtAlloc)
		AllocBuffer(filepos+size);

	// limit writeable size to buffer size
	if (filesize[filemt]-filepos < size)
		size=filesize[filemt]-filepos;

	// write into file, update stream position
	if (size) {
		memcpy(filebuf[filemt]+filepos, buf, size);
		filepos+=size;

		// update valid content count if wrote past the current file size
		if (filepos > filecount)
			filecount=filepos;
	}

	return size;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
jne 0xfa71
movq %rdi, %rbx
movl 0x10(%rdi), %eax
cmpl $0x2, %eax
je 0xfa71
testb $0x1, 0xc(%rbx)
jne 0xfa83
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rdx, %r12
movq %rsi, %r14
testl %eax, %eax
jne 0xfa9c
movq 0x40(%rbx), %rsi
addq %r12, %rsi
movq %rbx, %rdi
callq 0xf90e
movslq 0x10(%rbx), %rax
movq 0x28(%rbx,%rax,8), %rcx
movq 0x40(%rbx), %rdi
movq %rcx, %r15
subq %rdi, %r15
cmpq %r12, %r15
cmovaeq %r12, %r15
cmpq %rdi, %rcx
je 0xfa74
addq 0x18(%rbx,%rax,8), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4190
movq 0x40(%rbx), %rax
addq %r15, %rax
movq %rax, 0x40(%rbx)
cmpq 0x38(%rbx), %rax
jbe 0xfa74
movq %rax, 0x38(%rbx)
jmp 0xfa74
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/SOS_Unpacker.cpp
// Function: trackbuffer_shift_bits(unsigned char**, int, int)
void trackbuffer_shift_bits(UBYTE **pBuffer, int d0, int d1) {
    d0 -= 1;
    if (d0 >= 0) {
        UBYTE *buffer = *pBuffer;
        buffer += d1; buffer += d1;
        d1 -= 2;

        do {
            UWORD *a3 = (UWORD*)buffer;
            int	 d2 = d1;
            bool extend = false;

            --a3;
            if (*a3 & 0x8000)
                extend = true;
            *a3 <<= 1;

            do {
                bool extend2 = false;
                --a3;
                if (*a3 & 0x8000)
                    extend2 = true;
                *a3 <<= 1;

                if (extend)
                    *a3 |= 0x01;
                extend = extend2;
            } while (--d2 >= 0);

        } while (--d0 >= 0);
    }

    // Skip past SYNC marker
    while (readLEWord(*pBuffer) == gTrackSyncMarker)
        *pBuffer += 2;
}

// Assembly:
pushq %rbx
testl %esi, %esi
jle 0xfbc0
movq (%rdi), %rax
movslq %edx, %rcx
leaq (%rax,%rcx,2), %rdx
addq $-0x4, %rdx
addq %rcx, %rax
leal -0x1(%rcx), %r8d
movzwl -0x2(%rax,%rcx), %r11d
movl %r11d, %r9d
addl %r11d, %r9d
movw %r9w, -0x2(%rax,%rcx)
movl %r8d, %r9d
movq %rdx, %r10
movzwl (%r10), %ebx
shrdw $0xf, %bx, %r11w
movw %r11w, (%r10)
addq $-0x2, %r10
decl %r9d
movl %ebx, %r11d
testl %r9d, %r9d
jg 0xfb97
leal -0x1(%rsi), %r9d
cmpl $0x1, %esi
movl %r9d, %esi
jg 0xfb7f
movq (%rdi), %rax
cmpw $0x4489, (%rax)         # imm = 0x4489
jne 0xfbd9
cmpw $0x4489, 0x2(%rax)      # imm = 0x4489
leaq 0x2(%rax), %rax
je 0xfbca
movq %rax, (%rdi)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/SOS_Unpacker.cpp
// Function: sectorFindSync(unsigned char**, unsigned char*)
int sectorFindSync(UBYTE **pBuffer, UBYTE *pBufferEnd) {
    UDWORD	bits_shifted = 0;
    bool	found = false;

    for (; *pBuffer < pBufferEnd && !found; *pBuffer += 2) {
        UDWORD current = swapDWord(readLEDWord(*pBuffer));

        for (bits_shifted = 0; bits_shifted < 16; ++bits_shifted) {
            if (gTrackSyncMarker == (current & 0xFFFF)) {
                found = true;
                break;
            }
            current >>= 1;
        }
    }

    if (*pBuffer >= pBufferEnd)
        return -1;

    // track begins on next word boundry
    if (!bits_shifted)
        *pBuffer += 2;

    // Calculate number of bits shifted
    return (16 - bits_shifted);
}

// Assembly:
movq (%rdi), %rcx
xorl %edx, %edx
cmpq %rsi, %rcx
jae 0xfc20
xorl %eax, %eax
movl (%rcx), %r8d
roll $0x10, %r8d
xorl %edx, %edx
movzwl %r8w, %r9d
cmpl $0x4489, %r9d           # imm = 0x4489
je 0xfc0e
shrl %r8d
incl %edx
cmpl $0x10, %edx
jne 0xfbf0
movl $0x10, %edx
jmp 0xfc10
movb $0x1, %al
addq $0x2, %rcx
cmpq %rsi, %rcx
jae 0xfc1d
testb $0x1, %al
je 0xfbe7
movq %rcx, (%rdi)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rsi, %rcx
jae 0xfc3c
testl %edx, %edx
jne 0xfc35
addq $0x2, %rcx
movq %rcx, (%rdi)
movl $0x10, %eax
subl %edx, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/stdafx.cpp
// Function: file_select(dirent const*)
int file_select(const struct dirent *entry) {
    std::string name = entry->d_name;

    std::transform(name.begin(), name.end(), name.begin(), ::toupper);

    if (name.find(findType) == std::string::npos)
        return false;

    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x13(%rdi), %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq %r14, %rdi
callq 0x40f0
leaq (%rbx,%rax), %rdx
addq $0x13, %rdx
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10b94
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x11196
movq 0x8(%rsp), %r14
xorl %r12d, %r12d
movsbl (%r14,%r12), %edi
callq 0x43c0
movb %al, (%r14,%r12)
incq %r12
cmpq %r12, %rbx
jne 0x11180
movq 0xa4d3(%rip), %rsi      # 0x1b670
movq 0xa4d4(%rip), %rcx      # 0x1b678
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
callq 0x4390
movq %rax, %rbx
movq (%r14), %rdi
cmpq %r15, %rdi
je 0x111cb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4210
xorl %eax, %eax
cmpq $-0x1, %rbx
setne %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/OpenFodder[P]SOS_Unpacker/stdafx.cpp
// Function: GetLocalTime
void GetLocalTime(LPSYSTEMTIME lpSystemTime)
{
    time_t t = time(NULL);
    struct tm *tp = localtime(&t);

    lpSystemTime->wYear = tp->tm_year + 1900;
    lpSystemTime->wMonth = tp->tm_mon + 1;
    lpSystemTime->wDayOfWeek = tp->tm_wday;
    lpSystemTime->wDay = tp->tm_mday;
    lpSystemTime->wHour = tp->tm_hour;
    lpSystemTime->wMinute = tp->tm_min;
    lpSystemTime->wSecond = tp->tm_sec;
    // we don't have milliseconds in struct tm
    lpSystemTime->wMilliseconds = 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
xorl %edi, %edi
callq 0x41d0
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
callq 0x4170
movl $0x76c, %ecx            # imm = 0x76C
addl 0x14(%rax), %ecx
movw %cx, (%rbx)
movl 0x10(%rax), %ecx
incl %ecx
movw %cx, 0x2(%rbx)
movzwl 0x18(%rax), %ecx
movw %cx, 0x4(%rbx)
movzwl 0xc(%rax), %ecx
movw %cx, 0x6(%rbx)
movzwl 0x8(%rax), %ecx
movw %cx, 0x8(%rbx)
movzwl 0x4(%rax), %ecx
movw %cx, 0xa(%rbx)
movzwl (%rax), %eax
movw %ax, 0xc(%rbx)
movw $0x0, 0xe(%rbx)
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: alldr(unsigned int*, int*, int*, int, int)
void alldr(unsigned int *D,int *D_2,int *D_3,int i,int round){
    //for(int i=0;i<60;i++){
    int rofs = 0;if(round>1){rofs=dc2s[round-1];}
        printf("\n%d > %d[%d(%d)]:",round,i,D_2[i],D_3[i]);
        for(int j=D_2[i];j<D_2[i+1];j++){printf("%d(%d) ",D[j]+rofs,D[j]);printf("(+%d)",D_3[D[j]+rofs]);
            //if(round>0){alldr(D,D_2,D_3,D[j]+rofs,round-1);}
        }
    //}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %eax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %r13d, %r13d
cmpl $0x2, %r8d
jl 0x134a
leal -0x1(%rax), %edx
leaq 0x935a(%rip), %rsi      # 0xa6a0
movl (%rsi,%rdx,4), %r13d
movslq %ecx, %r12
movl (%r14,%r12,4), %ecx
movl (%rbx,%r12,4), %r8d
leaq 0x4cec(%rip), %rdi      # 0x6048
movl %eax, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x1030
movslq (%r14,%r12,4), %rbp
cmpl 0x4(%r14,%r12,4), %ebp
jge 0x13ae
movl (%r15,%rbp,4), %edx
leal (%rdx,%r13), %esi
leaq 0x4cd8(%rip), %rdi      # 0x605a
xorl %eax, %eax
callq 0x1030
movl (%r15,%rbp,4), %eax
addl %r13d, %eax
movl (%rbx,%rax,4), %esi
leaq 0x4cc8(%rip), %rdi      # 0x6062
xorl %eax, %eax
callq 0x1030
incq %rbp
movslq 0x4(%r14,%r12,4), %rax
cmpq %rax, %rbp
jl 0x1373
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: pscheck(unsigned int*, int*, int, int, int)
int pscheck(unsigned int *D,int *D_2,int start,int plen, int round){ 
    //配列mのstartからplen文字の完全一致を探す
    //if(DEBUGFLAG==1){
    //    printf("\npscheck[");
    //    for(int j = 0;j<plen;j++){printf("%d ",m[start+j]);}
    //    printf("]");
    //}
    int rofs = 0;if(round>1){rofs=dc2s[round-1];}
    int pos = 0;int posup = dc2s[round]-1;int posbt = dc2s[round+1]; //round内のみで計算する
    while(1){
        pos = posup + (posbt-posup)/2;
        //printf("\nテスト %d %d %d",pos,posbt,posup);
        int k = 0; // : the length of same prefix. if k == plen == the length of the purse, it's exactly the answer.
        int r = 0; // : for debuging
        for(int i = 0;i<plen;i++){
            if(i == D_2[pos+1]-D_2[pos]){k=-1;break;} //分割が短すぎる = この分割より後に出てくるはず
            if(m[start+i]-rofs==D[D_2[pos]+i]){k=0;}
            if(m[start+i]-rofs>D[D_2[pos]+i]){k=-1;break;} //pos should be larger than now
            if(m[start+i]-rofs<D[D_2[pos]+i]){k=1;break;} //pos should be smaller than now
        }
        if(k==-1){posup=pos;}
        if(k==1){posbt=pos;}
        if(k==0){
                if(D_2[pos+1]-D_2[pos]==plen){break;} //発見
                else{posbt=pos;} //パターンが短すぎる = もっと前に出てくるはず
        }
        //if(DEBUGFLAG==1){printf("\n >>  %d %d %d",pos,posbt,posup);}
        if(posbt-posup<2){pos=-1;break;} //もう探すところがない
    }
    //printf("位置%d ",pos);
    return pos;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, -0x8(%rsp)
xorl %r9d, %r9d
leaq 0x91b2(%rip), %rax      # 0xa6a0
cmpl $0x2, %r8d
jl 0x14fc
leal -0x1(%r8), %edi
movl (%rax,%rdi,4), %r9d
movslq %r8d, %rdi
movl (%rax,%rdi,4), %r10d
movl 0x4(%rax,%rdi,4), %r14d
decl %r10d
testl %ecx, %ecx
setg -0x9(%rsp)
movslq %edx, %rdx
movslq %ecx, %r11
movl %r11d, %ebx
shlq $0x2, %rdx
addq 0x91ea(%rip), %rdx      # 0xa710
movl %r14d, %edi
subl %r10d, %edi
movl %edi, %eax
shrl $0x1f, %eax
addl %edi, %eax
sarl %eax
addl %r10d, %eax
movslq %eax, %r15
testl %ecx, %ecx
jle 0x1557
movl 0x4(%rsi,%r15,4), %r13d
movslq (%rsi,%r15,4), %rdi
subl %edi, %r13d
jne 0x159a
movb -0x9(%rsp), %r12b
movl %eax, %r10d
jmp 0x155c
movb -0x9(%rsp), %r12b
testb $0x1, %r12b
je 0x1567
movl %r14d, %ebp
jmp 0x157a
movl 0x4(%rsi,%r15,4), %edi
subl (%rsi,%r15,4), %edi
movl %eax, %ebp
cmpl %ecx, %edi
jne 0x157a
xorl %edi, %edi
jmp 0x1593
movl %ebp, %edi
subl %r10d, %edi
cmpl $0x2, %edi
setge %dil
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
cmovll %r8d, %eax
movl %ebp, %r14d
testb %dil, %dil
jne 0x1526
jmp 0x15ea
movq -0x8(%rsp), %r8
leaq (%r8,%rdi,4), %rbp
negq %r13
movl $0x1, %edi
movb -0x9(%rsp), %r12b
movl -0x4(%rdx,%rdi,4), %r8d
subl %r9d, %r8d
cmpl -0x4(%rbp,%rdi,4), %r8d
ja 0x1552
jb 0x15e2
cmpq %r11, %rdi
setl %r12b
cmpq %rdi, %rbx
je 0x155c
leaq (%rdi,%r13), %r8
incq %r8
incq %rdi
cmpq $0x1, %r8
jne 0x15b0
jmp 0x1552
movl %eax, %r14d
jmp 0x155c
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: findintop(int*, int, int)
void findintop(int *D_3,int tg,int pofs){ //NS列からtgを探す
    if(DEBUGFLAG==1){printf("\n[%d]を探す(%d)",tg,dc2s[fround-1]);}
    int len = 0;
    for(int y1 = 0;y1<NSsize;y1++){
        if(DEBUGFLAG==1){printf("[%d]答え",NS[y1]);}
        if(NS[y1]==tg-dc2s[fround-1]){
            printf(" %d",len+pofs);
            if(ans<1000 && CHECKFLAG==1){checkans[ans]=len+pofs;}
            ans++;
        }
        len+= D_3[NS[y1]+dc2s[fround-1]];
    }
    //printf("\nend of searching.(%d)[%d]",len,tg);
    return;
}

// Assembly:
cmpl $0x0, 0x8aa6(%rip)      # 0xa720
jle 0x1d0d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
leaq 0x8a07(%rip), %r12      # 0xa6a0
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x8a72(%rip), %rax      # 0xa718
movslq 0x8a7b(%rip), %rcx      # 0xa728
movl %ebp, %edx
subl -0x4(%r12,%rcx,4), %edx
cmpl %edx, (%rax,%r13,4)
jne 0x1cd2
leal (%r15,%rbx), %esi
leaq 0x4465(%rip), %rdi      # 0x612a
xorl %eax, %eax
callq 0x1030
incl 0x8a1e(%rip)            # 0xa6f0
movq 0x8a3f(%rip), %rax      # 0xa718
movslq (%rax,%r13,4), %rax
movslq 0x8a44(%rip), %rcx      # 0xa728
movslq -0x4(%r12,%rcx,4), %rcx
addq %rax, %rcx
addl (%r14,%rcx,4), %r15d
incq %r13
movslq 0x8a26(%rip), %rax      # 0xa720
cmpq %rax, %r13
jl 0x1c9f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: pschecks(unsigned int*, int*, int, int, int)
int pschecks(unsigned int *D,int *D_2,int start,int plen,int round){
    //mのstartmからmlenを，分割の最初から始まるものだけ探す
    //配列mのstartからplen文字一致する最も番号の小さいものを探す
    //printf("\n[");for(int y8=0;y8<plen;y8++){printf(" %d",m[start+y8]);}printf("]を探す");
    int rofs = 0;if(round>1){rofs=dc2s[round-1];}
    int pos = 0;int posup = dc2s[round]-1;int posbt = dc2s[round+1]; //round内のみで計算する
    while(1){
        pos = posup + (posbt-posup)/2;int k = 0;
        for(int i = 0;i<plen;i++){
            if(i == D_2[pos+1]-D_2[pos]){k=-1;break;} //分割が短すぎる = この分割より後に出てくるはず
            if(m[start+i]-rofs==D[D_2[pos]+i]){k=0;}
            if(m[start+i]-rofs>D[D_2[pos]+i]){k=-1;break;} //pos should be larger than now
            if(m[start+i]-rofs<D[D_2[pos]+i]){k=1;break;} //pos should be smaller than now
        }
        if(k==-1){posup=pos;}
        if(k==1){posbt=pos;}
        if(k==0){ //パターンと完全に一致するprefixを持っている
                posbt=pos;
        }
        if(posbt-posup<2){pos=-1;break;} //もう探すところがない
    }
    //printf("\n[最小:%d]",posbt);
    return posbt;
}

// Assembly:
xorl %r9d, %r9d
leaq 0x8988(%rip), %rax      # 0xa6a0
cmpl $0x2, %r8d
jl 0x1d26
leal -0x1(%r8), %r9d
movl (%rax,%r9,4), %r9d
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movslq %r8d, %r10
movl (%rax,%r10,4), %r8d
movl 0x4(%rax,%r10,4), %eax
decl %r8d
movslq %edx, %rdx
movslq %ecx, %r10
shlq $0x2, %rdx
addq 0x89c2(%rip), %rdx      # 0xa710
movl %eax, %ebx
subl %r8d, %ebx
movl %ebx, %r11d
shrl $0x1f, %r11d
addl %ebx, %r11d
sarl %r11d
addl %r8d, %r11d
testl %ecx, %ecx
jle 0x1dad
movslq %r11d, %r14
movl 0x4(%rsi,%r14,4), %ebx
movslq (%rsi,%r14,4), %r14
subl %r14d, %ebx
leaq (%rdi,%r14,4), %r14
negq %rbx
movl $0x1, %r15d
leaq (%rbx,%r15), %r12
cmpq $0x1, %r12
je 0x1db2
movl -0x4(%rdx,%r15,4), %ebp
subl %r9d, %ebp
movl -0x4(%r14,%r15,4), %r12d
cmpl %r12d, %ebp
ja 0x1db2
jb 0x1dad
leaq 0x1(%r15), %r12
cmpq %r10, %r15
movq %r12, %r15
jl 0x1d83
movl %r11d, %eax
jmp 0x1db5
movl %r11d, %r8d
movl %eax, %r11d
subl %r8d, %r11d
cmpl $0x1, %r11d
jg 0x1d4e
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: leftopen(unsigned int*, int*, int*, int, int, int)
void leftopen(unsigned int *D,int *D_2,int *D_3,int round,int count,int tround){ //左の[0]をcount回開ける
    if(DEBUGFLAG==1){
         printf("\n[1-左%dオープン(%d)]",count,round);
         if(occart2[tround][0] > -1){alldr(D,D_2,D_3,occart2[tround][0],tround-1);}
    }
    int rofs=0;
    if(round>1){rofs=dc2s[round-1];}
    if(occart2[tround][0] > -1){
       occart2[tround][0] = rofs+D[D_2[1+occart2[tround][0]]-1];
       if(DEBUGFLAG==1){printf(" >> %d ",occart2[tround][0]);}
       if(count>1){leftopen(D,D_2,D_3,round-1,count-1,tround);}
    }
    return;
}

// Assembly:
pushq %rbx
leaq 0x8358(%rip), %rax      # 0xa6a0
movslq %r9d, %rdx
leaq (%rdx,%rdx,4), %rdx
leaq 0x7e1a(%rip), %r9       # 0xa170
leaq (%r9,%rdx,8), %r10
xorl %r11d, %r11d
cmpl $0x2, %ecx
jl 0x236a
leal -0x1(%rcx), %r11d
movl (%rax,%r11,4), %r11d
movslq (%r9,%rdx,8), %rbx
testq %rbx, %rbx
js 0x238d
movslq 0x4(%rsi,%rbx,4), %rbx
addl -0x4(%rdi,%rbx,4), %r11d
movl %r11d, (%r10)
cmpl $0x2, %r8d
jl 0x238d
decl %ecx
decl %r8d
jmp 0x235a
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: leftopennd(unsigned int*, int*, int*, int, int, int)
int leftopennd(unsigned int *D,int *D_2,int *D_3,int round,int count,int tround){ //左の[0][1]をcount回開ける
     if(DEBUGFLAG==1){
         printf("\n[2-左%dオープン(%d)]",count,round);
         if(occart2[tround][1] > -1){alldr(D,D_2,D_3,occart2[tround][1],tround-1);}
         if(occart2[tround][0] > -1){alldr(D,D_2,D_3,occart2[tround][0],tround-1);}
    }
    int rofs=0;
    if(round>1){rofs=dc2s[round-1];}
    if(occart2[tround][1] > -1){ //左辺文字Aが指定されていれば
         if(DEBUGFLAG==1){printf("open [%d,%d--%d] >>",occart2[tround][1],dc2s[round],rofs);}
        int a1 = rofs+D[D_2[1+occart2[tround][1]] - 1];
        if(DEBUGFLAG==1){printf("\na1 = %d(%d)",a1,count);}
        if(count>1){occart2[tround][1] = a1;return leftopennd(D,D_2,D_3,round-1,count-1,tround);}
        int a2;
        if(D_2[occart2[tround][1]]<2){printf("a2を消す");a2 = -1;}
        a2 = rofs+D[D_2[1+occart2[tround][1]] - 2];
        occart2[tround][1] = a1;
        occart2[tround][0] = a2;
        if(DEBUGFLAG==1){printf("\n更新 = %d & %d",a1,a2);}
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r11
xorl %eax, %eax
leaq 0x82f7(%rip), %rdx      # 0xa6a0
movslq %r9d, %rsi
leaq (%rsi,%rsi,4), %rsi
leaq 0x7db9(%rip), %rdi      # 0xa170
leaq (%rdi,%rsi,8), %r15
xorl %r12d, %r12d
movl $0x0, %r13d
cmpl $0x2, %ecx
jl 0x23d1
leal -0x1(%rcx), %r9d
movl (%rdx,%r9,4), %r13d
movslq 0x4(%rdi,%rsi,8), %r9
testq %r9, %r9
js 0x2435
movslq 0x4(%r14,%r9,4), %r10
movl -0x4(%r11,%r10,4), %ebx
addl %r13d, %ebx
cmpl $0x2, %r8d
jl 0x2403
movl %ebx, 0x4(%r15)
decl %ecx
decl %r8d
testb $0x1, %r12b
cmovel %eax, %ebp
movb $0x1, %r12b
jmp 0x23be
cmpl $0x1, (%r14,%r9,4)
jg 0x2420
leaq 0x3cbd(%rip), %rdi      # 0x60ce
xorl %eax, %eax
movq %r11, (%rsp)
callq 0x1030
movq (%rsp), %r11
movslq 0x4(%r15), %rax
movslq 0x4(%r14,%rax,4), %rax
addl -0x8(%r11,%rax,4), %r13d
movl %ebx, 0x4(%r15)
movl %r13d, (%r15)
xorl %eax, %eax
testb $0x1, %r12b
cmovnel %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: findinround1(unsigned int*, int*, int*, int, int, int)
void findinround1(unsigned int *D,int *D_2,int *D_3,int tg,int round,int pofs){
    if(round==fround){return findintop(D_3,tg,pofs);}
    //あるラウンドから文字[tg]を探す
    //printf("%d(+%d)",tg,pofs); //引き継いだズレ値を記録
    int e2[2];
    int rofs = 0;
    if(round>1){rofs=dc2s[round-1];}
    for(int y8=dc2s[round];y8<dc2s[round+1];y8++){
        int ofs = 0;
        //printf("\n[%d(%d)]",y8,D_2[y8+1]-D_2[y8]);
        for(int y9=D_2[y8];y9<D_2[y8+1];y9++){
            //printf(" %d",rofs+D[y9]);
            if(rofs+D[y9]==tg){
                //if(round>15){printf("\n発見(%d,%d[+%d])",tg,ofs+pofs,ofs);}
                findinround1(D,D_2,D_3,y8,round+1,pofs+ofs);
            }
            if(round>0){ofs+=D_3[rofs+D[y9]];}else{ofs++;}
        }
    }
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r13
cmpl %r8d, 0x802e(%rip)      # 0xa728
jne 0x2717
movq %r13, %rdi
movl %ecx, %esi
movl %r9d, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c73
movq %rsi, %r12
movq %rdi, %rbp
xorl %r11d, %r11d
leaq 0x7f79(%rip), %r10      # 0xa6a0
cmpl $0x2, %r8d
jl 0x2735
leal -0x1(%r8), %eax
movl (%r10,%rax,4), %r11d
movslq %r8d, %rax
movslq (%r10,%rax,4), %rbx
movq %rax, (%rsp)
cmpl 0x4(%r10,%rax,4), %ebx
jge 0x27fa
incq (%rsp)
movl %ecx, 0xc(%rsp)
movq %r8, 0x10(%rsp)
movl %r11d, 0x8(%rsp)
movq %rbx, %rax
movslq (%r12,%rbx,4), %r14
incq %rbx
movq %rax, 0x20(%rsp)
cmpl 0x4(%r12,%rax,4), %r14d
jge 0x27e2
xorl %r15d, %r15d
movq %rbx, 0x18(%rsp)
movl (%rbp,%r14,4), %eax
addl %r11d, %eax
cmpl %ecx, %eax
jne 0x27ba
movq %r9, %rbx
addl %r15d, %r9d
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq 0x20(%rsp), %rcx
movq (%rsp), %r8
callq 0x26e2
movl 0x8(%rsp), %r11d
movq 0x10(%rsp), %r8
movl 0xc(%rsp), %ecx
movq %rbx, %r9
movq 0x18(%rsp), %rbx
testl %r8d, %r8d
jle 0x27ce
movl (%rbp,%r14,4), %eax
addl %r11d, %eax
movl (%r13,%rax,4), %eax
jmp 0x27d3
movl $0x1, %eax
addl %eax, %r15d
incq %r14
movslq (%r12,%rbx,4), %rax
cmpq %rax, %r14
jl 0x277b
leaq 0x7eb7(%rip), %rax      # 0xa6a0
movq (%rsp), %r10
movslq (%rax,%r10,4), %rax
cmpq %rax, %rbx
jl 0x275d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq