// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x122b0
leaq -0x80(%rbp), %rdi
callq 0x122b0
movq -0x8(%rbp), %rdi
callq 0x8110
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0xcad5
leaq 0x174e8(%rip), %rdi     # 0x23faa
movb $0x0, %al
callq 0x17af0
movl $0x1, -0x1c(%rbp)
jmp 0xcdf0
movl $0x2, -0x228(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0xcd16
movq -0x18(%rbp), %rdi
movl -0x228(%rbp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
leaq 0x17653(%rip), %rdx     # 0x24158
callq 0x122d0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xcb1a
jmp 0xcd16
movq -0x30(%rbp), %rdi
callq 0x8110
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0xcb32
jmp 0xcd16
leaq -0xd0(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0x50, %edx
callq 0x11bc0
leaq -0xd0(%rbp), %rdi
leaq 0x174aa(%rip), %rsi     # 0x23fff
callq 0x8040
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xcb7a
leaq -0xd0(%rbp), %rdi
leaq 0x17485(%rip), %rsi     # 0x23ff5
movl $0x50, %edx
callq 0x11bc0
leaq -0xd0(%rbp), %rdi
leaq 0x17480(%rip), %rsi     # 0x24008
callq 0x8200
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xcba1
movl $0x1, -0x28(%rbp)
jmp 0xcd11
leaq -0xd0(%rbp), %rdi
leaq 0x17423(%rip), %rsi     # 0x23fd2
callq 0x8340
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0xcbca
movl $0x1, -0x20(%rbp)
jmp 0xcd0f
leaq -0xd0(%rbp), %rdi
leaq 0x17401(%rip), %rsi     # 0x23fd9
callq 0x8340
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0xcbf3
movl $0x1, -0x24(%rbp)
jmp 0xcd0d
leaq -0xd0(%rbp), %rdi
callq 0x18920
cmpl $0x0, %eax
je 0xcc1e
leaq -0x80(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x50, %edx
callq 0x11bc0
jmp 0xcd0b
leaq -0xd0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
movl $0x50, %edx
callq 0x18ca0
movl %eax, -0x22c(%rbp)
movl -0x22c(%rbp), %eax
movl %eax, -0x230(%rbp)
testl %eax, %eax
je 0xcc5b
jmp 0xcc4e
movl -0x230(%rbp), %eax
subl $0x1, %eax
je 0xcc9a
jmp 0xcccc
leaq -0xd0(%rbp), %rsi
leaq 0x173a1(%rip), %rdi     # 0x2400a
movb $0x0, %al
callq 0x17af0
leaq -0xd0(%rbp), %rcx
movl $0x2, %edi
leaq 0x17004(%rip), %rsi     # 0x23c87
leaq 0x17380(%rip), %rdx     # 0x2400a
movb $0x0, %al
callq 0x21bf0
movl $0x1, -0x1c(%rbp)
jmp 0xcd09
leaq -0x220(%rbp), %rdi
leaq -0x120(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x11aa0
leaq -0x220(%rbp), %rdi
leaq 0x19d19(%rip), %rsi     # 0x269d9
movl $0x100, %edx            # imm = 0x100
callq 0x11aa0
jmp 0xcd09
leaq -0xd0(%rbp), %rsi
leaq 0x17352(%rip), %rdi     # 0x2402c
movb $0x0, %al
callq 0x17af0
leaq -0xd0(%rbp), %rcx
movl $0x2, %edi
leaq 0x16f93(%rip), %rsi     # 0x23c87
leaq 0x17331(%rip), %rdx     # 0x2402c
movb $0x0, %al
callq 0x21bf0
movl $0x1, -0x1c(%rbp)
jmp 0xcd0b
jmp 0xcd0d
jmp 0xcd0f
jmp 0xcd11
jmp 0xcadf
leaq -0x220(%rbp), %rdi
callq 0x8110
movl %eax, %ecx
movl %ecx, -0x224(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0xcd43
movl -0x224(%rbp), %eax
subl $0x1, %eax
cltq
movb $0x0, -0x220(%rbp,%rax)
xorl %eax, %eax
cmpl -0x1c(%rbp), %eax
jne 0xcdda
movl $0x2, %edi
leaq 0x16f2d(%rip), %rsi     # 0x23c87
leaq 0x172e8(%rip), %rdx     # 0x24049
movb $0x0, %al
callq 0x21bf0
movq -0x8(%rbp), %rcx
leaq -0x80(%rbp), %r8
movl -0x24(%rbp), %r9d
movl -0x20(%rbp), %eax
movl $0x2, %edi
leaq 0x16f04(%rip), %rsi     # 0x23c87
leaq 0x172f4(%rip), %rdx     # 0x2407e
movl %eax, (%rsp)
movb $0x0, %al
callq 0x21bf0
leaq -0x220(%rbp), %rcx
movl -0x28(%rbp), %r8d
movl $0x2, %edi
leaq 0x16edc(%rip), %rsi     # 0x23c87
leaq 0x17306(%rip), %rdx     # 0x240b8
movb $0x0, %al
callq 0x21bf0
movq -0x8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl -0x24(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq -0x220(%rbp), %r8
movl -0x28(%rbp), %r9d
callq 0x18990
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0xcdee
leaq 0x172eb(%rip), %rdi     # 0x240d2
movb $0x0, %al
callq 0x17af0
jmp 0xcdf0
movl -0x1c(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nopl (%rax)