// File: /workspace/github_cpp_makefile_star2_O1/jamesliu516[P]amrdg2d/solveAMR.cpp
// Function: smoothcell()
void smoothcell()
{
    //	long Nac;
    int hoflag,hiflag,i,nncell;
    Node *current;//新生成的四个节点
    OctCell *pc,*parent,*pp[4];//定义4个叶子节点的地址   
    int n_smth=3;
    do
    {
        //		releaselist(0);
        //		releasecelllist(Adpcelllist);
        //创建新的链表				
        //		Nac=FormAdpCellList(cartcell,cNx,cNy);

        releaseList();
        formListForAllGrid();
     //   setFlagForAll0();
        nncell=0;
        //current=Adpcelllist;
        current = HeadListAllGrid;

        while(current!=NULL)
        {             			
            pc=current->cell;
            if(pc->flag==0 && current->flg==0){
            //if(current->flg!=6){
                hiflag=0;
                hoflag=0;
                hoflag=chargeholegrid(pc);//判断是否是hole grid
//cout<<"smooth\n";
                //if(hoflag==1){printf("hoflag=%d\n",hoflag);getchar();}
                hiflag=chargehillgrid(pc);//判断是否是hill grid
                //if(hiflag==1){printf("hiflag=%d\n",hiflag);getchar();}
                /**/			
                if(hoflag==1) 
                {
                    creat_sol_children(pc);
                  //  pc->reflag=1;
                    nncell++;
                }

                if(hiflag==1)
                {	
                    parent=pc->parent;
                    for(i=0;i<4;i++)
                    {
                        pp[i]=parent->children[i];
                        pp[i]->coflag=true;
                    }
                    creatsolcoarseparent(parent,pp);
                    parent->coflag=false;
                    parent->reflag=0;
                    nncell++;
                }
            }
            current=current->next;
        }
        //	printf("nncell=%d\n",nncell);
        cout<<"nncell= "<<nncell<<endl;
        --n_smth;
    }while(nncell>0&& n_smth>0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0x3, %r15d
callq 0xc11d
callq 0xbc5c
leaq 0xdf4c(%rip), %rax      # 0x2a610
movq (%rax), %rbx
movl $0x0, %ebp
testq %rbx, %rbx
je 0x1c76b
xorl %ebp, %ebp
movq 0x8(%rbx), %r12
cmpw $0x0, 0x1b0(%r12)
jne 0x1c75e
cmpw $0x0, (%rbx)
jne 0x1c75e
movq %r12, %rdi
callq 0x1c574
movl %eax, %r14d
movq %r12, %rdi
callq 0x1c5f9
movl %eax, %r13d
testl %r14d, %r14d
je 0x1c712
movq %r12, %rdi
callq 0x1b9bf
incl %ebp
testl %r13d, %r13d
je 0x1c75e
movq 0x250(%r12), %r12
xorl %eax, %eax
movq 0x258(%r12,%rax,8), %rcx
movq %rcx, (%rsp,%rax,8)
movb $0x1, 0x1fe(%rcx)
incq %rax
cmpq $0x4, %rax
jne 0x1c721
movq %r12, %rdi
movq %rsp, %rsi
callq 0x1c12a
movb $0x0, 0x1fe(%r12)
movw $0x0, 0x1fc(%r12)
incl %ebp
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0x1c6d7
movl $0x8, %edx
movq 0x8851(%rip), %rbx      # 0x24fc8
movq %rbx, %rdi
leaq 0x260b(%rip), %rsi      # 0x1ed8c
callq 0x3250
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3350
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3170
testl %ebp, %ebp
jle 0x1c7cf
leal -0x1(%r15), %eax
cmpl $0x1, %r15d
movl %eax, %r15d
ja 0x1c6b3
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq