// File: /workspace/github_cpp_makefile_star2_O3/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, %ebx
movaps %xmm0, 0x20(%rsp)
leaq 0x6c2a9(%rip), %rax     # 0x1421c0
cmpb $0x0, 0x1c(%rax)
jne 0xd5f32
leaq 0x13692(%rip), %rdi     # 0xe95b6
leaq 0x2506a(%rip), %rsi     # 0xfaf95
xorl %eax, %eax
callq 0xcfe73
movl %ebx, %edx
negl %edx
leaq 0x70(%rsp), %r12
leaq 0x58(%rsp), %rsi
movq %r12, %rdi
callq 0xd62bb
leal (,%rbp,2), %edx
leaq 0x68(%rsp), %r15
leaq 0x60(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0xd62bb
movq (%r14), %rcx
xorl %eax, %eax
testl %ebp, %ebp
setg %al
shll $0x3, %eax
movq %rcx, 0x40(%rsp)
movsd (%rcx,%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq (%r15), %rcx
movq %rcx, 0x38(%rsp)
movsd (%rcx,%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x6, %edi
callq 0x21190
movsd 0x4072(%rip), %xmm2     # 0xda018
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movaps 0x20(%rsp), %xmm2
callq 0x21e60
movq (%r12), %r13
leaq 0x58(%rsp), %rax
movq (%rax), %r12
testl %ebx, %ebx
js 0xd6048
movsd 0x10(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rsp)
movl %ebx, %r14d
movsd (%r12,%r14,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r13,%r14,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21310
movsd (%r12,%r14,8), %xmm0
movsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r13,%r14,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd (%rsp), %xmm2
callq 0x21e60
addq $-0x1, %r14
jb 0xd5fe9
callq 0x21c50
cmpl $0x3, %ebp
movq %rbx, 0x30(%rsp)
jl 0xd61b5
decl %ebp
leal 0x1(%rbx), %r14d
movl $0x1, %r15d
movq %rbp, %rbx
movq 0x40(%rsp), %rax
movsd 0x8(%rax,%r15,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x38(%rsp), %rax
movsd 0x8(%rax,%r15,8), %xmm0
movsd %xmm0, (%rsp)
movl $0x8, %edi
callq 0x21190
cmpl $0x0, 0x30(%rsp)
js 0xd6188
movsd 0x18(%rsp), %xmm1
movapd 0x20(%rsp), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp)
movsd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x48(%rsp)
xorl %ebp, %ebp
movsd (%r12,%rbp,8), %xmm0
movsd (%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r13,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x18(%rsp), %xmm2
callq 0x21310
movsd (%r12,%rbp,8), %xmm0
movsd (%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r13,%rbp,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x50(%rsp), %xmm2
callq 0x21e60
movsd (%r12,%rbp,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r13,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21310
movsd (%r12,%rbp,8), %xmm0
movsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r13,%rbp,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x48(%rsp), %xmm2
callq 0x21e60
incq %rbp
cmpq %rbp, %r14
jne 0xd60ca
incq %r15
callq 0x21c50
movsd (%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rbp
cmpq %rbx, %r15
jne 0xd6067
jmp 0xd61c1
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd %xmm1, (%rsp)
movsd %xmm0, 0x18(%rsp)
movl $0x6, %edi
callq 0x21190
movsd 0x42f2(%rip), %xmm2     # 0xda4d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
movaps 0x434e(%rip), %xmm2     # 0xda540
xorps 0x20(%rsp), %xmm2
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21e60
movsd 0x18(%rsp), %xmm0
movq 0x30(%rsp), %rbx
testl %ebx, %ebx
js 0xd6284
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
incl %ebx
xorl %r14d, %r14d
movsd (%r12,%r14,8), %xmm0
movsd (%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r13,%r14,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x18(%rsp), %xmm2
callq 0x21310
movsd (%r12,%r14,8), %xmm0
movsd (%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r13,%r14,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21e60
incq %r14
cmpq %r14, %rbx
jne 0xd6224
callq 0x21c50
movq %r13, %rdi
callq 0x21ad0
movq %r12, %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