// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/lpeg-0.10.2/lpeg.c
// Function: optimizecaptures
static void optimizecaptures (Instruction *p) {
  int i;
  int limit = 0;
  for (i = 0; p[i].i.code != IEnd; i += sizei(p + i)) {
    if (isjmp(p + i) && dest(p, i) >= limit)
      limit = dest(p, i) + 1;  /* do not optimize jump targets */
    else if (i >= limit && ismovablecap(p + i) && isfixcheck(p + i + 1)) {
      int end, n, j;  /* found a border capture|check */
      int maxoff = getoff(p + i);
      int start = i;
      /* find first capture in the group */
      while (start > limit && ismovablecap(p + start - 1)) {
        start--;
        if (getoff(p + start) > maxoff) maxoff = getoff(p + start);
      }
      end = skipchecks(p + i + 1, maxoff, &n) + i;  /* find last check */
      if (n == 0) continue;  /* first check is too big to move across */
      assert(n <= MAXOFF && start <= i && i < end);
      for (j = start; j <= i; j++)
        p[j].i.aux += (n << 4);  /* correct offset of captures to be moved */
      rotate(p + start, end - start, i - start + 1);  /* move them up */
      i = end;
      assert(isfixcheck(p + start) && iscapture(p + i));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %r14d, %r14d
movl $0xfdc478, %r15d        # imm = 0xFDC478
xorl %ebp, %ebp
movslq %ebp, %r12
movzbl (%rbx,%r12,8), %eax
cmpq $0x6, %rax
je 0x1f28db
leaq (%rbx,%r12,8), %rdi
btq %rax, %r15
jb 0x1f27aa
movswl 0x2(%rdi), %ecx
testl %ecx, %ecx
je 0x1f27aa
addl %ebp, %ecx
cmpl %r14d, %ecx
jge 0x1f282b
cmpl %r14d, %ebp
jl 0x1f28cb
addq $-0x17, %rax
cmpq $-0x4, %rax
jb 0x1f28cb
movzbl 0x1(%rdi), %esi
cmpl $0xef, %esi
ja 0x1f28cb
movzbl 0x8(%rdi), %eax
addq $-0x3, %rax
cmpq $0x15, %rax
jb 0x1f28cb
cmpw $0x0, 0xa(%rdi)
jne 0x1f28cb
addq $0x8, %rdi
shrl $0x4, %esi
movslq %r14d, %rax
movq %r12, %r13
cmpq %rax, %r13
jle 0x1f2835
movzbl -0x8(%rbx,%r13,8), %ecx
addq $-0x17, %rcx
cmpq $-0x4, %rcx
jb 0x1f2838
movzbl -0x7(%rbx,%r13,8), %ecx
cmpl $0xef, %ecx
ja 0x1f2838
decq %r13
shrl $0x4, %ecx
cmpl %ecx, %esi
cmovlel %ecx, %esi
jmp 0x1f27fb
incl %ecx
movl %ecx, %r14d
jmp 0x1f28cb
movl %r14d, %r13d
leaq 0x4(%rsp), %rdx
callq 0x1f2928
movl %eax, %r15d
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x1f28bf
cmpl %ebp, %r13d
jg 0x1f2909
cmpl $0xf, %eax
jg 0x1f2909
testl %r15d, %r15d
jle 0x1f2909
addl %ebp, %r15d
shlb $0x4, %al
movslq %r13d, %rcx
movq %rcx, %rdx
cmpq %r12, %rdx
jg 0x1f2882
addb %al, 0x1(%rbx,%rdx,8)
incq %rdx
jmp 0x1f2874
leaq (%rbx,%rcx,8), %r12
movl %r15d, %esi
subl %r13d, %esi
subl %r13d, %ebp
incl %ebp
movq %r12, %rdi
movl %ebp, %edx
callq 0x1f2711
movzbl (%r12), %eax
addq $-0x3, %rax
cmpq $0x15, %rax
jb 0x1f28ea
cmpw $0x0, 0x2(%r12)
jne 0x1f28ea
movslq %r15d, %r12
cmpb $0x11, (%rbx,%r12,8)
ja 0x1f28c2
jmp 0x1f28ea
movl %ebp, %r15d
movl %r15d, %ebp
movl $0xfdc478, %r15d        # imm = 0xFDC478
leaq (%rbx,%r12,8), %rdi
callq 0x1f1f5f
addl %eax, %ebp
jmp 0x1f277b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17763f(%rip), %rdi    # 0x369f30
leaq 0x1771ea(%rip), %rsi    # 0x369ae2
leaq 0x17760c(%rip), %rcx    # 0x369f0b
movl $0x382, %edx            # imm = 0x382
callq 0x174b0
leaq 0x1775d6(%rip), %rdi    # 0x369ee6
leaq 0x1771cb(%rip), %rsi    # 0x369ae2
leaq 0x1775ed(%rip), %rcx    # 0x369f0b
movl $0x37d, %edx            # imm = 0x37D
callq 0x174b0