// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movzbl (%rax,%rcx,8), %eax
cmpl $0x6, %eax
je 0x361433
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movzbl (%rax,%rcx,8), %eax
movl %eax, %ecx
leaq 0x23ba39(%rip), %rax    # 0x59cb30
movl (%rax,%rcx,4), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x361152
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movswl 0x2(%rax,%rcx,8), %eax
cmpl $0x0, %eax
je 0x361152
movl 0x1c(%rsp), %eax
movq 0x20(%rsp), %rcx
movslq 0x1c(%rsp), %rdx
movswl 0x2(%rcx,%rdx,8), %ecx
addl %ecx, %eax
cmpl 0x18(%rsp), %eax
jl 0x361152
movl 0x1c(%rsp), %eax
movq 0x20(%rsp), %rcx
movslq 0x1c(%rsp), %rdx
movswl 0x2(%rcx,%rdx,8), %ecx
addl %ecx, %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x36140e
movl 0x1c(%rsp), %eax
cmpl 0x18(%rsp), %eax
jl 0x36140c
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movzbl (%rax,%rcx,8), %eax
movl %eax, %ecx
leaq 0x23b9b9(%rip), %rax    # 0x59cb30
movl (%rax,%rcx,4), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x36140c
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movzbl 0x1(%rax,%rcx,8), %eax
sarl $0x4, %eax
andl $0xf, %eax
cmpl $0xf, %eax
jge 0x36140c
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movzbl 0x8(%rax,%rcx,8), %eax
movl %eax, %ecx
leaq 0x23b974(%rip), %rax    # 0x59cb30
movl (%rax,%rcx,4), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x36140c
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movswl 0xa(%rax,%rcx,8), %eax
cmpl $0x0, %eax
jne 0x36140c
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movzbl 0x1(%rax,%rcx,8), %eax
sarl $0x4, %eax
andl $0xf, %eax
movl %eax, 0x8(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %ecx
xorl %eax, %eax
cmpl 0x18(%rsp), %ecx
movb %al, 0x3(%rsp)
jle 0x361264
movq 0x20(%rsp), %rax
movslq 0x4(%rsp), %rcx
movzbl -0x8(%rax,%rcx,8), %eax
movl %eax, %ecx
leaq 0x23b904(%rip), %rax    # 0x59cb30
movl (%rax,%rcx,4), %ecx
andl $0x20, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x2(%rsp)
je 0x36125c
movq 0x20(%rsp), %rax
movslq 0x4(%rsp), %rcx
movzbl -0x7(%rax,%rcx,8), %eax
sarl $0x4, %eax
andl $0xf, %eax
cmpl $0xf, %eax
setl %al
movb %al, 0x2(%rsp)
movb 0x2(%rsp), %al
movb %al, 0x3(%rsp)
movb 0x3(%rsp), %al
testb $0x1, %al
jne 0x36126e
jmp 0x3612b2
movl 0x4(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x4(%rsp)
movq 0x20(%rsp), %rax
movslq 0x4(%rsp), %rcx
movzbl 0x1(%rax,%rcx,8), %eax
sarl $0x4, %eax
andl $0xf, %eax
cmpl 0x8(%rsp), %eax
jle 0x3612ad
movq 0x20(%rsp), %rax
movslq 0x4(%rsp), %rcx
movzbl 0x1(%rax,%rcx,8), %eax
sarl $0x4, %eax
andl $0xf, %eax
movl %eax, 0x8(%rsp)
jmp 0x361204
movq 0x20(%rsp), %rdi
movslq 0x1c(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
addq $0x8, %rdi
movl 0x8(%rsp), %esi
leaq 0x10(%rsp), %rdx
callq 0x3615f0
addl 0x1c(%rsp), %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x10(%rsp)
jne 0x3612e9
jmp 0x361410
cmpl $0xf, 0x10(%rsp)
jg 0x361306
movl 0x4(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jg 0x361306
movl 0x1c(%rsp), %eax
cmpl 0x14(%rsp), %eax
jge 0x361306
jmp 0x361325
leaq 0x23bcf1(%rip), %rdi    # 0x59cffe
leaq 0x23b8e6(%rip), %rsi    # 0x59cbfa
movl $0x37d, %edx            # imm = 0x37D
leaq 0x23bd03(%rip), %rcx    # 0x59d023
callq 0x19490
movl 0x4(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jg 0x361360
movl 0x10(%rsp), %esi
shll $0x4, %esi
movq 0x20(%rsp), %rax
movslq 0xc(%rsp), %rcx
movzbl 0x1(%rax,%rcx,8), %edx
addl %esi, %edx
movb %dl, 0x1(%rax,%rcx,8)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x36132d
movq 0x20(%rsp), %rdi
movslq 0x4(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl 0x14(%rsp), %esi
subl 0x4(%rsp), %esi
movl 0x1c(%rsp), %edx
subl 0x4(%rsp), %edx
addl $0x1, %edx
callq 0x360c40
movl 0x14(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movslq 0x4(%rsp), %rcx
movzbl (%rax,%rcx,8), %eax
movl %eax, %ecx
leaq 0x23b788(%rip), %rax    # 0x59cb30
movl (%rax,%rcx,4), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3613eb
movq 0x20(%rsp), %rax
movslq 0x4(%rsp), %rcx
movswl 0x2(%rax,%rcx,8), %eax
cmpl $0x0, %eax
jne 0x3613eb
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movzbl (%rax,%rcx,8), %eax
movl %eax, %ecx
leaq 0x23b752(%rip), %rax    # 0x59cb30
movl (%rax,%rcx,4), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x3613eb
jmp 0x36140a
leaq 0x23bc56(%rip), %rdi    # 0x59d048
leaq 0x23b801(%rip), %rsi    # 0x59cbfa
movl $0x382, %edx            # imm = 0x382
leaq 0x23bc1e(%rip), %rcx    # 0x59d023
callq 0x19490
jmp 0x36140c
jmp 0x36140e
jmp 0x361410
movq 0x20(%rsp), %rdi
movslq 0x1c(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x35f7b0
addl 0x1c(%rsp), %eax
movl %eax, 0x1c(%rsp)
jmp 0x3610c9
addq $0x28, %rsp
retq
nopl (%rax,%rax)