// File: MPSLab-ASU[P]DiRAC/./src/baseAccelSim.cc
// Function: baseAccelSim::set_kernel_parameters()
void baseAccelSim::set_kernel_parameters()
{
	uint16_t idx = 0;
	assert(idx >= 0 && "Not A Valid Processing of the Kernel.");

	std::vector<uint16_t> tokens; std::string token;
	std::istringstream tokenStream(kernels[idx]);
	while (std::getline(tokenStream, token, ','))
	 	tokens.push_back(stoi(token));

	assert(tokens.size() >= 4 && "Incorrect number of bytes for a layer. Total bytes must be 4 or more.");

	total_operands	= tokens[0];
	output_operands = tokens[1];

	assert(total_operands >= 3 && "Total tensor operands must be three or more for a kernel execution.");
	assert(output_operands < total_operands && "Total tensor operands for outputs must be less than total input/output tensor operands for a kernel execution.");

	input_operands = total_operands - output_operands;
	tensor_operands	= new data_type*[total_operands];
	golden_outputs	= new data_type*[output_operands];
	size_tensors		= new uint64_t[total_operands]();

	for(uint8_t it=0; it < total_operands; it++)
	{
		size_tensors[it]	= tokens[2 + it];
		assert(size_tensors[it] >= 1 && "Tensor operand must contain one or more elements.");
		tensor_operands[it]	= new data_type[size_tensors[it]]();
		if(it >= input_operands)
			golden_outputs[it - input_operands] = new data_type[size_tensors[it]]();
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movw $0x0, -0xa(%rbp)
movzwl -0xa(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1d8(%rbp)
jl 0x405180
movb $0x1, %al
movb %al, -0x1d8(%rbp)
jmp 0x405180
movb -0x1d8(%rbp), %al
testb $0x1, %al
jne 0x40518c
jmp 0x40518e
jmp 0x4051ad
leaq 0x19d3c1(%rip), %rdi    # 0x5a2556
leaq 0x19bef2(%rip), %rsi    # 0x5a108e
movl $0x165, %edx            # imm = 0x165
leaq 0x19d3e2(%rip), %rcx    # 0x5a258a
callq 0x4e53d0
leaq -0x28(%rbp), %rdi
callq 0x40f2b0
leaq -0x48(%rbp), %rdi
callq 0x4a2620
movzwl -0xa(%rbp), %eax
movl %eax, %esi
leaq 0x2193c4(%rip), %rdi    # 0x61e590
callq 0x40f2d0
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
movl $0x8, %edx
callq 0x49a120
jmp 0x4051e7
jmp 0x4051e9
leaq -0x1c8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x2c, %edx
callq 0x427b70
movq %rax, -0x1e0(%rbp)
jmp 0x405207
movq -0x1e0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x472d70
movb %al, -0x1e1(%rbp)
jmp 0x405225
movb -0x1e1(%rbp), %al
testb $0x1, %al
jne 0x405231
jmp 0x4052a9
xorl %eax, %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
movl $0xa, %edx
callq 0x40ee40
movl %eax, -0x1e8(%rbp)
jmp 0x40524b
movl -0x1e8(%rbp), %eax
movw %ax, -0x1d6(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x1d6(%rbp), %rsi
callq 0x40f2f0
jmp 0x40526a
jmp 0x4051e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d0(%rbp)
movl %eax, -0x1d4(%rbp)
jmp 0x40562d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d0(%rbp)
movl %eax, -0x1d4(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x497a10
jmp 0x40562d
leaq -0x28(%rbp), %rdi
callq 0x40f320
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x4, %rcx
movb %al, -0x1e9(%rbp)
jb 0x4052cd
movb $0x1, %al
movb %al, -0x1e9(%rbp)
jmp 0x4052cd
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x4052d9
jmp 0x4052db
jmp 0x4052fa
leaq 0x19d319(%rip), %rdi    # 0x5a25fb
leaq 0x19bda5(%rip), %rsi    # 0x5a108e
movl $0x16c, %edx            # imm = 0x16C
leaq 0x19d295(%rip), %rcx    # 0x5a258a
callq 0x4e53d0
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x40f340
movw (%rax), %ax
movb %al, 0x219246(%rip)     # 0x61e556
leaq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x40f340
movw (%rax), %ax
movb %al, 0x219230(%rip)     # 0x61e557
movzbl 0x219228(%rip), %ecx    # 0x61e556
xorl %eax, %eax
cmpl $0x3, %ecx
movb %al, -0x1ea(%rbp)
jl 0x405345
movb $0x1, %al
movb %al, -0x1ea(%rbp)
jmp 0x405345
movb -0x1ea(%rbp), %al
testb $0x1, %al
jne 0x405351
jmp 0x405353
jmp 0x405372
leaq 0x19d343(%rip), %rdi    # 0x5a269d
leaq 0x19bd2d(%rip), %rsi    # 0x5a108e
movl $0x171, %edx            # imm = 0x171
leaq 0x19d21d(%rip), %rcx    # 0x5a258a
callq 0x4e53d0
movzbl 0x2191de(%rip), %ecx    # 0x61e557
movzbl 0x2191d6(%rip), %edx    # 0x61e556
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x1eb(%rbp)
jge 0x405396
movb $0x1, %al
movb %al, -0x1eb(%rbp)
jmp 0x405396
movb -0x1eb(%rbp), %al
testb $0x1, %al
jne 0x4053a2
jmp 0x4053a4
jmp 0x4053c3
leaq 0x19d3be(%rip), %rdi    # 0x5a2769
leaq 0x19bcdc(%rip), %rsi    # 0x5a108e
movl $0x172, %edx            # imm = 0x172
leaq 0x19d1cc(%rip), %rcx    # 0x5a258a
callq 0x4e53d0
movzbl 0x21918c(%rip), %eax    # 0x61e556
movzbl 0x219186(%rip), %ecx    # 0x61e557
subl %ecx, %eax
movb %al, 0x21917f(%rip)     # 0x61e558
movzbl 0x219176(%rip), %eax    # 0x61e556
shll $0x3, %eax
movl %eax, %edi
callq 0x425dd0
movq %rax, -0x1f8(%rbp)
jmp 0x4053f3
movq -0x1f8(%rbp), %rax
movq %rax, 0x21915f(%rip)    # 0x61e560
movzbl 0x21914f(%rip), %eax    # 0x61e557
shll $0x3, %eax
movl %eax, %edi
callq 0x425dd0
movq %rax, -0x200(%rbp)
jmp 0x40541b
movq -0x200(%rbp), %rax
movq %rax, 0x21913f(%rip)    # 0x61e568
movzbl 0x219126(%rip), %eax    # 0x61e556
shll $0x3, %eax
movl %eax, %edi
movq %rdi, -0x210(%rbp)
callq 0x425dd0
movq %rax, -0x208(%rbp)
jmp 0x40544a
movq -0x208(%rbp), %rdi
movq -0x210(%rbp), %rdx
xorl %esi, %esi
callq 0x401080
movq -0x208(%rbp), %rax
movq %rax, 0x219103(%rip)    # 0x61e570
movb $0x0, -0x1d7(%rbp)
movzbl -0x1d7(%rbp), %eax
movzbl 0x2190d4(%rip), %ecx    # 0x61e556
cmpl %ecx, %eax
jge 0x405606
movzbl -0x1d7(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
leaq -0x28(%rbp), %rdi
callq 0x40f340
movzwl (%rax), %eax
movl %eax, %edx
movq 0x2190c4(%rip), %rax    # 0x61e570
movzbl -0x1d7(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq 0x2190b2(%rip), %rcx    # 0x61e570
movzbl -0x1d7(%rbp), %eax
movl %eax, %edx
xorl %eax, %eax
cmpq $0x1, (%rcx,%rdx,8)
movb %al, -0x211(%rbp)
jb 0x4054e0
movb $0x1, %al
movb %al, -0x211(%rbp)
jmp 0x4054e0
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0x4054ec
jmp 0x4054ee
jmp 0x40550d
leaq 0x19d33b(%rip), %rdi    # 0x5a2830
leaq 0x19bb92(%rip), %rsi    # 0x5a108e
movl $0x17c, %edx            # imm = 0x17C
leaq 0x19d082(%rip), %rcx    # 0x5a258a
callq 0x4e53d0
movq 0x21905c(%rip), %rax    # 0x61e570
movzbl -0x1d7(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
addq %rdi, %rdi
movq $-0x1, %rax
cmovbq %rax, %rdi
movq %rdi, -0x228(%rbp)
callq 0x425dd0
movq %rax, -0x220(%rbp)
jmp 0x405542
movq -0x220(%rbp), %rdi
movq -0x228(%rbp), %rdx
xorl %esi, %esi
callq 0x401080
movq -0x220(%rbp), %rdx
movq 0x218ffb(%rip), %rax    # 0x61e560
movzbl -0x1d7(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movzbl -0x1d7(%rbp), %eax
movzbl 0x218fda(%rip), %ecx    # 0x61e558
cmpl %ecx, %eax
jl 0x4055f1
movq 0x218fe7(%rip), %rax    # 0x61e570
movzbl -0x1d7(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
addq %rdi, %rdi
movq $-0x1, %rax
cmovbq %rax, %rdi
movq %rdi, -0x238(%rbp)
callq 0x425dd0
movq %rax, -0x230(%rbp)
jmp 0x4055b7
movq -0x230(%rbp), %rdi
movq -0x238(%rbp), %rdx
xorl %esi, %esi
callq 0x401080
movq -0x230(%rbp), %rdx
movq 0x218f8e(%rip), %rax    # 0x61e568
movzbl -0x1d7(%rbp), %ecx
movzbl 0x218f70(%rip), %esi    # 0x61e558
subl %esi, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4055f3
movb -0x1d7(%rbp), %al
addb $0x1, %al
movb %al, -0x1d7(%rbp)
jmp 0x405474
leaq -0x1c8(%rbp), %rdi
callq 0x497a10
leaq -0x48(%rbp), %rdi
callq 0x4a2730
leaq -0x28(%rbp), %rdi
callq 0x40f360
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x4a2730
leaq -0x28(%rbp), %rdi
callq 0x40f360
movq -0x1d0(%rbp), %rdi
callq 0x4d0770
nopl (%rax,%rax)