// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0x250, %rsp            # imm = 0x250
movq %rdi, %rbx
leaq 0x99bd(%rip), %rsi      # 0x10899
callq 0x30d0
testl %eax, %eax
je 0x70c3
leaq 0x99ac(%rip), %rsi      # 0x1089c
movq %rbx, %rdi
callq 0x30d0
testl %eax, %eax
je 0x70c3
leaq 0x9998(%rip), %rsi      # 0x1089f
movq %rbx, %rdi
callq 0x30d0
testl %eax, %eax
je 0x70c3
leaq 0x9984(%rip), %rsi      # 0x108a2
movq %rbx, %rdi
callq 0x30d0
testl %eax, %eax
je 0x70c3
movq (%rbx), %rsi
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movl $0x4, %edx
callq 0x3530
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
movq %rbx, %rdi
callq 0x3380
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33f0
movabsq $0x435043202d20564d, %rax # imm = 0x435043202D20564D
cmpq %rax, 0x8(%rsp)
je 0x6f90
movabsq $0x4445444e45545845, %rax # imm = 0x4445444E45545845
cmpq %rax, 0x8(%rsp)
je 0x701f
xorl %ebx, %ebx
jmp 0x70a9
movl $0x120, %edi            # imm = 0x120
callq 0x32c0
movq %rax, %rbx
movq $0x0, 0x8(%rax)
leaq 0xecc4(%rip), %rax      # 0x15c70
movq %rax, (%rbx)
leaq 0xebda(%rip), %rax      # 0x15b90
movq %rax, 0x10(%rbx)
movl $0x0, 0x4a(%rbx)
movaps 0x9728(%rip), %xmm0     # 0x106f0
movups %xmm0, 0x18(%rbx)
movaps 0x972d(%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 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x751c
leaq 0x48(%rsp), %rdi
callq 0x30a0
jmp 0x70a9
movl $0x120, %edi            # imm = 0x120
callq 0x32c0
movq %rax, %rbx
movq $0x0, 0x8(%rax)
leaq 0xec75(%rip), %rax      # 0x15cb0
movq %rax, (%rbx)
leaq 0xeb9b(%rip), %rax      # 0x15be0
movq %rax, 0x10(%rbx)
movl $0x0, 0x4a(%rbx)
movaps 0x96c9(%rip), %xmm0     # 0x10720
movups %xmm0, 0x18(%rbx)
movaps 0x96ce(%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 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x78e4
leaq 0x48(%rsp), %rdi
callq 0x30a0
leaq 0x48(%rsp), %rdi
callq 0x30b0
movq %rbx, %rax
addq $0x250, %rsp            # imm = 0x250
popq %rbx
popq %r14
popq %r15
retq
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
callq 0x33e0
leaq 0x97ce(%rip), %rsi      # 0x108a5
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x3320
movl $0x50, %edi
callq 0x3150
movq %rax, %r14
leaq 0x18(%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 0x50(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x34c0
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rcx
movq %r14, %rdi
movl $0x224, %edx            # imm = 0x224
callq 0x7e6c
leaq 0xec3f(%rip), %rsi      # 0x15d88
leaq 0xd7a(%rip), %rdx       # 0x7eca
movq %r14, %rdi
callq 0x34f0
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7176
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x71b6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x71b6
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x71a9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32d0
movq %r14, %rdi
callq 0x31f0
jmp 0x71b6
movq %rax, %rbx
movq 0xee03(%rip), %rsi      # 0x15fc0
leaq 0x48(%rsp), %rdi
callq 0x3160
leaq 0xb8(%rsp), %rdi
callq 0x3100
jmp 0x71e3
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0xce30
nop