// File: /workspace/github_c_makefile_star2_O2/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 0x5cfa(%rip), %rdi      # 0x1a90a
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x17172
movl $0x0, %ecx
movl $0x0, %edx
movl $0x0, %esi
movl $0x0, %edi
testq %rax, %rax
je 0x14c50
movl 0x208ca4(%rip), %ebx    # 0x21d8dc
movl 0x208ca6(%rip), %ecx    # 0x21d8e4
movl 0x208ca8(%rip), %edx    # 0x21d8ec
movl 0x208caa(%rip), %esi    # 0x21d8f4
movl 0x208cac(%rip), %edi    # 0x21d8fc
movl %ebx, 0x208c8a(%rip)    # 0x21d8e0
movl %ecx, 0x208c8c(%rip)    # 0x21d8e8
movl %edx, 0x208c8e(%rip)    # 0x21d8f0
movl %esi, 0x208c90(%rip)    # 0x21d8f8
movl %edi, 0x208c92(%rip)    # 0x21d900
callq 0x12ab4
cmpl 0x202c2f(%rip), %eax    # 0x2178a8
jge 0x14cd7
movl 0x208c7f(%rip), %ecx    # 0x21d900
addl 0x202c1d(%rip), %ecx    # 0x2178a4
cmpl %ecx, %eax
jle 0x14d1f
leaq 0x5c74(%rip), %rdi      # 0x1a90a
xorl %esi, %esi
callq 0x17172
testq %rax, %rax
je 0x14cb5
movq 0x20ac7f(%rip), %rdi    # 0x21f928
movslq 0x2037fc(%rip), %rsi    # 0x2184ac
callq 0xf1b1
movq 0x20ac64(%rip), %rdi    # 0x21f920
movslq 0x2037e9(%rip), %rax    # 0x2184ac
movslq 0x208c1e(%rip), %rsi    # 0x21d8e8
addq %rax, %rsi
callq 0xf1b1
pushq $0x1
popq %rbx
jmp 0x14d39
movq 0x20ac42(%rip), %rdi    # 0x21f920
movslq 0x2043cb(%rip), %rax    # 0x2190b0
movslq 0x208bf4(%rip), %rsi    # 0x21d8e0
addq %rax, %rsi
callq 0xf1b1
leaq 0x5c0f(%rip), %rdi      # 0x1a90a
xorl %esi, %esi
callq 0x17172
pushq $0x2
popq %rbx
testq %rax, %rax
je 0x14d39
movq 0x20ac17(%rip), %rdi    # 0x21f928
movslq 0x204398(%rip), %rsi    # 0x2190b0
callq 0xf1b1
jmp 0x14d39
movq 0x20abfa(%rip), %rdi    # 0x21f920
callq 0xf1d2
movq 0x20abf6(%rip), %rdi    # 0x21f928
callq 0xf1d2
xorl %ebx, %ebx
movl %ebx, %edi
popq %rbx
jmp 0x14d3e