// File: /workspace/github_cpp_makefile_star2_O3/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 0xaa09
leal -0x1(%rdi), %ecx
movl %edi, %edx
shlq $0x4, %rcx
leaq (%rsi,%rcx), %rdi
movapd 0x12c65(%rip), %xmm2    # 0x1d410
movsd %xmm1, %xmm2            # xmm2 = xmm1[0],xmm2[1]
shlq $0x4, %rdx
xorl %r8d, %r8d
movapd 0x12a02(%rip), %xmm3    # 0x1d1c0
movsd 0x12c3a(%rip), %xmm4    # 0x1d400
movsd 0x129d2(%rip), %xmm5    # 0x1d1a0
movapd 0x128ca(%rip), %xmm6    # 0x1d0a0
movsd 0x1296a(%rip), %xmm7    # 0x1d148
xorpd %xmm8, %xmm8
xorl %eax, %eax
cmpq %r8, %rcx
jne 0xa822
movsd 0x8(%rdi), %xmm9
movsd 0x8(%rsi), %xmm11
movapd %xmm9, %xmm10
subsd %xmm11, %xmm10
andpd %xmm3, %xmm10
ucomisd %xmm10, %xmm4
jbe 0xa88b
movsd (%rsi), %xmm12
movapd %xmm12, %xmm14
subsd %xmm0, %xmm14
movsd (%rdi), %xmm10
jmp 0xa85d
movsd 0x8(%rsi,%r8), %xmm9
movsd 0x18(%rsi,%r8), %xmm11
movapd %xmm9, %xmm10
subsd %xmm11, %xmm10
andpd %xmm3, %xmm10
ucomisd %xmm10, %xmm4
jbe 0xa897
movsd (%rsi,%r8), %xmm10
movsd 0x10(%rsi,%r8), %xmm12
movapd %xmm12, %xmm14
subsd %xmm0, %xmm14
movapd %xmm10, %xmm13
subsd %xmm0, %xmm13
mulsd %xmm13, %xmm14
addsd %xmm5, %xmm14
ucomisd %xmm14, %xmm5
jb 0xa961
movapd %xmm9, %xmm14
subsd %xmm1, %xmm14
jmp 0xa951
movsd (%rdi), %xmm10
movsd (%rsi), %xmm12
jmp 0xa8a4
movsd (%rsi,%r8), %xmm10
movsd 0x10(%rsi,%r8), %xmm12
movapd %xmm10, %xmm13
subsd %xmm12, %xmm13
andpd %xmm3, %xmm13
ucomisd %xmm13, %xmm4
jbe 0xa8f0
movapd %xmm11, %xmm13
subsd %xmm1, %xmm13
movapd %xmm9, %xmm14
subsd %xmm1, %xmm14
mulsd %xmm13, %xmm14
addsd %xmm5, %xmm14
ucomisd %xmm14, %xmm5
movapd %xmm10, %xmm13
subsd %xmm0, %xmm13
jb 0xa961
movapd %xmm13, %xmm14
jmp 0xa951
movapd %xmm12, %xmm14
subsd %xmm0, %xmm14
movapd %xmm10, %xmm13
subsd %xmm0, %xmm13
mulsd %xmm13, %xmm14
addsd %xmm5, %xmm14
ucomisd %xmm14, %xmm5
jb 0xa961
movapd %xmm11, %xmm14
subsd %xmm9, %xmm14
xorpd %xmm6, %xmm14
movapd %xmm12, %xmm15
subsd %xmm10, %xmm15
divsd %xmm15, %xmm14
movapd %xmm14, %xmm15
mulsd %xmm10, %xmm15
addsd %xmm9, %xmm15
mulsd %xmm0, %xmm14
addsd %xmm1, %xmm14
subsd %xmm15, %xmm14
andpd %xmm3, %xmm14
ucomisd %xmm14, %xmm4
ja 0xaa0e
movapd %xmm12, %xmm14
subsd %xmm0, %xmm14
mulsd %xmm13, %xmm14
movapd %xmm11, %xmm15
subsd %xmm9, %xmm15
movapd %xmm12, %xmm13
subsd %xmm10, %xmm13
xorpd %xmm6, %xmm13
addsd %xmm12, %xmm10
addsd %xmm11, %xmm9
mulsd %xmm7, %xmm9
mulsd %xmm7, %xmm10
movapd %xmm0, %xmm11
subsd %xmm10, %xmm11
unpcklpd %xmm9, %xmm9            # xmm9 = xmm9[0,0]
movapd %xmm2, %xmm10
subpd %xmm9, %xmm10
unpcklpd %xmm13, %xmm13          # xmm13 = xmm13[0,0]
mulpd %xmm10, %xmm13
mulsd %xmm15, %xmm11
unpcklpd %xmm11, %xmm11          # xmm11 = xmm11[0,0]
addpd %xmm13, %xmm11
movapd %xmm11, %xmm9
unpckhpd %xmm11, %xmm9           # xmm9 = xmm9[1],xmm11[1]
mulpd %xmm11, %xmm9
cmplepd %xmm8, %xmm9
cmplepd %xmm8, %xmm14
andpd %xmm9, %xmm14
movd %xmm14, %r9d
subl %r9d, %eax
addq $0x10, %r8
cmpq %r8, %rdx
jne 0xa7e5
andl $0x1, %eax
jmp 0xaa0b
xorl %eax, %eax
negl %eax
retq
movl $0x2, %eax
retq