// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x10, %rsp
callq 0x5349
callq 0x30e0
cvtsi2ss %eax, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x4384(%rip), %xmm0     # 0x92d0
divsd 0x4384(%rip), %xmm0     # 0x92d8
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x7568(%rip)     # 0xc4c8
callq 0x30e0
movss 0x7587(%rip), %xmm0     # 0xc4f4
testb $0x1, %al
je 0x4f7a
andps 0x43e8(%rip), %xmm0     # 0x9360
jmp 0x4f81
orps 0x43bf(%rip), %xmm0     # 0x9340
movss %xmm0, 0x756b(%rip)     # 0xc4f4
callq 0x30e0
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x4377(%rip), %xmm0     # 0x9314
addss 0x4373(%rip), %xmm0     # 0x9318
mulss 0x436f(%rip), %xmm0     # 0x931c
movss %xmm0, 0x750f(%rip)     # 0xc4c4
movq $0x0, 0x7518(%rip) # 0xc4d8
cmpb $0x0, 0x74f9(%rip)      # 0xc4c0
jne 0x4fd3
movss 0x7527(%rip), %xmm0     # 0xc4f8
jmp 0x4fdb
movss 0x4345(%rip), %xmm0     # 0x9320
movss %xmm0, 0xc(%rsp)
movl $0x70, %edi
callq 0x32e0
movq %rax, %rbx
movss 0x432e(%rip), %xmm0     # 0x9324
movss 0xc(%rsp), %xmm1
mulss %xmm1, %xmm0
mulss 0x4320(%rip), %xmm1     # 0x9328
movq %rax, %rdi
callq 0x6108
movq %rbx, %rdi
callq 0x6562
xorl %ebp, %ebp
callq 0x809c
movl %eax, %r14d
testb %al, %al
je 0x502d
callq 0x30e0
movl %eax, %ebp
movzbl %r14b, %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6594
callq 0x7fa2
callq 0x8080
callq 0x7fd8
movb %al, 0x7481(%rip)       # 0xc4d1
callq 0x8022
movss %xmm0, 0x7477(%rip)     # 0xc4d4
callq 0x80d4
movl %eax, %ebp
movb 0x7465(%rip), %r14b     # 0xc4d0
movl %r14d, %eax
cmpb %bpl, %r14b
je 0x507c
movb %bpl, 0x7456(%rip)      # 0xc4d0
movl %ebp, %eax
testb %al, %al
je 0x5088
movq %rbx, %rdi
callq 0x65b8
movsd 0x41c0(%rip), %xmm0     # 0x9250
movq %rbx, %rdi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x7b1a
movl 0x7458(%rip), %esi      # 0xc4fc
leaq 0x7405(%rip), %rcx      # 0xc4b0
leaq 0x7406(%rip), %r8       # 0xc4b8
movq %rbx, %rdi
movl $0x1, %edx
callq 0x65c0
testb %al, %al
je 0x5179
leaq 0x741a(%rip), %rsi      # 0xc4e8
movq %rbx, %rdi
callq 0x794e
movq %rax, 0x7403(%rip)      # 0xc4e0
movq %rbx, %rdi
callq 0x64b4
movl $0x70, %esi
movq %rbx, %rdi
callq 0x32f0
callq 0x81c8
movss %xmm0, 0x73cd(%rip)     # 0xc4cc
callq 0x8196
testb %al, %al
je 0x513f
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 0x41f5(%rip), %xmm0     # 0x932c
movss %xmm0, 0x738d(%rip)     # 0xc4cc
cmpb %bpl, %r14b
je 0x51b9
movb 0x7386(%rip), %bl       # 0xc4d0
movl $0x1d01, %edi           # imm = 0x1D01
callq 0x3570
movl $0xb50, %edi            # imm = 0xB50
cmpb $0x1, %bl
jne 0x51a0
callq 0x32a0
movl $0x4000, %edi           # imm = 0x4000
callq 0x32a0
movl $0xb57, %edi            # imm = 0xB57
callq 0x32a0
jmp 0x51b9
movb 0x7341(%rip), %al       # 0xc4c0
testb %al, %al
jne 0x5308
callq 0x7f14
testl %eax, %eax
jle 0x5302
leaq 0x420e(%rip), %rdi      # 0x93a9
jmp 0x5320
callq 0x30c0
movl $0x4000, %edi           # imm = 0x4000
callq 0x30c0
movl $0xb57, %edi            # imm = 0xB57
callq 0x30c0
callq 0x813e
cvttss2si %xmm0, %rax
movq %rax, 0x7336(%rip)      # 0xc500
xorl %edi, %edi
callq 0x3290
movq %rax, 0x7330(%rip)      # 0xc508
movslq 0x7309(%rip), %rsi      # 0xc4e8
movl %esi, 0x7307(%rip)      # 0xc4ec
cmpb $0x1, 0x72e4(%rip)      # 0xc4d0
jne 0x52f9
movq 0x72e7(%rip), %rcx      # 0xc4e0
movq %rcx, %rax
cqto
idivq %rsi
testq %rax, %rax
jle 0x52f9
movl %esi, %edx
movq 0x72a5(%rip), %rdi      # 0xc4b8
decq %rcx
xorl %r8d, %r8d
leaq (%r8,%r8,4), %r9
leaq (%rdi,%r9,8), %r9
addq $0x20, %r9
movb $0x1, %r10b
testl %edx, %edx
jle 0x52dd
movslq (%r9), %r11
movq 0x7276(%rip), %rbx      # 0xc4b0
xorl %r14d, %r14d
leaq (%r14,%r11), %r15
leaq (%r15,%rsi), %r12
cmpq %r12, %rcx
jle 0x52d1
imulq $0x38, %r15, %r15
incq %r14
cmpq %rdx, %r14
movl $0x0, %ebp
cmovel %esi, %ebp
subl %ebp, %r12d
incl %r12d
movslq %r12d, %r12
imulq $0x38, %r12, %r12
movsd 0x30(%rbx,%r15), %xmm0
addsd 0x30(%rbx,%r12), %xmm0
movupd 0x20(%rbx,%r15), %xmm1
movupd 0x20(%rbx,%r12), %xmm2
addpd %xmm1, %xmm2
movapd %xmm2, %xmm1
mulpd %xmm2, %xmm1
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
movapd %xmm2, %xmm3
mulsd %xmm2, %xmm3
addsd %xmm1, %xmm3
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm3, %xmm1
sqrtsd %xmm1, %xmm1
divsd %xmm1, %xmm0
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
divpd %xmm1, %xmm2
movupd %xmm2, 0x20(%rbx,%r15)
movsd %xmm0, 0x30(%rbx,%r15)
jmp 0x52d4
incq %r14
cmpq %rdx, %r14
jne 0x523d
testb $0x1, %r10b
movl $0x0, %r10d
jne 0x5228
incq %r8
cmpq %rax, %r8
jne 0x5219
movb $0x1, 0x7210(%rip)      # 0xc510
jmp 0x530c
movb 0x71b8(%rip), %al       # 0xc4c0
testb $0x1, %al
je 0x5319
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40b2(%rip), %rdi      # 0x93d2
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x4202
movq %rax, %r14
movl $0x70, %esi
movq %rbx, %rdi
callq 0x32f0
movq %r14, %rdi
callq 0x35b0