// File: emr4378[P]FAT-File-System/FileSys.cpp
// Function: FileSys::printFAT(int)
void FileSys::printFAT(int width) {
	int i;
	string titleRow;
	string rowDivide;
	string title = "File Allocation Table";
	for (i = 0; i < width; i++) {
		rowDivide += "-----------";
	}
	titleRow = rowDivide;
	
	cout << titleRow.replace(titleRow.length()/2-title.length()/2, 
							title.length(), title);
	for (i = 0; i < numClusters; i++) {
		if (i % width == 0) {
			cout << endl;
		}
		cout << "\033[1;1m" << setw(4) << i << ":";
		if (fileAllocationTable[i] == 0x0000) {
			cout << "\033[0;32m";
		} else if (fileAllocationTable[i] >= 0xFFFE) {
			cout << "\033[0;31m";
		} else {
			cout << "\033[0;34m";
		}
		cout << setw(5) << fileAllocationTable[i];
		cout << "\033[0m" << "|";

	}
	cout << endl << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3430
leaq -0x50(%rbp), %rdi
callq 0x3430
leaq -0x71(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3540
movq -0x98(%rbp), %rdx
leaq 0x5b2f(%rip), %rsi      # 0xc06c
leaq -0x70(%rbp), %rdi
callq 0x6e60
jmp 0x6548
leaq -0x71(%rbp), %rdi
callq 0x3300
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x65b9
leaq 0x5b1b(%rip), %rsi      # 0xc082
leaq -0x50(%rbp), %rdi
callq 0x3280
jmp 0x6572
jmp 0x6574
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x6558
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x3300
jmp 0x6872
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3180
jmp 0x6872
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3050
jmp 0x65c8
leaq -0x30(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x3470
shrq %rax
movq %rax, -0xc8(%rbp)
leaq -0x70(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3470
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movq -0xc8(%rbp), %rax
shrq %rcx
subq %rcx, %rax
movq %rax, -0xb8(%rbp)
callq 0x3470
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rcx
movq %rax, %rdx
callq 0x30e0
movq %rax, -0xa8(%rbp)
jmp 0x663b
movq -0xa8(%rbp), %rsi
movq 0x9987(%rip), %rdi      # 0xffd0
callq 0x3220
jmp 0x6650
movl $0x0, -0x10(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x10(%rbp), %eax
cmpl 0x30(%rcx), %eax
jge 0x681d
movl -0x10(%rbp), %eax
cltd
idivl -0xc(%rbp)
cmpl $0x0, %edx
jne 0x668d
movq 0x9953(%rip), %rdi      # 0xffd0
movq 0x993c(%rip), %rsi      # 0xffc0
callq 0x32e0
jmp 0x668b
jmp 0x668d
movq 0x993c(%rip), %rdi      # 0xffd0
leaq 0x59f3(%rip), %rsi      # 0xc08e
callq 0x3290
movq %rax, -0xd0(%rbp)
jmp 0x66a9
movl $0x4, %edi
callq 0x6e10
movl %eax, -0xd4(%rbp)
jmp 0x66bb
movq -0xd0(%rbp), %rdi
movl -0xd4(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %esi
callq 0x3340
movq %rax, -0xe0(%rbp)
jmp 0x66e2
movq -0xe0(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x3520
movq %rax, -0xe8(%rbp)
jmp 0x66fa
movq -0xe8(%rbp), %rdi
leaq 0x5af1(%rip), %rsi      # 0xc1f9
callq 0x3290
jmp 0x670f
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x10(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x673b
movq 0x98a5(%rip), %rdi      # 0xffd0
leaq 0x5963(%rip), %rsi      # 0xc095
callq 0x3290
jmp 0x6739
jmp 0x6783
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x10(%rbp), %rcx
cmpl $0xfffe, (%rax,%rcx,4)  # imm = 0xFFFE
jl 0x676a
movq 0x9876(%rip), %rdi      # 0xffd0
leaq 0x593c(%rip), %rsi      # 0xc09d
callq 0x3290
jmp 0x6768
jmp 0x6781
movq 0x985f(%rip), %rdi      # 0xffd0
leaq 0x592d(%rip), %rsi      # 0xc0a5
callq 0x3290
jmp 0x677f
jmp 0x6781
jmp 0x6783
movl $0x5, %edi
callq 0x6e10
movl %eax, -0xec(%rbp)
jmp 0x6795
movl -0xec(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %esi
movq 0x9822(%rip), %rdi      # 0xffd0
callq 0x3340
movq %rax, -0xf8(%rbp)
jmp 0x67bc
movq -0xf8(%rbp), %rdi
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x10(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x3520
jmp 0x67dc
movq 0x97ed(%rip), %rdi      # 0xffd0
leaq 0x58c3(%rip), %rsi      # 0xc0ad
callq 0x3290
movq %rax, -0x100(%rbp)
jmp 0x67f8
movq -0x100(%rbp), %rdi
leaq 0x58ac(%rip), %rsi      # 0xc0b2
callq 0x3290
jmp 0x680d
jmp 0x680f
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x6657
movq 0x97ac(%rip), %rdi      # 0xffd0
movq 0x9795(%rip), %rsi      # 0xffc0
callq 0x32e0
movq %rax, -0x108(%rbp)
jmp 0x6839
movq -0x108(%rbp), %rdi
movq 0x9779(%rip), %rsi      # 0xffc0
callq 0x32e0
jmp 0x684e
leaq -0x70(%rbp), %rdi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3180
leaq -0x30(%rbp), %rdi
callq 0x3180
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x3180
leaq -0x30(%rbp), %rdi
callq 0x3180
movq -0x80(%rbp), %rdi
callq 0x3530
nopl (%rax)