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

    /* Adjust z and radius as stacks are drawn. */

    double z0,z1;
    double r0,r1;

    /* Pre-computed circle */

    double *sint1,*cost1;
    double *sint2,*cost2;

    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSphere" );

    fghCircleTable(&sint1,&cost1,-slices);
    fghCircleTable(&sint2,&cost2,stacks*2);

    /* The top stack is covered with a triangle fan */

    z0 = 1.0;
    z1 = cost2[(stacks>0)?1:0];
    r0 = 0.0;
    r1 = sint2[(stacks>0)?1:0];

    glBegin(GL_TRIANGLE_FAN);

        glNormal3d(0,0,1);
        glVertex3d(0,0,radius);

        for (j=slices; j>=0; j--)
        {
            glNormal3d(cost1[j]*r1,        sint1[j]*r1,        z1       );
            glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
        }

    glEnd();

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

    for( i=1; i<stacks-1; i++ )
    {
        z0 = z1; z1 = cost2[i+1];
        r0 = r1; r1 = sint2[i+1];

        glBegin(GL_QUAD_STRIP);

            for(j=0; j<=slices; j++)
            {
                glNormal3d(cost1[j]*r1,        sint1[j]*r1,        z1       );
                glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
                glNormal3d(cost1[j]*r0,        sint1[j]*r0,        z0       );
                glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
            }

        glEnd();
    }

    /* The bottom stack is covered with a triangle fan */

    z0 = z1;
    r0 = r1;

    glBegin(GL_TRIANGLE_FAN);

        glNormal3d(0,0,-1);
        glVertex3d(0,0,-radius);

        for (j=0; j<=slices; j++)
        {
            glNormal3d(cost1[j]*r0,        sint1[j]*r0,        z0       );
            glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
        }

    glEnd();

    /* Release sin and cos tables */

    free(sint1);
    free(cost1);
    free(sint2);
    free(cost2);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebp
movl %edi, %r13d
movaps %xmm0, 0x20(%rsp)
leaq 0x72657(%rip), %rax     # 0x1331e0
cmpb $0x0, 0x1c(%rax)
jne 0xc0ba4
leaq 0x136d0(%rip), %rdi     # 0xd4266
leaq 0x25068(%rip), %rsi     # 0xe5c05
xorl %eax, %eax
callq 0xbad73
movl %r13d, %edx
negl %edx
leaq 0x70(%rsp), %r12
leaq 0x68(%rsp), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0xc0eee
leal (,%rbp,2), %edx
leaq 0x60(%rsp), %r14
leaq 0x58(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc0eee
movq (%rbx), %rcx
xorl %eax, %eax
testl %ebp, %ebp
setg %al
shll $0x3, %eax
movq %rcx, 0x40(%rsp)
movsd (%rcx,%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq (%r14), %rcx
movq %rcx, 0x38(%rsp)
movsd (%rcx,%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
pushq $0x6
popq %rdi
callq 0x21190
movsd 0x43fe(%rip), %xmm2     # 0xc5018
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21300
xorps %xmm0, %xmm0
xorpd %xmm1, %xmm1
movaps 0x20(%rsp), %xmm2
callq 0x21e80
movq (%r15), %r15
movq (%r12), %r12
movsd 0x8(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl %r13d, %ebx
testl %ebx, %ebx
js 0xc0cb6
movl %ebx, %r14d
movsd (%r15,%r14,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%r14,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21300
movsd (%r15,%r14,8), %xmm0
movsd 0x18(%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%r14,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e80
decl %ebx
jmp 0xc0c53
callq 0x21c60
decl %ebp
movslq %r13d, %r13
movslq %ebp, %rbx
pushq $0x1
popq %rax
cmpq %rbx, %rax
jge 0xc0e0b
leaq 0x1(%rax), %r14
movq 0x40(%rsp), %rcx
movsd 0x8(%rcx,%rax,8), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x38(%rsp), %rcx
movsd 0x8(%rcx,%rax,8), %xmm0
movsd %xmm0, 0x10(%rsp)
pushq $0x8
popq %rdi
callq 0x21190
movsd 0x30(%rsp), %xmm1
movapd 0x20(%rsp), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp)
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x48(%rsp)
xorl %ebp, %ebp
cmpq %r13, %rbp
jg 0xc0de6
movsd (%r15,%rbp,8), %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x30(%rsp), %xmm2
callq 0x21300
movsd (%r15,%rbp,8), %xmm0
movsd 0x10(%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%rbp,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x50(%rsp), %xmm2
callq 0x21e80
movsd (%r15,%rbp,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21300
movsd (%r15,%rbp,8), %xmm0
movsd 0x18(%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%rbp,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x48(%rsp), %xmm2
callq 0x21e80
incq %rbp
jmp 0xc0d25
callq 0x21c60
movq %r14, %rax
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0xc0cc6
pushq $0x6
popq %rdi
callq 0x21190
movsd 0x46b5(%rip), %xmm2     # 0xc54d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21300
movaps 0x4701(%rip), %xmm2     # 0xc5530
xorps 0x20(%rsp), %xmm2
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21e80
movsd 0x8(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
xorl %ebx, %ebx
cmpq %r13, %rbx
jg 0xc0eb7
movsd (%r15,%rbx,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21300
movsd (%r15,%rbx,8), %xmm0
movsd 0x18(%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%rbx,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e80
incq %rbx
jmp 0xc0e55
callq 0x21c60
movq %r12, %rdi
callq 0x21ad0
movq %r15, %rdi
callq 0x21ad0
movq 0x38(%rsp), %rdi
callq 0x21ad0
movq 0x40(%rsp), %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ad0