// File: /workspace/github_c_makefile_star2_O1/schroeder-lvb[P]sissm/src/api.c
// Function: apiMapChange
int apiMapChange( char *mapName, char *gameMode, int secIns, int dayNight, char *mutatorsList, int clearMutators )
{
    int i, errCode = 1;
    char strOut[300], strResp[300];

    for (i = 0; i<API_MAXMAPS; i++ ) {

        if ( 0 == strlen( mapCycleList[i].reqName ))  
            break;

        // For map change to execute, the mapCycleList[].travel element must match input parameters 
        // on 1) day-night, 2) ins-security, and 3) either gamemode must be 'blank' or must match what is specified
        //
        if ( NULL != strcasestr( mapCycleList[i].reqName, mapName ) ) {
            if ( mapCycleList[i].dayNight == dayNight ) {
                if (( mapCycleList[i].secIns == -1 ) || ( mapCycleList[i].secIns == secIns )) {
                    if ( ( 0 == strlen( gameMode )) || ( 0 == strcasecmp( mapCycleList[i].gameMode, gameMode )) ) {
                        snprintf( strOut, 300, "travel %s", mapCycleList[i].traveler );
                        if ( 0 != strlen( mutatorsList )) {
                            strlcat( strOut, "?Mutators=", 300 );
                            if ( clearMutators ) strlcat( strOut, "?", 300 );
                            strlcat( strOut, mutatorsList, 300 );
                        }
                        logPrintf( LOG_LEVEL_INFO, "api", "*** Admin command map change ::%s::", strOut );
                        apiRcon( strOut, strResp );
                        errCode = 0;
                        break;
                    }
                } 
            }
        } 
    }

    if ( errCode ) {
        logPrintf( LOG_LEVEL_INFO, "api", 
            "Admin issued invalid map change ::%s::%d::%d", 
            mapName, secIns, dayNight );
    }
                        
    return( errCode );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movl %r9d, 0xc(%rsp)
movq %r8, 0x10(%rsp)
movl %ecx, %ebx
movl %edx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, %r14
leaq 0x164747(%rip), %r13    # 0x1782f8
xorl %ebp, %ebp
movl $0x1, %r15d
cmpb $0x0, -0x308(%r13)
je 0x13c1f
leaq -0x308(%r13), %rdi
movq %r14, %rsi
callq 0x8350
testq %rax, %rax
je 0x13c08
cmpl %ebx, -0x8(%r13)
jne 0x13c08
movl -0x4(%r13), %eax
cmpl $-0x1, %eax
setne %cl
cmpl 0x8(%rsp), %eax
setne %al
testb %al, %cl
jne 0x13c08
cmpb $0x0, (%r12)
je 0x13c5f
movq %r13, %rdi
movq %r12, %rsi
callq 0x8060
testl %eax, %eax
je 0x13c5f
addq $-0x430, %rbp           # imm = 0xFBD0
addq $0x430, %r13            # imm = 0x430
cmpq $-0x86000, %rbp         # imm = 0xFFF7A000
jne 0x13bb9
xorl %eax, %eax
testb %al, %al
jne 0x13c4a
leaq 0xa263(%rip), %rsi      # 0x1de8f
leaq 0xaa4c(%rip), %rdx      # 0x1e67f
movl $0x2, %edi
movq %r14, %rcx
movl 0x8(%rsp), %r8d
movl %ebx, %r9d
xorl %eax, %eax
callq 0x1a227
movl %r15d, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16428a(%rip), %rcx    # 0x177ef0
subq %rbp, %rcx
addq $0x300, %rcx            # imm = 0x300
leaq 0xa9cd(%rip), %rdx      # 0x1e644
xorl %r15d, %r15d
leaq 0x20(%rsp), %rdi
movl $0x12c, %esi            # imm = 0x12C
xorl %eax, %eax
callq 0x8190
movq 0x10(%rsp), %r12
cmpb $0x0, (%r12)
je 0x13cdc
leaq 0xa9b0(%rip), %rsi      # 0x1e64e
leaq 0x20(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
callq 0xefc4
cmpl $0x0, 0xc(%rsp)
je 0x13cca
leaq 0xa99e(%rip), %rsi      # 0x1e659
leaq 0x20(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
callq 0xefc4
leaq 0x20(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
movq %r12, %rsi
callq 0xefc4
leaq 0xa1ac(%rip), %rsi      # 0x1de8f
leaq 0xa971(%rip), %rdx      # 0x1e65b
leaq 0x20(%rsp), %r12
movl $0x2, %edi
movq %r12, %rcx
xorl %eax, %eax
callq 0x1a227
movq 0xc5783(%rip), %rdi     # 0xd9488
leaq 0x150(%rsp), %rcx
leaq 0x1c(%rsp), %r8
movl $0x2, %esi
movq %r12, %rdx
callq 0x9748
movb $0x1, %al
jmp 0x13c21