// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdi, %rbx
leaq -0x270(%rbp), %rdi
callq 0x2130
xorl %r13d, %r13d
pushq $0x20
popq %r15
pushq $0x30
popq %r12
xorl %r14d, %r14d
movslq 0x2c(%rbx), %rax
cmpq %rax, %r14
jge 0x3fdd
movq 0x38(%rbx), %rsi
addq %r13, %rsi
leaq -0x260(%rbp), %rdi
callq 0x21a0
movq %rax, %rdi
movl %r15d, %esi
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x5, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %r12d, %esi
callq 0x22e0
movq 0x50(%rbx), %rcx
movl (%rcx,%r14,4), %esi
movq %rax, %rdi
callq 0x2320
movq %rax, %rdi
movl %r15d, %esi
callq 0x2210
incq %r14
addq $0x20, %r13
jmp 0x3f77
leaq -0x258(%rbp), %r15
leaq -0xc8(%rbp), %rdi
movq %r15, %rsi
callq 0x22f0
movq %rbx, %rdi
callq 0x51b4
leaq -0x68(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
movl %eax, %edx
callq 0x4216
leaq -0xc8(%rbp), %rdi
callq 0x20e0
movq -0x68(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x2290
leaq -0xa8(%rbp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x50d6
leaq -0xa8(%rbp), %rdi
callq 0x20e0
leaq 0x206f(%rip), %rsi      # 0x60bc
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x258e
leaq -0x50(%rbp), %rsi
movq %r15, %rdi
callq 0x22c0
leaq -0x50(%rbp), %rdi
callq 0x20e0
xorl %r14d, %r14d
pushq $0x30
popq %r12
pushq $0x20
popq %r13
movq 0x70(%rbx), %rax
subq 0x68(%rbx), %rax
sarq $0x2, %rax
cmpq %r14, %rax
jbe 0x40d1
movq -0x260(%rbp), %rax
movq -0x18(%rax), %rax
movq $0x5, -0x250(%rbp,%rax)
leaq -0x260(%rbp), %rdi
movl %r12d, %esi
callq 0x22e0
movq 0x68(%rbx), %rcx
movl (%rcx,%r14,4), %esi
movq %rax, %rdi
callq 0x2320
movq %rax, %rdi
movl %r13d, %esi
callq 0x2210
incq %r14
jmp 0x407a
leaq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0x22f0
movq %rbx, %rdi
callq 0x51b4
leaq -0x50(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl %eax, %edx
callq 0x4216
leaq -0x88(%rbp), %rdi
callq 0x20e0
xorl %r15d, %r15d
leaq -0xe8(%rbp), %r14
xorl %r12d, %r12d
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r12, %rax
jbe 0x4153
addq %r15, %rsi
movq %r14, %rdi
callq 0x2290
leal 0x1(%r12), %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x50d6
movq %r14, %rdi
callq 0x20e0
addq $0x20, %r15
incq %r12
jmp 0x4113
leaq -0x50(%rbp), %rdi
callq 0x25fc
leaq -0x68(%rbp), %rdi
callq 0x25fc
leaq -0x270(%rbp), %rdi
callq 0x2150
pushq $0x1
popq %rax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x41e4
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
jmp 0x41ad
jmp 0x41e4
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
jmp 0x41ad
jmp 0x41e4
jmp 0x41f2
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x20e0
jmp 0x41e7
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x20e0
jmp 0x41f5
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x20e0
jmp 0x41d9
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x25fc
jmp 0x41e7
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x25fc
jmp 0x41f5
movq %rax, %rbx
leaq -0x270(%rbp), %rdi
callq 0x2150
movq %rbx, %rdi
callq 0x2330
nop