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

    /* Step in z and radius as stacks are drawn. */

    double z = 0.0;
    double r = base;

    const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
    const double rStep = base / ( ( stacks > 0 ) ? stacks : 1 );

    /* Scaling factors for vertex normals */

    const double cosn = ( height / sqrt ( height * height + base * base ));
    const double sinn = ( base   / sqrt ( height * height + base * base ));

    /* Pre-computed circle */

    double *sint,*cost;

    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCone" );

    fghCircleTable(&sint,&cost,-slices);

    /* Draw the stacks... */

    for (i=0; i<stacks; i++)
    {
        glBegin(GL_LINE_LOOP);

            for( j=0; j<slices; j++ )
            {
                glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
                glVertex3d(cost[j]*r,    sint[j]*r,    z   );
            }

        glEnd();

        z += zStep;
        r -= rStep;
    }

    /* Draw the slices */

    r = base;

    glBegin(GL_LINES);

        for (j=0; j<slices; j++)
        {
            glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn  );
            glVertex3d(cost[j]*r,    sint[j]*r,    0.0   );
            glVertex3d(0.0,          0.0,          height);
        }

    glEnd();

    /* Release sin and cos tables */

    free(sint);
    free(cost);
}

// Assembly:
subq $0x98, %rsp
movsd %xmm0, 0x90(%rsp)
movsd %xmm1, 0x88(%rsp)
movl %edi, 0x84(%rsp)
movl %esi, 0x80(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
cmpl $0x0, 0x80(%rsp)
jle 0x188c05
movl 0x80(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0x188c10
movl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x188c10
movsd 0x30(%rsp), %xmm0
movl 0x2c(%rsp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
cmpl $0x0, 0x80(%rsp)
jle 0x188c4e
movl 0x80(%rsp), %eax
movl %eax, 0x1c(%rsp)
jmp 0x188c59
movl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x188c59
movsd 0x20(%rsp), %xmm0
movl 0x1c(%rsp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x88(%rsp), %xmm0
movsd 0x88(%rsp), %xmm2
movsd 0x90(%rsp), %xmm1
mulsd 0x90(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x22780
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x88(%rsp), %xmm0
movsd 0x88(%rsp), %xmm2
movsd 0x90(%rsp), %xmm1
mulsd 0x90(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x22780
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
leaq 0x71672(%rip), %rax     # 0x1fa390
cmpb $0x0, 0x1c(%rax)
jne 0x188d39
leaq 0x14ba7(%rip), %rdi     # 0x19d8d2
leaq 0x26487(%rip), %rsi     # 0x1af1b9
movb $0x0, %al
callq 0x17de70
xorl %edx, %edx
subl 0x84(%rsp), %edx
leaq 0x40(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x188210
movl $0x0, 0x7c(%rsp)
movl 0x7c(%rsp), %eax
cmpl 0x80(%rsp), %eax
jge 0x188e40
movl $0x2, %edi
callq 0x221b0
movl $0x0, 0x78(%rsp)
movl 0x78(%rsp), %eax
cmpl 0x84(%rsp), %eax
jge 0x188e03
movq 0x38(%rsp), %rax
movslq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
mulsd 0x48(%rsp), %xmm0
movq 0x40(%rsp), %rax
movslq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd 0x48(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
callq 0x22330
movq 0x38(%rsp), %rax
movslq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
mulsd 0x68(%rsp), %xmm0
movq 0x40(%rsp), %rax
movslq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd 0x68(%rsp), %xmm1
movsd 0x70(%rsp), %xmm2
callq 0x23020
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x188d7c
callq 0x22de0
movsd 0x60(%rsp), %xmm0
addsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x58(%rsp), %xmm1
movsd 0x68(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x188d59
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movl $0x1, %edi
callq 0x221b0
movl $0x0, 0x78(%rsp)
movl 0x78(%rsp), %eax
cmpl 0x84(%rsp), %eax
jge 0x188efd
movq 0x38(%rsp), %rax
movslq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
mulsd 0x48(%rsp), %xmm0
movq 0x40(%rsp), %rax
movslq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd 0x48(%rsp), %xmm1
movsd 0x50(%rsp), %xmm2
callq 0x22330
movq 0x38(%rsp), %rax
movslq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
mulsd 0x68(%rsp), %xmm0
movq 0x40(%rsp), %rax
movslq 0x78(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd 0x68(%rsp), %xmm1
xorps %xmm2, %xmm2
callq 0x23020
movsd 0x88(%rsp), %xmm2
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x23020
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x188e61
callq 0x22de0
movq 0x40(%rsp), %rdi
callq 0x22c30
movq 0x38(%rsp), %rdi
callq 0x22c30
addq $0x98, %rsp
retq
nop