// File: /workspace/github_c_makefile_star2_O1/schroeder-lvb[P]sissm/src/api.c
// Function: apiBotRespawn
int apiBotRespawn( int resetAlgo )
{
    char botMinStr[80], botMinResetStr[80],  botMaxStr[80], botMaxResetStr[80];
    int  botMin, botMinReset, botMax, botMaxReset;
    int errCode = 1;

    // Get minimumenemies/maximumenemies strings
    // Store and convert them to integers
    //
    strlcpy( botMinStr, apiGameModePropertyGet( "minimumenemies" ), 80 );
    strlcpy( botMaxStr, apiGameModePropertyGet( "maximumenemies" ), 80 );
    if ( 1 == sscanf( botMinStr, "%d", &botMin ) ) {
        if ( 1 == sscanf( botMaxStr, "%d", &botMax ) ) {
            errCode = 0;
        }
    }

    // drop the count by algo type
    //
    if ( errCode == 0) {

        logPrintf( LOG_LEVEL_INFO, "api", "apiBotReset algo ::%d:: min/max read ::%s::%s::", resetAlgo, botMinStr, botMaxStr );

        switch( resetAlgo ) {
        case 1: 
            botMinReset = 0;  botMaxReset = 0;
            break;
        case 2:                                            // minimum value 
            botMinReset = 1;  botMaxReset = 2;
            break;
        case 3:                                            // minus-one value
            botMinReset = botMin-1;  botMaxReset = botMax-1;
            break;
        case 4:                                            // half value 
            botMinReset = 1;  botMaxReset = botMax / 2;
            break;
        default:                                           // re-write same value
            botMinReset = botMin;  botMaxReset = botMax;   
            break;
        }
   
        snprintf( botMinResetStr, 80, "%d", botMinReset );
        snprintf( botMaxResetStr, 80, "%d", botMaxReset );
        errCode = _apiGameModePropertySet( "minimumenemies", botMinResetStr );
        if ( 0 == errCode )  {
            errCode = _apiGameModePropertySet( "maximumenemies", botMaxResetStr );
            logPrintf( LOG_LEVEL_INFO, "api", "apiBotReset min/max to ::%s::%s::", botMinResetStr, botMaxResetStr );
        }
        
    }

    // slight delay
    //
    if ( errCode == 0 ) 
        usleep( 250000 );   // 250,000us = 100ms = 0.25s
 
    // Restore minimumenemies/maximumenemies
    //
    if ( errCode == 0 ) {
        errCode |= _apiGameModePropertySet( "minimumenemies", botMinStr );
        errCode |= _apiGameModePropertySet( "maximumenemies", botMaxStr );
    }

    return( errCode );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movl %edi, %ebx
leaq 0x8547(%rip), %rdi      # 0x1ba43
callq 0x12e75
leaq 0x1586d8(%rip), %r14    # 0x16bbe0
leaq 0x60(%rsp), %r15
movl $0x50, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0xf038
leaq 0x852e(%rip), %rdi      # 0x1ba52
callq 0x12e75
leaq 0x10(%rsp), %rdi
movl $0x50, %edx
movq %r14, %rsi
callq 0xf038
leaq 0x8b8b(%rip), %rsi      # 0x1c0cd
leaq 0xc(%rsp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x82d0
movl $0x1, %r14d
cmpl $0x1, %eax
jne 0x13684
leaq 0x8b66(%rip), %rsi      # 0x1c0cd
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x82d0
cmpl $0x1, %eax
jne 0x13684
leaq 0xa905(%rip), %rsi      # 0x1de8f
leaq 0xaf27(%rip), %rdx      # 0x1e4b8
leaq 0x60(%rsp), %r8
leaq 0x10(%rsp), %r9
movl $0x2, %edi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1a227
decl %ebx
cmpl $0x3, %ebx
ja 0x135eb
leaq 0xa899(%rip), %rax      # 0x1de50
movslq (%rax,%rbx,4), %rcx
addq %rax, %rcx
xorl %ebx, %ebx
jmpq *%rcx
movl $0x2, %ebx
jmp 0x135e4
movl 0xc(%rsp), %ebp
decl %ebp
movl 0x8(%rsp), %ebx
decl %ebx
jmp 0x135f3
movl 0x8(%rsp), %eax
movl %eax, %ebx
shrl $0x1f, %ebx
addl %eax, %ebx
sarl %ebx
movl $0x1, %ebp
jmp 0x135f3
movl 0xc(%rsp), %ebp
movl 0x8(%rsp), %ebx
leaq 0x8ad3(%rip), %r14      # 0x1c0cd
leaq 0x100(%rsp), %r15
movl $0x50, %esi
movq %r15, %rdi
movq %r14, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x8190
leaq 0xb0(%rsp), %rdi
movl $0x50, %esi
movq %r14, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x8190
leaq 0x840d(%rip), %rdi      # 0x1ba43
movq %r15, %rsi
callq 0x12e1d
movl %eax, %r14d
testl %eax, %eax
jne 0x13684
leaq 0x8406(%rip), %rdi      # 0x1ba52
leaq 0xb0(%rsp), %rbx
movq %rbx, %rsi
callq 0x12e1d
movl %eax, %r14d
leaq 0xa829(%rip), %rsi      # 0x1de8f
leaq 0xae7b(%rip), %rdx      # 0x1e4e8
leaq 0x100(%rsp), %rcx
movl $0x2, %edi
movq %rbx, %r8
xorl %eax, %eax
callq 0x1a227
testl %r14d, %r14d
jne 0x136bd
movl $0x3d090, %edi          # imm = 0x3D090
callq 0x83f0
leaq 0x83a9(%rip), %rdi      # 0x1ba43
leaq 0x60(%rsp), %rsi
callq 0x12e1d
movl %eax, %ebx
leaq 0x83a5(%rip), %rdi      # 0x1ba52
leaq 0x10(%rsp), %rsi
callq 0x12e1d
movl %eax, %r14d
orl %ebx, %r14d
movl %r14d, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r14
popq %r15
popq %rbp
retq