// File: MPSLab-ASU[P]DiRAC/./src/baseAccelSim.cc
// Function: baseAccelSim::read_file_SPM_read_management(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void baseAccelSim::read_file_SPM_read_management(string spmReadManageFileName)
{
	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(spmReadManageFileName.c_str());
	if(!inFile)
	{
		cout << "Cannot open and read file: " << spmReadManageFileName.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);
		operand_number 					= stoul(token3);
		offset_network_packets	= stoul(token4);
		burst_width_elements		= stoul(token5);
		offset_base_addr_SPM 		= stoul(token6);

		assert((RF_pass_number >= 0 && RF_pass_number < RF_passes) && "invalid number for an RF pass!");
		assert((network_number >= 0 && network_number < inNetworks) && "invalid number of a network for read-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 read-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 read-operand via network!");
			assert(offset_base_addr_SPM >= 0 && offset_base_addr_SPM < SPM_size &&
				"invalid SPM address specified for reading an operand in an RF pass!");

		read_data_RF_pass[RF_pass_number][network_number] = true;
		RF_pass_network_read_operand[RF_pass_number][network_number].push_back(operand_number);
		RF_pass_network_read_operand_offset_network_packet[RF_pass_number][network_number].push_back(offset_network_packets);
		RF_pass_network_read_operand_burst_width_elements[RF_pass_number][network_number].push_back(burst_width_elements);
		RF_pass_network_read_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, -0x4a1(%rbp)
jmp 0x40b80a
movb -0x4a1(%rbp), %al
testb $0x1, %al
jne 0x40b816
jmp 0x40b88c
movq $0x61f900, %rdi         # imm = 0x61F900
leaq 0x1957ec(%rip), %rsi    # 0x5a1010
callq 0x492450
movq %rax, -0x4c0(%rbp)
jmp 0x40b832
movq -0x4b0(%rbp), %rdi
callq 0x4a4170
movq -0x4c0(%rbp), %rdi
movq %rax, %rsi
callq 0x492450
movq %rax, -0x4c8(%rbp)
jmp 0x40b856
movq -0x4c8(%rbp), %rdi
movq $0x491d30, %rsi         # imm = 0x491D30
callq 0x490f40
jmp 0x40b86b
movl $0x1, %edi
callq 0x4ec1e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x40bf07
leaq -0x260(%rbp), %rdi
callq 0x4a2620
leaq -0x230(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x4a5170
movq %rax, -0x4d0(%rbp)
jmp 0x40b8b4
movq -0x4d0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x472d70
movb %al, -0x4d1(%rbp)
jmp 0x40b8d2
movb -0x4d1(%rbp), %al
testb $0x1, %al
jne 0x40b8e1
jmp 0x40becc
movzwl -0x22(%rbp), %eax
cmpl $0x2, %eax
jge 0x40b90f
movw -0x22(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x22(%rbp)
jmp 0x40b898
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x40befb
leaq -0x3e0(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movl $0x8, %edx
callq 0x49a120
jmp 0x40b929
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 0x40b994
movq -0x4e0(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x4f0(%rbp)
jmp 0x40b9b0
movq -0x4f0(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x4f8(%rbp)
jmp 0x40b9cc
movq -0x4f8(%rbp), %rdi
leaq -0x460(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x500(%rbp)
jmp 0x40b9e8
movq -0x500(%rbp), %rdi
leaq -0x480(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x508(%rbp)
jmp 0x40ba04
movq -0x508(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x4277f0
jmp 0x40ba19
xorl %eax, %eax
movl %eax, %esi
leaq -0x400(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x510(%rbp)
jmp 0x40ba37
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 0x40ba60
movq -0x518(%rbp), %rax
movb %al, -0x12(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x440(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x520(%rbp)
jmp 0x40ba88
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 0x40bab0
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 0x40bad9
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 0x40bb01
movq -0x538(%rbp), %rax
movl %eax, -0x1c(%rbp)
movzwl -0x14(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x539(%rbp)
jl 0x40bb3d
movzwl -0x14(%rbp), %ecx
movzwl 0x212a2b(%rip), %edx    # 0x61e552
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x539(%rbp)
jge 0x40bb3d
movb $0x1, %al
movb %al, -0x539(%rbp)
jmp 0x40bb3d
movb -0x539(%rbp), %al
testb $0x1, %al
jne 0x40bb49
jmp 0x40bb4e
jmp 0x40bbd8
leaq 0x197097(%rip), %rdi    # 0x5a2bec
leaq 0x195532(%rip), %rsi    # 0x5a108e
movl $0x2ae, %edx            # imm = 0x2AE
leaq 0x1970dc(%rip), %rcx    # 0x5a2c44
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 0x40befb
movzbl -0x12(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x53a(%rbp)
jl 0x40bc0a
movzbl -0x12(%rbp), %ecx
movzbl 0x21055d(%rip), %edx    # 0x61c151
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x53a(%rbp)
jge 0x40bc0a
movb $0x1, %al
movb %al, -0x53a(%rbp)
jmp 0x40bc0a
movb -0x53a(%rbp), %al
testb $0x1, %al
jne 0x40bc16
jmp 0x40bc18
jmp 0x40bc37
leaq 0x19708d(%rip), %rdi    # 0x5a2cac
leaq 0x195468(%rip), %rsi    # 0x5a108e
movl $0x2af, %edx            # imm = 0x2AF
leaq 0x197012(%rip), %rcx    # 0x5a2c44
callq 0x4e53d0
movzbl -0x11(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x53b(%rbp)
jl 0x40bc69
movzbl -0x11(%rbp), %ecx
movzbl 0x212903(%rip), %edx    # 0x61e556
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x53b(%rbp)
jge 0x40bc69
movb $0x1, %al
movb %al, -0x53b(%rbp)
jmp 0x40bc69
movb -0x53b(%rbp), %al
testb $0x1, %al
jne 0x40bc75
jmp 0x40bc77
jmp 0x40bc96
leaq 0x196372(%rip), %rdi    # 0x5a1ff0
leaq 0x195409(%rip), %rsi    # 0x5a108e
movl $0x2b0, %edx            # imm = 0x2B0
leaq 0x196fb3(%rip), %rcx    # 0x5a2c44
callq 0x4e53d0
movzwl -0x16(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x53c(%rbp)
jl 0x40bcd0
movzwl -0x16(%rbp), %ecx
movq 0x212936(%rip), %rax    # 0x61e5e8
movzbl -0x11(%rbp), %edx
movzwl (%rax,%rdx,2), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x53c(%rbp)
jge 0x40bcd0
movb $0x1, %al
movb %al, -0x53c(%rbp)
jmp 0x40bcd0
movb -0x53c(%rbp), %al
testb $0x1, %al
jne 0x40bcdc
jmp 0x40bcde
jmp 0x40bcfd
leaq 0x197091(%rip), %rdi    # 0x5a2d76
leaq 0x1953a2(%rip), %rsi    # 0x5a108e
movl $0x2b2, %edx            # imm = 0x2B2
leaq 0x196f4c(%rip), %rcx    # 0x5a2c44
callq 0x4e53d0
xorl %eax, %eax
cmpl $0x0, -0x20(%rbp)
movb %al, -0x53d(%rbp)
jbe 0x40bd33
movl -0x20(%rbp), %ecx
movq 0x2128d3(%rip), %rax    # 0x61e5e8
movzbl -0x11(%rbp), %edx
movzwl (%rax,%rdx,2), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x53d(%rbp)
ja 0x40bd33
movb $0x1, %al
movb %al, -0x53d(%rbp)
jmp 0x40bd33
movb -0x53d(%rbp), %al
testb $0x1, %al
jne 0x40bd3f
jmp 0x40bd41
jmp 0x40bd60
leaq 0x197146(%rip), %rdi    # 0x5a2e8e
leaq 0x19533f(%rip), %rsi    # 0x5a108e
movl $0x2b4, %edx            # imm = 0x2B4
leaq 0x196ee9(%rip), %rcx    # 0x5a2c44
callq 0x4e53d0
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x53e(%rbp)
jb 0x40bd8b
movl -0x1c(%rbp), %ecx
xorl %eax, %eax
cmpl 0x21283b(%rip), %ecx    # 0x61e5b4
movb %al, -0x53e(%rbp)
jae 0x40bd8b
movb $0x1, %al
movb %al, -0x53e(%rbp)
jmp 0x40bd8b
movb -0x53e(%rbp), %al
testb $0x1, %al
jne 0x40bd97
jmp 0x40bd99
jmp 0x40bdb8
leaq 0x1971e5(%rip), %rdi    # 0x5a2f85
leaq 0x1952e7(%rip), %rsi    # 0x5a108e
movl $0x2b6, %edx            # imm = 0x2B6
leaq 0x196e91(%rip), %rcx    # 0x5a2c44
callq 0x4e53d0
movq 0x2128c9(%rip), %rax    # 0x61e688
movzwl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzbl -0x12(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq 0x2128ba(%rip), %rax    # 0x61e690
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 0x40bdf5
movq 0x21289c(%rip), %rax    # 0x61e698
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 0x40be1b
movq 0x21287e(%rip), %rax    # 0x61e6a0
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 0x40be41
movq 0x212860(%rip), %rax    # 0x61e6a8
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 0x40be67
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 0x40b898
leaq -0x230(%rbp), %rdi
callq 0x46ee70
jmp 0x40beda
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
nop