// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0xf0(%rsp), %r12
movaps %xmm0, (%r12)
leaq 0x80(%rsp), %r14
movaps %xmm0, (%r14)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
leaq 0x50(%rsp), %r15
andq $0x0, (%r15)
movaps %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
movups 0x278(%rdi), %xmm0
leaq 0x110(%rsp), %r13
movaps %xmm0, (%r13)
movsd 0x288(%rdi), %xmm0
movsd 0x290(%rdi), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x5c(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1016a
movslq (%rbp), %rcx
leaq 0x10e9f(%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 0x10c4f(%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
movapd (%rax,%rcx), %xmm2
leaq 0x100(%rsp), %rsi
movapd %xmm2, (%rsi)
leaq 0x128(%rsp), %rdx
movsd %xmm1, (%rdx)
movsd %xmm0, 0x8(%rdx)
leaq 0x48(%rsp), %rax
movq %rax, (%rsp)
leaq 0x138(%rsp), %r8
movsd 0x10(%rsp), %xmm0
movq %r13, %rdi
movq %r14, %rcx
movq %r12, %r9
callq 0xf8fe
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x10ec8
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x50(%rsp), %r14
movsd 0x288(%r14), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x290(%r14), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x278(%r14), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x280(%r14), %xmm0
movsd %xmm0, 0x18(%rsp)
addq $0x30, %r14
xorl %r15d, %r15d
pushq $0x6
popq %rbp
cmpq $0x4, %r15
je 0x124a9
movsd 0x40(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
movsd 0x30(%rsp), %xmm4
movsd 0x28(%rsp), %xmm5
movq %r14, %rdi
movl %ebp, %esi
callq 0xca49
movsd %xmm0, 0xd0(%rsp,%r15,8)
incq %r15
addq $0x30, %r14
jmp 0x12462
movsd 0xd0(%rsp), %xmm1
movsd %xmm1, 0xb0(%rsp)
movupd 0xd8(%rsp), %xmm2
movapd %xmm1, %xmm0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
divpd %xmm0, %xmm2
movupd %xmm2, 0xb8(%rsp)
movapd %xmm2, %xmm0
mulpd %xmm2, %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
movsd 0x8c7b(%rip), %xmm0     # 0x1b170
mulsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
addsd 0xe8(%rsp), %xmm0
mulsd 0x8d1a(%rip), %xmm0     # 0x1b228
movsd %xmm0, 0xc8(%rsp)
mulsd 0x8d11(%rip), %xmm0     # 0x1b230
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jae 0x12532
callq 0x3180
movsd 0x48(%rsp), %xmm1
leaq 0xb0(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
leaq 0x60(%rsp), %rdx
movsd 0x10(%rsp), %xmm0
callq 0xfc66
movsd 0x60(%rsp), %xmm1
movsd 0x68(%rsp), %xmm0
movsd 0x70(%rsp), %xmm2
movapd %xmm1, %xmm3
movsd 0x78(%rsp), %xmm4
movsd 0x8bfc(%rip), %xmm5     # 0x1b178
mulsd %xmm1, %xmm5
movsd %xmm1, 0x30(%rbx)
mulsd %xmm0, %xmm1
mulsd %xmm2, %xmm3
divsd 0x8c93(%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 0x125e5
xorl %ecx, %ecx
cmpq $0x5, %rcx
je 0x125dc
andq $0x0, (%rbx,%rcx,8)
incq %rcx
jmp 0x125cc
incq %rax
addq $0x30, %rbx
jmp 0x125c4
leaq 0x90(%rsp), %rdi
callq 0x4cba
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x12606
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4cba
movq %rbx, %rdi
callq 0x3350