// File: jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: getGridIndex3(bodygridclass*, pointxy const*, bodygridclass*&)
void getGridIndex3(OctCell *parent00, const PXYZ *p_sm, ptrOctCell &pcell)
{
 //  OctCell *pp[8]={NULL};
 
  // find_sol_refp(pp,bodygrid+parent->NOparent);

    OctCell *pp[48]={NULL}, *parent; 
    parent=bodygrid+parent00->NOparent;
    pp[0]=EastNeighbor(parent);
    pp[1]=NorthNeighbor(pp[0]);
    pp[2]=NorthNeighbor(parent);
    pp[3]=WestNeighbor(pp[2]);
    pp[4]=WestNeighbor(parent);
    pp[5]=SouthNeighbor(pp[4]);
    pp[6]=SouthNeighbor(parent);
    pp[7]=EastNeighbor(pp[6]);

    pp[8]=NorthNeighbor(pp[1]);

    pp[9]=WestNeighbor(pp[8]);
    pp[10]=WestNeighbor(pp[9]);
    pp[11]=WestNeighbor(pp[10]);
    pp[12]=WestNeighbor(pp[3]);
    pp[13]=WestNeighbor(pp[4]);
    pp[14]=WestNeighbor(pp[5]);
    pp[15]=SouthNeighbor(pp[14]);
    pp[16]=EastNeighbor(pp[15]);
    pp[17]=EastNeighbor(pp[16]);
    pp[18]=EastNeighbor(pp[17]);
    pp[19]=EastNeighbor(pp[18]);
    pp[20]=NorthNeighbor(pp[19]);
    pp[21]=NorthNeighbor(pp[20]);
    pp[22]=NorthNeighbor(pp[21]);
    pp[23]=NorthNeighbor(pp[22]);
    //================
    pp[24]= NorthNeighbor(pp[23]);
    pp[25]=WestNeighbor(pp[24]);
    pp[26]=WestNeighbor(pp[25]);
    pp[27]=WestNeighbor(pp[26]);  
    pp[28]=WestNeighbor(pp[27]);  
    pp[29]=WestNeighbor(pp[28]);    

    pp[30]=WestNeighbor(pp[11]);
    pp[31]=WestNeighbor(pp[12]);
    pp[32]=WestNeighbor(pp[13]);  
    pp[33]=WestNeighbor(pp[14]);  
    pp[34]=WestNeighbor(pp[15]);    

    pp[35]=SouthNeighbor(pp[34]);

    pp[36]=SouthNeighbor(pp[15]);
    pp[37]=SouthNeighbor(pp[16]);
    pp[38]=SouthNeighbor(pp[17]);
    pp[39]=SouthNeighbor(pp[18]);
    pp[40]=SouthNeighbor(pp[19]);
    pp[41]=EastNeighbor(pp[40]);
    pp[42]=NorthNeighbor(pp[41]);
    pp[43]=NorthNeighbor(pp[42]);  
    pp[44]=NorthNeighbor(pp[43]);  
    pp[45]=NorthNeighbor(pp[44]);  
    pp[46]=NorthNeighbor(pp[45]); 

    OctCell *smInCell=NULL;//�ԳƵ����ڵ�cell

    smInCell=findPointInCell(p_sm, bodygrid+parent00->NOparent);
    if(smInCell==NULL){ 
        for(int ii=0; ii<48; ++ii) {
            if(pp[ii]!=NULL) {
                smInCell=findPointInCell(p_sm, pp[ii]);
                if(smInCell!=NULL) break;
            }
        } 
    }
#ifdef DEBUG  
    if(smInCell==NULL){
        cout<<"020wrong find symitric point cell\n";
        cout<<parent->xc1<<","<<parent->yc1<<endl;
        cout<<p_sm->x<<","<<p_sm->y<<endl;
    }

#endif   
    pcell= smInCell;
 //   if(smInCell==NULL)pcell=parent; //2012/3/36
}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0x1b0(%rsp)
movq %rsi, 0x1a8(%rsp)
movq %rdx, 0x1a0(%rsp)
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
movl $0x180, %edx            # imm = 0x180
callq 0x3150
leaq 0x213c9(%rip), %rax     # 0x4b370
movq (%rax), %rax
movq 0x1b0(%rsp), %rcx
movl 0x200(%rcx), %ecx
imulq $0x360, %rcx, %rcx      # imm = 0x360
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
callq 0x118d0
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
callq 0x11670
movq %rax, 0x28(%rsp)
movq 0x18(%rsp), %rdi
callq 0x11670
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
callq 0x117a0
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rdi
callq 0x117a0
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
callq 0x11a00
movq %rax, 0x48(%rsp)
movq 0x18(%rsp), %rdi
callq 0x11a00
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
callq 0x118d0
movq %rax, 0x58(%rsp)
movq 0x28(%rsp), %rdi
callq 0x11670
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x117a0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x117a0
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rdi
callq 0x117a0
movq %rax, 0x78(%rsp)
movq 0x38(%rsp), %rdi
callq 0x117a0
movq %rax, 0x80(%rsp)
movq 0x40(%rsp), %rdi
callq 0x117a0
movq %rax, 0x88(%rsp)
movq 0x48(%rsp), %rdi
callq 0x117a0
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rdi
callq 0x11a00
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdi
callq 0x118d0
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x118d0
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x118d0
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x118d0
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x11670
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x11670
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x11670
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x11670
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x11670
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x117a0
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x117a0
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x117a0
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x117a0
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rdi
callq 0x117a0
movq %rax, 0x108(%rsp)
movq 0x78(%rsp), %rdi
callq 0x117a0
movq %rax, 0x110(%rsp)
movq 0x80(%rsp), %rdi
callq 0x117a0
movq %rax, 0x118(%rsp)
movq 0x88(%rsp), %rdi
callq 0x117a0
movq %rax, 0x120(%rsp)
movq 0x90(%rsp), %rdi
callq 0x117a0
movq %rax, 0x128(%rsp)
movq 0x98(%rsp), %rdi
callq 0x117a0
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rdi
callq 0x11a00
movq %rax, 0x138(%rsp)
movq 0x98(%rsp), %rdi
callq 0x11a00
movq %rax, 0x140(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x11a00
movq %rax, 0x148(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x11a00
movq %rax, 0x150(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x11a00
movq %rax, 0x158(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x11a00
movq %rax, 0x160(%rsp)
movq 0x160(%rsp), %rdi
callq 0x118d0
movq %rax, 0x168(%rsp)
movq 0x168(%rsp), %rdi
callq 0x11670
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rdi
callq 0x11670
movq %rax, 0x178(%rsp)
movq 0x178(%rsp), %rdi
callq 0x11670
movq %rax, 0x180(%rsp)
movq 0x180(%rsp), %rdi
callq 0x11670
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rdi
callq 0x11670
movq %rax, 0x190(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x1a8(%rsp), %rdi
leaq 0x2100a(%rip), %rax     # 0x4b370
movq (%rax), %rsi
movq 0x1b0(%rsp), %rax
movl 0x200(%rax), %eax
imulq $0x360, %rax, %rax      # imm = 0x360
addq %rax, %rsi
callq 0x29c10
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x2a3e8
movl $0x0, 0xc(%rsp)
cmpl $0x30, 0xc(%rsp)
jge 0x2a3e6
movslq 0xc(%rsp), %rax
cmpq $0x0, 0x20(%rsp,%rax,8)
je 0x2a3d7
movq 0x1a8(%rsp), %rdi
movslq 0xc(%rsp), %rax
movq 0x20(%rsp,%rax,8), %rsi
callq 0x29c10
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0x2a3d5
jmp 0x2a3e6
jmp 0x2a3d7
jmp 0x2a3d9
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x2a39b
jmp 0x2a3e8
cmpq $0x0, 0x10(%rsp)
jne 0x2a49e
movq 0x20bd5(%rip), %rdi     # 0x4afd0
leaq 0x15439(%rip), %rsi     # 0x3f83b
callq 0x3240
movq 0x18(%rsp), %rax
movsd 0x278(%rax), %xmm0
movq 0x20bb5(%rip), %rdi     # 0x4afd0
callq 0x3480
movq %rax, %rdi
leaq 0x14c65(%rip), %rsi     # 0x3f08f
callq 0x3240
movq %rax, %rdi
movq 0x18(%rsp), %rax
movsd 0x280(%rax), %xmm0
callq 0x3480
movq %rax, %rdi
movq 0x20b6a(%rip), %rsi     # 0x4afb8
callq 0x3290
movq 0x1a8(%rsp), %rax
movsd (%rax), %xmm0
movq 0x20b6a(%rip), %rdi     # 0x4afd0
callq 0x3480
movq %rax, %rdi
leaq 0x14c1a(%rip), %rsi     # 0x3f08f
callq 0x3240
movq %rax, %rdi
movq 0x1a8(%rsp), %rax
movsd 0x8(%rax), %xmm0
callq 0x3480
movq %rax, %rdi
movq 0x20b1f(%rip), %rsi     # 0x4afb8
callq 0x3290
movq 0x10(%rsp), %rcx
movq 0x1a0(%rsp), %rax
movq %rcx, (%rax)
addq $0x1b8, %rsp            # imm = 0x1B8
retq
nopw %cs:(%rax,%rax)