// File: /workspace/github_c_makefile_star2_O1/masyagin1998[P]GCI/src/parser/parser.c
// Function: additive_expr_ast_read
static enum PARSER_CODES additive_expr_ast_read(struct PARSER*parser, struct ADDITIVE_EXPR_AST**additive_expr)
{
    enum PARSER_CODES r;

    struct MULTIPLICATIVE_EXPR_AST**multiplicative_exprs = NULL;
    size_t multiplicative_exprs_len = 0;
    size_t multiplicative_exprs_cap = 0;

    enum AST_ADDITIVE_OP*ops = NULL;
    size_t ops_len = 0;
    size_t ops_cap = 0;
    
    struct MULTIPLICATIVE_EXPR_AST*multiplicative_expr;

    r = multiplicative_expr_ast_read(parser, &multiplicative_expr);
    if (r != PARSER_OK) {
        goto err0;
    }

    PUSH_BACK(multiplicative_exprs, multiplicative_expr);

    while (((parser->tok)->token_type == TOKEN_TYPE_PLUS) || ((parser->tok)->token_type == TOKEN_TYPE_MINUS)) {
        if ((parser->tok)->token_type == TOKEN_TYPE_PLUS) {
            PUSH_BACK(ops, AST_ADDITIVE_OP_PLUS);
        } else if ((parser->tok)->token_type == TOKEN_TYPE_MINUS) {
            PUSH_BACK(ops, AST_ADDITIVE_OP_MINUS);
        }
        
        token_free((parser->tok));
        lexer_next_token(parser->lexer, &(parser->tok));

        r = multiplicative_expr_ast_read(parser, &multiplicative_expr);
        if (r != PARSER_OK) {
            goto err1;
        }

        PUSH_BACK(multiplicative_exprs, multiplicative_expr);
    }

    (*additive_expr) = create_additive_expr_ast(multiplicative_exprs, ops, multiplicative_exprs_len,
                                                (parser->tok)->frag.starting.line,
                                                (parser->tok)->frag.starting.pos);

    return PARSER_OK;

 err1:
    {
        size_t i;
        for (i = 0; i < multiplicative_exprs_len; i++) {
            multiplicative_expr_ast_free(multiplicative_exprs[i]);
        }
        SAFE_FREE(multiplicative_exprs);
    }
 err0:
    (*additive_expr) = NULL;
    return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r12
leaq 0x20(%rsp), %rsi
callq 0x7932
testl %eax, %eax
je 0x7691
movl %eax, %ecx
xorl %eax, %eax
jmp 0x78f2
movl $0x8, %edi
callq 0x1130
testq %rax, %rax
je 0x7913
movq %rax, %r14
movq %rbx, 0x28(%rsp)
movq 0x20(%rsp), %rax
movq %rax, (%r14)
movq 0x8(%r12), %rdx
movl (%rdx), %eax
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x16, %ecx
jne 0x7895
leaq 0x8(%r12), %rbx
movl $0x1, %ecx
movq %rcx, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
movl $0x1, %r13d
movq %rbx, 0x30(%rsp)
cmpl $0x17, %eax
je 0x774f
cmpl $0x16, %eax
jne 0x77e3
xorl %ebx, %ebx
movq 0x10(%rsp), %rax
cmpq %rax, %rbp
jne 0x77d3
testq %rax, %rax
je 0x7798
leaq (,%rax,8), %r15
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %rax, %rbx
callq 0x1160
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x7918
addq %rbx, %rbx
movq %rbx, 0x10(%rsp)
xorl %ebx, %ebx
jmp 0x77d3
movl $0x1, %ebx
movq 0x10(%rsp), %rax
cmpq %rax, %rbp
jne 0x77d3
testq %rax, %rax
je 0x77b1
leaq (,%rax,8), %r15
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %rax, %rbx
callq 0x1160
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x7920
addq %rbx, %rbx
movq %rbx, 0x10(%rsp)
movl $0x1, %ebx
jmp 0x77d3
movl $0x4, %edi
callq 0x1130
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x77c9
jmp 0x7928
movl $0x4, %edi
callq 0x1130
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x792d
movl $0x1, %eax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rax
movl %ebx, (%rax,%rbp,4)
incq %rbp
movq 0x30(%rsp), %rbx
movq 0x8(%r12), %rdi
callq 0x53b0
movq (%r12), %rdi
movq %rbx, %rsi
callq 0x45b5
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x7932
testl %eax, %eax
jne 0x78c5
movq 0x18(%rsp), %rax
cmpq %rax, %r13
jne 0x7874
testq %rax, %rax
je 0x7854
movq %r14, %rdi
movq %r12, %r14
movq %rbp, %r12
movq %rax, %r15
shlq $0x4, %r15
movq %r15, %rsi
movq %rax, %rbp
callq 0x1160
testq %rax, %rax
je 0x7906
addq %rbp, %rbp
movq %rbp, 0x18(%rsp)
movq %r12, %rbp
movq %r14, %r12
movq %rax, %r14
jmp 0x7874
movl $0x8, %edi
callq 0x1130
testq %rax, %rax
je 0x790e
movq %rax, %r14
movl $0x1, %eax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq %rax, (%r14,%r13,8)
incq %r13
movq (%rbx), %rdx
movl (%rdx), %eax
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x16, %ecx
je 0x76f7
jmp 0x78a4
movl $0x1, %r13d
movq $0x0, 0x8(%rsp)
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %r8
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0xa365
movq 0x28(%rsp), %rbx
xorl %ecx, %ecx
jmp 0x78f2
movl %eax, %r15d
testq %r13, %r13
je 0x78e0
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
callq 0xa51a
incq %rbx
cmpq %rbx, %r13
jne 0x78cf
movq %r14, %rdi
callq 0x1030
xorl %eax, %eax
movl %r15d, %ecx
movq 0x28(%rsp), %rbx
movq %rax, (%rbx)
movl %ecx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x1ad8
callq 0x1b08
callq 0x1b39
movq %r15, %rdi
callq 0x1a77
movq %r15, %rdi
callq 0x1a16
callq 0x1aa7
callq 0x1a46