// File: MPSLab-ASU[P]DiRAC/./src/baseAccelSim.cc
// Function: baseAccelSim::read_file_SPM_config(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void baseAccelSim::read_file_SPM_config(string spmConfigFileName)
{
	uint8_t operand_number; uint32_t start_addr_SPM_buffer0, start_addr_SPM_buffer1;
	uint16_t it=0;

	ifstream inFile(spmConfigFileName.c_str());
	if(!inFile)
	{
		cout << "Cannot open and read file: " << spmConfigFileName.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;
		operand_number = stoul(token1);
		start_addr_SPM_buffer0 = stoul(token2);
		start_addr_SPM_buffer1 = stoul(token3);

		assert((operand_number >= 0 && operand_number < total_operands) && "invalid operand number!");
		assert(start_addr_SPM_buffer0 >= 0 && start_addr_SPM_buffer0 < SPM_size && "invalid SPM address specified!");
		assert(start_addr_SPM_buffer1 >= 0 && start_addr_SPM_buffer1 < SPM_size && "invalid SPM address specified!");

		operand_start_addr_SPM_buffer[0][operand_number] = start_addr_SPM_buffer0;
		operand_start_addr_SPM_buffer[1][operand_number] = start_addr_SPM_buffer1;
		it++;
	}

	inFile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rsi, -0x450(%rbp)
movq %rdi, %rax
movq -0x450(%rbp), %rdi
movq %rdi, -0x448(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movw $0x0, -0x1e(%rbp)
callq 0x4a4170
movq %rax, %rsi
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x46e8c0
movq -0x228(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x228(%rbp,%rax), %rdi
callq 0x472d80
movb %al, -0x439(%rbp)
jmp 0x407eca
movb -0x439(%rbp), %al
testb $0x1, %al
jne 0x407ed6
jmp 0x407f4c
movq $0x61f900, %rdi         # imm = 0x61F900
leaq 0x19912c(%rip), %rsi    # 0x5a1010
callq 0x492450
movq %rax, -0x458(%rbp)
jmp 0x407ef2
movq -0x448(%rbp), %rdi
callq 0x4a4170
movq -0x458(%rbp), %rdi
movq %rax, %rsi
callq 0x492450
movq %rax, -0x460(%rbp)
jmp 0x407f16
movq -0x460(%rbp), %rdi
movq $0x491d30, %rsi         # imm = 0x491D30
callq 0x490f40
jmp 0x407f2b
movl $0x1, %edi
callq 0x4ec1e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x4082d4
leaq -0x258(%rbp), %rdi
callq 0x4a2620
leaq -0x228(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x4a5170
movq %rax, -0x468(%rbp)
jmp 0x407f74
movq -0x468(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x472d70
movb %al, -0x469(%rbp)
jmp 0x407f92
movb -0x469(%rbp), %al
testb $0x1, %al
jne 0x407fa1
jmp 0x408299
movzwl -0x1e(%rbp), %eax
cmpl $0x2, %eax
jge 0x407fcf
movw -0x1e(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x1e(%rbp)
jmp 0x407f58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x4082c8
leaq -0x3d8(%rbp), %rdi
leaq -0x258(%rbp), %rsi
movl $0x8, %edx
callq 0x49a120
jmp 0x407fe9
leaq -0x3f8(%rbp), %rdi
movq %rdi, -0x480(%rbp)
callq 0x4a2620
leaq -0x418(%rbp), %rdi
callq 0x4a2620
leaq -0x438(%rbp), %rdi
callq 0x4a2620
movq -0x480(%rbp), %rsi
leaq -0x3d8(%rbp), %rdi
callq 0x4277f0
movq %rax, -0x478(%rbp)
jmp 0x408030
movq -0x478(%rbp), %rdi
leaq -0x418(%rbp), %rsi
callq 0x4277f0
movq %rax, -0x488(%rbp)
jmp 0x40804c
movq -0x488(%rbp), %rdi
leaq -0x438(%rbp), %rsi
callq 0x4277f0
jmp 0x408061
xorl %eax, %eax
movl %eax, %esi
leaq -0x3f8(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x490(%rbp)
jmp 0x40807f
movq -0x490(%rbp), %rax
movb %al, -0x11(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x418(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x498(%rbp)
jmp 0x4080a7
movq -0x498(%rbp), %rax
movl %eax, -0x18(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x438(%rbp), %rdi
movl $0xa, %edx
callq 0x40f200
movq %rax, -0x4a0(%rbp)
jmp 0x4080cf
movq -0x4a0(%rbp), %rax
movl %eax, -0x1c(%rbp)
movzbl -0x11(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4a1(%rbp)
jl 0x40810b
movzbl -0x11(%rbp), %ecx
movzbl 0x216461(%rip), %edx    # 0x61e556
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x4a1(%rbp)
jge 0x40810b
movb $0x1, %al
movb %al, -0x4a1(%rbp)
jmp 0x40810b
movb -0x4a1(%rbp), %al
testb $0x1, %al
jne 0x408117
jmp 0x408119
jmp 0x40817f
leaq 0x199ed0(%rip), %rdi    # 0x5a1ff0
leaq 0x198f67(%rip), %rsi    # 0x5a108e
movl $0xf6, %edx
leaq 0x199f13(%rip), %rcx    # 0x5a2046
callq 0x4e53d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x438(%rbp), %rdi
callq 0x4a2730
leaq -0x418(%rbp), %rdi
callq 0x4a2730
leaq -0x3f8(%rbp), %rdi
callq 0x4a2730
leaq -0x3d8(%rbp), %rdi
callq 0x497a10
jmp 0x4082c8
xorl %eax, %eax
cmpl $0x0, -0x18(%rbp)
movb %al, -0x4a2(%rbp)
jb 0x4081aa
movl -0x18(%rbp), %ecx
xorl %eax, %eax
cmpl 0x21641c(%rip), %ecx    # 0x61e5b4
movb %al, -0x4a2(%rbp)
jae 0x4081aa
movb $0x1, %al
movb %al, -0x4a2(%rbp)
jmp 0x4081aa
movb -0x4a2(%rbp), %al
testb $0x1, %al
jne 0x4081b6
jmp 0x4081b8
jmp 0x4081d7
leaq 0x199ed6(%rip), %rdi    # 0x5a2095
leaq 0x198ec8(%rip), %rsi    # 0x5a108e
movl $0xf7, %edx
leaq 0x199e74(%rip), %rcx    # 0x5a2046
callq 0x4e53d0
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x4a3(%rbp)
jb 0x408202
movl -0x1c(%rbp), %ecx
xorl %eax, %eax
cmpl 0x2163c4(%rip), %ecx    # 0x61e5b4
movb %al, -0x4a3(%rbp)
jae 0x408202
movb $0x1, %al
movb %al, -0x4a3(%rbp)
jmp 0x408202
movb -0x4a3(%rbp), %al
testb $0x1, %al
jne 0x40820e
jmp 0x408210
jmp 0x40822f
leaq 0x199ee3(%rip), %rdi    # 0x5a20fa
leaq 0x198e70(%rip), %rsi    # 0x5a108e
movl $0xf8, %edx
leaq 0x199e1c(%rip), %rcx    # 0x5a2046
callq 0x4e53d0
movl -0x18(%rbp), %edx
movq 0x216407(%rip), %rax    # 0x61e640
movq (%rax), %rax
movzbl -0x11(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %edx
movq 0x2163f3(%rip), %rax    # 0x61e640
movq 0x8(%rax), %rax
movzbl -0x11(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movw -0x1e(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x1e(%rbp)
leaq -0x438(%rbp), %rdi
callq 0x4a2730
leaq -0x418(%rbp), %rdi
callq 0x4a2730
leaq -0x3f8(%rbp), %rdi
callq 0x4a2730
leaq -0x3d8(%rbp), %rdi
callq 0x497a10
jmp 0x407f58
leaq -0x228(%rbp), %rdi
callq 0x46ee70
jmp 0x4082a7
leaq -0x258(%rbp), %rdi
callq 0x4a2730
leaq -0x228(%rbp), %rdi
callq 0x46f220
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
leaq -0x258(%rbp), %rdi
callq 0x4a2730
leaq -0x228(%rbp), %rdi
callq 0x46f220
movq -0x230(%rbp), %rdi
callq 0x4d0770
nopl (%rax)