// File: jmfenner92[P]Log-Parser/src/log_parser.cpp
// Function: dataCollection(CmdRecord*, std::basic_ifstream<char, std::char_traits<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void dataCollection(CmdRecord* curr_record, ifstream& log_file, std::string temp_data) {
	// find the length in words of the command data
	int length = (curr_record->HexToDec(temp_data) / 4);
	int field_counter = 0;
	int indexer = 0;
	std::string curr_field;

	for (int i = 0; i < (length*NUM_FIELDS); i++)  {
		log_file >> curr_field;
		field_counter++;

		if (field_counter == DATA) {
			// we have the Data field value (this is special if it's in the address of
			// a command we want, so set it aside for later)
			//curr_node->curr_record.Set_Data(i, curr_field.substr(0,4);
			//curr_node->curr_record.Set_Data(i+1, curr_field.substr(4,4));
			curr_record->Set_Data(indexer, curr_field.substr(0,4));
			curr_record->Set_Data(indexer+1, curr_field.substr(4,4));
			indexer += 2;

		} else if (field_counter == ENDLINE) {
			field_counter = 0;
			line_count++;
		}
	}

	curr_record->Set_Total_Words(length);
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdx, -0xe0(%rbp)
movq %rsi, %rax
movq -0xe0(%rbp), %rsi
movq %rdi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x30f0
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x5850
movl %eax, -0xc4(%rbp)
jmp 0x3f5e
movl -0xc4(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, -0xe4(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3150
movl -0xe4(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3360
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
imull $0xe, -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x4118
movq -0x10(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3310
jmp 0x3fc0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
cmpl $0x8, -0x50(%rbp)
jne 0x40ea
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0xe8(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0xa0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0x4, %ecx
callq 0x3250
jmp 0x4002
movl -0xe8(%rbp), %esi
movq -0xf0(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x5400
jmp 0x401d
leaq -0xa0(%rbp), %rdi
callq 0x3150
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movl -0x54(%rbp), %eax
incl %eax
movl %eax, -0xf4(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0x4, %ecx
movq %rcx, %rdx
callq 0x3250
jmp 0x4059
movl -0xf4(%rbp), %esi
movq -0x100(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0x5400
jmp 0x4074
leaq -0xc0(%rbp), %rdi
callq 0x3150
movl -0x54(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x54(%rbp)
jmp 0x4108
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3150
jmp 0x4141
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x4138
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3150
jmp 0x4138
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x3150
jmp 0x4138
cmpl $0xe, -0x50(%rbp)
jne 0x4106
movl $0x0, -0x50(%rbp)
movl 0x9133(%rip), %eax      # 0xd230
addl $0x1, %eax
movl %eax, 0x912a(%rip)      # 0xd230
jmp 0x4108
jmp 0x410a
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x3fa2
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x5590
jmp 0x4126
leaq -0x78(%rbp), %rdi
callq 0x3150
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x78(%rbp), %rdi
callq 0x3150
movq -0x48(%rbp), %rdi
callq 0x33e0
nopw (%rax,%rax)