// File: /workspace/github_cpp_makefile_star2_O3/carlos-urena[P]svg-gen/svgobjects.cpp
// Function: ZCylinderPolygonWithSector::ZCylinderPolygonWithSector(Polygon const&, float, float, float, float)
ZCylinderPolygonWithSector::ZCylinderPolygonWithSector( const Polygon & orig,
                                                         real ang0, real ang1,
                                                         real lonX, real lonY  )
{
   style.draw_lines   = true ;
   style.draw_filled  = false ;
   style.close_lines  = true ;
   style.lines_width  = 0.015 ;
   style.fill_opacity = 0.2 ;
   style.lines_color  = vec3( 1.0, 0.0, 0.0 );
   style.fill_color   = vec3( 1.0, 0.0, 0.0 );

   assert( orig.points3D.size() > 0 );
   for( unsigned i = 0 ; i < orig.points3D.size() ; i++ )
   {

      const vec3 porig = orig.points3D[i] ;
      const vec3 pesf  = porig.normalized();
      const real len   = real(sqrt( double( pesf[0]*pesf[0]+pesf[1]*pesf[1] ))) ;

      if ( len > 1e-6 )
      {
         const real f    = real(1.0)/len;
         const vec3 pcil = vec3(  f*pesf[0], f*pesf[1], pesf[2]) ;
         points3D.push_back( pcil );
      }
      else
      {
         using namespace std ;
         cout << "porig.length() == " << porig.length() << endl ;
      }
  }

  // añadir el sector

  using namespace std ;

  vec2 p0 = vec2( lonX*cos(ang0), lonY*sin(ang0)),
       p1 = vec2( lonX*cos(ang1), lonY*sin(ang1));


  cout << "ang1 == " << ang1/M_PI  << "*pi, ang0 == " << ang0/M_PI << "*pi " << endl ;

  real ang0corr = atan2( p0[1], p0[0] ),
       ang1corr = atan2( p1[1], p1[0] );
  cout << "ang1 (c) == " << ang1corr/M_PI  << "*pi, ang0 (c) == " << ang0corr/M_PI << "*pi " << endl ;
  // insertar points en el borde del cilindro, desde ang1 (incluido) hasta ang0 (sin incluir)

  if (ang1corr < ang0corr ) ang1corr += 2.0*M_PI ; // corrige ang1 para saltar discontinuidades de atan2, por si acaso ;
  assert( ang0corr < ang1corr ); // check

  const int nump = points3D.size() ;

  for( int i = nump ; 0 <= i ; i-- )
  {
    const real ang = ang0corr + (ang1corr-ang0corr)*real(i)/real(nump) ;
    points3D.push_back( vec3( cos(ang), sin(ang), 1.0 ) );
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movss %xmm3, -0x2c(%rbp)
movss %xmm2, -0x7c(%rbp)
movss %xmm1, -0x60(%rbp)
movss %xmm0, -0x48(%rbp)
movq %rsi, %r15
movq %rdi, %rbx
xorl %r12d, %r12d
movb %r12b, 0x8(%rdi)
leaq 0x6131(%rip), %rax      # 0x11760
movq %rax, (%rdi)
addq $0x20, %rdi
callq 0x6c64
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rbx)
movups %xmm0, 0x78(%rbx)
movups %xmm0, 0x68(%rbx)
leaq 0x656c(%rip), %rax      # 0x11bc0
movq %rax, (%rbx)
movw $0x101, 0x38(%rbx)      # imm = 0x101
movb %r12b, 0x3a(%rbx)
movabsq $0x3e4ccccd3c75c28f, %rax # imm = 0x3E4CCCCD3C75C28F
movq %rax, 0x3c(%rbx)
movapd 0x1bf9(%rip), %xmm0     # 0xd270
movupd %xmm0, 0x20(%rbx)
movq $0x0, 0x30(%rbx)
movq 0x68(%r15), %rax
cmpq %rax, 0x70(%r15)
je 0xbb34
leaq 0x68(%rbx), %rcx
movq %rcx, -0x90(%rbp)
movq 0x692c(%rip), %r13      # 0x11fd0
leaq (%r12,%r12,2), %rcx
movl 0x8(%rax,%rcx,4), %edx
movl %edx, -0x80(%rbp)
movq (%rax,%rcx,4), %rax
movq %rax, -0x88(%rbp)
xorpd %xmm0, %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
cvtss2sd -0x88(%rbp,%rax,4), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq $0x3, %rax
jne 0xb6c0
cvtsd2ss %xmm0, %xmm0
ucomiss 0x1bc4(%rip), %xmm0     # 0xd2ac
jb 0xb6f0
sqrtss %xmm0, %xmm0
jmp 0xb6f5
callq 0x32d0
xorl %eax, %eax
movss -0x88(%rbp,%rax,4), %xmm1
divss %xmm0, %xmm1
movss %xmm1, -0x40(%rbp,%rax,4)
incq %rax
cmpq $0x3, %rax
jne 0xb6f7
movsd -0x40(%rbp), %xmm0
movaps %xmm0, %xmm1
shufps $0x55, %xmm0, %xmm1     # xmm1 = xmm1[1,1],xmm0[1,1]
movaps %xmm1, %xmm2
mulss %xmm1, %xmm2
movaps %xmm0, %xmm3
mulss %xmm0, %xmm3
addss %xmm2, %xmm3
xorps %xmm2, %xmm2
sqrtss %xmm3, %xmm2
xorps %xmm3, %xmm3
cvtss2sd %xmm2, %xmm3
ucomisd 0x1ac1(%rip), %xmm3     # 0xd208
jbe 0xb796
movss -0x38(%rbp), %xmm3
movss 0x18b2(%rip), %xmm4     # 0xd008
divss %xmm2, %xmm4
mulss %xmm4, %xmm0
mulss %xmm1, %xmm4
movss %xmm0, -0x40(%rbp)
movss %xmm4, -0x3c(%rbp)
movss %xmm3, -0x38(%rbp)
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0xb81c
movl -0x38(%rbp), %eax
movl %eax, 0x8(%rsi)
movq -0x40(%rbp), %rax
movq %rax, (%rsi)
addq $0xc, 0x70(%rbx)
jmp 0xb82c
movl $0x12, %edx
movq %r13, %rdi
leaq 0x24ee(%rip), %rsi      # 0xdc93
callq 0x31e0
xorps %xmm0, %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
cvtss2sd -0x88(%rbp,%rax,4), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq $0x3, %rax
jne 0xb7af
cvtsd2ss %xmm0, %xmm0
ucomiss 0x1ad5(%rip), %xmm0     # 0xd2ac
jb 0xb7df
sqrtss %xmm0, %xmm0
jmp 0xb7e4
callq 0x32d0
cvtss2sd %xmm0, %xmm0
movq %r13, %rdi
callq 0x3250
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0xb82c
movq -0x90(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0xc3cc
incl %r12d
movq 0x68(%r15), %rax
movq 0x70(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %r12, %rcx
ja 0xb6a4
movss -0x48(%rbp), %xmm0
callq 0x3150
movss %xmm0, -0x78(%rbp)
movss -0x48(%rbp), %xmm0
callq 0x3180
movss %xmm0, -0x74(%rbp)
movss -0x60(%rbp), %xmm0
callq 0x3150
movss %xmm0, -0x70(%rbp)
movss -0x60(%rbp), %xmm0
callq 0x3180
movss %xmm0, -0x30(%rbp)
movq 0x6738(%rip), %rdi      # 0x11fd0
leaq 0x2407(%rip), %rsi      # 0xdca6
movl $0x8, %edx
callq 0x31e0
xorps %xmm0, %xmm0
cvtss2sd -0x60(%rbp), %xmm0
divsd 0x192f(%rip), %xmm0     # 0xd1e8
movq 0x6710(%rip), %rdi      # 0x11fd0
callq 0x3250
movq %rax, %r15
leaq 0x23e0(%rip), %rsi      # 0xdcaf
movl $0xd, %edx
movq %rax, %rdi
callq 0x31e0
xorps %xmm0, %xmm0
cvtss2sd -0x48(%rbp), %xmm0
divsd 0x18fc(%rip), %xmm0     # 0xd1e8
movq %r15, %rdi
callq 0x3250
movq %rax, %r15
leaq 0x23bf(%rip), %rsi      # 0xdcbd
movl $0x4, %edx
movq %rax, %rdi
callq 0x31e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movss -0x7c(%rbp), %xmm2
movss -0x78(%rbp), %xmm1
mulss %xmm2, %xmm1
movss -0x2c(%rbp), %xmm3
movss -0x74(%rbp), %xmm0
mulss %xmm3, %xmm0
movss -0x70(%rbp), %xmm4
mulss %xmm2, %xmm4
movss %xmm4, -0x70(%rbp)
movss -0x30(%rbp), %xmm2
mulss %xmm3, %xmm2
movss %xmm2, -0x30(%rbp)
callq 0x3200
movss %xmm0, -0x2c(%rbp)
movss -0x30(%rbp), %xmm0
movss -0x70(%rbp), %xmm1
callq 0x3200
movapd %xmm0, -0x60(%rbp)
movq 0x6641(%rip), %rdi      # 0x11fd0
leaq 0x232c(%rip), %rsi      # 0xdcc2
movl $0xc, %edx
callq 0x31e0
movq -0x90(%rbp), %r12
xorps %xmm0, %xmm0
cvtss2sd -0x60(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
divsd 0x182c(%rip), %xmm0     # 0xd1e8
movq 0x660d(%rip), %rdi      # 0x11fd0
callq 0x3250
movq %rax, %r15
leaq 0x22fd(%rip), %rsi      # 0xdccf
movl $0x11, %edx
movq %rax, %rdi
callq 0x31e0
xorps %xmm0, %xmm0
cvtss2sd -0x2c(%rbp), %xmm0
divsd 0x17f9(%rip), %xmm0     # 0xd1e8
movq %r15, %rdi
callq 0x3250
movq %rax, %r15
leaq 0x22bc(%rip), %rsi      # 0xdcbd
movl $0x4, %edx
movq %rax, %rdi
callq 0x31e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movsd -0x48(%rbp), %xmm0
addsd 0x17ce(%rip), %xmm0     # 0xd210
cvtsd2ss %xmm0, %xmm0
movaps -0x60(%rbp), %xmm3
movaps %xmm3, %xmm4
movss -0x2c(%rbp), %xmm2
cmpltss %xmm2, %xmm4
movaps %xmm4, %xmm1
andnps %xmm3, %xmm1
andps %xmm0, %xmm4
orps %xmm1, %xmm4
movaps %xmm4, -0x70(%rbp)
ucomiss %xmm2, %xmm4
jbe 0xbb53
movq 0x70(%rbx), %rax
subq 0x68(%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %r14d # imm = 0xAAAAAAAB
testl %r14d, %r14d
js 0xbb25
movaps -0x70(%rbp), %xmm0
subss -0x2c(%rbp), %xmm0
movaps %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, -0x30(%rbp)
leaq -0x40(%rbp), %r15
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
mulss -0x70(%rbp), %xmm0
divss -0x30(%rbp), %xmm0
addss -0x2c(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
callq 0x3150
movss %xmm0, -0x60(%rbp)
movss -0x48(%rbp), %xmm0
callq 0x3180
movss -0x60(%rbp), %xmm1
movss %xmm1, -0x40(%rbp)
movss %xmm0, -0x3c(%rbp)
movl $0x3f800000, -0x38(%rbp) # imm = 0x3F800000
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0xbb0e
movl -0x38(%rbp), %eax
movl %eax, 0x8(%rsi)
movq -0x40(%rbp), %rax
movq %rax, (%rsi)
addq $0xc, 0x70(%rbx)
jmp 0xbb19
movq %r12, %rdi
movq %r15, %rdx
callq 0xc244
leal -0x1(%r14), %eax
testl %r14d, %r14d
movl %eax, %r14d
jg 0xbaaa
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f1d(%rip), %rdi      # 0xda58
leaq 0x196e(%rip), %rsi      # 0xd4b0
leaq 0x20ea(%rip), %rcx      # 0xdc33
movl $0x48c, %edx            # imm = 0x48C
callq 0x3120
leaq 0x2187(%rip), %rdi      # 0xdce1
leaq 0x194f(%rip), %rsi      # 0xd4b0
leaq 0x20cb(%rip), %rcx      # 0xdc33
movl $0x4b1, %edx            # imm = 0x4B1
callq 0x3120
jmp 0xbb7a
jmp 0xbb7a
jmp 0xbb7a
jmp 0xbb7a
movq %rax, %r14
movq %rbx, %rdi
callq 0xbbb4
movq %r14, %rdi
callq 0x32b0
nop