// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0xc0, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movq %rax, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movups 0x278(%rdi), %xmm0
movaps %xmm0, 0x30(%rsp)
movsd 0x288(%rdi), %xmm0
movsd 0x290(%rdi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jae 0x14039
callq 0x31b0
leaq 0x30(%rsp), %r14
leaq 0x6c(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x11acd
movslq (%r15), %rcx
leaq 0x111a8(%rip), %rdx     # 0x25200
movl (%rdx,%rcx,4), %edx
decl %edx
cltq
movq %rax, %rsi
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq 0x10f60(%rip), %rcx     # 0x24fd0
shlq $0x4, %rsi
leaq 0x1(%rax), %rdi
movq %rdi, %r8
shlq $0x4, %r8
addq %rcx, %r8
xorl %r9d, %r9d
cmpl %edx, %eax
movaps (%rsi,%rcx), %xmm0
leaq 0xa0(%rsp), %rsi
movaps %xmm0, (%rsi)
cmoveq %rcx, %r8
cmovneq %rdi, %r9
movsd (%r8), %xmm0
leaq 0x90(%rsp), %rdx
movsd %xmm0, (%rdx)
shlq $0x4, %r9
movsd 0x8(%r9,%rcx), %xmm0
movsd %xmm0, 0x8(%rdx)
leaq 0x40(%rsp), %r15
leaq 0xb0(%rsp), %r8
leaq 0x50(%rsp), %r9
movq %r14, %rdi
movq %r15, %rcx
callq 0x10f48
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x129d4
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x132be
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x13da5
movsd 0x88(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movapd %xmm1, %xmm4
mulsd 0x9f8e(%rip), %xmm1     # 0x1e0c8
mulsd %xmm2, %xmm1
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
mulsd %xmm4, %xmm4
movapd %xmm5, %xmm2
subsd %xmm4, %xmm2
movsd 0x70(%rsp), %xmm3
movsd 0x78(%rsp), %xmm6
movsd 0x80(%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 0x9fb2(%rip), %xmm5     # 0x1e148
mulsd %xmm3, %xmm5
movsd %xmm3, 0x30(%rbx)
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm4
divsd 0x9ff9(%rip), %xmm0     # 0x1e1a8
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)
movl $0x38, %eax
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rbx,%rax)
movupd %xmm0, (%rbx,%rax)
movq $0x0, 0x20(%rbx,%rax)
addq $0x30, %rax
cmpq $0xf8, %rax
jne 0x141e1
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x14218
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
addq $0xc0, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1423f
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %rbx, %rdi
callq 0x3370