// File: /workspace/github_cpp_makefile_star2_O2/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 $0xd8, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %r15
movaps %xmm0, (%r15)
leaq 0x30(%rsp), %r14
movaps %xmm0, (%r14)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x90(%rsp)
leaq 0x20(%rsp), %r12
andq $0x0, (%r12)
movaps %xmm0, 0x80(%rsp)
andq $0x0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movups 0x278(%rdi), %xmm0
leaq 0x60(%rsp), %r13
movaps %xmm0, (%r13)
leaq 0x2c(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1016a
movslq (%rbp), %rcx
leaq 0x110cb(%rip), %rdx     # 0x23200
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 0x10e7b(%rip), %rcx     # 0x22fd0
addq %rcx, %rdi
xorl %r8d, %r8d
cmpl %edx, %eax
cmovneq %rsi, %r8
cmoveq %rcx, %rdi
shlq $0x4, %r8
movsd 0x8(%r8,%rcx), %xmm0
movsd (%rdi), %xmm1
shlq $0x4, %rax
movaps (%rax,%rcx), %xmm2
leaq 0xa0(%rsp), %rsi
movaps %xmm2, (%rsi)
leaq 0xb8(%rsp), %rdx
movsd %xmm1, (%rdx)
movsd %xmm0, 0x8(%rdx)
leaq 0xc8(%rsp), %r8
movq %r13, %rdi
movq %r14, %rcx
movq %r15, %r9
callq 0xf750
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x10ec8
movq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rsp, %rcx
callq 0x1171f
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x11f43
leaq 0x40(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x80(%rsp), %r14
movq %r14, %rdx
callq 0xfad1
movsd (%r14), %xmm1
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm2
movapd %xmm1, %xmm3
movsd 0x18(%r14), %xmm4
movsd 0x8f56(%rip), %xmm5     # 0x1b178
mulsd %xmm1, %xmm5
movsd %xmm1, 0x30(%rbx)
mulsd %xmm0, %xmm1
mulsd %xmm2, %xmm3
divsd 0x8fed(%rip), %xmm4     # 0x1b228
mulsd %xmm2, %xmm2
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm5, %xmm0
addsd %xmm4, %xmm0
movsd %xmm1, 0x60(%rbx)
movsd %xmm3, 0x90(%rbx)
movsd %xmm0, 0xc0(%rbx)
addq $0x38, %rbx
xorl %eax, %eax
cmpq $0x4, %rax
je 0x1228b
xorl %ecx, %ecx
cmpq $0x5, %rcx
je 0x12282
andq $0x0, (%rbx,%rcx,8)
incq %rcx
jmp 0x12272
incq %rax
addq $0x30, %rbx
jmp 0x1226a
movq %rsp, %rdi
callq 0x4cba
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x4cba
movq %rbx, %rdi
callq 0x3350