// File: /workspace/github_cpp_makefile_star2_O1/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, %ebx
cmpl $0x2, %esi
movl $0x1, %r14d
movl %esi, 0x20(%rsp)
cmovgel %esi, %r14d
movsd %xmm0, 0x18(%rsp)
mulsd %xmm0, %xmm0
movsd %xmm1, 0x30(%rsp)
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
movsd %xmm0, 0x8(%rsp)
jae 0xd85ed
movapd %xmm1, %xmm0
movsd %xmm1, 0x10(%rsp)
callq 0x216c0
xorpd %xmm2, %xmm2
movsd 0x10(%rsp), %xmm1
movsd %xmm0, 0x10(%rsp)
ucomisd %xmm2, %xmm1
jae 0xd8608
movapd %xmm1, %xmm0
callq 0x216c0
movsd %xmm0, 0x8(%rsp)
leaq 0x6bbb1(%rip), %rax     # 0x1441c0
cmpb $0x0, 0x1c(%rax)
jne 0xd862a
leaq 0x12f4a(%rip), %rdi     # 0xeb566
leaq 0x2493f(%rip), %rsi     # 0xfcf62
xorl %eax, %eax
callq 0xd1cf7
movl %ebx, %edx
negl %edx
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xd81be
movl $0x6, %edi
callq 0x21190
movsd 0x3e81(%rip), %xmm2     # 0xdc4d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x21e70
movq %rbx, 0x28(%rsp)
testl %ebx, %ebx
movsd 0x18(%rsp), %xmm2
js 0xd86bc
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
movq 0x28(%rsp), %rax
leal 0x1(%rax), %r12d
xorl %r13d, %r13d
movsd (%rbx,%r13,8), %xmm0
mulsd %xmm2, %xmm0
movsd (%r15,%r13,8), %xmm1
mulsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e70
movsd 0x18(%rsp), %xmm2
incq %r13
cmpq %r13, %r12
jne 0xd8691
movsd 0x30(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movapd %xmm2, %xmm0
divsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
callq 0x21c60
movl 0x20(%rsp), %ebp
cmpl $0x2, %ebp
jl 0xd883c
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd 0x30(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm3
movapd %xmm3, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, 0x50(%rsp)
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %r15
movq 0x28(%rsp), %rbx
leal 0x1(%rbx), %r12d
addl $-0x2, %ebp
xorpd %xmm2, %xmm2
xorl %r13d, %r13d
movsd %xmm1, 0x58(%rsp)
movapd %xmm1, %xmm4
movsd %xmm3, 0x8(%rsp)
movapd %xmm3, %xmm1
movsd %xmm2, 0x60(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm4, 0x20(%rsp)
movl $0x8, %edi
callq 0x21190
movsd 0x8(%rsp), %xmm0
subsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
testl %ebx, %ebx
movsd 0x10(%rsp), %xmm2
js 0xd87f8
xorl %ebx, %ebx
movsd (%r14,%rbx,8), %xmm0
mulsd %xmm2, %xmm0
movsd (%r15,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x21310
movsd (%r14,%rbx,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x60(%rsp), %xmm2
callq 0x21e70
movsd (%r14,%rbx,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x21e70
movsd 0x10(%rsp), %xmm2
incq %rbx
cmpq %rbx, %r12
jne 0xd8781
movsd 0x58(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x21c60
movsd 0x18(%rsp), %xmm4
leal 0x1(%r13), %eax
movsd 0x20(%rsp), %xmm0
movapd %xmm0, %xmm2
movsd 0x8(%rsp), %xmm1
cmpl %ebp, %r13d
movl %eax, %r13d
movq 0x28(%rsp), %rbx
jne 0xd8747
jmp 0xd8851
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x28(%rsp), %rbx
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movl $0x4, %edi
callq 0x21190
movq 0x40(%rsp), %r14
movsd (%r14), %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
movq 0x48(%rsp), %r15
movsd (%r15), %xmm1
mulsd %xmm2, %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x21310
testl %ebx, %ebx
jle 0xd8932
movl %ebx, %ebx
xorl %r12d, %r12d
movsd (%r14,%r12,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x21e70
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movsd 0x30(%rsp), %xmm2
callq 0x21e70
leaq 0x1(%r12), %r13
movsd 0x8(%r14,%r12,8), %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x8(%r15,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x21310
movsd 0x8(%r14,%r12,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x8(%r15,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x21e70
movq %r13, %r12
cmpq %r13, %rbx
jne 0xd889b
callq 0x21c60
movq %r15, %rdi
callq 0x21ae0
movq %r14, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ae0