// File: 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:
subq $0x438, %rsp            # imm = 0x438
movq %rdi, 0x430(%rsp)
movq 0x430(%rsp), %rdi
leaq 0xbc5b(%rip), %rsi      # 0x158e9
callq 0xb250
testb $0x1, %al
jne 0x9c99
jmp 0x9ce9
movq 0x430(%rsp), %rdi
leaq 0xbc44(%rip), %rsi      # 0x158ec
callq 0xb250
testb $0x1, %al
jne 0x9cb3
jmp 0x9ce9
movq 0x430(%rsp), %rdi
leaq 0xbc2d(%rip), %rsi      # 0x158ef
callq 0xb250
testb $0x1, %al
jne 0x9ccd
jmp 0x9ce9
movq 0x430(%rsp), %rdi
leaq 0xbc16(%rip), %rsi      # 0x158f2
callq 0xb250
testb $0x1, %al
jne 0x9e54
leaq 0x2b8(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x44c0
movq 0x38(%rsp), %rdi
leaq 0xbbee(%rip), %rsi      # 0x158f5
callq 0x42f0
jmp 0x9d0e
movb $0x1, 0x25f(%rsp)
movl $0x50, %edi
callq 0x4190
movq %rax, 0x28(%rsp)
leaq 0x287(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x4610
movq 0x30(%rsp), %rdx
leaq 0xbbcd(%rip), %rsi      # 0x15910
leaq 0x288(%rsp), %rdi
callq 0x53b0
jmp 0x9d52
leaq 0x260(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x4340
jmp 0x9d69
movq 0x28(%rsp), %rdi
leaq 0x288(%rsp), %rsi
movl $0x224, %edx            # imm = 0x224
leaq 0x260(%rsp), %rcx
callq 0xbf00
movq 0x28(%rsp), %rdi
movb $0x0, 0x25f(%rsp)
leaq 0x10fec(%rip), %rsi     # 0x1ad88
leaq 0x220d(%rip), %rdx      # 0xbfb0
callq 0x45e0
jmp 0xa018
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
jmp 0x9e42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
jmp 0x9e1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
jmp 0x9e10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x46a8
leaq 0x288(%rsp), %rdi
callq 0x46a8
leaq 0x287(%rsp), %rdi
callq 0x4380
testb $0x1, 0x25f(%rsp)
jne 0x9e36
jmp 0x9e40
movq 0x28(%rsp), %rdi
callq 0x4210
jmp 0x9e42
leaq 0x2b8(%rsp), %rdi
callq 0x40b0
jmp 0xa00b
movq 0x430(%rsp), %rdi
callq 0x4140
movq %rax, %rsi
leaq 0x50(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movl $0x4, %edx
callq 0x4630
movq 0x20(%rsp), %rdi
movq $0x0, 0x48(%rsp)
leaq 0x40(%rsp), %rsi
movl $0x8, %edx
callq 0x4460
jmp 0x9e97
xorl %edx, %edx
movl %edx, %esi
leaq 0x50(%rsp), %rdi
callq 0x44d0
jmp 0x9ea7
leaq 0x40(%rsp), %rsi
leaq 0xba6a(%rip), %rdi      # 0x1591d
movl $0x8, %edx
callq 0x4180
cmpl $0x0, %eax
jne 0x9f54
movl $0x120, %edi            # imm = 0x120
callq 0x4310
movq %rax, 0x18(%rsp)
jmp 0x9ed7
movq 0x18(%rsp), %rdi
callq 0xa3f0
jmp 0x9ee3
movq 0x18(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0x50(%rsp), %rsi
callq *%rax
jmp 0x9f02
leaq 0x50(%rsp), %rdi
callq 0x40a0
jmp 0x9f0e
jmp 0x9fe0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
jmp 0xa001
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
movl $0x120, %esi            # imm = 0x120
callq 0x4320
jmp 0xa001
leaq 0x40(%rsp), %rsi
leaq 0xb9c6(%rip), %rdi      # 0x15926
movl $0x8, %edx
callq 0x4180
cmpl $0x0, %eax
jne 0x9fde
movl $0x120, %edi            # imm = 0x120
callq 0x4310
movq %rax, 0x10(%rsp)
jmp 0x9f80
movq 0x10(%rsp), %rdi
callq 0xa980
jmp 0x9f8c
movq 0x10(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
leaq 0x50(%rsp), %rsi
callq *%rax
jmp 0x9fab
leaq 0x50(%rsp), %rdi
callq 0x40a0
jmp 0x9fb7
jmp 0x9fde
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
movl $0x120, %esi            # imm = 0x120
callq 0x4320
jmp 0xa001
jmp 0x9fe0
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x40c0
movq 0x8(%rsp), %rax
addq $0x438, %rsp            # imm = 0x438
retq
leaq 0x50(%rsp), %rdi
callq 0x40c0
movq 0x2b0(%rsp), %rdi
callq 0x11ab0
nopl (%rax,%rax)