// File: 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:
subq $0x198, %rsp            # imm = 0x198
movq %rdi, 0x190(%rsp)
movl %esi, 0x18c(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x6310
leaq 0x168(%rsp), %rdi
callq 0x6310
leaq 0x158(%rsp), %rdi
callq 0x6310
leaq 0x148(%rsp), %rdi
callq 0x6310
leaq 0x138(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x6310
leaq 0x128(%rsp), %rdi
callq 0x6310
leaq 0x118(%rsp), %rdi
callq 0x6310
leaq 0xd8(%rsp), %rdi
callq 0x6530
leaq 0xb8(%rsp), %rdi
callq 0x6530
leaq 0x98(%rsp), %rdi
callq 0x6530
leaq 0x78(%rsp), %rdi
callq 0x21aa0
movq $0x0, 0x70(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x62a0
movq 0x190(%rsp), %rax
movsd 0x278(%rax), %xmm0
movsd %xmm0, 0x138(%rsp)
movq 0x190(%rsp), %rax
movsd 0x280(%rax), %xmm0
movsd %xmm0, 0x140(%rsp)
movq 0x190(%rsp), %rax
movsd 0x288(%rax), %xmm0
movsd 0x290(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
callq 0x31c0
movq 0x18(%rsp), %rdi
movsd %xmm0, 0x38(%rsp)
leaq 0xf8(%rsp), %rsi
callq 0x27aa0
movl %eax, 0x20(%rsp)
jmp 0x2bf13
movl 0x20(%rsp), %eax
movl %eax, 0xfc(%rsp)
movl 0xfc(%rsp), %eax
movslq 0xf8(%rsp), %rdx
leaq 0x1f35c(%rip), %rcx     # 0x4b290
movl (%rcx,%rdx,4), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2c01c
movslq 0xf8(%rsp), %rcx
leaq 0x1f4bf(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0xfc(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x128(%rsp)
movslq 0xf8(%rsp), %rcx
leaq 0x1f48a(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0xfc(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x130(%rsp)
movslq 0xf8(%rsp), %rcx
leaq 0x1f454(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x118(%rsp)
movslq 0xf8(%rsp), %rcx
leaq 0x1f42e(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x120(%rsp)
jmp 0x2c0fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x30(%rsp)
movl %eax, 0x2c(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x62b0
jmp 0x2c28b
movslq 0xf8(%rsp), %rcx
leaq 0x1f3e5(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0xfc(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x128(%rsp)
movslq 0xf8(%rsp), %rcx
leaq 0x1f3b0(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0xfc(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x130(%rsp)
movslq 0xf8(%rsp), %rcx
leaq 0x1f37a(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0xfc(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x118(%rsp)
movslq 0xf8(%rsp), %rcx
leaq 0x1f340(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0xfc(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x120(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x128(%rsp), %rsi
leaq 0x118(%rsp), %rdx
leaq 0x168(%rsp), %rcx
movq %rcx, 0x10(%rsp)
leaq 0x158(%rsp), %r8
leaq 0x178(%rsp), %r9
callq 0x25d40
movq 0x10(%rsp), %rsi
movq 0x190(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x29dd0
jmp 0x2c14f
movq 0x70(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0x168(%rsp), %rdx
leaq 0x58(%rsp), %rcx
callq 0x2a8b0
jmp 0x2c170
leaq 0x58(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0x2b9f0
jmp 0x2c18c
leaq 0xd8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
leaq 0x98(%rsp), %rdx
movq %rdx, 0x8(%rsp)
callq 0x266f0
movq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x23570
jmp 0x2c1bf
movsd 0x78(%rsp), %xmm0
movq 0x190(%rsp), %rax
movsd %xmm0, 0x30(%rax)
movsd 0x80(%rsp), %xmm0
movq 0x190(%rsp), %rax
movsd %xmm0, 0x60(%rax)
movsd 0x88(%rsp), %xmm0
movq 0x190(%rsp), %rax
movsd %xmm0, 0x90(%rax)
movsd 0x90(%rsp), %xmm0
movq 0x190(%rsp), %rax
movsd %xmm0, 0xc0(%rax)
movl $0x0, 0x28(%rsp)
cmpl $0x4, 0x28(%rsp)
jge 0x2c279
movl $0x1, 0x24(%rsp)
cmpl $0x6, 0x24(%rsp)
jge 0x2c26a
movq 0x190(%rsp), %rax
addq $0x30, %rax
movslq 0x28(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq 0x24(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x2c231
jmp 0x2c26c
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x2c222
leaq 0x58(%rsp), %rdi
callq 0x62b0
addq $0x198, %rsp            # imm = 0x198
retq
movq 0x30(%rsp), %rdi
callq 0x3440
nopw %cs:(%rax,%rax)