// File: /workspace/github_c_makefile_star2_O3/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, %r14
leaq 0xa570(%rip), %rsi      # 0x16370
callq 0x8c28
testq %rax, %rax
je 0xbf0a
movq %rax, %rbx
xorl %edi, %edi
callq 0x9eb1
movl %eax, 0xa542(%rip)      # 0x16360
movl 0x20(%rbx), %ecx
cmpl $0x7, %ecx
je 0xbe8c
cmpl $0x6, %ecx
jne 0xbee6
cmpl $0x19, %eax
jne 0xbf1a
xorl %edi, %edi
callq 0x9eb1
movl %eax, 0xa51b(%rip)      # 0x16360
cmpl $0x1a, %eax
je 0xbeb6
movq %rbx, %r15
addq $0x28, %r15
leaq -0x28(%rbp), %r12
movq %r14, %rdi
callq 0xbde7
movq %rax, -0x28(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xdd50
movl 0xa4ee(%rip), %eax      # 0x16360
cmpq $0x1f, %rax
jne 0xbeb1
xorl %edi, %edi
callq 0x9eb1
movl %eax, 0xa4db(%rip)      # 0x16360
cmpl $0x1a, %eax
jne 0xbe55
jmp 0xbeb6
cmpl $0x26, %eax
jne 0xbf30
xorl %edi, %edi
callq 0x9eb1
movl %eax, 0xa4be(%rip)      # 0x16360
movq %r14, %rdi
callq 0xbde7
movl $0x28, %ecx
jmp 0xbee2
cmpl $0x1a, %eax
jne 0xbef6
xorl %edi, %edi
callq 0x9eb1
movl %eax, 0xa49d(%rip)      # 0x16360
cmpl $0x26, %eax
jne 0xbf46
xorl %edi, %edi
callq 0x9eb1
movl %eax, 0xa48b(%rip)      # 0x16360
movq %r14, %rdi
callq 0xbde7
movl $0x48, %ecx
movq %rax, (%rbx,%rcx)
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9d43(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rsi
leaq 0x5156(%rip), %rdi      # 0x1105e
jmp 0xbf5a
leaq 0x50f6(%rip), %rdi      # 0x11007
leaq 0xa458(%rip), %rsi      # 0x16370
jmp 0xbf5a
movl %eax, %eax
leaq 0x9d1d(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rsi
leaq 0x50f0(%rip), %rdi      # 0x1101e
jmp 0xbf5a
movl %eax, %eax
leaq 0x9d07(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rsi
leaq 0x517c(%rip), %rdi      # 0x110c0
jmp 0xbf5a
movl %eax, %eax
leaq 0x9cf1(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rsi
leaq 0x513c(%rip), %rdi      # 0x11096
xorl %eax, %eax
callq 0x878e