// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/utils/Helper_Functions.cpp
// Function: Utils::Euler_estimation(std::vector<double, std::allocator<double>>&, unsigned int, double, int, double, double, int)
void Euler_estimation(std::vector<double>& mu, unsigned int b, double rho, int d, double h, double max_diff, int itr_max)
	{
		std::vector<double> w_0, w;
		for (int i = 0; i <= mu.size(); i++) {
			if (i == 0) {
				w_0.push_back(1);
				w.push_back(1);
			} else {
				w_0.push_back(0);
				w.push_back(0);
				for (int j = i; j < mu.size(); j++)
					w_0[i] += mu[j];
			}
		}

		double t = h;
		int itr = 0;
		double diff = 100000000000000;
		while (itr < itr_max && diff > max_diff) {
			double sigma = 0;
			for (unsigned int j = 1; j <= b; j++) {
				sigma += std::pow(w_0[j], d);
			}

			for (unsigned int i = 1; i < b; i++) {
				w[i] = w_0[i] + h * (1 - std::pow(w_0[i], d) - (b - sigma) * ((i * (w_0[i] - w_0[i + 1])) / (b * rho)));
			}

			diff = std::abs(w[0] - w_0[0]);
			for (unsigned int i = 1; i <= b; i++) {
				if (std::abs(w[i] - w_0[i]) > diff) {
					diff = std::abs(w[i] - w_0[i]);
				}
			}

			for (int i = 1; i < w_0.size(); i++) {
				w_0[i] = w[i];
			}

			t += h;
			itr++;
		}

		for (unsigned int i = 0; i <= b; i++) {
			mu[i] = w_0[i] - w_0[i + 1];
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %ecx, 0x2c(%rsp)
movsd %xmm2, 0x60(%rsp)
movsd %xmm1, 0x78(%rsp)
movl %edx, 0x20(%rsp)
movsd %xmm0, 0x38(%rsp)
movl %esi, %ebx
movq %rdi, %r14
xorpd %xmm0, %xmm0
movq %rsp, %rax
movapd %xmm0, (%rax)
xorl %r12d, %r12d
movq %r12, 0x10(%rax)
leaq 0x40(%rsp), %rax
movq %r12, 0x10(%rax)
movq %rax, %rbp
movapd %xmm0, (%rax)
movabsq $0x3ff0000000000000, %r13 # imm = 0x3FF0000000000000
leaq 0x30(%rsp), %r15
testq %r12, %r12
je 0x52946
movq $0x0, 0x30(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x52969
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x52974
movq %r13, 0x30(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x529db
movq %r13, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x529e6
movq %rsp, %rdi
movq %r15, %rdx
callq 0x3cd1a
movq $0x0, 0x30(%rsp)
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x5299b
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x529a6
movq %rbp, %rdi
movq %r15, %rdx
callq 0x3cd1a
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x52a10
movq (%rsp), %rdx
movsd (%rdx,%r12,8), %xmm0
movq %r12, %rsi
addsd (%rax,%rsi,8), %xmm0
movsd %xmm0, (%rdx,%r12,8)
incq %rsi
cmpq %rsi, %rcx
ja 0x529c6
jmp 0x52a10
movq %rsp, %rdi
movq %r15, %rdx
callq 0x3cd1a
movq %r13, 0x30(%rsp)
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x52a05
movq %r13, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x52a10
movq %rbp, %rdi
movq %r15, %rdx
callq 0x3cd1a
movq 0x8(%r14), %rax
subq (%r14), %rax
leaq 0x1(%r12), %rcx
sarq $0x3, %rax
cmpq %r12, %rax
movq %rcx, %r12
ja 0x5291a
cmpl $0x0, 0x2c(%rsp)
jle 0x52bf3
movsd 0x7ec9(%rip), %xmm0     # 0x5a908
ucomisd 0x60(%rsp), %xmm0
jbe 0x52bf3
cvtsi2sdl 0x20(%rsp), %xmm1
movl %ebx, %r15d
cvtsi2sd %r15, %xmm2
movsd 0x38(%rsp), %xmm0
movsd %xmm2, 0x70(%rsp)
mulsd %xmm2, %xmm0
movsd %xmm0, 0x38(%rsp)
leal 0x1(%rbx), %eax
cmpl $0x3, %eax
movl $0x2, %r12d
cmovael %eax, %r12d
xorl %r13d, %r13d
movsd %xmm1, 0x68(%rsp)
xorpd %xmm3, %xmm3
testl %ebx, %ebx
je 0x52ac1
movl $0x1, %ebp
movsd %xmm3, 0x20(%rsp)
movl %ebp, %eax
movq (%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
callq 0x7610
movsd 0x20(%rsp), %xmm3
movsd 0x68(%rsp), %xmm1
addsd %xmm0, %xmm3
incl %ebp
cmpl %ebx, %ebp
jbe 0x52a95
cmpl $0x2, %ebx
jb 0x52b6a
movsd 0x70(%rsp), %xmm0
subsd %xmm3, %xmm0
xorpd 0x6794(%rip), %xmm0     # 0x59270
movapd %xmm0, 0x80(%rsp)
movl $0x1, %ebp
movq (%rsp), %rax
movsd (%rax,%rbp,8), %xmm0
movsd %xmm0, 0x20(%rsp)
callq 0x7610
movsd 0x510a(%rip), %xmm4     # 0x57c10
movsd 0x38(%rsp), %xmm5
movl %ebp, %eax
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
movq (%rsp), %rax
movsd (%rax,%rbp,8), %xmm3
subsd 0x8(%rax,%rbp,8), %xmm3
subsd %xmm0, %xmm4
mulsd %xmm2, %xmm3
movsd 0x78(%rsp), %xmm2
movsd 0x68(%rsp), %xmm1
divsd %xmm5, %xmm3
mulsd 0x80(%rsp), %xmm3
addsd %xmm4, %xmm3
mulsd %xmm2, %xmm3
addsd 0x20(%rsp), %xmm3
movq 0x40(%rsp), %rax
movsd %xmm3, (%rax,%rbp,8)
leaq 0x1(%rbp), %rax
movq %rax, %rbp
cmpq %rax, %r15
jne 0x52aea
movq 0x40(%rsp), %rax
movsd (%rax), %xmm2
movq (%rsp), %rcx
subsd (%rcx), %xmm2
movapd 0x59ad(%rip), %xmm3     # 0x58530
andpd %xmm3, %xmm2
testl %ebx, %ebx
je 0x52bb0
movl $0x1, %edx
movsd (%rax,%rdx,8), %xmm0
subsd (%rcx,%rdx,8), %xmm0
andpd %xmm3, %xmm0
maxsd %xmm2, %xmm0
incq %rdx
movapd %xmm0, %xmm2
cmpq %rdx, %r12
jne 0x52b90
jmp 0x52bb4
movapd %xmm2, %xmm0
movq 0x8(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq $0x2, %rdx
jb 0x52bdd
movl $0x1, %esi
movsd (%rax,%rsi,8), %xmm2
movsd %xmm2, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rdx
jne 0x52bcb
incl %r13d
cmpl 0x2c(%rsp), %r13d
jge 0x52bf3
ucomisd 0x60(%rsp), %xmm0
ja 0x52a88
movq (%rsp), %rax
movq (%r14), %rcx
leal 0x1(%rbx), %edx
cmpl $0x1, %edx
adcl $0x1, %ebx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm0
subsd 0x8(%rax,%rdx,8), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
leaq 0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq %rsi, %rbx
jne 0x52c05
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x52c30
callq 0x7370
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x52c3e
callq 0x7370
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x52c56
jmp 0x52c56
jmp 0x52c56
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x52c68
callq 0x7370
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x52c76
callq 0x7370
movq %rbx, %rdi
callq 0x7620
nop