LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/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 0xeec2
pushq %rbx
movq %rdi, %rbx
leaq 0x58(%rdi), %rax
cmpl $0x0, 0x44(%rdi)
je 0xee25
movq (%rax), %rdi
testq %rdi, %rdi
je 0xee4e
callq 0x4280
cmpl $0x0, 0x44(%rbx)
movl $0x0, 0x28(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%rbx)
movups %xmm0, 0x68(%rbx)
movups %xmm0, 0x78(%rbx)
movups %xmm0, 0x84(%rbx)
jne 0xee6b
jmp 0xee3e
movl $0x0, 0x28(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x2c(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0xee6b
callq 0x4280
jmp 0xee6b
movl $0x0, 0x28(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%rbx)
movups %xmm0, 0x68(%rbx)
movups %xmm0, 0x78(%rbx)
movups %xmm0, 0x84(%rbx)
xorl %eax, %eax
movq %rax, 0x48(%rbx)
movl $0x0, 0x50(%rbx)
movq %rax, 0xd0(%rbx)
movq 0xd8(%rbx), %rdi
testq %rdi, %rdi
je 0xee90
callq 0x4280
movq $0x0, 0xd8(%rbx)
movl $0x0, 0xf4(%rbx)
movq 0xf8(%rbx), %rdi
testq %rdi, %rdi
je 0xeeb6
callq 0x4280
movq $0x0, 0xf8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0xef1d
pushq %rbx
movq %rdi, %rbx
movl $0x0, 0xa8(%rdi)
movq 0xb0(%rdi), %rdi
testq %rdi, %rdi
je 0xeef4
callq 0x4280
movq $0x0, 0xb0(%rbx)
movl $0x0, 0x34(%rbx)
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0xef14
callq 0x4280
movq $0x0, 0x38(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0xef4f
pushq %rbx
movq %rdi, %rbx
movq $0x0, 0xd0(%rdi)
movq 0xd8(%rdi), %rdi
testq %rdi, %rdi
je 0xef43
callq 0x4280
movq $0x0, 0xd8(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0xef80
pushq %rbx
movq %rdi, %rbx
movl $0x0, 0xf4(%rdi)
movq 0xf8(%rdi), %rdi
testq %rdi, %rdi
je 0xef74
callq 0x4280
movq $0x0, 0xf8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf0a0
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rdi)
movups %xmm0, (%rdi)
testq %rsi, %rsi
je 0xf0a0
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
imull $0x147b, %eax, %ecx     # imm = 0x147B
shrl $0x13, %ecx
movl %ecx, 0x4(%rdi)
imull $0x64, %ecx, %ecx
subl %ecx, %eax
movzwl %ax, %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
nop
// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
testb $0x2, 0x10(%rdi)
jne 0xf159
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x8484
movq %rbx, %rdi
movq %r14, %rsi
callq 0x852a
xorl %ebx, %ebx
testl %eax, %eax
jne 0xf189
leaq 0x8(%rsp), %rdi
callq 0x8646
movl %eax, %ebp
testl %eax, %eax
je 0xf189
movl $0x10000, %edi          # imm = 0x10000
callq 0x4040
movq %rax, %r14
xorl %ebx, %ebx
movl $0x10000, %r13d         # imm = 0x10000
leaq 0x8(%rsp), %r15
cmpl %r13d, %ebp
movl $0x10000, %r12d         # imm = 0x10000
cmovll %ebp, %r12d
movq %r15, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x8604
cmpl %r12d, %eax
jne 0xf17f
movq %r14, %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x5088
movl %eax, %ebx
subl %r12d, %ebp
jne 0xf123
jmp 0xf181
movq 0x8(%r14), %rdi
xorl %ebx, %ebx
testq %rdi, %rdi
je 0xf193
movl 0x14(%r14), %esi
testl %esi, %esi
js 0xf193
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5055
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x4280
leaq 0x8(%rsp), %rdi
callq 0x8498
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf1aa
jmp 0xf1aa
jmp 0xf1aa
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x8498
movq %rbx, %rdi
callq 0x43a0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf1db
incl %esi
xorl %eax, %eax
shll $0x8, %eax
movzbl (%rdi), %ecx
incq %rdi
orl %ecx, %eax
decl %esi
cmpl $0x1, %esi
ja 0xf1c8
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/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
jne 0xf21e
movq %rsi, %rbx
movl %ebp, %esi
movl %ecx, %edx
callq 0xf228
testq %rax, %rax
je 0xf21e
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
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf2ea
movl %esi, %r14d
movq %rdi, %rbx
testl %esi, %esi
jle 0xf2ef
movl 0xd0(%rbx), %r12d
leal (%r12,%r14), %ebp
cmpl 0xd4(%rbx), %ebp
jle 0xf2ba
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 0xf2a0
movslq %r12d, %rcx
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x4190
testq %r15, %r15
je 0xf2b4
movq %r15, %rdi
callq 0x4280
movl 0xd0(%rbx), %r12d
movl %ebp, 0xd4(%rbx)
movslq %r12d, %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 0xf305
xorl %r15d, %r15d
jmp 0xf305
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_O3/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 0xf381
movq %rdi, %rbx
movl $0x0, 0xf4(%rdi)
movq 0xf8(%rdi), %rdi
testq %rdi, %rdi
je 0xf33a
callq 0x4280
movq $0x0, 0xf8(%rbx)
movslq 0x18(%rbx), %r15
testq %r15, %r15
jle 0xf381
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
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x8484
movq %r14, %rdi
movq %rbx, %rsi
callq 0x852a
xorl %ebp, %ebp
testl %eax, %eax
jne 0xf41f
movq %rbx, %rdi
callq 0xf448
movl %eax, %ebp
cmpl $0x1, %eax
jne 0xf41f
movq %rbx, %rdi
callq 0xf4d2
movl %eax, %ebp
cmpl $0x1, %eax
jne 0xf41f
movq %rbx, %rdi
callq 0xf578
movl %eax, %ebp
movq %rsp, %rdi
callq 0x8498
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0xf434
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8498
movq %rbx, %rdi
callq 0x43a0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0xcdec
movq %r14, %rdi
movq %rbx, %rsi
callq 0xced6
movl $0x1, %ebx
testl %eax, %eax
jne 0xf4a3
leaq 0x8(%rsp), %rbx
movl $0x143f, %ebp           # imm = 0x143F
movq %rbx, %rdi
xorl %esi, %esi
callq 0xcf7a
decl %eax
cmpl $0xd, %eax
jae 0xf481
btl %eax, %ebp
jae 0xf481
movl %eax, %eax
leaq 0x3008(%rip), %rcx      # 0x124a8
movl (%rcx,%rax,4), %ebx
leaq 0x8(%rsp), %rdi
callq 0xce72
movl %ebx, %eax
addq $0xf0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0xf4bd
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xce72
movq %rbx, %rdi
callq 0x43a0
// File: /workspace/github_cpp_makefile_star2_O3/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 0x8484
movq %r14, %rdi
movq %rbx, %rsi
callq 0x852a
xorl %ebp, %ebp
testl %eax, %eax
jne 0xf54b
movq %rsp, %rdi
callq 0x8646
movl $0xff, %ebx
cmpl %ebx, %eax
cmovll %eax, %ebx
movq %rsp, %rdi
leaq 0x10(%rsp), %rsi
movl %ebx, %edx
callq 0x8604
xorl %ebp, %ebp
cmpl %ebx, %eax
jne 0xf54b
movslq %ebx, %rax
movb $0x0, 0x10(%rsp,%rax)
leaq 0x2fb3(%rip), %rsi      # 0x124e5
leaq 0x10(%rsp), %rdi
callq 0x4070
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
leal 0x1(,%rcx,4), %ebp
movq %rsp, %rdi
callq 0x8498
movl %ebp, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %rbp
retq
jmp 0xf565
jmp 0xf565
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8498
movq %rbx, %rdi
callq 0x43a0
// File: /workspace/github_cpp_makefile_star2_O3/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 $0x228, %rsp            # imm = 0x228
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
callq 0x8484
movq %r14, %rdi
movq %rbx, %rsi
callq 0x852a
xorl %ebp, %ebp
testl %eax, %eax
je 0xf5c4
movq %rsp, %rdi
callq 0x8498
movl %ebp, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdi
callq 0x8646
movl %eax, %ebx
movq %rsp, %r14
leaq 0x10(%rsp), %r15
leaq 0x20(%rsp), %r12
movl $0x1, %ebp
cmpl $0x10, %ebx
jl 0xf5a8
movq %r14, %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x8604
cmpl $0x10, %eax
jne 0xf65e
cmpb $0xd, 0x10(%rsp)
jne 0xf5a8
cmpb $0x4, 0x11(%rsp)
jne 0xf5a8
movzwl 0x12(%rsp), %r13d
testl %r13d, %r13d
je 0xf5a8
addl $-0x10, %ebx
subl %r13d, %ebx
jb 0xf5a8
cmpl $0x200, %r13d           # imm = 0x200
ja 0xf5a8
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x8604
movl $0x0, %ebp
cmpl %r13d, %eax
jne 0xf5a8
movq %r12, %rdi
leaq 0x2e92(%rip), %rsi      # 0x124dc
callq 0x4070
testq %rax, %rax
je 0xf5db
movl $0x4, %ebp
jmp 0xf5a8
xorl %ebp, %ebp
jmp 0xf5a8
jmp 0xf66b
jmp 0xf66b
jmp 0xf66b
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8498
movq %rbx, %rdi
callq 0x43a0
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf704
leaq 0x2df3(%rip), %rax      # 0x12484
movslq (%rax,%rdi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x230, %edi            # imm = 0x230
callq 0x4200
movq %rax, %rbx
movq %rax, %rdi
callq 0x957c
jmp 0xf706
movl $0xb8, %edi
callq 0x4200
movq %rax, %rbx
movq %rax, %rdi
callq 0x1113c
jmp 0xf706
movl $0xb8, %edi
callq 0x4200
movq %rax, %rbx
movq %rax, %rdi
callq 0x11100
jmp 0xf706
movl $0x230, %edi            # imm = 0x230
callq 0x4200
movq %rax, %rbx
movq %rax, %rdi
callq 0x957c
leaq 0x9355(%rip), %rax      # 0x18a50
addq $0x10, %rax
movq %rax, (%rbx)
jmp 0xf706
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
jmp 0xf713
movq %rax, %r14
movl $0x230, %esi            # imm = 0x230
jmp 0xf727
jmp 0xf71f
movq %rax, %r14
movl $0xb8, %esi
movq %rbx, %rdi
callq 0x4210
movq %r14, %rdi
callq 0x43a0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf872
testq %r15, %r15
je 0xf8a4
testq %r12, %r12
jne 0xf8a7
movl $0x1, %eax
jmp 0xf8d1
testq %r15, %r15
je 0xf89a
movq %r14, %rdi
movq %r15, %rsi
callq 0xf8de
testq %r12, %r12
je 0xf89a
movq 0x18(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x4190
movq %r15, 0x38(%r14)
movl $0x0, 0x10(%r14)
jmp 0xf8bb
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_O3/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 0xf96d
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
addq $0x200, %rbx            # imm = 0x200
movq %rbx, %rdi
callq 0x4040
movq %rax, %r15
leaq 0x38(%r14), %r13
movups 0x38(%r14), %xmm0
movaps %xmm0, (%rsp)
movq 0x18(%r14), %r12
movq 0x38(%r14), %rdx
testq %rdx, %rdx
je 0xf932
movq %r15, %rdi
movq %r12, %rsi
callq 0x4190
movq $0x0, 0x28(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
testq %r12, %r12
je 0xf94f
movq %r12, %rdi
callq 0x4280
movq %r15, 0x18(%r14)
movq %rbx, 0x28(%r14)
movaps (%rsp), %xmm0
movups %xmm0, 0x38(%r14)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf97c
callq 0xf7ce
jmp 0xf98f
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_O3/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 0xf9b5
callq 0x4280
movq $0x0, 0x18(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0xf9f1
movq %rdi, %r14
movslq 0x10(%rdi), %rcx
cmpq $0x2, %rcx
je 0xf9f1
movq %rdx, %rbx
movq 0x38(%r14), %rdx
movq 0x40(%r14), %rax
subq %rax, %rdx
jne 0xf9fe
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
cmpq %rbx, %rdx
cmovbq %rdx, %rbx
addq 0x18(%r14,%rcx,8), %rax
movq %rsi, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x4190
addq %rbx, 0x40(%r14)
jmp 0xf9f3
// File: /workspace/github_cpp_makefile_star2_O3/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 0xfa80
movq %rdi, %rbx
movl 0x10(%rdi), %eax
cmpl $0x2, %eax
je 0xfa80
testb $0x1, 0xc(%rbx)
je 0xfa80
movq %rdx, %r12
movq %rsi, %r14
testl %eax, %eax
jne 0xfa63
movq 0x40(%rbx), %rsi
addq %r12, %rsi
movq %rbx, %rdi
callq 0xf8de
movl 0x10(%rbx), %eax
cltq
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
jne 0xfa92
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
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 0xfa83
movq %rax, 0x38(%rbx)
jmp 0xfa83
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %rbx
movq (%rdi), %rax
testl %esi, %esi
jle 0xfb9b
movslq %edx, %rcx
leaq (%rax,%rcx), %rdx
leaq (%rax,%rcx,2), %r8
addq $-0x4, %r8
leal -0x1(%rcx), %r9d
movzwl -0x2(%rdx,%rcx), %ebx
movl %ebx, %r10d
addl %ebx, %r10d
movw %r10w, -0x2(%rdx,%rcx)
movl %r9d, %r10d
movq %r8, %r11
movzwl (%r11), %ebp
shrdw $0xf, %bp, %bx
movw %bx, (%r11)
addq $-0x2, %r11
decl %r10d
movl %ebp, %ebx
testl %r10d, %r10d
jg 0xfb74
leal -0x1(%rsi), %r10d
cmpl $0x1, %esi
movl %r10d, %esi
jg 0xfb5d
cmpw $0x4489, (%rax)         # imm = 0x4489
jne 0xfbb1
cmpw $0x4489, 0x2(%rax)      # imm = 0x4489
leaq 0x2(%rax), %rax
je 0xfba2
movq %rax, (%rdi)
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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), %r8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rsi, %r8
jae 0xfc1d
movq %r8, %rcx
movl (%r8), %r8d
roll $0x10, %r8d
xorl %edx, %edx
movzwl %r8w, %r9d
cmpl $0x4489, %r9d           # imm = 0x4489
je 0xfbfd
shrl %r8d
incl %edx
cmpl $0x10, %edx
jne 0xfbcd
leaq 0x2(%rcx), %r8
movl $0x10, %edx
cmpq %rsi, %r8
jae 0xfc01
cmpl $0x4489, %r9d           # imm = 0x4489
jne 0xfbc1
jmp 0xfc01
leaq 0x2(%rcx), %r8
movq %r8, (%rdi)
cmpq %rsi, %r8
jae 0xfc1d
testl %edx, %edx
jne 0xfc16
addq $0x4, %rcx
movq %rcx, (%rdi)
xorl %edx, %edx
movl $0x10, %eax
subl %edx, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x10bd4
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x111de
movq 0x8(%rsp), %r14
xorl %r12d, %r12d
movsbl (%r14,%r12), %edi
callq 0x43c0
movb %al, (%r14,%r12)
incq %r12
cmpq %r12, %rbx
jne 0x111c8
movq 0xa48b(%rip), %rsi      # 0x1b670
movq 0xa48c(%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 0x11213
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_O3/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
movq 0x10(%rax), %xmm0
pshuflw $0xe2, %xmm0, %xmm0     # xmm0 = xmm0[2,0,2,3,4,5,6,7]
paddw 0x1274(%rip), %xmm0     # 0x12710
movd %xmm0, (%rbx)
movzwl 0x18(%rax), %ecx
movw %cx, 0x4(%rbx)
movdqu (%rax), %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
pshufhw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,6,6,7]
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
pshuflw $0x1b, %xmm0, %xmm0     # xmm0 = xmm0[3,2,1,0,4,5,6,7]
movq %xmm0, 0x6(%rbx)
movw $0x0, 0xe(%rbx)
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x4ce4(%rip), %rdi      # 0x6040
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 0x4cd0(%rip), %rdi      # 0x6052
xorl %eax, %eax
callq 0x1030
movl (%r15,%rbp,4), %eax
addl %r13d, %eax
movl (%rbx,%rax,4), %esi
leaq 0x4cc0(%rip), %rdi      # 0x605a
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_O3/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 %r12
pushq %rbx
xorl %r9d, %r9d
leaq 0x91b9(%rip), %rax      # 0xa6a0
cmpl $0x2, %r8d
jl 0x14f5
leal -0x1(%r8), %r9d
movl (%rax,%r9,4), %r9d
movslq %r8d, %r10
movl (%rax,%r10,4), %r8d
movl 0x4(%rax,%r10,4), %r11d
decl %r8d
movslq %edx, %rdx
movl %ecx, %r10d
shlq $0x2, %rdx
addq 0x91fb(%rip), %rdx      # 0xa710
movl %r11d, %ebx
subl %r8d, %ebx
movl %ebx, %eax
shrl $0x1f, %eax
addl %ebx, %eax
sarl %eax
addl %r8d, %eax
movslq %eax, %r14
movl 0x4(%rsi,%r14,4), %ebx
movslq (%rsi,%r14,4), %r15
subl %r15d, %ebx
testl %ecx, %ecx
jle 0x1560
movl %ebx, %r14d
leaq (%rdi,%r15,4), %r15
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x1566
movl (%rdx,%r12,4), %ebp
subl %r9d, %ebp
cmpl (%r15,%r12,4), %ebp
ja 0x1566
jb 0x156c
incq %r12
cmpq %r12, %r10
jne 0x1544
cmpl %ecx, %ebx
jne 0x156c
jmp 0x157e
movl %eax, %r8d
movl %r11d, %eax
movl %eax, %ebx
subl %r8d, %ebx
movl %eax, %r11d
cmpl $0x1, %ebx
jg 0x1515
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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:
movl 0x8baf(%rip), %eax      # 0xa720
testl %eax, %eax
jle 0x1c16
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movq 0x8b86(%rip), %rcx      # 0xa718
movl 0x8b90(%rip), %edx      # 0xa728
leaq 0x8b01(%rip), %r12      # 0xa6a0
xorl %r13d, %r13d
xorl %r15d, %r15d
movl (%rcx,%r13,4), %esi
movslq %edx, %rdi
movl %ebp, %r8d
subl -0x4(%r12,%rdi,4), %r8d
cmpl %r8d, %esi
jne 0x1bec
leal (%r15,%rbx), %esi
leaq 0x455e(%rip), %rdi      # 0x6122
xorl %eax, %eax
callq 0x1030
incl 0x8b1f(%rip)            # 0xa6f0
movq 0x8b40(%rip), %rcx      # 0xa718
movslq 0x8b49(%rip), %rdx      # 0xa728
movl 0x8b3b(%rip), %eax      # 0xa720
movl (%rcx,%r13,4), %esi
movq %rdx, %rdi
decq %rdi
movslq (%r12,%rdi,4), %rdi
movslq %esi, %rsi
addq %rdi, %rsi
addl (%r14,%rsi,4), %r15d
incq %r13
movslq %eax, %rsi
cmpq %rsi, %r13
jl 0x1ba5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x8a7f(%rip), %rax      # 0xa6a0
cmpl $0x2, %r8d
jl 0x1c2f
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 0x8ab9(%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 0x1cb6
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 0x1cbb
movl -0x4(%rdx,%r15,4), %ebp
subl %r9d, %ebp
movl -0x4(%r14,%r15,4), %r12d
cmpl %r12d, %ebp
ja 0x1cbb
jb 0x1cb6
leaq 0x1(%r15), %r12
cmpq %r10, %r15
movq %r12, %r15
jl 0x1c8c
movl %r11d, %eax
jmp 0x1cbe
movl %r11d, %r8d
movl %eax, %r11d
subl %r8d, %r11d
cmpl $0x1, %r11d
jg 0x1c57
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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:
movslq %r9d, %rax
leaq (%rax,%rax,4), %rax
leaq 0x805c(%rip), %rdx      # 0xa170
leaq (%rdx,%rax,8), %rax
movl (%rax), %r9d
leaq 0x857e(%rip), %rdx      # 0xa6a0
xorl %r10d, %r10d
cmpl $0x2, %ecx
jl 0x2132
leal -0x1(%rcx), %r10d
movl (%rdx,%r10,4), %r10d
testl %r9d, %r9d
js 0x2157
movl %r9d, %r9d
movslq 0x4(%rsi,%r9,4), %r9
addl -0x4(%rdi,%r9,4), %r10d
movl %r10d, (%rax)
cmpl $0x2, %r8d
jl 0x2157
decl %ecx
decl %r8d
movl %r10d, %r9d
jmp 0x2122
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movslq %r9d, %rax
leaq (%rax,%rax,4), %rax
leaq 0x7ffc(%rip), %rdx      # 0xa170
leaq (%rdx,%rax,8), %r15
movl 0x4(%r15), %eax
leaq 0x851d(%rip), %rdx      # 0xa6a0
xorl %ebp, %ebp
cmpl $0x2, %ecx
jl 0x2190
leal -0x1(%rcx), %esi
movl (%rdx,%rsi,4), %ebp
testl %eax, %eax
js 0x21e2
movl %eax, %esi
movslq 0x4(%r14,%rsi,4), %rdi
movl -0x4(%rbx,%rdi,4), %r12d
addl %ebp, %r12d
cmpl $0x2, %r8d
jl 0x21b7
movl %r12d, 0x4(%r15)
decl %ecx
decl %r8d
movl %r12d, %eax
jmp 0x2183
cmpl $0x1, (%r14,%rsi,4)
jg 0x21d0
leaq 0x3f01(%rip), %rdi      # 0x60c6
xorl %eax, %eax
callq 0x1030
movl 0x4(%r15), %eax
cltq
movslq 0x4(%r14,%rax,4), %rax
addl -0x8(%rbx,%rax,4), %ebp
movl %r12d, 0x4(%r15)
movl %ebp, (%r15)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/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
movl %r8d, %r10d
movl %ecx, %r8d
movq %rdx, %r13
cmpl %r10d, 0x8347(%rip)     # 0xa728
jne 0x23ff
movq %r13, %rdi
movl %r8d, %esi
movl %r9d, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1b6b
xorl %ebp, %ebp
leaq 0x8298(%rip), %rcx      # 0xa6a0
cmpl $0x2, %r10d
jl 0x2415
leal -0x1(%r10), %eax
movl (%rcx,%rax,4), %ebp
movslq %r10d, %rax
movslq (%rcx,%rax,4), %r12
movq %rax, (%rsp)
movl 0x4(%rcx,%rax,4), %eax
cmpl %eax, %r12d
jge 0x24ec
incq (%rsp)
movl (%rsi,%r12,4), %ebx
movl %r8d, 0xc(%rsp)
movq %rdi, 0x10(%rsp)
movl %ebp, 0x8(%rsp)
movq %r12, %rcx
incq %r12
movq %rcx, 0x20(%rsp)
movl 0x4(%rsi,%rcx,4), %ecx
cmpl %ecx, %ebx
jge 0x24de
movslq %ebx, %r14
xorl %r15d, %r15d
movq %r12, 0x18(%rsp)
movl (%rdi,%r14,4), %eax
addl %ebp, %eax
cmpl %r8d, %eax
jne 0x24a9
movq %r9, %rbx
addl %r15d, %r9d
movq %r13, %rdx
movq 0x20(%rsp), %rcx
movq (%rsp), %r8
movq %r10, %rbp
movq %rsi, %r12
callq 0x23c3
movq %r12, %rsi
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %rdi
movq %rbp, %r10
movl 0x8(%rsp), %ebp
movl 0xc(%rsp), %r8d
movq %rbx, %r9
testl %r10d, %r10d
jle 0x24bb
movl (%rdi,%r14,4), %eax
addl %ebp, %eax
movl (%r13,%rax,4), %eax
jmp 0x24c0
movl $0x1, %eax
addl %eax, %r15d
incq %r14
movslq (%rsi,%r12,4), %rcx
cmpq %rcx, %r14
jl 0x2465
leaq 0x81ca(%rip), %rax      # 0xa6a0
movq (%rsp), %r11
movl (%rax,%r11,4), %eax
movslq %eax, %r11
movl %ecx, %ebx
cmpq %r11, %r12
jl 0x2443
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/TooruAkagi[P]GCIS_Index/gcis_nep_locate.cpp
// Function: queryload()
int queryload(){
    //load[qname] file and put it in array [m]
    char qname[] = "query.txt";
    char chr;
    FILE *fp;
    long long int qsize = 400;
    qsize = std::filesystem::file_size(qname);
    fp = fopen(qname, "r"); // open file or return null
    if(fp == NULL) {
        printf("%s such file doesn't exist!\n", qname);
        return -1;
    }
    int i = 0;
    for(i=0;i<qsize;i++) {
        chr = fgetc(fp);
        m[i] = chr;
        if(chr<0){m[i]=chr + 256;}
        //printf("\n%d(%d)",m[i],i);
    }
    return (int)qsize;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movabsq $0x78742e7972657571, %rax # imm = 0x78742E7972657571
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
movw $0x74, 0x8(%rsi)
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movl $0x2, %edx
callq 0x4ea8
movq %rbx, %rdi
callq 0x1170
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4f30
leaq 0x21a2(%rip), %rsi      # 0x6073
leaq 0x8(%rsp), %rdi
callq 0x1130
testq %rax, %rax
je 0x3f0b
testq %rbx, %rbx
jle 0x3f23
movq %rax, %r14
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x11b0
movzbl %al, %eax
movq 0x6813(%rip), %rcx      # 0xa710
movl %eax, (%rcx,%r15,4)
incq %r15
cmpq %r15, %rbx
jne 0x3eeb
jmp 0x3f23
leaq 0x2163(%rip), %rdi      # 0x6075
leaq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4f30
movq %rbx, %rdi
callq 0x11c0