// File: /workspace/github_cpp_makefile_star2_O3/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 $0x468, %rsp            # imm = 0x468
movq %rsi, %rbx
movq (%rsi), %rsi
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x461750
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x100(%rsp,%rax)
jne 0x4087d1
leaq 0xd0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
leaq 0x50(%rsp), %r15
leaq 0x30(%rsp), %r13
leaq 0xe0(%rsp), %r14
leaq 0xc0(%rsp), %rbp
movl $0x0, 0x10(%rsp)
leaq (%rsp,%rax), %rdi
addq $0xe0, %rdi
movl $0xa, %esi
callq 0x465f00
movsbl %al, %edx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x41aa00
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x40866d
movl 0x10(%rsp), %eax
cmpw $0x1, %ax
jbe 0x408656
leaq 0x2e8(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movl $0x8, %edx
callq 0x48cfb0
movq %r15, 0x40(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x48(%rsp)
movb %cl, 0x50(%rsp)
movq %r13, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
movb %cl, 0x30(%rsp)
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rcx, 0xa8(%rsp)
movb %cl, 0xb0(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %rcx, 0x88(%rsp)
movb %cl, 0x90(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %rcx, 0x68(%rsp)
movb %cl, 0x70(%rsp)
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x41a680
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x41a680
movq %rax, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x41a680
movq %rax, %rdi
leaq 0x80(%rsp), %rsi
callq 0x41a680
movq %rax, %rdi
leaq 0x60(%rsp), %rsi
callq 0x41a680
movq 0x40(%rsp), %r14
callq 0x4c85e0
movq %rax, %rbp
movl (%rax), %ebx
movl $0x0, (%rax)
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x4df260
cmpq %r14, 0x8(%rsp)
je 0x40875e
movq %rax, %r13
movl (%rbp), %r15d
testl %r15d, %r15d
je 0x408340
cmpl $0x22, %r15d
jne 0x408346
jmp 0x4087c5
movl %ebx, (%rbp)
movl %ebx, %r15d
movq 0x20(%rsp), %r12
movl $0x0, (%rbp)
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x4df260
cmpq %r12, 0x8(%rsp)
je 0x40876a
movq %rax, %r14
movl (%rbp), %ebx
testl %ebx, %ebx
je 0x408383
cmpl $0x22, %ebx
jne 0x40838a
jmp 0x4087ad
movl %r15d, (%rbp)
movl %r15d, %ebx
movq 0xa0(%rsp), %r12
movl $0x0, (%rbp)
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x4df260
cmpq %r12, 0x8(%rsp)
je 0x408746
movl (%rbp), %ecx
testl %ecx, %ecx
je 0x4083c7
cmpl $0x22, %ecx
jne 0x4083ca
jmp 0x408795
movl %ebx, (%rbp)
movl %eax, 0x1c(%rsp)
movq 0x80(%rsp), %r12
movl (%rbp), %ebx
movl $0x0, (%rbp)
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x4df260
cmpq %r12, 0x8(%rsp)
je 0x408752
movl (%rbp), %ecx
testl %ecx, %ecx
je 0x40840e
cmpl $0x22, %ecx
jne 0x408411
jmp 0x4087a1
movl %ebx, (%rbp)
movl %eax, 0x14(%rsp)
movq 0x60(%rsp), %r12
movl (%rbp), %ebx
movl $0x0, (%rbp)
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x4df260
cmpq %r12, 0x8(%rsp)
je 0x40873a
movl (%rbp), %ecx
testl %ecx, %ecx
je 0x408452
cmpl $0x22, %ecx
jne 0x408455
jmp 0x4087b9
movl %ebx, (%rbp)
movl %eax, 0x18(%rsp)
movzbl %r14b, %ecx
movzbl 0x2030f2(%rip), %edx    # 0x60b556
cmpl %edx, %ecx
jae 0x4086dd
movzwl %r13w, %ecx
cmpl $0x2, %ecx
leaq 0xc0(%rsp), %rbp
jb 0x4086be
movzwl 0x2030cc(%rip), %edx    # 0x60b554
addl $0x2, %edx
cmpl %edx, %ecx
jae 0x4086be
movl 0x1c(%rsp), %ecx
movl 0x203117(%rip), %edx    # 0x60b5b4
cmpl %edx, %ecx
jae 0x4086fc
movl 0x14(%rsp), %esi
testl %esi, %esi
je 0x408776
cmpl %edx, %esi
jae 0x408776
cmpl %eax, %edx
jbe 0x40871b
movq 0x2031a0(%rip), %rax    # 0x60b668
movzwl %r13w, %r12d
leal (,%r12,8), %edx
movq (%rax,%rdx), %rax
movzbl %r14b, %esi
movb $0x1, (%rax,%rsi)
movq 0x203189(%rip), %rax    # 0x60b670
movq (%rax,%rdx), %rax
leaq (%rsi,%rsi,2), %rbx
leaq (%rax,%rbx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x40851b
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
leaq 0x50(%rsp), %r15
leaq 0x30(%rsp), %r13
leaq 0xe0(%rsp), %r14
jmp 0x408537
leaq 0x1c(%rsp), %rdx
leaq 0x50(%rsp), %r15
leaq 0x30(%rsp), %r13
callq 0x40ea5c
leaq 0xe0(%rsp), %r14
movq 0x20313a(%rip), %rax    # 0x60b678
movq (%rax,%r12,8), %rax
leaq (%rax,%rbx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x408560
movl 0x14(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x40856a
leaq 0x14(%rsp), %rdx
callq 0x40ea5c
movq 0x20310f(%rip), %rax    # 0x60b680
movq (%rax,%r12,8), %rax
leaq (%rax,%rbx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x408593
movl 0x18(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x40859d
leaq 0x18(%rsp), %rdx
callq 0x40ea5c
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x4085b9
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x4085de
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x408603
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x40861a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x408631
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4177e0
leaq 0x2e8(%rsp), %rdi
movq $0x606328, %rsi         # imm = 0x606328
callq 0x48d260
leaq 0x360(%rsp), %rdi
callq 0x467320
movl 0x10(%rsp), %eax
incl %eax
movl %eax, 0x10(%rsp)
movq 0xe0(%rsp), %rax
movq -0x18(%rax), %rax
jmp 0x4081e6
leaq 0xe0(%rsp), %rdi
callq 0x461d00
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x40869f
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4177e0
leaq 0xe0(%rsp), %rdi
callq 0x4620b0
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18c752(%rip), %rdi    # 0x594e17
leaq 0x18b9ad(%rip), %rsi    # 0x594079
leaq 0x18c70c(%rip), %rcx    # 0x594ddf
movl $0x14f, %edx            # imm = 0x14F
callq 0x4d8100
leaq 0x18c381(%rip), %rdi    # 0x594a65
leaq 0x18b98e(%rip), %rsi    # 0x594079
leaq 0x18c6ed(%rip), %rcx    # 0x594ddf
movl $0x14e, %edx            # imm = 0x14E
callq 0x4d8100
leaq 0x18c54c(%rip), %rdi    # 0x594c4f
leaq 0x18b96f(%rip), %rsi    # 0x594079
leaq 0x18c6ce(%rip), %rcx    # 0x594ddf
movl $0x151, %edx            # imm = 0x151
callq 0x4d8100
leaq 0x18c633(%rip), %rdi    # 0x594d55
leaq 0x18b950(%rip), %rsi    # 0x594079
leaq 0x18c6af(%rip), %rcx    # 0x594ddf
movl $0x155, %edx            # imm = 0x155
callq 0x4d8100
leaq 0x18d28a(%rip), %rdi    # 0x5959cb
callq 0x402b51
leaq 0x18d27e(%rip), %rdi    # 0x5959cb
callq 0x402b51
leaq 0x18d272(%rip), %rdi    # 0x5959cb
callq 0x402b51
leaq 0x18d266(%rip), %rdi    # 0x5959cb
callq 0x402b51
leaq 0x18d25a(%rip), %rdi    # 0x5959cb
callq 0x402b51
leaq 0x18c565(%rip), %rdi    # 0x594ce2
leaq 0x18b8f5(%rip), %rsi    # 0x594079
leaq 0x18c654(%rip), %rcx    # 0x594ddf
movl $0x153, %edx            # imm = 0x153
callq 0x4d8100
leaq 0x18d22f(%rip), %rdi    # 0x5959cb
callq 0x402c01
leaq 0x18d223(%rip), %rdi    # 0x5959cb
callq 0x402c01
leaq 0x18d217(%rip), %rdi    # 0x5959cb
callq 0x402c01
leaq 0x18d20b(%rip), %rdi    # 0x5959cb
callq 0x402c01
leaq 0x18d1ff(%rip), %rdi    # 0x5959cb
callq 0x402c01
movq $0x60c900, %rdi         # imm = 0x60C900
leaq 0x18b841(%rip), %rsi    # 0x594020
movl $0x1b, %edx
callq 0x484db0
movq (%rbx), %rsi
movq $0x60c900, %rdi         # imm = 0x60C900
callq 0x4852e0
movq %rax, %rdi
callq 0x484bc0
movl $0x1, %edi
callq 0x4def10
movq %rax, %r14
jmp 0x408928
jmp 0x408843
jmp 0x408843
jmp 0x40882b
jmp 0x40882b
movq %rax, %r14
cmpl $0x0, (%rbp)
jne 0x408837
movl %r15d, (%rbp)
jmp 0x408837
jmp 0x40882b
movq %rax, %r14
cmpl $0x0, (%rbp)
jne 0x408837
movl %ebx, (%rbp)
leaq 0x50(%rsp), %r15
leaq 0x30(%rsp), %r13
jmp 0x40884e
movq %rax, %r14
jmp 0x408903
movq %rax, %r14
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x40886a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x40888f
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x4088b4
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x4088cb
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x4088e2
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4177e0
movq $0x606328, %rsi         # imm = 0x606328
leaq 0x2e8(%rsp), %rdi
callq 0x48d260
leaq 0x360(%rsp), %rdi
callq 0x467320
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x408928
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4177e0
leaq 0xe0(%rsp), %rdi
callq 0x4620b0
movq %r14, %rdi
callq 0x4c34a0
nop