// File: /workspace/github_c_makefile_star2_O0/masyagin1998[P]GCI/src/parser/parser.c
// Function: variable_part_ast_read
static enum PARSER_CODES variable_part_ast_read(struct PARSER*parser, struct VARIABLE_PART_AST**variable_part)
{
    enum PARSER_CODES r;
    
    switch ((parser->tok)->token_type) {
    case TOKEN_TYPE_DOT: {
        struct IDENT_AST*field;

        token_free((parser->tok));
        lexer_next_token(parser->lexer, &(parser->tok));

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

        (*variable_part) = create_variable_part_ast(field, AST_VARIABLE_PART_TYPE_FIELD);
        break;
    }
    case TOKEN_TYPE_LBRACKET: {
        struct LOGICAL_OR_EXPR_AST*index;
        
        token_free((parser->tok));
        lexer_next_token(parser->lexer, &(parser->tok));

        r = logical_or_expr_ast_read(parser, &index);
        if (r != PARSER_OK) {
            goto err0;
        }

        if ((parser->tok)->token_type != TOKEN_TYPE_RBRACKET) {
            logical_or_expr_ast_free(index);
            r = PARSER_INVALID_TOKEN;
            set_parser_error(parser, 1, TOKEN_TYPE_RBRACKET);
            goto err0;
        }

        token_free((parser->tok));
        lexer_next_token(parser->lexer, &(parser->tok));

        (*variable_part) = create_variable_part_ast(index, AST_VARIABLE_PART_TYPE_INDEX);
        break;
    }
    default: {
        r = PARSER_INVALID_TOKEN;
        set_parser_error(parser, 2, TOKEN_TYPE_DOT, TOKEN_TYPE_LBRACKET);
        goto err0;
        break;
    }
    }

    return PARSER_OK;

 err0:
    (*variable_part) = 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
movl (%rax), %eax
movl %eax, -0x34(%rbp)
subl $0x1e, %eax
je 0x63c8
jmp 0x6364
movl -0x34(%rbp), %eax
subl $0x24, %eax
jne 0x6473
jmp 0x6372
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 0x63ae
jmp 0x649f
movq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0xa9a0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x6496
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 0x64c0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x6404
jmp 0x649f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1f, (%rax)
je 0x6438
movq -0x30(%rbp), %rdi
callq 0xa030
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1f, %edx
movb $0x0, %al
callq 0x4030
jmp 0x649f
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 -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0xa9a0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x6496
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
movl $0x2, %esi
movl $0x24, %edx
movl $0x1e, %ecx
movb $0x0, %al
callq 0x4030
jmp 0x649f
movl $0x0, -0x4(%rbp)
jmp 0x64b0
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
nopl (%rax)