// File: /workspace/github_cpp_makefile_star2_O3/jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: getGhostValueExtWall(bodygridclass*)
void getGhostValueExtWall(OctCell * ghostcell)
{
    PXYZ nml1;
    PXYZ symtrcpt,jiaodian,wnph; 
    PXYZ ghostpt, plsA, plsB;

    int  ils;
    //Rieman problem������
    //    double dil,dir,ui,prei;
    JBBL ingrid1,jbu1; 

    JBBL jbgst1;

    SHBL shgst1;

    //	OctCell *leafp;
    OctCell *pincell=NULL;
    vector< OctCell * > grid;

//    double pwh1, vnsolid,pw1;	
 //   double  hc;

    ghostpt.x = ghostcell->xc1;
    ghostpt.y = ghostcell->yc1;	

    //hc=max2(ghostcell->dx, ghostcell->dy);
//    hc=sqrt(ghostcell->dx*ghostcell->dx+ghostcell->dy*ghostcell->dy);

    ils = getIndexAtWallPoint(&ghostpt, NPT_EXT_WALL, ext_wall); //TODO

    if(ils == NPT_EXT_WALL-1) 
    {
        plsA.x = ext_wall[ils].x; 
        plsA.y = ext_wall[ils].y;
        plsB.x = ext_wall[0].x; 
        plsB.y = ext_wall[0].y;
    }
    else
    {
        plsA.x = ext_wall[ils].x; 
        plsA.y = ext_wall[ils].y;
        plsB.x = ext_wall[ils+1].x; 
        plsB.y = ext_wall[ils+1].y;
    }

    getsmtrctAB(&ghostpt, &plsA, &plsB,
        &symtrcpt, &jiaodian, &nml1);

#ifdef DEBUG
    //cout<<"("<<ghostpt.x<<", "<<ghostpt.y<<")  ("<<jiaodian.x<<", "<<jiaodian.y<<")   ("
    // << symtrcpt.x<<", "<<symtrcpt.y<<")\n";
#endif

    //void getGridIndex(OctCell *gstc, const PXYZ *p_sm, int &iy, int &ix)
    //    getGridIndex(ghostcell, &symtrcpt, jj, kk);
    //void getGridIndex(OctCell *parent, const PXYZ *p_sm, ptrOctCell &pcell)

    getGridIndex2(ghostcell, &symtrcpt, pincell);

    //----------------------------------------------------------begin
    //void findIntpltCell(int iy, int ix, const PXYZ &gstp, const PXYZ &smtricp, vector< OctCell * > &grid) 

    //   findIntpltCell(jj, kk, ghostpt, symtrcpt, grid);
    //incellΪ���������ڵĿ�����
    //void findIntpltCell(const OctCell * incell, const PXYZ &gstp, const PXYZ &smtricp, vector< OctCell * > &grid)     
    findIntpltCell(pincell, ghostpt, symtrcpt, grid);

    // 	numbergrid = grid.size();

    //cout<<"numbergrid"<<numbergrid<<endl;

    // 	void chazhi4smtrictPshbl(vector< OctCell * > &grid, const PXYZ &smtrict, JBBL &jbu )

    chazhi4smtrictPshbl(grid, symtrcpt, ingrid1); 

    //2011-9.9	  									
    //    	InterpolateForMoving(grid, &symtrcpt, numbergrid, &ingrid1); 
    //------------------------------------------------------end-----------

    //	linearInterpolate(grid, &symtrcpt, &ingrid1);  

    reflection(&ingrid1, &nml1, &jbgst1);
    //////////////////				
    jbblToShbl(&jbgst1, &shgst1);

    ghostcell->dof[0][0] = shgst1.q;
    ghostcell->dof[1][0] = shgst1.qu;
    ghostcell->dof[2][0]  = shgst1.qv;
    ghostcell->dof[3][0] = shgst1.te;
    for(int itm=0; itm<4; ++itm) {
        for(int jtm=1;jtm<nDOF; ++jtm) {
            ghostcell->dof[itm][jtm]=0.0;
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movq %rax, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movups 0x278(%rdi), %xmm0
leaq 0x70(%rsp), %rdi
movaps %xmm0, (%rdi)
leaq 0x140a4(%rip), %r14     # 0x28280
movl $0x138, %esi            # imm = 0x138
movq %r14, %rdx
callq 0x118d1
cmpl $0x137, %eax            # imm = 0x137
jne 0x14200
leaq 0x1378(%r14), %rcx
leaq 0x1370(%r14), %rax
jmp 0x14222
movslq %eax, %rdx
shlq $0x4, %rdx
leaq 0x14072(%rip), %rsi     # 0x28280
leaq (%rsi,%rdx), %rax
leaq (%rsi,%rdx), %rcx
addq $0x8, %rcx
leaq (%rsi,%rdx), %r14
addq $0x10, %r14
movaps (%r14), %xmm0
movsd (%rcx), %xmm1
movsd (%rax), %xmm2
leaq 0x98(%rsp), %rsi
movsd %xmm2, (%rsi)
movsd %xmm1, 0x8(%rsi)
leaq 0x88(%rsp), %rdx
movups %xmm0, (%rdx)
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %r14
leaq 0xa8(%rsp), %r8
leaq 0x40(%rsp), %r9
movq %r14, %rcx
callq 0x10bc0
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1298d
movq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x12cbd
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x13746
movsd 0x68(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
movapd %xmm1, %xmm4
mulsd 0x8e04(%rip), %xmm1     # 0x1d0c8
mulsd %xmm2, %xmm1
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
mulsd %xmm4, %xmm4
movapd %xmm5, %xmm2
subsd %xmm4, %xmm2
movsd 0x50(%rsp), %xmm3
movsd 0x58(%rsp), %xmm6
movsd 0x60(%rsp), %xmm7
movapd %xmm1, %xmm8
mulsd %xmm7, %xmm8
mulsd %xmm6, %xmm2
addsd %xmm8, %xmm2
subsd %xmm5, %xmm4
mulsd %xmm7, %xmm4
mulsd %xmm6, %xmm1
addsd %xmm4, %xmm1
movapd %xmm3, %xmm4
movsd 0x8e2b(%rip), %xmm5     # 0x1d148
mulsd %xmm3, %xmm5
movsd %xmm3, 0x30(%rbx)
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm4
divsd 0x8e72(%rip), %xmm0     # 0x1d1a8
mulsd %xmm1, %xmm1
mulsd %xmm2, %xmm2
addsd %xmm1, %xmm2
mulsd %xmm5, %xmm2
addsd %xmm0, %xmm2
movsd %xmm3, 0x60(%rbx)
movsd %xmm4, 0x90(%rbx)
movsd %xmm2, 0xc0(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x38(%rbx)
movupd %xmm0, 0x48(%rbx)
xorl %eax, %eax
movq %rax, 0x58(%rbx)
movupd %xmm0, 0x68(%rbx)
movupd %xmm0, 0x78(%rbx)
movq %rax, 0x88(%rbx)
movupd %xmm0, 0x98(%rbx)
movupd %xmm0, 0xa8(%rbx)
movq %rax, 0xb8(%rbx)
movupd %xmm0, 0xc8(%rbx)
movupd %xmm0, 0xd8(%rbx)
movq %rax, 0xe8(%rbx)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x143c9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
addq $0xb8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x143ee
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %rbx, %rdi
callq 0x3370