// File: 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
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0xb5b0
movq -0x80(%rbp), %rax
leaq 0xc025(%rip), %rcx      # 0x1dad8
addq $0x10, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
callq 0x13790
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
callq 0x13790
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jne 0x11ae6
jmp 0x11b05
leaq 0x5fb0(%rip), %rdi      # 0x17a9d
leaq 0x597c(%rip), %rsi      # 0x17470
movl $0x410, %edx            # imm = 0x410
leaq 0x5fca(%rip), %rcx      # 0x17aca
callq 0x3100
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
callq 0x13790
movq %rax, %rcx
movl $0x1, %eax
cmpq %rcx, %rax
jae 0x11b21
jmp 0x11b40
leaq 0x5fe3(%rip), %rdi      # 0x17b0b
leaq 0x5941(%rip), %rsi      # 0x17470
movl $0x411, %edx            # imm = 0x411
leaq 0x5f8f(%rip), %rcx      # 0x17aca
callq 0x3100
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
jmp 0x11b53
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
jmp 0x11b66
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x13f10
movq %rax, %rdi
callq 0x93d0
movq %rax, -0x88(%rbp)
jmp 0x11b96
movq -0x88(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x13f10
movq %rax, %rdi
callq 0x93d0
movq %rax, -0x90(%rbp)
jmp 0x11bc8
movq -0x90(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x3c(%rbp)
movl $0x1, -0x40(%rbp)
movslq -0x40(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
callq 0x13790
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jae 0x11d3b
movq -0x10(%rbp), %rdi
subq $-0x80, %rdi
movslq -0x40(%rbp), %rsi
callq 0x137e0
movq %rax, %rdi
callq 0x13470
movq %rax, -0xa0(%rbp)
jmp 0x11c2c
movq -0xa0(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x44(%rbp)
movq -0x18(%rbp), %rdi
subq $-0x80, %rdi
movslq -0x40(%rbp), %rsi
callq 0x137e0
movq %rax, %rdi
callq 0x13470
movq %rax, -0xa8(%rbp)
jmp 0x11c5e
movq -0xa8(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x44(%rbp), %xmm0
movss -0x48(%rbp), %xmm1
subss %xmm1, %xmm0
callq 0x13f30
movss %xmm0, -0xac(%rbp)
jmp 0x11c8b
movss -0xac(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x5569(%rip), %xmm1     # 0x17208
ucomisd %xmm1, %xmm0
jbe 0x11ce9
movq 0xc314(%rip), %rdi      # 0x1dfc0
leaq 0x5e71(%rip), %rsi      # 0x17b24
callq 0x31a0
movq %rax, -0xb8(%rbp)
jmp 0x11cc1
movq -0xb8(%rbp), %rdi
movq 0xc2d9(%rip), %rsi      # 0x1dfa8
callq 0x31c0
jmp 0x11cd6
jmp 0x11ce9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x11eb2
movss -0x44(%rbp), %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x11d0a
movl -0x40(%rbp), %eax
movl %eax, -0x30(%rbp)
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
jmp 0x11d2b
movss -0x3c(%rbp), %xmm1
movss -0x44(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x11d29
movl -0x40(%rbp), %eax
movl %eax, -0x34(%rbp)
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
jmp 0x11d2b
jmp 0x11d2d
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x11bdf
movl $0x98, %edi
callq 0x31b0
movq %rax, -0xc0(%rbp)
jmp 0x11d4e
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movslq -0x30(%rbp), %rsi
callq 0x13f10
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
movslq -0x30(%rbp), %rsi
callq 0x13f10
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq %rax, %rdx
callq 0xcbb0
jmp 0x11d8f
movq -0xc0(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x98, %edi
callq 0x31b0
movq %rax, -0xd0(%rbp)
jmp 0x11dad
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
movslq -0x34(%rbp), %rsi
callq 0x13f10
movq %rax, -0xd8(%rbp)
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
movslq -0x34(%rbp), %rsi
callq 0x13f10
movq -0xd0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movq %rax, %rdx
callq 0xcbb0
jmp 0x11dee
movq -0xd0(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movl $0x3b449ba6, 0x3c(%rax) # imm = 0x3B449BA6
movl $0x3ecccccd, -0x68(%rbp) # imm = 0x3ECCCCCD
movl $0x3ecccccd, -0x6c(%rbp) # imm = 0x3ECCCCCD
movl $0x3ecccccd, -0x70(%rbp) # imm = 0x3ECCCCCD
leaq -0x64(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x6c(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x8c30
jmp 0x11e30
movq -0x50(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl %ecx, 0x28(%rax)
movq -0x64(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq -0x50(%rbp), %rsi
addq $0x20, %rsi
movq -0x58(%rbp), %rdi
addq $0x20, %rdi
callq 0x13f50
jmp 0x11e59
movq -0x80(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xb660
jmp 0x11e68
movq -0x80(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xb660
jmp 0x11e77
addq $0xe0, %rsp
popq %rbp
retq
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x3190
jmp 0x11eb2
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x3190
movq -0x80(%rbp), %rdi
callq 0xb5f0
movq -0x28(%rbp), %rdi
callq 0x3280
nopw %cs:(%rax,%rax)