// File: jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: getsmtrctAB(pointxy const*, pointxy const*, pointxy const*, pointxy*, pointxy*, pointxy*)
void getsmtrctAB(const PXYZ *gst, const PXYZ *pA, const PXYZ *pB,
    PXYZ *smtrctP, PXYZ *jiaodian, PXYZ *normal)
{
    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);

        jiaodian->x = gst->x;
        jiaodian->y = pA->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;

        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;
    }
    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;	

        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;
    }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x38(%rsp)
movq 0x50(%rsp), %rax
movsd 0x8(%rax), %xmm1
movq 0x58(%rsp), %rax
subsd 0x8(%rax), %xmm1
movaps 0x19483(%rip), %xmm0    # 0x3f200
pand %xmm0, %xmm1
movsd 0x19687(%rip), %xmm0    # 0x3f410
ucomisd %xmm1, %xmm0
jbe 0x25e5a
movq 0x60(%rsp), %rax
movsd (%rax), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x58(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq 0x48(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x60(%rsp), %rax
subsd 0x8(%rax), %xmm0
movq 0x48(%rsp), %rax
movsd 0x8(%rax), %xmm1
movq 0x60(%rsp), %rax
subsd 0x8(%rax), %xmm1
movaps 0x193e3(%rip), %xmm2    # 0x3f200
pand %xmm2, %xmm1
divsd %xmm1, %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x60(%rsp), %rax
movsd (%rax), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x58(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x261d4
movq 0x58(%rsp), %rax
movsd (%rax), %xmm1
movq 0x50(%rsp), %rax
subsd (%rax), %xmm1
movaps 0x1938d(%rip), %xmm0    # 0x3f200
pand %xmm0, %xmm1
movsd 0x19591(%rip), %xmm0    # 0x3f410
ucomisd %xmm1, %xmm0
jbe 0x25fb1
movq 0x58(%rsp), %rax
movsd (%rax), %xmm0
movq 0x60(%rsp), %rax
movsd (%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x58(%rsp), %rax
movsd (%rax), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x40(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x40(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x60(%rsp), %rax
movsd (%rax), %xmm0
subsd 0x10(%rsp), %xmm0
movq 0x60(%rsp), %rax
movsd (%rax), %xmm2
subsd 0x10(%rsp), %xmm2
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm1
subsd 0x8(%rsp), %xmm1
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm3
subsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x31c0
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
movq 0x60(%rsp), %rax
subsd (%rax), %xmm0
divsd (%rsp), %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x8(%rsp), %xmm0
movq 0x60(%rsp), %rax
subsd 0x8(%rax), %xmm0
divsd (%rsp), %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x261d2
movq 0x58(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x50(%rsp), %rax
subsd 0x8(%rax), %xmm0
movq 0x58(%rsp), %rax
movsd (%rax), %xmm1
movq 0x50(%rsp), %rax
subsd (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x193a7(%rip), %xmm0    # 0x3f390
divsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x58(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x30(%rsp), %xmm0
movq 0x58(%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)
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x28(%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, 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
subsd 0x20(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
subsd 0x28(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x8(%rsp), %xmm0
movq 0x40(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movsd 0x10(%rsp), %xmm0
movq 0x60(%rsp), %rax
movsd (%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x8(%rsp), %xmm0
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x60(%rsp), %rax
movsd (%rax), %xmm0
subsd 0x10(%rsp), %xmm0
movq 0x60(%rsp), %rax
movsd (%rax), %xmm2
subsd 0x10(%rsp), %xmm2
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm1
subsd 0x8(%rsp), %xmm1
movq 0x60(%rsp), %rax
movsd 0x8(%rax), %xmm3
subsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x31c0
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
movq 0x60(%rsp), %rax
subsd (%rax), %xmm0
divsd (%rsp), %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x8(%rsp), %xmm0
movq 0x60(%rsp), %rax
subsd 0x8(%rax), %xmm0
divsd (%rsp), %xmm0
movq 0x38(%rsp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x261d4
addq $0x68, %rsp
retq
nopl (%rax)