// File: PeterDenton[P]Nu-Pert/src/Progress.cpp
// Function: Progress_Bar::update(double)
void Progress_Bar::update(double _progress)
{
	if (not Progress_Bar_visible)
		return;
	if (std::abs(_progress - progress) < 0.009 and _progress < 1)
		return;

	progress = _progress;
	elapsed_time = time(NULL) - start_time;
	remaining_time = elapsed_time * (1. - progress) / progress;

	if (Progress_Bar_statistics and fmod(elapsed_time, 5) == 0)
	{
		if (N_stats < 100)
		{
			times[0][N_stats] = elapsed_time;
			times[1][N_stats] = remaining_time;
			N_stats++;
		}
	}

	std::cerr << "  " << int(progress * 100.) << " % [";
	int position = bar_width * progress;
	for (int i = 0; i < bar_width; ++i)
	{
		if (i < position)
			std::cerr << "=";
		else if (i == position)
			std::cerr << ">";
		else
			std::cerr << " ";
	}
	std::cerr << "] ";
	if (progress > 0.15 or elapsed_time > 10)
		std::cerr << int(remaining_time) << "   ";
	std::cerr << "\r";
	std::cerr.flush();
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
testb $0x1, 0x7c33(%rip)      # 0x17233
jne 0xf607
jmp 0xf85e
movq 0x8(%rsp), %rax
movsd 0x18(%rsp), %xmm0
subsd 0x10(%rax), %xmm0
callq 0x7490
movaps %xmm0, %xmm1
movsd 0x3521(%rip), %xmm0     # 0x12b48
ucomisd %xmm1, %xmm0
jbe 0xf642
movsd 0x29e3(%rip), %xmm0     # 0x12018
ucomisd 0x18(%rsp), %xmm0
jbe 0xf642
jmp 0xf85e
movq 0x8(%rsp), %rax
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x2130
movq %rax, %rcx
movq 0x8(%rsp), %rax
cvtsi2sd %rcx, %xmm0
subsd 0x18(%rax), %xmm0
movsd %xmm0, 0x20(%rax)
movsd 0x20(%rax), %xmm0
movsd 0x2999(%rip), %xmm1     # 0x12018
subsd 0x10(%rax), %xmm1
mulsd %xmm1, %xmm0
divsd 0x10(%rax), %xmm0
movsd %xmm0, 0x28(%rax)
testb $0x1, 0x7b9b(%rip)      # 0x17234
je 0xf708
movq 0x8(%rsp), %rax
movsd 0x20(%rax), %xmm0
movsd 0x2dc3(%rip), %xmm1     # 0x12470
callq 0x21e0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xf708
jp 0xf708
movq 0x8(%rsp), %rax
cmpl $0x64, 0x670(%rax)
jge 0xf706
movq 0x8(%rsp), %rax
movsd 0x20(%rax), %xmm0
movslq 0x670(%rax), %rcx
movsd %xmm0, 0x30(%rax,%rcx,8)
movsd 0x28(%rax), %xmm0
movslq 0x670(%rax), %rcx
movsd %xmm0, 0x350(%rax,%rcx,8)
movl 0x670(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x670(%rax)
jmp 0xf708
movq 0x78e1(%rip), %rdi      # 0x16ff0
leaq 0x347f(%rip), %rsi      # 0x12b95
callq 0x2160
movq %rax, %rdi
movq 0x8(%rsp), %rax
movsd 0x3425(%rip), %xmm0     # 0x12b50
mulsd 0x10(%rax), %xmm0
cvttsd2si %xmm0, %esi
callq 0x2290
movq %rax, %rdi
leaq 0x3447(%rip), %rsi      # 0x12b8a
callq 0x2160
movq 0x8(%rsp), %rax
cvtsi2sdl 0x8(%rax), %xmm0
mulsd 0x10(%rax), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movl 0x10(%rsp), %eax
cmpl 0x8(%rcx), %eax
jge 0xf7d7
movl 0x10(%rsp), %eax
cmpl 0x14(%rsp), %eax
jge 0xf794
movq 0x786a(%rip), %rdi      # 0x16ff0
leaq 0x3402(%rip), %rsi      # 0x12b8f
callq 0x2160
jmp 0xf7c8
movl 0x10(%rsp), %eax
cmpl 0x14(%rsp), %eax
jne 0xf7b3
movq 0x784b(%rip), %rdi      # 0x16ff0
leaq 0x3513(%rip), %rsi      # 0x12cbf
callq 0x2160
jmp 0xf7c6
movq 0x7836(%rip), %rdi      # 0x16ff0
leaq 0x33d5(%rip), %rsi      # 0x12b96
callq 0x2160
jmp 0xf7c8
jmp 0xf7ca
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0xf767
movq 0x7812(%rip), %rdi      # 0x16ff0
leaq 0x33ac(%rip), %rsi      # 0x12b91
callq 0x2160
movq 0x8(%rsp), %rax
movsd 0x10(%rax), %xmm0
movsd 0x335c(%rip), %xmm1     # 0x12b58
ucomisd %xmm1, %xmm0
ja 0xf81a
movq 0x8(%rsp), %rax
movsd 0x20(%rax), %xmm0
movsd 0x334c(%rip), %xmm1     # 0x12b60
ucomisd %xmm1, %xmm0
jbe 0xf83f
movq 0x8(%rsp), %rax
cvttsd2si 0x28(%rax), %esi
movq 0x77c5(%rip), %rdi      # 0x16ff0
callq 0x2290
movq %rax, %rdi
leaq 0x335a(%rip), %rsi      # 0x12b94
callq 0x2160
movq 0x77aa(%rip), %rdi      # 0x16ff0
leaq 0x334b(%rip), %rsi      # 0x12b98
callq 0x2160
movq 0x7797(%rip), %rdi      # 0x16ff0
callq 0x20e0
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)