// File: /workspace/github_c_makefile_star2_O2/orangeduck[P]mpc/mpc.c
// Function: mpcf_re_range
static mpc_val_t *mpcf_re_range(mpc_val_t *x) {

  mpc_parser_t *out;
  size_t i, j;
  size_t start, end;
  const char *tmp = NULL;
  const char *s = x;
  int comp = s[0] == '^' ? 1 : 0;
  char *range = calloc(1,1);

  if (s[0] == '\0') { free(range); free(x); return mpc_fail("Invalid Regex Range Expression"); }
  if (s[0] == '^' &&
      s[1] == '\0') { free(range); free(x); return mpc_fail("Invalid Regex Range Expression"); }

  for (i = comp; i < strlen(s); i++){

    /* Regex Range Escape */
    if (s[i] == '\\') {
      tmp = mpc_re_range_escape_char(s[i+1]);
      if (tmp != NULL) {
        range = realloc(range, strlen(range) + strlen(tmp) + 1);
        strcat(range, tmp);
      } else {
        range = realloc(range, strlen(range) + 1 + 1);
        range[strlen(range) + 1] = '\0';
        range[strlen(range) + 0] = s[i+1];
      }
      i++;
    }

    /* Regex Range...Range */
    else if (s[i] == '-') {
      if (s[i+1] == '\0' || i == 0) {
          range = realloc(range, strlen(range) + strlen("-") + 1);
          strcat(range, "-");
      } else {
        start = s[i-1]+1;
        end = s[i+1]-1;
        for (j = start; j <= end; j++) {
          range = realloc(range, strlen(range) + 1 + 1 + 1);
          range[strlen(range) + 1] = '\0';
          range[strlen(range) + 0] = (char)j;
        }
      }
    }

    /* Regex Range Normal */
    else {
      range = realloc(range, strlen(range) + 1 + 1);
      range[strlen(range) + 1] = '\0';
      range[strlen(range) + 0] = s[i];
    }

  }

  out = comp == 1 ? mpc_noneof(range) : mpc_oneof(range);

  free(x);
  free(range);

  return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzbl (%rdi), %ebp
pushq $0x1
popq %rdi
movq %rdi, %rsi
callq 0x43c0
movq %rax, %r14
cmpl $0x5e, %ebp
je 0x81fa
testl %ebp, %ebp
jne 0x8200
movq %r14, %rdi
callq 0x4880
movq %rbx, %rdi
callq 0x4880
leaq 0x456a(%rip), %rdi      # 0xc751
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4710
cmpb $0x0, 0x1(%rbx)
je 0x81d0
xorl %r13d, %r13d
movl %ebp, 0x4(%rsp)
cmpb $0x5e, %bpl
sete %r13b
leaq 0x3fd6(%rip), %rbp      # 0xc1ec
movq %rbx, %rdi
callq 0x41c0
cmpq %rax, %r13
jae 0x83bc
movzbl (%rbx,%r13), %eax
cmpl $0x2d, %eax
je 0x8265
cmpl $0x5c, %eax
jne 0x82fe
movzbl 0x1(%rbx,%r13), %eax
incq %r13
leal -0x61(%rax), %ecx
cmpl $0x16, %ecx
ja 0x82ee
movslq (%rbp,%rcx,4), %rax
addq %rbp, %rax
jmpq *%rax
leaq 0x4510(%rip), %r15      # 0xc770
jmp 0x8384
movsbq 0x1(%rbx,%r13), %r15
testq %r15, %r15
setne %al
testq %r13, %r13
setne %cl
testb %al, %cl
jne 0x82a6
movq %r14, %rdi
callq 0x41c0
leaq 0x2(%rax), %rsi
movq %r14, %rdi
callq 0x4610
movq %rax, %r14
movq %rax, %rdi
callq 0x41c0
movw $0x2d, (%r14,%rax)
jmp 0x83b4
movsbq -0x1(%rbx,%r13), %r12
decq %r15
incq %r12
cmpq %r15, %r12
ja 0x83b4
movq %r14, %rdi
callq 0x41c0
leaq 0x3(%rax), %rsi
movq %r14, %rdi
callq 0x4610
movq %rax, %r14
movq %rax, %rdi
callq 0x41c0
movb $0x0, 0x1(%r14,%rax)
movq %r14, %rdi
callq 0x41c0
movb %r12b, (%r14,%rax)
jmp 0x82af
leaq 0x4253(%rip), %r15      # 0xc548
cmpl $0x2d, %eax
je 0x8384
movq %r14, %rdi
callq 0x41c0
leaq 0x2(%rax), %rsi
movq %r14, %rdi
callq 0x4610
movq %rax, %r14
movq %rax, %rdi
callq 0x41c0
movb $0x0, 0x1(%r14,%rax)
movb (%rbx,%r13), %r15b
movq %r14, %rdi
callq 0x41c0
movb %r15b, (%r14,%rax)
jmp 0x83b4
leaq 0x443c(%rip), %r15      # 0xc778
jmp 0x8384
leaq 0x44c5(%rip), %r15      # 0xc80a
jmp 0x8384
leaq 0x43a4(%rip), %r15      # 0xc6f2
jmp 0x8384
leaq 0x40ea(%rip), %r15      # 0xc441
jmp 0x8384
leaq 0x4414(%rip), %r15      # 0xc774
jmp 0x8384
leaq 0x4409(%rip), %r15      # 0xc772
jmp 0x8384
leaq 0x40b6(%rip), %r15      # 0xc428
jmp 0x8384
leaq 0x43fb(%rip), %r15      # 0xc776
jmp 0x8384
leaq 0x40a9(%rip), %r15      # 0xc42d
movq %r14, %rdi
callq 0x41c0
movq %rax, %r12
movq %r15, %rdi
callq 0x41c0
leaq (%r12,%rax), %rsi
incq %rsi
movq %r14, %rdi
callq 0x4610
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x4740
incq %r13
jmp 0x8216
cmpb $0x5e, 0x4(%rsp)
jne 0x83cd
movq %r14, %rdi
callq 0x4230
jmp 0x83d5
movq %r14, %rdi
callq 0x4090
movq %rax, %r15
movq %rbx, %rdi
callq 0x4880
movq %r14, %rdi
callq 0x4880
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq