// File: MPSLab-ASU[P]DiRAC/./src/baseAccelSim.cc
// Function: baseAccelSim::read_file_output_network_packets(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void baseAccelSim::read_file_output_network_packets(string outputNetworkPacketsFileName)
{
	config_data_collect_write_back = new uint16_t*[outNetworks];
	for(uint8_t i=0; i < outNetworks; i++)
    config_data_collect_write_back[i] = new uint16_t[size_config_data_collect_write_back[i]];

	uint16_t it=0;
	ifstream inFile(outputNetworkPacketsFileName.c_str());
	if(!inFile)
	{
		cout << "Cannot open and read file: " << outputNetworkPacketsFileName.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;
		tokenStream >> token1 >> token2 >> token3;

		uint8_t		network 	= stoul(token1);
		uint16_t 	idx				= stoul(token2);
		uint16_t 	offset 		= stoul(token3);

		assert(network < outNetworks && "network number should be less than total networks for outputting data.");
		assert(idx < size_config_data_collect_write_back[network] &&
			"packet number should be less than total data collected via network in an execution pass.");
		assert(offset < size_config_data_collect_write_back[network] &&
			"packet's offset number should be less than total data collected via network in an execution pass.");

		config_data_collect_write_back[network][idx] = offset;
	}
	inFile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rsi, -0x440(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movzbl 0x213bc3(%rip), %eax    # 0x61e5e4
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x425dd0
movq %rax, 0x213bbf(%rip)    # 0x61e608
movb $0x0, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
movzbl 0x213b8c(%rip), %ecx    # 0x61e5e4
cmpl %ecx, %eax
jge 0x40aaa8
movq 0x213b8d(%rip), %rax    # 0x61e5f0
movzbl -0x11(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
movl $0x2, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x425dd0
movq %rax, %rdx
movq 0x213b72(%rip), %rax    # 0x61e608
movzbl -0x11(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0x40aa4d
movq -0x440(%rbp), %rdi
movw $0x0, -0x14(%rbp)
callq 0x4a4170
movq %rax, %rsi
leaq -0x220(%rbp), %rdi
movl $0x8, %edx
callq 0x46e8c0
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x472d80
movb %al, -0x441(%rbp)
jmp 0x40aaee
movb -0x441(%rbp), %al
testb $0x1, %al
jne 0x40aafa
jmp 0x40ab70
movq $0x61f900, %rdi         # imm = 0x61F900
leaq 0x196508(%rip), %rsi    # 0x5a1010
callq 0x492450
movq %rax, -0x450(%rbp)
jmp 0x40ab16
movq -0x440(%rbp), %rdi
callq 0x4a4170
movq -0x450(%rbp), %rdi
movq %rax, %rsi
callq 0x492450
movq %rax, -0x458(%rbp)
jmp 0x40ab3a
movq -0x458(%rbp), %rdi
movq $0x491d30, %rsi         # imm = 0x491D30
callq 0x490f40
jmp 0x40ab4f
movl $0x1, %edi
callq 0x4ec1e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x40aeec
leaq -0x250(%rbp), %rdi
callq 0x4a2620
leaq -0x220(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x4a5170
movq %rax, -0x460(%rbp)
jmp 0x40ab98
movq -0x460(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x472d70
movb %al, -0x461(%rbp)
jmp 0x40abb6
movb -0x461(%rbp), %al
testb $0x1, %al
jne 0x40abc5
jmp 0x40aeb1
movzwl -0x14(%rbp), %eax
cmpl $0x2, %eax
jge 0x40abf3
movw -0x14(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x14(%rbp)
jmp 0x40ab7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x40aee0
leaq -0x3d0(%rbp), %rdi
leaq -0x250(%rbp), %rsi
movl $0x8, %edx
callq 0x49a120
jmp 0x40ac0d
leaq -0x3f0(%rbp), %rdi
movq %rdi, -0x478(%rbp)
callq 0x4a2620
leaq -0x410(%rbp), %rdi
callq 0x4a2620
leaq -0x430(%rbp), %rdi
callq 0x4a2620
movq -0x478(%rbp), %rsi
leaq -0x3d0(%rbp), %rdi
callq 0x4277f0
movq %rax, -0x470(%rbp)
jmp 0x40ac54
movq -0x470(%rbp), %rdi
leaq -0x410(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x480(%rbp)
jmp 0x40ac70
movq -0x480(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x4277f0
jmp 0x40ac85
xorl %eax, %eax
movl %eax, %esi
leaq -0x3f0(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x488(%rbp)
jmp 0x40aca3
movq -0x488(%rbp), %rax
movb %al, -0x431(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x410(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x490(%rbp)
jmp 0x40acce
movq -0x490(%rbp), %rax
movw %ax, -0x434(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x430(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x498(%rbp)
jmp 0x40acfa
movq -0x498(%rbp), %rax
movw %ax, -0x436(%rbp)
movzbl -0x431(%rbp), %ecx
movzbl 0x2138ce(%rip), %edx    # 0x61e5e4
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x499(%rbp)
jge 0x40ad2c
movb $0x1, %al
movb %al, -0x499(%rbp)
jmp 0x40ad2c
movb -0x499(%rbp), %al
testb $0x1, %al
jne 0x40ad38
jmp 0x40ad3a
jmp 0x40ada0
leaq 0x197c05(%rip), %rdi    # 0x5a2946
leaq 0x196346(%rip), %rsi    # 0x5a108e
movl $0x267, %edx            # imm = 0x267
leaq 0x197c54(%rip), %rcx    # 0x5a29a8
callq 0x4e53d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x4a2730
leaq -0x410(%rbp), %rdi
callq 0x4a2730
leaq -0x3f0(%rbp), %rdi
callq 0x4a2730
leaq -0x3d0(%rbp), %rdi
callq 0x497a10
jmp 0x40aee0
movzwl -0x434(%rbp), %ecx
movq 0x213842(%rip), %rax    # 0x61e5f0
movzbl -0x431(%rbp), %edx
movzwl (%rax,%rdx,2), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x49a(%rbp)
jge 0x40adcf
movb $0x1, %al
movb %al, -0x49a(%rbp)
jmp 0x40adcf
movb -0x49a(%rbp), %al
testb $0x1, %al
jne 0x40addb
jmp 0x40addd
jmp 0x40adfc
leaq 0x197c59(%rip), %rdi    # 0x5a2a3d
leaq 0x1962a3(%rip), %rsi    # 0x5a108e
movl $0x269, %edx            # imm = 0x269
leaq 0x197bb1(%rip), %rcx    # 0x5a29a8
callq 0x4e53d0
movzwl -0x436(%rbp), %ecx
movq 0x2137e6(%rip), %rax    # 0x61e5f0
movzbl -0x431(%rbp), %edx
movzwl (%rax,%rdx,2), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x49b(%rbp)
jge 0x40ae2b
movb $0x1, %al
movb %al, -0x49b(%rbp)
jmp 0x40ae2b
movb -0x49b(%rbp), %al
testb $0x1, %al
jne 0x40ae37
jmp 0x40ae39
jmp 0x40ae58
leaq 0x197cf0(%rip), %rdi    # 0x5a2b30
leaq 0x196247(%rip), %rsi    # 0x5a108e
movl $0x26b, %edx            # imm = 0x26B
leaq 0x197b55(%rip), %rcx    # 0x5a29a8
callq 0x4e53d0
movw -0x436(%rbp), %dx
movq 0x2137a2(%rip), %rax    # 0x61e608
movzbl -0x431(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movzwl -0x434(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
leaq -0x430(%rbp), %rdi
callq 0x4a2730
leaq -0x410(%rbp), %rdi
callq 0x4a2730
leaq -0x3f0(%rbp), %rdi
callq 0x4a2730
leaq -0x3d0(%rbp), %rdi
callq 0x497a10
jmp 0x40ab7c
leaq -0x220(%rbp), %rdi
callq 0x46ee70
jmp 0x40aebf
leaq -0x250(%rbp), %rdi
callq 0x4a2730
leaq -0x220(%rbp), %rdi
callq 0x46f220
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
leaq -0x250(%rbp), %rdi
callq 0x4a2730
leaq -0x220(%rbp), %rdi
callq 0x46f220
movq -0x228(%rbp), %rdi
callq 0x4d0770
nopw %cs:(%rax,%rax)