// File: jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: reflection(double, double, double, double*, pointxy const*, privariables*)
void reflection(double hr, double hg, double vnsolid, double U[4], const PXYZ *nxyz, JBBL *jbugst)
{
    double tx,ty,nx,ny;
    nx=nxyz->x;
    ny=nxyz->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->q = U[0];
    jbugst->p = U[3];

    //	jbugst->u = (- nxyz->x * nxyz->x + nxyz->y * nxyz->y) * jbu->u
     //  - 2 * nxyz->x * nxyz->y * jbu->v + 2 * nxyz->x * vnsolid;
    //    jbugst->v = - 2 * nxyz->x * nxyz->y * jbu->u + (nxyz->x * nxyz->x - nxyz->y * nxyz->y)* jbu->v 
//        + 2 * nxyz->y * vnsolid; 
    jbugst->u = (ny * ut2 - ty * un2)/(tx * ny - nx * ty);
    jbugst->v = (tx * un2 - nx * ut2)/(tx * ny - nx * ty);			
}

// Assembly:
subq $0xa8, %rsp
movsd %xmm0, 0xa0(%rsp)
movsd %xmm1, 0x98(%rsp)
movsd %xmm2, 0x90(%rsp)
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdx, 0x78(%rsp)
movq 0x80(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x80(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x60(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x60(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
leaq 0x48(%rsp), %rdi
callq 0x1e1a0
movsd 0x70(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
leaq 0x38(%rsp), %rdi
callq 0x1e1a0
movq 0x88(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x88(%rsp), %rax
movsd 0x10(%rax), %xmm1
leaq 0x28(%rsp), %rdi
callq 0x1e1a0
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1e1d0
movsd %xmm0, 0x20(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x1e1d0
movsd %xmm0, 0x18(%rsp)
movsd 0x98(%rsp), %xmm0
divsd 0xa0(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x88(%rsp), %rax
movsd (%rax), %xmm0
movq 0x78(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x88(%rsp), %rax
movsd 0x18(%rax), %xmm0
movq 0x78(%rsp), %rax
movsd %xmm0, 0x18(%rax)
movsd 0x58(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movsd 0x68(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0x58(%rsp), %xmm3
movsd 0x60(%rsp), %xmm2
mulsd 0x68(%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 0x78(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movsd 0x70(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movsd 0x60(%rsp), %xmm1
mulsd 0x8(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0x58(%rsp), %xmm3
movsd 0x60(%rsp), %xmm2
mulsd 0x68(%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 0x78(%rsp), %rax
movsd %xmm0, 0x10(%rax)
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)