// File: /workspace/github_c_makefile_star2_O3/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
cmpl $0x5e, %ebp
je 0x8d0c
testl %ebp, %ebp
jne 0x8d12
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
callq 0x4580
leaq 0x5a68(%rip), %rdi      # 0xe761
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4490
cmpb $0x0, 0x1(%rbx)
je 0x8ce2
xorl %r13d, %r13d
cmpb $0x5e, %bpl
sete %r13b
movq %rbx, %rdi
callq 0x4130
cmpq %r13, %rax
jbe 0x8ed5
movzbl (%rbx,%r13), %eax
cmpl $0x2d, %eax
je 0x8d72
cmpl $0x5c, %eax
jne 0x8e0b
movzbl 0x1(%rbx,%r13), %eax
incq %r13
leal -0x61(%rax), %ecx
cmpl $0x16, %ecx
ja 0x8dfb
leaq 0x548f(%rip), %rdx      # 0xe1ec
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
leaq 0x5a13(%rip), %r15      # 0xe780
jmp 0x8e91
movsbq 0x1(%rbx,%r13), %r15
testq %r15, %r15
setne %al
testq %r13, %r13
setne %cl
testb %al, %cl
jne 0x8db3
movq %r14, %rdi
callq 0x4130
leaq 0x2(%rax), %rsi
movq %r14, %rdi
callq 0x43f0
movq %rax, %r14
movq %rax, %rdi
callq 0x4130
movw $0x2d, (%r14,%rax)
jmp 0x8ec1
movsbq -0x1(%rbx,%r13), %r12
decq %r15
incq %r12
cmpq %r15, %r12
ja 0x8ec1
movq %r14, %rdi
callq 0x4130
leaq 0x3(%rax), %rsi
movq %r14, %rdi
callq 0x43f0
movq %rax, %r14
movq %rax, %rdi
callq 0x4130
movb $0x0, 0x1(%r14,%rax)
movq %r14, %rdi
callq 0x4130
movb %r12b, (%r14,%rax)
jmp 0x8dbc
leaq 0x5756(%rip), %r15      # 0xe558
cmpl $0x2d, %eax
je 0x8e91
movq %r14, %rdi
callq 0x4130
leaq 0x2(%rax), %rsi
movq %r14, %rdi
callq 0x43f0
movq %rax, %r14
movq %rax, %rdi
callq 0x4130
movb $0x0, 0x1(%r14,%rax)
movb (%rbx,%r13), %r15b
movq %r14, %rdi
callq 0x4130
movb %r15b, (%r14,%rax)
jmp 0x8ec1
leaq 0x593f(%rip), %r15      # 0xe788
jmp 0x8e91
leaq 0x59c8(%rip), %r15      # 0xe81a
jmp 0x8e91
leaq 0x58a7(%rip), %r15      # 0xe702
jmp 0x8e91
leaq 0x55ed(%rip), %r15      # 0xe451
jmp 0x8e91
leaq 0x5917(%rip), %r15      # 0xe784
jmp 0x8e91
leaq 0x590c(%rip), %r15      # 0xe782
jmp 0x8e91
leaq 0x55b9(%rip), %r15      # 0xe438
jmp 0x8e91
leaq 0x58fe(%rip), %r15      # 0xe786
jmp 0x8e91
leaq 0x55ac(%rip), %r15      # 0xe43d
movq %r14, %rdi
callq 0x4130
movq %rax, %r12
movq %r15, %rdi
callq 0x4130
leaq (%r12,%rax), %rsi
incq %rsi
movq %r14, %rdi
callq 0x43f0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x44b0
incq %r13
movq %rbx, %rdi
callq 0x4130
cmpq %rax, %r13
jb 0x8d2e
movq %r14, %rdi
cmpb $0x5e, %bpl
jne 0x8ee5
callq 0x4190
jmp 0x8eea
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