// File: /workspace/github_c_makefile_star2_O2/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 0x26ce
movq %rax, %r13
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x26ce
movq %rax, %r14
xorl %edi, %edi
movq %r13, %rsi
callq 0x5b22
movq %rax, %r12
movq %rdx, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x5b22
movq %rdx, %rbp
testb $0x10, (%r12)
jne 0x6444
movq %rbp, (%rsp)
movl (%rbx), %r12d
movl %r12d, %edi
callq 0x4d85
movl %eax, %ebp
movl (%r13), %edi
callq 0x4d85
movl %eax, %r13d
movl (%r14), %edi
callq 0x4d85
movl %eax, %r14d
cmpl %ebp, %r13d
jb 0x641c
jne 0x6427
addl $0xffffbdf0, %r12d      # imm = 0xFFFFBDF0
cmpl $0x1a, %r12d
ja 0x6427
movl $0x7ff0001, %eax        # imm = 0x7FF0001
btl %r12d, %eax
jae 0x6427
movq %r15, %rdi
callq 0x5b29
movq %rax, %r15
cmpl %ebp, %r14d
movq (%rsp), %r14
jae 0x64c0
movq %r14, %rdi
callq 0x5b29
movq %rax, %r14
jmp 0x64e0
leaq 0xc815(%rip), %rdi      # 0x12c60
movq %r15, %rsi
callq 0x9e47
leaq 0xc0a6(%rip), %r14      # 0x12500
movq %rax, %rdi
movq %r14, %rsi
callq 0x9e47
movq %rax, %rdi
movq %rbp, %rsi
callq 0x9e47
movq %rax, %rdi
movq %r14, %rsi
callq 0x9e47
leaq 0xc2fe(%rip), %rsi      # 0x12780
movq %rax, %rdi
callq 0x9e47
leaq 0xbe0f(%rip), %rsi      # 0x122a0
movq %rax, %rdi
callq 0x9e47
movq %rax, %r14
xorl %edi, %edi
movq %r12, %rsi
callq 0x30e4
movq %r14, %rdi
movq %rax, %rsi
callq 0x9e47
leaq 0xbe08(%rip), %r14      # 0x122c0
movq %rax, %rdi
movq %r14, %rsi
jmp 0x64ea
jne 0x64e0
movl $0xffffbdf0, %eax       # imm = 0xFFFFBDF0
addl (%rbx), %eax
cmpl $0x1a, %eax
ja 0x6434
movl $0x7ff0001, %ecx        # imm = 0x7FF0001
btl %eax, %ecx
jae 0x6434
leaq 0xc2f9(%rip), %rsi      # 0x127e0
movq %r15, %rdi
callq 0x9e47
movq %rax, %rdi
movq %r14, %rsi
callq 0x9e47
movq %rax, %r14
xorl %edi, %edi
movq %rbx, %rsi
callq 0x5137
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq