// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rsi, %rbx
movq %rdi, -0x50(%rbp)
leaq -0x2a0(%rbp), %r14
movq %r14, %rdi
callq 0x21a0
movq (%rbx), %rsi
pushq $0x18
popq %rdx
movq %r14, %rdi
callq 0x2130
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq -0x2a0(%rbp), %r15
leaq -0x70(%rbp), %r12
leaq 0x1e07(%rip), %rbx      # 0x51eb
leaq -0x44(%rbp), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x2030
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x343f
movq %r12, %rdi
leaq 0x1d0b(%rip), %rsi      # 0x5116
callq 0x37c8
testb %al, %al
je 0x33e8
movq -0x70(%rbp), %rdi
movq %rbx, %rsi
callq 0x21e0
testq %rax, %rax
je 0x33e8
movq %rax, %rdi
callq 0x21d0
movl %eax, -0x44(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x4618
xorl %edi, %edi
jmp 0x3418
addq $0x8, -0x50(%rbp)
pushq $0x1
popq %r14
xorl %ebx, %ebx
leaq -0x90(%rbp), %r15
pushq $-0x1
popq %r12
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
shrq $0x2, %rax
cltq
cmpq %rax, %rbx
jge 0x353f
movq %r15, %rdi
movl %r14d, %esi
callq 0x29f2
movq %r15, %rdi
movl %r12d, %esi
callq 0x2a02
movq -0x40(%rbp), %rax
movl (%rax,%rbx,4), %esi
movq %r15, %rdi
callq 0x2a12
movq -0x40(%rbp), %rax
movl 0x4(%rax,%rbx,4), %esi
movq %r15, %rdi
callq 0x29fa
movq -0x40(%rbp), %rax
movl 0x8(%rax,%rbx,4), %esi
movq %r15, %rdi
callq 0x2a1a
movq -0x40(%rbp), %rax
movl 0xc(%rax,%rbx,4), %esi
movq %r15, %rdi
callq 0x2a0a
movq -0x40(%rbp), %rax
xorl %esi, %esi
cmpl $0x0, 0x10(%rax,%rbx,4)
setne %sil
movq %r15, %rdi
callq 0x2a2c
movq -0x40(%rbp), %rax
xorl %esi, %esi
cmpl $0x0, 0x14(%rax,%rbx,4)
setne %sil
movq %r15, %rdi
callq 0x2a22
movq -0x40(%rbp), %rax
xorl %esi, %esi
cmpl $0x0, 0x18(%rax,%rbx,4)
setne %sil
movq %r15, %rdi
callq 0x2a36
movq -0x40(%rbp), %rax
xorl %esi, %esi
cmpl $0x0, 0x1c(%rax,%rbx,4)
setne %sil
movq %r15, %rdi
callq 0x2a40
movq %r15, %rdi
xorl %esi, %esi
callq 0x2a4a
movq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x37d6
incl %r14d
addq $0x8, %rbx
jmp 0x3455
leaq -0x40(%rbp), %rdi
callq 0x45f4
leaq -0x70(%rbp), %rdi
callq 0x20c0
leaq -0x2a0(%rbp), %rdi
callq 0x2040
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x358d
jmp 0x3578
jmp 0x3578
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x45f4
leaq -0x70(%rbp), %rdi
callq 0x20c0
leaq -0x2a0(%rbp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2240
nop