// File: /workspace/github_c_makefile_star2_O3/ryvnf[P]czc/eval.c
// Function: eval_asgn_expr
struct expr eval_asgn_expr(struct ast *ast)
{
    struct ast *lhs_ast = ast_ast(ast, 0);
    struct ast *rhs_ast = ast_ast(ast, 1);
    struct expr lhs_expr = eval_expr(NULL, lhs_ast);
    struct expr rhs_expr = eval_expr(lhs_expr.type, rhs_ast);

    // if lhs is array, generate memcpy instead
    if (is_array_type(lhs_expr.type)) {
        struct rope *rope = memcpy_lparen_rope;
        rope = rope_new_tree(rope, lhs_expr.rope);
        rope = rope_new_tree(rope, comma_sp_rope);
        rope = rope_new_tree(rope, rhs_expr.rope);
        rope = rope_new_tree(rope, comma_sp_rope);
        rope = rope_new_tree(rope, sizeof_sp_rope);
        rope = rope_new_tree(rope, lparen_rope);
        rope = rope_new_tree(rope, type_to_c(NULL, lhs_expr.type));
        rope = rope_new_tree(rope, rparen_rope);
        rope = rope_new_tree(rope, rparen_rope);

        return (struct expr) {
            .rope = rope,
            .type = eval_type(NULL, ast)
        };
    }

    int prec = get_c_prec(ast->tag);
    int lhs_prec = get_c_prec(lhs_ast->tag);
    int rhs_prec = get_c_prec(rhs_ast->tag);

    if (lhs_prec < prec || (lhs_prec == prec && is_rassoc(ast->tag)))
        lhs_expr.rope = add_paren(lhs_expr.rope);

    if (rhs_prec < prec || (rhs_prec == prec && !is_rassoc(ast->tag)))
        rhs_expr.rope = add_paren(rhs_expr.rope);

    struct rope *rope = lhs_expr.rope;
    rope = rope_new_tree(rope, asgn_binop_rope);
    rope = rope_new_tree(rope, rhs_expr.rope);

    return (struct expr) {
        .rope = rope,
        .type = eval_type(NULL, ast)
    };
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %esi, %esi
callq 0x27e8
movq %rax, %r13
movl $0x1, %esi
movq %rbx, %rdi
callq 0x27e8
movq %rax, %r14
xorl %edi, %edi
movq %r13, %rsi
xorl %edx, %edx
callq 0x79f9
movq %rax, %r12
movq %rdx, %r15
movq %rax, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x79f9
movq %rdx, %rbp
testb $0x10, (%r12)
jne 0x6c99
movq %rbp, (%rsp)
movl (%rbx), %r12d
movl %r12d, %edi
callq 0x5349
movl %eax, %ebp
movl (%r13), %edi
callq 0x5349
movl %eax, %r13d
movl (%r14), %edi
callq 0x5349
movl %eax, %r14d
cmpl %ebp, %r13d
jb 0x6c45
jne 0x6c66
leal -0x4220(%r12), %eax
cmpl $0xb, %eax
jae 0x6d5d
leaq 0xc654(%rip), %rdi      # 0x132a0
movq %r15, %rsi
callq 0xaebf
leaq 0xc665(%rip), %rsi      # 0x132c0
movq %rax, %rdi
callq 0xaebf
movq %rax, %r15
cmpl %ebp, %r14d
movq (%rsp), %r14
jae 0x6d15
leaq 0xc626(%rip), %rdi      # 0x132a0
movq %r14, %rsi
callq 0xaebf
leaq 0xc637(%rip), %rsi      # 0x132c0
movq %rax, %rdi
callq 0xaebf
movq %rax, %r14
jmp 0x6d24
leaq 0xcfc0(%rip), %rdi      # 0x13c60
movq %r15, %rsi
callq 0xaebf
leaq 0xc851(%rip), %r14      # 0x13500
movq %rax, %rdi
movq %r14, %rsi
callq 0xaebf
movq %rax, %rdi
movq %rbp, %rsi
callq 0xaebf
movq %rax, %rdi
movq %r14, %rsi
callq 0xaebf
leaq 0xcaa9(%rip), %rsi      # 0x13780
movq %rax, %rdi
callq 0xaebf
leaq 0xc5ba(%rip), %rsi      # 0x132a0
movq %rax, %rdi
callq 0xaebf
movq %rax, %r14
xorl %edi, %edi
movq %r12, %rsi
callq 0x342a
movq %r14, %rdi
movq %rax, %rsi
callq 0xaebf
leaq 0xc5b3(%rip), %r14      # 0x132c0
movq %rax, %rdi
movq %r14, %rsi
jmp 0x6d2e
jne 0x6d24
movl (%rbx), %eax
leal -0x4220(%rax), %ecx
cmpl $0xb, %ecx
jae 0x6d6f
leaq 0xcab5(%rip), %rsi      # 0x137e0
movq %r15, %rdi
callq 0xaebf
movq %rax, %rdi
movq %r14, %rsi
callq 0xaebf
movq %rax, %r14
xorl %edi, %edi
movq %rbx, %rsi
callq 0x578e
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x4210, %r12d          # imm = 0x4210
je 0x6c45
jmp 0x6c66
cmpl $0x4210, %eax           # imm = 0x4210
je 0x6d24
jmp 0x6c73