// File: /workspace/github_cpp_makefile_star2_O1/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, %r12d
movsd %xmm0, 0x40(%rsp)
leaq 0x6bec6(%rip), %rax     # 0x1441c0
cmpb $0x0, 0x1c(%rax)
jne 0xd8315
leaq 0x1325f(%rip), %rdi     # 0xeb566
leaq 0x24c28(%rip), %rsi     # 0xfcf36
xorl %eax, %eax
callq 0xd1cf7
movl %r12d, %edx
negl %edx
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xd81be
leal (%rbx,%rbx), %edx
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xd81be
movq %rbx, 0x28(%rsp)
cmpl $0x2, %ebx
jl 0xd843e
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x68(%rsp), %r13
movq 0x70(%rsp), %rbp
leal 0x1(%r12), %ebx
movl 0x28(%rsp), %eax
movq %rax, 0x10(%rsp)
movl $0x1, %r15d
movq 0x20(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x18(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x38(%rsp)
movl $0x2, %edi
callq 0x21190
movq %r12, %r14
testl %r12d, %r12d
js 0xd8428
movsd 0x8(%rsp), %xmm0
mulsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r12d, %r12d
movsd (%r13,%r12,8), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd (%rbp,%r12,8), %xmm1
movsd %xmm1, 0x50(%rsp)
movsd 0x8(%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 0x30(%rsp), %xmm2
callq 0x21e70
incq %r12
cmpq %r12, %rbx
jne 0xd83c4
callq 0x21c60
incq %r15
cmpq 0x10(%rsp), %r15
movq %r14, %r12
jne 0xd837b
testl %r12d, %r12d
movq 0x28(%rsp), %r15
jle 0xd854b
movq 0x68(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x60(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq 0x70(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq 0x58(%rsp), %rcx
movq %rcx, 0x10(%rsp)
leal 0x1(%r15), %ecx
movq %rcx, 0x80(%rsp)
movl %r12d, %eax
movq %rax, 0x78(%rsp)
xorl %ebx, %ebx
movq 0x30(%rsp), %r13
movq 0x20(%rsp), %rbp
movq 0x80(%rsp), %r14
movl $0x3, %edi
callq 0x21190
testl %r15d, %r15d
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rsi
js 0xd8533
xorl %r15d, %r15d
movq %rbx, 0x38(%rsp)
movsd (%rbp,%r15,8), %xmm1
movsd (%r13,%rbx,8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
mulsd (%rdx,%rbx,8), %xmm1
movsd %xmm1, 0x48(%rsp)
movsd (%rsi,%r15,8), %xmm2
movsd %xmm2, 0x50(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
callq 0x21310
movsd 0x40(%rsp), %xmm3
movsd 0x8(%rsp), %xmm0
mulsd %xmm3, %xmm0
movsd 0x48(%rsp), %xmm1
mulsd %xmm3, %xmm1
movsd 0x50(%rsp), %xmm2
mulsd %xmm3, %xmm2
callq 0x21e70
movq %r12, %rsi
movq %rbx, %rdx
movq 0x38(%rsp), %rbx
incq %r15
cmpq %r15, %r14
jne 0xd84bd
callq 0x21c60
incq %rbx
cmpq 0x78(%rsp), %rbx
movq 0x28(%rsp), %r15
jne 0xd849c
movq 0x70(%rsp), %rdi
callq 0x21ae0
movq 0x68(%rsp), %rdi
callq 0x21ae0
movq 0x60(%rsp), %rdi
callq 0x21ae0
movq 0x58(%rsp), %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ae0