// File: /workspace/github_c_makefile_star2_O3/schroeder-lvb[P]sissm/src/picladmin.c
// Function: cmdMap
int _cmdMap( char *arg, char *arg2, char *passThru )
{
    int errCode = 0;
    int isNight = 0, isIns = 0, clearMutators = 0;
    char *w, gameMode[80], wordBuf[80], mutName[80];
    char mutatorsList[256];
    int i, j, c;

    strclr( mutatorsList );
    strclr( gameMode );

    if ( 0 == strlen( arg ) ) {
        apiSaySys( "You must specify a map.  Type !maplist");
        errCode = 1;
    }
    else {
        //
        // Walk through each word to determine if it is "ins", "sec", 
        // "day", "night" or any of the approved mutators or game modes.
        // The check order may be important in the future.
        //
        j = 2;
        while ( errCode == 0 ) {

            w = getWord( passThru, j++, " " );
            if ( w == NULL )       break;
            if ( 0 == strlen( w )) break;
         
            strlcpy( wordBuf, w, 80 );

            // alias 
            //
            if ( 0 == strcasecmp( wordBuf, "hardcore" )) strlcpy( wordBuf, "checkpointhardcore", 80 );

            // process each word
            //
            if ( 0 == strcmp( wordBuf, "@" ) ) 
                clearMutators = 1;
            else if (NULL != strcasestr( wordBuf, "night" )) 
                isNight = 1;
            else if (NULL != strcasestr( wordBuf, "ins"   )) 
                isIns   = 1;
            else if ( apiIsSupportedGameMode( wordBuf ) ) {
                strlcpy( gameMode, wordBuf, 80 );
            }
            else {
                c = apiMutLookup( wordBuf, mutName, 80 );
                switch (c) {
                    case 0:
                        apiSaySys("Unknown game mode or mutator '%s'", wordBuf );
                        logPrintf(  LOG_LEVEL_INFO, "picladmin", "Unknown game mode or mutator '%s'", wordBuf );
                        errCode = 1;
                        break;
                    case 1:
                        strlcat( mutatorsList, mutName, 256 );
                        strlcat( mutatorsList, ",",     256 );
                        break;
                    default:
                        apiSaySys("Ambiguious mutator name '%s'", wordBuf );
                        logPrintf(  LOG_LEVEL_INFO, "picladmin", "Ambiguious mutator name '%s'", wordBuf );
                        errCode = 1;
                        break;
                }
            }
        }

        // clean up the mutatorsList (remove trailing comma)
        //
        if ( 0 != ( i = (int) strlen( mutatorsList ) )) {
            mutatorsList[ i-1 ] = 0;
        }

        if ( 0 == errCode ) {
            // change map
            logPrintf(  LOG_LEVEL_INFO, "picladmin", "----------------------------------------------------" );
            logPrintf(  LOG_LEVEL_INFO, "picladmin", "Map change to '%s' Mode '%s'  Sec/Ins '%d' Day/Night '%d'", arg, gameMode, isIns, isNight );
            logPrintf(  LOG_LEVEL_INFO, "picladmin", "Mutators: '%s'  clear: %d", mutatorsList, clearMutators );
            errCode = apiMapChange( arg, gameMode, isIns, isNight, mutatorsList, clearMutators );
        }

        if ( errCode ) {
            apiSaySys( "Map/mode/side/mutator not found" );
        }
    }
    return errCode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdx, %r13
movq %rdi, %rbx
leaq 0xc0(%rsp), %rdi
callq 0xf829
leaq 0x70(%rsp), %rdi
callq 0xf829
movl $0x1, %r15d
cmpb $0x0, (%rbx)
je 0xbc51
movq %rbx, 0x18(%rsp)
leaq 0x10672(%rip), %rdx     # 0x1c14e
movq %r13, %rdi
movl $0x2, %esi
callq 0xf82d
movb $0x1, %bpl
testq %rax, %rax
je 0xbc5d
movl $0x0, 0x10(%rsp)
movl $0x3, %r14d
leaq 0x20(%rsp), %r12
leaq 0x1c0(%rsp), %r15
leaq 0x10637(%rip), %rbp     # 0x1c14e
movl $0x0, 0xc(%rsp)
movl $0x0, 0x14(%rsp)
movq %r15, %rbx
cmpb $0x0, (%rax)
je 0xbc46
movl $0x50, %edx
movq %r12, %rdi
movq %rax, %rsi
callq 0xf384
movq %r12, %rdi
leaq 0x104aa(%rip), %rsi     # 0x1bff7
callq 0x8060
testl %eax, %eax
je 0xbb6b
cmpw $0x40, 0x20(%rsp)
jne 0xbb7f
movl $0x1, 0x10(%rsp)
jmp 0xbc25
movups 0x1047b(%rip), %xmm0    # 0x1bfed
movaps %xmm0, 0x20(%rsp)
movl $0x65726f, 0x2f(%rsp)   # imm = 0x65726F
movq %r12, %rdi
leaq 0x10441(%rip), %rsi     # 0x1bfca
callq 0x8350
testq %rax, %rax
je 0xbba0
movl $0x1, 0x14(%rsp)
jmp 0xbc25
movq %r12, %rdi
leaq 0x10427(%rip), %rsi     # 0x1bfd1
callq 0x8350
testq %rax, %rax
je 0xbbbe
movl $0x1, 0xc(%rsp)
jmp 0xbc25
movq %r12, %rdi
callq 0x13e8a
testl %eax, %eax
je 0xbbde
movl $0x50, %edx
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
callq 0xf384
jmp 0xbc25
movq %r12, %rdi
movq %r15, %rsi
movl $0x50, %edx
callq 0x140d4
cmpl $0x1, %eax
jne 0xbd61
movl $0x100, %edx            # imm = 0x100
leaq 0xc0(%rsp), %rdi
movq %r15, %rsi
callq 0xf310
movl $0x100, %edx            # imm = 0x100
leaq 0xc0(%rsp), %rdi
leaq 0x12d95(%rip), %rsi     # 0x1e9b5
callq 0xf310
leal 0x1(%r14), %r15d
movq %r13, %rdi
movl %r14d, %esi
movq %rbp, %rdx
callq 0xf82d
movl %r15d, %r14d
testq %rax, %rax
movq %rbx, %r15
jne 0xbb2a
movl $0x1, %r15d
movb $0x1, %bpl
jmp 0xbc75
leaq 0x1034a(%rip), %rbx     # 0x1bfa2
jmp 0xbd40
movl $0x0, 0x14(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x8120
testl %eax, %eax
je 0xbc92
decl %eax
cltq
movb $0x0, 0xc0(%rsp,%rax)
leaq 0x1042f(%rip), %rbx     # 0x1c0c8
testb %bpl, %bpl
je 0xbd40
leaq 0xffd6(%rip), %r14      # 0x1bc7f
leaq 0x1038f(%rip), %rdx     # 0x1c03f
xorl %ebp, %ebp
movl $0x2, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1a3e3
movl 0x14(%rsp), %r12d
movl %r12d, (%rsp)
leaq 0x103a3(%rip), %rdx     # 0x1c074
leaq 0x70(%rsp), %r8
movl $0x2, %edi
movq %r14, %rsi
movq 0x18(%rsp), %r15
movq %r15, %rcx
movl 0xc(%rsp), %r13d
movl %r13d, %r9d
xorl %eax, %eax
callq 0x1a3e3
leaq 0x103b2(%rip), %rdx     # 0x1c0ae
leaq 0xc0(%rsp), %rcx
movl $0x2, %edi
movq %r14, %rsi
movl 0x10(%rsp), %r14d
movl %r14d, %r8d
xorl %eax, %eax
callq 0x1a3e3
movq %r15, %rdi
leaq 0x70(%rsp), %rsi
movl %r13d, %edx
movl %r12d, %ecx
leaq 0xc0(%rsp), %r8
movl %r14d, %r9d
callq 0x13ece
movl %eax, %r15d
testl %eax, %eax
je 0xbd4d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x134e5
movl %r15d, %ebp
movl %ebp, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %eax, %eax
jne 0xbd6e
leaq 0x10294(%rip), %rbx     # 0x1c000
jmp 0xbd75
leaq 0x102ad(%rip), %rbx     # 0x1c022
movl $0x1, %r15d
xorl %ebp, %ebp
leaq 0x20(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x134e5
leaq 0xfee9(%rip), %rsi      # 0x1bc7f
movl $0x2, %edi
movq %rbx, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1a3e3
jmp 0xbc75