// File: jamesliu516[P]amrdg2d/riemannWallBound.cpp
// Function: reflectionRieQVLV(double, double, double, double*, pointxy*, pointxy const*, privariables*)
void reflectionRieQVLV(double hr,double hg, double vw,double U[4], PXYZ *nml, const PXYZ *wpt, JBBL *jbugst)
{
    double rd,tx,ty,nx,ny;
    nx=nml->x;
    ny=nml->y;
    tx=ny;
    ty=-nx;
    rd=getWallCurvatureRadius(wpt);
    Vec2D ndir(nx,ny);
    Vec2D tdir(tx,ty);
    Vec2D ur(U[1],U[2]);
    double un1,ut1,un2,ut2;
    un1=ur.dot(ndir);
    ut1=ur.dot(tdir);
    un2=-(hg/hr)*un1;
    ut2=ut1;

    jbugst->u = (ny * ut2 - ty * un2)/(tx * ny - nx * ty);
    jbugst->v = (tx * un2 - nx * ut2)/(tx * ny - nx * ty);			
    double dw,pw;

    solveERS(U[0],-un1,U[3],vw,&dw,&pw);

    jbugst->p=pw+hg*((pw-U[3])/hr-dw*ut2*ut2/rd);
    jbugst->q=dw+hg/hr*(dw-U[0]);
    if(jbugst->p<1.0e-13|| jbugst->q<1.0e-13
        || pw<1.0e-13||dw<1.0e-13){
        jbugst->p=U[3];
        jbugst->q=U[0];
    }
}

// Assembly:
subq $0xc8, %rsp
movsd %xmm0, 0xc0(%rsp)
movsd %xmm1, 0xb8(%rsp)
movsd %xmm2, 0xb0(%rsp)
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movq %rdx, 0x98(%rsp)
movq %rcx, 0x90(%rsp)
movq 0xa0(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0xa0(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x70(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x78(%rsp)
movq 0x98(%rsp), %rdi
callq 0x270f0
movsd %xmm0, 0x88(%rsp)
movsd 0x70(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
leaq 0x58(%rsp), %rdi
callq 0x1e1a0
movsd 0x80(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
leaq 0x48(%rsp), %rdi
callq 0x1e1a0
movq 0xa8(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0xa8(%rsp), %rax
movsd 0x10(%rax), %xmm1
leaq 0x38(%rsp), %rdi
callq 0x1e1a0
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1e1d0
movsd %xmm0, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1e1d0
movsd %xmm0, 0x28(%rsp)
movsd 0xb8(%rsp), %xmm0
divsd 0xc0(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x68(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
movsd 0x78(%rsp), %xmm1
mulsd 0x20(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x80(%rsp), %xmm1
movsd 0x68(%rsp), %xmm3
movsd 0x70(%rsp), %xmm2
mulsd 0x78(%rsp), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq 0x90(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movsd 0x80(%rsp), %xmm0
movsd 0x20(%rsp), %xmm2
movsd 0x70(%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x80(%rsp), %xmm1
movsd 0x68(%rsp), %xmm3
movsd 0x70(%rsp), %xmm2
mulsd 0x78(%rsp), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq 0x90(%rsp), %rax
movsd %xmm0, 0x10(%rax)
movq 0xa8(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x30(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movq 0xa8(%rsp), %rax
movsd 0x18(%rax), %xmm2
movsd 0xb0(%rsp), %xmm3
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x3d9d0
movsd 0x8(%rsp), %xmm1
movsd 0xb8(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movq 0xa8(%rsp), %rax
subsd 0x18(%rax), %xmm2
divsd 0xc0(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
mulsd 0x18(%rsp), %xmm3
mulsd 0x18(%rsp), %xmm3
divsd 0x88(%rsp), %xmm3
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x90(%rsp), %rax
movsd %xmm0, 0x18(%rax)
movsd 0x10(%rsp), %xmm1
movsd 0xb8(%rsp), %xmm0
divsd 0xc0(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movq 0xa8(%rsp), %rax
subsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x90(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x90(%rsp), %rax
movsd 0x1419(%rip), %xmm0     # 0x3f748
ucomisd 0x18(%rax), %xmm0
ja 0x3e36c
movq 0x90(%rsp), %rax
movsd 0x1402(%rip), %xmm0     # 0x3f748
ucomisd (%rax), %xmm0
ja 0x3e36c
movsd 0x13f4(%rip), %xmm0     # 0x3f748
ucomisd 0x8(%rsp), %xmm0
ja 0x3e36c
movsd 0x13e4(%rip), %xmm0     # 0x3f748
ucomisd 0x10(%rsp), %xmm0
jbe 0x3e39e
movq 0xa8(%rsp), %rax
movsd 0x18(%rax), %xmm0
movq 0x90(%rsp), %rax
movsd %xmm0, 0x18(%rax)
movq 0xa8(%rsp), %rax
movsd (%rax), %xmm0
movq 0x90(%rsp), %rax
movsd %xmm0, (%rax)
addq $0xc8, %rsp
retq