// File: /workspace/github_cpp_makefile_star2_O3/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 %esi, %ebx
movl %edi, %r14d
movsd %xmm1, 0x10(%rsp)
cmpl $0x2, %esi
movl $0x1, %ebp
cmovgel %esi, %ebp
movsd %xmm0, 0x18(%rsp)
leaq 0x6b55a(%rip), %rax     # 0x1421c0
cmpb $0x0, 0x1c(%rax)
jne 0xd6c81
leaq 0x12943(%rip), %rdi     # 0xe95b6
leaq 0x245ae(%rip), %rsi     # 0xfb228
xorl %eax, %eax
callq 0xcfe73
movl %r14d, %edx
negl %edx
leaq 0x40(%rsp), %r15
leaq 0x38(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0xd62bb
movl $0x6, %edi
callq 0x21190
movsd 0x3823(%rip), %xmm2     # 0xda4d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e60
movq (%r15), %r12
movq (%r13), %r15
movq %r14, 0x8(%rsp)
testl %r14d, %r14d
js 0xd6d13
movq 0x8(%rsp), %rax
leal 0x1(%rax), %r14d
xorl %r13d, %r13d
movsd (%r15,%r13,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%r13,8), %xmm1
mulsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e60
incq %r13
cmpq %r13, %r14
jne 0xd6ce8
callq 0x21c50
movl $0x6, %edi
callq 0x21190
movsd 0x32ee(%rip), %xmm2     # 0xda018
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e60
cmpl $0x0, 0x8(%rsp)
js 0xd6d81
movl 0x8(%rsp), %r14d
movsd (%r15,%r14,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%r14,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e60
addq $-0x1, %r14
jb 0xd6d56
callq 0x21c50
testl %ebx, %ebx
movq 0x8(%rsp), %r14
movsd 0x10(%rsp), %xmm1
jle 0xd6e79
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
leal 0x1(%r14), %r13d
xorpd %xmm3, %xmm3
movl $0x1, %ebp
movsd %xmm2, 0x28(%rsp)
movapd %xmm2, %xmm0
movsd %xmm3, 0x30(%rsp)
cmpl %ebx, %ebp
je 0xd6dcd
movapd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
movl $0x8, %edi
callq 0x21190
testl %r14d, %r14d
js 0xd6e4c
xorl %r14d, %r14d
movsd (%r15,%r14,8), %xmm0
movsd (%r12,%r14,8), %xmm1
xorpd %xmm2, %xmm2
callq 0x21310
movsd (%r15,%r14,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%r14,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x30(%rsp), %xmm2
callq 0x21e60
movsd (%r15,%r14,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r12,%r14,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x21e60
incq %r14
cmpq %r14, %r13
jne 0xd6de5
callq 0x21c50
movsd 0x28(%rsp), %xmm0
movsd 0x20(%rsp), %xmm3
addsd %xmm3, %xmm0
leal 0x1(%rbp), %eax
cmpl %ebx, %ebp
movl %eax, %ebp
movq 0x8(%rsp), %r14
movsd 0x10(%rsp), %xmm1
jne 0xd6dbf
movq %r12, %rdi
callq 0x21ad0
movq %r15, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ad0