// File: 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
subq $0x380, %rsp            # imm = 0x380
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2f8(%rbp)
leaq -0x218(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x32d0
movq -0x2f0(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x8, %edx
callq 0x3190
jmp 0x4c48
leaq -0x248(%rbp), %rdi
callq 0x3380
movq 0x6375(%rip), %rdi      # 0xafd0
leaq 0x362b(%rip), %rsi      # 0x828d
callq 0x3280
movq %rax, -0x300(%rbp)
jmp 0x4c70
movq -0x300(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3280
movq %rax, -0x308(%rbp)
jmp 0x4c89
movq -0x308(%rbp), %rdi
movq 0x6329(%rip), %rsi      # 0xafc0
callq 0x32b0
jmp 0x4c9e
leaq -0x270(%rbp), %rdi
callq 0x3380
movl $0x0, -0x274(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x3450
movb %al, -0x309(%rbp)
jmp 0x4cc8
movb -0x309(%rbp), %al
testb $0x1, %al
jne 0x4cd7
jmp 0x5085
movq 0x62f2(%rip), %rdi      # 0xafd0
leaq 0x35cc(%rip), %rsi      # 0x82b1
callq 0x3280
movq %rax, -0x318(%rbp)
jmp 0x4cf3
movq -0x318(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3280
movq %rax, -0x320(%rbp)
jmp 0x4d0c
movq -0x320(%rbp), %rdi
leaq 0x359f(%rip), %rsi      # 0x82b9
callq 0x3280
jmp 0x4d21
jmp 0x4d23
leaq -0x218(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x30a0
movq %rax, -0x328(%rbp)
jmp 0x4d3f
movq -0x328(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3340
movb %al, -0x329(%rbp)
jmp 0x4d5d
movb -0x329(%rbp), %al
testb $0x1, %al
jne 0x4d6c
jmp 0x5029
leaq 0x32bc(%rip), %rsi      # 0x802f
leaq -0x270(%rbp), %rdi
callq 0x51a0
movb %al, -0x32a(%rbp)
jmp 0x4d87
movb -0x32a(%rbp), %al
testb $0x1, %al
jne 0x4d96
jmp 0x5024
leaq -0x270(%rbp), %rdi
callq 0x3400
cmpq $0x6, %rax
jbe 0x5024
leaq -0x298(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movl $0x6, %edx
movl $0x1, %ecx
callq 0x32a0
jmp 0x4dcb
leaq -0x248(%rbp), %rdi
movq %rdi, -0x338(%rbp)
leaq -0x298(%rbp), %rsi
movq %rsi, -0x340(%rbp)
callq 0x3330
movq -0x340(%rbp), %rdi
callq 0x3180
movq -0x338(%rbp), %rdi
leaq 0x34bd(%rip), %rsi      # 0x82c3
callq 0x51d0
movb %al, -0x32b(%rbp)
jmp 0x4e13
movb -0x32b(%rbp), %al
testb $0x1, %al
jne 0x4e22
jmp 0x4f1f
movl $0x28, %edi
callq 0x3290
movq %rax, -0x348(%rbp)
jmp 0x4e35
movb $0x1, -0x2b9(%rbp)
leaq -0x2b8(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x3130
jmp 0x4e51
movq -0x348(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x4870
jmp 0x4e66
movq -0x348(%rbp), %rax
movb $0x0, -0x2b9(%rbp)
movq %rax, -0x250(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x3180
jmp 0x5002
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x5119
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x510d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x5101
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x4f03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x3180
testb $0x1, -0x2b9(%rbp)
jne 0x4f0e
jmp 0x4f1a
movq -0x348(%rbp), %rdi
callq 0x3260
jmp 0x5101
leaq 0x339f(%rip), %rsi      # 0x82c5
leaq -0x248(%rbp), %rdi
callq 0x51d0
movb %al, -0x349(%rbp)
jmp 0x4f3a
movb -0x349(%rbp), %al
testb $0x1, %al
jne 0x4f49
jmp 0x4ffe
movl $0x48, %edi
callq 0x3290
movq %rax, -0x358(%rbp)
jmp 0x4f5c
movb $0x1, -0x2e1(%rbp)
leaq -0x2e0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x3130
jmp 0x4f78
movq -0x358(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x4520
jmp 0x4f8d
movq -0x358(%rbp), %rax
movb $0x0, -0x2e1(%rbp)
movq %rax, -0x250(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x3180
jmp 0x5000
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x4fe2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x3180
testb $0x1, -0x2e1(%rbp)
jne 0x4fed
jmp 0x4ff9
movq -0x358(%rbp), %rdi
callq 0x3260
jmp 0x5101
jmp 0x5000
jmp 0x5002
movq -0x2f8(%rbp), %rdi
movq -0x250(%rbp), %rsi
callq 0x4bb0
movl -0x274(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x274(%rbp)
jmp 0x4d23
movq 0x5fa0(%rip), %rdi      # 0xafd0
leaq 0x3290(%rip), %rsi      # 0x82c7
callq 0x3280
movq %rax, -0x360(%rbp)
jmp 0x5045
movq -0x360(%rbp), %rdi
movl -0x274(%rbp), %esi
callq 0x3490
movq %rax, -0x368(%rbp)
jmp 0x5060
movq -0x368(%rbp), %rdi
movq 0x5f52(%rip), %rsi      # 0xafc0
callq 0x32b0
jmp 0x5075
leaq -0x218(%rbp), %rdi
callq 0x30b0
jmp 0x5083
jmp 0x50d4
movq 0x5f44(%rip), %rdi      # 0xafd0
movq 0x5f2d(%rip), %rsi      # 0xafc0
callq 0x32b0
movq %rax, -0x370(%rbp)
jmp 0x50a1
movq -0x370(%rbp), %rdi
leaq 0x3225(%rip), %rsi      # 0x82d4
callq 0x3280
movq %rax, -0x378(%rbp)
jmp 0x50bd
movq -0x378(%rbp), %rdi
movq 0x5ef5(%rip), %rsi      # 0xafc0
callq 0x32b0
jmp 0x50d2
jmp 0x50d4
leaq -0x270(%rbp), %rdi
callq 0x3180
leaq -0x248(%rbp), %rdi
callq 0x3180
leaq -0x218(%rbp), %rdi
callq 0x30e0
addq $0x380, %rsp            # imm = 0x380
popq %rbp
retq
leaq -0x270(%rbp), %rdi
callq 0x3180
leaq -0x248(%rbp), %rdi
callq 0x3180
leaq -0x218(%rbp), %rdi
callq 0x30e0
movq -0x220(%rbp), %rdi
callq 0x34b0
nopw %cs:(%rax,%rax)