// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/tuning.cpp
// Function: VarTuning::VarTuning(int, ...)
VarTuning::VarTuning(int s, ...) {
	
	for (int k = abs(rand() % 10000); k > 0; --k) {
		rkiss.rand<unsigned>();
	}
	
	updateCount = 0;
	size = s;
	
	assert(size >= 0 && size < 100);
	
	va_list vl;
	va_start(vl, s);
	for (int k = 0; k < size; ++k) {
		var[k].valueptr = (tune_t*)va_arg(vl, double*);
		var[k].value = *var[k].valueptr;
		var[k].startvalue = *var[k].valueptr;
		var[k].deltaAxisFactor = DELTA_AXIS_FACTOR;
		var[k].sdevSum = 0.0;
		var[k].varSum = 0.0;
		var[k].applyFactor = APPLY_FACTOR;
		memset(var[k].history, 0, sizeof(tune_t) * TUNE_HISTORY_SIZE);
		var[k].historyIndex = 0;
	}
	va_end(vl);
	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x2a58b
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movabsq $0x46dd577ff603b540, %rax # imm = 0x46DD577FF603B540
movq %rax, 0x29cc8(%rdi)
movabsq $-0x3bf8842205306785, %rax # imm = 0xC4077BDDFACF987B
movq %rax, 0x29cd0(%rdi)
movabsq $-0x440b26c48dff17a8, %rax # imm = 0xBBF4D93B7200E858
movq %rax, 0x29cd8(%rdi)
movabsq $-0x2c1f8a302bb644e2, %rax # imm = 0xD3E075CFD449BB1E
movq %rax, 0x29ce0(%rdi)
callq 0x5100
movslq %eax, %r8
imulq $0x68db8bad, %r8, %rax  # imm = 0x68DB8BAD
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x2c, %rax
addl %ecx, %eax
imull $0x2710, %eax, %eax     # imm = 0x2710
subl %eax, %r8d
je 0x2a670
movq 0x29ce0(%rbx), %rax
movq 0x29cd8(%rbx), %rcx
movq 0x29cc8(%rbx), %rsi
movq 0x29cd0(%rbx), %rdx
movl %r8d, %edi
negl %edi
cmpl %edi, %r8d
cmovgl %r8d, %edi
incl %edi
movq %rdx, %r8
rolq $0x7, %r8
movq %rsi, %r9
movq %rcx, %rsi
rolq $0xd, %rsi
xorq %rdx, %rsi
movq %rax, %rdx
rolq $0x25, %rdx
subq %r8, %r9
addq %rcx, %rdx
movq %rax, %rcx
addq %r9, %rcx
movq %r9, %rax
addq %rsi, %rax
decl %edi
cmpl $0x1, %edi
ja 0x2a620
movq %rsi, 0x29cc8(%rbx)
movq %rdx, 0x29cd0(%rbx)
movq %rcx, 0x29cd8(%rbx)
movq %rax, 0x29ce0(%rbx)
movl $0x0, 0x29cc4(%rbx)
movl %ebp, 0x29cc0(%rbx)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movslq 0x29cc0(%rbx), %rcx
testq %rcx, %rcx
jle 0x2a74a
movl (%rsp), %ebp
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rax
imulq $0x6b0, %rcx, %r12      # imm = 0x6B0
xorl %r13d, %r13d
cmpl $0x28, %ebp
ja 0x2a6e8
movq %rax, %r15
movl %ebp, %eax
addq 0x18(%rsp), %rax
addl $0x8, %ebp
movl %ebp, (%rsp)
jmp 0x2a6f1
leaq 0x8(%rax), %r15
movq %r15, 0x8(%rsp)
movq (%rax), %rax
leaq (%rbx,%r13), %r14
addq $0x68, %r14
movq %rax, -0x68(%r14)
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%r14)
movsd %xmm0, -0x58(%r14)
xorps %xmm0, %xmm0
movups %xmm0, -0x28(%r14)
movaps 0x9761(%rip), %xmm0     # 0x33e80
movups %xmm0, -0x40(%r14)
movl $0x640, %edx            # imm = 0x640
movq %r14, %rdi
xorl %esi, %esi
callq 0x5210
movl $0x0, -0x8(%r14)
addq $0x6b0, %r13            # imm = 0x6B0
movq %r15, %rax
cmpq %r13, %r12
jne 0x2a6d1
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq