// File: MPSLab-ASU[P]DiRAC/./src/baseAccelSim.cc
// Function: baseAccelSim::read_file_SPM_write_management(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void baseAccelSim::read_file_SPM_write_management(string spmWriteManageFileName)
{
	uint8_t operand_number, network_number;	uint16_t RF_pass_number, offset_network_packets;
	uint32_t offset_base_addr_SPM,	burst_width_elements;
	uint16_t it=0;

	ifstream inFile(spmWriteManageFileName.c_str());
	if(!inFile)
	{
		cout << "Cannot open and read file: " << spmWriteManageFileName.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, token6;
		tokenStream >> token1 >> token2 >> token3 >> token4 >> token5 >> token6;
		RF_pass_number 					= stoul(token1);
		network_number					= stoul(token2);
		uint8_t	write_network		= inNetworks + network_number;
		operand_number 					= stoul(token3);
		offset_network_packets	= stoul(token4);
		burst_width_elements		= stoul(token5);
		offset_base_addr_SPM 		= stoul(token6);

		assert((RF_pass_number >= WB_delay_RF_pass && RF_pass_number < RF_passes + WB_delay_RF_pass) && "invalid number for an RF pass!");
		assert((network_number >= 0 && network_number < outNetworks) && "invalid number of a network for write-operands!");
		assert((operand_number >= 0 && operand_number < total_operands) && "invalid operand number!");
		assert(offset_network_packets >= 0 && offset_network_packets < size_packetArr[operand_number] &&
			"invalid start address specified for communicating data packets for a write-operand in an RF pass!");
		assert(burst_width_elements > 0 && burst_width_elements <= size_packetArr[operand_number] &&
			"invalid burst width specified for communicating data packets for write-operand via network!");
			assert(offset_base_addr_SPM >= 0 && offset_base_addr_SPM < SPM_size &&
				"invalid SPM address specified for writing an operand in an RF pass!");

		write_data_RF_pass[RF_pass_number][network_number] = true;
		RF_pass_network_write_operand[RF_pass_number][network_number].push_back(operand_number);
		RF_pass_network_write_operand_offset_network_packet[RF_pass_number][network_number].push_back(offset_network_packets);
		RF_pass_network_write_operand_burst_width_elements[RF_pass_number][network_number].push_back(burst_width_elements);
		RF_pass_network_write_operand_offset_base_addr_SPM[RF_pass_number][network_number].push_back(offset_base_addr_SPM);
		it++;
	}
	inFile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x540, %rsp            # imm = 0x540
movq %rsi, -0x4b8(%rbp)
movq %rdi, %rax
movq -0x4b8(%rbp), %rdi
movq %rdi, -0x4b0(%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, -0x4a2(%rbp)
jmp 0x40bf8a
movb -0x4a2(%rbp), %al
testb $0x1, %al
jne 0x40bf96
jmp 0x40c00c
movq $0x61f900, %rdi         # imm = 0x61F900
leaq 0x19506c(%rip), %rsi    # 0x5a1010
callq 0x492450
movq %rax, -0x4c0(%rbp)
jmp 0x40bfb2
movq -0x4b0(%rbp), %rdi
callq 0x4a4170
movq -0x4c0(%rbp), %rdi
movq %rax, %rsi
callq 0x492450
movq %rax, -0x4c8(%rbp)
jmp 0x40bfd6
movq -0x4c8(%rbp), %rdi
movq $0x491d30, %rsi         # imm = 0x491D30
callq 0x490f40
jmp 0x40bfeb
movl $0x1, %edi
callq 0x4ec1e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x40c69d
leaq -0x260(%rbp), %rdi
callq 0x4a2620
leaq -0x230(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x4a5170
movq %rax, -0x4d0(%rbp)
jmp 0x40c034
movq -0x4d0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x472d70
movb %al, -0x4d1(%rbp)
jmp 0x40c052
movb -0x4d1(%rbp), %al
testb $0x1, %al
jne 0x40c061
jmp 0x40c662
movzwl -0x22(%rbp), %eax
cmpl $0x2, %eax
jge 0x40c08f
movw -0x22(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x22(%rbp)
jmp 0x40c018
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x40c691
leaq -0x3e0(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movl $0x8, %edx
callq 0x49a120
jmp 0x40c0a9
leaq -0x400(%rbp), %rdi
movq %rdi, -0x4e8(%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
leaq -0x4a0(%rbp), %rdi
callq 0x4a2620
movq -0x4e8(%rbp), %rsi
leaq -0x3e0(%rbp), %rdi
callq 0x4277f0
movq %rax, -0x4e0(%rbp)
jmp 0x40c114
movq -0x4e0(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x4f0(%rbp)
jmp 0x40c130
movq -0x4f0(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x4f8(%rbp)
jmp 0x40c14c
movq -0x4f8(%rbp), %rdi
leaq -0x460(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x500(%rbp)
jmp 0x40c168
movq -0x500(%rbp), %rdi
leaq -0x480(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x508(%rbp)
jmp 0x40c184
movq -0x508(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x4277f0
jmp 0x40c199
xorl %eax, %eax
movl %eax, %esi
leaq -0x400(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x510(%rbp)
jmp 0x40c1b7
movq -0x510(%rbp), %rax
movw %ax, -0x14(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x420(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x518(%rbp)
jmp 0x40c1e0
movq -0x518(%rbp), %rax
movb %al, -0x12(%rbp)
movzbl 0x20ff60(%rip), %eax    # 0x61c151
movzbl -0x12(%rbp), %ecx
addl %ecx, %eax
movb %al, -0x4a1(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x440(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x520(%rbp)
jmp 0x40c21b
movq -0x520(%rbp), %rax
movb %al, -0x11(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x460(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x528(%rbp)
jmp 0x40c243
movq -0x528(%rbp), %rax
movw %ax, -0x16(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x480(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x530(%rbp)
jmp 0x40c26c
movq -0x530(%rbp), %rax
movl %eax, -0x20(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x4a0(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x538(%rbp)
jmp 0x40c294
movq -0x538(%rbp), %rax
movl %eax, -0x1c(%rbp)
movzwl -0x14(%rbp), %ecx
xorl %eax, %eax
cmpl $0x2, %ecx
movb %al, -0x539(%rbp)
jl 0x40c2d3
movzwl -0x14(%rbp), %ecx
movzwl 0x212298(%rip), %edx    # 0x61e552
addl $0x2, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x539(%rbp)
jge 0x40c2d3
movb $0x1, %al
movb %al, -0x539(%rbp)
jmp 0x40c2d3
movb -0x539(%rbp), %al
testb $0x1, %al
jne 0x40c2df
jmp 0x40c2e4
jmp 0x40c36e
leaq 0x196d20(%rip), %rdi    # 0x5a300b
leaq 0x194d9c(%rip), %rsi    # 0x5a108e
movl $0x2e1, %edx            # imm = 0x2E1
leaq 0x196d87(%rip), %rcx    # 0x5a3085
callq 0x4e53d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0x4a2730
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 0x40c691
movzbl -0x12(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x53a(%rbp)
jl 0x40c3a0
movzbl -0x12(%rbp), %ecx
movzbl 0x21225a(%rip), %edx    # 0x61e5e4
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x53a(%rbp)
jge 0x40c3a0
movb $0x1, %al
movb %al, -0x53a(%rbp)
jmp 0x40c3a0
movb -0x53a(%rbp), %al
testb $0x1, %al
jne 0x40c3ac
jmp 0x40c3ae
jmp 0x40c3cd
leaq 0x196d3a(%rip), %rdi    # 0x5a30ef
leaq 0x194cd2(%rip), %rsi    # 0x5a108e
movl $0x2e2, %edx            # imm = 0x2E2
leaq 0x196cbd(%rip), %rcx    # 0x5a3085
callq 0x4e53d0
movzbl -0x11(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x53b(%rbp)
jl 0x40c3ff
movzbl -0x11(%rbp), %ecx
movzbl 0x21216d(%rip), %edx    # 0x61e556
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x53b(%rbp)
jge 0x40c3ff
movb $0x1, %al
movb %al, -0x53b(%rbp)
jmp 0x40c3ff
movb -0x53b(%rbp), %al
testb $0x1, %al
jne 0x40c40b
jmp 0x40c40d
jmp 0x40c42c
leaq 0x195bdc(%rip), %rdi    # 0x5a1ff0
leaq 0x194c73(%rip), %rsi    # 0x5a108e
movl $0x2e3, %edx            # imm = 0x2E3
leaq 0x196c5e(%rip), %rcx    # 0x5a3085
callq 0x4e53d0
movzwl -0x16(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x53c(%rbp)
jl 0x40c466
movzwl -0x16(%rbp), %ecx
movq 0x2121a0(%rip), %rax    # 0x61e5e8
movzbl -0x11(%rbp), %edx
movzwl (%rax,%rdx,2), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x53c(%rbp)
jge 0x40c466
movb $0x1, %al
movb %al, -0x53c(%rbp)
jmp 0x40c466
movb -0x53c(%rbp), %al
testb $0x1, %al
jne 0x40c472
jmp 0x40c474
jmp 0x40c493
leaq 0x196d41(%rip), %rdi    # 0x5a31bc
leaq 0x194c0c(%rip), %rsi    # 0x5a108e
movl $0x2e5, %edx            # imm = 0x2E5
leaq 0x196bf7(%rip), %rcx    # 0x5a3085
callq 0x4e53d0
xorl %eax, %eax
cmpl $0x0, -0x20(%rbp)
movb %al, -0x53d(%rbp)
jbe 0x40c4c9
movl -0x20(%rbp), %ecx
movq 0x21213d(%rip), %rax    # 0x61e5e8
movzbl -0x11(%rbp), %edx
movzwl (%rax,%rdx,2), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x53d(%rbp)
ja 0x40c4c9
movb $0x1, %al
movb %al, -0x53d(%rbp)
jmp 0x40c4c9
movb -0x53d(%rbp), %al
testb $0x1, %al
jne 0x40c4d5
jmp 0x40c4d7
jmp 0x40c4f6
leaq 0x196df8(%rip), %rdi    # 0x5a32d6
leaq 0x194ba9(%rip), %rsi    # 0x5a108e
movl $0x2e7, %edx            # imm = 0x2E7
leaq 0x196b94(%rip), %rcx    # 0x5a3085
callq 0x4e53d0
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x53e(%rbp)
jb 0x40c521
movl -0x1c(%rbp), %ecx
xorl %eax, %eax
cmpl 0x2120a5(%rip), %ecx    # 0x61e5b4
movb %al, -0x53e(%rbp)
jae 0x40c521
movb $0x1, %al
movb %al, -0x53e(%rbp)
jmp 0x40c521
movb -0x53e(%rbp), %al
testb $0x1, %al
jne 0x40c52d
jmp 0x40c52f
jmp 0x40c54e
leaq 0x196e98(%rip), %rdi    # 0x5a33ce
leaq 0x194b51(%rip), %rsi    # 0x5a108e
movl $0x2e9, %edx            # imm = 0x2E9
leaq 0x196b3c(%rip), %rcx    # 0x5a3085
callq 0x4e53d0
movq 0x21215b(%rip), %rax    # 0x61e6b0
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x12(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq 0x21214c(%rip), %rax    # 0x61e6b8
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x12(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
leaq -0x11(%rbp), %rsi
callq 0x40f630
jmp 0x40c58b
movq 0x21212e(%rip), %rax    # 0x61e6c0
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x12(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
leaq -0x16(%rbp), %rsi
callq 0x40f6a0
jmp 0x40c5b1
movq 0x212110(%rip), %rax    # 0x61e6c8
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x12(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
leaq -0x20(%rbp), %rsi
callq 0x40f240
jmp 0x40c5d7
movq 0x2120f2(%rip), %rax    # 0x61e6d0
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x12(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x40f240
jmp 0x40c5fd
movw -0x22(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x22(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0x4a2730
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 0x40c018
leaq -0x230(%rbp), %rdi
callq 0x46ee70
jmp 0x40c670
leaq -0x260(%rbp), %rdi
callq 0x4a2730
leaq -0x230(%rbp), %rdi
callq 0x46f220
addq $0x540, %rsp            # imm = 0x540
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)