// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movb (%rdi), %al
cmpb $0x6, %al
je 0x23f7db
movq %rdi, %rbx
leaq 0x1(%rdi), %rcx
movq %rcx, 0x10(%rsp)
xorl %r15d, %r15d
movl $0xfdc478, %r8d         # imm = 0xFDC478
xorl %r13d, %r13d
movzbl %al, %eax
btq %rax, %r8
jb 0x23f673
movswl 0x2(%rdi), %ecx
testl %ecx, %ecx
je 0x23f673
addl %r15d, %ecx
cmpl %r13d, %ecx
jge 0x23f6f8
cmpl %r13d, %r15d
jl 0x23f79f
addq $-0x17, %rax
cmpq $-0x4, %rax
jb 0x23f79f
movzbl 0x1(%rdi), %esi
cmpl $0xef, %esi
ja 0x23f79f
movzbl 0x8(%rdi), %eax
addq $-0x3, %rax
cmpq $0x15, %rax
jb 0x23f79f
cmpw $0x0, 0xa(%rdi)
jne 0x23f79f
shrl $0x4, %esi
cmpl %r13d, %r15d
jle 0x23f702
movslq %r15d, %r14
movslq %r13d, %rax
movzbl -0x8(%rbx,%r14,8), %ecx
addq $-0x17, %rcx
cmpq $-0x4, %rcx
jb 0x23f705
movzbl -0x7(%rbx,%r14,8), %ecx
cmpl $0xef, %ecx
ja 0x23f705
decq %r14
shrl $0x4, %ecx
cmpl %ecx, %esi
cmovlel %ecx, %esi
cmpq %rax, %r14
jg 0x23f6c5
movl %r13d, %r14d
jmp 0x23f705
incl %ecx
movl %ecx, %r13d
jmp 0x23f79f
movl %r15d, %r14d
addq $0x8, %rdi
leaq 0xc(%rsp), %rdx
callq 0x23f828
movl %eax, %ebp
movl 0xc(%rsp), %eax
testl %eax, %eax
je 0x23f793
cmpl %r15d, %r14d
jg 0x23f809
cmpl $0xf, %eax
jg 0x23f809
testl %ebp, %ebp
jle 0x23f809
addl %r15d, %ebp
shlb $0x4, %al
movslq %r14d, %rcx
incl %r15d
movq 0x10(%rsp), %rdx
leaq (%rdx,%rcx,8), %rdx
subl %r14d, %r15d
xorl %esi, %esi
addb %al, (%rdx,%rsi,8)
incq %rsi
cmpl %esi, %r15d
jne 0x23f751
leaq (%rbx,%rcx,8), %r12
movl %ebp, %esi
subl %r14d, %esi
movq %r12, %rdi
movl %r15d, %edx
callq 0x23f596
movzbl (%r12), %eax
addq $-0x3, %rax
cmpq $0x15, %rax
jb 0x23f7ea
cmpw $0x0, 0x2(%r12)
jne 0x23f7ea
movslq %ebp, %rax
cmpb $0x11, (%rbx,%rax,8)
ja 0x23f796
jmp 0x23f7ea
movl %r15d, %ebp
movl %ebp, %r15d
movl $0xfdc478, %r8d         # imm = 0xFDC478
movslq %r15d, %rcx
movzbl (%rbx,%rcx,8), %edx
movl $0x5, %eax
leal -0x2(%rdx), %esi
cmpl $0x2, %esi
jb 0x23f7c7
cmpl $0x11, %edx
jne 0x23f7c2
movzbl 0x1(%rbx,%rcx,8), %eax
addl $0x2, %eax
jmp 0x23f7c7
movl $0x1, %eax
addl %eax, %r15d
movslq %r15d, %rax
leaq (%rbx,%rax,8), %rdi
movb (%rdi), %al
cmpb $0x6, %al
jne 0x23f656
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18a33f(%rip), %rdi    # 0x3c9b30
leaq 0x189eea(%rip), %rsi    # 0x3c96e2
leaq 0x18a30c(%rip), %rcx    # 0x3c9b0b
movl $0x382, %edx            # imm = 0x382
callq 0x174d0
leaq 0x18a2d6(%rip), %rdi    # 0x3c9ae6
leaq 0x189ecb(%rip), %rsi    # 0x3c96e2
leaq 0x18a2ed(%rip), %rcx    # 0x3c9b0b
movl $0x37d, %edx            # imm = 0x37D
callq 0x174d0