// File: 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:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x6310
leaq 0x130(%rsp), %rdi
callq 0x6310
leaq 0x120(%rsp), %rdi
callq 0x6310
leaq 0x110(%rsp), %rdi
callq 0x6310
leaq 0x100(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x6310
leaq 0xf0(%rsp), %rdi
callq 0x6310
leaq 0xe0(%rsp), %rdi
callq 0x6310
leaq 0xb8(%rsp), %rdi
callq 0x6530
leaq 0x98(%rsp), %rdi
callq 0x6530
leaq 0x78(%rsp), %rdi
callq 0x6530
leaq 0x58(%rsp), %rdi
callq 0x21aa0
movq $0x0, 0x50(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x62a0
movq 0x18(%rsp), %rdi
movq 0x150(%rsp), %rax
movsd 0x278(%rax), %xmm0
movsd %xmm0, 0x100(%rsp)
movq 0x150(%rsp), %rax
movsd 0x280(%rax), %xmm0
movsd %xmm0, 0x108(%rsp)
leaq 0x223e2(%rip), %rdx     # 0x4f310
movl $0x138, %esi            # imm = 0x138
callq 0x280d0
movl %eax, 0x20(%rsp)
jmp 0x2cf3e
movl 0x20(%rsp), %eax
movl %eax, 0xdc(%rsp)
cmpl $0x137, 0xdc(%rsp) # imm = 0x137
jne 0x2cfec
movslq 0xdc(%rsp), %rcx
leaq 0x223a7(%rip), %rax     # 0x4f310
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0xf0(%rsp)
movslq 0xdc(%rsp), %rcx
leaq 0x22384(%rip), %rax     # 0x4f310
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0xf8(%rsp)
leaq 0x22368(%rip), %rax     # 0x4f310
movsd (%rax), %xmm0
movsd %xmm0, 0xe0(%rsp)
leaq 0x22354(%rip), %rax     # 0x4f310
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0xe8(%rsp)
jmp 0x2d084
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x30(%rsp)
movl %eax, 0x2c(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x62b0
jmp 0x2d207
movslq 0xdc(%rsp), %rcx
leaq 0x22315(%rip), %rax     # 0x4f310
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0xf0(%rsp)
movslq 0xdc(%rsp), %rcx
leaq 0x222f2(%rip), %rax     # 0x4f310
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0xf8(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x222c9(%rip), %rax     # 0x4f310
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0xe0(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x222a1(%rip), %rax     # 0x4f310
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0xe8(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
leaq 0x130(%rsp), %rcx
movq %rcx, 0x10(%rsp)
leaq 0x120(%rsp), %r8
leaq 0x140(%rsp), %r9
callq 0x25d40
movq 0x10(%rsp), %rsi
movq 0x150(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x2a4c0
jmp 0x2d0d7
movq 0x50(%rsp), %rdi
leaq 0x100(%rsp), %rsi
leaq 0x130(%rsp), %rdx
leaq 0x38(%rsp), %rcx
callq 0x2a8b0
jmp 0x2d0f8
leaq 0x38(%rsp), %rdi
leaq 0x130(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x2b9f0
jmp 0x2d114
leaq 0xb8(%rsp), %rdi
leaq 0x140(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movq %rdx, 0x8(%rsp)
callq 0x266f0
movq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x23570
jmp 0x2d144
movsd 0x58(%rsp), %xmm0
movq 0x150(%rsp), %rax
movsd %xmm0, 0x30(%rax)
movsd 0x60(%rsp), %xmm0
movq 0x150(%rsp), %rax
movsd %xmm0, 0x60(%rax)
movsd 0x68(%rsp), %xmm0
movq 0x150(%rsp), %rax
movsd %xmm0, 0x90(%rax)
movsd 0x70(%rsp), %xmm0
movq 0x150(%rsp), %rax
movsd %xmm0, 0xc0(%rax)
movl $0x0, 0x28(%rsp)
cmpl $0x4, 0x28(%rsp)
jge 0x2d1f5
movl $0x1, 0x24(%rsp)
cmpl $0x6, 0x24(%rsp)
jge 0x2d1e6
movq 0x150(%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 0x2d1ad
jmp 0x2d1e8
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x2d19e
leaq 0x38(%rsp), %rdi
callq 0x62b0
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x30(%rsp), %rdi
callq 0x3440
nopw %cs:(%rax,%rax)