// File: /workspace/github_cpp_makefile_star2_O2/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 0x237fb(%rip), %rax     # 0x28610
movq (%rax), %rbp
leaq 0x1e3e1(%rip), %r12     # 0x23200
leaq 0x1e55a(%rip), %rbx     # 0x23380
testq %rbp, %rbp
je 0x4f71
movq 0x8(%rbp), %r14
movsd 0x278(%r14), %xmm0
movsd 0x280(%r14), %xmm1
movl (%r12), %edi
movq %rbx, %rsi
callq 0x9c67
testl %eax, %eax
je 0x4f34
cmpl $-0x1, %eax
jne 0x4f3b
movq %r14, %rdi
callq 0x8610
movq %rax, %r15
movq %r14, %rdi
callq 0x858f
movq %rax, %r12
movq %r14, %rdi
callq 0x850c
movq %rax, %r13
movq %r14, %rdi
callq 0x8488
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 0x1e337(%rip), %r12     # 0x23200
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
cmpq $0x4, %r15
je 0x4f4e
movsd 0x20(%rsp,%r15,8), %xmm0
movsd (%rsp,%r15,8), %xmm1
movl (%r12), %edi
movq %rbx, %rsi
callq 0x9c67
incq %r15
testl %eax, %eax
jne 0x4f0c
jmp 0x4f46
xorl %ecx, %ecx
movl %eax, %r15d
jmp 0x4f56
testl %r15d, %r15d
je 0x4f67
cmpl $0x2, %r15d
jne 0x4f6b
movw $0x2, %cx
pushq $0x2
jmp 0x4f54
movw $0xffff, %cx            # imm = 0xFFFF
pushq $-0x1
popq %r15
movw %cx, 0x1b0(%r14)
movq 0x10(%rbp), %rbp
jmp 0x4e26
xorl %ecx, %ecx
jmp 0x4f56
movw $0xffff, %cx            # imm = 0xFFFF
jmp 0x4f56
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq