// File: /workspace/github_c_makefile_star2_O0/mattn[P]orelang/slre.c
// Function: bar
static int bar(const char *re, int re_len, const char *s, int s_len,
               struct regex_info *info, int bi) {
  /* i is offset in re, j is offset in s, bi is brackets index */
  int i, j, n, step;

  for (i = j = 0; i < re_len && j <= s_len; i += step) {

    /* Handle quantifiers. Get the length of the chunk. */
    step = re[i] == '(' ? info->brackets[bi + 1].len + 2 :
      get_op_len(re + i, re_len - i);

    DBG(("%s [%.*s] [%.*s] re_len=%d step=%d i=%d j=%d\n", __func__,
         re_len - i, re + i, s_len - j, s + j, re_len, step, i, j));

    FAIL_IF(is_quantifier(&re[i]), SLRE_UNEXPECTED_QUANTIFIER);
    FAIL_IF(step <= 0, SLRE_INVALID_CHARACTER_SET);

    if (i + step < re_len && is_quantifier(re + i + step)) {
      DBG(("QUANTIFIER: [%.*s]%c [%.*s]\n", step, re + i,
           re[i + step], s_len - j, s + j));
      if (re[i + step] == '?') {
        int result = bar(re + i, step, s + j, s_len - j, info, bi);
        j += result > 0 ? result : 0;
        i++;
      } else if (re[i + step] == '+' || re[i + step] == '*') {
        int j2 = j, nj = j, n1, n2 = -1, ni, non_greedy = 0;

        /* Points to the regexp code after the quantifier */
        ni = i + step + 1;
        if (ni < re_len && re[ni] == '?') {
          non_greedy = 1;
          ni++;
        }

        do {
          if ((n1 = bar(re + i, step, s + j2, s_len - j2, info, bi)) > 0) {
            j2 += n1;
          }
          if (re[i + step] == '+' && n1 < 0) break;

          if (ni >= re_len) {
            /* After quantifier, there is nothing */
            nj = j2;
          } else if ((n2 = bar(re + ni, re_len - ni, s + j2,
                               s_len - j2, info, bi)) >= 0) {
            /* Regex after quantifier matched */
            nj = j2 + n2;
          }
          if (nj > j && non_greedy) break;
        } while (n1 > 0);

        /*
         * Even if we found one or more pattern, this branch will be executed,
         * changing the next captures.
         */
        if (n1 < 0 && n2 < 0 && re[i + step] == '*' &&
            (n2 = bar(re + ni, re_len - ni, s + j, s_len - j, info, bi)) > 0) {
          nj = j + n2;
        }

        DBG(("STAR/PLUS END: %d %d %d %d %d\n", j, nj, re_len - ni, n1, n2));
        FAIL_IF(re[i + step] == '+' && nj == j, SLRE_NO_MATCH);

        /* If while loop body above was not executed for the * quantifier,  */
        /* make sure the rest of the regex matches                          */
        FAIL_IF(nj == j && ni < re_len && n2 < 0, SLRE_NO_MATCH);

        /* Returning here cause we've matched the rest of RE already */
        return nj;
      }
      continue;
    }

    if (re[i] == '[') {
      n = match_set(re + i + 1, re_len - (i + 2), s + j, info);
      DBG(("SET %.*s [%.*s] -> %d\n", step, re + i, s_len - j, s + j, n));
      FAIL_IF(n <= 0, SLRE_NO_MATCH);
      j += n;
    } else if (re[i] == '(') {
      n = SLRE_NO_MATCH;
      bi++;
      FAIL_IF(bi >= info->num_brackets, SLRE_INTERNAL_ERROR);
      DBG(("CAPTURING [%.*s] [%.*s] [%s]\n",
           step, re + i, s_len - j, s + j, re + i + step));

      if (re_len - (i + step) <= 0) {
        /* Nothing follows brackets */
        n = doh(s + j, s_len - j, info, bi);
      } else {
        int j2;
        for (j2 = 0; j2 <= s_len - j; j2++) {
          if ((n = doh(s + j, s_len - (j + j2), info, bi)) >= 0 &&
              bar(re + i + step, re_len - (i + step),
                  s + j + n, s_len - (j + n), info, bi) >= 0) break;
        }
      }

      DBG(("CAPTURED [%.*s] [%.*s]:%d\n", step, re + i, s_len - j, s + j, n));
      FAIL_IF(n < 0, n);
      if (info->caps != NULL && n > 0) {
        info->caps[bi - 1].ptr = s + j;
        info->caps[bi - 1].len = n;
      }
      j += n;
    } else if (re[i] == '^') {
      FAIL_IF(j != 0, SLRE_NO_MATCH);
    } else if (re[i] == '$') {
      FAIL_IF(j != s_len, SLRE_NO_MATCH);
    } else {
      FAIL_IF(j >= s_len, SLRE_NO_MATCH);
      n = match_op((unsigned char *) (re + i), (unsigned char *) (s + j), info);
      FAIL_IF(n <= 0, n);
      j += n;
    }
  }

  return j;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %ecx
xorl %eax, %eax
cmpl -0x14(%rbp), %ecx
movb %al, -0x65(%rbp)
jge 0xf335
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
setle %al
movb %al, -0x65(%rbp)
movb -0x65(%rbp), %al
testb $0x1, %al
jne 0xf341
jmp 0xf90c
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x28, %eax
jne 0xf371
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl $0x2, %eax
movl %eax, -0x6c(%rbp)
jmp 0xf38a
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
movl -0x14(%rbp), %esi
subl -0x38(%rbp), %esi
callq 0xedd0
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
callq 0xf920
cmpl $0x0, %eax
je 0xf3b1
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0xf912
cmpl $0x0, -0x44(%rbp)
jg 0xf3c3
movl $0xfffffffb, -0x4(%rbp) # imm = 0xFFFFFFFB
jmp 0xf912
movl -0x38(%rbp), %eax
addl -0x44(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xf66d
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
movslq -0x44(%rbp), %rax
addq %rax, %rdi
callq 0xf920
cmpl $0x0, %eax
je 0xf66d
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3f, %eax
jne 0xf463
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
movl -0x44(%rbp), %esi
movq -0x20(%rbp), %rdx
movslq -0x3c(%rbp), %rax
addq %rax, %rdx
movl -0x24(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %r8
movl -0x34(%rbp), %r9d
callq 0xf2f0
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jle 0xf445
movl -0x48(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0xf44c
xorl %eax, %eax
movl %eax, -0x70(%rbp)
jmp 0xf44c
movl -0x70(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xf668
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2b, %eax
je 0xf493
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2a, %eax
jne 0xf666
movl -0x3c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x50(%rbp)
movl $0xffffffff, -0x58(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x60(%rbp)
movl -0x38(%rbp), %eax
addl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xf4e2
movq -0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3f, %eax
jne 0xf4e2
movl $0x1, -0x60(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xf4e4
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
movl -0x44(%rbp), %esi
movq -0x20(%rbp), %rdx
movslq -0x4c(%rbp), %rax
addq %rax, %rdx
movl -0x24(%rbp), %ecx
subl -0x4c(%rbp), %ecx
movq -0x30(%rbp), %r8
movl -0x34(%rbp), %r9d
callq 0xf2f0
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
jle 0xf521
movl -0x54(%rbp), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2b, %eax
jne 0xf53f
cmpl $0x0, -0x54(%rbp)
jge 0xf53f
jmp 0xf5ad
movl -0x5c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0xf54f
movl -0x4c(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0xf591
movq -0x10(%rbp), %rdi
movslq -0x5c(%rbp), %rax
addq %rax, %rdi
movl -0x14(%rbp), %esi
subl -0x5c(%rbp), %esi
movq -0x20(%rbp), %rdx
movslq -0x4c(%rbp), %rax
addq %rax, %rdx
movl -0x24(%rbp), %ecx
subl -0x4c(%rbp), %ecx
movq -0x30(%rbp), %r8
movl -0x34(%rbp), %r9d
callq 0xf2f0
movl %eax, -0x58(%rbp)
cmpl $0x0, %eax
jl 0xf58f
movl -0x4c(%rbp), %eax
addl -0x58(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0xf591
movl -0x50(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jle 0xf5a1
cmpl $0x0, -0x60(%rbp)
je 0xf5a1
jmp 0xf5ad
jmp 0xf5a3
cmpl $0x0, -0x54(%rbp)
jg 0xf4e4
cmpl $0x0, -0x54(%rbp)
jge 0xf60f
cmpl $0x0, -0x58(%rbp)
jge 0xf60f
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2a, %eax
jne 0xf60f
movq -0x10(%rbp), %rdi
movslq -0x5c(%rbp), %rax
addq %rax, %rdi
movl -0x14(%rbp), %esi
subl -0x5c(%rbp), %esi
movq -0x20(%rbp), %rdx
movslq -0x3c(%rbp), %rax
addq %rax, %rdx
movl -0x24(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %r8
movl -0x34(%rbp), %r9d
callq 0xf2f0
movl %eax, -0x58(%rbp)
cmpl $0x0, %eax
jle 0xf60f
movl -0x3c(%rbp), %eax
addl -0x58(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2b, %eax
jne 0xf639
movl -0x50(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0xf639
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf912
movl -0x50(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0xf65b
movl -0x5c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xf65b
cmpl $0x0, -0x58(%rbp)
jge 0xf65b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf912
movl -0x50(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf912
jmp 0xf668
jmp 0xf8fe
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5b, %eax
jne 0xf6cf
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
addq $0x1, %rdi
movl -0x14(%rbp), %esi
movl -0x38(%rbp), %eax
addl $0x2, %eax
subl %eax, %esi
movq -0x20(%rbp), %rdx
movslq -0x3c(%rbp), %rax
addq %rax, %rdx
movq -0x30(%rbp), %rcx
callq 0xf970
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jg 0xf6c1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf912
movl -0x40(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0xf8fc
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x28, %eax
jne 0xf863
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x960(%rcx), %eax
jl 0xf70f
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0xf912
movl -0x14(%rbp), %eax
movl -0x38(%rbp), %ecx
addl -0x44(%rbp), %ecx
subl %ecx, %eax
cmpl $0x0, %eax
jg 0xf744
movq -0x20(%rbp), %rdi
movslq -0x3c(%rbp), %rax
addq %rax, %rdi
movl -0x24(%rbp), %esi
subl -0x3c(%rbp), %esi
movq -0x30(%rbp), %rdx
movl -0x34(%rbp), %ecx
callq 0xf1a0
movl %eax, -0x40(%rbp)
jmp 0xf7e6
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl -0x24(%rbp), %ecx
subl -0x3c(%rbp), %ecx
cmpl %ecx, %eax
jg 0xf7e4
movq -0x20(%rbp), %rdi
movslq -0x3c(%rbp), %rax
addq %rax, %rdi
movl -0x24(%rbp), %esi
movl -0x3c(%rbp), %eax
addl -0x64(%rbp), %eax
subl %eax, %esi
movq -0x30(%rbp), %rdx
movl -0x34(%rbp), %ecx
callq 0xf1a0
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
jl 0xf7d4
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
movslq -0x44(%rbp), %rax
addq %rax, %rdi
movl -0x14(%rbp), %esi
movl -0x38(%rbp), %eax
addl -0x44(%rbp), %eax
subl %eax, %esi
movq -0x20(%rbp), %rdx
movslq -0x3c(%rbp), %rax
addq %rax, %rdx
movslq -0x40(%rbp), %rax
addq %rax, %rdx
movl -0x24(%rbp), %ecx
movl -0x3c(%rbp), %eax
addl -0x40(%rbp), %eax
subl %eax, %ecx
movq -0x30(%rbp), %r8
movl -0x34(%rbp), %r9d
callq 0xf2f0
cmpl $0x0, %eax
jl 0xf7d4
jmp 0xf7e4
jmp 0xf7d6
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xf74b
jmp 0xf7e6
cmpl $0x0, -0x40(%rbp)
jge 0xf7f7
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf912
movq -0x30(%rbp), %rax
cmpq $0x0, 0xfb0(%rax)
je 0xf855
cmpl $0x0, -0x40(%rbp)
jle 0xf855
movq -0x20(%rbp), %rcx
movslq -0x3c(%rbp), %rax
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0xfb0(%rax), %rax
movl -0x34(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movl -0x40(%rbp), %ecx
movq -0x30(%rbp), %rax
movq 0xfb0(%rax), %rax
movl -0x34(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x40(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0xf8fa
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5e, %eax
jne 0xf888
cmpl $0x0, -0x3c(%rbp)
je 0xf886
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf912
jmp 0xf8f8
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x24, %eax
jne 0xf8ac
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0xf8aa
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf912
jmp 0xf8f6
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jl 0xf8bd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf912
movq -0x10(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movslq -0x3c(%rbp), %rax
addq %rax, %rsi
movq -0x30(%rbp), %rdx
callq 0xfbc0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jg 0xf8ed
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf912
movl -0x40(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0xf8f8
jmp 0xf8fa
jmp 0xf8fc
jmp 0xf8fe
movl -0x44(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0xf31c
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)