// File: /workspace/github_c_makefile_star2_O1/goodpaul6[P]generic/script.c
// Function: parse_type_tag
static type_tag_t* parse_type_tag(script_t* script)
{
	type_tag_t* tag = get_type_tag_from_name(script, g_lexeme);
	if(!tag) error_exit_p("Invalid type tag '%s'\n", g_lexeme);
	get_next_token();

	switch(tag->type)
	{
		case TAG_FUNC: // parse argument types and return type
		{
			if(g_cur_tok != TOK_OPENPAREN) error_exit_p("Expected '(' after 'func' in type definition but received '%s'\n", g_token_names[g_cur_tok]);
			get_next_token();
			
			while(g_cur_tok != TOK_CLOSEPAREN)
			{
				type_tag_t* arg_tag = parse_type_tag(script);
				vec_push_back(&tag->func.arg_types, &arg_tag);
				if(g_cur_tok == TOK_COMMA) get_next_token();
				else if(g_cur_tok != TOK_CLOSEPAREN) error_exit_p("Expected ')' at the end of function argument list '%s'\n", g_token_names[g_cur_tok]);
			}
			get_next_token();
			
			if(g_cur_tok != TOK_MINUS) error_exit_p("Expected '-' after ')' but received '%s'\n", g_token_names[g_cur_tok]);
			get_next_token();
			
			tag->func.return_type = parse_type_tag(script);
		} break;
		
		case TAG_ARRAY: // parse contained type
		{
			if(g_cur_tok != TOK_MINUS) error_exit_p("Expected '-' after 'array' but received '%s'\n", g_token_names[g_cur_tok]);
			get_next_token();
			
			tag->contained = parse_type_tag(script);
		} break;
		
		default: break;
	}

	return tag;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0xa3d1(%rip), %rsi      # 0x16360
callq 0x8dac
testq %rax, %rax
je 0xc0a0
movq %rax, %r14
xorl %edi, %edi
callq 0xa0ca
movl %eax, 0xa3a3(%rip)      # 0x16350
movl 0x20(%r14), %ecx
cmpl $0x7, %ecx
je 0xc058
cmpl $0x6, %ecx
jne 0xc07c
cmpl $0x19, %eax
jne 0xc0b0
xorl %edi, %edi
callq 0xa0ca
movl %eax, 0xa377(%rip)      # 0x16350
cmpl $0x1a, %eax
je 0xc027
movq %r14, %r15
addq $0x28, %r15
leaq -0x28(%rbp), %r12
movq %rbx, %rdi
callq 0xbf76
movq %rax, -0x28(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf81
movl 0xa34a(%rip), %eax      # 0x16350
cmpq $0x1a, %rax
je 0xc01e
cmpl $0x1f, %eax
jne 0xc08c
xorl %edi, %edi
callq 0xa0ca
movl %eax, 0xa332(%rip)      # 0x16350
cmpl $0x1a, 0xa32b(%rip)     # 0x16350
jne 0xbfe9
xorl %edi, %edi
callq 0xa0ca
movl %eax, 0xa31c(%rip)      # 0x16350
movl $0x48, %r15d
cmpl $0x26, %eax
je 0xc063
movl %eax, %eax
leaq 0x9bf8(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rsi
leaq 0x5043(%rip), %rdi      # 0x11096
jmp 0xc0da
movl $0x28, %r15d
cmpl $0x26, %eax
jne 0xc0c6
xorl %edi, %edi
callq 0xa0ca
movl %eax, 0xa2e0(%rip)      # 0x16350
movq %rbx, %rdi
callq 0xbf76
movq %rax, (%r14,%r15)
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9bad(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rsi
leaq 0x4fc0(%rip), %rdi      # 0x1105e
jmp 0xc0da
leaq 0x4f60(%rip), %rdi      # 0x11007
leaq 0xa2b2(%rip), %rsi      # 0x16360
jmp 0xc0da
movl %eax, %eax
leaq 0x9b87(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rsi
leaq 0x4f5a(%rip), %rdi      # 0x1101e
jmp 0xc0da
movl %eax, %eax
leaq 0x9b71(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rsi
leaq 0x4fe6(%rip), %rdi      # 0x110c0
xorl %eax, %eax
callq 0x88df