// File: /workspace/github_c_makefile_star2_O2/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 0x5137
movq %rax, %rbx
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x270b
movq %rax, %r14
testl %ebp, %ebp
je 0x6f05
leaq 0xb49d(%rip), %r15      # 0x123a0
jmp 0x6f3f
xorl %edi, %edi
movq %r12, %rsi
callq 0x30e4
leaq 0xb38a(%rip), %rdi      # 0x122a0
movq %rax, %rsi
callq 0x9e47
leaq 0xb3db(%rip), %rsi      # 0x12300
movq %rax, %rdi
callq 0x9e47
leaq 0xb46c(%rip), %rsi      # 0x123a0
movq %rax, %rdi
callq 0x9e47
movq %rax, %r15
movl (%r12), %eax
testb $0x10, %al
jne 0x6fc1
testb $0x40, %al
je 0x702c
movq %rbx, 0x10(%rsp)
movq %r12, %rdi
callq 0xa80e
movq %rax, %r12
addq $0x28, %r12
xorl %r13d, %r13d
movzbl %bpl, %ebp
leaq 0xb58f(%rip), %rbx      # 0x12500
cmpq 0x8(%rsp), %r13
jae 0x7027
movq (%r12), %rdi
movq (%r14,%r13,8), %rsi
movl %ebp, %edx
callq 0x7050
movq %r15, %rdi
movq %rdx, %rsi
callq 0x9e47
movq 0x8(%rsp), %rcx
decq %rcx
movq %rbx, %rsi
cmpq %rcx, %r13
jne 0x6fad
leaq 0xb6d3(%rip), %rsi      # 0x12680
movq %rax, %rdi
callq 0x9e47
movq %rax, %r15
incq %r13
addq $0x10, %r12
jmp 0x6f71
movq %rbx, 0x10(%rsp)
movq %r12, %rdi
callq 0xa7aa
movq %rax, %r12
xorl %ebx, %ebx
movzbl %bpl, %ebp
leaq 0xb522(%rip), %r13      # 0x12500
cmpq 0x8(%rsp), %rbx
jae 0x7027
movq 0x8(%r12), %rdi
movq (%r14,%rbx,8), %rsi
movl %ebp, %edx
callq 0x7050
movq %r15, %rdi
movq %rdx, %rsi
callq 0x9e47
movq 0x8(%rsp), %rcx
decq %rcx
movq %r13, %rsi
cmpq %rcx, %rbx
jne 0x7017
leaq 0xb669(%rip), %rsi      # 0x12680
movq %rax, %rdi
callq 0x9e47
movq %rax, %r15
incq %rbx
jmp 0x6fde
movq 0x10(%rsp), %rbx
leaq 0xb38d(%rip), %rsi      # 0x123c0
movq %r15, %rdi
callq 0x9e47
movq %rax, %rdx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq