// File: marcellapantarotto[P]pseudoSO/scheduler.cpp
// Function: Scheduler::readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Scheduler::readFile(string filename) {
	fstream txt;	// realiza operações de E/S em algum arquivo
	txt.open(filename.c_str());		// abrindo arquivo .txt
	string data;
	vector<int> tmp;
	char *ptr;
	Process p;
	int id = 1;

	while(getline(txt, data)) 	{
		if(data != "") {
			ptr = strtok((char*)data.c_str(),"\t ,");	// divide string em tokens
			while(ptr != NULL) {
				tmp.push_back(atoi(ptr));
				ptr = strtok(NULL,"\t ,");
			}
		}
	}

	// atibuição dos valores do processo a instancia
	for(int i = 0; i < (int)tmp.size(); i += 8) {
		p.setPID(id);
		p.setMemoryOffset(-1);
		p.setInitTime(tmp[i]);
		p.setPriority(tmp[i+1]);
		p.setExecutionTime(tmp[i+2]);
		p.setAmoutBlocks(tmp[i+3]);
		p.setPrinter(tmp[i+4]);
		p.setScanner(tmp[i+5]);
		p.setModem(tmp[i+6]);
		p.setSata(tmp[i+7]);
		p.setBlockedResource(WITHOUT_RESOURCES);
		processes.push_back(p);
		id++;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rsi, -0x2b0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x21c0
movq -0x2b0(%rbp), %rdi
callq 0x20b0
movq %rax, -0x2a8(%rbp)
movl $0x8, %edi
movl $0x10, %esi
callq 0x59d0
movl %eax, -0x2a0(%rbp)
jmp 0x4fbb
movl -0x2a0(%rbp), %edx
movq -0x2a8(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x2130
jmp 0x4fd6
leaq -0x250(%rbp), %rdi
callq 0x21f0
leaq -0x268(%rbp), %rdi
callq 0x59f0
leaq -0x290(%rbp), %rdi
callq 0x5700
jmp 0x4ffc
movl $0x1, -0x294(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x2030
movq %rax, -0x2c0(%rbp)
jmp 0x5022
movq -0x2c0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x21d0
movb %al, -0x2c1(%rbp)
jmp 0x5040
movb -0x2c1(%rbp), %al
testb $0x1, %al
jne 0x504f
jmp 0x5136
leaq 0x5105(%rip), %rsi      # 0xa15b
leaq -0x250(%rbp), %rdi
callq 0x5a10
movb %al, -0x2c2(%rbp)
jmp 0x506a
movb -0x2c2(%rbp), %al
testb $0x1, %al
jne 0x5079
jmp 0x5131
leaq -0x250(%rbp), %rdi
callq 0x20b0
movq %rax, %rdi
leaq 0x51a1(%rip), %rsi      # 0xa230
callq 0x2230
movq %rax, -0x270(%rbp)
cmpq $0x0, -0x270(%rbp)
je 0x512f
movq -0x270(%rbp), %rdi
callq 0x2220
movl %eax, -0x298(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x5a40
jmp 0x50d0
xorl %eax, %eax
movl %eax, %edi
leaq 0x5155(%rip), %rsi      # 0xa230
callq 0x2230
movq %rax, -0x270(%rbp)
jmp 0x509b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5363
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x5b20
leaq -0x250(%rbp), %rdi
callq 0x20e0
jmp 0x5363
jmp 0x5131
jmp 0x5006
movl $0x0, -0x29c(%rbp)
movl -0x29c(%rbp), %eax
movl %eax, -0x2c8(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x5a70
movq %rax, %rcx
movl -0x2c8(%rbp), %eax
cmpl %ecx, %eax
jge 0x5336
movl -0x294(%rbp), %esi
leaq -0x290(%rbp), %rdi
callq 0x36f0
jmp 0x517d
leaq -0x290(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x3770
jmp 0x5190
movslq -0x29c(%rbp), %rsi
leaq -0x268(%rbp), %rdi
callq 0x5a90
movl (%rax), %esi
leaq -0x290(%rbp), %rdi
callq 0x37f0
jmp 0x51b3
movl -0x29c(%rbp), %eax
incl %eax
movslq %eax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x5a90
movl (%rax), %esi
leaq -0x290(%rbp), %rdi
callq 0x3730
jmp 0x51da
movl -0x29c(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x5a90
movl (%rax), %esi
leaq -0x290(%rbp), %rdi
callq 0x3830
jmp 0x5202
movl -0x29c(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x5a90
movl (%rax), %esi
leaq -0x290(%rbp), %rdi
callq 0x37b0
jmp 0x522a
movl -0x29c(%rbp), %eax
addl $0x4, %eax
movslq %eax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x5a90
movl (%rax), %eax
testl %eax, %eax
setne %al
movzbl %al, %esi
leaq -0x290(%rbp), %rdi
callq 0x38b0
jmp 0x525a
movl -0x29c(%rbp), %eax
addl $0x5, %eax
movslq %eax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x5a90
movl (%rax), %eax
testl %eax, %eax
setne %al
movzbl %al, %esi
leaq -0x290(%rbp), %rdi
callq 0x3870
jmp 0x528a
movl -0x29c(%rbp), %eax
addl $0x6, %eax
movslq %eax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x5a90
movl (%rax), %eax
testl %eax, %eax
setne %al
movzbl %al, %esi
leaq -0x290(%rbp), %rdi
callq 0x38f0
jmp 0x52ba
movl -0x29c(%rbp), %eax
addl $0x7, %eax
movslq %eax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x5a90
movl (%rax), %eax
testl %eax, %eax
setne %al
movzbl %al, %esi
leaq -0x290(%rbp), %rdi
callq 0x3930
jmp 0x52ea
leaq -0x290(%rbp), %rdi
xorl %esi, %esi
callq 0x3970
jmp 0x52fa
movq -0x2b8(%rbp), %rdi
addq $0x8, %rdi
leaq -0x290(%rbp), %rsi
callq 0x5ab0
jmp 0x5313
movl -0x294(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x294(%rbp)
movl -0x29c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x29c(%rbp)
jmp 0x5140
leaq -0x268(%rbp), %rdi
callq 0x5b20
leaq -0x250(%rbp), %rdi
callq 0x20e0
leaq -0x220(%rbp), %rdi
callq 0x2040
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x2040
movq -0x228(%rbp), %rdi
callq 0x2280
nopl (%rax,%rax)