// File: /workspace/github_cpp_makefile_star2_O3/nwieder[P]SSTS/src/System/Gillespie_Sys.cpp
// Function: nw::Gillespie_Sys::go(long)
void Gillespie_Sys::go(long n_it)
{
	try{

// 		build path to output files. n_it represents the current simulation run.

//		data files containing molecular numbers
		data_path << output_dir_path << "data_" << n_it << ".e";
// 		open/close log for channel dynamics
		oc_path << output_dir_path << "oc_log_" << n_it << ".e";
//		independent result log of every simulation run
		info_path << output_dir_path << "sim_res.e";

		const string &tmp_data = data_path.str();
		const string &tmp_info = info_path.str();
		const string &tmp_oclog = oc_path.str();

//		connect streams to output file
		data_output_file.open(tmp_data.c_str());
		oc_log_file.open(tmp_oclog.c_str());
		oc_log_file << std::setprecision(10);

//		reconnect to existing file (adding text)
		if (n_it == 1){
			info_output_file.open(tmp_info.c_str());
		}else{
			info_output_file.open(tmp_info.c_str(), ios::in | ios::ate);
		}

//		console output: indicate simulation start
		info_output_file<< "###### Run: " << n_it << " ######" << endl;
		cout << "--SIMULATION BEGIN-- \n" << endl;
		info_output_file << "--SIMULATION RESULTS-- \n" << endl;

//		print the initial system state
		print_system_state();

//		###############################
//		## START THE SIMULATION LOOP ##
//		###############################

//		set times
		double tau = 0, begin, end;
		begin = time(0);

//		check exit conditions
		for (size_t i = 0; i < n_steps; ++i) {
			if (curr_time <= max_Sim_Time) {

				long nextIndex = 0;
				double minTau = INFINITY;

//				event update procedure
				for (size_t j = 0; j < evt_vec->size(); ++j) {
					double actTau = evt_vec->at(j)->update(tau);
//					determine next Event Index
					if (actTau < minTau) {
						minTau = actTau;
						nextIndex = j;
					}
				}

//				update system times
				tau = minTau;
				rec_time += tau;
				curr_time += tau;

//				update event counter
				evt_cntr[nextIndex]++;

//				execute next Event
				evt_vec->at(nextIndex)->execute();

//				print system state if necessary
				system_output();

			} else{
				n_steps = i;
				break;
			}
		}

//		############################
//		## END OF SIMULATION LOOP ##
//		############################

		end = time(0);

//		output of event distribution in info_output_file
		cout << "Event distribution:\t";
		info_output_file << "Event distribution:\t";
		for (long p = 0; p < (long)evt_cntr.size(); p++){
			cout << evt_cntr.at(p) << ",";
			info_output_file << evt_cntr.at(p) << ",";
		}
		cout << endl;
		info_output_file << endl;

//		system information output to info_output_file.
		cout << "Simulated time:\t\t" << curr_time << " ms" << endl;
		info_output_file << "Simulated time:\t\t" << curr_time << " ms" << endl;
		cout << "Number of steps: \t" << n_steps << endl;
		info_output_file << "Number of steps: \t" << n_steps << endl;
		cout << "Computation time:\t" << end - begin << " s" << endl;
		info_output_file << "Computation time:\t" << end - begin << " s" << endl;

//		console output: indicate simulation end
		print_system_state();
		cout << "\n--SIMULATION END--" << endl;
		info_output_file << "\n--SIMULATION END--" << endl << endl << endl;

// 		disconnect stream from output file
		data_output_file.close();
		info_output_file.close();
		oc_log_file.close();
	}

	catch(exception& e){
		cout << "System::go(): " << e.what() << endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r13
movq %rdi, %r15
addq $0x80, %rdi
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
callq 0x42f0
movq %rax, %rbx
leaq 0x158e1(%rip), %rsi     # 0x24a06
movl $0x5, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4270
leaq 0x158d7(%rip), %rsi     # 0x24a1b
movl $0x2, %edx
movq %rax, %rdi
callq 0x42f0
leaq 0x390(%r15), %rdi
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
callq 0x42f0
movq %rax, %rbx
leaq 0x1589d(%rip), %rsi     # 0x24a0c
movl $0x7, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4270
leaq 0x1588d(%rip), %rsi     # 0x24a1b
movl $0x2, %edx
movq %rax, %rdi
callq 0x42f0
leaq 0x208(%r15), %rdi
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
callq 0x42f0
leaq 0x1585e(%rip), %rsi     # 0x24a14
movl $0x9, %edx
movq %rax, %rdi
callq 0x42f0
leaq 0x88(%r15), %rsi
leaq 0x78(%rsp), %rdi
callq 0x4460
leaq 0x210(%r15), %rsi
leaq 0x58(%rsp), %rdi
callq 0x4460
leaq 0x398(%r15), %rsi
leaq 0x38(%rsp), %rdi
callq 0x4460
leaq 0x690(%r15), %rdi
movq 0x78(%rsp), %rsi
movq %rdi, 0x28(%rsp)
movl $0x10, %edx
callq 0x4050
leaq 0xa90(%r15), %rbp
movq 0x38(%rsp), %rsi
movl $0x10, %ebx
movq %rbp, %rdi
movl $0x10, %edx
callq 0x4050
movq 0xa90(%r15), %rax
movq -0x18(%rax), %rax
movq $0xa, 0xa98(%r15,%rax)
leaq 0x890(%r15), %r12
cmpq $0x1, %r13
movq 0x58(%rsp), %rsi
movl $0xa, %edx
cmovel %ebx, %edx
movq %r12, %rdi
callq 0x4050
leaq 0x157b1(%rip), %rsi     # 0x24a1e
movl $0xc, %edx
movq %r12, %rdi
callq 0x42f0
movq %r12, %rdi
movq %r13, %rsi
callq 0x4270
movq %rax, %rbx
leaq 0x1579c(%rip), %rsi     # 0x24a2b
movl $0x7, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq 0x23cfe(%rip), %rbx     # 0x32fc8
leaq 0x15762(%rip), %rsi     # 0x24a33
movl $0x16, %edx
movq %rbx, %rdi
callq 0x42f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq 0x23ccc(%rip), %rdi     # 0x32fc8
callq 0x4040
movq %rax, %rdi
callq 0x4190
leaq 0x1573a(%rip), %rsi     # 0x24a4a
movl $0x18, %edx
movq %r12, %rdi
callq 0x42f0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq %r15, %rdi
callq 0xfa46
xorl %edi, %edi
callq 0x4260
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x10(%r15)
je 0xf463
xorpd %xmm2, %xmm2
xorl %r14d, %r14d
movsd 0x28(%r15), %xmm0
movsd 0x38(%r15), %xmm1
ucomisd %xmm1, %xmm0
jb 0xf45f
movq 0xef0(%r15), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
je 0xf3fc
xorl %r13d, %r13d
movsd 0x14c69(%rip), %xmm1    # 0x24008
xorl %ebx, %ebx
movapd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
movq (%rax,%r13,8), %rdi
movq (%rdi), %rax
movapd %xmm2, %xmm0
callq *0x10(%rax)
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %r13, %rbx
minsd %xmm1, %xmm0
incq %r13
movq 0xef0(%r15), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movapd %xmm0, %xmm1
cmpq %rdx, %r13
movapd 0x10(%rsp), %xmm2
jb 0xf3a7
movsd 0x38(%r15), %xmm1
jmp 0xf40a
sarq $0x3, %rdx
xorl %ebx, %ebx
movsd 0x14bfe(%rip), %xmm0    # 0x24008
movapd %xmm0, 0x10(%rsp)
movhpd 0x40(%r15), %xmm1       # xmm1 = xmm1[0],mem[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
addpd %xmm0, %xmm1
movupd %xmm1, 0x38(%r15)
movq 0xe90(%r15), %rcx
incq (%rcx,%rbx,8)
cmpq %rbx, %rdx
jbe 0xf946
movq (%rax,%rbx,8), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq %r15, %rdi
callq 0xfcbc
incq %r14
cmpq 0x10(%r15), %r14
movapd 0x10(%rsp), %xmm2
jb 0xf36b
jmp 0xf463
movq %r14, 0x10(%r15)
movq %rbp, 0x10(%rsp)
xorl %edi, %edi
callq 0x4260
movq %rax, 0x8(%rsp)
movq 0x23b4d(%rip), %rbx     # 0x32fc8
leaq 0x155e1(%rip), %rsi     # 0x24a63
movl $0x14, %edx
movq %rbx, %rdi
callq 0x42f0
leaq 0x155cd(%rip), %rsi     # 0x24a63
movl $0x14, %edx
movq %r12, %rdi
callq 0x42f0
movq 0xe90(%r15), %rax
movq 0xe98(%r15), %rcx
subq %rax, %rcx
testq %rcx, %rcx
jle 0xf541
xorl %r14d, %r14d
movq 0x23b01(%rip), %r13     # 0x32fc8
leaq 0x14f46(%rip), %rbp     # 0x24414
movq (%rax,%r14,8), %rsi
movq %r13, %rdi
callq 0x4270
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42f0
movq 0xe90(%r15), %rax
movq 0xe98(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0xf935
movq (%rax,%r14,8), %rsi
movq %r12, %rdi
callq 0x4270
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42f0
incq %r14
movq 0xe90(%r15), %rax
movq 0xe98(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r14
jl 0xf4ce
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq 0x23a69(%rip), %rdi     # 0x32fc8
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq 0x23a2d(%rip), %rdi     # 0x32fc8
leaq 0x154d6(%rip), %rsi     # 0x24a78
movl $0x11, %edx
callq 0x42f0
movsd 0x38(%r15), %xmm0
movq 0x23a0f(%rip), %rdi     # 0x32fc8
callq 0x4480
movq %rax, %rbx
leaq 0x154c2(%rip), %rsi     # 0x24a8a
movl $0x3, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
leaq 0x15475(%rip), %rsi     # 0x24a78
movl $0x11, %edx
movq %r12, %rdi
callq 0x42f0
movsd 0x38(%r15), %xmm0
movq %r12, %rdi
callq 0x4480
movq %rax, %rbx
leaq 0x15462(%rip), %rsi     # 0x24a8a
movl $0x3, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq 0x23965(%rip), %rdi     # 0x32fc8
leaq 0x15424(%rip), %rsi     # 0x24a8e
movl $0x12, %edx
callq 0x42f0
movq 0x10(%r15), %rsi
movq 0x23949(%rip), %rdi     # 0x32fc8
callq 0x4180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
leaq 0x153d9(%rip), %rsi     # 0x24a8e
movl $0x12, %edx
movq %r12, %rdi
callq 0x42f0
movq 0x10(%r15), %rsi
movq %r12, %rdi
callq 0x4180
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq 0x238c9(%rip), %rdi     # 0x32fc8
leaq 0x1539b(%rip), %rsi     # 0x24aa1
movl $0x12, %edx
callq 0x42f0
cvtsi2sdq 0x30(%rsp), %xmm1
cvtsi2sdq 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movq 0x2389f(%rip), %rdi     # 0x32fc8
movsd %xmm0, 0x8(%rsp)
callq 0x4480
movq %rax, %rbx
leaq 0x17057(%rip), %rsi     # 0x26795
movl $0x2, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
leaq 0x15328(%rip), %rsi     # 0x24aa1
movl $0x12, %edx
movq %r12, %rdi
callq 0x42f0
movq %r12, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x4480
movq %rax, %rbx
leaq 0x16ff7(%rip), %rsi     # 0x26795
movl $0x2, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq %r15, %rdi
callq 0xfa46
movq 0x237e7(%rip), %rbx     # 0x32fc8
leaq 0x152cc(%rip), %rsi     # 0x24ab4
movl $0x13, %edx
movq %rbx, %rdi
callq 0x42f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq 0x237b5(%rip), %rdi     # 0x32fc8
callq 0x4040
movq %rax, %rdi
callq 0x4190
leaq 0x1528d(%rip), %rsi     # 0x24ab4
movl $0x13, %edx
movq %r12, %rdi
callq 0x42f0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4190
movq 0x28(%rsp), %rdi
callq 0x43e0
movq %r12, %rdi
callq 0x43e0
movq 0x10(%rsp), %rdi
callq 0x43e0
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf8e7
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42c0
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf902
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42c0
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf923
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42c0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14707(%rip), %rdi     # 0x24043
movq %r14, %rsi
xorl %eax, %eax
callq 0x4430
leaq 0x146f6(%rip), %rdi     # 0x24043
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4430
movq %rdx, %r14
movq %rax, %rbx
jmp 0xf99e
movq %rdx, %r14
movq %rax, %rbx
jmp 0xf9b9
jmp 0xf96b
jmp 0xf97d
movq %rdx, %r14
movq %rax, %rbx
jmp 0xf9da
jmp 0xf97d
jmp 0xf97d
jmp 0xf97d
jmp 0xf97d
jmp 0xf97d
movq %rdx, %r14
movq %rax, %rbx
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf99e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42c0
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf9b9
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42c0
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf9da
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42c0
cmpl $0x1, %r14d
jne 0xfa35
movq %rbx, %rdi
callq 0x4100
movq %rax, %rbx
movq 0x235d6(%rip), %rdi     # 0x32fc8
leaq 0x150cf(%rip), %rsi     # 0x24ac8
movl $0xe, %edx
callq 0x42f0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq 0x235b5(%rip), %rdi     # 0x32fc8
movq %rax, %rsi
callq 0x4290
movq %rax, %rdi
callq 0x4120
callq 0x44a0
jmp 0xf923
movq %rax, %rbx
callq 0x44a0
movq %rbx, %rdi
callq 0x4510
movq %rax, %rdi
callq 0x71af
nop