// File: jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: getGhostValueRiemann(bodygridclass*)
void getGhostValueRiemann(OctCell * ghostcell)
{
    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,hg;
    double W00[4],U00[4],U01[4];
    double xs,ys,xcs,ycs,dxs,dys;
    double vac;

    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(hc,&ghostpt, &plsA, &plsB,
        &symtrcpt, &jiaodian, &nml1,&hg);

#ifdef DEBUG
    //cout<<"("<<ghostpt.x<<", "<<ghostpt.y<<")  ("<<jiaodian.x<<", "<<jiaodian.y<<")   ("
    // << symtrcpt.x<<", "<<symtrcpt.y<<")\n";
#endif

    if(Nr==0)
        getGridIndex3(ghostcell, &symtrcpt, pincell);
    else
        getGridIndex(ghostcell, &symtrcpt, pincell);

    //        findIntpltCell(pincell, ghostpt, symtrcpt, grid);

    //       chazhi4smtrictPshbl(grid, symtrcpt, ingrid1); 

    xs=symtrcpt.x;
    ys=symtrcpt.y;
    dxs=pincell->dx;
    dys=pincell->dy;
    xcs=pincell->xc1;
    ycs=pincell->yc1;

  /*  for(int tm=0;tm<4;++tm){
        W00[tm]=pincell->dof[tm][0];
    }
    shbl2jbbl(W00,U01);
*/

    for(int itp=0;itp<4;++itp){
        W00[itp]=n_approx_sol(xs,ys,xcs,ycs,dxs,dys,pincell->dof[itp],nDOF);
    }

    shbl2jbbl(W00,U00);
    vac=4.0*sqrt(GAMMA*U00[3]/U00[0])/GAM11
        -(U00[1]*nml1.x+U00[2]*nml1.y);
    vac=-1.0;

    if(vac>0.0){
        if(qvlvRie == 0)
            reflectionRie(hc,hg,0.0,U00, &nml1, &jbgst1);
        else
            reflectionRieQVLV(hc,hg,0.0,U00, &nml1,&jiaodian, &jbgst1);
    }
    else{
        reflection(hc,hg,0.0,U00, &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 $0x248, %rsp            # imm = 0x248
movq %rdi, 0x240(%rsp)
leaq 0x230(%rsp), %rdi
callq 0x6310
leaq 0x220(%rsp), %rdi
callq 0x6310
leaq 0x210(%rsp), %rdi
callq 0x6310
leaq 0x200(%rsp), %rdi
callq 0x6310
leaq 0x1f0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x6310
leaq 0x1e0(%rsp), %rdi
callq 0x6310
leaq 0x1d0(%rsp), %rdi
callq 0x6310
leaq 0x190(%rsp), %rdi
callq 0x6530
leaq 0x170(%rsp), %rdi
callq 0x6530
leaq 0x150(%rsp), %rdi
callq 0x6530
leaq 0x130(%rsp), %rdi
callq 0x21aa0
movq $0x0, 0x128(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x62a0
movq 0x240(%rsp), %rax
movsd 0x278(%rax), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movq 0x240(%rsp), %rax
movsd 0x280(%rax), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movq 0x240(%rsp), %rax
movsd 0x288(%rax), %xmm0
movsd 0x290(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
callq 0x31c0
movq 0x20(%rsp), %rdi
movsd %xmm0, 0xf0(%rsp)
leaq 0x1b0(%rsp), %rsi
callq 0x27aa0
movl %eax, 0x2c(%rsp)
jmp 0x2c3d8
movl 0x2c(%rsp), %eax
movl %eax, 0x1b4(%rsp)
movl 0x1b4(%rsp), %eax
movslq 0x1b0(%rsp), %rdx
leaq 0x1ee97(%rip), %rcx     # 0x4b290
movl (%rcx,%rdx,4), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2c4e4
movslq 0x1b0(%rsp), %rcx
leaq 0x1effa(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x1b4(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x1e0(%rsp)
movslq 0x1b0(%rsp), %rcx
leaq 0x1efc5(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x1b4(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x1e8(%rsp)
movslq 0x1b0(%rsp), %rcx
leaq 0x1ef8f(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x1d0(%rsp)
movslq 0x1b0(%rsp), %rcx
leaq 0x1ef69(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x1d8(%rsp)
jmp 0x2c5c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x62b0
jmp 0x2c920
movslq 0x1b0(%rsp), %rcx
leaq 0x1ef1d(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x1b4(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x1e0(%rsp)
movslq 0x1b0(%rsp), %rcx
leaq 0x1eee8(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movslq 0x1b4(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x1e8(%rsp)
movslq 0x1b0(%rsp), %rcx
leaq 0x1eeb2(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x1b4(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x1d0(%rsp)
movslq 0x1b0(%rsp), %rcx
leaq 0x1ee78(%rip), %rax     # 0x4b410
imulq $0x1f40, %rcx, %rcx     # imm = 0x1F40
addq %rcx, %rax
movl 0x1b4(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x1d8(%rsp)
movsd 0xf0(%rsp), %xmm0
movq %rsp, %rax
leaq 0xe8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x1f0(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x1d0(%rsp), %rdx
leaq 0x220(%rsp), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x210(%rsp), %r8
leaq 0x230(%rsp), %r9
callq 0x261e0
movq 0x18(%rsp), %rsi
movq 0x240(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x29dd0
jmp 0x2c631
movsd 0x220(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x228(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0x128(%rsp), %rax
movsd 0x288(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x128(%rsp), %rax
movsd 0x290(%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x128(%rsp), %rax
movsd 0x278(%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0x128(%rsp), %rax
movsd 0x280(%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movl $0x0, 0x38(%rsp)
cmpl $0x4, 0x38(%rsp)
jge 0x2c727
movsd 0x78(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
movsd 0x60(%rsp), %xmm3
movsd 0x58(%rsp), %xmm4
movsd 0x50(%rsp), %xmm5
movq 0x128(%rsp), %rax
movslq 0x38(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
leaq 0x30(%rax,%rcx), %rdi
movl $0x6, %esi
callq 0x1f600
movsd %xmm0, 0x10(%rsp)
jmp 0x2c706
movsd 0x10(%rsp), %xmm0
movslq 0x38(%rsp), %rax
movsd %xmm0, 0xc0(%rsp,%rax,8)
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x2c6af
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2e130
jmp 0x2c73e
movsd 0x12a92(%rip), %xmm0    # 0x3f1d8
mulsd 0xb8(%rsp), %xmm0
divsd 0xa0(%rsp), %xmm0
callq 0x31c0
movaps %xmm0, %xmm1
movsd 0x12fd8(%rip), %xmm0    # 0x3f740
mulsd %xmm1, %xmm0
movsd 0x12a74(%rip), %xmm1    # 0x3f1e8
divsd %xmm1, %xmm0
movsd 0xa8(%rsp), %xmm1
movsd 0x230(%rsp), %xmm3
movsd 0xb0(%rsp), %xmm2
mulsd 0x238(%rsp), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x12bda(%rip), %xmm0    # 0x3f390
movsd %xmm0, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2c801
movsd 0xf0(%rsp), %xmm0
movsd 0xe8(%rsp), %xmm1
xorps %xmm2, %xmm2
leaq 0xa0(%rsp), %rdi
leaq 0x230(%rsp), %rsi
leaq 0x150(%rsp), %rdx
callq 0x3dc10
jmp 0x2c7ff
jmp 0x2c837
movsd 0xf0(%rsp), %xmm0
movsd 0xe8(%rsp), %xmm1
xorps %xmm2, %xmm2
leaq 0xa0(%rsp), %rdi
leaq 0x230(%rsp), %rsi
leaq 0x150(%rsp), %rdx
callq 0x26ab0
jmp 0x2c835
jmp 0x2c837
leaq 0x150(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x23570
jmp 0x2c84e
movsd 0x130(%rsp), %xmm0
movq 0x240(%rsp), %rax
movsd %xmm0, 0x30(%rax)
movsd 0x138(%rsp), %xmm0
movq 0x240(%rsp), %rax
movsd %xmm0, 0x60(%rax)
movsd 0x140(%rsp), %xmm0
movq 0x240(%rsp), %rax
movsd %xmm0, 0x90(%rax)
movsd 0x148(%rsp), %xmm0
movq 0x240(%rsp), %rax
movsd %xmm0, 0xc0(%rax)
movl $0x0, 0x34(%rsp)
cmpl $0x4, 0x34(%rsp)
jge 0x2c90b
movl $0x1, 0x30(%rsp)
cmpl $0x6, 0x30(%rsp)
jge 0x2c8fc
movq 0x240(%rsp), %rax
addq $0x30, %rax
movslq 0x34(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq 0x30(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x2c8c3
jmp 0x2c8fe
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x2c8b4
leaq 0x110(%rsp), %rdi
callq 0x62b0
addq $0x248, %rsp            # imm = 0x248
retq
movq 0x40(%rsp), %rdi
callq 0x3440
nopw (%rax,%rax)