// File: /workspace/github_c_makefile_star2_O0/MaoKo[P]FGFX/fgfl/src/regex.c
// Function: finite_seq
static regex_node_t*
finite_seq(regex_node_t* root) {
    if (advance_token(regex_spec->lex) != T_DIGIT) {
        errorf(CURRENT_LINE(regex_spec->lex), "Missing a digit after the '{'.");
        return (NULL_NODE);
    }

    size_t start = atoi(C_LEXEME(regex_spec->lex));
    regex_node_t* rep_node = cpy_concat_regex_node(root, start);

    if (peek_token(regex_spec->lex) == T_REG_COMMA) {
        advance_token(regex_spec->lex);
        if (peek_token(regex_spec->lex) == T_DIGIT) {
            advance_token(regex_spec->lex);
            size_t until = atoi(C_LEXEME(regex_spec->lex));

            if (until < start) {
                del_regex_node(rep_node);
                errorf(CURRENT_LINE(regex_spec->lex),
                            "The first digit in the finite sequence %zu"
                            " is greater than the second %zu.", start, until);
                return (NULL_NODE);
            }   
            for (size_t i = start + 1; i <= until; ++i) {
                root = cpy_regex_node(root);
                rep_node = new_regex_node(AST_UNION, rep_node,
                                            cpy_concat_regex_node(root, i));
            }
        }
        else {
            rep_node = new_regex_node(AST_CONCAT, rep_node,
                new_regex_node(AST_STAR, cpy_regex_node(rep_node)));
        }
    }

    if (advance_token(regex_spec->lex) != T_REG_RBRACE) {
        del_regex_node(rep_node);
        errorf(CURRENT_LINE(regex_spec->lex),
                                "Missing the '}' in the finite sequence.");
        return (NULL_NODE);
    }
    return (rep_node);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq 0x19e6d(%rip), %rax     # 0x21dc0
movq (%rax), %rdi
callq 0x2cc0
cmpq $0x11, %rax
je 0x7f8a
movq 0x19e58(%rip), %rax     # 0x21dc0
movq (%rax), %rax
movslq 0x28(%rax), %rdi
leaq 0x706f(%rip), %rsi      # 0xefe5
movb $0x0, %al
callq 0x4230
movq $0x0, -0x8(%rbp)
jmp 0x8146
movq 0x19e2f(%rip), %rax     # 0x21dc0
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
callq 0x1170
cltq
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa650
movq %rax, -0x20(%rbp)
movq 0x19e02(%rip), %rax     # 0x21dc0
movq (%rax), %rdi
callq 0x3300
cmpl $0x12, %eax
jne 0x80fa
movq 0x19dea(%rip), %rax     # 0x21dc0
movq (%rax), %rdi
callq 0x2cc0
movq 0x19ddb(%rip), %rax     # 0x21dc0
movq (%rax), %rdi
callq 0x3300
cmpl $0x11, %eax
jne 0x80c1
movq 0x19dc3(%rip), %rax     # 0x21dc0
movq (%rax), %rdi
callq 0x2cc0
movq 0x19db4(%rip), %rax     # 0x21dc0
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
callq 0x1170
cltq
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x8065
movq -0x20(%rbp), %rdi
callq 0xa380
movq 0x19d85(%rip), %rax     # 0x21dc0
movq (%rax), %rax
movslq 0x28(%rax), %rdi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq 0x6fb3(%rip), %rsi      # 0xf004
movb $0x0, %al
callq 0x4230
movq $0x0, -0x8(%rbp)
jmp 0x8146
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
ja 0x80bf
movq -0x10(%rbp), %rdi
callq 0xa440
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xa650
movq -0x38(%rbp), %rsi
movq %rax, %rdx
xorl %edi, %edi
movb $0x0, %al
callq 0x9c00
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x8071
jmp 0x80f8
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa440
movq %rax, %rsi
movl $0x3, %edi
movb $0x0, %al
callq 0x9c00
movq -0x40(%rbp), %rsi
movq %rax, %rdx
movl $0x1, %edi
movb $0x0, %al
callq 0x9c00
movq %rax, -0x20(%rbp)
jmp 0x80fa
movq 0x19cbf(%rip), %rax     # 0x21dc0
movq (%rax), %rdi
callq 0x2cc0
cmpq $0x10, %rax
je 0x813e
movq -0x20(%rbp), %rdi
callq 0xa380
movq 0x19ca1(%rip), %rax     # 0x21dc0
movq (%rax), %rax
movslq 0x28(%rax), %rdi
leaq 0x6f22(%rip), %rsi      # 0xf04f
movb $0x0, %al
callq 0x4230
movq $0x0, -0x8(%rbp)
jmp 0x8146
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq