// File: /workspace/github_c_makefile_star2_O0/masyagin1998[P]GCI/src/parser/parser.c
// Function: append_stmt_ast_read
static enum PARSER_CODES append_stmt_ast_read(struct PARSER*parser, struct APPEND_STMT_AST**append_stmt)
{
    enum PARSER_CODES r;

    struct VARIABLE_AST*obj;
    struct IDENT_AST*ident;

    size_t line;
    size_t pos;

    if ((parser->tok)->token_type != TOKEN_TYPE_APPEND) {
        r = PARSER_INVALID_TOKEN;
        set_parser_error(parser, 1, TOKEN_TYPE_APPEND);
        goto err0;
    } 
    line = (parser->tok)->frag.starting.line;
    pos = (parser->tok)->frag.starting.pos;   
    token_free((parser->tok));
    lexer_next_token(parser->lexer, &(parser->tok));

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

    r = ident_ast_read(parser, &ident);
    if (r != PARSER_OK) {
        goto err0;
    }

    r = variable_ast_read(parser, &obj, ident);
    if (r != PARSER_OK) {
        goto err1;
    }

    ident = NULL;

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

    r = ident_ast_read(parser, &ident);
    if (r != PARSER_OK) {
        goto err2;
    }

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

    (*append_stmt) = create_append_stmt_ast(obj, ident,
                                            line, pos);

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

    return PARSER_OK;

 err2:
    variable_ast_free(obj);
 err1:
    if (ident != NULL) {
        ident_ast_free(ident);
    }
 err0:
    (*append_stmt) = NULL;
    return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x7, (%rax)
je 0x5a4e
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x7, %edx
movb $0x0, %al
callq 0x4030
jmp 0x5c68
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
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), %rax
movq 0x8(%rax), %rax
cmpl $0x1b, (%rax)
je 0x5abd
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1b, %edx
movb $0x0, %al
callq 0x4030
jmp 0x5c68
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 0x4190
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x5af9
jmp 0x5c68
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq -0x28(%rbp), %rsi
callq 0x4f80
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x5b18
jmp 0x5c56
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x22, (%rax)
je 0x5b4e
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x22, %edx
movb $0x0, %al
callq 0x4030
jmp 0x5c4d
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 0x4190
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x5b8a
jmp 0x5c4d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1c, (%rax)
je 0x5bb8
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1c, %edx
movb $0x0, %al
callq 0x4030
jmp 0x5c4d
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 -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0xa4d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x23, (%rax)
je 0x5c23
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x23, %edx
movb $0x0, %al
callq 0x4030
jmp 0x5c68
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
movl $0x0, -0x4(%rbp)
jmp 0x5c79
movq -0x28(%rbp), %rdi
callq 0x9a80
cmpq $0x0, -0x30(%rbp)
je 0x5c66
movq -0x30(%rbp), %rdi
callq 0x8b30
jmp 0x5c68
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)