// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r14
movq %rcx, %rbx
movq %rdi, %r15
movapd %xmm0, %xmm5
movsd 0x8(%rdx), %xmm1
movsd 0x8(%rsi), %xmm0
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
andpd 0xd02c(%rip), %xmm2     # 0x1e1c0
movq 0x60(%rsp), %r12
movsd 0xd23f(%rip), %xmm3     # 0x1e3e0
ucomisd %xmm2, %xmm3
jbe 0x11216
movq $0x0, (%r14)
movsd 0x8(%rbx), %xmm0
subsd 0x8(%r15), %xmm0
movapd 0xcfff(%rip), %xmm1     # 0x1e1c0
andpd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%r14)
movsd (%r15), %xmm2
movsd %xmm2, (%r8)
movsd 0x8(%rsi), %xmm3
movsd %xmm3, 0x8(%r8)
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
subsd %xmm2, %xmm0
subsd %xmm3, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1127f
sqrtsd %xmm0, %xmm0
jmp 0x112a6
movsd (%rsi), %xmm6
movapd %xmm6, %xmm2
subsd (%rdx), %xmm2
movapd 0xcf96(%rip), %xmm4     # 0x1e1c0
andpd %xmm2, %xmm4
ucomisd %xmm4, %xmm3
jbe 0x112ca
movsd %xmm6, (%r8)
movsd 0x8(%r15), %xmm2
movsd %xmm2, 0x8(%r8)
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
subsd %xmm6, %xmm0
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1135e
sqrtsd %xmm0, %xmm0
jmp 0x11385
movapd %xmm5, 0x20(%rsp)
movapd %xmm2, 0x10(%rsp)
movapd %xmm3, (%rsp)
callq 0x31b0
movapd (%rsp), %xmm3
movapd 0x10(%rsp), %xmm2
movapd 0x20(%rsp), %xmm5
movsd %xmm0, (%r12)
movupd (%r14), %xmm0
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm0, %xmm5
unpcklpd %xmm3, %xmm2            # xmm2 = xmm2[0],xmm3[0]
addpd %xmm5, %xmm2
movupd %xmm2, (%rbx)
jmp 0x11412
movapd %xmm0, %xmm7
subsd %xmm1, %xmm7
divsd %xmm2, %xmm7
movsd 0xd0aa(%rip), %xmm1     # 0x1e388
divsd %xmm7, %xmm1
movapd %xmm7, %xmm2
subsd %xmm1, %xmm2
unpcklpd %xmm7, %xmm1            # xmm1 = xmm1[0],xmm7[0]
movsd (%r15), %xmm3
movsd 0x8(%r15), %xmm4
unpcklpd %xmm6, %xmm3            # xmm3 = xmm3[0],xmm6[0]
mulpd %xmm1, %xmm3
unpcklpd %xmm0, %xmm4            # xmm4 = xmm4[0],xmm0[0]
subpd %xmm3, %xmm4
movapd %xmm4, %xmm0
unpckhpd %xmm4, %xmm0            # xmm0 = xmm0[1],xmm4[1]
subsd %xmm0, %xmm4
divsd %xmm2, %xmm4
mulsd %xmm4, %xmm7
addsd %xmm0, %xmm7
movsd %xmm4, (%r8)
movsd %xmm7, 0x8(%r8)
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
subsd %xmm4, %xmm0
subsd %xmm7, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x113b7
sqrtsd %xmm0, %xmm0
jmp 0x113de
movapd %xmm5, 0x20(%rsp)
movapd %xmm6, 0x10(%rsp)
movapd %xmm2, (%rsp)
callq 0x31b0
movapd (%rsp), %xmm2
movapd 0x10(%rsp), %xmm6
movapd 0x20(%rsp), %xmm5
movsd %xmm0, (%r12)
movupd (%r15), %xmm1
unpcklpd %xmm2, %xmm6            # xmm6 = xmm6[0],xmm2[0]
movapd %xmm6, %xmm2
subpd %xmm1, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm2
movupd %xmm2, (%r14)
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm2, %xmm5
addpd %xmm6, %xmm5
jmp 0x1140e
movapd %xmm5, 0x20(%rsp)
movapd %xmm4, 0x10(%rsp)
movapd %xmm7, (%rsp)
callq 0x31b0
movapd (%rsp), %xmm7
movapd 0x10(%rsp), %xmm4
movapd 0x20(%rsp), %xmm5
movsd %xmm0, (%r12)
movupd (%r15), %xmm1
unpcklpd %xmm7, %xmm4            # xmm4 = xmm4[0],xmm7[0]
movapd %xmm4, %xmm2
subpd %xmm1, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm2
movupd %xmm2, (%r14)
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm2, %xmm5
addpd %xmm4, %xmm5
movupd %xmm5, (%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq