// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/FitBitSt.cpp
// Function: FitBitSt::FitBitSt(task*, double*, double*, int)
FitBitSt::FitBitSt(struct task *task, NUMBER* a_PARAM, NUMBER* a_GRAD, NCAT a_nPARAM) {
    this->nS = task->nS;
    this->nO = task->nO;
    this->nG = task->nG;
    this->nK = task->nK;
    this->tol = task->tol;
    this->tol_mode = task->tol_mode;
    this->nPARAM = a_nPARAM;
    this->PARAM = a_PARAM;
    this->PARAMm1 = NULL;
    this->PARAMm2 = NULL;
    this->GRAD = a_GRAD;
    this->GRADm1 = NULL;
    this->GRADcopy = NULL;
    this->PARAMcopy = NULL;
    this->DIR = NULL;
    this->DIRm1 = NULL;
    this->task = task;
    this->projecttosimplex = 1;
    this->Cslice = 0;
    this->tag = 0;
    
    this->fit_results = new FitResult[this->nK];
    for(NCAT k=0; k<this->nK; k++) {
        this->fit_results[k].iter = 0;
        this->fit_results[k].pO0_prefit = -1.0; // means never assigned
        this->fit_results[k].pO0  = 0.0;
        this->fit_results[k].pO   = 0.0;
        this->fit_results[k].conv = 0;
        this->fit_results[k].ndat = 0;
    }
    this->fit_result.iter = 0;
    this->fit_result.pO0_prefit = -1.0; // means never assigned
    this->fit_result.pO0  = 0.0;
    this->fit_result.pO   = 0.0;
    this->fit_result.conv = 0;
    this->fit_result.ndat = 0;

    this->sclsmplx_offsets = NULL;// start positions of the scaled vectors in the gradient and parameter arrays
    this->sclsmplx_sizes = NULL;// lengths of the scaled vectorsin the gradient and parameter arrays
    this->sclsmplx_bound_offsets = NULL;
    this->sclsmplx_blocks = NULL;
    this->param_blocks = NULL;
    this->sclsmplx_n = 0;

    this->PARAMm1 = init1D<NUMBER>(this->nPARAM);
    this->PARAMm2 = init1D<NUMBER>(this->nPARAM);
    
    if(this->task->solver==METHOD_GD || this->task->solver==METHOD_CGD || this->task->solver==METHOD_GBB || this->task->solver==METHOD_GDL) {
        toValue1D<NUMBER>(this->GRAD, this->nPARAM, 0); // init1D<NUMBER>(this->nPARAM);
    }
    if(this->task->solver==METHOD_CGD) {
        this->DIR = init1D<NUMBER>(this->nPARAM);
        this->DIRm1 = init1D<NUMBER>(this->nPARAM);
        this->GRADm1 = init1D<NUMBER>(this->nPARAM);
    }
    if(this->task->solver==METHOD_GBB) {
        this->GRADm1 = init1D<NUMBER>(this->nPARAM);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %r8d, %ebp
movq %rcx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movb 0x900(%rsi), %al
movb %al, 0x1(%rdi)
movb 0x901(%rsi), %al
movb %al, (%rdi)
movl 0x904(%rsi), %eax
movl %eax, 0x4(%rdi)
movslq 0x908(%rsi), %r12
movl %r12d, 0x8(%rdi)
movsd 0x38(%rsi), %xmm0
movsd %xmm0, 0xc8(%rdi)
movb 0x40(%rsi), %al
movb %al, 0xd0(%rdi)
movl %r8d, 0xc(%rdi)
movq %rdx, 0x10(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rdi)
movq %rcx, 0x30(%rdi)
movq $0x0, 0x28(%rdi)
movups %xmm0, 0x38(%rdi)
movups %xmm0, 0x48(%rdi)
movq %rsi, 0x88(%rdi)
movw $0x1, 0x90(%rdi)
movb $0x0, 0x92(%rdi)
movl $0x28, %ecx
movq %r12, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x2030
xorps %xmm0, %xmm0
movq %rax, 0x58(%rbx)
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
testq %r12, %r12
jle 0x7acd
shlq $0x3, %r12
leaq (%r12,%r12,4), %rdx
xorl %esi, %esi
xorl %edi, %edi
movl %esi, (%rax,%rdi)
movq %rcx, 0x8(%rax,%rdi)
movl %esi, 0x24(%rax,%rdi)
movups %xmm0, 0x10(%rax,%rdi)
movb $0x0, 0x20(%rax,%rdi)
addq $0x28, %rdi
cmpq %rdi, %rdx
jne 0x7aae
xorl %eax, %eax
movl %eax, 0x60(%rbx)
movq %rcx, 0x68(%rbx)
movl %eax, 0x84(%rbx)
movslq %ebp, %r12
movl $0x8, %esi
movq %r12, %rdi
callq 0x2110
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbx)
movb $0x0, 0x80(%rbx)
movups %xmm0, 0x98(%rbx)
movups %xmm0, 0xa8(%rbx)
movups %xmm0, 0xb4(%rbx)
movq %rax, 0x18(%rbx)
movl $0x8, %esi
movq %r12, %rdi
callq 0x2110
movq %rax, 0x20(%rbx)
movzbl 0x4f(%r15), %r15d
leal -0x2(%r15), %eax
cmpb $0x4, %al
setb %al
testl %ebp, %ebp
setg %cl
testb %al, %cl
je 0x7b4b
movl %ebp, %edx
shlq $0x3, %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2100
cmpl $0x5, %r15d
je 0x7b79
cmpl $0x3, %r15d
jne 0x7b8d
movl $0x8, %esi
movq %r12, %rdi
callq 0x2110
movq %rax, 0x48(%rbx)
movl $0x8, %esi
movq %r12, %rdi
callq 0x2110
movq %rax, 0x50(%rbx)
addq $0x38, %rbx
movl $0x8, %esi
movq %r12, %rdi
callq 0x2110
movq %rax, (%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq