// File: /workspace/github_c_makefile_star2_O0/goodpaul6[P]generic/script.c
// Function: finalize_type
static void finalize_type(const char* key, void* v_tag, void* data)
{
	type_tag_t* tag = v_tag;
	if(tag->defined && !tag->finalized)
	{
		if(tag->type != TAG_STRUCT) error_exit_c(tag->ctx, "Attempted to use non-struct type in struct '%s'\n", tag->ds.name);
		
		for(int using_index = 0; using_index < tag->ds.using.length; ++using_index)
		{
			type_tag_t* using = vec_get_value(&tag->ds.using, using_index, type_tag_t*);
			
			for(int mem_id = 0; mem_id < using->ds.members.length; ++mem_id)
			{
				type_tag_member_t* mem = vec_get(&using->ds.members, mem_id);
				
				type_tag_member_t mem_copy;
				mem_copy.name = estrdup(mem->name);
				mem_copy.index = mem->index + tag->ds.size;
				mem_copy.type = mem->type;
			
				if(mem->default_value)
				{
					// NOTE: Making a shallow copy of the default_value expression
					mem_copy.default_value = emalloc(sizeof(expr_t));
					memcpy(mem_copy.default_value, mem->default_value, sizeof(expr_t));
					mem_copy.default_value->is_shallow_copy = 1;
				}
				else
					mem_copy.default_value = NULL;
				
				vec_push_back(&tag->ds.members, &mem_copy);
			}
			
			tag->ds.size += using->ds.size;
		}
		
		tag->finalized = 1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x24(%rax), %eax
cmpl $0x0, %eax
je 0x10027
movq -0x20(%rbp), %rax
cmpb $0x0, 0x25(%rax)
jne 0x10027
movq -0x20(%rbp), %rax
cmpl $0xa, 0x20(%rax)
je 0xff04
movq -0x20(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x30(%rcx), %rsi
leaq 0x572e(%rip), %rdi      # 0x15609
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x10030
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x1001f
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
addq $0x18, %rdi
movslq -0x24(%rbp), %rsi
callq 0x11890
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x70(%rcx), %rax
jae 0xfffd
movq -0x30(%rbp), %rdi
addq $0x28, %rdi
addq $0x38, %rdi
movslq -0x34(%rbp), %rsi
callq 0x11890
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x2500
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movslq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
addq 0x38(%rcx), %rax
movl %eax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xffd2
movl $0x60, %edi
callq 0x3580
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rsi
movl $0x60, %edx
callq 0x2180
movq -0x48(%rbp), %rax
movb $0x1, (%rax)
jmp 0xffda
movq $0x0, -0x48(%rbp)
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
addq $0x38, %rdi
leaq -0x60(%rbp), %rsi
callq 0x11960
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xff40
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x20(%rbp), %rax
addq 0x38(%rax), %rcx
movq %rcx, 0x38(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xff0b
movq -0x20(%rbp), %rax
movb $0x1, 0x25(%rax)
addq $0x80, %rsp
popq %rbp
retq