// File: /workspace/github_cpp_makefile_star2_O2/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 0x4fa6
callq 0x30e0
cvtsi2ss %eax, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x471b(%rip), %xmm0     # 0x92d0
divsd 0x471b(%rip), %xmm0     # 0x92d8
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x890f(%rip)     # 0xd4d8
callq 0x30e0
movss 0x892e(%rip), %xmm0     # 0xd504
testb $0x1, %al
je 0x4be3
andps 0x477f(%rip), %xmm0     # 0x9360
jmp 0x4bea
orps 0x4756(%rip), %xmm0     # 0x9340
movss %xmm0, 0x8912(%rip)     # 0xd504
callq 0x30e0
cvtsi2ss %eax, %xmm0
mulss 0x4711(%rip), %xmm0     # 0x9314
addss 0x470d(%rip), %xmm0     # 0x9318
mulss 0x4709(%rip), %xmm0     # 0x931c
andq $0x0, 0x88cd(%rip)      # 0xd4e8
movss %xmm0, 0x88b1(%rip)     # 0xd4d4
cmpb $0x0, 0x88a6(%rip)      # 0xd4d0
jne 0x4c36
movss 0x88d4(%rip), %xmm0     # 0xd508
jmp 0x4c3e
movss 0x46e2(%rip), %xmm0     # 0x9320
movss %xmm0, 0x4(%rsp)
pushq $0x70
popq %rdi
callq 0x3300
movq %rax, %r14
movss 0x46cd(%rip), %xmm0     # 0x9324
movss 0x4(%rsp), %xmm1
mulss %xmm1, %xmm0
mulss 0x46bf(%rip), %xmm1     # 0x9328
movq %rax, %rdi
callq 0x5f04
movq %r14, %rdi
callq 0x62d2
xorl %ebx, %ebx
callq 0x79e6
movl %eax, %ebp
testb %al, %al
je 0x4c8d
callq 0x30e0
movl %eax, %ebx
movzbl %bpl, %esi
movq %r14, %rdi
movl %ebx, %edx
callq 0x6302
callq 0x78f4
callq 0x79cc
callq 0x7928
movb %al, 0x8831(%rip)       # 0xd4e1
callq 0x7970
movss %xmm0, 0x8827(%rip)     # 0xd4e4
callq 0x7a0a
movl %eax, %ebp
movb 0x8815(%rip), %r15b     # 0xd4e0
movl %r15d, %eax
cmpb %bpl, %r15b
je 0x4cdc
movb %bpl, 0x8806(%rip)      # 0xd4e0
movl %ebp, %eax
testb %al, %al
je 0x4ce8
movq %r14, %rdi
callq 0x6312
movsd 0x4560(%rip), %xmm0     # 0x9250
movq %r14, %rdi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x7506
movl 0x8808(%rip), %esi      # 0xd50c
leaq 0x87b5(%rip), %rcx      # 0xd4c0
leaq 0x87b6(%rip), %r8       # 0xd4c8
pushq $0x1
popq %rbx
movq %r14, %rdi
movl %ebx, %edx
callq 0x6318
testb %al, %al
je 0x4dc1
leaq 0x87ca(%rip), %rsi      # 0xd4f8
movq %r14, %rdi
callq 0x733e
movq %rax, 0x87b3(%rip)      # 0xd4f0
movq %r14, %rdi
callq 0x623c
pushq $0x70
popq %rsi
movq %r14, %rdi
callq 0x3310
callq 0x7ad8
movss %xmm0, 0x877f(%rip)     # 0xd4dc
callq 0x7aa6
testb %al, %al
je 0x4d85
callq 0x30e0
pushq $0x65
popq %rcx
cltd
idivl %ecx
cvtsi2ss %edx, %xmm0
mulss 0x45af(%rip), %xmm0     # 0x932c
movss %xmm0, 0x8757(%rip)     # 0xd4dc
cmpb %bpl, %r15b
je 0x4e01
movb 0x874f(%rip), %bpl      # 0xd4e0
movl $0x1d01, %edi           # imm = 0x1D01
callq 0x3590
movl $0xb50, %edi            # imm = 0xB50
cmpb $0x1, %bpl
jne 0x4de8
callq 0x32c0
movl $0x4000, %edi           # imm = 0x4000
callq 0x32c0
movl $0xb57, %edi            # imm = 0xB57
callq 0x32c0
jmp 0x4e01
movb 0x8709(%rip), %al       # 0xd4d0
testb %al, %al
jne 0x4f63
callq 0x788c
testl %eax, %eax
jle 0x4f5d
leaq 0x45c6(%rip), %rdi      # 0x93a9
jmp 0x4f7d
callq 0x30c0
movl $0x4000, %edi           # imm = 0x4000
callq 0x30c0
movl $0xb57, %edi            # imm = 0xB57
callq 0x30c0
callq 0x7a60
cvttss2si %xmm0, %rax
movq %rax, 0x86fe(%rip)      # 0xd510
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x32b0
movq %rax, 0x86f5(%rip)      # 0xd518
movslq 0x86ce(%rip), %rsi      # 0xd4f8
movl %esi, 0x86cc(%rip)      # 0xd4fc
cmpb $0x1, 0x86a9(%rip)      # 0xd4e0
jne 0x4f54
movq 0x86ac(%rip), %rcx      # 0xd4f0
movq %rcx, %rax
cqto
idivq %rsi
movq 0x8675(%rip), %rdx      # 0xd4c8
decq %rcx
testl %esi, %esi
movl $0x0, %edi
cmovgl %esi, %edi
testq %rax, %rax
cmovleq %r14, %rax
movl %ebx, %r8d
subl %esi, %r8d
cmpq %rax, %r14
je 0x4f54
imulq $0x28, %r14, %r9
addq %rdx, %r9
addq $0x20, %r9
xorl %r10d, %r10d
cmpl $0x2, %r10d
je 0x4f4c
xorl %r11d, %r11d
movq 0x8628(%rip), %r15      # 0xd4c0
cmpl %edi, %r11d
je 0x4f44
movslq (%r9), %r13
movslq %r11d, %r12
addq %r13, %r12
leal (%r12,%rsi), %ebp
movslq %ebp, %r13
cmpq %r13, %rcx
jle 0x4f3c
imulq $0x38, %r12, %r12
incl %r11d
cmpl %esi, %r11d
movl %ebx, %r13d
cmovel %r8d, %r13d
addl %ebp, %r13d
movslq %r13d, %r13
imulq $0x38, %r13, %r13
movsd 0x30(%r15,%r12), %xmm0
addsd 0x30(%r15,%r13), %xmm0
movupd 0x20(%r15,%r12), %xmm1
movupd 0x20(%r15,%r13), %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(%r15,%r12)
movsd %xmm0, 0x30(%r15,%r12)
jmp 0x4e98
incl %r11d
jmp 0x4e98
incl %r10d
jmp 0x4e84
incq %r14
jmp 0x4e6d
movb $0x1, 0x85c5(%rip)      # 0xd520
jmp 0x4f67
movb 0x856d(%rip), %al       # 0xd4d0
testb $0x1, %al
je 0x4f76
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4455(%rip), %rdi      # 0x93d2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40b7
movq %rax, %rbx
pushq $0x70
popq %rsi
movq %r14, %rdi
callq 0x3310
movq %rbx, %rdi
callq 0x35d0