// File: /workspace/github_cpp_makefile_star2_O1/pelrun[P]aft/CDSKFile.cpp
// Function: CDSKFile::OpenDSKFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
CDSKFile* CDSKFile::OpenDSKFile(const std::string &filename)
{
	TOOLS_ASSERTMSG(	filename != "a:" && filename != "A:" && 
						filename != "b:" && filename != "B:", "Unable to dump real floppy");

	std::ifstream file(filename.c_str(), std::ios::binary);

	CDSKFile *dsk = NULL;

	char header[8];
	file.read(header, 8);
	file.seekg(0, std::ios::beg);

	if (strncmp("MV - CPC", header, 8) == 0)
	{
		dsk = new CStandardDSKFile();
		dsk->readDSK(file);
		file.close();
	}
	else
	{
		if (strncmp("EXTENDED", header, 8) == 0)
		{
			dsk = new CExtendedDSKFile();
			dsk->readDSK(file);
			file.close();
		}
	}
	return dsk;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdi, %rbx
leaq 0x99ae(%rip), %rsi      # 0x10899
callq 0x30d0
testl %eax, %eax
je 0x70cf
leaq 0x999d(%rip), %rsi      # 0x1089c
movq %rbx, %rdi
callq 0x30d0
testl %eax, %eax
je 0x70cf
leaq 0x9989(%rip), %rsi      # 0x1089f
movq %rbx, %rdi
callq 0x30d0
testl %eax, %eax
je 0x70cf
leaq 0x9975(%rip), %rsi      # 0x108a2
movq %rbx, %rdi
callq 0x30d0
testl %eax, %eax
je 0x70cf
movq (%rbx), %rsi
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movl $0x4, %edx
callq 0x3530
movq %rsp, %rsi
movl $0x8, %edx
movq %rbx, %rdi
callq 0x3380
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33f0
movabsq $0x435043202d20564d, %rax # imm = 0x435043202D20564D
cmpq %rax, (%rsp)
je 0x6f9b
movabsq $0x4445444e45545845, %rax # imm = 0x4445444E45545845
cmpq %rax, (%rsp)
je 0x702a
xorl %ebx, %ebx
jmp 0x70b4
movl $0x120, %edi            # imm = 0x120
callq 0x32c0
movq %rax, %rbx
movq $0x0, 0x8(%rax)
leaq 0xecb9(%rip), %rax      # 0x15c70
movq %rax, (%rbx)
leaq 0xebcf(%rip), %rax      # 0x15b90
movq %rax, 0x10(%rbx)
movl $0x0, 0x4a(%rbx)
movaps 0x971d(%rip), %xmm0     # 0x106f0
movups %xmm0, 0x18(%rbx)
movaps 0x9722(%rip), %xmm0     # 0x10700
movups %xmm0, 0x28(%rbx)
movl $0xa0d6f, 0x37(%rbx)    # imm = 0xA0D6F
movabsq $0x656c69464b534443, %rax # imm = 0x656C69464B534443
movq %rax, 0x3b(%rbx)
movb $0x0, 0x43(%rbx)
movq %rbx, %rdi
addq $0x4e, %rdi
movl $0xcc, %edx
xorl %esi, %esi
callq 0x3180
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x7518
leaq 0x40(%rsp), %rdi
callq 0x30a0
jmp 0x70b4
movl $0x120, %edi            # imm = 0x120
callq 0x32c0
movq %rax, %rbx
movq $0x0, 0x8(%rax)
leaq 0xec6a(%rip), %rax      # 0x15cb0
movq %rax, (%rbx)
leaq 0xeb90(%rip), %rax      # 0x15be0
movq %rax, 0x10(%rbx)
movl $0x0, 0x4a(%rbx)
movaps 0x96be(%rip), %xmm0     # 0x10720
movups %xmm0, 0x18(%rbx)
movaps 0x96c3(%rip), %xmm0     # 0x10730
movups %xmm0, 0x28(%rbx)
movl $0xa0d6f, 0x37(%rbx)    # imm = 0xA0D6F
movabsq $0x656c69464b534443, %rax # imm = 0x656C69464B534443
movq %rax, 0x3b(%rbx)
movb $0x0, 0x43(%rbx)
movq %rbx, %rdi
addq $0x4e, %rdi
movl $0xcc, %edx
xorl %esi, %esi
callq 0x3180
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x78c4
leaq 0x40(%rsp), %rdi
callq 0x30a0
leaq 0x40(%rsp), %rdi
callq 0x30b0
movq %rbx, %rax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x33e0
leaq 0x97c2(%rip), %rsi      # 0x108a5
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x3320
movl $0x50, %edi
callq 0x3150
movq %rax, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movabsq $0x656c69464b534443, %rax # imm = 0x656C69464B534443
movq %rax, (%r15)
movl $0x7070632e, 0x8(%r15)  # imm = 0x7070632E
movq $0xc, -0x8(%r15)
movb $0x0, 0xc(%r15)
leaq 0x48(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x34c0
movq %rsp, %rsi
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
movl $0x224, %edx            # imm = 0x224
callq 0x7dfc
leaq 0xec35(%rip), %rsi      # 0x15d88
leaq 0xd00(%rip), %rdx       # 0x7e5a
movq %rbx, %rdi
callq 0x34f0
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7180
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x32d0
xorl %ebp, %ebp
jmp 0x718a
movq %rax, %r14
movb $0x1, %bpl
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x71a0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x32d0
testb %bpl, %bpl
je 0x71b2
movq %rbx, %rdi
callq 0x31f0
jmp 0x71b2
movq %rax, %r14
movq 0xee07(%rip), %rsi      # 0x15fc0
leaq 0x40(%rsp), %rdi
callq 0x3160
leaq 0xb0(%rsp), %rdi
callq 0x3100
jmp 0x71df
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x30b0
movq %r14, %rdi
callq 0xcdb0
nop