// File: /workspace/github_c_makefile_star2_O0/sisshiki1969[P]monocc/src/codegen.c
// Function: gen_initialize
void gen_initialize(Type *l_ty, int offset, Node *rhs) {
  if (is_array(l_ty) && is_array(type(rhs))) {
    Vector *vec = rhs->nodes;
    Type *ty = l_ty->ptr_to;
    int size = l_ty->array_size;
    for (int i = 0; i < vec_len(vec); i++) {
      if (size <= i) break;
      if (vec->data[i]->kind == ND_INIT) {
        gen_initialize(ty, offset, vec->data[i]);
      } else {
        gen(vec->data[i]);
        fprintf(output, "\tlea  rax, [rbp - %d]\n", offset);
        store(ty);
      }
      offset -= sizeof_type(ty);
    }
  } else if (is_struct(l_ty) && is_struct(type(rhs))) {
    Vector *vec = rhs->nodes;
    MemberInfo *member = l_ty->member;
    for (int i = 0; i < vec_len(vec); i++) {
      if (vec->data[i]->kind == ND_INIT) {
        gen_initialize(member->type, offset - member->offset, vec->data[i]);
      } else {
        gen(vec->data[i]);
        fprintf(output, "\tlea  rax, [rbp - %d]\n", offset - member->offset);
        store(member->type);
      }
      member = member->next;
    }
  } else {
    error_at_node(rhs, "Unsupported initializer.");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0xd370
testb $0x1, %al
jne 0x3555
jmp 0x3650
movq -0x18(%rbp), %rdi
callq 0xdda0
movq %rax, %rdi
callq 0xd370
testb $0x1, %al
jne 0x356f
jmp 0x3650
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
callq 0x4000
movl %eax, %ecx
movl -0x48(%rbp), %eax
cmpl %ecx, %eax
jge 0x364b
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jg 0x35c1
jmp 0x364b
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x3, (%rax)
jne 0x35f2
movq -0x28(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3530
jmp 0x362a
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1b50
leaq 0x11c03(%rip), %rax     # 0x15210
movq (%rax), %rdi
movl -0xc(%rbp), %edx
leaq 0xbd5f(%rip), %rsi      # 0xf379
movb $0x0, %al
callq 0x10f0
movq -0x28(%rbp), %rdi
callq 0x2530
movq -0x28(%rbp), %rdi
callq 0xd640
movl %eax, %ecx
movl -0xc(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xc(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3598
jmp 0x3765
movq -0x8(%rbp), %rdi
callq 0xd3b0
testb $0x1, %al
jne 0x3662
jmp 0x3751
movq -0x18(%rbp), %rdi
callq 0xdda0
movq %rax, %rdi
callq 0xd3b0
testb $0x1, %al
jne 0x367c
jmp 0x3751
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x4000
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jge 0x374f
movq -0x38(%rbp), %rax
movq (%rax), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x3, (%rax)
jne 0x36f3
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0xc(%rbp), %esi
movq -0x40(%rbp), %rax
subl 0x18(%rax), %esi
movq -0x38(%rbp), %rax
movq (%rax), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3530
jmp 0x3736
movq -0x38(%rbp), %rax
movq (%rax), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1b50
leaq 0x11b02(%rip), %rax     # 0x15210
movq (%rax), %rdi
movl -0xc(%rbp), %edx
movq -0x40(%rbp), %rax
subl 0x18(%rax), %edx
leaq 0xbc57(%rip), %rsi      # 0xf379
movb $0x0, %al
callq 0x10f0
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2530
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x369b
jmp 0x3763
movq -0x18(%rbp), %rdi
leaq 0xd0f2(%rip), %rsi      # 0x1084e
movb $0x0, %al
callq 0x6040
jmp 0x3765
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)