// File: jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: getsmtrctAB(double, pointxy const*, pointxy const*, pointxy const*, pointxy*, pointxy*, pointxy*, double*)
void getsmtrctAB(double hd, const PXYZ *gst, const PXYZ *pA, const PXYZ *pB,
    PXYZ *smtrctP, PXYZ *jiaodian, PXYZ *normal, double *dis)
{
    double ls1;
    double ls2;
    double b1, b2, xjd, yjd, jl;

    if(fabs(pB->y-pA->y) < 1e-10)
    {
//        smtrctP->x = gst->x;
  //      smtrctP->y = 2.0 * pA->y - gst->y;

        normal->x = 0.0;
        normal->y = (smtrctP->y - gst->y)/fabs(smtrctP->y - gst->y);
        xjd=jiaodian->x = gst->x;
        yjd=jiaodian->y = pA->y;
        *dis = sqrt((gst->x-xjd) * (gst->x-xjd) + (gst->y-yjd) * (gst->y-yjd));
        smtrctP->x=xjd+hd*normal->x;
        smtrctP->y=yjd+hd*normal->y;
    }
    else if(fabs(pA->x - pB->x) < 1e-10)
    {
       // smtrctP->x = 2 * pA->x - gst->x;
        //smtrctP->y = gst->y;

        jiaodian->x = pA->x;
        xjd=jiaodian->x;

        jiaodian->y = gst->y;
        yjd=jiaodian->y;

        *dis=jl = sqrt((gst->x - xjd) * (gst->x - xjd) + (gst->y - yjd) * (gst->y - yjd));

        normal->x = (xjd - gst->x)/jl;
        normal->y = (yjd - gst->y)/jl;
        smtrctP->x=xjd+hd*normal->x;
        smtrctP->y=yjd+hd*normal->y;
    }
    else
    {
        ls1 = (pA->y-pB->y)/(pA->x-pB->x);
        ls2 = - 1.0/ls1;
        b1 = pA->y - ls1 * pA->x;
        b2 = gst->y - ls2 * gst->x;

        xjd = (b2 - b1)/(ls1-ls2);
        yjd = ls1 * xjd + b1;

        jiaodian->x = xjd;
        jiaodian->y = yjd;

//        smtrctP->x = 2 * xjd - gst->x;
  //      smtrctP->y = 2 * yjd - gst->y;	

        *dis=jl = sqrt((gst->x-xjd) * (gst->x-xjd) + (gst->y-yjd) * (gst->y-yjd));

        normal->x = (xjd - gst->x)/jl;
        normal->y = (yjd - gst->y)/jl;
        smtrctP->x=xjd+hd*normal->x;
        smtrctP->y=yjd+hd*normal->y;
    }
}

// Assembly:
subq $0x78, %rsp
movq 0x80(%rsp), %rax
movsd %xmm0, 0x70(%rsp)
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq %r9, 0x40(%rsp)
movq 0x58(%rsp), %rax
movsd 0x8(%rax), %xmm1
movq 0x60(%rsp), %rax
subsd 0x8(%rax), %xmm1
movaps 0x18fd5(%rip), %xmm0    # 0x3f200
pand %xmm0, %xmm1
movsd 0x191d9(%rip), %xmm0    # 0x3f410
ucomisd %xmm1, %xmm0
jbe 0x2636e
movq 0x40(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq 0x50(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x68(%rsp), %rax
subsd 0x8(%rax), %xmm0
movq 0x50(%rsp), %rax
movsd 0x8(%rax), %xmm1
movq 0x68(%rsp), %rax
subsd 0x8(%rax), %xmm1
movaps 0x18f84(%rip), %xmm2    # 0x3f200
pand %xmm2, %xmm1
divsd %xmm1, %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x68(%rsp), %rax
movsd (%rax), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, (%rax)
movsd %xmm0, 0x18(%rsp)
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movsd %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rax
movsd (%rax), %xmm0
subsd 0x18(%rsp), %xmm0
movq 0x68(%rsp), %rax
movsd (%rax), %xmm2
subsd 0x18(%rsp), %xmm2
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm1
subsd 0x10(%rsp), %xmm1
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm3
subsd 0x10(%rsp), %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x31c0
movq 0x80(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x18(%rsp), %xmm1
movsd 0x70(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x50(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm1
movsd 0x70(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x50(%rsp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x266e4
movq 0x60(%rsp), %rax
movsd (%rax), %xmm1
movq 0x58(%rsp), %rax
subsd (%rax), %xmm1
movaps 0x18e79(%rip), %xmm0    # 0x3f200
pand %xmm0, %xmm1
movsd 0x1907d(%rip), %xmm0    # 0x3f410
ucomisd %xmm1, %xmm0
jbe 0x264d4
movq 0x60(%rsp), %rax
movsd (%rax), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x48(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x48(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rax
movsd (%rax), %xmm0
subsd 0x18(%rsp), %xmm0
movq 0x68(%rsp), %rax
movsd (%rax), %xmm2
subsd 0x18(%rsp), %xmm2
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm1
subsd 0x10(%rsp), %xmm1
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm3
subsd 0x10(%rsp), %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x31c0
movsd %xmm0, 0x8(%rsp)
movq 0x80(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x18(%rsp), %xmm0
movq 0x68(%rsp), %rax
subsd (%rax), %xmm0
divsd 0x8(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm0
movq 0x68(%rsp), %rax
subsd 0x8(%rax), %xmm0
divsd 0x8(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movsd 0x18(%rsp), %xmm1
movsd 0x70(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x50(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm1
movsd 0x70(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x50(%rsp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x266e2
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x58(%rsp), %rax
subsd 0x8(%rax), %xmm0
movq 0x60(%rsp), %rax
movsd (%rax), %xmm1
movq 0x58(%rsp), %rax
subsd (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x18e84(%rip), %xmm0    # 0x3f390
divsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x38(%rsp), %xmm0
movq 0x60(%rsp), %rax
movsd (%rax), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x30(%rsp), %xmm0
movq 0x68(%rsp), %rax
movsd (%rax), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm0
subsd 0x28(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
subsd 0x30(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x38(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
movsd 0x28(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x68(%rsp), %rax
movsd (%rax), %xmm0
subsd 0x18(%rsp), %xmm0
movq 0x68(%rsp), %rax
movsd (%rax), %xmm2
subsd 0x18(%rsp), %xmm2
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm1
subsd 0x10(%rsp), %xmm1
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm3
subsd 0x10(%rsp), %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x31c0
movsd %xmm0, 0x8(%rsp)
movq 0x80(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x18(%rsp), %xmm0
movq 0x68(%rsp), %rax
subsd (%rax), %xmm0
divsd 0x8(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm0
movq 0x68(%rsp), %rax
subsd 0x8(%rax), %xmm0
divsd 0x8(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movsd 0x18(%rsp), %xmm1
movsd 0x70(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x50(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm1
movsd 0x70(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x50(%rsp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x266e4
addq $0x78, %rsp
retq
nopl (%rax)