// File: /workspace/github_cpp_makefile_star2_O3/CDISC2020[P]Projet_satellite_agile/src/planManager/plan.cpp
// Function: Plan::loadPlan(char const*)
void Plan::loadPlan(const char* filepath)
{
	ifstream  readFile;
	readFile.open(filepath);
	string type;
	
	cout << "Starting the reading of a the plan "<< filepath<< endl;
	
	GenericInstruction * planInstruction;
	string planLine;
	int line = 0;
	
	if (readFile.is_open())	
	{
		cout << "\t File " << filepath<< " opened \n";
		while(  getline (readFile, planLine) ) 
		{
			if (planLine != "\n" && planLine.length()>6)
			{
				type = planLine.substr(6,1);
				
				if (type == "a")
				{
					planInstruction = new AttitudeInstruction(planLine); 
				} 
				
				else if (type == "p") 
				{
					planInstruction = new PhotoInstruction(planLine); 
				}
				else
				{
					//Message d'erreur!
				}
				this->stockInstruction(planInstruction);
				line ++;
			}
		}

		cout << "Lines read: "<< line << endl;
		readFile.close();
	}
	else
	{
		cout <<endl <<"File not found bitch!!!!"<< endl;	
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rsi, %rbx
movq %rdi, -0x38(%rbp)
leaq -0x2e0(%rbp), %r14
movq %r14, %rdi
callq 0x32e0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x3180
leaq -0xa8(%rbp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movq 0x558b(%rip), %r15      # 0x9fd0
leaq 0x2866(%rip), %rsi      # 0x72b2
movl $0x23, %edx
movq %r15, %rdi
callq 0x3300
testq %rbx, %rbx
je 0x4a7a
movq %rbx, %rdi
callq 0x3130
movq 0x5563(%rip), %rdi      # 0x9fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3300
jmp 0x4a92
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x3440
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq 0x5520(%rip), %r15      # 0x9fd0
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x268(%rbp), %rdi
callq 0x30b0
testb %al, %al
je 0x4b26
movq 0x54e6(%rip), %r15      # 0x9fd0
leaq 0x27e5(%rip), %rsi      # 0x72d6
movl $0x7, %edx
movq %r15, %rdi
callq 0x3300
testq %rbx, %rbx
je 0x4b94
movq %rbx, %rdi
callq 0x3130
movq 0x54ba(%rip), %rdi      # 0x9fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3300
jmp 0x4bac
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq 0x548c(%rip), %rdi      # 0x9fd0
callq 0x3030
movq %rax, %rdi
callq 0x31a0
movq %rax, %rbx
leaq 0x279e(%rip), %rsi      # 0x72f9
movl $0x18, %edx
movq %rax, %rdi
callq 0x3300
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
jmp 0x4dc2
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x3440
movq 0x541d(%rip), %rdi      # 0x9fd0
leaq 0x2724(%rip), %rsi      # 0x72de
movl $0x9, %edx
callq 0x3300
xorl %r12d, %r12d
leaq -0x58(%rbp), %r13
leaq 0x2459(%rip), %rbx      # 0x702b
movq -0x2e0(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x34c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4d5e
movq %r13, %rdi
movq %rbx, %rsi
callq 0x30e0
testl %eax, %eax
je 0x4bd2
cmpq $0x7, -0x50(%rbp)
jb 0x4bd2
movl $0x6, %edx
movl $0x1, %ecx
leaq -0xd8(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x32c0
leaq -0xb8(%rbp), %rdi
movq %r15, %rsi
callq 0x3340
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x4c63
callq 0x3270
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
leaq 0x2674(%rip), %rsi      # 0x72e8
callq 0x30e0
testl %eax, %eax
je 0x4cd7
movq %r15, %rdi
leaq 0x2663(%rip), %rsi      # 0x72ea
callq 0x30e0
testl %eax, %eax
jne 0x4d31
movl $0x48, %edi
callq 0x32b0
movq %rax, -0x30(%rbp)
leaq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %r15
movq %r15, %rdi
callq 0x48e2
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x4462
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
jmp 0x4d27
movl $0x28, %edi
callq 0x32b0
movq %rax, -0x30(%rbp)
leaq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %r15
movq %r15, %rdi
callq 0x48e2
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x46e8
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x4d31
callq 0x3270
movq -0x38(%rbp), %rax
movslq 0x320(%rax), %rax
cmpq $0x64, %rax
je 0x4d56
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rdx
movq %rdx, (%rcx,%rax,8)
incl %eax
movl %eax, 0x320(%rcx)
incl %r12d
jmp 0x4bd2
movq 0x526b(%rip), %rdi      # 0x9fd0
leaq 0x2580(%rip), %rsi      # 0x72ec
movl $0xc, %edx
leaq -0xa8(%rbp), %r13
callq 0x3300
movq 0x524c(%rip), %rdi      # 0x9fd0
movl %r12d, %esi
callq 0x3460
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
leaq -0x2e0(%rbp), %rdi
callq 0x30a0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x4dd4
callq 0x3270
movq -0xb8(%rbp), %rdi
cmpq %r13, %rdi
je 0x4de5
callq 0x3270
leaq -0x2e0(%rbp), %rdi
callq 0x30d0
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
jmp 0x4e23
jmp 0x4e2f
movq %rax, %rbx
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x4e32
callq 0x3270
jmp 0x4e32
movq %rax, %rbx
movq -0x30(%rbp), %rdi
callq 0x3270
jmp 0x4e50
jmp 0x4e4d
jmp 0x4e4d
movq %rax, %rbx
jmp 0x4e7a
movq %rax, %rbx
jmp 0x4e62
jmp 0x4e4d
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x4e62
callq 0x3270
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x4e7a
callq 0x3270
leaq -0x2e0(%rbp), %rdi
callq 0x30d0
movq %rbx, %rdi
callq 0x3490