// File: /workspace/github_c_makefile_star2_O3/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, %r14
movl $0x0, -0x40(%rbp)
movl %esi, -0x3c(%rbp)
cmpl $0x3, %esi
jl 0x78b1
movl $0x1, %ebx
movl $0x0, -0x78(%rbp)
leaq -0x94(%rbp), %r13
leaq 0x1f8c0(%rip), %r12     # 0x27070
movl $0x0, -0x64(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x4c(%rbp)
movq %rdx, -0x70(%rbp)
movq %r14, -0x48(%rbp)
movslq %ebx, %r15
movq (%rdx,%r15,8), %r14
movq (%r14), %rax
testq %rax, %rax
jne 0x77ed
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq -0x70(%rbp), %rdx
movq (%r14), %rax
cmpb $0x2d, (%rax)
jne 0x78a0
movq (%rdx,%r15,8), %rsi
movq -0x48(%rbp), %r14
movq %r14, %rdi
leaq 0x2d458(%rip), %rdx     # 0x34c60
movq %r13, %rcx
leaq 0x23260(%rip), %r8      # 0x2aa72
movl $0x3, %r9d
callq 0x7eac
movl $0x1, %r15d
testl %eax, %eax
jne 0x78cb
movl -0x94(%rbp), %eax
cmpq $0x6, %rax
ja 0x786b
movslq (%r12,%rax,4), %rax
addq %r12, %rax
movq -0x70(%rbp), %rdx
jmpq *%rax
movl $0x1, -0x78(%rbp)
jmp 0x7893
movl $0x1, -0x2c(%rbp)
jmp 0x7893
orl $0x1, -0x4c(%rbp)
jmp 0x7893
movl $0x1, -0x64(%rbp)
jmp 0x7893
orl $0x2, -0x4c(%rbp)
jmp 0x7893
movq -0x70(%rbp), %rdx
jmp 0x7893
incl %ebx
cmpl -0x3c(%rbp), %ebx
je 0x78b1
movslq %ebx, %rax
movq (%rdx,%rax,8), %rsi
movq %r14, %rdi
leaq -0x40(%rbp), %rdx
callq 0x80ce
movq -0x70(%rbp), %rdx
testl %eax, %eax
jne 0x78cb
incl %ebx
cmpl -0x3c(%rbp), %ebx
jl 0x77cd
jmp 0x78a4
movq -0x48(%rbp), %r14
movl -0x3c(%rbp), %r13d
subl %ebx, %r13d
cmpl $0x2, %r13d
jge 0x78e0
leaq 0x23184(%rip), %rcx     # 0x2aa3c
movl $0x1, %r15d
movq %r14, %rdi
movl $0x1, %esi
callq 0x7446
movl %r15d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %ebx, %r15
movq (%rdx,%r15,8), %rsi
movq %r14, %rdi
movq %rdx, %r12
movl -0x4c(%rbp), %edx
callq 0x827b
movq %rax, -0xb0(%rbp)
testq %rax, %rax
je 0x79a4
movq (%r12,%r15,8), %r14
movq (%r14), %rax
movq %rax, -0xa0(%rbp)
testq %rax, %rax
jne 0x7930
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq -0x70(%rbp), %r12
movq (%r14), %rax
movq %rax, -0xa0(%rbp)
movq 0x8(%r12,%r15,8), %r14
movq (%r14), %r12
testq %r12, %r12
jne 0x794a
movq 0x8(%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq (%r14), %r12
movslq 0x14(%r14), %r14
addl $-0x2, %r13d
cmpl $0x0, -0x2c(%rbp)
movq -0x48(%rbp), %r15
je 0x79bc
testl %r13d, %r13d
je 0x79af
leaq 0x23111(%rip), %rsi     # 0x2aa79
movq %r15, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7508
movq %rax, %r14
incl 0x10(%rax)
movq (%r15), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x7994
movq %r15, %rdi
callq 0x758c
movq %r14, (%r15)
movl $0x1, %r15d
xorl %ecx, %ecx
jmp 0x7e9c
movl $0x1, %r15d
jmp 0x78cb
movq -0xb0(%rbp), %rax
movl (%rax), %r13d
incl %r13d
movslq %r13d, %rax
movq %rax, -0xa8(%rbp)
leaq 0x8(,%rax,8), %rsi
xorl %r15d, %r15d
xorl %edi, %edi
callq *0x2f8af(%rip)          # 0x37288
movq %rax, %rcx
movl -0x40(%rbp), %edx
testl %edx, %edx
je 0x7a04
movq %rdx, %rax
jns 0x79f0
addl %r14d, %eax
incl %eax
movl %eax, -0x40(%rbp)
cmpl %r14d, %eax
movq %rax, -0x58(%rbp)
jle 0x7a15
addq %r14, %r12
movl $0x10, %r15d
jmp 0x7a24
movq $0x0, -0x58(%rbp)
jmp 0x7a24
incl %ebx
jmp 0x78a4
movl $0x10, %r15d
testl %eax, %eax
jle 0x7a24
movl %eax, %eax
addq %rax, %r12
cmpl $0x0, -0x2c(%rbp)
movq %rcx, -0x38(%rbp)
je 0x7a5a
movq -0x48(%rbp), %rdi
callq 0xae38
movq -0x38(%rbp), %rcx
leaq 0x2d926(%rip), %rdx     # 0x35368
movq %rdx, 0x8(%rax)
movq $0x0, (%rax)
xorps %xmm0, %xmm0
movq %rax, -0x80(%rbp)
movups %xmm0, 0x18(%rax)
jmp 0x7a62
movq $0x0, -0x80(%rbp)
incq -0xa8(%rbp)
cmpl $0x0, -0x2c(%rbp)
setne %al
cmpl $0x0, -0x64(%rbp)
sete %dl
orb %al, %dl
movb %dl, -0x2d(%rbp)
movl -0x3c(%rbp), %eax
movq %rax, -0xc0(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x5c(%rbp)
movl %r13d, -0x74(%rbp)
movq -0xb0(%rbp), %rdi
movq %r12, %rsi
movq -0xa8(%rbp), %rdx
movl %r15d, %r8d
callq 0x83c0
cmpl $0x2, %eax
jae 0x7e05
cmpl $0x1, %eax
je 0x7db7
movl -0x5c(%rbp), %eax
incl %eax
cmpb $0x0, -0x2d(%rbp)
movl %eax, -0x5c(%rbp)
je 0x7d44
movq %r12, -0x88(%rbp)
xorl %eax, %eax
testl %r13d, %r13d
setg %al
addl $0x2, %ebx
xorl %ecx, %ecx
cmpl -0x3c(%rbp), %ebx
setl %cl
cmpl $0x0, -0x2c(%rbp)
cmovel %ecx, %eax
cmpb $0x1, %al
movq -0x48(%rbp), %r15
jne 0x7d37
movslq %ebx, %r12
incq %r12
movl $0x1, %r14d
movq %r15, %rdi
callq 0xae38
movq %rax, %r13
cmpl $0x0, -0x78(%rbp)
je 0x7c04
leaq 0x2d83e(%rip), %rax     # 0x35368
movq %rax, 0x8(%r13)
movq $0x0, (%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r13)
movq -0x38(%rbp), %rcx
movl -0x8(%rcx,%r14,8), %r15d
cmpl $-0x1, %r15d
je 0x7c54
testl %r15d, %r15d
jns 0x7b69
movq -0x88(%rbp), %rdi
callq 0x6180
movq -0x38(%rbp), %rcx
movq %rax, %r15
movl -0x4(%rcx,%r14,8), %eax
testl %eax, %eax
jns 0x7b7e
movq -0x88(%rbp), %rdi
callq 0x6180
movq %rax, -0x90(%rbp)
addl -0x58(%rbp), %r15d
movslq %r15d, %rax
movq %rax, -0xb8(%rbp)
movq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0xae38
leaq 0x2d74a(%rip), %rcx     # 0x352f0
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq -0xb8(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x7683
movq -0x58(%rbp), %rax
movq -0x90(%rbp), %rcx
addl %ecx, %eax
decl %eax
cltq
movq %rax, -0x90(%rbp)
movq %r15, %rdi
callq 0xae38
leaq 0x2d701(%rip), %rcx     # 0x352f0
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
jmp 0x7ca8
leaq 0x2f68d(%rip), %rax     # 0x37298
movq %rax, (%r13)
movl $0x0, 0x14(%r13)
movq $0x0, 0x8(%r13)
movq -0x38(%rbp), %rax
movslq -0x8(%rax,%r14,8), %rax
cmpq $-0x1, %rax
je 0x7cba
movq %rax, %rdx
addq -0x88(%rbp), %rdx
movq -0x38(%rbp), %rcx
movl -0x4(%rcx,%r14,8), %ecx
subl %eax, %ecx
movq %r15, %rdi
movq %r13, %rsi
callq 0x86a0
jmp 0x7cba
movq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0xae38
leaq 0x2d689(%rip), %rcx     # 0x352f0
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq $-0x1, %rcx
movq %rcx, 0x18(%rax)
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x7683
movq %r15, %rdi
callq 0xae38
leaq 0x2d658(%rip), %rcx     # 0x352f0
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, (%rax)
movq $-0x1, %rcx
movq %rcx, 0x18(%rax)
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x7683
cmpl $0x0, -0x2c(%rbp)
je 0x7cd1
movq %r15, %rdi
movq -0x80(%rbp), %rsi
movq %r13, %rdx
callq 0x7683
jmp 0x7cf0
movq -0x70(%rbp), %rax
movq -0x8(%rax,%r12,8), %rsi
movq %r15, %rdi
movq %r13, %rdx
callq 0x876e
movl $0x0, -0x60(%rbp)
testl %eax, %eax
jne 0x7d21
xorl %eax, %eax
movl -0x74(%rbp), %r13d
cmpl %r14d, %r13d
setg %al
xorl %ecx, %ecx
cmpq -0xc0(%rbp), %r12
setl %cl
cmpl $0x0, -0x2c(%rbp)
cmovel %ecx, %eax
incq %r14
incl %ebx
incq %r12
testb %al, %al
jne 0x7b0e
jmp 0x7d37
movq %r15, %rdi
movq %r13, %rsi
callq 0x758c
movl $0x1, -0x60(%rbp)
movl -0x74(%rbp), %r13d
cmpl $0x0, -0x64(%rbp)
movq -0x88(%rbp), %r12
je 0x7db7
movq -0xa0(%rbp), %rax
cmpb $0x5e, (%rax)
movq -0x38(%rbp), %rcx
jne 0x7d5c
movl -0x4c(%rbp), %eax
andl $0x1, %eax
je 0x7dbb
cmpb $0x0, (%r12)
je 0x7dbb
movslq 0x4(%rcx), %r14
testq %r14, %r14
je 0x7d94
movl %r14d, %eax
testl %r14d, %r14d
movq -0x58(%rbp), %r15
jns 0x7d84
movq %r12, %rdi
callq 0x6180
movq -0x38(%rbp), %rcx
addl %eax, %r15d
movq %r15, -0x58(%rbp)
movl %r15d, -0x40(%rbp)
addq %r14, %r12
jmp 0x7da4
incq %r12
movq -0x58(%rbp), %rax
incl %eax
movq %rax, -0x58(%rbp)
movl %eax, -0x40(%rbp)
movl $0x10, %r15d
cmpb $0x0, (%r12)
jne 0x7a98
jmp 0x7dbb
movq -0x38(%rbp), %rcx
movl -0x60(%rbp), %r15d
testl %r15d, %r15d
jne 0x7e9c
cmpl $0x0, -0x2c(%rbp)
je 0x7e4c
movq -0x80(%rbp), %rax
incl 0x10(%rax)
movq -0x48(%rbp), %rbx
movq (%rbx), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %edx
movl %edx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x7df6
movq %rbx, %rdi
callq 0x758c
movq -0x38(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rax, (%rbx)
xorl %r15d, %r15d
jmp 0x7e9c
movl %eax, %eax
leaq 0x2db12(%rip), %rcx     # 0x35920
movq (%rcx,%rax,8), %rcx
leaq 0x23907(%rip), %rdx     # 0x2b720
leaq -0x130(%rbp), %r14
movl $0x64, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x61e0
leaq 0x22c79(%rip), %rsi     # 0x2aaaf
movq -0x48(%rbp), %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x6923
movl $0x1, %r15d
jmp 0x7e98
movslq -0x5c(%rbp), %rbx
movq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0xae38
movq %rax, %r14
leaq 0x2d48a(%rip), %rax     # 0x352f0
movq %rax, 0x8(%r14)
movq $0x0, (%r14)
movq %rbx, 0x18(%r14)
incl 0x10(%r14)
movq (%r15), %rsi
movl 0x10(%rsi), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x10(%rsi)
cmpl $0x1, %eax
jg 0x7e92
movq %r15, %rdi
callq 0x758c
movq %r14, (%r15)
xorl %r15d, %r15d
movq -0x38(%rbp), %rcx
movq %rcx, %rdi
xorl %esi, %esi
callq *0x2f3e1(%rip)          # 0x37288
jmp 0x78cb