// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movl %edi, -0x4(%rbp)
movl $0x1, -0x164(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq 0xb9f9(%rip), %rdi      # 0x23a43
callq 0x17720
movq -0x178(%rbp), %rdi
movq %rax, %rsi
movl $0x50, %edx
callq 0x11bc0
leaq -0x100(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq 0xb9da(%rip), %rdi      # 0x23a52
callq 0x17720
movq -0x170(%rbp), %rdi
movq %rax, %rsi
movl $0x50, %edx
callq 0x11bc0
leaq -0x60(%rbp), %rdi
leaq 0xc033(%rip), %rsi      # 0x240cf
leaq -0x154(%rbp), %rdx
movb $0x0, %al
callq 0x82c0
movl %eax, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x180e8
leaq -0x100(%rbp), %rdi
leaq 0xc00c(%rip), %rsi      # 0x240cf
leaq -0x15c(%rbp), %rdx
movb $0x0, %al
callq 0x82c0
movl %eax, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x180e6
movl $0x0, -0x164(%rbp)
jmp 0x180e8
cmpl $0x0, -0x164(%rbp)
jne 0x18275
movl -0x4(%rbp), %ecx
leaq 0xdd98(%rip), %rsi      # 0x25e97
leaq 0xe3ba(%rip), %rdx      # 0x264c0
xorl %eax, %eax
movl $0x2, %edi
leaq -0x60(%rbp), %r8
leaq -0x100(%rbp), %r9
callq 0x21bf0
movl -0x4(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x180(%rbp)
subl $0x3, %eax
ja 0x181b7
movq -0x180(%rbp), %rax
leaq 0xdd16(%rip), %rcx      # 0x25e58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x158(%rbp)
movl $0x0, -0x160(%rbp)
jmp 0x181cf
movl $0x1, -0x158(%rbp)
movl $0x2, -0x160(%rbp)
jmp 0x181cf
movl -0x154(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x158(%rbp)
movl -0x15c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x160(%rbp)
jmp 0x181cf
movl $0x1, -0x158(%rbp)
movl -0x15c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x160(%rbp)
jmp 0x181cf
movl -0x154(%rbp), %eax
movl %eax, -0x158(%rbp)
movl -0x15c(%rbp), %eax
movl %eax, -0x160(%rbp)
leaq -0xb0(%rbp), %rdi
movl -0x158(%rbp), %ecx
movl $0x50, %esi
leaq 0xbee7(%rip), %rdx      # 0x240cf
movb $0x0, %al
callq 0x8180
leaq -0x150(%rbp), %rdi
movl -0x160(%rbp), %ecx
movl $0x50, %esi
leaq 0xbec7(%rip), %rdx      # 0x240cf
movb $0x0, %al
callq 0x8180
leaq -0xb0(%rbp), %rsi
leaq 0xb826(%rip), %rdi      # 0x23a43
callq 0x17680
movl %eax, -0x164(%rbp)
xorl %eax, %eax
cmpl -0x164(%rbp), %eax
jne 0x18273
leaq -0x150(%rbp), %rsi
leaq 0xb812(%rip), %rdi      # 0x23a52
callq 0x17680
movl %eax, -0x164(%rbp)
leaq -0xb0(%rbp), %rcx
leaq -0x150(%rbp), %r8
movl $0x2, %edi
leaq 0xdc32(%rip), %rsi      # 0x25e97
leaq 0xe284(%rip), %rdx      # 0x264f0
movb $0x0, %al
callq 0x21bf0
jmp 0x18275
cmpl $0x0, -0x164(%rbp)
jne 0x18288
movl $0x3d090, %edi          # imm = 0x3D090
callq 0x83c0
cmpl $0x0, -0x164(%rbp)
jne 0x182cc
leaq -0x60(%rbp), %rsi
leaq 0xb7a7(%rip), %rdi      # 0x23a43
callq 0x17680
orl -0x164(%rbp), %eax
movl %eax, -0x164(%rbp)
leaq -0x100(%rbp), %rsi
leaq 0xb797(%rip), %rdi      # 0x23a52
callq 0x17680
orl -0x164(%rbp), %eax
movl %eax, -0x164(%rbp)
movl -0x164(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopl (%rax,%rax)