// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movq %rcx, %rbx
movb $0x0, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movq $0x0, 0x30(%rdi)
leaq 0x6afe(%rip), %rax      # 0x11b00
movq %rdi, -0x48(%rbp)
movq %rax, (%rdi)
movq 0x70(%rsi), %rax
subq 0x68(%rsi), %rax
movq 0x70(%rdx), %rcx
subq 0x68(%rdx), %rcx
cmpq %rcx, %rax
jne 0xb286
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq $0x1, %rax
jbe 0xb2a5
movq %rdx, %r14
movq %rsi, %r15
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
movq 0x70(%r15), %rax
subq %rbx, %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
movq $0x0, -0x40(%rbp)
cmpq $0x2, %rax
jb 0xb18f
movq 0x68(%r14), %rax
movss (%rax), %xmm0
movss %xmm0, -0x30(%rbp)
movq 0x68(%r15), %rax
movss (%rax), %xmm0
movss %xmm0, -0x34(%rbp)
movl $0x1, %r13d
movq 0x6f1e(%rip), %r12      # 0x11fd0
movl $0x0, -0x2c(%rbp)
movq 0x80(%r15), %rax
movss (%rax,%r13,8), %xmm0
movq 0x80(%r14), %rax
movss %xmm0, -0x4c(%rbp)
subss (%rax,%r13,8), %xmm0
andps 0x21a1(%rip), %xmm0     # 0xd280
cvtss2sd %xmm0, %xmm0
ucomisd 0x211d(%rip), %xmm0     # 0xd208
jbe 0xb129
movl $0x2b, %edx
movq %r12, %rdi
leaq 0x2a68(%rip), %rsi      # 0xdb64
callq 0x31e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movss -0x34(%rbp), %xmm0
movss -0x4c(%rbp), %xmm1
ucomiss %xmm1, %xmm0
movaps %xmm1, %xmm0
jbe 0xb149
movss %xmm0, -0x34(%rbp)
movl %r13d, %eax
movq %rax, -0x40(%rbp)
jmp 0xb158
ucomiss -0x30(%rbp), %xmm0
jbe 0xb158
movss %xmm0, -0x30(%rbp)
movl %r13d, -0x2c(%rbp)
incq %r13
movq 0x68(%r15), %rbx
movq 0x70(%r15), %rax
subq %rbx, %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %r13, %rax
ja 0xb0b9
movslq -0x40(%rbp), %r13
movslq -0x2c(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xb192
xorl %r13d, %r13d
movl $0x98, %edi
callq 0x31d0
movq %rax, %r12
shlq $0x2, %r13
leaq (,%r13,2), %rdx
addq %r13, %rdx
addq %rdx, %rbx
addq 0x68(%r14), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8454
movl $0x98, %edi
callq 0x31d0
movq %rax, %r13
movq -0x40(%rbp), %rax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rdx
movq 0x68(%r15), %rsi
addq %rdx, %rsi
addq 0x68(%r14), %rdx
movq %r13, %rdi
callq 0x8454
movl $0x3b449ba6, 0x3c(%r12) # imm = 0x3B449BA6
movabsq $0x3ecccccd3ecccccd, %rax # imm = 0x3ECCCCCD3ECCCCCD
movq %rax, 0x20(%r12)
movl $0x3ecccccd, 0x28(%r12) # imm = 0x3ECCCCCD
movq 0x3e(%r12), %rax
movq %rax, 0x3e(%r13)
movq 0x30(%r12), %rax
movq %rax, 0x30(%r13)
movl 0x38(%r12), %eax
movl %eax, 0x38(%r13)
movl 0x3c(%r12), %eax
movl %eax, 0x3c(%r13)
movq 0x20(%r12), %rax
movq %rax, 0x20(%r13)
movl 0x28(%r12), %eax
movl %eax, 0x28(%r13)
movl 0x2c(%r12), %eax
movl %eax, 0x2c(%r13)
movq %r13, %rdi
addq $0x48, %rdi
movq %r12, %rsi
addq $0x48, %rsi
callq 0x3100
movq -0x48(%rbp), %rdi
movq %r12, %rsi
callq 0x7568
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x7568
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2850(%rip), %rdi      # 0xdadd
leaq 0x221c(%rip), %rsi      # 0xd4b0
leaq 0x286f(%rip), %rcx      # 0xdb0a
movl $0x410, %edx            # imm = 0x410
callq 0x3120
leaq 0x289f(%rip), %rdi      # 0xdb4b
leaq 0x21fd(%rip), %rsi      # 0xd4b0
leaq 0x2850(%rip), %rcx      # 0xdb0a
movl $0x411, %edx            # imm = 0x411
callq 0x3120
movq %rax, %rbx
movq %r13, %rdi
jmp 0xb2d2
movq %rax, %rbx
movq %r12, %rdi
callq 0x31a0
jmp 0xb2e2
jmp 0xb2df
jmp 0xb2df
jmp 0xb2df
movq %rax, %rbx
leaq 0x64a7(%rip), %rax      # 0x11790
movq -0x48(%rbp), %rcx
movq %rax, (%rcx)
movq 0x20(%rcx), %rdi
testq %rdi, %rdi
je 0xb2fe
callq 0x31a0
movq %rbx, %rdi
callq 0x32b0