// File: /workspace/github_cpp_makefile_star2_O1/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 0x6618
cmpl $0x1, %eax
jne 0x4b76
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 0x4a7b
movq %r12, %rdi
movl $0x20, %esi
callq 0x21a0
movb %al, 0xe0(%r12)
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 0x4ae4
leaq -0x48(%rbp), %r13
movl %r14d, %r12d
movl $0x5, %edx
movq %r15, %rdi
leaq 0x2729(%rip), %rsi      # 0x71ef
callq 0x21f0
movb $0x20, -0x48(%rbp)
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x21f0
decl %r12d
jne 0x4ab7
addl $0x2, %r14d
leaq -0x48(%rbp), %r12
movq %rbx, %rdi
callq 0x6604
leal -0x1(%r14), %ecx
decl %eax
cmpl %eax, %ecx
jge 0x4bee
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 0x4b47
movq %r13, %rdi
movl $0x20, %esi
callq 0x21a0
movb %al, 0xe0(%r13)
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 0x4aec
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
testl %r14d, %r14d
jle 0x4bd3
leaq -0x210(%rbp), %r15
negl %r14d
movl $0x1, %r13d
leaq -0x48(%rbp), %r12
movq %rbx, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x642a
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 0x4ba2
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4c16
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x4c16
leaq 0x25fa(%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 0x660e
leaq -0x68(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movl %eax, %edx
callq 0x5342
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4c65
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x2448(%rip), %rdx      # 0x70bc
leaq -0x48(%rbp), %rdi
movq %rdx, %rsi
callq 0x2644
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x2290
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4ca5
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x68(%rbp), %rax
cmpq %rax, -0x60(%rbp)
je 0x4ceb
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 0x4cbf
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 0x6604
cmpl %eax, %r12d
jge 0x4dbe
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 0x4dbe
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 0x4e16
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x4e22
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x4e22
testl %ecx, %ecx
jne 0x4d90
movl %r14d, (%r15)
movl %eax, -0x4c(%rbp)
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0x4da9
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x70(%rbx)
jmp 0x4db6
movq -0x70(%rbp), %rdi
leaq -0x4c(%rbp), %rdx
callq 0x61b0
incl %r12d
jmp 0x4d0d
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4dd7
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x68(%rbp), %rdi
callq 0x25da
movq 0x51d1(%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 0x23da(%rip), %rdi      # 0x71f7
callq 0x20f0
leaq 0x23ce(%rip), %rdi      # 0x71f7
callq 0x2270
jmp 0x4e87
jmp 0x4e54
jmp 0x4eae
movq %rax, %rbx
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4eb1
movq -0x88(%rbp), %rsi
jmp 0x4e6f
jmp 0x4eae
jmp 0x4e87
movq %rax, %rbx
jmp 0x4ea3
jmp 0x4eae
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4eb1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x4eb1
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x4e8a
movl %r14d, (%r15)
jmp 0x4e8a
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x4ea3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x68(%rbp), %rdi
callq 0x25da
jmp 0x4eb1
movq %rax, %rbx
movq 0x5100(%rip), %rsi      # 0x9fb8
leaq -0x220(%rbp), %rdi
callq 0x2130
leaq -0x1a0(%rbp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2300