// File: RC2K7[P]SDisk-FileSystem/filesystem.cpp
// Function: FileSystem::initRoot()
int FileSystem::initRoot()
{
	stringstream ssBuffer;

    // FileSystem Was Just Created
	if (this->getStatusCode() == 1) {
        // Setup Root With Default Values
		for (int i = 0; i < this->rootSize; i++)
			ssBuffer << "....." << this->delimiter << "00000" << this->delimiter;
	} else { // FileSystem Previously Existed
		string temp;
		this->getBlock(0, temp);
		ssBuffer << temp;
	}

	vector<string>vecRoot = block(ssBuffer.str(), this->getBlockSize());
	ssBuffer.str(vecRoot[0]);

	{ // Local Scope
		int i;
		string entry;
		for (i = 0; i  < (this->rootSize * 2) && getline(ssBuffer, entry,
			this->delimiter); i++)
		{
			if (i % 2 == 0)
				this->rootFileName.push_back(entry);
			else
				this->rootFirstBlock.push_back(std::stoi(entry, nullptr, 10));
		}
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x31c0
movq -0x230(%rbp), %rdi
callq 0x9c10
movl %eax, -0x228(%rbp)
jmp 0x66ba
movl -0x228(%rbp), %eax
cmpl $0x1, %eax
jne 0x677d
movl $0x0, -0x1a0(%rbp)
movq -0x230(%rbp), %rcx
movl -0x1a0(%rbp), %eax
cmpl 0x2c(%rcx), %eax
jge 0x677b
leaq -0x180(%rbp), %rdi
leaq 0x3af2(%rip), %rsi      # 0xa1e9
callq 0x3280
movq %rax, -0x238(%rbp)
jmp 0x6705
movq -0x238(%rbp), %rdi
movl $0x20, %esi
callq 0x3330
movq %rax, -0x240(%rbp)
jmp 0x671f
movq -0x240(%rbp), %rdi
leaq 0x3ac2(%rip), %rsi      # 0xa1ef
callq 0x3280
movq %rax, -0x248(%rbp)
jmp 0x673b
movq -0x248(%rbp), %rdi
movl $0x20, %esi
callq 0x3330
jmp 0x674e
jmp 0x6750
movl -0x1a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a0(%rbp)
jmp 0x66d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x6a22
jmp 0x67ed
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x33e0
movq -0x230(%rbp), %rdi
movq -0x250(%rbp), %rdx
xorl %esi, %esi
callq 0x9840
jmp 0x67a7
leaq -0x180(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3230
jmp 0x67bc
leaq -0x1c0(%rbp), %rdi
callq 0x3170
jmp 0x67ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x3170
jmp 0x6a22
leaq -0x1f8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x3270
jmp 0x6802
movq -0x230(%rbp), %rdi
callq 0x9bf0
movl %eax, -0x254(%rbp)
jmp 0x6816
movl -0x254(%rbp), %edx
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x76a0
jmp 0x6831
leaq -0x1f8(%rbp), %rdi
callq 0x3170
xorl %eax, %eax
movl %eax, %esi
leaq -0x1d8(%rbp), %rdi
callq 0x5a80
movq %rax, %rsi
leaq -0x190(%rbp), %rdi
callq 0x3310
jmp 0x685e
leaq -0x220(%rbp), %rdi
callq 0x33e0
movl $0x0, -0x1fc(%rbp)
movq -0x230(%rbp), %rax
movl -0x1fc(%rbp), %ecx
movl 0x2c(%rax), %edx
shll %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x255(%rbp)
jge 0x68df
leaq -0x190(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movl $0x20, %edx
callq 0x34a0
movq %rax, -0x260(%rbp)
jmp 0x68b3
movq -0x260(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3380
movb %al, -0x261(%rbp)
jmp 0x68d1
movb -0x261(%rbp), %al
movb %al, -0x255(%rbp)
jmp 0x68df
movb -0x255(%rbp), %al
testb $0x1, %al
jne 0x68ee
jmp 0x69e4
movl -0x1fc(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x697c
movq -0x230(%rbp), %rdi
addq $0x38, %rdi
leaq -0x220(%rbp), %rsi
callq 0x8830
jmp 0x691a
jmp 0x69ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x3170
jmp 0x6a22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x6a16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x3170
jmp 0x6a16
movq -0x230(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x270(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x220(%rbp), %rdi
movl $0xa, %edx
callq 0x88d0
movl %eax, -0x268(%rbp)
jmp 0x69ab
movq -0x270(%rbp), %rdi
movl -0x268(%rbp), %eax
movl %eax, -0x224(%rbp)
leaq -0x224(%rbp), %rsi
callq 0x88a0
jmp 0x69cc
jmp 0x69ce
jmp 0x69d0
movl -0x1fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1fc(%rbp)
jmp 0x6874
leaq -0x220(%rbp), %rdi
callq 0x3170
leaq -0x1d8(%rbp), %rdi
callq 0x38d0
leaq -0x190(%rbp), %rdi
callq 0x31e0
movl $0x1, %eax
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
leaq -0x1d8(%rbp), %rdi
callq 0x38d0
leaq -0x190(%rbp), %rdi
callq 0x31e0
movq -0x198(%rbp), %rdi
callq 0x3470
nopw (%rax,%rax)