// File: nwieder[P]SSTS/src/System/Gillespie_Sys.cpp
// Function: nw::Gillespie_Sys::Gillespie_Sys(long, long, double, double, std::vector<nw::_Event*, std::allocator<nw::_Event*>>*, std::vector<nw::_Voxel*, std::allocator<nw::_Voxel*>>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<long, std::allocator<long>>, std::vector<long, std::allocator<long>>)
Gillespie_Sys::Gillespie_Sys(long output_mode, long n_steps, double max_Sim_Time,
	double rec_interval, EventVector* evt_vec, VoxelVector* vxl_vec,
	string output_dir_path, vector<long> osid, vector<long> ovid):
	output_mode(output_mode),
	n_steps(n_steps),
	opcntr(0),
	max_Sim_Time(max_Sim_Time),
	rec_interval(rec_interval),
	curr_time(0),
	rec_time(0),
	a_0(0),
	output_dir_path(output_dir_path),
	osid(osid),
	ovid(ovid),
	evt_vec(evt_vec),
	vxl_vec(vxl_vec)
{

//	initialize event counter vector
	evt_cntr.assign(evt_vec->size(), 0);
//  initialize distribution vector
	distr_vec.assign(500, 0);

//	initialize all Events
	for (size_t i = 0; i < evt_vec->size(); ++i) {
		evt_vec->at(i)->init();
	}

	this->a_0 = 0;
//	Calculate a_0 from all system events
	for (size_t i = 0; i < this->evt_vec->size() ;++i){
		this->a_0 += this->evt_vec->at(i)->get_a();
	}

//	Adapt exit conditions and record interval according to the timing_mode
	if (this->output_mode == 1){
		// set the record interval to 10 * average system waiting time
		this->rec_interval = 10 / a_0;
	} else if (this->output_mode == 2){
		this->rec_interval = 0;
	}

//	print data output parameters for data analysis
	this->dcol_path << output_dir_path << "sim_param.py";
	const string &tmp_dcol = this->dcol_path.str();
	this->dcol_file.open(tmp_dcol.c_str());
	this->dcol_file << "mean_tau = " << 1/this->a_0 << endl << "dt = "
					<< this->rec_interval << endl << "n_steps= " << this->n_steps
					<< endl << "T_max = " << this->max_Sim_Time << endl << endl;
	this->dcol_file.close();
	cout 	<< "\n### Timing Parameters ###\n" << "mean_tau = " << 1/this->a_0
			<< endl << "dt = " << this->rec_interval << endl << "n_steps= "
			<< this->n_steps << endl << "T_max = " << this->max_Sim_Time
			<< "\n######################" << endl << endl;

//	initialize channel state log
	channel_state = 0;

//	build the dependency graph
	build_dep_graph();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %r9, -0xa8(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x1b100
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
leaq 0x44551(%rip), %rax     # 0x5db10
movq %rax, (%rdi)
movq -0x10(%rbp), %rax
movq %rax, 0x8(%rdi)
movq -0x18(%rbp), %rax
movq %rax, 0x10(%rdi)
movq $0x0, 0x18(%rdi)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, 0x28(%rdi)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, 0x30(%rdi)
movq $0x0, 0x38(%rdi)
movq $0x0, 0x40(%rdi)
movq $0x0, 0x48(%rdi)
addq $0x50, %rdi
movq %rdi, -0xa0(%rbp)
callq 0x5130
jmp 0x19618
movq -0xb0(%rbp), %rdi
addq $0x70, %rdi
movq %rdi, -0xc8(%rbp)
callq 0x51e0
jmp 0x19631
movq -0xb0(%rbp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
movq %rdi, -0xd0(%rbp)
callq 0x51e0
jmp 0x1964d
movq -0xb0(%rbp), %rdi
addq $0x380, %rdi            # imm = 0x380
movq %rdi, -0xd8(%rbp)
callq 0x51e0
jmp 0x19669
movq -0xb0(%rbp), %rdi
addq $0x508, %rdi            # imm = 0x508
movq %rdi, -0xe0(%rbp)
callq 0x51e0
jmp 0x19685
movq -0xb0(%rbp), %rdi
addq $0x690, %rdi            # imm = 0x690
movq %rdi, -0xe8(%rbp)
callq 0x5610
jmp 0x196a1
movq -0xb0(%rbp), %rdi
addq $0x890, %rdi            # imm = 0x890
movq %rdi, -0xf0(%rbp)
callq 0x5610
jmp 0x196bd
movq -0xb0(%rbp), %rdi
addq $0xa90, %rdi            # imm = 0xA90
movq %rdi, -0xf8(%rbp)
callq 0x5610
jmp 0x196d9
movq -0xb0(%rbp), %rdi
addq $0xc90, %rdi            # imm = 0xC90
movq %rdi, -0x100(%rbp)
callq 0x5610
jmp 0x196f5
movq -0xb0(%rbp), %rdi
addq $0xe90, %rdi            # imm = 0xE90
movq %rdi, -0x118(%rbp)
callq 0x10390
movq -0xb0(%rbp), %rdi
addq $0xea8, %rdi            # imm = 0xEA8
movq %rdi, -0x110(%rbp)
callq 0x10390
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
addq $0xec0, %rdi            # imm = 0xEC0
movq %rdi, -0x108(%rbp)
callq 0x79e0
jmp 0x1974c
movq -0xc0(%rbp), %rsi
movq -0xb0(%rbp), %rdi
addq $0xed8, %rdi            # imm = 0xED8
movq %rdi, -0x120(%rbp)
callq 0x79e0
jmp 0x1976f
movq -0xb0(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0xef0(%rax)
movq -0x38(%rbp), %rcx
movq %rcx, 0xef8(%rax)
addq $0xe90, %rax            # imm = 0xE90
movq %rax, -0x128(%rbp)
movq -0x30(%rbp), %rdi
callq 0x7b50
movq -0x128(%rbp), %rdi
movq %rax, %rsi
movq $0x0, -0x58(%rbp)
leaq -0x58(%rbp), %rdx
callq 0x7bc0
jmp 0x197bf
movq -0xb0(%rbp), %rdi
addq $0xea8, %rdi            # imm = 0xEA8
movq $0x0, -0x60(%rbp)
movl $0x1f4, %esi            # imm = 0x1F4
leaq -0x60(%rbp), %rdx
callq 0x7bc0
jmp 0x197e5
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x30(%rbp), %rdi
callq 0x7b50
movq %rax, %rcx
movq -0x130(%rbp), %rax
cmpq %rcx, %rax
jae 0x1991b
movq -0x30(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x102d0
movq %rax, -0x138(%rbp)
jmp 0x1982a
movq -0x138(%rbp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
jmp 0x1983f
jmp 0x19841
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x197ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19edb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19ecf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19ec3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19eb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19eab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19e9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19e93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19e87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19e7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19e57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19e4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19e3f
movq -0xb0(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x48(%rax)
movq $0x0, -0x70(%rbp)
movq -0xb0(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, -0x140(%rbp)
movq 0xef0(%rax), %rdi
callq 0x7b50
movq %rax, %rcx
movq -0x140(%rbp), %rax
cmpq %rcx, %rax
jae 0x199c6
movq -0xb0(%rbp), %rax
movq 0xef0(%rax), %rdi
movq -0x70(%rbp), %rsi
callq 0x102d0
movq %rax, -0x148(%rbp)
jmp 0x1997f
movq -0x148(%rbp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movsd %xmm0, -0x150(%rbp)
jmp 0x1999c
movq -0xb0(%rbp), %rax
movsd -0x150(%rbp), %xmm0
addsd 0x48(%rax), %xmm0
movsd %xmm0, 0x48(%rax)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x19932
movq -0xb0(%rbp), %rax
cmpq $0x1, 0x8(%rax)
jne 0x199ef
movq -0xb0(%rbp), %rax
movsd 0x2bf65(%rip), %xmm0    # 0x45948
divsd 0x48(%rax), %xmm0
movsd %xmm0, 0x30(%rax)
jmp 0x19a0e
movq -0xb0(%rbp), %rax
cmpq $0x2, 0x8(%rax)
jne 0x19a0c
movq -0xb0(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x30(%rax)
jmp 0x19a0e
movq -0xa8(%rbp), %rsi
movq -0xb0(%rbp), %rdi
addq $0x518, %rdi            # imm = 0x518
callq 0x52c0
movq %rax, -0x158(%rbp)
jmp 0x19a31
movq -0x158(%rbp), %rdi
leaq 0x2bf19(%rip), %rsi     # 0x45958
callq 0x5300
jmp 0x19a46
movq -0xb0(%rbp), %rsi
addq $0x508, %rsi            # imm = 0x508
leaq -0x98(%rbp), %rdi
callq 0x52f0
jmp 0x19a62
movq -0xb0(%rbp), %rax
leaq -0x98(%rbp), %rcx
movq %rcx, -0x78(%rbp)
addq $0xc90, %rax            # imm = 0xC90
movq %rax, -0x160(%rbp)
movq -0x78(%rbp), %rdi
callq 0x5120
movq -0x160(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0x5060
jmp 0x19aa0
movq -0xb0(%rbp), %rdi
addq $0xc90, %rdi            # imm = 0xC90
leaq 0x2beb0(%rip), %rsi     # 0x45965
callq 0x5300
movq %rax, -0x168(%rbp)
jmp 0x19ac3
movq -0x168(%rbp), %rdi
movq -0xb0(%rbp), %rax
movsd 0x48(%rax), %xmm1
movsd 0x2be72(%rip), %xmm0    # 0x45950
divsd %xmm1, %xmm0
callq 0x5700
movq %rax, -0x170(%rbp)
jmp 0x19af0
movq -0x170(%rbp), %rdi
movq 0x444a2(%rip), %rsi     # 0x5dfa0
callq 0x5340
movq %rax, -0x178(%rbp)
jmp 0x19b0c
movq -0x178(%rbp), %rdi
leaq 0x2be57(%rip), %rsi     # 0x45971
callq 0x5300
movq %rax, -0x180(%rbp)
jmp 0x19b28
movq -0x180(%rbp), %rdi
movq -0xb0(%rbp), %rax
movsd 0x30(%rax), %xmm0
callq 0x5700
movq %rax, -0x188(%rbp)
jmp 0x19b49
movq -0x188(%rbp), %rdi
movq 0x44449(%rip), %rsi     # 0x5dfa0
callq 0x5340
movq %rax, -0x190(%rbp)
jmp 0x19b65
movq -0x190(%rbp), %rdi
leaq 0x2be04(%rip), %rsi     # 0x45977
callq 0x5300
movq %rax, -0x198(%rbp)
jmp 0x19b81
movq -0x198(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x50b0
movq %rax, -0x1a0(%rbp)
jmp 0x19ba1
movq -0x1a0(%rbp), %rdi
movq 0x443f1(%rip), %rsi     # 0x5dfa0
callq 0x5340
movq %rax, -0x1a8(%rbp)
jmp 0x19bbd
movq -0x1a8(%rbp), %rdi
leaq 0x2bdb6(%rip), %rsi     # 0x45981
callq 0x5300
movq %rax, -0x1b0(%rbp)
jmp 0x19bd9
movq -0x1b0(%rbp), %rdi
movq -0xb0(%rbp), %rax
movsd 0x28(%rax), %xmm0
callq 0x5700
movq %rax, -0x1b8(%rbp)
jmp 0x19bfa
movq -0x1b8(%rbp), %rdi
movq 0x44398(%rip), %rsi     # 0x5dfa0
callq 0x5340
movq %rax, -0x1c0(%rbp)
jmp 0x19c16
movq -0x1c0(%rbp), %rdi
movq 0x4437c(%rip), %rsi     # 0x5dfa0
callq 0x5340
jmp 0x19c2b
movq -0xb0(%rbp), %rdi
addq $0xc90, %rdi            # imm = 0xC90
callq 0x5510
jmp 0x19c40
movq 0x44389(%rip), %rdi     # 0x5dfd0
leaq 0x2bd3c(%rip), %rsi     # 0x4598a
callq 0x5300
movq %rax, -0x1c8(%rbp)
jmp 0x19c5c
movq -0x1c8(%rbp), %rdi
leaq 0x2bcfb(%rip), %rsi     # 0x45965
callq 0x5300
movq %rax, -0x1d0(%rbp)
jmp 0x19c78
movq -0x1d0(%rbp), %rdi
movq -0xb0(%rbp), %rax
movsd 0x48(%rax), %xmm1
movsd 0x2bcbd(%rip), %xmm0    # 0x45950
divsd %xmm1, %xmm0
callq 0x5700
movq %rax, -0x1d8(%rbp)
jmp 0x19ca5
movq -0x1d8(%rbp), %rdi
movq 0x442ed(%rip), %rsi     # 0x5dfa0
callq 0x5340
movq %rax, -0x1e0(%rbp)
jmp 0x19cc1
movq -0x1e0(%rbp), %rdi
leaq 0x2bca2(%rip), %rsi     # 0x45971
callq 0x5300
movq %rax, -0x1e8(%rbp)
jmp 0x19cdd
movq -0x1e8(%rbp), %rdi
movq -0xb0(%rbp), %rax
movsd 0x30(%rax), %xmm0
callq 0x5700
movq %rax, -0x1f0(%rbp)
jmp 0x19cfe
movq -0x1f0(%rbp), %rdi
movq 0x44294(%rip), %rsi     # 0x5dfa0
callq 0x5340
movq %rax, -0x1f8(%rbp)
jmp 0x19d1a
movq -0x1f8(%rbp), %rdi
leaq 0x2bc4f(%rip), %rsi     # 0x45977
callq 0x5300
movq %rax, -0x200(%rbp)
jmp 0x19d36
movq -0x200(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x50b0
movq %rax, -0x208(%rbp)
jmp 0x19d56
movq -0x208(%rbp), %rdi
movq 0x4423c(%rip), %rsi     # 0x5dfa0
callq 0x5340
movq %rax, -0x210(%rbp)
jmp 0x19d72
movq -0x210(%rbp), %rdi
leaq 0x2bc01(%rip), %rsi     # 0x45981
callq 0x5300
movq %rax, -0x218(%rbp)
jmp 0x19d8e
movq -0x218(%rbp), %rdi
movq -0xb0(%rbp), %rax
movsd 0x28(%rax), %xmm0
callq 0x5700
movq %rax, -0x220(%rbp)
jmp 0x19daf
movq -0x220(%rbp), %rdi
leaq 0x2bbe9(%rip), %rsi     # 0x459a6
callq 0x5300
movq %rax, -0x228(%rbp)
jmp 0x19dcb
movq -0x228(%rbp), %rdi
movq 0x441c7(%rip), %rsi     # 0x5dfa0
callq 0x5340
movq %rax, -0x230(%rbp)
jmp 0x19de7
movq -0x230(%rbp), %rdi
movq 0x441ab(%rip), %rsi     # 0x5dfa0
callq 0x5340
jmp 0x19dfc
movq -0xb0(%rbp), %rdi
movq $0x0, 0x20(%rdi)
callq 0x19ef0
jmp 0x19e12
leaq -0x98(%rbp), %rdi
callq 0x5768
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5768
movq -0x120(%rbp), %rdi
callq 0x61a0
movq -0x108(%rbp), %rdi
callq 0x61a0
movq -0x110(%rbp), %rdi
callq 0x61a0
movq -0x118(%rbp), %rdi
callq 0x61a0
movq -0x100(%rbp), %rdi
callq 0x5550
movq -0xf8(%rbp), %rdi
callq 0x5550
movq -0xf0(%rbp), %rdi
callq 0x5550
movq -0xe8(%rbp), %rdi
callq 0x5550
movq -0xe0(%rbp), %rdi
callq 0x5230
movq -0xd8(%rbp), %rdi
callq 0x5230
movq -0xd0(%rbp), %rdi
callq 0x5230
movq -0xc8(%rbp), %rdi
callq 0x5230
movq -0xa0(%rbp), %rdi
callq 0x5768
movq -0xb0(%rbp), %rdi
callq 0x1b580
movq -0x48(%rbp), %rdi
callq 0x5650