// File: /workspace/github_cpp_makefile_star2_O3/BartMassey[P]ancient-raytracer/poly.cc
// Function: poly::contains(point&)
int poly::contains( point &v )
{
  int pn = np;
  float xx = X(v);
  float yy = Y(v);
  int nr = 0;
  int i, j;
  float x0,x1,y0,y1,xl,xr,yi,yj;
  point *r[4];

  for( i = 0; i < pn; i++ ) {
    j = i + 1;
    if( j >= pn )
      j -= pn;
    yi = Y(get(i));
    yj = Y(get(j));
    if( yi < yy && yj >= yy ) {
      r[ nr++ ] = &get(i);
      r[ nr++ ] = &get(j);
    } else if( yi >= yy && yj < yy ) {
      r[ nr++ ] = &get(j);
      r[ nr++ ] = &get(i);
    }
  }
  /* if we haven't found a trapezoid, continue */
  if( nr < 4 )
    return 0;
  /* intercept first line */
  x0 = X(*r[0]);
  y0 = Y(*r[0]);
  x1 = X(*r[1]);
  y1 = Y(*r[1]);
  if( y1 - y0 < TINY ) {
    if( xx < x0 && xx < x1 )
      xl = MIN( x0, x1 );
    else if( xx > x0 && xx > x1 )
      xl = MAX( x0, x1 );
    else
      return 0;
  } else {
      xl = x0 + (x1 - x0) * (yy - y0) / (y1 - y0);
  }
  /* intercept second line */
  x0 = X(*r[2]);
  y0 = Y(*r[2]);
  x1 = X(*r[3]);
  y1 = Y(*r[3]);
  if( y1 - y0 < TINY ) {
    if( xx < x0 && xx < x1 )
      xr = MIN( x0, x1 );
    else if( xx > x0 && xx > x1 )
      xr = MAX( x0, x1 );
    else
      return 0;
  } else {
      xr = x0 + (x1 - x0) * (yy - y0) / (y1 - y0);
  }
  /* containment test */
  if( xl < xr && xl < xx && xx < xr )
    return 1;
  if( xl > xr && xl > xx && xx > xr )
    return 1;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %r15
movl 0x18(%rdi), %r12d
movq (%rsi), %rax
movq %rsi, %rdi
callq *0xe8(%rax)
testl %eax, %eax
jle 0x3b85
movq (%r14), %rax
xorl %ebp, %ebp
movq %r14, %rdi
xorl %esi, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movaps %xmm0, 0x20(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0xe8(%rax)
cmpl $0x1, %eax
jle 0x3b66
movq (%r14), %rax
movl $0x1, %ebx
movq %r14, %rdi
movl $0x1, %esi
callq *0x30(%rax)
testl %r12d, %r12d
jle 0x3b3e
movss (%rax), %xmm1
movl %r12d, %eax
negl %eax
movq %rax, 0x48(%rsp)
movl $0x0, (%rsp)
movl $0x0, 0x10(%rsp)
movss %xmm1, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
leal -0x1(%rbx), %esi
cmpl %r12d, %ebx
movl $0x0, %eax
cmovll %eax, %r12d
movq (%r15), %rax
movq %r15, %rdi
movl %esi, 0x30(%rsp)
callq *0x50(%rax)
movq %rax, %r14
movq (%rax), %rax
movq %r14, %rdi
callq *0xe8(%rax)
cmpl $0x1, %eax
jle 0x3b66
movq %rbx, %rbp
subl %r12d, %ebx
movq (%r14), %rax
movq %r14, %rdi
movl $0x1, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movss %xmm0, 0x4(%rsp)
movq (%r15), %rax
movq %r15, %r13
movq %r15, %rdi
movl %ebx, %esi
callq *0x50(%rax)
movq %rax, %r14
movq (%rax), %rax
movq %r14, %rdi
callq *0xe8(%rax)
cmpl $0x1, %eax
jle 0x3b66
movl 0x10(%rsp), %r15d
incl %r15d
movl %r15d, 0x10(%rsp)
subl %r12d, %r15d
movq (%r14), %rax
movq %r14, %rdi
movl $0x1, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movss 0x8(%rsp), %xmm1
movss 0x4(%rsp), %xmm2
ucomiss %xmm2, %xmm1
movl 0x30(%rsp), %ebx
jbe 0x383f
ucomiss %xmm1, %xmm0
jb 0x383f
movl %ebx, %esi
movl %r15d, %ebx
movl 0xc(%rsp), %r12d
jmp 0x3851
ucomiss %xmm1, %xmm2
movl 0xc(%rsp), %r12d
jb 0x3881
ucomiss %xmm0, %xmm1
movl %r15d, %esi
jbe 0x3881
movq %r13, %r15
movq (%r13), %rax
movq %r13, %rdi
callq *0x50(%rax)
movslq (%rsp), %r14
movq %rax, 0x50(%rsp,%r14,8)
movq (%r13), %rax
movq %r13, %rdi
movl %ebx, %esi
callq *0x50(%rax)
leal 0x2(%r14), %ecx
movl %ecx, (%rsp)
movq %rax, 0x58(%rsp,%r14,8)
jmp 0x3884
movq %r13, %r15
movq 0x48(%rsp), %rax
addl %ebp, %eax
incl %eax
movl %ebp, %ecx
incl %ecx
movl %ecx, %ebx
cmpl $0x1, %eax
jne 0x377f
xorl %ebp, %ebp
cmpl $0x4, (%rsp)
jl 0x3b3e
movq 0x50(%rsp), %rbx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
testl %eax, %eax
jle 0x3b85
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
cmpl $0x1, %eax
jle 0x3b66
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movss %xmm0, 0x30(%rsp)
movq 0x58(%rsp), %rbx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
testl %eax, %eax
jle 0x3b85
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movss %xmm0, 0x4(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
cmpl $0x1, %eax
jle 0x3b66
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movss 0x30(%rsp), %xmm4
subss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x4703(%rip), %xmm2     # 0x8070
ucomisd %xmm1, %xmm2
jbe 0x3993
movaps 0x20(%rsp), %xmm0
movaps 0x10(%rsp), %xmm1
ucomiss %xmm0, %xmm1
movss 0x4(%rsp), %xmm2
jbe 0x39bf
ucomiss %xmm0, %xmm2
jbe 0x39bf
minss %xmm2, %xmm1
jmp 0x39d7
movaps 0x10(%rsp), %xmm2
movss 0x4(%rsp), %xmm3
subss %xmm2, %xmm3
movss 0x8(%rsp), %xmm1
subss %xmm4, %xmm1
mulss %xmm3, %xmm1
divss %xmm0, %xmm1
addss %xmm1, %xmm2
movaps %xmm2, 0x10(%rsp)
jmp 0x39dc
xorl %ebp, %ebp
ucomiss %xmm1, %xmm0
jbe 0x3b3e
ucomiss %xmm2, %xmm0
jbe 0x3b3e
maxss %xmm2, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x60(%rsp), %rbx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
testl %eax, %eax
jle 0x3b85
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movaps %xmm0, 0x30(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
cmpl $0x1, %eax
jle 0x3b66
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movss %xmm0, 0x4(%rsp)
movq 0x68(%rsp), %rbx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
testl %eax, %eax
jle 0x3b85
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movss %xmm0, (%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
cmpl $0x1, %eax
jle 0x3b66
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
callq *0x30(%rax)
movss (%rax), %xmm0
movss 0x4(%rsp), %xmm4
subss %xmm4, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x45cd(%rip), %xmm2     # 0x8070
ucomisd %xmm1, %xmm2
jbe 0x3ad5
movaps 0x20(%rsp), %xmm0
movaps 0x30(%rsp), %xmm3
ucomiss %xmm0, %xmm3
movaps 0x10(%rsp), %xmm2
movss (%rsp), %xmm1
jbe 0x3b4f
ucomiss %xmm0, %xmm1
jbe 0x3b4f
minss %xmm1, %xmm3
jmp 0x3b03
movaps 0x30(%rsp), %xmm3
movss (%rsp), %xmm2
subss %xmm3, %xmm2
movss 0x8(%rsp), %xmm1
subss %xmm4, %xmm1
mulss %xmm2, %xmm1
divss %xmm0, %xmm1
addss %xmm1, %xmm3
movaps 0x20(%rsp), %xmm0
movaps 0x10(%rsp), %xmm2
ucomiss %xmm0, %xmm3
jbe 0x3b1c
movaps 0x20(%rsp), %xmm0
ucomiss %xmm2, %xmm0
jbe 0x3b1c
movl $0x1, %ebp
ucomiss %xmm2, %xmm3
ja 0x3b3e
movaps %xmm3, %xmm0
movaps 0x20(%rsp), %xmm1
ucomiss %xmm3, %xmm1
cmpltps %xmm2, %xmm0
cmpltps %xmm2, %xmm1
andps %xmm0, %xmm1
movd %xmm1, %eax
seta %cl
andb %al, %cl
movzbl %cl, %ebp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
ucomiss %xmm3, %xmm0
jbe 0x3b3e
ucomiss %xmm1, %xmm0
jbe 0x3b3e
maxss %xmm1, %xmm3
movaps 0x20(%rsp), %xmm0
jmp 0x3b03
leaq 0x4799(%rip), %rdi      # 0x8306
leaq 0x4532(%rip), %rsi      # 0x80a6
leaq 0x4795(%rip), %rcx      # 0x8310
movl $0x109, %edx            # imm = 0x109
callq 0x2080
leaq 0x475f(%rip), %rdi      # 0x82eb
leaq 0x4513(%rip), %rsi      # 0x80a6
leaq 0x475b(%rip), %rcx      # 0x82f5
movl $0x104, %edx            # imm = 0x104
callq 0x2080