// File: /workspace/github_cpp_makefile_star2_O2/MPSLab-ASU[P]DiRAC/./src/baseAccelSim.cc
// Function: baseAccelSim::read_file_DMAC_WB_management(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void baseAccelSim::read_file_DMAC_WB_management(string dmacWBManageFileName)
{
	uint8_t operand_number;	uint16_t SPM_pass_number;
	uint32_t offset_base_addr_SPM,	burst_width_bytes, offset_base_addr_DRAM;
	uint16_t it=0;

	ifstream inFile(dmacWBManageFileName.c_str());
	if(!inFile)
	{
		cout << "Cannot open and read file: " << dmacWBManageFileName.c_str() << endl;
		exit (EXIT_FAILURE);
	}

	string line;
 	while (getline(inFile, line)) {
		// skip reading first two lines of the file
		if(it < 2) {
			it++; continue;
		}
		istringstream tokenStream(line);
		string token1, token2, token3, token4, token5;
		tokenStream >> token1 >> token2 >> token3 >> token4 >> token5;
		SPM_pass_number = stoul(token1);
		operand_number = stoul(token2);
		offset_base_addr_SPM = stoul(token3);
		burst_width_bytes = stoul(token4);
		offset_base_addr_DRAM = stoul(token5);

		assert((operand_number >= 0 && operand_number < total_operands) && "invalid operand number!");
		assert((SPM_pass_number >= WB_delay_SPM_pass && SPM_pass_number < (SPM_passes+WB_delay_SPM_pass)) && "invalid number for an SPM pass!");
		assert(offset_base_addr_SPM >= 0 && offset_base_addr_SPM < SPM_size &&
			"invalid SPM address specified for setting offset for an operand for an SPM pass!");
		assert(burst_width_bytes > 0 && burst_width_bytes < SPM_size &&
			"invalid burst width specified for managing data in SPM!");
		assert(offset_base_addr_DRAM >= 0 && offset_base_addr_DRAM < SPM_size &&
			"invalid offset specified for accessing operand from DRAM in SPM pass!");

		write_operand_SPM_pass[SPM_pass_number][operand_number] = true;
		write_operand_offset_base_addr_SPM[SPM_pass_number][operand_number].push_back(offset_base_addr_SPM);
		write_operand_burst_width_bytes_SPM_pass[SPM_pass_number][operand_number].push_back(burst_width_bytes);
		write_operand_offset_base_addr_DRAM[SPM_pass_number][operand_number].push_back(offset_base_addr_DRAM);
		it++;
	}

	inFile.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x458, %rsp            # imm = 0x458
movq %rsi, %rbx
movq (%rsi), %rsi
leaq 0xd0(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x45cbc0
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xf0(%rsp,%rax)
jne 0x406df5
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xd0(%rsp), %rbx
pushq $0xa
popq %r12
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x493470
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x406d21
cmpw $0x1, %r14w
jbe 0x406d19
leaq 0x2d8(%rsp), %r15
movq %r15, %rdi
leaq 0xb0(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x488420
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
andq $0x0, 0x98(%rsp)
xorl %ecx, %ecx
movb %cl, 0xa0(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movb %cl, 0x80(%rsp)
movb %cl, 0x60(%rsp)
movb %cl, 0x40(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movb %cl, 0x20(%rsp)
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x415af0
movq %rax, %rdi
leaq 0x70(%rsp), %rsi
callq 0x415af0
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x415af0
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x415af0
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x415af0
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x40a485
movq %rax, %r13
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x40a485
movq %rax, %rbp
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x40a485
movl %eax, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x40a485
movl %eax, 0x4(%rsp)
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x40a485
movl %eax, 0xc(%rsp)
movzbl %bpl, %ecx
movzbl 0x20193d(%rip), %edx    # 0x608556
cmpl %edx, %ecx
jae 0x406d79
movzwl %r13w, %ecx
cmpl $0x2, %ecx
jb 0x406d5a
movzwl 0x20191f(%rip), %edx    # 0x608554
addl $0x2, %edx
cmpl %edx, %ecx
jae 0x406d5a
movl 0x20196e(%rip), %ecx    # 0x6085b4
cmpl %ecx, 0x8(%rsp)
jae 0x406db7
movl 0x4(%rsp), %edx
testl %edx, %edx
je 0x406dd6
cmpl %ecx, %edx
jae 0x406dd6
cmpl %eax, %ecx
jbe 0x406d98
movq 0x2019f5(%rip), %rax    # 0x608668
movzwl %r13w, %r15d
leal (,%r15,8), %ecx
movq (%rax,%rcx), %rax
movzbl %bpl, %edx
movb $0x1, (%rax,%rdx)
movq 0x2019de(%rip), %rax    # 0x608670
imulq $0x18, %rdx, %r13
movq (%rax,%rcx), %rdi
addq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x40a4a2
movq 0x2019ca(%rip), %rax    # 0x608678
movq (%rax,%r15,8), %rdi
addq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x40a4a2
movq 0x2019ba(%rip), %rax    # 0x608680
addq (%rax,%r15,8), %r13
movq %r13, %rdi
leaq 0xc(%rsp), %rsi
callq 0x40a4a2
leaq 0x10(%rsp), %rdi
callq 0x490a30
leaq 0x30(%rsp), %rdi
callq 0x490a30
leaq 0x50(%rsp), %rdi
callq 0x490a30
leaq 0x70(%rsp), %rdi
callq 0x490a30
leaq 0x90(%rsp), %rdi
callq 0x490a30
leaq 0x2d8(%rsp), %rdi
callq 0x485d10
incl %r14d
jmp 0x406aaa
leaq 0xd0(%rsp), %rdi
callq 0x45d170
leaq 0xb0(%rsp), %rdi
callq 0x490a30
leaq 0xd0(%rsp), %rdi
callq 0x45d520
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18a0b6(%rip), %rdi    # 0x590e17
leaq 0x189311(%rip), %rsi    # 0x590079
leaq 0x18a070(%rip), %rcx    # 0x590ddf
movl $0x14f, %edx            # imm = 0x14F
callq 0x4d36d0
leaq 0x189ce5(%rip), %rdi    # 0x590a65
leaq 0x1892f2(%rip), %rsi    # 0x590079
leaq 0x18a051(%rip), %rcx    # 0x590ddf
movl $0x14e, %edx            # imm = 0x14E
callq 0x4d36d0
leaq 0x189fb6(%rip), %rdi    # 0x590d55
leaq 0x1892d3(%rip), %rsi    # 0x590079
leaq 0x18a032(%rip), %rcx    # 0x590ddf
movl $0x155, %edx            # imm = 0x155
callq 0x4d36d0
leaq 0x189e91(%rip), %rdi    # 0x590c4f
leaq 0x1892b4(%rip), %rsi    # 0x590079
leaq 0x18a013(%rip), %rcx    # 0x590ddf
movl $0x151, %edx            # imm = 0x151
callq 0x4d36d0
leaq 0x189f05(%rip), %rdi    # 0x590ce2
leaq 0x189295(%rip), %rsi    # 0x590079
leaq 0x189ff4(%rip), %rcx    # 0x590ddf
movl $0x153, %edx            # imm = 0x153
callq 0x4d36d0
movq $0x609900, %rdi         # imm = 0x609900
leaq 0x18921d(%rip), %rsi    # 0x590020
callq 0x480750
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x480750
movq %rax, %rdi
callq 0x480030
pushq $0x1
popq %rdi
callq 0x4da4e0
movq %rax, %rbx
jmp 0x406e83
jmp 0x406e2c
jmp 0x406e2c
movq %rax, %rbx
jmp 0x406e76
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x490a30
leaq 0x30(%rsp), %rdi
callq 0x490a30
leaq 0x50(%rsp), %rdi
callq 0x490a30
leaq 0x70(%rsp), %rdi
callq 0x490a30
leaq 0x90(%rsp), %rdi
callq 0x490a30
leaq 0x2d8(%rsp), %rdi
callq 0x485d10
leaq 0xb0(%rsp), %rdi
callq 0x490a30
leaq 0xd0(%rsp), %rdi
callq 0x45d520
movq %rbx, %rdi
callq 0x4bea70