// File: /workspace/github_cpp_makefile_star2_O1/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 0x32d0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x3170
leaq -0xa8(%rbp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movq 0x5507(%rip), %r15      # 0x9fd0
leaq 0x27e2(%rip), %rsi      # 0x72b2
movl $0x23, %edx
movq %r15, %rdi
callq 0x32f0
testq %rbx, %rbx
je 0x4afe
movq %rbx, %rdi
callq 0x3130
movq 0x54df(%rip), %rdi      # 0x9fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x4b16
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x3430
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq 0x549c(%rip), %r15      # 0x9fd0
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
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 0x4baa
movq 0x5462(%rip), %r15      # 0x9fd0
leaq 0x2761(%rip), %rsi      # 0x72d6
movl $0x7, %edx
movq %r15, %rdi
callq 0x32f0
testq %rbx, %rbx
je 0x4c18
movq %rbx, %rdi
callq 0x3130
movq 0x5436(%rip), %rdi      # 0x9fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x4c30
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq 0x5408(%rip), %rdi      # 0x9fd0
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x271a(%rip), %rsi      # 0x72f9
movl $0x18, %edx
movq %rax, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
jmp 0x4e46
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x3430
movq 0x5399(%rip), %rdi      # 0x9fd0
leaq 0x26a0(%rip), %rsi      # 0x72de
movl $0x9, %edx
callq 0x32f0
xorl %r12d, %r12d
leaq -0x58(%rbp), %r13
leaq 0x23d5(%rip), %rbx      # 0x702b
movq -0x2e0(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x34b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4de2
movq %r13, %rdi
movq %rbx, %rsi
callq 0x30e0
testl %eax, %eax
je 0x4c56
cmpq $0x7, -0x50(%rbp)
jb 0x4c56
movl $0x6, %edx
movl $0x1, %ecx
leaq -0xd8(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x32b0
leaq -0xb8(%rbp), %rdi
movq %r15, %rsi
callq 0x3330
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x4ce7
callq 0x3260
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
leaq 0x25f0(%rip), %rsi      # 0x72e8
callq 0x30e0
testl %eax, %eax
je 0x4d5b
movq %r15, %rdi
leaq 0x25df(%rip), %rsi      # 0x72ea
callq 0x30e0
testl %eax, %eax
jne 0x4db5
movl $0x48, %edi
callq 0x32a0
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 0x496a
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x44ea
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
jmp 0x4dab
movl $0x28, %edi
callq 0x32a0
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 0x496a
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x4770
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x4db5
callq 0x3260
movq -0x38(%rbp), %rax
movslq 0x320(%rax), %rax
cmpq $0x64, %rax
je 0x4dda
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rdx
movq %rdx, (%rcx,%rax,8)
incl %eax
movl %eax, 0x320(%rcx)
incl %r12d
jmp 0x4c56
movq 0x51e7(%rip), %rdi      # 0x9fd0
leaq 0x24fc(%rip), %rsi      # 0x72ec
movl $0xc, %edx
leaq -0xa8(%rbp), %r13
callq 0x32f0
movq 0x51c8(%rip), %rdi      # 0x9fd0
movl %r12d, %esi
callq 0x3450
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
leaq -0x2e0(%rbp), %rdi
callq 0x30a0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x4e58
callq 0x3260
movq -0xb8(%rbp), %rdi
cmpq %r13, %rdi
je 0x4e69
callq 0x3260
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 0x4ea7
jmp 0x4eb3
movq %rax, %rbx
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x4eb6
callq 0x3260
jmp 0x4eb6
movq %rax, %rbx
movq -0x30(%rbp), %rdi
callq 0x3260
jmp 0x4ed4
jmp 0x4ed1
jmp 0x4ed1
movq %rax, %rbx
jmp 0x4efe
movq %rax, %rbx
jmp 0x4ee6
jmp 0x4ed1
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x4ee6
callq 0x3260
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x4efe
callq 0x3260
leaq -0x2e0(%rbp), %rdi
callq 0x30d0
movq %rbx, %rdi
callq 0x3480