// File: /workspace/github_cpp_makefile_star2_O1/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 0x6b57c(%rip), %rax     # 0x1441c0
cmpb $0x0, 0x1c(%rax)
jne 0xd8c5f
leaq 0x12915(%rip), %rdi     # 0xeb566
leaq 0x24580(%rip), %rsi     # 0xfd1d8
xorl %eax, %eax
callq 0xd1cf7
movl %r14d, %edx
negl %edx
leaq 0x28(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xd81be
movl $0x6, %edi
callq 0x21190
movsd 0x384b(%rip), %xmm2     # 0xdc4d0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e70
movq %r14, 0x8(%rsp)
testl %r14d, %r14d
js 0xd8cee
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %r15
movq 0x8(%rsp), %rax
leal 0x1(%rax), %r12d
xorl %r13d, %r13d
movsd (%r14,%r13,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd (%r15,%r13,8), %xmm1
mulsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
callq 0x21e70
incq %r13
cmpq %r13, %r12
jne 0xd8cc3
callq 0x21c60
movl $0x6, %edi
callq 0x21190
movsd 0x3313(%rip), %xmm2     # 0xdc018
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0x21310
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e70
movq 0x8(%rsp), %rax
testl %eax, %eax
js 0xd8d6a
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %r15
movl %eax, %r12d
incq %r12
movsd -0x8(%r14,%r12,8), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd -0x8(%r15,%r12,8), %xmm1
mulsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
callq 0x21e70
decq %r12
jg 0xd8d3e
callq 0x21c60
testl %ebx, %ebx
movsd 0x10(%rsp), %xmm1
jle 0xd8e69
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %r12
movq 0x8(%rsp), %rax
leal 0x1(%rax), %r13d
xorpd %xmm3, %xmm3
movl $0x1, %ebp
movsd %xmm2, 0x38(%rsp)
movapd %xmm2, %xmm0
movsd %xmm3, 0x40(%rsp)
cmpl %ebx, %ebp
je 0xd8dc0
movapd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
movl $0x8, %edi
callq 0x21190
cmpl $0x0, 0x8(%rsp)
js 0xd8e41
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 0x40(%rsp), %xmm2
callq 0x21e70
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 0x21e70
incq %r14
cmpq %r14, %r13
jne 0xd8dda
callq 0x21c60
movsd 0x38(%rsp), %xmm0
movsd 0x30(%rsp), %xmm3
addsd %xmm3, %xmm0
leal 0x1(%rbp), %eax
cmpl %ebx, %ebp
movl %eax, %ebp
movsd 0x10(%rsp), %xmm1
jne 0xd8db2
movq 0x28(%rsp), %rdi
callq 0x21ae0
movq 0x20(%rsp), %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ae0