// File: /workspace/github_cpp_makefile_star2_O3/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 -0x268(%rbp), %rdi
callq 0x2110
cmpl $0x0, 0x2c(%rbx)
jle 0x5000
movl $0x8, %r14d
xorl %r15d, %r15d
movq 0x38(%rbx), %rax
movq -0x8(%rax,%r14), %rsi
movq (%rax,%r14), %rdx
leaq -0x258(%rbp), %rdi
callq 0x21f0
movb $0x20, -0x48(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x48(%rbp), %rsi
callq 0x21f0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rcx
movq $0x5, 0x10(%r12,%rcx)
movq -0x18(%rax), %rax
movq %r12, %r13
addq %rax, %r13
cmpb $0x0, 0xe1(%r12,%rax)
jne 0x4fbf
movq %r13, %rdi
movl $0x20, %esi
callq 0x21a0
movb $0x1, 0xe1(%r13)
movb $0x30, 0xe0(%r13)
movq 0x50(%rbx), %rax
movl (%rax,%r15,4), %esi
movq %r12, %rdi
callq 0x22f0
movb $0x20, -0x48(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x48(%rbp), %rsi
callq 0x21f0
incq %r15
movslq 0x2c(%rbx), %rax
addq $0x20, %r14
cmpq %rax, %r15
jl 0x4f54
leaq -0x250(%rbp), %r15
leaq -0xc8(%rbp), %rdi
movq %r15, %rsi
callq 0x22c0
movq %rbx, %rdi
callq 0x6602
leaq -0xe0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
movl %eax, %edx
callq 0x537e
leaq -0xb8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5052
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xe0(%rbp), %rax
leaq -0x78(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x4218
leaq -0x88(%rbp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x650c
movq -0x88(%rbp), %rdi
cmpq %r14, %rdi
je 0x50a0
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x38(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x200d(%rip), %rdx      # 0x70bc
leaq -0x48(%rbp), %rdi
movq %rdx, %rsi
callq 0x2648
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x2290
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x50dc
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
movq 0x68(%rbx), %rax
cmpq %rax, 0x70(%rbx)
je 0x517d
leaq -0x258(%rbp), %r15
xorl %r14d, %r14d
leaq -0x48(%rbp), %r12
movq -0x258(%rbp), %rcx
movq -0x18(%rcx), %rdx
movq $0x5, -0x248(%rbp,%rdx)
movq -0x18(%rcx), %rcx
leaq (%r15,%rcx), %r13
cmpb $0x0, -0x177(%rbp,%rcx)
jne 0x513a
movq %r13, %rdi
movl $0x20, %esi
callq 0x21a0
movb $0x1, 0xe1(%r13)
movq 0x68(%rbx), %rax
movb $0x30, 0xe0(%r13)
movl (%rax,%r14,4), %esi
movq %r15, %rdi
callq 0x22f0
movb $0x20, -0x48(%rbp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x21f0
incq %r14
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x50f8
leaq -0xa8(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x22c0
movq %rbx, %rdi
callq 0x6602
leaq -0x48(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl %eax, %edx
callq 0x537e
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x51c9
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x48(%rbp), %rax
cmpq %rax, -0x40(%rbp)
je 0x523b
movl $0x8, %r12d
leaq -0x58(%rbp), %r15
xorl %r13d, %r13d
leaq -0x68(%rbp), %r14
movq %r15, -0x68(%rbp)
movq -0x8(%rax,%r12), %rsi
movq (%rax,%r12), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x4218
leal 0x1(%r13), %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x650c
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x5220
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
incq %r13
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r12
cmpq %r13, %rcx
ja 0x51e4
leaq -0x48(%rbp), %rdi
callq 0x25da
leaq -0xe0(%rbp), %rdi
callq 0x25da
movq 0x4d61(%rip), %rsi      # 0x9fb8
leaq -0x268(%rbp), %rdi
callq 0x2130
leaq -0x1e8(%rbp), %rdi
callq 0x20a0
movl $0x1, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5336
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x5339
movq -0x38(%rbp), %rsi
jmp 0x52e0
jmp 0x5336
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r14, %rdi
je 0x5339
movq -0x78(%rbp), %rsi
jmp 0x52e0
jmp 0x5336
jmp 0x5347
movq %rax, %rbx
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5339
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x5339
movq %rax, %rbx
leaq -0xb8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x534a
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x534a
movq %rax, %rbx
jmp 0x532b
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x532b
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x48(%rbp), %rdi
callq 0x25da
jmp 0x5339
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x25da
jmp 0x534a
movq %rax, %rbx
movq 0x4c67(%rip), %rsi      # 0x9fb8
leaq -0x268(%rbp), %rdi
callq 0x2130
leaq -0x1e8(%rbp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2300
nop