// File: /workspace/github_cpp_makefile_star2_O1/jamesliu516[P]amrdg2d/setflag.cpp
// Function: setFlagForAll()
void setFlagForAll()
{
    Node *current;
    OctCell *lsbl;
    OctCell *lss;
    OctCell *lse;
    OctCell *lsw;
    OctCell *lsn;
    double x1,y1;
    int value, flg[N_BODY+1];

    current = HeadListAllGrid;

    double xcn[4],ycn[4];
    int flgn[4], sflg;	
    int i;
    int n0,n2,nm;

    while(current != NULL)
    {
        lsbl = current->cell;

        x1=lsbl->xc1;
        y1=lsbl->yc1;

        for (int jj=0; jj<N_BODY;++jj){
            value = newFlagpoint(x1,y1,NWallPts[jj], MultiCircle[jj]);
            if(value==0) {
                flg[jj]=value;
            }
            else if(value==-1) {
                lss=SouthNeighbor(lsbl);
                lse=EastNeighbor(lsbl);
                lsw=WestNeighbor(lsbl);
                lsn=NorthNeighbor(lsbl);
                xcn[0]=lss->xc1;
                ycn[0]=lss->yc1;
                xcn[1]=lse->xc1;
                ycn[1]=lse->yc1;	
                xcn[2]=lsn->xc1;
                ycn[2]=lsn->yc1;
                xcn[3]=lsw->xc1;
                ycn[3]=lsw->yc1;	        
                sflg=0;
                for(i=0; i<4; ++i) {      
                    flgn[i]=newFlagpoint(xcn[i],ycn[i],NWallPts[jj], MultiCircle[jj]);

                    if(flgn[i]==0) {
                        flg[jj]=2;
                        ++sflg;
                        break;
                    }
                }  

                if(sflg==0) flg[jj]=-1;       
            }		       
        }
        n0=n2=nm=0;

        for (int jj=0; jj<N_BODY;++jj){
            if(flg[jj]==0) ++n0;
            if(flg[jj]==2) ++n2;
            if(flg[jj]==-1) ++nm;
        }

        if(n0==N_BODY) lsbl->flag=0;
        else if(n2>0) lsbl->flag=2;
        else lsbl->flag=-1;
        current=current->next;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
leaq 0x256ab(%rip), %rax     # 0x2a610
movq (%rax), %rbp
testq %rbp, %rbp
je 0x50be
leaq 0x20288(%rip), %r12     # 0x25200
leaq 0x20401(%rip), %rbx     # 0x25380
movq 0x8(%rbp), %r14
movsd 0x278(%r14), %xmm0
movsd 0x280(%r14), %xmm1
movl (%r12), %edi
movq %rbx, %rsi
callq 0xa82f
cmpl $-0x1, %eax
je 0x4fb6
testl %eax, %eax
jne 0x5094
xorl %r15d, %r15d
jmp 0x5094
movq %r14, %rdi
callq 0x8f00
movq %rax, %r15
movq %r14, %rdi
callq 0x8e7f
movq %rax, %r12
movq %r14, %rdi
callq 0x8dfc
movq %rax, %r13
movq %r14, %rdi
callq 0x8d78
movsd 0x278(%r15), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x280(%r15), %xmm0
movsd %xmm0, (%rsp)
movsd 0x278(%r12), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x280(%r12), %xmm0
leaq 0x201e3(%rip), %r12     # 0x25200
movsd %xmm0, 0x8(%rsp)
movsd 0x278(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x280(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x278(%r13), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x280(%r13), %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %r15d, %r15d
movsd 0x20(%rsp,%r15,8), %xmm0
movsd (%rsp,%r15,8), %xmm1
movl (%r12), %edi
movq %rbx, %rsi
callq 0xa82f
testl %eax, %eax
je 0x508e
incq %r15
cmpq $0x4, %r15
jne 0x5060
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x5094
movl $0x2, %r15d
xorl %eax, %eax
cmpl $0x2, %r15d
sete %al
leal (%rax,%rax,2), %eax
decl %eax
testl %r15d, %r15d
cmovel %r15d, %eax
movw %ax, 0x1b0(%r14)
movq 0x10(%rbp), %rbp
testq %rbp, %rbp
jne 0x4f7f
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq