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

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

    double r;
    double x,y,z;

    /* Pre-computed circle */

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

    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSphere" );

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

    /* Draw a line loop for each stack */

    for (i=1; i<stacks; i++)
    {
        z = cost2[i];
        r = sint2[i];

        glBegin(GL_LINE_LOOP);

            for(j=0; j<=slices; j++)
            {
                x = cost1[j];
                y = sint1[j];

                glNormal3d(x,y,z);
                glVertex3d(x*r*radius,y*r*radius,z*radius);
            }

        glEnd();
    }

    /* Draw a line loop for each slice */

    for (i=0; i<slices; i++)
    {
        glBegin(GL_LINE_STRIP);

            for(j=0; j<=stacks; j++)
            {
                x = cost1[i]*sint2[j];
                y = sint1[i]*sint2[j];
                z = cost2[j];

                glNormal3d(x,y,z);
                glVertex3d(x*radius,y*radius,z*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 $0x88, %rsp
movl %esi, %ebx
movl %edi, %r14d
movsd %xmm0, 0x40(%rsp)
leaq 0x6bdcc(%rip), %rax     # 0x1421c0
cmpb $0x0, 0x1c(%rax)
jne 0xd640f
leaq 0x131b5(%rip), %rdi     # 0xe95b6
leaq 0x24b7e(%rip), %rsi     # 0xfaf86
xorl %eax, %eax
callq 0xcfe73
movl %r14d, %edx
negl %edx
leaq 0x80(%rsp), %r12
leaq 0x78(%rsp), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0xd62bb
leal (%rbx,%rbx), %edx
movq %r14, 0x8(%rsp)
leaq 0x70(%rsp), %r14
leaq 0x68(%rsp), %rbp
movq %r14, %rdi
movq %rbp, %rsi
callq 0xd62bb
movq (%r12), %r13
movq (%r15), %r12
movq (%r14), %r15
movq 0x8(%rsp), %r14
movq (%rbp), %rax
movq %rbx, 0x28(%rsp)
cmpl $0x2, %ebx
movq %rax, 0x30(%rsp)
jl 0xd653c
leal 0x1(%r14), %ebx
movl 0x28(%rsp), %ecx
movq %rcx, 0x10(%rsp)
movl $0x1, %ebp
movsd (%rax,%rbp,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd (%r15,%rbp,8), %xmm0
movsd %xmm0, 0x38(%rsp)
movl $0x2, %edi
callq 0x21190
testl %r14d, %r14d
js 0xd651f
movsd 0x20(%rsp), %xmm0
mulsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %r14d, %r14d
movsd (%r12,%r14,8), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd (%r13,%r14,8), %xmm1
movsd %xmm1, 0x50(%rsp)
movsd 0x20(%rsp), %xmm2
callq 0x21310
movsd 0x38(%rsp), %xmm2
movsd 0x48(%rsp), %xmm0
mulsd %xmm2, %xmm0
movsd 0x40(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x50(%rsp), %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm1, %xmm3
movapd %xmm3, %xmm1
movsd 0x18(%rsp), %xmm2
callq 0x21e60
incq %r14
cmpq %r14, %rbx
jne 0xd64bc
callq 0x21c50
incq %rbp
cmpq 0x10(%rsp), %rbp
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %r14
jne 0xd6481
movq %r13, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x18(%rsp)
testl %r14d, %r14d
jle 0xd6623
movq 0x28(%rsp), %rax
incl %eax
movq %rax, 0x60(%rsp)
movl %r14d, %eax
movq %rax, 0x58(%rsp)
xorl %ebx, %ebx
movq 0x30(%rsp), %r12
movq 0x18(%rsp), %r13
movq 0x60(%rsp), %rbp
movl $0x3, %edi
callq 0x21190
cmpl $0x0, 0x28(%rsp)
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
js 0xd6610
xorl %r14d, %r14d
movq %rbx, 0x38(%rsp)
movsd (%r13,%r14,8), %xmm1
movsd (%rdx,%rbx,8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
mulsd (%rsi,%rbx,8), %xmm1
movsd %xmm1, 0x48(%rsp)
movsd (%r12,%r14,8), %xmm2
movsd %xmm2, 0x50(%rsp)
movq %rdx, %rbx
movq %rsi, %r15
callq 0x21310
movsd 0x40(%rsp), %xmm3
movsd 0x20(%rsp), %xmm0
mulsd %xmm3, %xmm0
movsd 0x48(%rsp), %xmm1
mulsd %xmm3, %xmm1
movsd 0x50(%rsp), %xmm2
mulsd %xmm3, %xmm2
callq 0x21e60
movq %r15, %rsi
movq %rbx, %rdx
movq 0x38(%rsp), %rbx
incq %r14
cmpq %r14, %rbp
jne 0xd659c
callq 0x21c50
incq %rbx
cmpq 0x58(%rsp), %rbx
jne 0xd6579
movq 0x10(%rsp), %rdi
callq 0x21ad0
movq 0x8(%rsp), %rdi
callq 0x21ad0
movq 0x18(%rsp), %rdi
callq 0x21ad0
movq 0x30(%rsp), %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ad0