// File: /workspace/github_cpp_makefile_star2_O2/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 0x71637(%rip), %rax     # 0x1331e0
cmpb $0x0, 0x1c(%rax)
jne 0xc1bc4
leaq 0x126b0(%rip), %rdi     # 0xd4266
leaq 0x2408e(%rip), %rsi     # 0xe5c4b
xorl %eax, %eax
callq 0xbad73
cmpl $0x2, %ebx
pushq $0x1
popq %r14
cmovll %r14d, %ebx
cmpl $0x2, %ebp
cmovgel %ebp, %r14d
movl %ebx, %eax
imull %r14d, %eax
leal (%rax,%rax,2), %r15d
pushq $0x8
popq %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x21600
movq %rax, %r13
movq %r12, %rdi
movq %r15, %rsi
callq 0x21600
movq %rax, %r12
callq 0x21f70
movq %r14, 0x18(%rsp)
cvtsi2sd %r14d, %xmm0
movsd 0x7121(%rip), %xmm1     # 0xc8d38
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, 0x40(%rsp)
cvtsi2sd %ebx, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x48(%rsp)
movq %rbx, 0x20(%rsp)
imulq $0x18, %rbx, %r15
movq %r12, 0x8(%rsp)
addq $0x10, %r12
movq %r13, 0x10(%rsp)
addq $0x10, %r13
xorpd %xmm0, %xmm0
xorl %ebp, %ebp
cmpq 0x18(%rsp), %rbp
je 0xc1d39
movsd %xmm0, 0x28(%rsp)
callq 0x221f0
movapd %xmm0, 0x30(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x21170
movapd 0x30(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, 0x30(%rsp)
xorpd %xmm0, %xmm0
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0xc1d1f
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
callq 0x221f0
movaps %xmm0, 0x60(%rsp)
movsd (%rsp), %xmm0
callq 0x21170
movapd 0x60(%rsp), %xmm4
movapd %xmm4, %xmm1
movsd 0x50(%rsp), %xmm2
mulsd %xmm2, %xmm1
addsd 0x58(%rsp), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
movapd 0x30(%rsp), %xmm3
mulpd %xmm3, %xmm1
movupd %xmm1, -0x10(%r13,%rbx)
movapd %xmm4, %xmm1
unpcklpd %xmm4, %xmm1            # xmm1 = xmm1[0],xmm4[0]
mulpd %xmm3, %xmm1
movupd %xmm1, -0x10(%r12,%rbx)
movsd %xmm0, (%r12,%rbx)
mulsd %xmm2, %xmm0
movsd %xmm0, (%r13,%rbx)
movsd (%rsp), %xmm0
subsd 0x48(%rsp), %xmm0
addq $0x18, %rbx
jmp 0xc1c91
movsd 0x28(%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
incq %rbp
addq %r15, %r12
addq %r15, %r13
jmp 0xc1c54
xorl %eax, %eax
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
cmpq 0x20(%rsp), %rax
je 0xc1d97
movq %rax, (%rsp)
pushq $0x2
popq %rdi
callq 0x21190
movq %rbx, %r12
movq %r14, %r13
movq 0x18(%rsp), %rbp
subq $0x1, %rbp
jb 0xc1d81
movq %r12, %rdi
callq 0x21e20
movq %r13, %rdi
callq 0x211b0
addq %r15, %r13
addq %r15, %r12
jmp 0xc1d63
callq 0x21c60
movq (%rsp), %rax
incq %rax
addq $0x18, %r14
addq $0x18, %rbx
jmp 0xc1d45
xorl %eax, %eax
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
cmpq 0x18(%rsp), %rax
je 0xc1df5
movq %rax, (%rsp)
pushq $0x2
popq %rdi
callq 0x21190
movq %rbx, %r12
movq %r14, %r13
movq 0x20(%rsp), %rbp
subq $0x1, %rbp
jb 0xc1de1
movq %r12, %rdi
callq 0x21e20
movq %r13, %rdi
callq 0x211b0
addq $0x18, %r13
addq $0x18, %r12
jmp 0xc1dc1
callq 0x21c60
movq (%rsp), %rax
incq %rax
addq %r15, %r14
addq %r15, %rbx
jmp 0xc1da3
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 0x221e0