// File: jamesliu516[P]amrdg2d/riemannWallBound.cpp
// Function: reflectionRie(double, double, double, double*, pointxy*, privariables*)
void reflectionRie(double hr,double hg, double vw,double U[4], PXYZ *nml, JBBL *jbugst)
{
    double tx,ty,nx,ny;
    nx=nml->x;
    ny=nml->y;
    tx=ny;
    ty=-nx;
    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=U[3];
 //   jbugst->q=U[0];
    jbugst->p=pw+hg/hr*(pw-U[3]);
    jbugst->q=dw+hg/hr*(dw-U[0]);
  //  jbugst->p=pw;
   // jbugst->q=dw;
    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 $0xb8, %rsp
movsd %xmm0, 0xb0(%rsp)
movsd %xmm1, 0xa8(%rsp)
movsd %xmm2, 0xa0(%rsp)
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq 0x90(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0x90(%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)
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 0x98(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x98(%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 0xa8(%rsp), %xmm0
divsd 0xb0(%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 0x88(%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 0x88(%rsp), %rax
movsd %xmm0, 0x10(%rax)
movq 0x98(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x30(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movq 0x98(%rsp), %rax
movsd 0x18(%rax), %xmm2
movsd 0xa0(%rsp), %xmm3
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x3d9d0
movsd 0x8(%rsp), %xmm1
movsd 0xa8(%rsp), %xmm0
divsd 0xb0(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movq 0x98(%rsp), %rax
subsd 0x18(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x88(%rsp), %rax
movsd %xmm0, 0x18(%rax)
movsd 0x10(%rsp), %xmm1
movsd 0xa8(%rsp), %xmm0
divsd 0xb0(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movq 0x98(%rsp), %rax
subsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x88(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x88(%rsp), %rax
movsd 0x1806(%rip), %xmm0     # 0x3f748
ucomisd 0x18(%rax), %xmm0
ja 0x3df7f
movq 0x88(%rsp), %rax
movsd 0x17ef(%rip), %xmm0     # 0x3f748
ucomisd (%rax), %xmm0
ja 0x3df7f
movsd 0x17e1(%rip), %xmm0     # 0x3f748
ucomisd 0x8(%rsp), %xmm0
ja 0x3df7f
movsd 0x17d1(%rip), %xmm0     # 0x3f748
ucomisd 0x10(%rsp), %xmm0
jbe 0x3dfb1
movq 0x98(%rsp), %rax
movsd 0x18(%rax), %xmm0
movq 0x88(%rsp), %rax
movsd %xmm0, 0x18(%rax)
movq 0x98(%rsp), %rax
movsd (%rax), %xmm0
movq 0x88(%rsp), %rax
movsd %xmm0, (%rax)
addq $0xb8, %rsp
retq
nopl (%rax)