// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/fglut/freeglut_geometry.c
// Function: glutWireTorus
void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings )
{
  double  iradius = dInnerRadius, oradius = dOuterRadius, phi, psi, dpsi, dphi;
  double *vertex, *normal;
  int    i, j;
  double spsi, cpsi, sphi, cphi ;

  FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTorus" );

  if ( nSides < 1 ) nSides = 1;
  if ( nRings < 1 ) nRings = 1;

  /* Allocate the vertices array */
  vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings );
  normal = (double *)calloc( sizeof(double), 3 * nSides * nRings );

  glPushMatrix();

  dpsi =  2.0 * M_PI / (double)nRings ;
  dphi = -2.0 * M_PI / (double)nSides ;
  psi  = 0.0;

  for( j=0; j<nRings; j++ )
  {
    cpsi = cos ( psi ) ;
    spsi = sin ( psi ) ;
    phi = 0.0;

    for( i=0; i<nSides; i++ )
    {
      int offset = 3 * ( j * nSides + i ) ;
      cphi = cos ( phi ) ;
      sphi = sin ( phi ) ;
      *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
      *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
      *(vertex + offset + 2) =                    sphi * iradius  ;
      *(normal + offset + 0) = cpsi * cphi ;
      *(normal + offset + 1) = spsi * cphi ;
      *(normal + offset + 2) =        sphi ;
      phi += dphi;
    }

    psi += dpsi;
  }

  for( i=0; i<nSides; i++ )
  {
    glBegin( GL_LINE_LOOP );

    for( j=0; j<nRings; j++ )
    {
      int offset = 3 * ( j * nSides + i ) ;
      glNormal3dv( normal + offset );
      glVertex3dv( vertex + offset );
    }

    glEnd();
  }

  for( j=0; j<nRings; j++ )
  {
    glBegin(GL_LINE_LOOP);

    for( i=0; i<nSides; i++ )
    {
      int offset = 3 * ( j * nSides + i ) ;
      glNormal3dv( normal + offset );
      glVertex3dv( vertex + offset );
    }

    glEnd();
  }

  free ( vertex ) ;
  free ( normal ) ;
  glPopMatrix();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebp
movl %edi, %ebx
movsd %xmm1, 0x58(%rsp)
movsd %xmm0, 0x50(%rsp)
leaq 0x6b140(%rip), %rax     # 0x1421c0
cmpb $0x0, 0x1c(%rax)
jne 0xd709b
leaq 0x12529(%rip), %rdi     # 0xe95b6
leaq 0x23f47(%rip), %rsi     # 0xfafdb
xorl %eax, %eax
callq 0xcfe73
cmpl $0x2, %ebx
movl $0x1, %r14d
cmovll %r14d, %ebx
cmpl $0x2, %ebp
cmovgel %ebp, %r14d
movl %ebx, %eax
imull %r14d, %eax
leal (%rax,%rax,2), %r15d
movl $0x8, %edi
movq %r15, %rsi
callq 0x21600
movq %rax, %r13
movl $0x8, %edi
movq %r15, %rsi
callq 0x21600
movq %rax, %r12
callq 0x21f50
movq %r14, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd 0x6cbd(%rip), %xmm1     # 0xdddb0
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, 0x40(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x48(%rsp)
movq %r12, 0x8(%rsp)
addq $0x10, %r12
movq %rbx, 0x20(%rsp)
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rbp
movq %r13, 0x10(%rsp)
addq $0x10, %r13
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
movsd %xmm0, 0x28(%rsp)
callq 0x221d0
movapd %xmm0, 0x30(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x21170
movaps 0x30(%rsp), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movaps %xmm1, 0x30(%rsp)
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
callq 0x221d0
movaps %xmm0, 0x60(%rsp)
movsd (%rsp), %xmm0
callq 0x21170
movapd 0x60(%rsp), %xmm4
movapd %xmm4, %xmm1
movsd 0x50(%rsp), %xmm3
mulsd %xmm3, %xmm1
addsd 0x58(%rsp), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
movapd 0x30(%rsp), %xmm2
mulpd %xmm2, %xmm1
movupd %xmm1, -0x10(%r13,%rbx)
movapd %xmm4, %xmm1
unpcklpd %xmm4, %xmm1            # xmm1 = xmm1[0],xmm4[0]
mulpd %xmm2, %xmm1
movupd %xmm1, -0x10(%r12,%rbx)
movsd %xmm0, (%r12,%rbx)
mulsd %xmm3, %xmm0
movsd %xmm0, (%r13,%rbx)
movsd (%rsp), %xmm0
subsd 0x48(%rsp), %xmm0
addq $0x18, %rbx
cmpq %rbx, %rbp
jne 0xd716a
movsd 0x28(%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
incq %r15
addq %rbp, %r12
addq %rbp, %r13
cmpq 0x18(%rsp), %r15
jne 0xd713c
xorl %eax, %eax
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
movq %rax, (%rsp)
movl $0x2, %edi
callq 0x21190
movq 0x18(%rsp), %r15
movq %rbx, %r12
movq %r14, %r13
movq %r12, %rdi
callq 0x21e00
movq %r13, %rdi
callq 0x211b0
addq %rbp, %r13
addq %rbp, %r12
decq %r15
jne 0xd7238
callq 0x21c50
movq (%rsp), %rax
incq %rax
addq $0x18, %r14
addq $0x18, %rbx
cmpq 0x20(%rsp), %rax
jne 0xd721f
xorl %eax, %eax
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
movq %rax, (%rsp)
movl $0x2, %edi
callq 0x21190
movq 0x20(%rsp), %r15
movq %rbx, %r12
movq %r14, %r13
movq %r12, %rdi
callq 0x21e00
movq %r13, %rdi
callq 0x211b0
addq $0x18, %r13
addq $0x18, %r12
decq %r15
jne 0xd7293
callq 0x21c50
movq (%rsp), %rax
incq %rax
addq %rbp, %r14
addq %rbp, %rbx
cmpq 0x18(%rsp), %rax
jne 0xd727a
movq 0x10(%rsp), %rdi
callq 0x21ad0
movq 0x8(%rsp), %rdi
callq 0x21ad0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x221c0