// File: /workspace/github_c_makefile_star2_O1/msteveb[P]autosetup/./jimsh0.c
// Function: Jim_RegexpCmd
int Jim_RegexpCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
    int opt_indices = 0;
    int opt_all = 0;
    int opt_inline = 0;
    regex_t *regex;
    int match, i, j;
    int offset = 0;
    regmatch_t *pmatch = NULL;
    int source_len;
    int result = JIM_OK;
    const char *pattern;
    const char *source_str;
    int num_matches = 0;
    int num_vars;
    Jim_Obj *resultListObj = NULL;
    int regcomp_flags = 0;
    int eflags = 0;
    int option;
    enum {
        OPT_INDICES,  OPT_NOCASE, OPT_LINE, OPT_ALL, OPT_INLINE, OPT_START, OPT_END
    };
    static const char * const options[] = {
        "-indices", "-nocase", "-line", "-all", "-inline", "-start", "--", NULL
    };

    if (argc < 3) {
      wrongNumArgs:
        Jim_WrongNumArgs(interp, 1, argv,
            "?-switch ...? exp string ?matchVar? ?subMatchVar ...?");
        return JIM_ERR;
    }

    for (i = 1; i < argc; i++) {
        const char *opt = Jim_String(argv[i]);

        if (*opt != '-') {
            break;
        }
        if (Jim_GetEnum(interp, argv[i], options, &option, "switch", JIM_ERRMSG | JIM_ENUM_ABBREV) != JIM_OK) {
            return JIM_ERR;
        }
        if (option == OPT_END) {
            i++;
            break;
        }
        switch (option) {
            case OPT_INDICES:
                opt_indices = 1;
                break;

            case OPT_NOCASE:
                regcomp_flags |= REG_ICASE;
                break;

            case OPT_LINE:
                regcomp_flags |= REG_NEWLINE;
                break;

            case OPT_ALL:
                opt_all = 1;
                break;

            case OPT_INLINE:
                opt_inline = 1;
                break;

            case OPT_START:
                if (++i == argc) {
                    goto wrongNumArgs;
                }
                if (Jim_GetIndex(interp, argv[i], &offset) != JIM_OK) {
                    return JIM_ERR;
                }
                break;
        }
    }
    if (argc - i < 2) {
        goto wrongNumArgs;
    }

    regex = SetRegexpFromAny(interp, argv[i], regcomp_flags);
    if (!regex) {
        return JIM_ERR;
    }

    pattern = Jim_String(argv[i]);
    source_str = Jim_GetString(argv[i + 1], &source_len);

    num_vars = argc - i - 2;

    if (opt_inline) {
        if (num_vars) {
            Jim_SetResultString(interp, "regexp match variables not allowed when using -inline",
                -1);
            result = JIM_ERR;
            goto done;
        }
        num_vars = regex->re_nsub + 1;
    }

    pmatch = Jim_Alloc((num_vars + 1) * sizeof(*pmatch));

    if (offset) {
        if (offset < 0) {
            offset += source_len + 1;
        }
        if (offset > source_len) {
            source_str += source_len;
        }
        else if (offset > 0) {
            source_str += utf8_index(source_str, offset);
        }
        eflags |= REG_NOTBOL;
    }

    if (opt_inline) {
        resultListObj = Jim_NewListObj(interp, NULL, 0);
    }

  next_match:
    match = jim_regexec(regex, source_str, num_vars + 1, pmatch, eflags);
    if (match >= REG_BADPAT) {
        char buf[100];

        jim_regerror(match, regex, buf, sizeof(buf));
        Jim_SetResultFormatted(interp, "error while matching pattern: %s", buf);
        result = JIM_ERR;
        goto done;
    }

    if (match == REG_NOMATCH) {
        goto done;
    }

    num_matches++;

    if (opt_all && !opt_inline) {

        goto try_next_match;
    }


    j = 0;
    for (i += 2; opt_inline ? j < num_vars : i < argc; i++, j++) {
        Jim_Obj *resultObj;

        if (opt_indices) {
            resultObj = Jim_NewListObj(interp, NULL, 0);
        }
        else {
            resultObj = Jim_NewStringObj(interp, "", 0);
        }

        if (pmatch[j].rm_so == -1) {
            if (opt_indices) {
                Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp, -1));
                Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp, -1));
            }
        }
        else {
            if (opt_indices) {

                int so = utf8_strlen(source_str, pmatch[j].rm_so);
                int eo = utf8_strlen(source_str, pmatch[j].rm_eo);
                Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp, offset + so));
                Jim_ListAppendElement(interp, resultObj, Jim_NewIntObj(interp, offset + eo - 1));
            }
            else {
                Jim_AppendString(interp, resultObj, source_str + pmatch[j].rm_so, pmatch[j].rm_eo - pmatch[j].rm_so);
            }
        }

        if (opt_inline) {
            Jim_ListAppendElement(interp, resultListObj, resultObj);
        }
        else {

            result = Jim_SetVariable(interp, argv[i], resultObj);

            if (result != JIM_OK) {
                Jim_FreeObj(interp, resultObj);
                break;
            }
        }
    }

  try_next_match:
    if (opt_all && (pattern[0] != '^' || (regcomp_flags & REG_NEWLINE)) && *source_str) {
        if (pmatch[0].rm_eo) {
            offset += utf8_strlen(source_str, pmatch[0].rm_eo);
            source_str += pmatch[0].rm_eo;
        }
        else {
            source_str++;
            offset++;
        }
        if (*source_str) {
            eflags = REG_NOTBOL;
            goto next_match;
        }
    }

  done:
    if (result == JIM_OK) {
        if (opt_inline) {
            Jim_SetResult(interp, resultListObj);
        }
        else {
            Jim_SetResultInt(interp, num_matches);
        }
    }

    Jim_Free(pmatch);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl %esi, -0x44(%rbp)
cmpl $0x3, %esi
jl 0x78d5
movl $0x1, %r14d
movl $0x0, -0x58(%rbp)
leaq -0x84(%rbp), %r12
leaq 0x208ac(%rip), %r15     # 0x28070
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x54(%rbp)
movq %rdx, -0x68(%rbp)
movslq %r14d, %r13
movq (%rdx,%r13,8), %rbx
cmpq $0x0, (%rbx)
jne 0x77f8
movq 0x8(%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movq -0x68(%rbp), %rdx
movq (%rbx), %rax
movl $0x3, %ebx
cmpb $0x2d, (%rax)
jne 0x787c
movq (%rdx,%r13,8), %rsi
movq -0x40(%rbp), %rdi
leaq 0x2e43c(%rip), %rdx     # 0x35c50
movq %r12, %rcx
leaq 0x242ac(%rip), %r8      # 0x2baca
movl $0x3, %r9d
callq 0x7e97
testl %eax, %eax
je 0x7838
movl $0x1, %ebx
movq -0x68(%rbp), %rdx
jmp 0x787c
movl -0x84(%rbp), %eax
cmpq $0x6, %rax
ja 0x7872
movslq (%r15,%rax,4), %rax
addq %r15, %rax
movq -0x68(%rbp), %rdx
jmpq *%rax
movl $0x1, -0x58(%rbp)
jmp 0x787a
movl $0x1, -0x30(%rbp)
jmp 0x787a
orl $0x1, -0x54(%rbp)
jmp 0x787a
movl $0x1, -0x6c(%rbp)
jmp 0x787a
xorl %ebx, %ebx
jmp 0x7832
orl $0x2, -0x54(%rbp)
xorl %ebx, %ebx
testl %ebx, %ebx
jne 0x78be
incl %r14d
cmpl -0x44(%rbp), %r14d
jl 0x77dd
jmp 0x78c8
incl %r14d
movl $0x2, %ebx
cmpl -0x44(%rbp), %r14d
je 0x787c
movslq %r14d, %rax
movq (%rdx,%rax,8), %rsi
movq -0x40(%rbp), %rdi
leaq -0x34(%rbp), %rdx
callq 0x80b2
movq -0x68(%rbp), %rdx
movl %eax, %ebx
jmp 0x787c
incl %r14d
jmp 0x787c
cmpl $0x1, %ebx
je 0x78ef
cmpl $0x2, %ebx
je 0x78d5
movl -0x44(%rbp), %r13d
subl %r14d, %r13d
cmpl $0x2, %r13d
jge 0x7903
leaq 0x241b8(%rip), %rcx     # 0x2ba94
movl $0x1, %ebx
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x7454
movl %ebx, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %r14d, %r15
movq (%rdx,%r15,8), %rsi
movq -0x40(%rbp), %rdi
movq %rdx, %r12
movl -0x54(%rbp), %edx
callq 0x8260
movq %rax, -0x98(%rbp)
testq %rax, %rax
je 0x79cc
movq (%r12,%r15,8), %rbx
cmpq $0x0, (%rbx)
jne 0x7941
movq 0x8(%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movq -0x68(%rbp), %r12
movq (%rbx), %rax
movq %rax, -0xa0(%rbp)
movq 0x8(%r12,%r15,8), %rbx
cmpq $0x0, (%rbx)
jne 0x7960
movq 0x8(%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movslq 0x14(%rbx), %r15
movq (%rbx), %rbx
addl $-0x2, %r13d
cmpl $0x0, -0x30(%rbp)
je 0x79e3
testl %r13d, %r13d
je 0x79d6
leaq 0x24154(%rip), %rsi     # 0x2bad1
movq -0x40(%rbp), %r15
movq %r15, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7516
movq %rax, %rbx
incl 0x10(%rax)
movq (%r15), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x79ad
movq %r15, %rdi
callq 0x759a
movq %rbx, (%r15)
movq $0x0, -0x60(%rbp)
movl $0x1, %ebx
xorl %eax, %eax
movq $0x0, -0x78(%rbp)
jmp 0x7e14
movl $0x1, %ebx
jmp 0x78ef
movq -0x98(%rbp), %rax
movl (%rax), %r13d
incl %r13d
movslq %r13d, %rax
movq %rax, -0x90(%rbp)
leaq 0x8(,%rax,8), %rsi
xorl %r12d, %r12d
xorl %edi, %edi
callq *0x30888(%rip)          # 0x38288
movq %rax, -0x60(%rbp)
movl -0x34(%rbp), %eax
testl %eax, %eax
je 0x7a35
jns 0x7a15
addl %r15d, %eax
incl %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl %r15d, %eax
jle 0x7a28
addq %r15, %rbx
movl $0x10, %r12d
jmp 0x7a35
movl $0x10, %r12d
testl %eax, %eax
jle 0x7a35
addq %rax, %rbx
movq -0x40(%rbp), %r15
movq %rbx, -0x50(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x7a6a
movq %r15, %rdi
callq 0xae58
leaq 0x2e906(%rip), %rcx     # 0x36358
movq %rcx, 0x8(%rax)
movq $0x0, (%rax)
xorps %xmm0, %xmm0
movq %rax, -0x78(%rbp)
movups %xmm0, 0x18(%rax)
jmp 0x7a72
movq $0x0, -0x78(%rbp)
incq -0x90(%rbp)
cmpl $0x0, -0x30(%rbp)
setne %al
cmpl $0x0, -0x6c(%rbp)
sete %cl
orb %al, %cl
movb %cl, -0x35(%rbp)
movl -0x44(%rbp), %eax
movq %rax, -0xc0(%rbp)
xorl %ebx, %ebx
movl $0x0, -0x2c(%rbp)
movq -0x50(%rbp), %rsi
movl %r13d, -0x7c(%rbp)
movq -0x98(%rbp), %rdi
movq %rsi, -0x50(%rbp)
movq -0x90(%rbp), %rdx
movq -0x60(%rbp), %rcx
movl %r12d, %r8d
callq 0x83a3
cmpl $0x2, %eax
jae 0x7dce
cmpl $0x1, %eax
je 0x7e11
cmpb $0x0, -0x35(%rbp)
je 0x7d4a
xorl %eax, %eax
testl %r13d, %r13d
setg %al
addl $0x2, %r14d
xorl %ecx, %ecx
cmpl -0x44(%rbp), %r14d
setl %cl
cmpl $0x0, -0x30(%rbp)
cmovel %ecx, %eax
cmpb $0x1, %al
jne 0x7d4a
movl -0x34(%rbp), %eax
movq %rax, -0xa8(%rbp)
movslq %r14d, %r14
movl $0x1, %r13d
movq %r15, %rdi
callq 0xae58
movq %rax, %r12
cmpl $0x0, -0x58(%rbp)
je 0x7b48
leaq 0x2e828(%rip), %rax     # 0x36358
movq %rax, 0x8(%r12)
movq $0x0, (%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r12)
jmp 0x7b65
leaq 0x30749(%rip), %rax     # 0x38298
movq %rax, (%r12)
movl $0x0, 0x14(%r12)
movq $0x0, 0x8(%r12)
movq -0x60(%rbp), %rax
movslq -0x8(%rax,%r13,8), %r15
cmpq $-0x1, %r15
je 0x7c3c
cmpl $0x0, -0x58(%rbp)
je 0x7cae
movl %ebx, -0x80(%rbp)
testl %r15d, %r15d
jns 0x7b96
movq -0x50(%rbp), %rdi
callq 0x6180
movq %rax, %r15
movq -0x60(%rbp), %rax
movl -0x4(%rax,%r13,8), %eax
testl %eax, %eax
jns 0x7bac
movq -0x50(%rbp), %rdi
callq 0x6180
movq %rax, -0xb8(%rbp)
movq -0xa8(%rbp), %rbx
addl %ebx, %r15d
movslq %r15d, %rax
movq %rax, -0xb0(%rbp)
movq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0xae58
leaq 0x2e706(%rip), %rcx     # 0x362e0
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq -0xb0(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x7695
movq -0xb8(%rbp), %rax
addl %ebx, %eax
decl %eax
movslq %eax, %rbx
movq %r15, %rdi
callq 0xae58
leaq 0x2e6c7(%rip), %rcx     # 0x362e0
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq %rbx, 0x18(%rax)
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x7695
movl -0x80(%rbp), %ebx
jmp 0x7cd0
cmpl $0x0, -0x58(%rbp)
movq -0x40(%rbp), %r15
je 0x7cd0
movq %r15, %rdi
callq 0xae58
leaq 0x2e687(%rip), %rcx     # 0x362e0
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq $-0x1, %rcx
movq %rcx, 0x18(%rax)
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x7695
movq %r15, %rdi
callq 0xae58
leaq 0x2e656(%rip), %rcx     # 0x362e0
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq $-0x1, %rcx
movq %rcx, 0x18(%rax)
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x7695
jmp 0x7cd0
movq %r15, %rdx
addq -0x50(%rbp), %rdx
movq -0x60(%rbp), %rax
movl -0x4(%rax,%r13,8), %ecx
subl %r15d, %ecx
movq -0x40(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x8653
cmpl $0x0, -0x30(%rbp)
je 0x7ce9
movq %r15, %rdi
movq -0x78(%rbp), %rsi
movq %r12, %rdx
callq 0x7695
movb $0x1, %al
jmp 0x7d18
movq -0x68(%rbp), %rax
movq (%rax,%r14,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x871b
testl %eax, %eax
je 0x7d14
movq %r15, %rdi
movq %r12, %rsi
callq 0x759a
movl $0x1, %ebx
xorl %eax, %eax
jmp 0x7d18
movb $0x1, %al
xorl %ebx, %ebx
testb %al, %al
je 0x7d46
incq %r14
xorl %eax, %eax
cmpl %r13d, -0x7c(%rbp)
setg %al
xorl %ecx, %ecx
cmpq -0xc0(%rbp), %r14
setl %cl
cmpl $0x0, -0x30(%rbp)
cmovnel %eax, %ecx
incq %r13
testb %cl, %cl
jne 0x7b18
movl -0x7c(%rbp), %r13d
movl -0x2c(%rbp), %eax
incl %eax
cmpl $0x0, -0x6c(%rbp)
je 0x7e14
movl %eax, -0x2c(%rbp)
testb $0x1, -0x54(%rbp)
sete %al
movq -0xa0(%rbp), %rcx
cmpb $0x5e, (%rcx)
sete %cl
testb %al, %cl
jne 0x7e11
movq -0x50(%rbp), %rax
cmpb $0x0, (%rax)
je 0x7e11
movl %ebx, %r12d
movq -0x60(%rbp), %rax
movslq 0x4(%rax), %rbx
testq %rbx, %rbx
je 0x7db0
movl %ebx, %eax
testl %ebx, %ebx
jns 0x7da4
movq -0x50(%rbp), %rdi
callq 0x6180
addl %eax, -0x34(%rbp)
movq -0x50(%rbp), %rsi
addq %rbx, %rsi
jmp 0x7dba
movq -0x50(%rbp), %rsi
incq %rsi
incl -0x34(%rbp)
movl %r12d, %ebx
movl $0x10, %r12d
cmpb $0x0, (%rsi)
jne 0x7aa7
jmp 0x7e11
movl %eax, %eax
leaq 0x2eb49(%rip), %rcx     # 0x36920
movq (%rcx,%rax,8), %rcx
leaq 0x24999(%rip), %rdx     # 0x2c77b
leaq -0x130(%rbp), %rbx
movl $0x64, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x61e0
leaq 0x23d08(%rip), %rsi     # 0x2bb07
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x692d
movl $0x1, %ebx
movl -0x2c(%rbp), %eax
testl %ebx, %ebx
jne 0x7e45
cmpl $0x0, -0x30(%rbp)
je 0x7e56
movq -0x78(%rbp), %rax
incl 0x10(%rax)
movq (%r15), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x2, %eax
jge 0x7e3e
movq %r15, %rdi
callq 0x759a
movq -0x78(%rbp), %rax
movq %rax, (%r15)
movq -0x60(%rbp), %rdi
xorl %esi, %esi
callq *0x30437(%rip)          # 0x38288
jmp 0x78ef
movl %ebx, %r14d
movslq %eax, %rbx
movq %r15, %rdi
callq 0xae58
leaq 0x2e475(%rip), %rcx     # 0x362e0
movq %rcx, 0x8(%rax)
movq $0x0, (%rax)
movq %rbx, 0x18(%rax)
movl %r14d, %ebx
movq %rax, -0x78(%rbp)
incl 0x10(%rax)
movq (%r15), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jle 0x7e36
jmp 0x7e3e