// File: /workspace/github_cpp_makefile_star2_O3/BhanuPrakashN[P]sparse_chol/smatrix.cpp
// Function: sm_chol(smatrix*, etree*, std::map<int, std::vector<int, std::allocator<int>>*, std::less<int>, std::allocator<std::pair<int const, std::vector<int, std::allocator<int>>*>>>*)
sm *sm_chol(sm *A,et *e,map<int,vector<int>* > * cs){
    sm *L=smalloc (0, 0, 1, 1, 1);
    double l_jj,*l_b;
    int n,c;
    n=A->n;
    vector<int> *temp,*chl;
    Fm *F,*Um;
    map<int,Fm*> *U=new map<int,Fm*>;
    for(int j=0;j<n;j++){
        temp=cs->at(j);
        F=fmalloc(temp->size(),temp);
        fconstruct(F,A,j);
        //printf("\n Frontal[%d]\n",j);
        //for(int k=0;k<F->n;k++)printf("%d ",temp->at(k));
        
        chl=e->chl->at(j);
        for(int k=0;k<chl->size();k++){
            c=chl->at(k);
            Fupdate(F,U->at(c));
            U->erase(c);
        }
        //printFm(F);
        l_b=(double*)malloc(((F->n)-1)*sizeof(double));
        l_jj=sqrt(F->x[0][0]);
        sm_insert (L,  j,  j, l_jj);

        //printf("%g\n",*l_jj);
        for(int k=1;k<F->n;k++){
            l_b[k-1]=F->x[0][k]/(l_jj);
            sm_insert (L,  F->indices->at(k),  j, l_b[k-1]);
            //printf("%g\n",l_b[k-1]);
        }

        if(e->par[j] != -1){
            Um=UpdateF(F,l_b,cs->at(e->par[j]));
            // printf("\n Update[%d]\n",j);
            //printFm(Um);
           
            U->insert(pair<int,Fm*>(j,Um));
        }

    }
    L=TripletToCC(L);
    return L;



}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, -0x48(%rbp)
movq %rsi, %r14
movq %rdi, %r15
xorl %ebx, %ebx
xorl %edi, %edi
xorl %esi, %esi
movl $0x1, %edx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x1763
movq %rax, -0x38(%rbp)
movq %r15, -0x68(%rbp)
movl 0x8(%r15), %r15d
movl $0x30, %edi
callq 0x1100
movq %rax, %r13
addq $0x8, %rax
movl %ebx, 0x8(%r13)
movq %rbx, 0x10(%r13)
movq %rax, 0x18(%r13)
movq %rax, 0x20(%r13)
movq %rbx, 0x28(%r13)
movl %ebx, -0x2c(%rbp)
movl %r15d, -0x3c(%rbp)
testl %r15d, %r15d
jle 0x24fb
leaq -0x30(%rbp), %r15
movq %r14, -0x60(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x2c(%rbp), %rbx
movq %rbx, %rsi
callq 0x15f8
movq (%rax), %rsi
movq 0x8(%rsi), %rdi
subq (%rsi), %rdi
shrq $0x2, %rdi
callq 0x1e30
movq %rax, %r12
movl -0x2c(%rbp), %edx
movq %rax, %rdi
movq -0x68(%rbp), %rsi
callq 0x1ea5
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x15f8
movq (%rax), %rbx
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x23f9
xorl %r14d, %r14d
movl (%rax,%r14,4), %eax
movl %eax, -0x30(%rbp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x2524
movq (%rax), %rsi
movq %r12, %rdi
callq 0x202f
movq %r13, %rdi
movq %r15, %rsi
callq 0x2b4e
movq %r13, %rdi
movq %rax, %rsi
callq 0x2bd0
incq %r14
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x23b0
movslq (%r12), %r15
leaq -0x8(,%r15,8), %rdi
callq 0x1150
movq %rax, -0x58(%rbp)
movq 0x10(%r12), %rbx
movq (%rbx), %rax
movsd (%rax), %xmm0
ucomisd 0xcce(%rip), %xmm0      # 0x30f0
movq %r12, -0x50(%rbp)
jb 0x242e
sqrtsd %xmm0, %xmm0
jmp 0x2433
callq 0x10d0
movl -0x2c(%rbp), %edx
movq -0x38(%rbp), %rdi
movl %edx, %esi
movsd %xmm0, -0x70(%rbp)
callq 0x1644
cmpl $0x2, %r15d
jl 0x24a2
movq -0x50(%rbp), %rax
movq 0x8(%rax), %r14
movl $0x1, %r12d
movq (%rbx), %rax
movsd (%rax,%r12,8), %xmm0
divsd -0x70(%rbp), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, -0x8(%rax,%r12,8)
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0x2513
movl (%rax,%r12,4), %esi
movl -0x2c(%rbp), %edx
movq -0x38(%rbp), %rdi
callq 0x1644
incq %r12
cmpq %r12, %r15
jne 0x245a
movq -0x60(%rbp), %r14
movq (%r14), %rcx
movslq -0x2c(%rbp), %rax
cmpl $-0x1, (%rcx,%rax,4)
je 0x24e9
leaq (%rcx,%rax,4), %rsi
movq -0x48(%rbp), %rdi
callq 0x15f8
movq (%rax), %rdx
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x20b1
movl -0x2c(%rbp), %ecx
movl %ecx, -0x80(%rbp)
movq %rax, -0x78(%rbp)
movq %r13, %rdi
leaq -0x80(%rbp), %rsi
callq 0x2cca
movl -0x2c(%rbp), %eax
leaq -0x30(%rbp), %r15
incl %eax
movl %eax, -0x2c(%rbp)
cmpl -0x3c(%rbp), %eax
jl 0x2360
movq -0x38(%rbp), %rdi
callq 0x197b
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb4f(%rip), %rdi       # 0x3069
movq %r12, %rsi
xorl %eax, %eax
callq 0x1190