// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_lexer.c
// Function: lexDigitSeq
static uint64_t lexDigitSeq(Lexer *lex, int base, int *len, bool isFrac)
{
    uint64_t result = 0;
    *len = 0;

    if (lexCharDigit(lex->buf[lex->bufPos], base) == -1)
        lex->error->handler(lex->error->context, "Invalid number");

    bool skipDigits = false;

    while (lexCharDigit(lex->buf[lex->bufPos], base) != -1)
    {
        uint64_t newResult = result * base + lexCharDigit(lex->buf[lex->bufPos], base);
        if ((result * base) / base != result || newResult < result)
        {
            if (isFrac)
                skipDigits = true;
            else
                lex->error->handler(lex->error->context, "Number is too large");
        }

        if (!skipDigits)
        {
            result = newResult;
            (*len)++;
        }

        lexChar(lex);

        if (lex->buf[lex->bufPos] == '_')
        {
            if (lexCharDigit(lex->buf[lex->bufPos + 1], base) != -1)
                lexChar(lex);
            else
                lex->error->handler(lex->error->context, "_ must be placed between digits");
        }
    }

    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movslq 0x18(%rcx), %rcx
movb (%rax,%rcx), %al
movl -0xc(%rbp), %esi
movsbl %al, %edi
callq 0x1c1d0
cmpl $-0x1, %eax
jne 0x1c337
movq -0x8(%rbp), %rax
movq 0x268(%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x268(%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x1bd486(%rip), %rsi    # 0x1d97b9
movb $0x0, %al
callq *%rcx
movb $0x0, -0x29(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movslq 0x18(%rcx), %rcx
movb (%rax,%rcx), %al
movl -0xc(%rbp), %esi
movsbl %al, %edi
callq 0x1c1d0
cmpl $-0x1, %eax
je 0x1c498
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movslq 0x18(%rcx), %rcx
movb (%rax,%rcx), %al
movl -0xc(%rbp), %esi
movsbl %al, %edi
callq 0x1c1d0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq %rcx, %rax
movslq -0xc(%rbp), %rcx
xorl %edx, %edx
divq %rcx
cmpq -0x28(%rbp), %rax
jne 0x1c3c5
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x1c3fb
testb $0x1, -0x19(%rbp)
je 0x1c3d1
movb $0x1, -0x29(%rbp)
jmp 0x1c3f9
movq -0x8(%rbp), %rax
movq 0x268(%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x268(%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x1bd3b0(%rip), %rsi    # 0x1d97a5
movb $0x0, %al
callq *%rcx
jmp 0x1c3fb
testb $0x1, -0x29(%rbp)
jne 0x1c414
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
callq 0x1bff0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movslq 0x18(%rcx), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5f, %eax
jne 0x1c493
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x18(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movl -0xc(%rbp), %esi
movsbl %al, %edi
callq 0x1c1d0
cmpl $-0x1, %eax
je 0x1c469
movq -0x8(%rbp), %rdi
callq 0x1bff0
jmp 0x1c491
movq -0x8(%rbp), %rax
movq 0x268(%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x268(%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x1bd33b(%rip), %rsi    # 0x1d97c8
movb $0x0, %al
callq *%rcx
jmp 0x1c493
jmp 0x1c33b
movq -0x28(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)