// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2a40
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x2a40
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x81b0
movq %rax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x81b0
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x6e90
testb $0x1, %al
jne 0x8f1b
jmp 0x9003
leaq 0x10d2e(%rip), %rax     # 0x19c50
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x105ae(%rip), %rsi     # 0x194f0
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x10589(%rip), %rsi     # 0x194f0
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x107f5(%rip), %rsi     # 0x19770
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x10301(%rip), %rsi     # 0x19290
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x3ee0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x102e8(%rip), %rsi     # 0x192b0
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x102d4(%rip), %rsi     # 0x192b0
callq 0xf2a0
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x7130
movq %rax, -0x10(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x90cd
movq -0x18(%rbp), %rax
movl (%rax), %edi
callq 0x6a50
movl %eax, -0x54(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %edi
callq 0x6a50
movl %eax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %edi
callq 0x6a50
movl %eax, -0x5c(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0x904e
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0x905b
movq -0x18(%rbp), %rax
movl (%rax), %edi
callq 0x6b20
testb $0x1, %al
jne 0x904e
jmp 0x905b
movq -0x30(%rbp), %rdi
callq 0x81f0
movq %rax, -0x30(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0x907a
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0x9087
movq -0x18(%rbp), %rax
movl (%rax), %edi
callq 0x6b20
testb $0x1, %al
jne 0x9087
movq -0x40(%rbp), %rdi
callq 0x81f0
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
leaq 0x10736(%rip), %rsi     # 0x197d0
callq 0xf2a0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xf2a0
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x7130
movq %rax, -0x10(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)