// File: /workspace/github_c_makefile_star2_O1/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 0x27c8
movq %rax, %r13
movl $0x1, %esi
movq %rbx, %rdi
callq 0x27c8
movq %rax, %r14
xorl %edi, %edi
movq %r13, %rsi
xorl %edx, %edx
callq 0x7a4c
movq %rax, %r12
movq %rdx, %r15
movq %rax, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x7a4c
movq %rdx, %rbp
testb $0x10, (%r12)
jne 0x6cf5
movq %rbp, (%rsp)
movl (%rbx), %r12d
movl %r12d, %edi
callq 0x53b9
movl %eax, %ebp
movl (%r13), %edi
callq 0x53b9
movl %eax, %r13d
movl (%r14), %edi
callq 0x53b9
movl %eax, %r14d
cmpl %ebp, %r13d
jb 0x6ca1
jne 0x6cc2
leal -0x4220(%r12), %eax
cmpl $0xb, %eax
jae 0x6db9
leaq 0xc5f8(%rip), %rdi      # 0x132a0
movq %r15, %rsi
callq 0xb136
leaq 0xc609(%rip), %rsi      # 0x132c0
movq %rax, %rdi
callq 0xb136
movq %rax, %r15
cmpl %ebp, %r14d
movq (%rsp), %r14
jae 0x6d71
leaq 0xc5ca(%rip), %rdi      # 0x132a0
movq %r14, %rsi
callq 0xb136
leaq 0xc5db(%rip), %rsi      # 0x132c0
movq %rax, %rdi
callq 0xb136
movq %rax, %r14
jmp 0x6d80
leaq 0xcf64(%rip), %rdi      # 0x13c60
movq %r15, %rsi
callq 0xb136
leaq 0xc7f5(%rip), %r14      # 0x13500
movq %rax, %rdi
movq %r14, %rsi
callq 0xb136
movq %rax, %rdi
movq %rbp, %rsi
callq 0xb136
movq %rax, %rdi
movq %r14, %rsi
callq 0xb136
leaq 0xca4d(%rip), %rsi      # 0x13780
movq %rax, %rdi
callq 0xb136
leaq 0xc55e(%rip), %rsi      # 0x132a0
movq %rax, %rdi
callq 0xb136
movq %rax, %r14
xorl %edi, %edi
movq %r12, %rsi
callq 0x348a
movq %r14, %rdi
movq %rax, %rsi
callq 0xb136
leaq 0xc557(%rip), %r14      # 0x132c0
movq %rax, %rdi
movq %r14, %rsi
jmp 0x6d8a
jne 0x6d80
movl (%rbx), %eax
leal -0x4220(%rax), %ecx
cmpl $0xb, %ecx
jae 0x6dcb
leaq 0xca59(%rip), %rsi      # 0x137e0
movq %r15, %rdi
callq 0xb136
movq %rax, %rdi
movq %r14, %rsi
callq 0xb136
movq %rax, %r14
xorl %edi, %edi
movq %rbx, %rsi
callq 0x57c4
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 0x6ca1
jmp 0x6cc2
cmpl $0x4210, %eax           # imm = 0x4210
je 0x6d80
jmp 0x6ccf