// File: /workspace/github_c_makefile_star2_O0/masyagin1998[P]GCI/src/parser/parser.c
// Function: decl_stmt_ast_read
static enum PARSER_CODES decl_stmt_ast_read(struct PARSER*parser, struct DECL_STMT_AST**decl_stmt)
{
    enum PARSER_CODES r;
    struct IDENT_AST*var_name;
    struct ASSIGNMENT_EXPR_AST*assignment_expr;
    
    if ((parser->tok)->token_type != TOKEN_TYPE_LET) {
        r = PARSER_INVALID_TOKEN;
        set_parser_error(parser, 1, TOKEN_TYPE_LET);
        goto err0;
    }    
    token_free((parser->tok));
    lexer_next_token(parser->lexer, &(parser->tok));

    r = ident_ast_read(parser, &var_name);
    if (r != PARSER_OK) {
        goto err0;
    }
    if ((parser->tok)->token_type != TOKEN_TYPE_EQ) {
        r = PARSER_INVALID_TOKEN;
        set_parser_error(parser, 1, TOKEN_TYPE_EQ);
        goto err1;
    }
    token_free((parser->tok));
    lexer_next_token(parser->lexer, &(parser->tok));

    r = assignment_expr_ast_read(parser, &assignment_expr);
    if (r != PARSER_OK) {
        goto err1;
    }

    if ((parser->tok)->token_type != TOKEN_TYPE_SEMI) {
        r = PARSER_INVALID_TOKEN;
        set_parser_error(parser, 1, TOKEN_TYPE_SEMI);
        goto err2;
    }
    token_free((parser->tok));
    lexer_next_token(parser->lexer, &(parser->tok));

    (*decl_stmt) = create_decl_stmt_ast(var_name, assignment_expr,
                                        (parser->tok)->frag.starting.line,
                                        (parser->tok)->frag.starting.pos);

    return PARSER_OK;

 err2:
    assignment_expr_ast_free(assignment_expr);
 err1:
    ident_ast_free(var_name);
 err0:
    (*decl_stmt) = NULL;
    return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1, (%rax)
je 0x4cce
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movb $0x0, %al
callq 0x4030
jmp 0x4e0a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x31b0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0x1fd0
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4190
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x4d0a
jmp 0x4e0a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x15, (%rax)
je 0x4d38
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x15, %edx
movb $0x0, %al
callq 0x4030
jmp 0x4e01
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x31b0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0x1fd0
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x5190
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x4d74
jmp 0x4e01
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x23, (%rax)
je 0x4d9f
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x23, %edx
movb $0x0, %al
callq 0x4030
jmp 0x4df8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x31b0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0x1fd0
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rcx
callq 0x9640
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4e1b
movq -0x30(%rbp), %rdi
callq 0x9810
movq -0x28(%rbp), %rdi
callq 0x8b30
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)