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

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

    double z0,z1;
    const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );

    /* Pre-computed circle */

    double *sint,*cost;

    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCylinder" );

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

    /* Cover the base and top */

    glBegin(GL_TRIANGLE_FAN);
        glNormal3d(0.0, 0.0, -1.0 );
        glVertex3d(0.0, 0.0,  0.0 );
        for (j=0; j<=slices; j++)
          glVertex3d(cost[j]*radius, sint[j]*radius, 0.0);
    glEnd();

    glBegin(GL_TRIANGLE_FAN);
        glNormal3d(0.0, 0.0, 1.0   );
        glVertex3d(0.0, 0.0, height);
        for (j=slices; j>=0; j--)
          glVertex3d(cost[j]*radius, sint[j]*radius, height);
    glEnd();

    /* Do the stacks */

    z0 = 0.0;
    z1 = zStep;

    for (i=1; i<=stacks; i++)
    {
        if (i==stacks)
            z1 = height;

        glBegin(GL_QUAD_STRIP);
            for (j=0; j<=slices; j++ )
            {
                glNormal3d(cost[j],        sint[j],        0.0 );
                glVertex3d(cost[j]*radius, sint[j]*radius, z0  );
                glVertex3d(cost[j]*radius, sint[j]*radius, z1  );
            }
        glEnd();

        z0 = z1; z1 += zStep;
    }

    /* Release sin and cos tables */

    free(sint);
    free(cost);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edi, %ebp
cmpl $0x2, %esi
pushq $0x1
popq %r12
movl %r12d, %eax
movl %esi, 0x14(%rsp)
cmovgel %esi, %eax
cvtsi2sd %eax, %xmm2
movsd %xmm0, 0x20(%rsp)
leaq 0x71a1b(%rip), %rax     # 0x1331e0
cmpb $0x0, 0x1c(%rax)
movsd %xmm1, 0x18(%rsp)
jne 0xc17f8
leaq 0x12a8e(%rip), %rdi     # 0xd4266
leaq 0x246b9(%rip), %rsi     # 0xe5e98
xorl %eax, %eax
movsd %xmm2, 0x8(%rsp)
callq 0xbad73
movsd 0x8(%rsp), %xmm2
movsd 0x18(%rsp), %xmm1
divsd %xmm2, %xmm1
movsd %xmm1, 0x28(%rsp)
movl %ebp, %edx
negl %edx
leaq 0x40(%rsp), %r15
leaq 0x38(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0xc0eee
pushq $0x6
popq %rdi
callq 0x21190
movsd 0x3ca5(%rip), %xmm2     # 0xc54d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21300
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e80
movq (%r14), %r14
movq (%r15), %r15
movslq %ebp, %r13
xorl %ebx, %ebx
cmpq %r13, %rbx
jg 0xc1881
movsd (%r14,%rbx,8), %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbx,8), %xmm1
mulsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e80
incq %rbx
jmp 0xc1854
callq 0x21c60
pushq $0x6
popq %rdi
callq 0x21190
movsd 0x3782(%rip), %xmm2     # 0xc5018
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21300
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movsd 0x18(%rsp), %xmm2
callq 0x21e80
testl %ebp, %ebp
js 0xc18e5
movl %ebp, %eax
movsd (%r14,%rax,8), %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rax,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x18(%rsp), %xmm2
callq 0x21e80
decl %ebp
jmp 0xc18b6
callq 0x21c60
xorl %ebx, %ebx
movl 0x14(%rsp), %eax
testl %eax, %eax
cmovgl %eax, %ebx
incl %ebx
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x28(%rsp), %xmm0
cmpl %ebx, %r12d
movsd 0x18(%rsp), %xmm1
je 0xc19be
movsd %xmm1, 0x8(%rsp)
cmpl 0x14(%rsp), %r12d
je 0xc1929
movsd %xmm0, 0x8(%rsp)
pushq $0x8
popq %rdi
callq 0x21190
xorl %ebp, %ebp
cmpq %r13, %rbp
jg 0xc199b
movsd (%r14,%rbp,8), %xmm0
movsd (%r15,%rbp,8), %xmm1
xorps %xmm2, %xmm2
callq 0x21300
movsd (%r14,%rbp,8), %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x30(%rsp), %xmm2
callq 0x21e80
movsd (%r14,%rbp,8), %xmm0
movsd 0x20(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%rbp,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
callq 0x21e80
incq %rbp
jmp 0xc1933
callq 0x21c60
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm1, %xmm0
incl %r12d
movsd %xmm1, 0x30(%rsp)
jmp 0xc1907
movq %r15, %rdi
callq 0x21ad0
movq %r14, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ad0