// File: tomfunkhouser[P]gaps/pkgs/fglut/freeglut_geometry.c
// Function: glutSolidSierpinskiSponge
void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale )
{
  int i, j ;

  FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSierpinskiSponge" );

  if ( num_levels == 0 )
  {
    glBegin ( GL_TRIANGLES ) ;

    for ( i = 0 ; i < NUM_TETR_FACES ; i++ )
    {
      glNormal3d ( -tet_r[i][0], -tet_r[i][1], -tet_r[i][2] ) ;
      for ( j = 0; j < 3; j++ )
      {
        double x = offset[0] + scale * tet_r[tet_i[i][j]][0] ;
        double y = offset[1] + scale * tet_r[tet_i[i][j]][1] ;
        double z = offset[2] + scale * tet_r[tet_i[i][j]][2] ;
        glVertex3d ( x, y, z ) ;
      }
    }

    glEnd () ;
  }
  else if ( num_levels > 0 )
  {
    GLdouble local_offset[3] ;  /* Use a local variable to avoid buildup of roundoff errors */
    num_levels -- ;
    scale /= 2.0 ;
    for ( i = 0 ; i < NUM_TETR_FACES ; i++ )
    {
      local_offset[0] = offset[0] + scale * tet_r[i][0] ;
      local_offset[1] = offset[1] + scale * tet_r[i][1] ;
      local_offset[2] = offset[2] + scale * tet_r[i][2] ;
      glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
    }
  }
}

// Assembly:
subq $0x58, %rsp
movl %edi, 0x54(%rsp)
movq %rsi, 0x48(%rsp)
movsd %xmm0, 0x40(%rsp)
leaq 0x6dd56(%rip), %rax     # 0x1fa390
cmpb $0x0, 0x1c(%rax)
jne 0x18c655
leaq 0x1128b(%rip), %rdi     # 0x19d8d2
leaq 0x22dc3(%rip), %rsi     # 0x1af411
movb $0x0, %al
callq 0x17de70
cmpl $0x0, 0x54(%rsp)
jne 0x18c849
movl $0x4, %edi
callq 0x221b0
movl $0x0, 0x3c(%rsp)
cmpl $0x4, 0x3c(%rsp)
jge 0x18c83f
movslq 0x3c(%rsp), %rcx
leaq 0x6df47(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x6df19(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movslq 0x3c(%rsp), %rcx
leaq 0x6deea(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
callq 0x22330
movl $0x0, 0x38(%rsp)
cmpl $0x3, 0x38(%rsp)
jge 0x18c82d
movq 0x48(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x40(%rsp), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x6e434(%rip), %rax     # 0x1fab70
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movslq 0x38(%rsp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x6de7d(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x48(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x40(%rsp), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x6e3e8(%rip), %rax     # 0x1fab70
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movslq 0x38(%rsp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x6de31(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x48(%rsp), %rax
movsd 0x10(%rax), %xmm1
movsd 0x40(%rsp), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x6e39b(%rip), %rax     # 0x1fab70
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movslq 0x38(%rsp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x6dde4(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x23020
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x18c716
jmp 0x18c82f
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x18c672
callq 0x22de0
jmp 0x18c94f
cmpl $0x0, 0x54(%rsp)
jle 0x18c94d
movl 0x54(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x54(%rsp)
movsd 0x40(%rsp), %xmm0
movsd 0x17e3(%rip), %xmm1     # 0x18e050
divsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
cmpl $0x4, 0x3c(%rsp)
jge 0x18c94b
movq 0x48(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x40(%rsp), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x6dd2b(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movq 0x48(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x40(%rsp), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x6dcf7(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x48(%rsp), %rax
movsd 0x10(%rax), %xmm1
movsd 0x40(%rsp), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x6dcc1(%rip), %rax     # 0x1fa5d0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x54(%rsp), %edi
movq %rsp, %rsi
movsd 0x40(%rsp), %xmm0
callq 0x18c620
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x18c87f
jmp 0x18c94d
jmp 0x18c94f
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)
nop