// File: /workspace/github_c_makefile_star2_O2/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, %r15
leaq 0x18(%rsp), %rsi
callq 0x4e1b
testl %eax, %eax
je 0x4b24
movl %eax, %r13d
xorl %eax, %eax
jmp 0x4d0d
movq %rbx, 0x20(%rsp)
pushq $0x8
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x4df8
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, (%r14)
leaq 0x8(%r15), %rax
movq %rax, 0x28(%rsp)
pushq $0x1
popq %rax
xorl %ebx, %ebx
movq %rax, %r12
movq %rax, 0x10(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
movq %r15, 0x30(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rax
movl (%rax), %ecx
movl %ecx, %edx
andl $-0x2, %edx
cmpl $0x16, %edx
jne 0x4ccb
cmpl $0x16, %ecx
jne 0x4bc7
xorl %r15d, %r15d
cmpq 0x8(%rsp), %rbp
jne 0x4c3b
testq %rbp, %rbp
je 0x4c05
leaq (,%rbp,8), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1160
testq %rax, %rax
je 0x4d83
movq %rax, %rbx
leaq (,%rbp,2), %rax
jmp 0x4c36
cmpq 0x8(%rsp), %rbp
jne 0x4bff
testq %rbp, %rbp
je 0x4c1b
leaq (,%rbp,8), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1160
testq %rax, %rax
je 0x4d64
movq %rax, %rbx
leaq (,%rbp,2), %rax
movq %rax, 0x8(%rsp)
pushq $0x1
popq %r15
jmp 0x4c3b
pushq $0x4
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x4dd5
movq %rax, %rbx
jmp 0x4c33
pushq $0x4
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x4db2
movq %rax, %rbx
pushq $0x1
popq %r15
pushq $0x1
popq %rax
movq %rax, 0x8(%rsp)
movl %r15d, (%rbx,%rbp,4)
movq 0x30(%rsp), %r15
movq 0x8(%r15), %rdi
callq 0x297c
movq (%r15), %rdi
movq 0x28(%rsp), %rsi
callq 0x1c9f
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x4e1b
testl %eax, %eax
jne 0x4ce6
cmpq 0x10(%rsp), %r12
jne 0x4cb7
testq %r12, %r12
je 0x4c9b
movq %r12, %r13
shlq $0x4, %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x1160
testq %rax, %rax
je 0x4d22
movq %rax, %r14
leaq (%r12,%r12), %rax
jmp 0x4cb2
pushq $0x8
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x4d41
movq %rax, %r14
pushq $0x1
popq %rax
movq %rax, 0x10(%rsp)
incq %rbp
movq 0x18(%rsp), %rax
movq %rax, (%r14,%r12,8)
incq %r12
jmp 0x4b6e
movq 0x18(%rax), %rcx
movq 0x20(%rax), %r8
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x799f
xorl %r13d, %r13d
jmp 0x4d08
movl %eax, %r13d
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x4cfe
movq (%r14,%rbx,8), %rdi
callq 0x7b5f
incq %rbx
jmp 0x4ceb
movq %r14, %rdi
callq 0x1030
xorl %eax, %eax
movq 0x20(%rsp), %rbx
movq %rax, (%rbx)
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x112c7(%rip), %rax     # 0x15ff0
movq (%rax), %rdi
leaq 0x9bbe(%rip), %rsi      # 0xe8f1
leaq 0x9a8a(%rip), %rdx      # 0xe7c4
movl $0x2c7, %ecx            # imm = 0x2C7
jmp 0x4da0
movq 0x112a8(%rip), %rax     # 0x15ff0
movq (%rax), %rdi
leaq 0x986c(%rip), %rsi      # 0xe5be
leaq 0x9a6b(%rip), %rdx      # 0xe7c4
pushq $0x8
popq %r8
movl $0x2c7, %ecx            # imm = 0x2C7
jmp 0x4da3
movq 0x11285(%rip), %rax     # 0x15ff0
movq (%rax), %rdi
leaq 0x9b7c(%rip), %rsi      # 0xe8f1
leaq 0x9a48(%rip), %rdx      # 0xe7c4
movl $0x2bc, %ecx            # imm = 0x2BC
jmp 0x4da0
movq 0x11266(%rip), %rax     # 0x15ff0
movq (%rax), %rdi
leaq 0x9b5d(%rip), %rsi      # 0xe8f1
leaq 0x9a29(%rip), %rdx      # 0xe7c4
movl $0x2ba, %ecx            # imm = 0x2BA
movq %r13, %r8
xorl %eax, %eax
callq 0x1100
pushq $0x1
popq %rdi
callq 0x1180
movq 0x11237(%rip), %rax     # 0x15ff0
movq (%rax), %rdi
leaq 0x97fb(%rip), %rsi      # 0xe5be
leaq 0x99fa(%rip), %rdx      # 0xe7c4
pushq $0x4
popq %r8
movl $0x2bc, %ecx            # imm = 0x2BC
jmp 0x4da3
movq 0x11214(%rip), %rax     # 0x15ff0
movq (%rax), %rdi
leaq 0x97d8(%rip), %rsi      # 0xe5be
leaq 0x99d7(%rip), %rdx      # 0xe7c4
pushq $0x4
popq %r8
movl $0x2ba, %ecx            # imm = 0x2BA
jmp 0x4da3
movq 0x111f1(%rip), %rax     # 0x15ff0
movq (%rax), %rdi
leaq 0x97b5(%rip), %rsi      # 0xe5be
leaq 0x99b4(%rip), %rdx      # 0xe7c4
pushq $0x8
popq %r8
movl $0x2b6, %ecx            # imm = 0x2B6
jmp 0x4da3