// File: /workspace/github_cpp_makefile_star2_O3/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 %edi, %r15d
cmpl $0x2, %esi
movl $0x1, %r12d
movl %esi, 0x10(%rsp)
cmovgel %esi, %r12d
movsd %xmm0, 0x18(%rsp)
mulsd %xmm0, %xmm0
movsd %xmm1, 0x30(%rsp)
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
leaq 0x6bb23(%rip), %rax     # 0x1421c0
cmpb $0x0, 0x1c(%rax)
jne 0xd66c4
leaq 0x12f0c(%rip), %rdi     # 0xe95b6
leaq 0x24901(%rip), %rsi     # 0xfafb2
xorl %eax, %eax
movsd %xmm1, 0x8(%rsp)
callq 0xcfe73
movsd 0x8(%rsp), %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movl %r15d, %edx
negl %edx
leaq 0x60(%rsp), %r14
leaq 0x58(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd62bb
movl $0x6, %edi
callq 0x21190
movsd 0x3dd3(%rip), %xmm2     # 0xda4d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x21e60
movq (%rbx), %rbx
movq (%r14), %r14
movq %r15, 0x20(%rsp)
testl %r15d, %r15d
movsd 0x18(%rsp), %xmm2
js 0xd6767
movq 0x20(%rsp), %rax
leal 0x1(%rax), %r15d
xorl %r13d, %r13d
movsd (%rbx,%r13,8), %xmm0
mulsd %xmm2, %xmm0
movsd (%r14,%r13,8), %xmm1
mulsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e60
movsd 0x18(%rsp), %xmm2
incq %r13
cmpq %r13, %r15
jne 0xd673c
movsd 0x30(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
callq 0x21c50
movl 0x10(%rsp), %ebp
cmpl $0x2, %ebp
jl 0xd68e1
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd 0x30(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm3
movapd %xmm3, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, 0x40(%rsp)
movq 0x20(%rsp), %r15
leal 0x1(%r15), %r12d
addl $-0x2, %ebp
xorpd %xmm2, %xmm2
xorl %r13d, %r13d
movsd %xmm1, 0x48(%rsp)
movapd %xmm1, %xmm4
movsd %xmm3, 0x10(%rsp)
movapd %xmm3, %xmm1
movsd %xmm2, 0x50(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm4, 0x8(%rsp)
movl $0x8, %edi
callq 0x21190
movsd 0x10(%rsp), %xmm0
subsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
testl %r15d, %r15d
movsd 0x28(%rsp), %xmm2
js 0xd689d
xorl %r15d, %r15d
movsd (%rbx,%r15,8), %xmm0
mulsd %xmm2, %xmm0
movsd (%r14,%r15,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x21310
movsd (%rbx,%r15,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r14,%r15,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x50(%rsp), %xmm2
callq 0x21e60
movsd (%rbx,%r15,8), %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r14,%r15,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21e60
movsd 0x28(%rsp), %xmm2
incq %r15
cmpq %r15, %r12
jne 0xd6826
movsd 0x48(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x21c50
movsd 0x18(%rsp), %xmm4
leal 0x1(%r13), %eax
movsd 0x8(%rsp), %xmm0
movapd %xmm0, %xmm2
movsd 0x10(%rsp), %xmm1
cmpl %ebp, %r13d
movl %eax, %r13d
movq 0x20(%rsp), %r15
jne 0xd67ea
jmp 0xd68f6
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x20(%rsp), %r15
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x4, %edi
callq 0x21190
movsd (%rbx), %xmm0
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r14), %xmm1
mulsd %xmm2, %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x21310
testl %r15d, %r15d
jle 0xd69ce
movl %r15d, %r15d
xorl %r12d, %r12d
movsd (%rbx,%r12,8), %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r14,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21e60
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movsd 0x30(%rsp), %xmm2
callq 0x21e60
leaq 0x1(%r12), %r13
movsd 0x8(%rbx,%r12,8), %xmm0
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x8(%r14,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x21310
movsd 0x8(%rbx,%r12,8), %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x8(%r14,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21e60
movq %r13, %r12
cmpq %r13, %r15
jne 0xd6937
callq 0x21c50
movq %r14, %rdi
callq 0x21ad0
movq %rbx, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ad0