// File: /workspace/github_c_makefile_star2_O3/sharmaeklavya2[P]cerplag/lexer.c
// Function: execute_action
void execute_action(action_t a, char ch, Dfa* pdfa, Token* ptok)
{
    lerr_t lerr = LERR_NONE;
    switch(a)
    {
    case A_ADD:
        pdfa->lexeme[pdfa->size] = ch;
        (pdfa->size)++;
        if(pdfa->size >= LEXEME_BUFSIZE)
        {
            (pdfa->size)--;
            pdfa->trunc = true;
        }
        pdfa->lexeme[pdfa->size] = '\0';
        break;
    case A_IGN:
        break;
    case A_NL:
        pdfa->line++;
        pdfa->col = 0;
        break;
    case A_CLR:
        pdfa->lexeme[0] = '\0';
        pdfa->size = 0;
        break;
    case A_ERR:
        if(get_cclass(ch) == C_REST)
            lerr = LERR_BAD_SYM;
        else if(pdfa->s == S_I1)
            lerr = LERR_NUM;
        else
            lerr = LERR_UPAT;
        // break statement intentionally left out
    case A_TOKS:
    case A_TOKF:
    case A_TOKN:
        if(a == A_TOKF)
        {
            pdfa->lexeme[(pdfa->size)++] = ch;
            pdfa->lexeme[pdfa->size] = '\0';
        }
        else if(a == A_TOKN)
            pdfa->lexeme[--(pdfa->size)] = '\0';
        else
        {
            input_ptr--;
            pdfa->col--;
        }
        swap_buffers(pdfa, ptok);

        ptok->line = pdfa->line;
        ptok->col = pdfa->col - ptok->size + 1;
        if(a == A_TOKN)
            ptok->col -= 2;

        if(pdfa->trunc)
        {
            ptok->tid = T_ERR;
            lerr = LERR_LONG_TOK;
            pdfa->trunc = false;
        }
        else if(a == A_TOKS)
        {
            ptok->tid = predict_token_from_state(pdfa->s);
            if(ptok->tid == T_ERR)
                lerr = LERR_OTH;
        }
        else if(a == A_TOKF)
        {
            ptok->tid = predict_token_from_char(ptok->lexeme[0]);
            if(get_cclass(ch) == C_REST)
                lerr = LERR_BAD_SYM;
            else if(ptok->tid == T_ERR)
                lerr = LERR_UPAT;
        }
        else if(a == A_TOKN)
            ptok->tid = T_NUM;
        else
            ptok->tid = T_ERR;

        if(a == A_TOKN)
        {
            pdfa->lexeme[0] = '.'; pdfa->lexeme[1] = '.'; pdfa->lexeme[2] = '\0';
            pdfa->size = 2;
        }
        else
        {
            pdfa->lexeme[0] = '\0';
            pdfa->size = 0;
        }
        break;
    case A_LAST:
        assert(false);
        break;
    }
    if(lerr != LERR_NONE)
        print_lex_error(lerr, pdfa, ptok);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x8, %edi
ja 0x5709
movq %rcx, %r14
movq %rdx, %rbx
movl %edi, %r15d
movl %edi, %eax
leaq 0x8b9e(%rip), %rcx      # 0xe108
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rbx), %rax
movslq 0x18(%rbx), %rcx
movb %sil, (%rax,%rcx)
movl 0x18(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x18(%rbx)
cmpl $0x1d, %eax
jl 0x5596
movl %eax, 0x18(%rbx)
movb $0x1, 0x1c(%rbx)
movl %eax, %ecx
movq 0x10(%rbx), %rax
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
jmp 0x5709
xorl %r12d, %r12d
jmp 0x5619
movq 0x10(%rbx), %rax
movslq 0x18(%rbx), %rcx
leaq -0x1(%rcx), %rdx
movl %edx, 0x18(%rbx)
movb $0x0, -0x1(%rax,%rcx)
xorl %eax, %eax
xorl %r12d, %r12d
jmp 0x564a
movq 0x10(%rbx), %rax
movb $0x0, (%rax)
movl $0x0, 0x18(%rbx)
jmp 0x5709
incl 0x4(%rbx)
movl $0x0, 0x8(%rbx)
jmp 0x5709
testb %sil, %sil
je 0x5609
movl $0x2, %r12d
js 0x5619
movsbq %sil, %rax
leaq 0x1135d(%rip), %rcx     # 0x16960
cmpl $0x0, (%rcx,%rax,4)
je 0x5619
xorl %eax, %eax
cmpl $0x10, (%rbx)
setne %al
leal 0x3(,%rax,2), %r12d
decq 0x11540(%rip)           # 0x16b60
decl 0x8(%rbx)
xorl %eax, %eax
jmp 0x564a
movq 0x10(%rbx), %rax
movslq 0x18(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x18(%rbx)
movb %sil, (%rax,%rcx)
movq 0x10(%rbx), %rax
movslq 0x18(%rbx), %rcx
movb $0x0, (%rax,%rcx)
xorl %r12d, %r12d
movb $0x1, %al
movq 0x10(%rbx), %rcx
movq 0x8(%r14), %r13
movq %r13, 0x10(%rbx)
movq %rcx, 0x8(%r14)
movl 0x18(%rbx), %edx
movl 0x14(%r14), %edi
movl %edi, 0x18(%rbx)
movl %edx, 0x14(%r14)
movl 0x4(%rbx), %edi
movl %edi, (%r14)
xorl %edi, %edi
cmpl $0x6, %r15d
setne %dil
notl %edx
leal (%rdx,%rdi,2), %edx
addl 0x8(%rbx), %edx
movl %edx, 0x4(%r14)
cmpb $0x1, 0x1c(%rbx)
jne 0x56c2
movl $0x0, 0x18(%r14)
movb $0x0, 0x1c(%rbx)
movl $0x7, %ecx
xorl %eax, %eax
cmpl $0x6, %r15d
jne 0x56bd
movb $0x2e, %al
movb %al, (%r13)
movq 0x10(%rbx), %rdx
movb %al, 0x1(%rdx)
movq 0x10(%rbx), %r13
addq $0x2, %r13
movl $0x2, %eax
movl %ecx, %r12d
jmp 0x56e0
cmpl $0x4, %r15d
jne 0x5718
movl (%rbx), %edi
callq 0x54bf
movl %eax, 0x18(%r14)
testl %eax, %eax
movl $0x1, %eax
cmovel %eax, %r12d
xorl %eax, %eax
movb $0x0, (%r13)
movl %eax, 0x18(%rbx)
testl %r12d, %r12d
je 0x5709
movl %r12d, %edi
movq %rbx, %rsi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x54da
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %al, %al
je 0x5765
movsbl (%rcx), %edi
movl %esi, -0x2c(%rbp)
callq 0x5433
movl -0x2c(%rbp), %edx
movl %eax, 0x18(%r14)
testb %dl, %dl
je 0x5752
movl $0x2, %ecx
js 0x569b
movsbq %dl, %rdx
leaq 0x11218(%rip), %rsi     # 0x16960
cmpl $0x0, (%rsi,%rdx,4)
je 0x569b
testl %eax, %eax
movl $0x5, %eax
cmovel %eax, %r12d
movl %r12d, %ecx
jmp 0x569b
cmpl $0x6, %r15d
jne 0x577b
movl $0x3, 0x18(%r14)
movl %r12d, %ecx
jmp 0x56a3
movl $0x0, 0x18(%r14)
jmp 0x56de
leaq 0x8d1a(%rip), %rdi      # 0xe4a9
leaq 0x8e9c(%rip), %rsi      # 0xe632
leaq 0x8e9d(%rip), %rcx      # 0xe63a
movl $0x1b8, %edx            # imm = 0x1B8
callq 0x30d0