// File: /workspace/github_c_makefile_star2_O2/msteveb[P]autosetup/./jimsh0.c
// Function: Jim_LsearchCoreCommand
static int Jim_LsearchCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    static const char * const options[] = {
        "-bool", "-not", "-nocase", "-exact", "-glob", "-regexp", "-all", "-inline", "-command",
        "-stride", "-index", NULL
    };
    enum
    { OPT_BOOL, OPT_NOT, OPT_NOCASE, OPT_EXACT, OPT_GLOB, OPT_REGEXP, OPT_ALL, OPT_INLINE,
            OPT_COMMAND, OPT_STRIDE, OPT_INDEX };
    int i;
    int opt_bool = 0;
    int opt_not = 0;
    int opt_all = 0;
    int opt_inline = 0;
    int opt_match = OPT_EXACT;
    int listlen;
    int rc = JIM_OK;
    Jim_Obj *listObjPtr = NULL;
    Jim_Obj *commandObj = NULL;
    Jim_Obj *indexObj = NULL;
    int match_flags = 0;
    long stride = 1;

    if (argc < 3) {
      wrongargs:
        Jim_WrongNumArgs(interp, 1, argv,
            "?-exact|-glob|-regexp|-command 'command'? ?-bool|-inline? ?-not? ?-nocase? ?-all? ?-stride len? ?-index val? list value");
        return JIM_ERR;
    }

    for (i = 1; i < argc - 2; i++) {
        int option;

        if (Jim_GetEnum(interp, argv[i], options, &option, NULL, JIM_ERRMSG) != JIM_OK) {
            return JIM_ERR;
        }
        switch (option) {
            case OPT_BOOL:
                opt_bool = 1;
                opt_inline = 0;
                break;
            case OPT_NOT:
                opt_not = 1;
                break;
            case OPT_NOCASE:
                match_flags |= JIM_NOCASE;
                break;
            case OPT_INLINE:
                opt_inline = 1;
                opt_bool = 0;
                break;
            case OPT_ALL:
                opt_all = 1;
                break;
            case OPT_REGEXP:
                opt_match = option;
                match_flags |= JIM_OPT_END;
                break;
            case OPT_COMMAND:
                if (i >= argc - 2) {
                    goto wrongargs;
                }
                commandObj = argv[++i];

            case OPT_EXACT:
            case OPT_GLOB:
                opt_match = option;
                break;
            case OPT_INDEX:
                if (i >= argc - 2) {
                    goto wrongargs;
                }
                indexObj = argv[++i];
                break;
            case OPT_STRIDE:
                if (i >= argc - 2) {
                    goto wrongargs;
                }
                if (Jim_GetLong(interp, argv[++i], &stride) != JIM_OK) {
                    return JIM_ERR;
                }
                if (stride < 1) {
                    Jim_SetResultString(interp, "stride length must be at least 1", -1);
                    return JIM_ERR;
                }
                break;
        }
    }

    argc -= i;
    if (argc < 2) {
        goto wrongargs;
    }
    argv += i;

    listlen = Jim_ListLength(interp, argv[0]);
    if (listlen % stride) {
        Jim_SetResultString(interp, "list size must be a multiple of the stride length", -1);
        return JIM_ERR;
    }

    if (opt_all) {
        listObjPtr = Jim_NewListObj(interp, NULL, 0);
    }
    if (opt_match == OPT_REGEXP) {
        commandObj = Jim_NewStringObj(interp, "regexp", -1);
    }
    if (commandObj) {
        Jim_IncrRefCount(commandObj);
    }

    for (i = 0; i < listlen; i += stride) {
        int eq = 0;
        Jim_Obj *searchListObj;
        Jim_Obj *objPtr;
        int offset;

        if (indexObj) {
            int indexlen = Jim_ListLength(interp, indexObj);
            if (stride == 1) {
                searchListObj = Jim_ListGetIndex(interp, argv[0], i);
            }
            else {
                searchListObj = Jim_NewListObj(interp, argv[0]->internalRep.listValue.ele + i, stride);
            }
            Jim_IncrRefCount(searchListObj);
            rc = Jim_ListIndices(interp, searchListObj, indexObj->internalRep.listValue.ele, indexlen, &objPtr, JIM_ERRMSG);
            if (rc != JIM_OK) {
                Jim_DecrRefCount(interp, searchListObj);
                rc = JIM_ERR;
                goto done;
            }

            offset = 0;
        }
        else {

            searchListObj = argv[0];
            offset = i;
            objPtr = Jim_ListGetIndex(interp, searchListObj, i);
            Jim_IncrRefCount(searchListObj);
        }

        switch (opt_match) {
            case OPT_EXACT:
                eq = Jim_StringCompareObj(interp, argv[1], objPtr, match_flags) == 0;
                break;

            case OPT_GLOB:
                eq = Jim_StringMatchObj(interp, argv[1], objPtr, match_flags);
                break;

            case OPT_REGEXP:
            case OPT_COMMAND:
                eq = Jim_CommandMatchObj(interp, commandObj, argv[1], objPtr, match_flags);
                if (eq < 0) {
                    Jim_DecrRefCount(interp, searchListObj);
                    rc = JIM_ERR;
                    goto done;
                }
                break;
        }


        if ((!opt_bool && eq == !opt_not) || (opt_bool && (eq || opt_all))) {
            Jim_Obj *resultObj;

            if (opt_bool) {
                resultObj = Jim_NewIntObj(interp, eq ^ opt_not);
            }
            else if (!opt_inline) {
                resultObj = Jim_NewIntObj(interp, i);
            }
            else if (stride == 1) {
                resultObj = objPtr;
            }
            else if (opt_all) {

                ListInsertElements(listObjPtr, -1, stride,
                    searchListObj->internalRep.listValue.ele + offset);

                resultObj = NULL;
            }
            else {
                resultObj = Jim_NewListObj(interp, searchListObj->internalRep.listValue.ele + offset, stride);
            }

            if (opt_all) {

                if (stride == 1) {
                    Jim_ListAppendElement(interp, listObjPtr, resultObj);
                }
            }
            else {
                Jim_SetResult(interp, resultObj);
                Jim_DecrRefCount(interp, searchListObj);
                goto done;
            }
        }
        Jim_DecrRefCount(interp, searchListObj);
    }

    if (opt_all) {
        Jim_SetResult(interp, listObjPtr);
        listObjPtr = NULL;
    }
    else {

        if (opt_bool) {
            Jim_SetResultBool(interp, opt_not);
        }
        else if (!opt_inline) {
            Jim_SetResultInt(interp, -1);
        }
    }

  done:
    if (listObjPtr) {
        Jim_FreeNewObj(interp, listObjPtr);
    }
    if (commandObj) {
        Jim_DecrRefCount(interp, commandObj);
    }
    return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq $0x1, -0xa0(%rbp)
cmpl $0x3, %esi
jge 0x1a284
leaq 0xe432(%rip), %rcx      # 0x286a2
pushq $0x1
popq %r14
movq %rbx, %rdi
movl %r14d, %esi
callq 0x72a5
jmp 0x1a43f
pushq $0x1
popq %r13
movq %rsi, -0x68(%rbp)
leal -0x2(%rsi), %r14d
movq $0x0, -0x90(%rbp)
pushq $0x3
popq %rax
movq %rax, -0x58(%rbp)
pushq $0x1
popq %rax
movq %rax, -0x70(%rbp)
leaq 0x9150(%rip), %r12      # 0x23400
movq $0x0, -0x38(%rbp)
movq $0x0, -0x80(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movq %rdx, -0x60(%rbp)
cmpl %r14d, %r13d
jge 0x1a3d6
movslq %r13d, %r15
movq (%rdx,%r15,8), %rsi
movq %rbx, %rdi
leaq 0x17f76(%rip), %rdx     # 0x32270
leaq -0x78(%rbp), %rcx
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x7b44
testl %eax, %eax
jne 0x1a43b
movl -0x78(%rbp), %eax
cmpq $0xa, %rax
ja 0x1a369
movslq (%r12,%rax,4), %rcx
addq %r12, %rcx
movq -0x60(%rbp), %rdx
jmpq *%rcx
jmp 0x1a3ca
orl $0x1, -0x44(%rbp)
jmp 0x1a3ce
movq 0x8(%rdx,%r15,8), %rsi
movq %rbx, %rdi
leaq -0xa0(%rbp), %rdx
callq 0xc8cb
testl %eax, %eax
jne 0x1a43b
movq -0xa0(%rbp), %rax
movq %rax, -0x70(%rbp)
testq %rax, %rax
jle 0x1a46f
incl %r13d
movq -0x60(%rbp), %rdx
jmp 0x1a3ce
movq $0x0, -0x90(%rbp)
pushq $0x1
popq %rax
movl %eax, -0x4c(%rbp)
jmp 0x1a3ce
pushq $0x1
popq %rax
movl %eax, -0x48(%rbp)
jmp 0x1a3ce
movl $0x0, -0x4c(%rbp)
pushq $0x1
popq %rax
movq %rax, -0x90(%rbp)
jmp 0x1a3ce
orl $0x2, -0x44(%rbp)
pushq $0x5
jmp 0x1a3c9
pushq $0x1
popq %rax
movl %eax, -0x2c(%rbp)
jmp 0x1a3ce
incl %r13d
movq 0x8(%rdx,%r15,8), %rax
movq %rax, -0x80(%rbp)
jmp 0x1a3ce
incl %r13d
movq 0x8(%rdx,%r15,8), %rax
movq %rax, -0x38(%rbp)
pushq $0x8
popq %rax
movq %rax, -0x58(%rbp)
incl %r13d
jmp 0x1a2e0
movq -0x68(%rbp), %rax
subl %r13d, %eax
cmpl $0x2, %eax
jl 0x1a269
movl %r13d, %r15d
movq (%rdx,%r15,8), %rsi
movq %rbx, %rdi
callq 0x8b3c
movl %eax, %ecx
cltq
cqto
movq -0x70(%rbp), %r13
idivq %r13
testq %rdx, %rdx
je 0x1a451
leaq 0xe32d(%rip), %rsi      # 0x2873b
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x7363
movq %rax, %r14
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x1a438
movq %rbx, %rdi
callq 0x73bf
movq %r14, (%rbx)
pushq $0x1
popq %r14
movl %r14d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ecx, -0x84(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x1a478
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x745b
movq %rax, -0x40(%rbp)
jmp 0x1a480
leaq 0xe2a4(%rip), %rsi      # 0x2871a
jmp 0x1a40e
movq $0x0, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq -0x58(%rbp), %rcx
movq -0x80(%rbp), %r12
cmpl $0x5, %ecx
jne 0x1a4a3
leaq 0xe129(%rip), %rsi      # 0x285c1
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x7363
movq %r15, -0x68(%rbp)
testq %rax, %rax
je 0x1a4af
incl 0x10(%rax)
movq %rax, -0x38(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x48(%rbp)
sete %al
movl %eax, -0x94(%rbp)
xorl %r14d, %r14d
movq -0x58(%rbp), %rax
addl $-0x3, %eax
movq %rax, -0x58(%rbp)
movl -0x84(%rbp), %eax
cmpl %eax, %r14d
jge 0x1a6c6
movslq %r14d, %r15
testq %r12, %r12
je 0x1a514
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8b3c
movl %eax, %r12d
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
cmpq $0x1, %r13
jne 0x1a53b
movq %rbx, %rdi
movl %r14d, %edx
callq 0xd95e
jmp 0x1a555
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %r13
movq %rbx, %rdi
movq %r13, %rsi
movl %r14d, %edx
callq 0xd95e
movq %rax, -0x78(%rbp)
incl 0x10(%r13)
movslq %r14d, %r12
jmp 0x1a584
leaq (,%r15,8), %rax
addq 0x18(%rsi), %rax
movq %rbx, %rdi
movq %rax, %rsi
movl %r13d, %edx
callq 0x745b
movq %rax, %r13
incl 0x10(%rax)
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rdx
movq %rbx, %rdi
movq %r13, %rsi
movl %r12d, %ecx
leaq -0x78(%rbp), %r8
pushq $0x1
popq %r9
callq 0x1f673
testl %eax, %eax
jne 0x1a6fc
xorl %r12d, %r12d
xorl %eax, %eax
movq -0x58(%rbp), %rcx
cmpl $0x5, %ecx
ja 0x1a606
leaq 0x8e52(%rip), %rdx      # 0x233e8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq -0x78(%rbp), %rcx
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
movl -0x44(%rbp), %r8d
callq 0x101bd
testl %eax, %eax
jns 0x1a606
jmp 0x1a6fc
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rsi
movq -0x78(%rbp), %rdx
movl -0x44(%rbp), %ecx
callq 0xa85d
jmp 0x1a606
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rsi
movq -0x78(%rbp), %rdx
movl -0x44(%rbp), %ecx
callq 0xaa82
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
sete %al
cmpl $0x0, -0x4c(%rbp)
je 0x1a637
movl %eax, %ecx
orl -0x2c(%rbp), %ecx
je 0x1a66c
xorl -0x48(%rbp), %eax
movq %rax, %rsi
movq %rbx, %rdi
callq 0x8212
movq %rax, %r12
cmpl $0x0, -0x2c(%rbp)
je 0x1a78c
cmpq $0x1, -0x70(%rbp)
je 0x1a65d
jmp 0x1a66c
cmpl -0x94(%rbp), %eax
jne 0x1a66c
cmpl $0x0, -0x90(%rbp)
je 0x1a697
cmpq $0x1, -0x70(%rbp)
jne 0x1a69f
movq -0x78(%rbp), %r12
cmpl $0x0, -0x2c(%rbp)
je 0x1a78c
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
movq %r12, %rdx
callq 0x74ad
movl 0x10(%r13), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%r13)
cmpl $0x1, %eax
jg 0x1a687
movq %rbx, %rdi
movq %r13, %rsi
callq 0x73bf
movq -0x70(%rbp), %r13
addl %r13d, %r14d
movq -0x80(%rbp), %r12
jmp 0x1a4d0
movq %r15, %rsi
jmp 0x1a619
shlq $0x3, %r12
addq 0x18(%r13), %r12
cmpl $0x0, -0x2c(%rbp)
je 0x1a77a
movq -0x40(%rbp), %rdi
pushq $-0x1
popq %rsi
movq -0x70(%rbp), %rdx
movq %r12, %rcx
callq 0xd439
jmp 0x1a66c
cmpl $0x0, -0x2c(%rbp)
je 0x1a728
movq -0x40(%rbp), %r14
incl 0x10(%r14)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
movq -0x38(%rbp), %r15
jg 0x1a6f1
movq %rbx, %rdi
callq 0x73bf
movq %r14, (%rbx)
xorl %r14d, %r14d
jmp 0x1a7e3
movl 0x10(%r13), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%r13)
cmpl $0x1, %eax
jg 0x1a717
movq %rbx, %rdi
movq %r13, %rsi
callq 0x73bf
movq -0x38(%rbp), %r15
movq -0x40(%rbp), %r12
pushq $0x1
popq %r14
jmp 0x1a7d3
cmpl $0x0, -0x4c(%rbp)
movq -0x40(%rbp), %r12
je 0x1a764
movl -0x48(%rbp), %esi
movq %rbx, %rdi
callq 0x8212
movq %rax, %r14
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x1a75c
movq %rbx, %rdi
callq 0x73bf
movq %r14, (%rbx)
xorl %r14d, %r14d
jmp 0x1a774
xorl %r14d, %r14d
cmpl $0x0, -0x90(%rbp)
je 0x1a810
movq -0x38(%rbp), %r15
jmp 0x1a7d3
movq %rbx, %rdi
movq %r12, %rsi
movq -0x70(%rbp), %rdx
callq 0x745b
movq %rax, %r12
incl 0x10(%r12)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x1a7aa
movq %rbx, %rdi
callq 0x73bf
movq %r12, (%rbx)
movl 0x10(%r13), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%r13)
xorl %r14d, %r14d
cmpl $0x1, %eax
movq -0x38(%rbp), %r15
jg 0x1a7cf
movq %rbx, %rdi
movq %r13, %rsi
callq 0x73bf
movq -0x40(%rbp), %r12
testq %r12, %r12
je 0x1a7e3
movq %rbx, %rdi
movq %r12, %rsi
callq 0x73bf
testq %r15, %r15
je 0x1a43f
movl 0x10(%r15), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%r15)
cmpl $0x1, %eax
jg 0x1a43f
movq %rbx, %rdi
movq %r15, %rsi
callq 0x73bf
jmp 0x1a43f
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0x8212
movq %rax, %r14
incl 0x10(%rax)
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x1a83a
movq %rbx, %rdi
callq 0x73bf
movq %r14, (%rbx)
movq -0x38(%rbp), %r15
xorl %r14d, %r14d
jmp 0x1a7d3