// File: /workspace/github_cpp_makefile_star2_O3/jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: getGhostValueMagazine(bodygridclass*, int)
void getGhostValueMagazine(OctCell * ghostcell, int lyx)
{
    PXYZ nml1;
    PXYZ symtrcpt,jiaodian,wnph; 
    PXYZ ghostpt, plsA, plsB;

    int jj,kk,m,numbergrid,lsflag,lsint, ils;
    int nb;
    //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,nb); //TODO

    if(ils == NWallPts[nb]-1) 
    {
        plsA.x = MultiCircle[nb][ils].x; 
        plsA.y = MultiCircle[nb][ils].y;
        plsB.x = MultiCircle[nb][0].x; 
        plsB.y = MultiCircle[nb][0].y;
    }
    else
    {
        plsA.x = MultiCircle[nb][ils].x; 
        plsA.y = MultiCircle[nb][ils].y;
        plsB.x = MultiCircle[nb][ils+1].x; 
        plsB.y = MultiCircle[nb][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)

    getGridIndex(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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rax
movaps %xmm0, (%rax)
leaq 0x60(%rsp), %r14
movaps %xmm0, (%r14)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
xorl %r15d, %r15d
leaq 0x30(%rsp), %r12
movq %r15, (%r12)
movq %r15, 0x10(%rsp)
movaps %xmm0, (%rsp)
movups 0x278(%rdi), %xmm0
leaq 0x70(%rsp), %r13
movaps %xmm0, (%r13)
leaq 0x3c(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x115e3
movslq (%rbp), %rcx
leaq 0x1083c(%rip), %rdx     # 0x24200
movl (%rdx,%rcx,4), %edx
decl %edx
cltq
leaq 0x1(%rax), %rsi
movq %rsi, %rdi
shlq $0x4, %rdi
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq 0x105ec(%rip), %rcx     # 0x23fd0
addq %rcx, %rdi
cmpl %edx, %eax
cmoveq %r15, %rsi
cmoveq %rcx, %rdi
shlq $0x4, %rsi
movsd 0x8(%rsi,%rcx), %xmm0
movsd (%rdi), %xmm1
shlq $0x4, %rax
movaps (%rax,%rcx), %xmm2
leaq 0x80(%rsp), %rsi
movaps %xmm2, (%rsi)
leaq 0x98(%rsp), %rdx
movsd %xmm1, (%rdx)
movsd %xmm0, 0x8(%rdx)
leaq 0xa8(%rsp), %r8
movq %r13, %rdi
movq %r14, %rcx
leaq 0x20(%rsp), %r9
callq 0x10bc0
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1235f
movq 0x30(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x60(%rsp), %rdx
movq %rsp, %rcx
callq 0x12cbd
movq %rsp, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x13746
movsd 0x58(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movapd %xmm1, %xmm4
mulsd 0x9638(%rip), %xmm1     # 0x1d0c8
mulsd %xmm2, %xmm1
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
mulsd %xmm4, %xmm4
movapd %xmm5, %xmm2
subsd %xmm4, %xmm2
movsd 0x40(%rsp), %xmm3
movsd 0x48(%rsp), %xmm6
movsd 0x50(%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 0x965f(%rip), %xmm5     # 0x1d148
mulsd %xmm3, %xmm5
movsd %xmm3, 0x30(%rbx)
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm4
divsd 0x96a6(%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 (%rsp), %rdi
testq %rdi, %rdi
je 0x13b94
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x13bbf
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %rbx, %rdi
callq 0x3370