// File: /workspace/github_cpp_makefile_star2_O1/intheswim[P]FractalTubes/infra.cpp
// Function: rollover()
void rollover()
{
    freePoints();
    
    rotation = 10.0 * (float)rand() / RAND_MAX;
    
    if (rand() & 1)
    {
        rotationSpeed = fabs (rotationSpeed);
    }
    else
    {
        rotationSpeed = -fabs (rotationSpeed);
    }
    
    x_shift = ((float)rand() / RAND_MAX - 0.5f) * 1.6f;
    
    image_alpha = 0.0;
    
    
    float scale = detailLevel;
    
#ifdef USE_RUNTIME
    scale = 2 * scale;
#endif
    
    if (m_Preview) scale = 0.4;
    
    M3DDrawer *m3d = new M3DDrawer (300 * scale, 200 * scale);
        
    m3d->SetDefaultPrams ();
    
    bool altPalette = AppParams::isPaletteAlternative();
    
    int palIndex = 0;
    
#ifndef USE_RUNTIME
    if (altPalette)
    {
        palIndex = rand();
    }
#endif
    
    m3d->SetAltPalette (altPalette, palIndex);
    
    bool lightChanged = NO;
    
    lightOption = AppParams::getLightSource();
    
    paletteOption = AppParams::getPalette();
    
    light2Sides = AppParams::getLight2Sides() ? GL_TRUE : GL_FALSE;
    
    distance2Light = AppParams::getLightDistance();
    
    bool newUseLight = AppParams::getLightMoving();
        
    if (newUseLight != USE_LIGHT)
    {
        USE_LIGHT = newUseLight;
        lightChanged = YES;
    }
    
    if ( USE_LIGHT )
    {
        m3d->DisableBrightness();
    }
    
    double light_x = 1; 
    double light_y = 1; 
    double light_z = 1; 
    
    m3d->SetLightDirection(light_x, light_y, light_z);
    
    if (!m3d->Paint (current_set_index, true, &pointData, &corePoints ))
    {
          if ((!m_Preview) && (AppParams::getDetailLevel() > 0))
          {
            writeLog ("Out of memory. Try smaller detail level.");
          }
          else if (!m_Preview)
          {
            writeLog ("Out of Memory");
          }

          return;
    }
    
    m3d_pt_count = m3d->getPointCount(m3d_pt_cycle);
    
    m3d_y_range = m3d->getYRange();
    
    delete m3d;
    
    shineFactor = AppParams::getGlossLevel();
        
    if (AppParams::getGlossRandom())
    {
        shineFactor = 0.1f * (rand() % 101);
    }
    
    if (lightChanged)
    {
        if (USE_LIGHT)
        {
            glShadeModel( SHADE_MODE );
            
            // both needed to enable light:
            glEnable(GL_LIGHTING);
            glEnable(GL_LIGHT0);
            
            glEnable ( GL_COLOR_MATERIAL ) ;
        }
        else
        {
            glShadeModel( SHADE_MODE );
        
            // both needed to enable light:
            glDisable (GL_LIGHTING);
            glDisable (GL_LIGHT0);
        
            glDisable ( GL_COLOR_MATERIAL ) ;
        }
    }
    
    rolloverPeriod = AppParams::getIntervalInSecs();
    
    rollover_time = time (NULL);
        
    grid_step = m3d_pt_cycle;
    
    if (USE_LIGHT)
    {
        adjustNormals();
    }
    
    after_rollover = true;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x5436
callq 0x30e0
cvtsi2ss %eax, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x42e2(%rip), %xmm0     # 0x92d0
divsd 0x42e2(%rip), %xmm0     # 0x92d8
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x74c6(%rip)     # 0xc4c8
callq 0x30e0
movss 0x74e5(%rip), %xmm0     # 0xc4f4
testb $0x1, %al
je 0x501c
andps 0x4336(%rip), %xmm0     # 0x9350
jmp 0x5023
orps 0x431d(%rip), %xmm0     # 0x9340
movss %xmm0, 0x74c9(%rip)     # 0xc4f4
callq 0x30e0
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x42d5(%rip), %xmm0     # 0x9314
addss 0x42d1(%rip), %xmm0     # 0x9318
mulss 0x42cd(%rip), %xmm0     # 0x931c
movss %xmm0, 0x746d(%rip)     # 0xc4c4
movq $0x0, 0x7476(%rip) # 0xc4d8
cmpb $0x0, 0x7457(%rip)      # 0xc4c0
jne 0x5075
movss 0x7485(%rip), %xmm0     # 0xc4f8
jmp 0x507d
movss 0x42a3(%rip), %xmm0     # 0x9320
movss %xmm0, (%rsp)
movl $0x70, %edi
callq 0x32f0
movq %rax, %rbx
movss 0x428d(%rip), %xmm0     # 0x9324
movss (%rsp), %xmm1
mulss %xmm1, %xmm0
mulss 0x4280(%rip), %xmm1     # 0x9328
movq %rax, %rdi
callq 0x6214
movq %rbx, %rdi
callq 0x665a
xorl %ebp, %ebp
callq 0x8240
movl %eax, %r14d
testb %al, %al
je 0x50cd
callq 0x30e0
movl %eax, %ebp
movzbl %r14b, %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x668c
callq 0x8146
callq 0x8224
callq 0x817c
movb %al, 0x73e1(%rip)       # 0xc4d1
callq 0x81c6
movss %xmm0, 0x73d7(%rip)     # 0xc4d4
callq 0x8278
movl %eax, %ebp
movb 0x73c5(%rip), %r14b     # 0xc4d0
cmpb %al, %r14b
je 0x5117
movb %bpl, 0x73b9(%rip)      # 0xc4d0
cmpb $0x1, 0x73b2(%rip)      # 0xc4d0
jne 0x5128
movq %rbx, %rdi
callq 0x66b0
movsd 0x4120(%rip), %xmm0     # 0x9250
movq %rbx, %rdi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x7cbe
movl 0x73b8(%rip), %esi      # 0xc4fc
leaq 0x7365(%rip), %rcx      # 0xc4b0
leaq 0x7366(%rip), %r8       # 0xc4b8
movq %rbx, %rdi
movl $0x1, %edx
callq 0x66b8
testb %al, %al
je 0x521d
leaq 0x737a(%rip), %rsi      # 0xc4e8
movq %rbx, %rdi
callq 0x7af2
movq %rax, 0x7363(%rip)      # 0xc4e0
movq %rbx, %rdi
callq 0x65ac
movl $0x70, %esi
movq %rbx, %rdi
callq 0x3300
callq 0x836c
movss %xmm0, 0x732d(%rip)     # 0xc4cc
callq 0x833a
testb %al, %al
je 0x51df
callq 0x30e0
cltq
imulq $0x288df0cb, %rax, %rcx # imm = 0x288DF0CB
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x24, %rcx
addl %edx, %ecx
imull $0x65, %ecx, %ecx
subl %ecx, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x4155(%rip), %xmm0     # 0x932c
movss %xmm0, 0x72ed(%rip)     # 0xc4cc
cmpb %bpl, %r14b
je 0x5278
movb 0x72e2(%rip), %bl       # 0xc4d0
movl $0x1d01, %edi           # imm = 0x1D01
callq 0x3580
movl $0xb50, %edi            # imm = 0xB50
cmpb $0x1, %bl
jne 0x525f
callq 0x32b0
movl $0x4000, %edi           # imm = 0x4000
callq 0x32b0
movl $0xb57, %edi            # imm = 0xB57
callq 0x32b0
jmp 0x5278
cmpb $0x0, 0x729c(%rip)      # 0xc4c0
jne 0x5238
callq 0x80b8
testl %eax, %eax
jle 0x5238
leaq 0x4163(%rip), %rdi      # 0x9399
jmp 0x524c
cmpb $0x0, 0x7281(%rip)      # 0xc4c0
jne 0x540f
leaq 0x4176(%rip), %rdi      # 0x93c2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4242
callq 0x30c0
movl $0x4000, %edi           # imm = 0x4000
callq 0x30c0
movl $0xb57, %edi            # imm = 0xB57
callq 0x30c0
callq 0x82e2
cvttss2si %xmm0, %rax
movq %rax, 0x7277(%rip)      # 0xc500
xorl %edi, %edi
callq 0x32a0
movq %rax, 0x7271(%rip)      # 0xc508
movslq 0x724a(%rip), %rcx      # 0xc4e8
movl %ecx, 0x7248(%rip)      # 0xc4ec
cmpb $0x1, 0x7225(%rip)      # 0xc4d0
jne 0x5408
movq 0x7228(%rip), %rax      # 0xc4e0
cqto
idivq %rcx
movq %rax, (%rsp)
testq %rax, %rax
jle 0x5408
xorl %r14d, %r14d
xorpd %xmm3, %xmm3
movq 0x71e0(%rip), %rax      # 0xc4b8
leaq (%r14,%r14,4), %rcx
leaq (%rax,%rcx,8), %r15
addq $0x20, %r15
xorl %r12d, %r12d
movl 0x71fb(%rip), %eax      # 0xc4e8
testl %eax, %eax
jle 0x53ea
xorl %r13d, %r13d
movslq (%r15), %rdx
movl 0x71eb(%rip), %ecx      # 0xc4ec
leal (%rdx,%rcx), %esi
addl %r13d, %esi
movslq %esi, %rsi
movq 0x71cf(%rip), %rdi      # 0xc4e0
decq %rdi
cmpq %rsi, %rdi
jle 0x53d8
movq 0x718c(%rip), %rbp      # 0xc4b0
movq %rdx, %rsi
addq %r13, %rsi
imulq $0x38, %rsi, %rbx
leal 0x1(%r13), %esi
cmpl %eax, %esi
movl $0x0, %eax
cmovel %ecx, %eax
addl %edx, %ecx
subl %eax, %ecx
leal (%rcx,%r13), %eax
incl %eax
cltq
imulq $0x38, %rax, %rax
movsd 0x20(%rbp,%rbx), %xmm1
addsd 0x20(%rbp,%rax), %xmm1
movsd 0x28(%rbp,%rbx), %xmm2
movsd %xmm1, 0x20(%rbp,%rbx)
addsd 0x28(%rbp,%rax), %xmm2
movsd %xmm2, 0x28(%rbp,%rbx)
movsd 0x30(%rbp,%rbx), %xmm0
addsd 0x30(%rbp,%rax), %xmm0
movsd %xmm0, 0x30(%rbp,%rbx)
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm3, %xmm0
jb 0x53a2
sqrtsd %xmm0, %xmm0
jmp 0x53ab
callq 0x3240
xorpd %xmm3, %xmm3
addq %rbx, %rbp
movsd 0x20(%rbp), %xmm1
movsd 0x28(%rbp), %xmm2
divsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rbp)
divsd %xmm0, %xmm2
movsd %xmm2, 0x28(%rbp)
movsd 0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rbp)
movl 0x710a(%rip), %eax      # 0xc4e8
incq %r13
cmpl %eax, %r13d
jl 0x52f8
leal 0x1(%r12), %eax
testl %r12d, %r12d
movl %eax, %r12d
je 0x52e7
incq %r14
cmpq (%rsp), %r14
jne 0x52d1
movb $0x1, 0x7101(%rip)      # 0xc510
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0x70, %esi
movq %rbx, %rdi
callq 0x3300
movq %r14, %rdi
callq 0x35c0