// File: /workspace/github_cpp_makefile_star2_O1/skyetheguy[P]gait_cycle_phase_detection/main.cpp
// Function: main
int main( )
{

	gaitCycle *mainCycle = new gaitCycle;

	int state; // Current state or phase of the gait cycle

	sensorData currentData;


	// OPEN FILE FOR READING
	ifstream infile;
	infile.open("./Data_files/walkData1.csv");

	// USED FOR READING FROM FILE
	string value; 
	vector<string> lineData;


	// WHILE NOT AT EOF KEEP READING LINES WHILE PROCESSING EACH AS WE READ
	while (infile.good())
	{

		for (int i = 0; i <= (CSV_LINE_LENGTH - 2); i++)
		{
			getline(infile, value, ',');
			lineData.push_back(value);

		}

		currentData.setTime( std::stoi(lineData[1], NULL, 10) );
		//cout << std::stoi(lineData[1], NULL, 10) << " ";
		currentData.setXAccel( std::stoi(lineData[2], NULL, 10) );
		//cout << std::stoi(lineData[2], NULL, 10) << " " ;
		currentData.setYAccel( std::stoi(lineData[3], NULL, 10) );
		//cout << std::stoi(lineData[3], NULL, 10) << " " ;
		currentData.setZAccel( std::stoi(lineData[4], NULL, 10) );
		//cout << std::stoi(lineData[4], NULL, 10) << " ";
		currentData.setXGyro( std::stoi(lineData[5], NULL, 10) );
		//cout << std::stoi(lineData[5], NULL, 10) << " " ;
		currentData.setYGyro( std::stoi(lineData[6], NULL, 10) );
		//cout << std::stoi(lineData[6], NULL, 10) << " ";
		currentData.setZGyro( std::stoi(lineData[7], NULL, 10) );
		//cout << std::stoi(lineData[7], NULL, 10) << endl;



		// PROCESS THE DATA JUST TAKEN IN
		state = mainCycle->processReadings(currentData);

		lineData.clear();
		sleep_for(nanoseconds(10000000));
	}


	infile.close(); // CLOSE FILE

   


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movl $0x278, %edi            # imm = 0x278
callq 0x2150
movq %rax, -0x58(%rbp)
movq %rax, %rdi
callq 0x2ce0
leaq -0x2a0(%rbp), %rbx
movq %rbx, %rdi
callq 0x2160
leaq 0x1ba8(%rip), %rsi      # 0x4004
movq %rbx, %rdi
movl $0x8, %edx
callq 0x20d0
leaq -0x88(%rbp), %rax
movq %rax, -0x10(%rax)
xorl %ebx, %ebx
movq %rbx, -0x8(%rax)
movb $0x0, (%rax)
movq %rbx, -0x30(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq -0x2a0(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x280(%rbp,%rax)
jne 0x27ff
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
leaq -0x2a0(%rbp), %r14
leaq -0x98(%rbp), %r12
leaq -0x50(%rbp), %r15
movq %r14, %rdi
movq %r12, %rsi
movl $0x2c, %edx
callq 0x2220
leaq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x295e
incl %ebx
cmpl $0x13, %ebx
jne 0x24bd
movq -0x40(%rbp), %rax
movq 0x20(%rax), %r14
callq 0x2040
movq %rax, %rbx
movl (%rax), %r12d
movl $0x0, (%rax)
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2180
cmpq %r14, -0x50(%rbp)
je 0x2888
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x2894
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x2894
testl %ecx, %ecx
jne 0x2535
movl %r12d, (%rbx)
leaq -0x78(%rbp), %rdi
movl %eax, %esi
callq 0x3c24
movq -0x40(%rbp), %rax
movq 0x40(%rax), %r14
movl (%rbx), %r12d
movl $0x0, (%rbx)
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2180
cmpq %r14, -0x50(%rbp)
je 0x2858
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x2864
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x2864
testl %ecx, %ecx
jne 0x258d
movl %r12d, (%rbx)
leaq -0x78(%rbp), %rdi
movl %eax, %esi
callq 0x3c2c
movq -0x40(%rbp), %rax
movq 0x60(%rax), %r14
movl (%rbx), %r12d
movl $0x0, (%rbx)
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2180
cmpq %r14, -0x50(%rbp)
je 0x284c
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x28a0
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x28a0
testl %ecx, %ecx
jne 0x25e5
movl %r12d, (%rbx)
leaq -0x78(%rbp), %rdi
movl %eax, %esi
callq 0x3c36
movq -0x40(%rbp), %rax
movq 0x80(%rax), %r14
movl (%rbx), %r12d
movl $0x0, (%rbx)
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2180
cmpq %r14, -0x50(%rbp)
je 0x28ac
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x2870
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x2870
testl %ecx, %ecx
jne 0x2640
movl %r12d, (%rbx)
leaq -0x78(%rbp), %rdi
movl %eax, %esi
callq 0x3c40
movq -0x40(%rbp), %rax
movq 0xa0(%rax), %r14
movl (%rbx), %r12d
movl $0x0, (%rbx)
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2180
cmpq %r14, -0x50(%rbp)
je 0x28b8
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x287c
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x287c
testl %ecx, %ecx
jne 0x269b
movl %r12d, (%rbx)
leaq -0x78(%rbp), %rdi
movl %eax, %esi
callq 0x3c4a
movq -0x40(%rbp), %rax
movq 0xc0(%rax), %r14
movl (%rbx), %r12d
movl $0x0, (%rbx)
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2180
cmpq %r14, -0x50(%rbp)
je 0x28d0
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x28c4
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x28c4
testl %ecx, %ecx
jne 0x26f6
movl %r12d, (%rbx)
leaq -0x78(%rbp), %rdi
movl %eax, %esi
callq 0x3c54
movq -0x40(%rbp), %rax
movq 0xe0(%rax), %r14
movl (%rbx), %r12d
movl $0x0, (%rbx)
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x2180
cmpq %r14, -0x50(%rbp)
je 0x28dc
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x28e8
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x28e8
testl %ecx, %ecx
jne 0x2751
movl %r12d, (%rbx)
leaq -0x78(%rbp), %rdi
movl %eax, %esi
callq 0x3c5e
movups -0x78(%rbp), %xmm0
movups -0x6c(%rbp), %xmm1
movups %xmm1, 0xc(%rsp)
movups %xmm0, (%rsp)
movq -0x58(%rbp), %rdi
callq 0x2d94
movq -0x40(%rbp), %r13
movq -0x38(%rbp), %r12
cmpq %r13, %r12
je 0x27a4
movq %r13, %r14
movq (%r14), %rdi
addq $0x10, %r14
cmpq %r14, %rdi
je 0x2797
callq 0x2130
addq $0x10, %r14
cmpq %r12, %r14
jne 0x2786
movq %r13, -0x38(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x989680, -0x48(%rbp)  # imm = 0x989680
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
leaq -0x2a0(%rbp), %r14
leaq -0x98(%rbp), %r12
movq %r15, %rdi
movq %r15, %rsi
callq 0x2080
cmpl $-0x1, %eax
jne 0x27e1
cmpl $0x4, (%rbx)
je 0x27cc
movq -0x2a0(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x280(%rbp,%rax)
movl $0x0, %ebx
je 0x24bd
leaq -0x2a0(%rbp), %rdi
callq 0x2050
leaq -0x40(%rbp), %rdi
callq 0x29aa
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x282c
callq 0x2130
leaq -0x2a0(%rbp), %rdi
callq 0x2060
xorl %eax, %eax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17cc(%rip), %rdi      # 0x401f
callq 0x20c0
leaq 0x17c0(%rip), %rdi      # 0x401f
callq 0x20c0
leaq 0x17b4(%rip), %rdi      # 0x401f
callq 0x2190
leaq 0x17a8(%rip), %rdi      # 0x401f
callq 0x2190
leaq 0x179c(%rip), %rdi      # 0x401f
callq 0x2190
leaq 0x1790(%rip), %rdi      # 0x401f
callq 0x20c0
leaq 0x1784(%rip), %rdi      # 0x401f
callq 0x2190
leaq 0x1778(%rip), %rdi      # 0x401f
callq 0x2190
leaq 0x176c(%rip), %rdi      # 0x401f
callq 0x20c0
leaq 0x1760(%rip), %rdi      # 0x401f
callq 0x20c0
leaq 0x1754(%rip), %rdi      # 0x401f
callq 0x2190
leaq 0x1748(%rip), %rdi      # 0x401f
callq 0x20c0
leaq 0x173c(%rip), %rdi      # 0x401f
callq 0x20c0
leaq 0x1730(%rip), %rdi      # 0x401f
callq 0x2190
jmp 0x2926
movq %rax, %r15
jmp 0x294a
movq %rax, %r15
movq -0x58(%rbp), %rdi
callq 0x2130
jmp 0x2956
jmp 0x2915
jmp 0x2915
jmp 0x2915
jmp 0x2915
jmp 0x2915
jmp 0x2915
movq %rax, %r15
cmpl $0x0, (%rbx)
jne 0x2929
movl %r12d, (%rbx)
jmp 0x2929
jmp 0x2926
jmp 0x2926
movq %rax, %r15
leaq -0x40(%rbp), %rdi
callq 0x29aa
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x294a
callq 0x2130
leaq -0x2a0(%rbp), %rdi
callq 0x2060
movq %r15, %rdi
callq 0x2200