// File: /workspace/github_c_makefile_star2_O1/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
movl $0x1, %edi
movl $0x1, %esi
callq 0x4280
movq %rax, %r14
movl %ebp, %eax
cmpl $0x5e, %ebp
je 0x8e04
testl %eax, %eax
jne 0x8e0a
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
callq 0x4580
leaq 0x5940(%rip), %rdi      # 0xe731
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x44a0
cmpb $0x0, 0x1(%rbx)
je 0x8dda
xorl %r13d, %r13d
movl %eax, 0x4(%rsp)
cmpb $0x5e, %al
sete %r13b
movq %rbx, %rdi
callq 0x4120
cmpq %r13, %rax
jbe 0x8ffb
movzbl (%rbx,%r13), %eax
cmpl $0x2d, %eax
je 0x8e67
cmpl $0x5c, %eax
jne 0x8ea8
movzbl 0x1(%rbx,%r13), %eax
leal -0x61(%rax), %ecx
cmpl $0x16, %ecx
ja 0x8f04
leaq 0x539c(%rip), %rdx      # 0xe1ec
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
xorl %ebp, %ebp
leaq 0x58ee(%rip), %r15      # 0xe750
jmp 0x8f7d
movsbq 0x1(%rbx,%r13), %r15
testq %r15, %r15
setne %al
testq %r13, %r13
setne %cl
testb %al, %cl
jne 0x8ebc
movq %r14, %rdi
callq 0x4120
leaq 0x2(%rax), %rsi
movq %r14, %rdi
callq 0x4400
movq %rax, %r14
movq %rax, %rdi
callq 0x4120
movw $0x2d, (%r14,%rax)
jmp 0x8fe7
movq %r14, %rdi
callq 0x4120
leaq 0x2(%rax), %rsi
movq %r14, %rdi
jmp 0x8f9a
movsbq -0x1(%rbx,%r13), %r12
decq %r15
incq %r12
cmpq %r15, %r12
ja 0x8fe7
movq %r14, %rdi
callq 0x4120
leaq 0x3(%rax), %rsi
movq %r14, %rdi
callq 0x4400
movq %rax, %r14
movq %rax, %rdi
callq 0x4120
movb $0x0, 0x1(%r14,%rax)
movq %r14, %rdi
callq 0x4120
movb %r12b, (%r14,%rax)
jmp 0x8ec5
cmpl $0x2d, %eax
jne 0x8f14
xorl %ebp, %ebp
leaq 0x5616(%rip), %r15      # 0xe528
jmp 0x8f7d
movb $0x1, %bpl
xorl %r15d, %r15d
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x5833(%rip), %r15      # 0xe758
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x58ba(%rip), %r15      # 0xe7ea
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x5797(%rip), %r15      # 0xe6d2
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x54db(%rip), %r15      # 0xe421
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x5803(%rip), %r15      # 0xe754
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x57f6(%rip), %r15      # 0xe752
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x54a1(%rip), %r15      # 0xe408
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x57e4(%rip), %r15      # 0xe756
jmp 0x8f7d
xorl %ebp, %ebp
leaq 0x5490(%rip), %r15      # 0xe40d
incq %r13
movq %r14, %rdi
callq 0x4120
movq %rax, %r12
testb %bpl, %bpl
je 0x8fc2
addq $0x2, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x4400
movq %rax, %r14
movq %rax, %rdi
callq 0x4120
movb $0x0, 0x1(%r14,%rax)
movb (%rbx,%r13), %bpl
movq %r14, %rdi
callq 0x4120
movb %bpl, (%r14,%rax)
jmp 0x8fe7
movq %r15, %rdi
callq 0x4120
leaq (%r12,%rax), %rsi
incq %rsi
movq %r14, %rdi
callq 0x4400
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x44c0
incq %r13
movq %rbx, %rdi
callq 0x4120
cmpq %rax, %r13
jb 0x8e28
cmpb $0x5e, 0x4(%rsp)
jne 0x900c
movq %r14, %rdi
callq 0x4190
jmp 0x9014
movq %r14, %rdi
callq 0x4070
movq %rax, %r15
movq %rbx, %rdi
callq 0x4580
movq %r14, %rdi
callq 0x4580
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq