// File: /workspace/github_c_makefile_star2_O0/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
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x6c(%rbp)
movq $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0x7dab
jmp 0x7d86
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x1, %esi
leaq 0x32dff(%rip), %rcx     # 0x3ab99
callq 0x7880
movl $0x1, -0x4(%rbp)
jmp 0x8577
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x7ef0
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7960
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x7dea
jmp 0x7ef0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x3df5f(%rip), %rdx     # 0x45d60
leaq -0x84(%rbp), %rcx
leaq 0x32dc0(%rip), %r8      # 0x3abcf
movl $0x3, %r9d
callq 0x8590
cmpl $0x0, %eax
je 0x7e2b
movl $0x1, -0x4(%rbp)
jmp 0x8577
cmpl $0x6, -0x84(%rbp)
jne 0x7e42
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x7ef0
movl -0x84(%rbp), %eax
movq %rax, -0x128(%rbp)
subq $0x5, %rax
ja 0x7ee0
movq -0x128(%rbp), %rax
leaq 0x2e1a9(%rip), %rcx     # 0x36010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, -0x24(%rbp)
jmp 0x7ee0
movl -0x7c(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x7c(%rbp)
jmp 0x7ee0
movl -0x7c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x7ee0
movl $0x1, -0x28(%rbp)
jmp 0x7ee0
movl $0x1, -0x2c(%rbp)
jmp 0x7ee0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
cmpl -0x14(%rbp), %eax
jne 0x7eb4
jmp 0x7d86
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x48(%rbp), %rdx
callq 0x87a0
cmpl $0x0, %eax
je 0x7ede
movl $0x1, -0x4(%rbp)
jmp 0x8577
jmp 0x7ee0
jmp 0x7ee2
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x7db2
movl -0x14(%rbp), %eax
subl -0x40(%rbp), %eax
cmpl $0x2, %eax
jge 0x7f00
jmp 0x7d86
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movl -0x7c(%rbp), %edx
callq 0x8860
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x7f2f
movl $0x1, -0x4(%rbp)
jmp 0x8577
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7960
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x54(%rbp), %rsi
callq 0x89b0
movq %rax, -0x68(%rbp)
movl -0x14(%rbp), %eax
subl -0x40(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x70(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x7ff3
cmpl $0x0, -0x70(%rbp)
je 0x7fe7
jmp 0x7f7c
movq -0x10(%rbp), %rdi
leaq 0x32c4f(%rip), %rsi     # 0x3abd6
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0x7fcd
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7a10
movq -0x98(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x58(%rbp)
jmp 0x84a1
movq -0x38(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
movq 0x40296(%rip), %rax     # 0x48290
movl -0x70(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rsi
shlq $0x3, %rsi
xorl %ecx, %ecx
movl %ecx, %edi
callq *%rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x8066
cmpl $0x0, -0x48(%rbp)
jge 0x8029
movl -0x54(%rbp), %eax
addl $0x1, %eax
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x54(%rbp), %eax
jle 0x8044
movl -0x54(%rbp), %ecx
movq -0x68(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x805d
cmpl $0x0, -0x48(%rbp)
jle 0x805b
movl -0x48(%rbp), %ecx
movq -0x68(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x805d
movl -0x80(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x80(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x807f
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x7b50
movq %rax, -0x78(%rbp)
jmp 0x8081
movq -0x38(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x70(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
movq -0x50(%rbp), %rcx
movl -0x80(%rbp), %r8d
callq 0x8a00
movl %eax, -0x3c(%rbp)
cmpl $0x2, -0x3c(%rbp)
jl 0x80e5
movl -0x3c(%rbp), %edi
movq -0x38(%rbp), %rsi
leaq -0x100(%rbp), %rdx
movl $0x64, %ecx
callq 0x8cf0
movq -0x10(%rbp), %rdi
leaq -0x100(%rbp), %rdx
leaq 0x32b3a(%rip), %rsi     # 0x3ac0c
movb $0x0, %al
callq 0x6b40
movl $0x1, -0x58(%rbp)
jmp 0x84a1
cmpl $0x1, -0x3c(%rbp)
jne 0x80f0
jmp 0x84a1
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x810a
cmpl $0x0, -0x2c(%rbp)
jne 0x810a
jmp 0x83e9
movl $0x0, -0x44(%rbp)
movl -0x40(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x8136
movl -0x44(%rbp), %eax
cmpl -0x70(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x12c(%rbp)
jmp 0x814a
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x12c(%rbp)
movl -0x12c(%rbp), %eax
cmpl $0x0, %eax
je 0x83e7
cmpl $0x0, -0x24(%rbp)
je 0x8177
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x7b50
movq %rax, -0x108(%rbp)
jmp 0x8190
movq -0x10(%rbp), %rdi
leaq 0x35830(%rip), %rsi     # 0x3d9b2
xorl %edx, %edx
callq 0x7990
movq %rax, -0x108(%rbp)
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
jne 0x822b
cmpl $0x0, -0x24(%rbp)
je 0x8226
movq -0x10(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x10(%rbp), %rdi
movq $-0x1, %rsi
callq 0x8d60
movq -0x150(%rbp), %rdi
movq -0x148(%rbp), %rsi
movq %rax, %rdx
callq 0x7bd0
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rdi
movq $-0x1, %rsi
callq 0x8d60
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %rsi
movq %rax, %rdx
callq 0x7bd0
jmp 0x8379
cmpl $0x0, -0x24(%rbp)
je 0x833c
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,8)
jge 0x8254
movq -0x68(%rbp), %rdi
callq 0x6190
movl %eax, -0x154(%rbp)
jmp 0x8265
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,8), %eax
movl %eax, -0x154(%rbp)
movl -0x154(%rbp), %eax
movl %eax, -0x10c(%rbp)
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpl $0x0, 0x4(%rax,%rcx,8)
jge 0x8291
movq -0x68(%rbp), %rdi
callq 0x6190
movl %eax, -0x158(%rbp)
jmp 0x82a3
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, -0x158(%rbp)
movl -0x158(%rbp), %eax
movl %eax, -0x110(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %eax
addl -0x10c(%rbp), %eax
movslq %eax, %rsi
callq 0x8d60
movq -0x178(%rbp), %rdi
movq -0x170(%rbp), %rsi
movq %rax, %rdx
callq 0x7bd0
movq -0x10(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %eax
addl -0x110(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8d60
movq -0x168(%rbp), %rdi
movq -0x160(%rbp), %rsi
movq %rax, %rdx
callq 0x7bd0
jmp 0x8377
movq -0x10(%rbp), %rdi
movq -0x108(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movslq (%rax,%rcx,8), %rax
addq %rax, %rdx
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %ecx
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %r8
subl (%rax,%r8,8), %ecx
callq 0x8db0
jmp 0x8379
cmpl $0x0, -0x2c(%rbp)
je 0x8395
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x108(%rbp), %rdx
callq 0x7bd0
jmp 0x83ce
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x108(%rbp), %rdx
callq 0x8df0
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x83cc
movq -0x10(%rbp), %rdi
movq -0x108(%rbp), %rsi
callq 0x7a10
jmp 0x83e7
jmp 0x83ce
jmp 0x83d0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x811a
jmp 0x83e9
cmpl $0x0, -0x28(%rbp)
je 0x849f
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x840e
movl -0x7c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x849f
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x849f
movq -0x50(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x8473
movq -0x50(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jge 0x8443
movq -0x68(%rbp), %rdi
callq 0x6190
movl %eax, -0x17c(%rbp)
jmp 0x8450
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x17c(%rbp)
movl -0x17c(%rbp), %eax
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x68(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x8488
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x68(%rbp), %rax
cmpb $0x0, (%rax)
je 0x849d
movl $0x10, -0x80(%rbp)
jmp 0x8081
jmp 0x849f
jmp 0x84a1
cmpl $0x0, -0x58(%rbp)
jne 0x8560
cmpl $0x0, -0x2c(%rbp)
je 0x8503
jmp 0x84b3
movq -0x78(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0x84f3
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7a10
movq -0x118(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x855e
jmp 0x8505
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x8d60
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0x854e
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7a10
movq -0x120(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x855e
jmp 0x8560
movq 0x3fd29(%rip), %rax     # 0x48290
movq -0x50(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl -0x58(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)