// File: /workspace/github_c_makefile_star2_O3/ryvnf[P]czc/eval.c
// Function: eval_init_expr
struct expr eval_init_expr(struct type *t, struct ast *ast, bool global_init)
{
    struct type *type = eval_type(t, ast);

    size_t n_childs;
    struct ast **childs = ast_asts(ast, &n_childs);

    struct rope *rope;

    // If this is not part of a global variable initializer, make this
    // initializer a compound expression.
    if (!global_init) {
        rope = lparen_rope;
        rope = rope_new_tree(rope, type_to_c(NULL, t));
        rope = rope_new_tree(rope, rparen_sp_rope);
        rope = rope_new_tree(rope, lcurly_sp_rope);
    } else {
        rope = lcurly_sp_rope;
    }

    if (is_array_type(t)) {
        struct array_type *a_t = array_type(t);

        for (size_t i = 0; i < n_childs; i++) {
            struct expr expr = eval_expr_(a_t->of, childs[i], global_init);
            rope = rope_new_tree(rope, expr.rope);

            if (i != n_childs - 1)
                rope = rope_new_tree(rope, comma_sp_rope);
            else
                rope = rope_new_tree(rope, sp_rope);
        }
    } else if (is_struct_type(t)) {
        struct struct_type *s_t = struct_type(t);

        for (size_t i = 0; i < n_childs; i++) {
            struct expr expr = eval_expr_(s_t->fields[i].type, childs[i], global_init);
            rope = rope_new_tree(rope, expr.rope);

            if (i != n_childs - 1)
                rope = rope_new_tree(rope, comma_sp_rope);
            else
                rope = rope_new_tree(rope, sp_rope);
        }
    }

    rope = rope_new_tree(rope, rcurly_rope);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r12
callq 0x578e
movq %rax, 0x10(%rsp)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x2825
movq %rax, %r14
testl %ebp, %ebp
je 0x78ad
leaq 0xbaf5(%rip), %r15      # 0x133a0
jmp 0x78e7
xorl %edi, %edi
movq %r12, %rsi
callq 0x342a
leaq 0xb9e2(%rip), %rdi      # 0x132a0
movq %rax, %rsi
callq 0xaebf
leaq 0xba33(%rip), %rsi      # 0x13300
movq %rax, %rdi
callq 0xaebf
leaq 0xbac4(%rip), %rsi      # 0x133a0
movq %rax, %rdi
callq 0xaebf
movq %rax, %r15
movl (%r12), %eax
testb $0x10, %al
jne 0x796c
testb $0x40, %al
je 0x79d3
movq %r12, %rdi
callq 0xb9cd
cmpq $0x0, 0x8(%rsp)
je 0x79d3
movq %rax, %r12
addq $0x28, %r12
xorl %r13d, %r13d
movzbl %bpl, %ebp
leaq 0xbbe0(%rip), %rbx      # 0x13500
movq (%r12), %rdi
movq (%r14,%r13,8), %rsi
movl %ebp, %edx
callq 0x79f9
movq %r15, %rdi
movq %rdx, %rsi
callq 0xaebf
movq 0x8(%rsp), %rcx
decq %rcx
movq %rbx, %rsi
cmpq %rcx, %r13
jne 0x7951
leaq 0xbd2f(%rip), %rsi      # 0x13680
movq %rax, %rdi
callq 0xaebf
movq %rax, %r15
incq %r13
addq $0x10, %r12
cmpq 0x8(%rsp), %r13
jb 0x7920
jmp 0x79d3
movq %r12, %rdi
callq 0xb969
cmpq $0x0, 0x8(%rsp)
je 0x79d3
movq %rax, %r12
xorl %ebx, %ebx
movzbl %bpl, %ebp
leaq 0xbb74(%rip), %r13      # 0x13500
movq 0x8(%r12), %rdi
movq (%r14,%rbx,8), %rsi
movl %ebp, %edx
callq 0x79f9
movq %r15, %rdi
movq %rdx, %rsi
callq 0xaebf
movq 0x8(%rsp), %rcx
decq %rcx
movq %r13, %rsi
cmpq %rcx, %rbx
jne 0x79be
leaq 0xbcc2(%rip), %rsi      # 0x13680
movq %rax, %rdi
callq 0xaebf
movq %rax, %r15
incq %rbx
cmpq 0x8(%rsp), %rbx
jb 0x798c
leaq 0xb9e6(%rip), %rsi      # 0x133c0
movq %r15, %rdi
callq 0xaebf
movq %rax, %rdx
movq 0x10(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq