// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/fglut/freeglut_geometry.c
// Function: glutSolidCone
void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLint stacks )
{
    int i,j;

    /* Step in z and radius as stacks are drawn. */

    double z0,z1;
    double r0,r1;

    const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
    const double rStep = base / ( ( stacks > 0 ) ? stacks : 1 );

    /* Scaling factors for vertex normals */

    const double cosn = ( height / sqrt ( height * height + base * base ));
    const double sinn = ( base   / sqrt ( height * height + base * base ));

    /* Pre-computed circle */

    double *sint,*cost;

    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCone" );

    fghCircleTable(&sint,&cost,-slices);

    /* Cover the circular base with a triangle fan... */

    z0 = 0.0;
    z1 = zStep;

    r0 = base;
    r1 = r0 - rStep;

    glBegin(GL_TRIANGLE_FAN);

        glNormal3d(0.0,0.0,-1.0);
        glVertex3d(0.0,0.0, z0 );

        for (j=0; j<=slices; j++)
            glVertex3d(cost[j]*r0, sint[j]*r0, z0);

    glEnd();

    /* Cover each stack with a quad strip, except the top stack */

    for( i=0; i<stacks-1; i++ )
    {
        glBegin(GL_QUAD_STRIP);

            for(j=0; j<=slices; j++)
            {
                glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
                glVertex3d(cost[j]*r0,   sint[j]*r0,   z0  );
                glVertex3d(cost[j]*r1,   sint[j]*r1,   z1  );
            }

            z0 = z1; z1 += zStep;
            r0 = r1; r1 -= rStep;

        glEnd();
    }

    /* The top stack is covered with individual triangles */

    glBegin(GL_TRIANGLES);

        glNormal3d(cost[0]*sinn, sint[0]*sinn, cosn);

        for (j=0; j<slices; j++)
        {
            glVertex3d(cost[j+0]*r0,   sint[j+0]*r0,   z0    );
            glVertex3d(0,              0,              height);
            glNormal3d(cost[j+1]*sinn, sint[j+1]*sinn, cosn  );
            glVertex3d(cost[j+1]*r0,   sint[j+1]*r0,   z0    );
        }

    glEnd();

    /* Release sin and cos tables */

    free(sint);
    free(cost);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebp
movl %edi, %ebx
cmpl $0x2, %esi
pushq $0x1
popq %r12
movl %r12d, %eax
cmovgel %esi, %eax
cvtsi2sd %eax, %xmm4
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm3
leaq 0x71f7c(%rip), %rax     # 0x1331e0
cmpb $0x0, 0x1c(%rax)
movsd %xmm1, 0x30(%rsp)
movsd %xmm0, 0x8(%rsp)
jne 0xc12af
leaq 0x12fe9(%rip), %rdi     # 0xd4266
leaq 0x2499e(%rip), %rsi     # 0xe5c22
xorl %eax, %eax
movsd %xmm4, 0x10(%rsp)
movsd %xmm3, 0x18(%rsp)
callq 0xbad73
movsd 0x18(%rsp), %xmm3
movsd 0x10(%rsp), %xmm4
movsd 0x8(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movapd %xmm1, %xmm2
divsd %xmm4, %xmm2
movsd %xmm2, 0x38(%rsp)
movapd %xmm0, %xmm2
divsd %xmm4, %xmm2
movsd %xmm2, 0x50(%rsp)
divsd %xmm3, %xmm1
movsd %xmm1, 0x28(%rsp)
divsd %xmm3, %xmm0
movsd %xmm0, 0x20(%rsp)
movl %ebx, %edx
negl %edx
leaq 0x60(%rsp), %r15
leaq 0x58(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0xc0eee
pushq $0x6
popq %rdi
callq 0x21190
movsd 0x41c8(%rip), %xmm2     # 0xc54d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21300
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e80
movq (%r14), %r14
movq (%r15), %r15
movq %rbx, 0x48(%rsp)
movslq %ebx, %r13
xorl %ebx, %ebx
cmpq %r13, %rbx
jg 0xc1363
movsd (%r14,%rbx,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e80
incq %rbx
jmp 0xc1336
callq 0x21c60
cmpl $0x2, %ebp
cmovgel %ebp, %r12d
decl %r12d
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x38(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
movsd %xmm1, 0x18(%rsp)
cmpl %r12d, %ebx
movsd %xmm0, 0x8(%rsp)
je 0xc1464
subsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
pushq $0x8
popq %rdi
callq 0x21190
xorl %ebp, %ebp
cmpq %r13, %rbp
jg 0xc142e
movsd (%r14,%rbp,8), %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x28(%rsp), %xmm2
callq 0x21300
movsd (%r14,%rbp,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e80
movsd (%r14,%rbp,8), %xmm0
movsd 0x40(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x18(%rsp), %xmm2
callq 0x21e80
incq %rbp
jmp 0xc13b5
movsd 0x38(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x21c60
movsd 0x8(%rsp), %xmm1
incl %ebx
movsd 0x40(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
movsd %xmm2, 0x10(%rsp)
jmp 0xc138a
pushq $0x4
popq %rdi
callq 0x21190
movsd (%r14), %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15), %xmm1
mulsd %xmm2, %xmm1
movsd 0x28(%rsp), %xmm2
callq 0x21300
xorl %ebx, %ebx
movq 0x48(%rsp), %r13
testl %r13d, %r13d
cmovlel %ebx, %r13d
cmpq %rbx, %r13
je 0xc1538
movsd (%r14,%rbx,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e80
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movsd 0x30(%rsp), %xmm2
callq 0x21e80
leaq 0x1(%rbx), %r12
movsd 0x8(%r14,%rbx,8), %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x8(%r15,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x28(%rsp), %xmm2
callq 0x21300
movsd 0x8(%r14,%rbx,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x8(%r15,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e80
movq %r12, %rbx
jmp 0xc149d
callq 0x21c60
movq %r15, %rdi
callq 0x21ad0
movq %r14, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ad0