// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %rdi, %rbx
leaq 0x18(%rsp), %rsi
callq 0x7695
testl %eax, %eax
je 0x743b
movl %eax, %r12d
xorl %eax, %eax
jmp 0x7654
movl $0x8, %edi
callq 0x1130
testq %rax, %rax
je 0x7686
movq %rax, %rdi
movq 0x18(%rsp), %rax
movq %rax, (%rdi)
movq 0x8(%rbx), %rax
movl (%rax), %ecx
movl %ecx, %edx
andl $-0x2, %edx
xorl %r12d, %r12d
cmpl $0x16, %edx
jne 0x75fb
movq %r15, 0x20(%rsp)
movq %rbx, 0x30(%rsp)
leaq 0x8(%rbx), %r12
movl $0x1, %r14d
xorl %ebx, %ebx
xorl %ebp, %ebp
xorl %esi, %esi
movq %r12, 0x28(%rsp)
movq %rdi, 0x10(%rsp)
movq %rbp, %r13
cmpl $0x16, %ecx
jne 0x74ca
xorl %r12d, %r12d
cmpq %rbx, %r13
jne 0x7500
testq %rbx, %rbx
je 0x75c2
leaq (,%rbx,8), %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x1160
testq %rax, %rax
jne 0x74fa
jmp 0x7679
movl $0x1, %r12d
cmpq %rbx, %r13
jne 0x7500
testq %rbx, %rbx
je 0x75d6
leaq (,%rbx,8), %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x1160
testq %rax, %rax
je 0x7671
movq %rax, %rsi
addq %rbx, %rbx
movq %rbx, 0x8(%rsp)
leaq 0x1(%r13), %rbp
movq %rsi, %rbx
movl %r12d, (%rsi,%r13,4)
movq 0x30(%rsp), %r15
movq 0x8(%r15), %rdi
callq 0x53ac
movq (%r15), %rdi
movq 0x28(%rsp), %r12
movq %r12, %rsi
callq 0x45d6
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x7695
testl %eax, %eax
jne 0x7604
cmpq %r14, %rbp
jne 0x7592
testq %r14, %r14
je 0x7574
movq %r14, %r15
shlq $0x4, %r15
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x1160
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x7669
addq %r14, %r14
jmp 0x7592
movl $0x8, %edi
callq 0x1130
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x7681
movl $0x1, %r14d
movq %rbx, %rsi
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rbx
movq %rax, 0x8(%rbx,%r13,8)
movq %rbx, %rdi
movq (%r12), %rax
movl (%rax), %ecx
movl %ecx, %edx
andl $-0x2, %edx
cmpl $0x16, %edx
movq 0x8(%rsp), %rbx
je 0x748f
jmp 0x7639
movl $0x4, %edi
callq 0x1130
testq %rax, %rax
jne 0x75e9
jmp 0x768b
movl $0x4, %edi
callq 0x1130
testq %rax, %rax
je 0x7690
movq %rax, %rsi
movl $0x1, %eax
movq %rax, 0x8(%rsp)
jmp 0x7505
movl $0x1, %ebp
xorl %esi, %esi
jmp 0x7644
movl %eax, %r15d
cmpq $-0x1, %r13
movq 0x10(%rsp), %r14
je 0x7625
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
callq 0xa164
incq %rbx
cmpq %rbx, %rbp
jne 0x7614
movq %r14, %rdi
callq 0x1030
xorl %eax, %eax
movl %r15d, %r12d
movq 0x20(%rsp), %r15
jmp 0x7654
incq %rbp
movq 0x20(%rsp), %r15
xorl %r12d, %r12d
movq 0x18(%rax), %rcx
movq 0x20(%rax), %r8
movq %rbp, %rdx
callq 0x9faf
movq %rax, (%r15)
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x1ac5
movq %r15, %rdi
callq 0x1a34
movq %r15, %rdi
callq 0x1a95
callq 0x1af5
callq 0x1b57
callq 0x1b26
callq 0x1a64