// File: /workspace/github_cpp_makefile_star2_O3/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 0xbfa2
callq 0xbae8
leaq 0xd458(%rip), %rax      # 0x29610
movq (%rax), %rbx
movl $0x0, %ebp
testq %rbx, %rbx
je 0x1c25f
xorl %ebp, %ebp
movq 0x8(%rbx), %r12
cmpw $0x0, 0x1b0(%r12)
jne 0x1c252
cmpw $0x0, (%rbx)
jne 0x1c252
movq %r12, %rdi
callq 0x1c068
movl %eax, %r14d
movq %r12, %rdi
callq 0x1c0ed
movl %eax, %r13d
testl %r14d, %r14d
je 0x1c206
movq %r12, %rdi
callq 0x1b4a1
incl %ebp
testl %r13d, %r13d
je 0x1c252
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 0x1c215
movq %r12, %rdi
movq %rsp, %rsi
callq 0x1bc1e
movb $0x0, 0x1fe(%r12)
movw $0x0, 0x1fc(%r12)
incl %ebp
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0x1c1cb
movl $0x8, %edx
movq 0x7d5d(%rip), %rbx      # 0x23fc8
movq %rbx, %rdi
leaq 0x1b1f(%rip), %rsi      # 0x1dd94
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 0x1c2c3
leal -0x1(%r15), %eax
cmpl $0x1, %r15d
movl %eax, %r15d
ja 0x1c1a7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq