// File: /workspace/github_cpp_makefile_star2_O3/RC2K7[P]SDisk-FileSystem/filesystem.cpp
// Function: FileSystem::initFat()
int FileSystem::initFat()
{
	stringstream ssBuffer;
	int dataStart = 1 + this->fatSize;

    // FileSystem Was Just Created
	if (this->getStatusCode() == 1) {
        // Setup Fat With Default Variables
		ssBuffer << setw(5) << setfill('0') << dataStart << this->delimiter;
		for (int i = 1; i < dataStart; i++)
			ssBuffer << "00000" << this->delimiter;
		for (int i = dataStart; i < (this->getNumberOfBlocks() - 1); i++)
			ssBuffer << setw(5) << setfill('0') << (i + 1) << this->delimiter;
		ssBuffer << "00000" << this->delimiter;
	} else {  // FileSystem Previously Existed
		string temp;
		for (int i = 1; i < dataStart; i++) {
			this->getBlock(i, temp);
			ssBuffer << temp;
		}
	}

	vector<string> vecFAT = block(ssBuffer.str(), this->getBlockSize());
	ssBuffer.str("");
	for (int i = 0; i < vecFAT.size(); i++)
		ssBuffer << vecFAT[i];

	{ // Local Scope
		int i;
		string entry;
		for (i = 0; i < this->getNumberOfBlocks() && getline(ssBuffer, entry,
			this->delimiter); i++)
		{
			this->fat.push_back(std::stoi(entry, nullptr, 10));
		}
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, %rbx
leaq -0x220(%rbp), %rdi
callq 0x2110
movl 0x30(%rbx), %r14d
movq %rbx, %rdi
callq 0x660c
cmpl $0x1, %eax
jne 0x4bb8
movq -0x210(%rbp), %rax
movq -0x18(%rax), %rcx
movq $0x5, -0x200(%rbp,%rcx)
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %r12
addq $-0x210, %r12           # imm = 0xFDF0
cmpb $0x0, 0xe1(%r12)
jne 0x4ac7
movq %r12, %rdi
movl $0x20, %esi
callq 0x21a0
movb $0x1, 0xe1(%r12)
leal 0x1(%r14), %esi
leaq -0x210(%rbp), %r15
movb $0x30, 0xe0(%r12)
movq %r15, %rdi
callq 0x22f0
leaq -0x48(%rbp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x21f0
testl %r14d, %r14d
jle 0x4b30
leaq -0x48(%rbp), %r13
movl %r14d, %r12d
movl $0x5, %edx
movq %r15, %rdi
leaq 0x26dd(%rip), %rsi      # 0x71ef
callq 0x21f0
movb $0x20, -0x48(%rbp)
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x21f0
decl %r12d
jne 0x4b03
addl $0x2, %r14d
leaq -0x48(%rbp), %r12
movq %rbx, %rdi
callq 0x65f8
leal -0x1(%r14), %ecx
decl %eax
cmpl %eax, %ecx
jge 0x4c34
movq -0x210(%rbp), %rax
movq -0x18(%rax), %rcx
movq $0x5, -0x200(%rbp,%rcx)
movq -0x18(%rax), %rax
leaq (%r15,%rax), %r13
cmpb $0x0, -0x12f(%rbp,%rax)
jne 0x4b8c
movq %r13, %rdi
movl $0x20, %esi
callq 0x21a0
movb $0x1, 0xe1(%r13)
movb $0x30, 0xe0(%r13)
movq %r15, %rdi
movl %r14d, %esi
callq 0x22f0
movb $0x20, -0x48(%rbp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x21f0
incl %r14d
jmp 0x4b38
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
testl %r14d, %r14d
jle 0x4c5c
leaq -0x210(%rbp), %r15
negl %r14d
movl $0x1, %r13d
leaq -0x48(%rbp), %r12
movq %rbx, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x641e
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r15, %rdi
callq 0x21f0
leal (%r14,%r13), %eax
incl %eax
movl %r13d, %ecx
incl %ecx
movl %ecx, %r13d
cmpl $0x1, %eax
jne 0x4be8
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4c5c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x4c5c
leaq 0x25b4(%rip), %rsi      # 0x71ef
movl $0x5, %edx
movq %r15, %rdi
callq 0x21f0
leaq -0x48(%rbp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %r15, %rdi
callq 0x21f0
leaq -0x208(%rbp), %r14
leaq -0x98(%rbp), %rdi
movq %r14, %rsi
callq 0x22c0
movq %rbx, %rdi
callq 0x6602
leaq -0x68(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movl %eax, %edx
callq 0x537e
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4cab
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2402(%rip), %rdx      # 0x70bc
leaq -0x48(%rbp), %rdi
movq %rdx, %rsi
callq 0x2648
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x2290
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4ceb
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x68(%rbp), %rax
cmpq %rax, -0x60(%rbp)
je 0x4d31
movl $0x8, %r15d
leaq -0x210(%rbp), %r14
xorl %r12d, %r12d
movq -0x8(%rax,%r15), %rsi
movq (%rax,%r15), %rdx
movq %r14, %rdi
callq 0x21f0
incq %r12
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r15
cmpq %r12, %rcx
ja 0x4d05
leaq -0x48(%rbp), %rcx
leaq -0x38(%rbp), %rax
movq %rax, (%rcx)
movq $0x0, 0x8(%rcx)
movb $0x0, 0x10(%rcx)
leaq 0x68(%rbx), %rax
movq %rax, -0x70(%rbp)
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x65f8
cmpl %eax, %r12d
jge 0x4e04
leaq -0x220(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x20, %edx
callq 0x2320
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4e04
movq -0x48(%rbp), %r13
callq 0x2040
movq %rax, %r15
movl (%rax), %r14d
movl $0x0, (%rax)
movq %r13, %rdi
leaq -0x78(%rbp), %rsi
movl $0xa, %edx
callq 0x2260
cmpq %r13, -0x78(%rbp)
je 0x4e5c
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x4e68
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x4e68
testl %ecx, %ecx
jne 0x4dd6
movl %r14d, (%r15)
movl %eax, -0x4c(%rbp)
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0x4def
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x70(%rbx)
jmp 0x4dfc
movq -0x70(%rbp), %rdi
leaq -0x4c(%rbp), %rdx
callq 0x61a4
incl %r12d
jmp 0x4d53
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4e1d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x68(%rbp), %rdi
callq 0x25da
movq 0x518b(%rip), %rsi      # 0x9fb8
leaq -0x220(%rbp), %rdi
callq 0x2130
leaq -0x1a0(%rbp), %rdi
callq 0x20a0
movl $0x1, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2394(%rip), %rdi      # 0x71f7
callq 0x20f0
leaq 0x2388(%rip), %rdi      # 0x71f7
callq 0x2270
jmp 0x4ecd
jmp 0x4e9a
jmp 0x4ef4
movq %rax, %rbx
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4ef7
movq -0x88(%rbp), %rsi
jmp 0x4eb5
jmp 0x4ef4
jmp 0x4ecd
movq %rax, %rbx
jmp 0x4ee9
jmp 0x4ef4
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4ef7
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x4ef7
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x4ed0
movl %r14d, (%r15)
jmp 0x4ed0
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4ee9
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x68(%rbp), %rdi
callq 0x25da
jmp 0x4ef7
movq %rax, %rbx
movq 0x50ba(%rip), %rsi      # 0x9fb8
leaq -0x220(%rbp), %rdi
callq 0x2130
leaq -0x1a0(%rbp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2300