// File: /workspace/github_cpp_makefile_star2_O2/carlos-urena[P]svg-gen/svgobjects.cpp
// Function: ExtrVertSegm::ExtrVertSegm(Polygon&, Polygon&, Camera const&)
ExtrVertSegm::ExtrVertSegm( Polygon & pol1, Polygon & pol2, const Camera & cam )
{
   using namespace std ;
   assert( pol1.points3D.size() == pol2.points3D.size() );
   assert( 1 < pol1.points3D.size() );

   pol1.project( cam );
   pol2.project( cam );

   int   imin = 0,
         imax = 0 ;
   float xmin = pol1.points3D[0][0],
         xmax = pol2.points3D[0][0];

   for( int i = 1 ; i < pol1.points3D.size() ; i++ )
   {
      const float x1 = pol1.points2D[i][0],
                  x2 = pol2.points2D[i][0] ;

      if ( std::fabs( x1-x2) > 1e-6 )
         cout << "WARNING! - non vertically aligned vertexes!" << endl ;
      //cout << "x1 == " << x1 << ", x2 == " << x2 << endl ;
      if ( x1 < xmin )
      {
         imin = i ;
         xmin = x1 ;
      }
      else if ( xmax < x1 )
      {
         imax = i ;
         xmax = x1 ;
      }
   }

   auto * smin = new Segment( pol1.points3D[imin], pol2.points3D[imin] );
   auto * smax = new Segment( pol1.points3D[imax], pol2.points3D[imax] );

   // tweak styles here
   smin->style.lines_width = 0.003 ;
   smin->style.lines_color = vec3( 0.4, 0.4, 0.4 );

   smax->style = smin->style ;

   add( smin );
   add( smax );



}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movb $0x0, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
andq $0x0, 0x30(%rdi)
leaq 0x6cff(%rip), %rax      # 0xfaf8
movq %rax, (%rdi)
movq 0x70(%rsi), %rax
subq 0x68(%rsi), %rax
movq 0x70(%rdx), %rcx
subq 0x68(%rdx), %rcx
cmpq %rcx, %rax
jne 0x8fb7
movq %rdx, %r14
pushq $0xc
popq %rcx
cqto
idivq %rcx
cmpq $0x1, %rax
jbe 0x8fd6
movq %rsi, %r15
movq %rdi, -0x40(%rbp)
movq (%rsi), %rax
movq %rsi, %rdi
movq %rbx, %rsi
callq *0x8(%rax)
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x8(%rax)
movq 0x68(%r15), %rbx
movss (%rbx), %xmm0
movss %xmm0, -0x34(%rbp)
movq 0x68(%r14), %rax
movss (%rax), %xmm0
movss %xmm0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
pushq $0x1
popq %r13
xorl %r12d, %r12d
movq 0x70(%r15), %rax
subq %rbx, %rax
cqto
pushq $0xc
popq %rcx
idivq %rcx
cmpq %r13, %rax
jbe 0x8f0f
movq 0x80(%r15), %rax
movss (%rax,%r13,8), %xmm0
movq 0x80(%r14), %rax
movss %xmm0, -0x38(%rbp)
subss (%rax,%r13,8), %xmm0
andps 0x2441(%rip), %xmm0     # 0xb2f0
cvtss2sd %xmm0, %xmm0
ucomisd 0x23c5(%rip), %xmm0     # 0xb280
jbe 0x8ed8
movq 0x7104(%rip), %rdi      # 0xffc8
leaq 0x2d0d(%rip), %rsi      # 0xbbd8
callq 0x31a0
movq %rax, %rdi
callq 0x30d0
movss -0x34(%rbp), %xmm0
movss -0x38(%rbp), %xmm1
ucomiss %xmm1, %xmm0
movaps %xmm1, %xmm0
jbe 0x8ef4
movss %xmm0, -0x34(%rbp)
movl %r13d, %r12d
jmp 0x8f03
ucomiss -0x30(%rbp), %xmm0
jbe 0x8f03
movss %xmm0, -0x30(%rbp)
movl %r13d, -0x2c(%rbp)
incq %r13
movq 0x68(%r15), %rbx
jmp 0x8e71
movl $0x98, %edi
callq 0x31b0
movq %rax, %r13
movslq %r12d, %rax
imulq $0xc, %rax, %rdx
addq %rdx, %rbx
addq 0x68(%r14), %rdx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x6fce
movl $0x98, %edi
movq -0x40(%rbp), %r12
callq 0x31b0
movq %rax, %rbx
movslq -0x2c(%rbp), %rax
imulq $0xc, %rax, %rdx
movq 0x68(%r15), %rsi
addq %rdx, %rsi
addq 0x68(%r14), %rdx
movq %rbx, %rdi
callq 0x6fce
movl $0x3b449ba6, 0x3c(%r13) # imm = 0x3B449BA6
movq %r13, %rsi
addq $0x20, %rsi
movabsq $0x3ecccccd3ecccccd, %rax # imm = 0x3ECCCCCD3ECCCCCD
movq %rax, 0x20(%r13)
movl $0x3ecccccd, 0x28(%r13) # imm = 0x3ECCCCCD
movq %rbx, %rdi
addq $0x20, %rdi
callq 0x9994
movq %r12, %rdi
movq %r13, %rsi
callq 0x664c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x664c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b93(%rip), %rdi      # 0xbb51
leaq 0x255f(%rip), %rsi      # 0xb524
leaq 0x2bb2(%rip), %rcx      # 0xbb7e
movl $0x410, %edx            # imm = 0x410
callq 0x3110
leaq 0x2be2(%rip), %rdi      # 0xbbbf
leaq 0x2540(%rip), %rsi      # 0xb524
leaq 0x2b93(%rip), %rcx      # 0xbb7e
movl $0x411, %edx            # imm = 0x411
callq 0x3110
movq %rax, %r14
movq %rbx, %rdi
jmp 0x9003
movq %rax, %r14
movq %r13, %rdi
callq 0x3190
jmp 0x9013
jmp 0x9010
jmp 0x9010
jmp 0x9010
movq %rax, %r14
movq -0x40(%rbp), %rdi
callq 0x971e
movq %r14, %rdi
callq 0x3250