// File: /workspace/github_c_makefile_star2_O1/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 0x5fd6(%rip), %rdi      # 0x1b912
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x18004
testq %rax, %rax
je 0x15982
movl 0x207f8c(%rip), %eax    # 0x21d8dc
movl %eax, 0x207f8a(%rip)    # 0x21d8e0
movl 0x207f88(%rip), %eax    # 0x21d8e4
movl %eax, 0x207f86(%rip)    # 0x21d8e8
movl 0x207f84(%rip), %eax    # 0x21d8ec
movl %eax, 0x207f82(%rip)    # 0x21d8f0
movl 0x207f80(%rip), %eax    # 0x21d8f4
movl %eax, 0x207f7e(%rip)    # 0x21d8f8
movl 0x207f7c(%rip), %ebx    # 0x21d8fc
jmp 0x1599a
movl %ebx, 0x207f58(%rip)    # 0x21d8e0
movl %ebx, 0x207f5a(%rip)    # 0x21d8e8
movl %ebx, 0x207f5c(%rip)    # 0x21d8f0
movl %ebx, 0x207f5e(%rip)    # 0x21d8f8
movl %ebx, 0x207f60(%rip)    # 0x21d900
callq 0x134dc
cmpl 0x201efd(%rip), %eax    # 0x2178a8
jge 0x15a0b
movl 0x207f4d(%rip), %ecx    # 0x21d900
addl 0x201eeb(%rip), %ecx    # 0x2178a4
cmpl %ecx, %eax
jle 0x15a55
leaq 0x5f4a(%rip), %rdi      # 0x1b912
xorl %esi, %esi
callq 0x18004
testq %rax, %rax
je 0x159e7
movq 0x209f4d(%rip), %rdi    # 0x21f928
movslq 0x202aca(%rip), %rsi    # 0x2184ac
callq 0xf953
movq 0x209f32(%rip), %rdi    # 0x21f920
movslq 0x202ab7(%rip), %rax    # 0x2184ac
movslq 0x207eec(%rip), %rsi    # 0x21d8e8
addq %rax, %rsi
callq 0xf953
movl $0x1, %ebx
jmp 0x15a6f
movq 0x209f0e(%rip), %rdi    # 0x21f920
movslq 0x203697(%rip), %rax    # 0x2190b0
movslq 0x207ec0(%rip), %rsi    # 0x21d8e0
addq %rax, %rsi
callq 0xf953
leaq 0x5ee3(%rip), %rdi      # 0x1b912
xorl %esi, %esi
callq 0x18004
movl $0x2, %ebx
testq %rax, %rax
je 0x15a6f
movq 0x209ee1(%rip), %rdi    # 0x21f928
movslq 0x203662(%rip), %rsi    # 0x2190b0
callq 0xf953
jmp 0x15a6f
movq 0x209ec4(%rip), %rdi    # 0x21f920
callq 0xf974
movq 0x209ec0(%rip), %rdi    # 0x21f928
callq 0xf974
xorl %ebx, %ebx
movl %ebx, %edi
popq %rbx
jmp 0x15a74