// File: /workspace/github_c_makefile_star2_O3/schroeder-lvb[P]sissm/src/piantirush.c
// Function: startOfEverything
void _startOfEverything( void )
{
    int currentPlayerCount;
   
    // this block is for the offset timer/values used in "training mode" 
    // from PICLADMIN: "!wax on/off" 
    //
    if ( 0L == p2pGetL( "piantirush.p2p.training", 0L )) {
        piantirushConfig.trTimeOfs     = 0;
        piantirushConfig.trSlowOfs     = 0;
        piantirushConfig.trEarlyOfs    = 0;
        piantirushConfig.trEarDesOfs   = 0;
        piantirushConfig.trNPlayerOfs  = 0;
    }
    else {
        piantirushConfig.trTimeOfs     = piantirushConfig.lockIntervalSecTrainOffset;
        piantirushConfig.trSlowOfs     = piantirushConfig.slowIntervalSecTrainOffset;
        piantirushConfig.trEarlyOfs    = piantirushConfig.earlyBreachSpeedupTrainOffset;
        piantirushConfig.trEarDesOfs   = piantirushConfig.destroySpeedupTrainOffset;
        piantirushConfig.trNPlayerOfs  = piantirushConfig.nPlayerExemptionTrainOffset;
    }

    currentPlayerCount = apiPlayersGetCount();
    if (currentPlayerCount >= piantirushConfig.nPlayerLockThreshold ) {
        alarmReset( aPtr, piantirushConfig.lockIntervalSec + piantirushConfig.trTimeOfs );
        if ( 0L != p2pGetL( "piantirush.p2p.training", 0L ) )     // if training mode enabled "on" or "perm"
            alarmReset( xPtr, piantirushConfig.lockIntervalSec );   // training mode reminder
        // logPrintf(LOG_LEVEL_DEBUG, "piantirush", "Antirush start LOCK alarm set %d", piantirushConfig.lockIntervalSec + piantirushConfig.trTimeOfs);
        _captureSpeed( 2 );
    }
    else if (currentPlayerCount > ( piantirushConfig.nPlayerExemption + piantirushConfig.trNPlayerOfs ) )  { 
        if ( 0L != p2pGetL( "piantirush.p2p.training", 0L ) )     // if training mode enabled "on" or "perm"
            alarmReset( xPtr, piantirushConfig.slowIntervalSec );   // training mode reminder 
        alarmReset( aPtr, piantirushConfig.slowIntervalSec +  piantirushConfig.trSlowOfs);
        // logPrintf(LOG_LEVEL_DEBUG, "piantirush", "Antirush start SLOW alarm set %d", piantirushConfig.lockIntervalSec +  piantirushConfig.trSlowOfs);
        _captureSpeed( 1 );
    }
    else {
        alarmCancel( aPtr );  
        alarmCancel( xPtr );
        _captureSpeed( 0 );   
    }

    return;

}

// Assembly:
pushq %rbx
leaq 0x5d5a(%rip), %rdi      # 0x1b90a
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x181e1
movl $0x0, %ecx
movl $0x0, %edx
movl $0x0, %esi
movl $0x0, %edi
testq %rax, %rax
je 0x15bf0
movl 0x207d04(%rip), %ebx    # 0x21d8dc
movl 0x207d06(%rip), %ecx    # 0x21d8e4
movl 0x207d08(%rip), %edx    # 0x21d8ec
movl 0x207d0a(%rip), %esi    # 0x21d8f4
movl 0x207d0c(%rip), %edi    # 0x21d8fc
movl %ebx, 0x207cea(%rip)    # 0x21d8e0
movl %ecx, 0x207cec(%rip)    # 0x21d8e8
movl %edx, 0x207cee(%rip)    # 0x21d8f0
movl %esi, 0x207cf0(%rip)    # 0x21d8f8
movl %edi, 0x207cf2(%rip)    # 0x21d900
callq 0x13853
cmpl 0x201c8f(%rip), %eax    # 0x2178a8
jge 0x15c79
movl 0x207cdf(%rip), %ecx    # 0x21d900
addl 0x201c7d(%rip), %ecx    # 0x2178a4
cmpl %ecx, %eax
jle 0x15cc3
leaq 0x5cd4(%rip), %rdi      # 0x1b90a
xorl %esi, %esi
callq 0x181e1
testq %rax, %rax
je 0x15c55
movq 0x209cdf(%rip), %rdi    # 0x21f928
movslq 0x20285c(%rip), %rsi    # 0x2184ac
callq 0xfc98
movq 0x209cc4(%rip), %rdi    # 0x21f920
movslq 0x202849(%rip), %rax    # 0x2184ac
movslq 0x207c7e(%rip), %rsi    # 0x21d8e8
addq %rax, %rsi
callq 0xfc98
movl $0x1, %ebx
jmp 0x15cdd
movq 0x209ca0(%rip), %rdi    # 0x21f920
movslq 0x203429(%rip), %rax    # 0x2190b0
movslq 0x207c52(%rip), %rsi    # 0x21d8e0
addq %rax, %rsi
callq 0xfc98
leaq 0x5c6d(%rip), %rdi      # 0x1b90a
xorl %esi, %esi
callq 0x181e1
movl $0x2, %ebx
testq %rax, %rax
je 0x15cdd
movq 0x209c73(%rip), %rdi    # 0x21f928
movslq 0x2033f4(%rip), %rsi    # 0x2190b0
callq 0xfc98
jmp 0x15cdd
movq 0x209c56(%rip), %rdi    # 0x21f920
callq 0xfcb9
movq 0x209c52(%rip), %rdi    # 0x21f928
callq 0xfcb9
xorl %ebx, %ebx
movl %ebx, %edi
popq %rbx
jmp 0x15ce2