// File: /workspace/github_cpp_makefile_star2_O3/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 0x2476b(%rip), %rax     # 0x29610
movq (%rax), %rbp
testq %rbp, %rbp
je 0x5005
leaq 0x1f348(%rip), %r12     # 0x24200
leaq 0x1f4c1(%rip), %rbx     # 0x24380
movq 0x8(%rbp), %r14
movsd 0x278(%r14), %xmm0
movsd 0x280(%r14), %xmm1
movl (%r12), %edi
movq %rbx, %rsi
callq 0xa6f2
testl %eax, %eax
je 0x4fca
cmpl $-0x1, %eax
jne 0x4fd1
movq %r14, %rdi
callq 0x8db8
movq %rax, %r15
movq %r14, %rdi
callq 0x8d37
movq %rax, %r12
movq %r14, %rdi
callq 0x8cb4
movq %rax, %r13
movq %r14, %rdi
callq 0x8c30
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 0x1f2a7(%rip), %r12     # 0x24200
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 0xa6f2
testl %eax, %eax
je 0x4fdc
incq %r15
cmpq $0x4, %r15
jne 0x4f9c
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x4fe8
xorl %ecx, %ecx
movl %eax, %r15d
jmp 0x4ff0
testl %r15d, %r15d
je 0x4fee
cmpl $0x2, %r15d
jne 0x4fe8
movl $0x2, %r15d
movw $0x2, %cx
jmp 0x4ff0
movw $0xffff, %cx            # imm = 0xFFFF
jmp 0x4ff0
xorl %ecx, %ecx
movw %cx, 0x1b0(%r14)
movq 0x10(%rbp), %rbp
testq %rbp, %rbp
jne 0x4ebf
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq