// File: /workspace/github_cpp_makefile_star2_O2/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:
leal -0x1(%rdi), %ecx
xorl %edx, %edx
testl %edi, %edi
cmovlel %edx, %edi
shlq $0x4, %rcx
leaq (%rsi,%rcx), %r8
movapd 0x1173d(%rip), %xmm2    # 0x1b470
movsd %xmm1, %xmm2            # xmm2 = xmm1[0],xmm2[1]
shlq $0x4, %rdi
movapd 0x114fd(%rip), %xmm3    # 0x1b240
movsd 0x11715(%rip), %xmm4    # 0x1b460
movsd 0x114cd(%rip), %xmm5    # 0x1b220
pushq $0x2
popq %rax
movapd 0x11342(%rip), %xmm6    # 0x1b0a0
movsd 0x11412(%rip), %xmm7    # 0x1b178
xorpd %xmm8, %xmm8
xorl %r9d, %r9d
cmpq %rdx, %rdi
je 0x9f92
cmpq %rdx, %rcx
jne 0x9db4
movsd 0x8(%r8), %xmm9
movsd 0x8(%rsi), %xmm11
movapd %xmm9, %xmm10
subsd %xmm11, %xmm10
andpd %xmm3, %xmm10
ucomisd %xmm10, %xmm4
jbe 0x9e1d
movsd (%rsi), %xmm12
movapd %xmm12, %xmm14
subsd %xmm0, %xmm14
movsd (%r8), %xmm10
jmp 0x9def
movsd 0x8(%rsi,%rdx), %xmm9
movsd 0x18(%rsi,%rdx), %xmm11
movapd %xmm9, %xmm10
subsd %xmm11, %xmm10
andpd %xmm3, %xmm10
ucomisd %xmm10, %xmm4
jbe 0x9e29
movsd (%rsi,%rdx), %xmm10
movsd 0x10(%rsi,%rdx), %xmm12
movapd %xmm12, %xmm14
subsd %xmm0, %xmm14
movapd %xmm10, %xmm13
subsd %xmm0, %xmm13
mulsd %xmm13, %xmm14
addsd %xmm5, %xmm14
ucomisd %xmm14, %xmm5
jb 0x9ef3
movapd %xmm9, %xmm14
subsd %xmm1, %xmm14
jmp 0x9ee3
movsd (%r8), %xmm10
movsd (%rsi), %xmm12
jmp 0x9e36
movsd (%rsi,%rdx), %xmm10
movsd 0x10(%rsi,%rdx), %xmm12
movapd %xmm10, %xmm13
subsd %xmm12, %xmm13
andpd %xmm3, %xmm13
ucomisd %xmm13, %xmm4
jbe 0x9e82
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 0x9ef3
movapd %xmm13, %xmm14
jmp 0x9ee3
movapd %xmm12, %xmm14
subsd %xmm0, %xmm14
movapd %xmm10, %xmm13
subsd %xmm0, %xmm13
mulsd %xmm13, %xmm14
addsd %xmm5, %xmm14
ucomisd %xmm14, %xmm5
jb 0x9ef3
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 0x9f9c
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, %r10d
subl %r10d, %r9d
addq $0x10, %rdx
jmp 0x9d6e
andl $0x1, %r9d
negl %r9d
movl %r9d, %eax
retq
nopl (%rax)