// File: MPSLab-ASU[P]DiRAC/./src/baseAccelSim.cc
// Function: baseAccelSim::read_file_DMAC_prefetch_management(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void baseAccelSim::read_file_DMAC_prefetch_management(string dmacPrefetchManageFileName)
{
	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(dmacPrefetchManageFileName.c_str());
	if(!inFile)
	{
		cout << "Cannot open and read file: " << dmacPrefetchManageFileName.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 >= 0 && SPM_pass_number < SPM_passes) && "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!");

		read_operand_SPM_pass[SPM_pass_number][operand_number] = true;
		read_operand_offset_base_addr_SPM[SPM_pass_number][operand_number].push_back(offset_base_addr_SPM);
		read_operand_burst_width_bytes_SPM_pass[SPM_pass_number][operand_number].push_back(burst_width_bytes);
		read_operand_offset_base_addr_DRAM[SPM_pass_number][operand_number].push_back(offset_base_addr_DRAM);
		it++;
	}

	inFile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x510, %rsp            # imm = 0x510
movq %rsi, -0x498(%rbp)
movq %rdi, %rax
movq -0x498(%rbp), %rdi
movq %rdi, -0x490(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movw $0x0, -0x22(%rbp)
callq 0x4a4170
movq %rax, %rsi
leaq -0x230(%rbp), %rdi
movl $0x8, %edx
callq 0x46e8c0
movq -0x230(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x230(%rbp,%rax), %rdi
callq 0x472d80
movb %al, -0x481(%rbp)
jmp 0x40835a
movb -0x481(%rbp), %al
testb $0x1, %al
jne 0x408366
jmp 0x4083dc
movq $0x61f900, %rdi         # imm = 0x61F900
leaq 0x198c9c(%rip), %rsi    # 0x5a1010
callq 0x492450
movq %rax, -0x4a0(%rbp)
jmp 0x408382
movq -0x490(%rbp), %rdi
callq 0x4a4170
movq -0x4a0(%rbp), %rdi
movq %rax, %rsi
callq 0x492450
movq %rax, -0x4a8(%rbp)
jmp 0x4083a6
movq -0x4a8(%rbp), %rdi
movq $0x491d30, %rsi         # imm = 0x491D30
callq 0x490f40
jmp 0x4083bb
movl $0x1, %edi
callq 0x4ec1e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x40894c
leaq -0x260(%rbp), %rdi
callq 0x4a2620
leaq -0x230(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x4a5170
movq %rax, -0x4b0(%rbp)
jmp 0x408404
movq -0x4b0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x472d70
movb %al, -0x4b1(%rbp)
jmp 0x408422
movb -0x4b1(%rbp), %al
testb $0x1, %al
jne 0x408431
jmp 0x408911
movzwl -0x22(%rbp), %eax
cmpl $0x2, %eax
jge 0x40845f
movw -0x22(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x22(%rbp)
jmp 0x4083e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x408940
leaq -0x3e0(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movl $0x8, %edx
callq 0x49a120
jmp 0x408479
leaq -0x400(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
callq 0x4a2620
leaq -0x420(%rbp), %rdi
callq 0x4a2620
leaq -0x440(%rbp), %rdi
callq 0x4a2620
leaq -0x460(%rbp), %rdi
callq 0x4a2620
leaq -0x480(%rbp), %rdi
callq 0x4a2620
movq -0x4c8(%rbp), %rsi
leaq -0x3e0(%rbp), %rdi
callq 0x4277f0
movq %rax, -0x4c0(%rbp)
jmp 0x4084d8
movq -0x4c0(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x4d0(%rbp)
jmp 0x4084f4
movq -0x4d0(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x4d8(%rbp)
jmp 0x408510
movq -0x4d8(%rbp), %rdi
leaq -0x460(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x4e0(%rbp)
jmp 0x40852c
movq -0x4e0(%rbp), %rdi
leaq -0x480(%rbp), %rsi
callq 0x4277f0
jmp 0x408541
xorl %eax, %eax
movl %eax, %esi
leaq -0x400(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x4e8(%rbp)
jmp 0x40855f
movq -0x4e8(%rbp), %rax
movw %ax, -0x14(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x420(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x4f0(%rbp)
jmp 0x408588
movq -0x4f0(%rbp), %rax
movb %al, -0x11(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x440(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x4f8(%rbp)
jmp 0x4085b0
movq -0x4f8(%rbp), %rax
movl %eax, -0x18(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x460(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x500(%rbp)
jmp 0x4085d8
movq -0x500(%rbp), %rax
movl %eax, -0x1c(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x480(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x508(%rbp)
jmp 0x408600
movq -0x508(%rbp), %rax
movl %eax, -0x20(%rbp)
movzbl -0x11(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x509(%rbp)
jl 0x40863c
movzbl -0x11(%rbp), %ecx
movzbl 0x215f30(%rip), %edx    # 0x61e556
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x509(%rbp)
jge 0x40863c
movb $0x1, %al
movb %al, -0x509(%rbp)
jmp 0x40863c
movb -0x509(%rbp), %al
testb $0x1, %al
jne 0x408648
jmp 0x40864a
jmp 0x4086c8
leaq 0x19999f(%rip), %rdi    # 0x5a1ff0
leaq 0x198a36(%rip), %rsi    # 0x5a108e
movl $0x11e, %edx            # imm = 0x11E
leaq 0x199afb(%rip), %rcx    # 0x5a215f
callq 0x4e53d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x480(%rbp), %rdi
callq 0x4a2730
leaq -0x460(%rbp), %rdi
callq 0x4a2730
leaq -0x440(%rbp), %rdi
callq 0x4a2730
leaq -0x420(%rbp), %rdi
callq 0x4a2730
leaq -0x400(%rbp), %rdi
callq 0x4a2730
leaq -0x3e0(%rbp), %rdi
callq 0x497a10
jmp 0x408940
movzwl -0x14(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x50a(%rbp)
jl 0x4086fa
movzwl -0x14(%rbp), %ecx
movzwl 0x215e70(%rip), %edx    # 0x61e554
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x50a(%rbp)
jge 0x4086fa
movb $0x1, %al
movb %al, -0x50a(%rbp)
jmp 0x4086fa
movb -0x50a(%rbp), %al
testb $0x1, %al
jne 0x408706
jmp 0x408708
jmp 0x408727
leaq 0x199aae(%rip), %rdi    # 0x5a21bd
leaq 0x198978(%rip), %rsi    # 0x5a108e
movl $0x11f, %edx            # imm = 0x11F
leaq 0x199a3d(%rip), %rcx    # 0x5a215f
callq 0x4e53d0
xorl %eax, %eax
cmpl $0x0, -0x18(%rbp)
movb %al, -0x50b(%rbp)
jb 0x408752
movl -0x18(%rbp), %ecx
xorl %eax, %eax
cmpl 0x215e74(%rip), %ecx    # 0x61e5b4
movb %al, -0x50b(%rbp)
jae 0x408752
movb $0x1, %al
movb %al, -0x50b(%rbp)
jmp 0x408752
movb -0x50b(%rbp), %al
testb $0x1, %al
jne 0x40875e
jmp 0x408760
jmp 0x40877f
leaq 0x199b03(%rip), %rdi    # 0x5a226a
leaq 0x198920(%rip), %rsi    # 0x5a108e
movl $0x121, %edx            # imm = 0x121
leaq 0x1999e5(%rip), %rcx    # 0x5a215f
callq 0x4e53d0
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x50c(%rbp)
jbe 0x4087aa
movl -0x1c(%rbp), %ecx
xorl %eax, %eax
cmpl 0x215e1c(%rip), %ecx    # 0x61e5b4
movb %al, -0x50c(%rbp)
jae 0x4087aa
movb $0x1, %al
movb %al, -0x50c(%rbp)
jmp 0x4087aa
movb -0x50c(%rbp), %al
testb $0x1, %al
jne 0x4087b6
jmp 0x4087b8
jmp 0x4087d7
leaq 0x199b76(%rip), %rdi    # 0x5a2335
leaq 0x1988c8(%rip), %rsi    # 0x5a108e
movl $0x123, %edx            # imm = 0x123
leaq 0x19998d(%rip), %rcx    # 0x5a215f
callq 0x4e53d0
xorl %eax, %eax
cmpl $0x0, -0x20(%rbp)
movb %al, -0x50d(%rbp)
jb 0x408802
movl -0x20(%rbp), %ecx
xorl %eax, %eax
cmpl 0x215dc4(%rip), %ecx    # 0x61e5b4
movb %al, -0x50d(%rbp)
jae 0x408802
movb $0x1, %al
movb %al, -0x50d(%rbp)
jmp 0x408802
movb -0x50d(%rbp), %al
testb $0x1, %al
jne 0x40880e
jmp 0x408810
jmp 0x40882f
leaq 0x199bd7(%rip), %rdi    # 0x5a23ee
leaq 0x198870(%rip), %rsi    # 0x5a108e
movl $0x125, %edx            # imm = 0x125
leaq 0x199935(%rip), %rcx    # 0x5a215f
callq 0x4e53d0
movq 0x215e12(%rip), %rax    # 0x61e648
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x11(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq 0x215e03(%rip), %rax    # 0x61e650
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x11(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
leaq -0x18(%rbp), %rsi
callq 0x40f240
jmp 0x40886c
movq 0x215de5(%rip), %rax    # 0x61e658
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x11(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x40f240
jmp 0x408892
movq 0x215dc7(%rip), %rax    # 0x61e660
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x11(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
leaq -0x20(%rbp), %rsi
callq 0x40f240
jmp 0x4088b8
movw -0x22(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x22(%rbp)
leaq -0x480(%rbp), %rdi
callq 0x4a2730
leaq -0x460(%rbp), %rdi
callq 0x4a2730
leaq -0x440(%rbp), %rdi
callq 0x4a2730
leaq -0x420(%rbp), %rdi
callq 0x4a2730
leaq -0x400(%rbp), %rdi
callq 0x4a2730
leaq -0x3e0(%rbp), %rdi
callq 0x497a10
jmp 0x4083e8
leaq -0x230(%rbp), %rdi
callq 0x46ee70
jmp 0x40891f
leaq -0x260(%rbp), %rdi
callq 0x4a2730
leaq -0x230(%rbp), %rdi
callq 0x46f220
addq $0x510, %rsp            # imm = 0x510
popq %rbp
retq
leaq -0x260(%rbp), %rdi
callq 0x4a2730
leaq -0x230(%rbp), %rdi
callq 0x46f220
movq -0x238(%rbp), %rdi
callq 0x4d0770
nopw %cs:(%rax,%rax)