// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
movl %r8d, %ebp
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), %r14
movl %r14d, 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)
andq $0x0, 0x28(%rdi)
movups %xmm0, 0x38(%rdi)
movups %xmm0, 0x48(%rdi)
movq %rsi, 0x88(%rdi)
movw $0x1, 0x90(%rdi)
movb $0x0, 0x92(%rdi)
pushq $0x28
popq %rcx
movq %r14, %rax
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
callq 0x3030
xorps %xmm0, %xmm0
movq %rax, 0x58(%rbx)
xorl %ecx, %ecx
testl %r14d, %r14d
movl $0x0, %edx
cmovgl %r14d, %edx
imulq $0x28, %rdx, %rsi
movabsq $-0x4010000000000000, %rdx # imm = 0xBFF0000000000000
cmpq %rcx, %rsi
je 0x6f77
andl $0x0, (%rax,%rcx)
movq %rdx, 0x8(%rax,%rcx)
andl $0x0, 0x24(%rax,%rcx)
movups %xmm0, 0x10(%rax,%rcx)
movb $0x0, 0x20(%rax,%rcx)
addq $0x28, %rcx
jmp 0x6f54
andl $0x0, 0x60(%rbx)
movq %rdx, 0x68(%rbx)
andl $0x0, 0x84(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbx)
movb $0x0, 0x80(%rbx)
movups %xmm0, 0x98(%rbx)
movups %xmm0, 0xa8(%rbx)
movups %xmm0, 0xb4(%rbx)
movl %ebp, %edi
callq 0x6a57
movq %rax, 0x18(%rbx)
movl 0xc(%rbx), %edi
callq 0x6a57
movq %rax, 0x20(%rbx)
movq 0x88(%rbx), %rax
movb 0x4f(%rax), %al
addb $-0x2, %al
cmpb $0x4, %al
jae 0x702b
movq 0x30(%rbx), %rdi
movl 0xc(%rbx), %esi
xorps %xmm0, %xmm0
callq 0x75fe
movq 0x88(%rbx), %rax
movb 0x4f(%rax), %al
cmpb $0x3, %al
jne 0x701b
movl 0xc(%rbx), %edi
callq 0x6a57
movq %rax, 0x48(%rbx)
movl 0xc(%rbx), %edi
callq 0x6a57
movq %rax, 0x50(%rbx)
movl 0xc(%rbx), %edi
callq 0x6a57
movq %rax, 0x38(%rbx)
movq 0x88(%rbx), %rax
movb 0x4f(%rax), %al
cmpb $0x5, %al
jne 0x702b
movl 0xc(%rbx), %edi
callq 0x6a57
movq %rax, 0x38(%rbx)
popq %rbx
popq %r14
popq %rbp
retq