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

	//Write Root To SDisk
	for (int i = 0; i < this->rootSize; i++)
		ssBuffer << this->rootFileName[i] << this->delimiter << setw(5) <<
			setfill('0') << this->rootFirstBlock[i] << this->delimiter;
	vector<string> vecRoot = block(ssBuffer.str(), this->getBlockSize());
	this->putBlock(0, vecRoot[0]);

	ssBuffer.str("");

	//Write fat To SDisk
	for (int i = 0; i < this->fat.size(); i++)
		ssBuffer << setw(5) << setfill('0') << fat[i] << this->delimiter;
	vector<string> vecFAT = block(ssBuffer.str(), this->getBlockSize());
	for (int i = 0; i < vecFAT.size(); i++)
		this->putBlock((1 + i), vecFAT[i]);

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2a0(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x31c0
movl $0x0, -0x194(%rbp)
movq -0x2a0(%rbp), %rcx
movl -0x194(%rbp), %eax
cmpl 0x2c(%rcx), %eax
jge 0x723e
movq -0x2a0(%rbp), %rdi
leaq -0x180(%rbp), %rax
movq %rax, -0x2b0(%rbp)
addq $0x38, %rdi
movslq -0x194(%rbp), %rsi
callq 0x5a80
movq -0x2b0(%rbp), %rdi
movq %rax, %rsi
callq 0x3230
movq %rax, -0x2a8(%rbp)
jmp 0x7143
movq -0x2a8(%rbp), %rdi
movl $0x20, %esi
callq 0x3330
movq %rax, -0x2b8(%rbp)
jmp 0x715d
movl $0x5, %edi
callq 0x8720
movl %eax, -0x2bc(%rbp)
jmp 0x716f
movq -0x2b8(%rbp), %rdi
movl -0x2bc(%rbp), %eax
movl %eax, -0x1a8(%rbp)
movl -0x1a8(%rbp), %esi
callq 0x3320
movq %rax, -0x2c8(%rbp)
jmp 0x7196
movl $0x30, %edi
callq 0x8740
movb %al, -0x2c9(%rbp)
jmp 0x71a8
movq -0x2c8(%rbp), %rdi
movb -0x2c9(%rbp), %al
movb %al, -0x1a9(%rbp)
movzbl -0x1a9(%rbp), %esi
callq 0x3430
movq %rax, -0x2d8(%rbp)
jmp 0x71d0
movq -0x2a0(%rbp), %rdi
addq $0x50, %rdi
movslq -0x194(%rbp), %rsi
callq 0x8760
movq -0x2d8(%rbp), %rdi
movl (%rax), %esi
callq 0x3460
movq %rax, -0x2e0(%rbp)
jmp 0x71fe
movq -0x2e0(%rbp), %rdi
movl $0x20, %esi
callq 0x3330
jmp 0x7211
jmp 0x7213
movl -0x194(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x194(%rbp)
jmp 0x70f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x766f
leaq -0x1e8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x3270
jmp 0x7253
movq -0x2a0(%rbp), %rdi
callq 0x9bf0
movl %eax, -0x2e4(%rbp)
jmp 0x7267
movl -0x2e4(%rbp), %edx
leaq -0x1c8(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x76a0
jmp 0x7282
leaq -0x1e8(%rbp), %rdi
callq 0x3170
xorl %eax, %eax
movl %eax, %esi
leaq -0x1c8(%rbp), %rdi
callq 0x5a80
movq %rax, %rsi
leaq -0x208(%rbp), %rdi
callq 0x3100
jmp 0x72af
movq -0x2a0(%rbp), %rdi
xorl %esi, %esi
leaq -0x208(%rbp), %rdx
callq 0x99d0
jmp 0x72c6
leaq -0x208(%rbp), %rdi
callq 0x3170
leaq -0x229(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x3480
movq -0x2f0(%rbp), %rdx
leaq 0x2dc9(%rip), %rsi      # 0xa0bc
leaq -0x228(%rbp), %rdi
callq 0x3750
jmp 0x7301
leaq -0x190(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x3310
jmp 0x7316
leaq -0x228(%rbp), %rdi
callq 0x3170
leaq -0x229(%rbp), %rdi
callq 0x32e0
movl $0x0, -0x230(%rbp)
movq -0x2a0(%rbp), %rdi
movslq -0x230(%rbp), %rax
movq %rax, -0x2f8(%rbp)
addq $0x68, %rdi
callq 0x8780
movq %rax, %rcx
movq -0x2f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x74e1
leaq -0x180(%rbp), %rax
movq %rax, -0x308(%rbp)
movl $0x5, %edi
callq 0x8720
movl %eax, -0x2fc(%rbp)
jmp 0x7389
movq -0x308(%rbp), %rdi
movl -0x2fc(%rbp), %eax
movl %eax, -0x234(%rbp)
movl -0x234(%rbp), %esi
callq 0x3320
movq %rax, -0x310(%rbp)
jmp 0x73b0
movl $0x30, %edi
callq 0x8740
movb %al, -0x311(%rbp)
jmp 0x73c2
movq -0x310(%rbp), %rdi
movb -0x311(%rbp), %al
movb %al, -0x235(%rbp)
movzbl -0x235(%rbp), %esi
callq 0x3430
movq %rax, -0x320(%rbp)
jmp 0x73ea
movq -0x2a0(%rbp), %rdi
addq $0x68, %rdi
movslq -0x230(%rbp), %rsi
callq 0x8760
movq -0x320(%rbp), %rdi
movl (%rax), %esi
callq 0x3460
movq %rax, -0x328(%rbp)
jmp 0x7418
movq -0x328(%rbp), %rdi
movl $0x20, %esi
callq 0x3330
jmp 0x742b
jmp 0x742d
movl -0x230(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x230(%rbp)
jmp 0x7338
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x3170
jmp 0x766f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x7663
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x3170
jmp 0x7663
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x74d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x3170
leaq -0x229(%rbp), %rdi
callq 0x32e0
jmp 0x7663
leaq -0x270(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x3270
jmp 0x74f6
movq -0x2a0(%rbp), %rdi
callq 0x9bf0
movl %eax, -0x32c(%rbp)
jmp 0x750a
movl -0x32c(%rbp), %edx
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x76a0
jmp 0x7525
leaq -0x270(%rbp), %rdi
callq 0x3170
movl $0x0, -0x274(%rbp)
movslq -0x274(%rbp), %rax
movq %rax, -0x338(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x5a60
movq %rax, %rcx
movq -0x338(%rbp), %rax
cmpq %rcx, %rax
jae 0x7625
movslq -0x274(%rbp), %rsi
movl %esi, %eax
incl %eax
movl %eax, -0x33c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x5a80
movq %rax, %rsi
leaq -0x298(%rbp), %rdi
callq 0x3100
jmp 0x7596
movl -0x33c(%rbp), %esi
movq -0x2a0(%rbp), %rdi
leaq -0x298(%rbp), %rdx
callq 0x99d0
jmp 0x75b1
leaq -0x298(%rbp), %rdi
callq 0x3170
movl -0x274(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x274(%rbp)
jmp 0x753b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x3170
jmp 0x7663
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x7657
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x3170
jmp 0x7657
leaq -0x250(%rbp), %rdi
callq 0x38d0
leaq -0x1c8(%rbp), %rdi
callq 0x38d0
leaq -0x190(%rbp), %rdi
callq 0x31e0
movl $0x1, %eax
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
leaq -0x250(%rbp), %rdi
callq 0x38d0
leaq -0x1c8(%rbp), %rdi
callq 0x38d0
leaq -0x190(%rbp), %rdi
callq 0x31e0
movq -0x1a0(%rbp), %rdi
callq 0x3470
nopw (%rax,%rax)