// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, %rbx
leaq -0x210(%rbp), %rdi
callq 0x2130
movl 0x30(%rbx), %r14d
movq %rbx, %rdi
callq 0x51be
cmpl $0x1, %eax
jne 0x3cd8
leaq -0x200(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq $0x5, -0x1f0(%rbp,%rax)
pushq $0x30
popq %rsi
callq 0x22e0
leal 0x1(%r14), %esi
movq %rax, %rdi
callq 0x2320
pushq $0x20
popq %rsi
movq %rax, %rdi
callq 0x2210
xorl %r15d, %r15d
testl %r14d, %r14d
cmovgl %r14d, %r15d
leaq 0x253d(%rip), %r12      # 0x61ef
pushq $0x20
popq %r13
subl $0x1, %r15d
jb 0x3d36
leaq -0x200(%rbp), %rdi
movq %r12, %rsi
callq 0x21d0
movq %rax, %rdi
movl %r13d, %esi
callq 0x2210
jmp 0x3cb6
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %r13d, %r13d
testl %r14d, %r14d
cmovgl %r14d, %r13d
leaq -0x200(%rbp), %r14
negl %r13d
pushq $0x1
popq %r15
leaq -0x50(%rbp), %r12
leal (%r15,%r13), %eax
cmpl $0x1, %eax
je 0x3d2b
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x4ff8
movq %r14, %rdi
movq %r12, %rsi
callq 0x21a0
incl %r15d
jmp 0x3d04
leaq -0x50(%rbp), %rdi
callq 0x20e0
jmp 0x3db3
addl $0x2, %r14d
pushq $0x30
popq %r12
pushq $0x20
popq %r13
movq %rbx, %rdi
callq 0x51aa
leal -0x1(%r14), %ecx
decl %eax
cmpl %eax, %ecx
jge 0x3d95
movq -0x200(%rbp), %rax
movq -0x18(%rax), %rax
movq $0x5, -0x1f0(%rbp,%rax)
leaq -0x200(%rbp), %rdi
movl %r12d, %esi
callq 0x22e0
movq %rax, %rdi
movl %r14d, %esi
callq 0x2320
incl %r14d
movq %rax, %rdi
movl %r13d, %esi
callq 0x2210
jmp 0x3d42
leaq 0x2453(%rip), %rsi      # 0x61ef
leaq -0x200(%rbp), %rdi
callq 0x21d0
pushq $0x20
popq %rsi
movq %rax, %rdi
callq 0x2210
leaq -0x1f8(%rbp), %r14
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0x22f0
movq %rbx, %rdi
callq 0x51b4
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl %eax, %edx
callq 0x4216
leaq -0x88(%rbp), %rdi
callq 0x20e0
leaq 0x22c6(%rip), %rsi      # 0x60bc
leaq -0x50(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x258e
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x22c0
leaq -0x50(%rbp), %rdi
callq 0x20e0
leaq -0x200(%rbp), %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r12, %rax
jbe 0x3e4d
addq %r15, %rsi
movq %r14, %rdi
callq 0x21a0
incq %r12
addq $0x20, %r15
jmp 0x3e25
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x68(%rbx), %r14
xorl %r15d, %r15d
leaq -0x50(%rbp), %r12
pushq $0x20
popq %r13
movq %rbx, %rdi
callq 0x51aa
cmpl %eax, %r15d
jge 0x3eba
leaq -0x210(%rbp), %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x2350
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3eba
movq %r12, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x4b21
movl %eax, -0x2c(%rbp)
movq %r14, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x4d44
incl %r15d
jmp 0x3e6c
leaq -0x50(%rbp), %rdi
callq 0x20e0
leaq -0x68(%rbp), %rdi
callq 0x25fc
leaq -0x210(%rbp), %rdi
callq 0x2150
pushq $0x1
popq %rax
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3f18
jmp 0x3f03
jmp 0x3f2f
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
jmp 0x3f11
jmp 0x3f2f
jmp 0x3f18
movq %rax, %rbx
jmp 0x3f24
jmp 0x3f2f
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x20e0
jmp 0x3f32
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x20e0
leaq -0x68(%rbp), %rdi
callq 0x25fc
jmp 0x3f32
movq %rax, %rbx
leaq -0x210(%rbp), %rdi
callq 0x2150
movq %rbx, %rdi
callq 0x2330