// File: /workspace/github_cpp_makefile_star2_O2/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 $0x2c8, %rsp            # imm = 0x2C8
movq %rsi, %rbx
movq %rdi, -0x40(%rbp)
leaq -0x2e8(%rbp), %r14
movq %r14, %rdi
callq 0x2270
pushq $0x8
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2170
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x4c8d(%rip), %rdi      # 0x7fd0
leaq 0x1f3e(%rip), %rsi      # 0x5288
callq 0x2240
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2240
movq %rax, %rdi
callq 0x2150
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x270(%rbp), %rdi
callq 0x20b0
testb %al, %al
je 0x34ea
movq 0x4c43(%rip), %rdi      # 0x7fd0
leaq 0x1f18(%rip), %rsi      # 0x52ac
callq 0x2240
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2240
leaq 0x1f09(%rip), %rsi      # 0x52b4
movq %rax, %rdi
callq 0x2240
xorl %r14d, %r14d
leaq -0x2e8(%rbp), %r12
leaq -0x60(%rbp), %r13
leaq 0x1c63(%rip), %rbx      # 0x502b
movq %r12, %rdi
movq %r13, %rsi
callq 0x2090
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x350f
movq %r13, %rdi
movq %rbx, %rsi
callq 0x35fd
cmpq $0x7, -0x58(%rbp)
setae %cl
andb %cl, %al
cmpb $0x1, %al
jne 0x33c8
movl %r14d, -0x34(%rbp)
leaq -0xe0(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
pushq $0x6
popq %rdx
pushq $0x1
popq %rcx
callq 0x2260
leaq -0x80(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x22c0
movq %r15, %rdi
callq 0x2140
movq %r14, %rdi
leaq 0x1e83(%rip), %rsi      # 0x52be
callq 0x360a
testb %al, %al
je 0x3474
pushq $0x28
popq %rdi
callq 0x2250
movq %rax, -0x30(%rbp)
movl -0x34(%rbp), %r14d
leaq -0xc0(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x2300
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x311a
jmp 0x34b5
movq %r14, %rdi
leaq 0x1e42(%rip), %rsi      # 0x52c0
callq 0x360a
testb %al, %al
movl -0x34(%rbp), %r14d
je 0x34bd
pushq $0x48
popq %rdi
callq 0x2250
movq %rax, -0x30(%rbp)
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x2300
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x2f22
movq %r15, %rdi
callq 0x2140
movq -0x40(%rbp), %rax
movslq 0x320(%rax), %rax
cmpq $0x64, %rax
je 0x34e2
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rdx
movq %rdx, (%rcx,%rax,8)
incl %eax
movl %eax, 0x320(%rcx)
incl %r14d
jmp 0x33c8
movq 0x4adf(%rip), %rdi      # 0x7fd0
callq 0x2150
leaq 0x1dd2(%rip), %rsi      # 0x52cf
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x2150
jmp 0x3541
movq 0x4aba(%rip), %rdi      # 0x7fd0
leaq 0x1da5(%rip), %rsi      # 0x52c2
callq 0x2240
movq %rax, %rdi
movl %r14d, %esi
callq 0x2400
movq %rax, %rdi
callq 0x2150
leaq -0x2e8(%rbp), %rdi
callq 0x20a0
leaq -0x60(%rbp), %rdi
callq 0x2140
leaq -0x80(%rbp), %rdi
callq 0x2140
leaq -0x2e8(%rbp), %rdi
callq 0x20e0
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
jmp 0x3589
jmp 0x3590
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x2140
jmp 0x3593
movq %rax, %rbx
movq -0x30(%rbp), %rdi
callq 0x2220
jmp 0x35b1
jmp 0x35ae
jmp 0x35ae
movq %rax, %rbx
jmp 0x35c3
movq %rax, %rbx
jmp 0x35ba
jmp 0x35ae
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2140
leaq -0x80(%rbp), %rdi
callq 0x2140
leaq -0x2e8(%rbp), %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x2420
nop