// File: /workspace/github_cpp_makefile_star2_O1/jamesliu516[P]amrdg2d/points_solid.cpp
// Function: newFlagpoint_1(double, double, int, pointxy*)
int newFlagpoint_1(double x, double y, int NumberPoint,PXYZ wallpnt[] )//Ӧ�����߷��� //in the solid flag==-1, out the solid flag=0
    //at the surface of the solid flag=2
{
    int j;
    double x1, y1, x2, y2;
    double dls1, dls2, nx, ny, pax, pay , pbx, pby, px, py, kslop, bs;
    int flag, xDirflag=0,yDirflag=0;
    const double smallp = 1e-10;
    x1=x;
    y1=20.2;
    x2=20.2;
    y2=y;

    for(j=0; j <= NumberPoint - 1; j++)
    {
        if(j == NumberPoint - 1)
        {
            if(fabs(wallpnt[j].y - wallpnt[0].y) < smallp )
            {
                if((wallpnt[0].x - x) * (wallpnt[j].x - x) +1.0 <= 1.0)
                {
                    if(fabs(wallpnt[j].y - y) < smallp )
                    { 
                        flag=2; 
                        return flag;
                    }
                }
            }
            else if(fabs(wallpnt[j].x - wallpnt[0].x) < smallp )
            {
                if((wallpnt[0].y - y) * (wallpnt[j].y - y) +1.0<= 1.0)
                {
                    if(fabs(wallpnt[j].x - x) < smallp )
                    { 
                        flag=2; 
                        return flag;
                    }
                }
            }
            else
            {
                kslop = (wallpnt[0].y-wallpnt[j].y)/(wallpnt[0].x-wallpnt[j].x);
                bs = wallpnt[j].y - kslop * wallpnt[j].x; 
                if((wallpnt[0].x - x) * (wallpnt[j].x - x) +1.0<= 1.0 
                    && fabs(y - kslop * x - bs) < smallp ) 
                {
                    flag=2;
                    return flag;
                }
            }

            dls1 = (wallpnt[j].x - x1) * (wallpnt[0].x - x1);

            nx = wallpnt[0].y - wallpnt[j].y;
            ny = -(wallpnt[0].x - wallpnt[j].x);
            px = 0.5 * (wallpnt[0].x + wallpnt[j].x);
            py = 0.5 * (wallpnt[0].y + wallpnt[j].y);
        }
        else
        { 
            if(fabs(wallpnt[j].y - wallpnt[j+1].y) < smallp )
            {
                if((wallpnt[j+1].x - x) * (wallpnt[j].x - x) +1.0<= 1.0)
                {
                    if(fabs(wallpnt[j].y - y) < smallp )
                    { 
                        flag=2; 
                        return flag;
                    }
                }
            }
            else if(fabs(wallpnt[j].x - wallpnt[j+1].x) < smallp )
            {
                if((wallpnt[j+1].y - y) * (wallpnt[j].y - y) +1.0<= 1.0)
                {
                    if(fabs(wallpnt[j].x - x) < smallp )
                    { 
                        flag=2; 
                        return flag;
                    }
                }
            }
            else
            {
                kslop = (wallpnt[j+1].y-wallpnt[j].y)/(wallpnt[j+1].x-wallpnt[j].x);
                bs = wallpnt[j].y - kslop * wallpnt[j].x; 
                if((wallpnt[j+1].x - x) * (wallpnt[j].x - x) +1.0<= 1.0 
                    && fabs(y - kslop * x - bs) < smallp ) 
                {
                    flag=2;
                    return flag;
                }
            }

            dls1 = (wallpnt[j].x - x1) * (wallpnt[j+1].x - x1);

            nx = wallpnt[j+1].y - wallpnt[j].y;
            ny = -(wallpnt[j+1].x - wallpnt[j].x);
            px = 0.5 * (wallpnt[j+1].x + wallpnt[j].x);
            py = 0.5 * (wallpnt[j+1].y + wallpnt[j].y);
        }

        pax = x - px;
        pay = y - py;
        pbx = x1 - px;
        pby = y1 - py;

        dls2 = (nx * pax + ny * pay) * (nx * pbx + ny * pby);

        if (dls1 <= 0.0 && dls2 <= 0.0) yDirflag++;
    }

    if(yDirflag % 2 == 0) flag = 0;
    else flag = -1;
    return flag;
}

// Assembly:
testl %edi, %edi
jle 0xac27
leal -0x1(%rdi), %ecx
movl %edi, %edx
movapd 0x13b17(%rip), %xmm2    # 0x1e3f0
movsd %xmm1, %xmm2            # xmm2 = xmm1[0],xmm2[1]
leaq 0x10(%rsi), %rdi
xorl %r8d, %r8d
movapd 0x138d4(%rip), %xmm3    # 0x1e1c0
movsd 0x13aec(%rip), %xmm4    # 0x1e3e0
movsd 0x138a4(%rip), %xmm5    # 0x1e1a0
movapd 0x1379c(%rip), %xmm6    # 0x1e0a0
movsd 0x1383c(%rip), %xmm7    # 0x1e148
xorpd %xmm8, %xmm8
xorl %eax, %eax
movsd -0x8(%rdi), %xmm9
cmpq %r8, %rcx
jne 0xa977
movsd 0x8(%rsi), %xmm10
movapd %xmm9, %xmm11
subsd %xmm10, %xmm11
andpd %xmm3, %xmm11
ucomisd %xmm11, %xmm4
jbe 0xa9d0
movsd (%rsi), %xmm11
subsd %xmm0, %xmm11
movsd -0x10(%rdi), %xmm12
subsd %xmm0, %xmm12
mulsd %xmm11, %xmm12
addsd %xmm5, %xmm12
ucomisd %xmm12, %xmm5
jb 0xaab1
movapd %xmm9, %xmm11
subsd %xmm1, %xmm11
jmp 0xaa23
movsd 0x8(%rdi), %xmm10
movapd %xmm9, %xmm11
subsd %xmm10, %xmm11
andpd %xmm3, %xmm11
ucomisd %xmm11, %xmm4
jbe 0xaa32
movsd -0x10(%rdi), %xmm11
movsd (%rdi), %xmm12
subsd %xmm0, %xmm12
subsd %xmm0, %xmm11
mulsd %xmm12, %xmm11
addsd %xmm5, %xmm11
ucomisd %xmm11, %xmm5
jb 0xaade
movapd %xmm9, %xmm11
subsd %xmm1, %xmm11
jmp 0xaa7d
movsd -0x10(%rdi), %xmm11
movsd (%rsi), %xmm12
movapd %xmm11, %xmm13
subsd %xmm12, %xmm13
andpd %xmm3, %xmm13
ucomisd %xmm13, %xmm4
jbe 0xaa8c
movapd %xmm10, %xmm12
subsd %xmm1, %xmm12
movapd %xmm9, %xmm13
subsd %xmm1, %xmm13
mulsd %xmm12, %xmm13
addsd %xmm5, %xmm13
ucomisd %xmm13, %xmm5
jb 0xaab1
subsd %xmm0, %xmm11
andpd %xmm3, %xmm11
ucomisd %xmm11, %xmm4
jmp 0xab22
movsd -0x10(%rdi), %xmm11
movsd (%rdi), %xmm12
movapd %xmm11, %xmm13
subsd %xmm12, %xmm13
andpd %xmm3, %xmm13
ucomisd %xmm13, %xmm4
jbe 0xaab9
movapd %xmm10, %xmm12
subsd %xmm1, %xmm12
movapd %xmm9, %xmm13
subsd %xmm1, %xmm13
mulsd %xmm12, %xmm13
addsd %xmm5, %xmm13
ucomisd %xmm13, %xmm5
jb 0xaade
subsd %xmm0, %xmm11
andpd %xmm3, %xmm11
ucomisd %xmm11, %xmm4
jmp 0xab68
movapd %xmm12, %xmm13
subsd %xmm0, %xmm13
movapd %xmm11, %xmm14
subsd %xmm0, %xmm14
mulsd %xmm13, %xmm14
addsd %xmm5, %xmm14
ucomisd %xmm14, %xmm5
jae 0xaae6
movq %rsi, %r9
jmp 0xab71
movapd %xmm12, %xmm13
subsd %xmm0, %xmm13
movapd %xmm11, %xmm14
subsd %xmm0, %xmm14
mulsd %xmm13, %xmm14
addsd %xmm5, %xmm14
ucomisd %xmm14, %xmm5
jae 0xab2c
movq %rdi, %r9
jmp 0xab71
movapd %xmm10, %xmm13
subsd %xmm9, %xmm13
xorpd %xmm6, %xmm13
subsd %xmm11, %xmm12
divsd %xmm12, %xmm13
mulsd %xmm13, %xmm11
addsd %xmm9, %xmm11
mulsd %xmm0, %xmm13
addsd %xmm1, %xmm13
subsd %xmm11, %xmm13
andpd %xmm3, %xmm13
ucomisd %xmm13, %xmm4
movq %rsi, %r9
jbe 0xab71
jmp 0xac2c
movapd %xmm10, %xmm13
subsd %xmm9, %xmm13
xorpd %xmm6, %xmm13
subsd %xmm11, %xmm12
divsd %xmm12, %xmm13
mulsd %xmm13, %xmm11
addsd %xmm9, %xmm11
mulsd %xmm0, %xmm13
addsd %xmm1, %xmm13
subsd %xmm11, %xmm13
andpd %xmm3, %xmm13
ucomisd %xmm13, %xmm4
movq %rdi, %r9
ja 0xac2c
movsd -0x10(%rdi), %xmm12
movapd %xmm12, %xmm13
subsd %xmm0, %xmm13
movsd (%r9), %xmm11
movapd %xmm11, %xmm14
subsd %xmm12, %xmm14
addsd %xmm11, %xmm12
subsd %xmm0, %xmm11
mulsd %xmm13, %xmm11
movapd %xmm10, %xmm13
subsd %xmm9, %xmm13
addsd %xmm10, %xmm9
mulsd %xmm7, %xmm9
mulsd %xmm7, %xmm12
movapd %xmm0, %xmm10
subsd %xmm12, %xmm10
unpcklpd %xmm9, %xmm9            # xmm9 = xmm9[0,0]
movapd %xmm2, %xmm12
subpd %xmm9, %xmm12
unpcklpd %xmm14, %xmm14          # xmm14 = xmm14[0,0]
mulpd %xmm12, %xmm14
mulsd %xmm13, %xmm10
unpcklpd %xmm10, %xmm10          # xmm10 = xmm10[0,0]
subpd %xmm14, %xmm10
movapd %xmm10, %xmm9
unpckhpd %xmm10, %xmm9           # xmm9 = xmm9[1],xmm10[1]
mulpd %xmm10, %xmm9
cmplepd %xmm8, %xmm9
cmplepd %xmm8, %xmm11
andpd %xmm9, %xmm11
movd %xmm11, %r9d
subl %r9d, %eax
incq %r8
addq $0x10, %rdi
cmpq %r8, %rdx
jne 0xa913
andl $0x1, %eax
jmp 0xac29
xorl %eax, %eax
negl %eax
retq
movl $0x2, %eax
retq
nop