// File: /workspace/github_cpp_makefile_star2_O1/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, %r13d
movl %edi, %ebx
movaps %xmm0, 0x20(%rsp)
leaq 0x6c3bc(%rip), %rax     # 0x1441c0
cmpb $0x0, 0x1c(%rax)
jne 0xd7e1f
leaq 0x13755(%rip), %rdi     # 0xeb566
leaq 0x2512d(%rip), %rsi     # 0xfcf45
xorl %eax, %eax
callq 0xd1cf7
movl %ebx, %edx
negl %edx
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xd81be
leal (,%r13,2), %edx
leaq 0x70(%rsp), %r15
leaq 0x68(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0xd81be
movq (%r14), %rcx
xorl %eax, %eax
testl %r13d, %r13d
setg %al
shll $0x3, %eax
movq %rcx, 0x48(%rsp)
movsd (%rcx,%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq (%r15), %rcx
movq %rcx, 0x40(%rsp)
movsd (%rcx,%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x6, %edi
callq 0x21190
movsd 0x4186(%rip), %xmm2     # 0xdc018
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movaps 0x20(%rsp), %xmm2
callq 0x21e70
testl %ebx, %ebx
js 0xd7f3a
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %r15
movsd 0x10(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rsp)
movl %ebx, %r12d
incq %r12
movsd -0x8(%r14,%r12,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd -0x8(%r15,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21310
movsd -0x8(%r14,%r12,8), %xmm0
movsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd -0x8(%r15,%r12,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd (%rsp), %xmm2
callq 0x21e70
decq %r12
jg 0xd7eda
callq 0x21c60
cmpl $0x3, %r13d
jl 0xd80b1
decl %r13d
movq %r13, 0x50(%rsp)
movq 0x30(%rsp), %r13
movq 0x38(%rsp), %rbp
leal 0x1(%rbx), %r14d
movl $0x1, %r15d
movq 0x48(%rsp), %rax
movsd 0x8(%rax,%r15,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x40(%rsp), %rax
movsd 0x8(%rax,%r15,8), %xmm0
movsd %xmm0, (%rsp)
movl $0x8, %edi
callq 0x21190
testl %ebx, %ebx
js 0xd8085
movsd 0x18(%rsp), %xmm1
movapd 0x20(%rsp), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rsp)
movsd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x58(%rsp)
xorl %r12d, %r12d
movsd (%r13,%r12,8), %xmm0
movsd (%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%rbp,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x18(%rsp), %xmm2
callq 0x21310
movsd (%r13,%r12,8), %xmm0
movsd (%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%rbp,%r12,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x60(%rsp), %xmm2
callq 0x21e70
movsd (%r13,%r12,8), %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%rbp,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21310
movsd (%r13,%r12,8), %xmm0
movsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%rbp,%r12,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x58(%rsp), %xmm2
callq 0x21e70
incq %r12
cmpq %r12, %r14
jne 0xd7fc3
incq %r15
callq 0x21c60
movsd (%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
cmpq 0x50(%rsp), %r15
jne 0xd7f65
jmp 0xd80bd
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd %xmm1, (%rsp)
movsd %xmm0, 0x18(%rsp)
movl $0x6, %edi
callq 0x21190
movsd 0x43f6(%rip), %xmm2     # 0xdc4d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
movaps 0x4442(%rip), %xmm2     # 0xdc530
xorps 0x20(%rsp), %xmm2
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21e70
movsd 0x18(%rsp), %xmm0
testl %ebx, %ebx
js 0xd8183
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %r15
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
incl %ebx
xorl %r12d, %r12d
movsd (%r14,%r12,8), %xmm0
movsd (%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x18(%rsp), %xmm2
callq 0x21310
movsd (%r14,%r12,8), %xmm0
movsd (%rsp), %xmm3
mulsd %xmm3, %xmm0
movapd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%r12,8), %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21e70
incq %r12
cmpq %r12, %rbx
jne 0xd8125
callq 0x21c60
movq 0x38(%rsp), %rdi
callq 0x21ae0
movq 0x30(%rsp), %rdi
callq 0x21ae0
movq 0x40(%rsp), %rdi
callq 0x21ae0
movq 0x48(%rsp), %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ae0