// File: /workspace/github_c_makefile_star2_O1/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 0x57c4
movq %rax, 0x10(%rsp)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x2805
movq %rax, %r14
testl %ebp, %ebp
je 0x7900
leaq 0xbaa2(%rip), %r15      # 0x133a0
jmp 0x793a
xorl %edi, %edi
movq %r12, %rsi
callq 0x348a
leaq 0xb98f(%rip), %rdi      # 0x132a0
movq %rax, %rsi
callq 0xb136
leaq 0xb9e0(%rip), %rsi      # 0x13300
movq %rax, %rdi
callq 0xb136
leaq 0xba71(%rip), %rsi      # 0x133a0
movq %rax, %rdi
callq 0xb136
movq %rax, %r15
movl (%r12), %eax
testb $0x10, %al
jne 0x79bf
testb $0x40, %al
je 0x7a26
movq %r12, %rdi
callq 0xbc3d
cmpq $0x0, 0x8(%rsp)
je 0x7a26
movq %rax, %r12
addq $0x28, %r12
xorl %r13d, %r13d
movzbl %bpl, %ebp
leaq 0xbb8d(%rip), %rbx      # 0x13500
movq (%r12), %rdi
movq (%r14,%r13,8), %rsi
movl %ebp, %edx
callq 0x7a4c
movq %r15, %rdi
movq %rdx, %rsi
callq 0xb136
movq 0x8(%rsp), %rcx
decq %rcx
movq %rbx, %rsi
cmpq %rcx, %r13
jne 0x79a4
leaq 0xbcdc(%rip), %rsi      # 0x13680
movq %rax, %rdi
callq 0xb136
movq %rax, %r15
incq %r13
addq $0x10, %r12
cmpq 0x8(%rsp), %r13
jb 0x7973
jmp 0x7a26
movq %r12, %rdi
callq 0xbbd9
cmpq $0x0, 0x8(%rsp)
je 0x7a26
movq %rax, %r12
xorl %ebx, %ebx
movzbl %bpl, %ebp
leaq 0xbb21(%rip), %r13      # 0x13500
movq 0x8(%r12), %rdi
movq (%r14,%rbx,8), %rsi
movl %ebp, %edx
callq 0x7a4c
movq %r15, %rdi
movq %rdx, %rsi
callq 0xb136
movq 0x8(%rsp), %rcx
decq %rcx
movq %r13, %rsi
cmpq %rcx, %rbx
jne 0x7a11
leaq 0xbc6f(%rip), %rsi      # 0x13680
movq %rax, %rdi
callq 0xb136
movq %rax, %r15
incq %rbx
cmpq 0x8(%rsp), %rbx
jb 0x79df
leaq 0xb993(%rip), %rsi      # 0x133c0
movq %r15, %rdi
callq 0xb136
movq %rax, %rdx
movq 0x10(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq