// File: 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:
subq $0x58, %rsp
movsd %xmm0, 0x50(%rsp)
movl %edi, 0x4c(%rsp)
movl %esi, 0x48(%rsp)
leaq 0x71fb7(%rip), %rax     # 0x1fa390
cmpb $0x0, 0x1c(%rax)
jne 0x1883f4
leaq 0x154ec(%rip), %rdi     # 0x19d8d2
leaq 0x26dad(%rip), %rsi     # 0x1af19a
movb $0x0, %al
callq 0x17de70
xorl %edx, %edx
subl 0x4c(%rsp), %edx
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x188210
movl 0x48(%rsp), %edx
shll %edx
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
callq 0x188210
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x188516
movq (%rsp), %rax
movslq 0x44(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rax
movslq 0x44(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x38(%rsp)
movl $0x2, %edi
callq 0x221b0
movl $0x0, 0x40(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jg 0x188501
movq 0x10(%rsp), %rax
movslq 0x40(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rax
movslq 0x40(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x22330
movsd 0x30(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
mulsd 0x50(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
mulsd 0x38(%rsp), %xmm1
mulsd 0x50(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
mulsd 0x50(%rsp), %xmm2
callq 0x23020
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x18846d
callq 0x22de0
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x188424
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x18860d
movl $0x3, %edi
callq 0x221b0
movl $0x0, 0x40(%rsp)
movl 0x40(%rsp), %eax
cmpl 0x48(%rsp), %eax
jg 0x1885f8
movq 0x10(%rsp), %rax
movslq 0x44(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x8(%rsp), %rax
movslq 0x40(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rax
movslq 0x44(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x8(%rsp), %rax
movslq 0x40(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movq (%rsp), %rax
movslq 0x40(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x22330
movsd 0x30(%rsp), %xmm0
mulsd 0x50(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
mulsd 0x50(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
mulsd 0x50(%rsp), %xmm2
callq 0x23020
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x18853e
callq 0x22de0
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x18851e
movq 0x18(%rsp), %rdi
callq 0x22c30
movq 0x10(%rsp), %rdi
callq 0x22c30
movq 0x8(%rsp), %rdi
callq 0x22c30
movq (%rsp), %rdi
callq 0x22c30
addq $0x58, %rsp
retq
nopl (%rax)