// File: /workspace/github_cpp_makefile_star2_O1/jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: getRadius(pointxy const*, pointxy const*, pointxy const*, pointxy&)
double getRadius(const PXYZ *pt1, const PXYZ *pt2,const PXYZ *pt3, PXYZ &centr)
{
    //Ҫ�����㹲�߻��߽ӽ������������Ŀ��Ҳ��� TODO
    double rd,dls1,dls2,dls3,dls4;
    dls1=(pt1->x-pt2->x)*(pt1->x-pt2->x)+(pt1->y-pt2->y)*(pt1->y-pt2->y);
    dls2=(pt1->x-pt3->x)*(pt1->x-pt3->x)+(pt1->y-pt3->y)*(pt1->y-pt3->y);
    dls3=(pt2->x-pt3->x)*(pt2->x-pt3->x)+(pt2->y-pt3->y)*(pt2->y-pt3->y);
    dls4=2.0*(pt3->x * (pt2->y - pt1->y) + pt2->x * (pt1->y - pt3->y) 
        + pt1->x * (pt3->y-pt2->y));
    rd = sqrt(dls1*dls2*dls3)/(fabs(dls4)+1.0e-18);

    double xc12,yc12;
    xc12=0.5*(pt1->x+pt2->x);
    yc12=0.5*(pt1->y+pt2->y);

    double dis1c, dis;
    dis1c=sqrt((pt1->x-xc12)*(pt1->x-xc12)+(pt1->y-yc12)*(pt1->y-yc12));
    dis=sqrt(rd*rd-dis1c*dis1c);

    //   PXYZ tdir;
    PXYZ nml, cen1;       
    //  tdir.x=(pt1->x-xc12)/dis1c;
    // tdir.y=(pt1->y-yc12)/dis1c;       

    nml.x=(pt1->y-yc12)/dis1c;  
    nml.y=-(pt1->x-xc12)/dis1c;

    cen1.x= xc12+nml.x*dis;
    cen1.y= yc12+nml.y*dis;

    if(fabs(rd*rd-(cen1.x-pt3->x)*(cen1.x-pt3->x)-(cen1.y-pt3->y)*(cen1.y-pt3->y))<ERRS) {
        centr=cen1;
    }
    else {
        centr.x= xc12-nml.x*dis;
        centr.y= yc12-nml.y*dis;        
    }  

    double a1,b1,a2,b2;
    a1=pt2->x-pt1->x;
    b1=pt2->y-pt1->y;

    a2=pt3->x-pt1->x;
    b2=pt3->y-pt1->y;
    if(fabs(a1*b2-b1*a2)<1.0e-12) rd=1.0e15;
    return rd;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movsd (%rdi), %xmm3
movsd 0x8(%rdi), %xmm0
movsd (%rsi), %xmm2
movsd 0x8(%rsi), %xmm4
movsd (%rdx), %xmm1
movsd 0x8(%rdx), %xmm8
movapd %xmm4, %xmm6
unpcklpd %xmm8, %xmm6            # xmm6 = xmm6[0],xmm8[0]
movapd %xmm4, %xmm5
subsd %xmm8, %xmm5
subsd %xmm4, %xmm8
mulsd %xmm3, %xmm8
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
subsd %xmm0, %xmm4
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
subpd %xmm6, %xmm0
movapd %xmm0, %xmm6
movapd %xmm2, %xmm7
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
mulsd %xmm2, %xmm0
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
subpd %xmm2, %xmm3
mulpd %xmm6, %xmm6
mulpd %xmm3, %xmm3
addpd %xmm6, %xmm3
subsd %xmm1, %xmm7
mulsd %xmm5, %xmm5
mulsd %xmm7, %xmm7
addsd %xmm5, %xmm7
mulsd %xmm1, %xmm4
addsd %xmm0, %xmm4
addsd %xmm4, %xmm8
addsd %xmm8, %xmm8
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
mulsd %xmm3, %xmm0
mulsd %xmm7, %xmm0
xorpd %xmm5, %xmm5
ucomisd %xmm5, %xmm0
jb 0x122e0
xorps %xmm6, %xmm6
sqrtsd %xmm0, %xmm6
jmp 0x122fb
movapd %xmm8, 0x10(%rsp)
callq 0x31b0
xorpd %xmm5, %xmm5
movapd 0x10(%rsp), %xmm8
movapd %xmm0, %xmm6
andpd 0xbebc(%rip), %xmm8     # 0x1e1c0
addsd 0xc56b(%rip), %xmm8     # 0x1e878
divsd %xmm8, %xmm6
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movsd (%r15), %xmm3
addsd %xmm0, %xmm3
movsd 0xbe1a(%rip), %xmm2     # 0x1e148
mulsd %xmm2, %xmm3
movsd 0x8(%r15), %xmm4
addsd %xmm1, %xmm4
mulsd %xmm2, %xmm4
subsd %xmm3, %xmm0
subsd %xmm4, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm5, %xmm0
movapd %xmm6, 0x10(%rsp)
movsd %xmm3, 0x8(%rsp)
movsd %xmm4, (%rsp)
jb 0x12374
xorps %xmm3, %xmm3
sqrtsd %xmm0, %xmm3
jmp 0x12383
callq 0x31b0
movapd 0x10(%rsp), %xmm6
movapd %xmm0, %xmm3
movapd %xmm3, %xmm1
mulsd %xmm3, %xmm1
movapd %xmm6, %xmm8
mulsd %xmm6, %xmm8
movapd %xmm8, %xmm0
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x123ae
sqrtsd %xmm0, %xmm0
jmp 0x123d3
movapd %xmm8, 0x30(%rsp)
movsd %xmm3, 0x28(%rsp)
callq 0x31b0
movsd 0x28(%rsp), %xmm3
movapd 0x30(%rsp), %xmm8
movapd 0x10(%rsp), %xmm6
movsd 0x8(%rsp), %xmm5
movsd (%rsp), %xmm7
movsd (%r14), %xmm1
movsd 0x8(%r14), %xmm2
subsd %xmm7, %xmm2
subsd %xmm5, %xmm1
xorpd 0xbca7(%rip), %xmm1     # 0x1e0a0
divsd %xmm3, %xmm2
divsd %xmm3, %xmm1
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm3
addsd %xmm5, %xmm3
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd %xmm7, %xmm0
movapd %xmm3, %xmm4
subsd (%rbx), %xmm4
mulsd %xmm4, %xmm4
subsd %xmm4, %xmm8
movapd %xmm0, %xmm4
subsd 0x8(%rbx), %xmm4
mulsd %xmm4, %xmm4
subsd %xmm4, %xmm8
andpd 0xbd7b(%rip), %xmm8     # 0x1e1c0
movsd 0xbd03(%rip), %xmm4     # 0x1e150
ucomisd %xmm8, %xmm4
jbe 0x1245c
movsd %xmm3, (%r12)
jmp 0x1246e
subsd %xmm2, %xmm5
movsd %xmm5, (%r12)
subsd %xmm1, %xmm7
movapd %xmm7, %xmm0
movsd %xmm0, 0x8(%r12)
movsd (%r15), %xmm1
movsd 0x8(%r15), %xmm2
movsd (%r14), %xmm3
movsd 0x8(%r14), %xmm4
subsd %xmm3, %xmm1
subsd %xmm4, %xmm2
movsd (%rbx), %xmm5
movsd 0x8(%rbx), %xmm0
subsd %xmm3, %xmm5
mulsd %xmm2, %xmm5
subsd %xmm4, %xmm0
mulsd %xmm1, %xmm0
subsd %xmm5, %xmm0
andpd 0xbd08(%rip), %xmm0     # 0x1e1c0
cmpltsd 0xc3bf(%rip), %xmm0     # 0x1e880
movsd 0xc3bf(%rip), %xmm1     # 0x1e888
andpd %xmm0, %xmm1
andnpd %xmm6, %xmm0
orpd %xmm1, %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq