// File: /workspace/github_c_makefile_star2_O1/goodpaul6[P]generic/script.c
// Function: resolve_type_tags
static void resolve_type_tags(script_t* script, void* vexp)
{
	expr_t* exp = vexp;
	
	// NOTE: Pathetic attempt at providing proper
	// line information for type warnings
	g_file = exp->ctx.file;
	g_line = exp->ctx.line;
	
	switch(exp->type)
	{
		case EXP_ATOMIC:
		{
			exp->tag = create_type_tag(script, TAG_VOID);
			resolve_type_tags(script, exp->atomx);
		} break;

		case EXP_DOT: case EXP_COLON:
		{
			resolve_type_tags(script, exp->dotx.value);
			if (exp->dotx.value->tag->type != TAG_STRUCT)
				error_defer_e(exp->dotx.value, "Attempted to access members in non-struct type\n");
			else
			{
				char found = 0;

				type_tag_t* tag = exp->dotx.value->tag;
				for (int i = 0; i < tag->ds.members.length; ++i)
				{
					type_tag_member_t* mem = vec_get(&tag->ds.members, i);
					if (strcmp(mem->name, exp->dotx.name) == 0)
					{
						exp->tag = mem->type;
						found = 1;

						if (exp->type == EXP_COLON) error_defer_e(exp, "Attempted to use ':' operator to access member value; use '.' instead\n");
						break;
					}
				}

				if (!found)
				{
					func_decl_t* decl = get_struct_member_function(script, exp->dotx.value->tag->ds.name, exp->dotx.name);
					if (decl) found = 1;
					if (exp->type == EXP_DOT) error_defer_e(exp, "Attempted to use '.' operator to access member function; use ':' instead\n");

					if (!found)
						error_exit_e(exp, "Attempted to access non-existent member '%s' in struct %s\n", exp->dotx.name, tag->ds.name);
					else
						exp->tag = decl->tag;
				}
			}
		} break;
		
		case EXP_NULL:
		{
			exp->tag = create_type_tag(script, TAG_DYNAMIC);
		} break;
		
		case EXP_STRUCT_DECL:
		{
			exp->tag = create_type_tag(script, TAG_VOID);
			
			for(int i = 0; i < exp->struct_tag->ds.members.length; ++i)
			{
				type_tag_member_t* mem = vec_get(&exp->struct_tag->ds.members, i);
				if(mem->default_value)
				{	
					resolve_type_tags(script, mem->default_value);
					if(!compare_type_tags(mem->type, mem->default_value->tag))
						error_defer_e(mem->default_value, "Type of default value does not match type of member variable '%s'\n", mem->name);
				}
			}
		} break;
		
		case EXP_STRUCT_NEW:
		{
			exp->tag = exp->newx.type;
			
			for(int i = 0; i < exp->newx.init.length; ++i)
			{
				expr_t* init = vec_get_value(&exp->newx.init, i, expr_t*);
				
				int member_index = get_struct_type_member_index(exp->newx.type, init->binx.lhs->varx.name);
				resolve_type_tags(script, init->binx.rhs);
					
				type_tag_member_t* mem = vec_get(&exp->newx.type->ds.members, member_index);
				if(!compare_type_tags(init->binx.rhs->tag, mem->type))
					error_defer_e(init->binx.rhs, "Type of initializer does not match type of member '%s' being initialized\n", mem->name);
			}
		} break;
			
		case EXP_NUMBER:
		{
			exp->tag = create_type_tag(script, TAG_NUMBER);
		} break;
		
		case EXP_STRING:
		{
			exp->tag = create_type_tag(script, TAG_STRING);
		} break;
		
		case EXP_BOOL:
		{
			exp->tag = create_type_tag(script, TAG_BOOL);
		} break;
		
		case EXP_CHAR:
		{
			exp->tag = create_type_tag(script, TAG_CHAR);
		} break;
		
		case EXP_VAR:
		{
			if(!exp->varx.decl)
			{
				func_decl_t* decl = reference_function(script, exp->varx.name);
				if(decl) exp->tag = decl->tag;
				else error_exit_e(exp, "Referencing undeclared function/variable '%s'\n", exp->varx.name); 
			}
			else
				exp->tag = exp->varx.decl->tag;
		} break;
		
		case EXP_WRITE:
		{
			exp->tag = create_type_tag(script, TAG_VOID);
			resolve_type_tags(script, exp->write);
		} break;
		
		case EXP_UNARY:
		{
			resolve_type_tags(script, exp->unaryx.rhs);
			switch(exp->unaryx.op)
			{
				case TOK_NOT:
				{
					if(exp->unaryx.rhs->tag->type != TAG_BOOL)
						error_defer_e(exp->unaryx.rhs, "Attempted to use unary ! operator on non-boolean value\n");
					exp->tag = create_type_tag(script, TAG_BOOL);
				} break;
				
				case TOK_MINUS:
				{
					if(exp->unaryx.rhs->tag->type != TAG_NUMBER)
						error_defer_e(exp->unaryx.rhs, "Attempted to use unary - operator on non-numerical value\n");
					exp->tag = create_type_tag(script, TAG_NUMBER);
				} break;
				
				default:
					error_exit_e(exp, "No type resolution for %s operator\n", g_token_names[exp->unaryx.op]);
					break;
			}
		} break;
		
		case EXP_BINARY:
		{
			resolve_type_tags(script, exp->binx.lhs);
			resolve_type_tags(script, exp->binx.rhs);
		
			// NOTE: assignment operation lhs does not need to be
			// number
			if(exp->binx.op != TOK_ASSIGN)
			{ 
				if(!compare_type_tags(exp->binx.lhs->tag, exp->binx.rhs->tag) || !is_type_tag(exp->binx.lhs->tag, TAG_NUMBER))
				{	
					if(exp->binx.op != TOK_EQUALS && exp->binx.op != TOK_NOTEQUAL && 
						exp->binx.op != TOK_LAND && exp->binx.op != TOK_LOR)
						error_defer_e(exp->binx.lhs, "Invalid types in binary %s operation\n", g_token_names[exp->binx.op]);
				}
			}
			else
			{
				// NOTE: If the type of the lhs is unknown, set it to the type of the rhs
				// (since this is an assignment, after all)
				if (exp->binx.lhs->tag->type == TAG_UNKNOWN)
				{
					exp->binx.lhs->tag = exp->binx.rhs->tag;

					var_decl_t* decl = get_root_var_decl(exp->binx.lhs);
					if(decl)
						decl->tag = exp->binx.lhs->tag;
				}
				else if (!are_assignment_types_valid(exp->binx.lhs, exp->binx.rhs))
					error_defer_e(exp->binx.lhs, "Type of lhs in assignment operation does not match the type of rhs\n");
			}

			switch(exp->binx.op)
			{
				case TOK_PLUS:
				case TOK_MINUS:
				case TOK_MUL:
				case TOK_DIV: 
				case TOK_MOD: exp->tag = create_type_tag(script, TAG_NUMBER); break;
				
				case TOK_LTE:
				case TOK_GTE:
				case TOK_LT:
				case TOK_GT:
				case TOK_EQUALS:
				case TOK_NOTEQUAL:
				case TOK_LAND:
				case TOK_LOR: exp->tag = create_type_tag(script, TAG_BOOL); break;
				
				default: exp->tag = create_type_tag(script, TAG_VOID); break;
			}
		} break;
		
		case EXP_CALL:
		{
			resolve_type_tags(script, exp->callx.func);
			if(exp->callx.func->tag->type == TAG_DYNAMIC)
				warn_e(exp, WARN_CALL_DYNAMIC);
			
			if(exp->callx.func->tag->type != TAG_FUNC && exp->callx.func->tag->type != TAG_DYNAMIC)
				error_defer_e(exp, "Attempting to call something that is not a function\n");
			
			if(exp->callx.func->tag->type != TAG_DYNAMIC && exp->callx.args.length != exp->callx.func->tag->func.arg_types.length)
				error_defer_e(exp, "Passed %d argument(s) into function expecting %d argument(s)\n", 
				exp->callx.args.length, exp->callx.func->tag->func.arg_types.length);
			else
			{
				for(int i = 0; i < exp->callx.args.length; ++i)
				{
					expr_t* arg = vec_get_value(&exp->callx.args, i, expr_t*);
					resolve_type_tags(script, arg);
					
					if(exp->callx.func->tag->type != TAG_DYNAMIC)
					{
						type_tag_t* expected_tag = vec_get_value(&exp->callx.func->tag->func.arg_types, i, type_tag_t*);
						if(!compare_type_tags(arg->tag, expected_tag)) 
							error_defer_e(arg, "Type of argument %i does not match expected type\n", i + 1);
					}
				}
			}
			
			exp->tag = exp->callx.func->tag->func.return_type;
		} break;
		
		case EXP_PAREN:
		{
			resolve_type_tags(script, exp->paren);
			exp->tag = exp->paren->tag;
		} break;
		
		case EXP_BLOCK:
		{
			exp->tag = create_type_tag(script, TAG_VOID);
			for(int i = 0; i < exp->block.length; ++i)
			{
				expr_t* e = vec_get_value(&exp->block, i, expr_t*);
				resolve_type_tags(script, e);
			}
		} break;
		
		case EXP_ARRAY_INDEX:
		{
			resolve_type_tags(script, exp->array_index.array);
			resolve_type_tags(script, exp->array_index.index);

			if(!is_type_tag(exp->array_index.index->tag, TAG_NUMBER))
				error_defer_e(exp->array_index.index, "Attempting to index array with non-number value\n");
			
			switch(exp->array_index.array->tag->type)
			{
				case TAG_STRING: exp->tag = create_type_tag(script, TAG_CHAR); break;
				case TAG_ARRAY: exp->tag = exp->array_index.array->tag->contained; break;
				default:
					error_defer_e(exp->array_index.array, "Attempting to index non-indexable type\n");
					break;
			}
		} break;
		
		case EXP_EXTERN:
		case EXP_EXTERN_LIST: break;
		
		case EXP_ARRAY_LITERAL:
		{
			for(int i = 0; i < exp->array_literal.values.length; ++i)
				resolve_type_tags(script, vec_get_value(&exp->array_literal.values, i, expr_t*));
			
			type_tag_t* tag = create_type_tag(script, TAG_ARRAY);
			if(exp->array_literal.contained) tag->contained = exp->array_literal.contained;
			else
			{
				expr_t* first = vec_get_value(&exp->array_literal.values, 0, expr_t*);
				tag->contained = first->tag;
				
				for(int i = 1; i < exp->array_literal.values.length; ++i)
				{
					expr_t* e = vec_get_value(&exp->array_literal.values, i, expr_t*);
					if(!compare_type_tags(e->tag, tag->contained))
					{
						warn_e(e, WARN_DYNAMIC_ARRAY_LITERAL);
						tag = create_type_tag(script, TAG_DYNAMIC);			// NOTE: okay, so it must be a dynamic literal
						break;										// NOTE: also, we don't care about the types anymore
					}
					// error_defer_e(e, "Array literal value type does not match the array's contained type\n");
				}
			}
			
			exp->tag = tag;
		} break;
		
		case EXP_LEN:
		{
			exp->tag = create_type_tag(script, TAG_NUMBER);
			resolve_type_tags(script, exp->len);
			
			if(exp->len->tag->type != TAG_STRING && exp->len->tag->type != TAG_ARRAY)
				error_defer_e(exp->len, "Attempted to find the length of non-measurable type\n");
		} break;
		
		case EXP_IF:
		{
			exp->tag = create_type_tag(script, TAG_VOID);
			resolve_type_tags(script, exp->ifx.cond);
			
			if(!is_type_tag(exp->ifx.cond->tag, TAG_BOOL))
				error_defer_e(exp->ifx.cond, "Condition does not evaluate to a boolean value\n");
			
			resolve_type_tags(script, exp->ifx.body);
			if(exp->ifx.alt)
				resolve_type_tags(script, exp->ifx.alt);
		} break;
		
		case EXP_WHILE:
		{
			exp->tag = create_type_tag(script, TAG_VOID);
			resolve_type_tags(script, exp->whilex.cond);
			
			if(!is_type_tag(exp->whilex.cond->tag, TAG_BOOL)) 
				error_defer_e(exp->whilex.cond, "Condition does not evaluate to a boolean value\n");
			
			resolve_type_tags(script, exp->whilex.body);
		} break;

		case EXP_FOR:
		{
			exp->tag = create_type_tag(script, TAG_VOID);

			resolve_type_tags(script, exp->forx.init);
			resolve_type_tags(script, exp->forx.cond);
			resolve_type_tags(script, exp->forx.step);

			if (!is_type_tag(exp->forx.cond->tag, TAG_BOOL))
				error_defer_e(exp->forx.cond, "Condition does not evaluate to a boolean value\n");

			resolve_type_tags(script, exp->forx.body);
		} break;
		
		case EXP_RETURN:
		{
			exp->tag = create_type_tag(script, TAG_VOID);
			resolve_type_tags(script, exp->retx.value);
	
			if(!compare_type_tags(exp->retx.value->tag, exp->retx.parent->tag->func.return_type))
				error_defer_e(exp, "Returned value's type does not match the return type of the enclosing function.\n");
		} break;
		
		case EXP_FUNC:
		{
			exp->tag = create_type_tag(script, TAG_VOID);
			resolve_type_tags(script, exp->funcx.body);
		} break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x63e6(%rip), %r15      # 0xf304
movq 0x10(%rbx), %rax
movq %rax, 0xd227(%rip)      # 0x16150
movl 0x8(%rbx), %eax
movl %eax, 0xd216(%rip)      # 0x16148
movl 0x28(%rbx), %eax
cmpq $0x1a, %rax
ja 0x9726
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq %r14, %rdi
xorl %esi, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
movq 0x38(%rbx), %rbx
jmp 0x8f1e
movq %r14, %rdi
xorl %esi, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
jmp 0x8fe9
movq %r14, %rdi
xorl %esi, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x40(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x48(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x40(%rbx), %rdi
movq 0x30(%rdi), %rax
movl 0x20(%rax), %eax
decl %eax
cmpl $0x2, %eax
jae 0x903c
movq 0x50(%rbx), %rbx
jmp 0x8f1e
movq %r14, %rdi
xorl %esi, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x38(%rbx), %rdi
movq 0x30(%rdi), %rax
movl 0x20(%rax), %eax
decl %eax
cmpl $0x2, %eax
jae 0x904f
movq 0x40(%rbx), %rbx
jmp 0x8f1e
movq %r14, %rdi
xorl %esi, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x38(%rbx), %rdi
movq 0x30(%rdi), %rax
movl 0x20(%rax), %eax
decl %eax
cmpl $0x2, %eax
jae 0x905f
movq 0x40(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x48(%rbx), %rbx
testq %rbx, %rbx
jne 0x8f1e
jmp 0x9726
leaq 0x7b43(%rip), %rsi      # 0x10b86
xorl %eax, %eax
callq 0x22a3
jmp 0x8fb4
leaq 0x7b30(%rip), %rsi      # 0x10b86
xorl %eax, %eax
callq 0x22a3
jmp 0x8fe9
leaq 0x7b20(%rip), %rsi      # 0x10b86
xorl %eax, %eax
callq 0x22a3
jmp 0x901e
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x38(%rbx), %rdi
movq 0x30(%rdi), %r15
cmpl $0xa, 0x20(%r15)
jne 0x9735
cmpq $0x0, 0x70(%r15)
je 0x911d
movq %r14, -0x40(%rbp)
leaq 0x60(%r15), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
xorl %r13d, %r13d
movq %r15, %r14
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0xdf24
movq %rax, %r15
movq (%rax), %rdi
movq 0x40(%rbx), %rsi
callq 0x2150
movl %eax, %r12d
testl %eax, %eax
jne 0x90e9
movq 0x10(%r15), %rax
movq %rax, 0x30(%rbx)
movb $0x1, %al
movq %rax, -0x38(%rbp)
cmpl $0x3, 0x28(%rbx)
je 0x90fc
testl %r12d, %r12d
movq %r14, %r15
je 0x910f
incq %r13
cmpq %r13, 0x70(%r15)
ja 0x90b0
jmp 0x910f
movq %rbx, %rdi
leaq 0x76c5(%rip), %rsi      # 0x107cb
xorl %eax, %eax
callq 0x22a3
jmp 0x90e9
cmpb $0x0, -0x38(%rbp)
movq -0x40(%rbp), %r14
jne 0x9726
movq 0x38(%rbx), %rax
movq 0x40(%rbx), %rdx
movq 0x30(%rax), %rax
movq 0x30(%rax), %rsi
movq %r14, %rdi
callq 0x9825
movq %rax, %r14
cmpl $0x4, 0x28(%rbx)
je 0x974f
testq %r14, %r14
je 0x97e3
movq 0x10(%r14), %rax
jmp 0x9722
leaq 0x40(%rbx), %r15
cmpq $0x0, 0x50(%rbx)
je 0x9181
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %r14, %rdi
callq 0x8f00
incq %r12
cmpq %r12, 0x50(%rbx)
ja 0x9162
movq %r14, %rdi
movl $0x7, %esi
callq 0x816f
movq %rax, %r12
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x964c
movq %rax, 0x28(%r12)
jmp 0x9742
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x40(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
cmpl $0x24, 0x48(%rbx)
movq 0x38(%rbx), %rax
movq 0x30(%rax), %rdi
jne 0x95be
cmpl $0xb, 0x20(%rdi)
movq 0x40(%rbx), %rcx
movq 0x30(%rcx), %rsi
jne 0x96eb
movq %rsi, 0x30(%rax)
movq 0x38(%rbx), %r15
movq %r15, %rdi
callq 0x9a35
testq %rax, %rax
je 0x96f8
movq 0x30(%r15), %rcx
movq %rcx, 0x8(%rax)
jmp 0x96f8
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x38(%rbx), %rax
movq 0x30(%rax), %rax
jmp 0x9722
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movslq 0x40(%rbx), %rax
cmpq $0x26, %rax
je 0x961e
cmpl $0x23, %eax
jne 0x97fc
movq 0x38(%rbx), %rdi
movq 0x30(%rdi), %rax
cmpl $0x2, 0x20(%rax)
je 0x9703
leaq 0x76f4(%rip), %rsi      # 0x10953
xorl %eax, %eax
callq 0x22a3
jmp 0x9703
movq 0x38(%rbx), %rax
movq %rax, 0x30(%rbx)
cmpq $0x0, 0x50(%rbx)
je 0x9726
leaq 0x40(%rbx), %rax
movq %rax, -0x30(%rbp)
xorl %r13d, %r13d
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0xdf24
movq (%rax), %r15
movq 0x38(%rbx), %rdi
movq 0x38(%r15), %rax
movq 0x38(%rax), %rsi
callq 0x99bc
movl %eax, %r12d
movq 0x40(%r15), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x38(%rbx), %rdi
addq $0x60, %rdi
movslq %r12d, %rsi
callq 0xdf24
movq %rax, %r12
movq 0x40(%r15), %rax
movq 0x30(%rax), %rdi
movq 0x10(%r12), %rsi
callq 0x8269
testb %al, %al
je 0x92ef
incq %r13
cmpq %r13, 0x50(%rbx)
ja 0x9289
jmp 0x9726
movq 0x40(%r15), %rdi
movq (%r12), %rdx
leaq 0x75dc(%rip), %rsi      # 0x108da
xorl %eax, %eax
callq 0x22a3
jmp 0x92e1
movq %r14, %rdi
movl $0x1, %esi
jmp 0x971d
movq %r14, %rdi
movl $0x5, %esi
jmp 0x971d
movq %r14, %rdi
xorl %esi, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
movq 0x38(%rbx), %rdi
cmpq $0x0, 0x70(%rdi)
je 0x9726
leaq 0x7552(%rip), %r15      # 0x10897
xorl %r12d, %r12d
addq $0x60, %rdi
movq %r12, %rsi
callq 0xdf24
movq 0x18(%rax), %rsi
testq %rsi, %rsi
je 0x937d
movq %rax, %r13
movq %r14, %rdi
callq 0x8f00
movq 0x10(%r13), %rdi
movq 0x18(%r13), %rax
movq 0x30(%rax), %rsi
callq 0x8269
testb %al, %al
je 0x938f
incq %r12
movq 0x38(%rbx), %rdi
cmpq %r12, 0x70(%rdi)
ja 0x9348
jmp 0x9726
movq (%r13), %rdx
movq 0x18(%r13), %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x22a3
jmp 0x937d
movq %r14, %rdi
xorl %esi, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
cmpq $0x0, 0x48(%rbx)
je 0x9726
leaq 0x38(%rbx), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %r14, %rdi
callq 0x8f00
incq %r12
cmpq %r12, 0x48(%rbx)
ja 0x93c3
jmp 0x9726
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x40(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x40(%rbx), %rdi
movq 0x30(%rdi), %rax
movl 0x20(%rax), %eax
cmpl $0x1, %eax
je 0x9418
cmpl $0x4, %eax
jne 0x9765
movq 0x38(%rbx), %rdi
movq 0x30(%rdi), %rax
movl 0x20(%rax), %ecx
cmpl $0x7, %ecx
je 0x9643
cmpl $0x5, %ecx
jne 0x9778
movq %r14, %rdi
movl $0x3, %esi
jmp 0x971d
movq 0x40(%rbx), %rax
testq %rax, %rax
je 0x96d0
movq 0x8(%rax), %rax
jmp 0x9722
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x38(%rbx), %rax
movq 0x30(%rax), %rax
cmpl $0x1, 0x20(%rax)
jne 0x9481
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x9a5b
movq 0x38(%rbx), %rax
movq 0x30(%rax), %rax
movl 0x20(%rax), %eax
cmpl $0x1, %eax
je 0x949a
cmpl $0x6, %eax
jne 0x9794
movq 0x38(%rbx), %rax
movq 0x30(%rax), %rax
cmpl $0x1, 0x20(%rax)
je 0x94b9
movq 0x50(%rbx), %rdx
movq 0x38(%rax), %rcx
cmpq %rcx, %rdx
jne 0x97aa
cmpq $0x0, 0x50(%rbx)
je 0x97bb
leaq 0x40(%rbx), %r15
xorl %r13d, %r13d
movq %r15, %rdi
movq %r13, %rsi
callq 0xdf24
movq (%rax), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x8f00
movq 0x38(%rbx), %rax
movq 0x30(%rax), %rdi
cmpl $0x1, 0x20(%rdi)
je 0x950f
addq $0x28, %rdi
movq %r13, %rsi
callq 0xdf24
movq (%rax), %rsi
movq 0x30(%r12), %rdi
callq 0x8269
testb %al, %al
je 0x951d
incq %r13
cmpq %r13, 0x50(%rbx)
ja 0x94cb
jmp 0x97bb
leal 0x1(%r13), %edx
movq %r12, %rdi
leaq 0x759b(%rip), %rsi      # 0x10ac6
xorl %eax, %eax
callq 0x22a3
jmp 0x950f
movq %r14, %rdi
movl $0x4, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x38(%rbx), %rdi
movq 0x30(%rdi), %rax
movl 0x20(%rax), %eax
orl $0x2, %eax
cmpl $0x7, %eax
je 0x9726
leaq 0x75e2(%rip), %rsi      # 0x10b51
jmp 0x977f
movq %r14, %rdi
xorl %esi, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
movq 0x40(%rbx), %rsi
movq %r14, %rdi
callq 0x8f00
movq 0x38(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x30(%rcx), %rdi
movq 0x10(%rax), %rax
movq 0x48(%rax), %rsi
callq 0x8269
testb %al, %al
jne 0x9726
leaq 0x7600(%rip), %rsi      # 0x10bb6
movq %rbx, %rdi
jmp 0x977f
movq 0x40(%rbx), %rax
movq 0x30(%rax), %rsi
callq 0x8269
testb %al, %al
je 0x95ec
movq 0x38(%rbx), %rax
movq 0x30(%rax), %rax
movl 0x20(%rax), %eax
cmpl $0x1, %eax
je 0x96f8
cmpl $0x4, %eax
je 0x96f8
movslq 0x48(%rbx), %rax
leal -0x2e(%rax), %ecx
cmpl $0x4, %ecx
jb 0x96f8
movq 0x38(%rbx), %rdi
leaq 0xc639(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rdx
leaq 0x73d7(%rip), %rsi      # 0x109e9
xorl %eax, %eax
callq 0x22a3
jmp 0x96f8
movq 0x38(%rbx), %rdi
movq 0x30(%rdi), %rax
cmpl $0x4, 0x20(%rax)
je 0x9715
leaq 0x7354(%rip), %rsi      # 0x1098b
xorl %eax, %eax
callq 0x22a3
jmp 0x9715
movq 0x28(%rax), %rax
jmp 0x9722
movq %r15, %rdi
xorl %esi, %esi
callq 0xdf24
movq (%rax), %rax
movq 0x30(%rax), %rax
movq %rax, 0x28(%r12)
cmpq $0x2, 0x50(%rbx)
jb 0x9742
movl $0x1, %r13d
movq %r15, %rdi
movq %r13, %rsi
callq 0xdf24
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq 0x30(%rax), %rdi
movq %r12, -0x30(%rbp)
movq 0x28(%r12), %rsi
callq 0x8269
movl %eax, %r12d
testb %al, %al
jne 0x96bc
movq -0x38(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x9a5b
movq %r14, %rdi
movl $0x1, %esi
callq 0x816f
movq %rax, -0x30(%rbp)
testb %r12b, %r12b
je 0x973e
incq %r13
cmpq %r13, 0x50(%rbx)
movq -0x30(%rbp), %r12
ja 0x9673
jmp 0x9742
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x84c0
testq %rax, %rax
je 0x9810
movq 0x10(%rax), %rax
jmp 0x9722
callq 0x8269
testb %al, %al
je 0x97cc
movl 0x48(%rbx), %eax
leal -0x2a(%rax), %ecx
cmpl $0x8, %ecx
jae 0x970d
movq %r14, %rdi
movl $0x2, %esi
jmp 0x971d
addl $-0x25, %eax
cmpl $0x4, %eax
ja 0x9748
movq %r14, %rdi
movl $0x4, %esi
callq 0x816f
movq %rax, 0x30(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x705f(%rip), %rsi      # 0x1079b
jmp 0x977f
movq -0x30(%rbp), %r12
movq %r12, 0x30(%rbx)
jmp 0x9726
movq %r14, %rdi
xorl %esi, %esi
jmp 0x971d
leaq 0x70bc(%rip), %rsi      # 0x10812
movq %rbx, %rdi
xorl %eax, %eax
callq 0x22a3
jmp 0x9142
leaq 0x738c(%rip), %rsi      # 0x10af8
xorl %eax, %eax
callq 0x22a3
jmp 0x9418
leaq 0x73aa(%rip), %rsi      # 0x10b29
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22a3
leaq 0x72b8(%rip), %rsi      # 0x10a53
movq %rbx, %rdi
xorl %eax, %eax
callq 0x22a3
jmp 0x949a
leaq 0x72d7(%rip), %rsi      # 0x10a88
movq %rbx, %rdi
xorl %eax, %eax
callq 0x22a3
movq 0x38(%rbx), %rax
movq 0x30(%rax), %rax
movq 0x48(%rax), %rax
jmp 0x9722
movq 0x38(%rbx), %rdi
leaq 0x7238(%rip), %rsi      # 0x10a0f
xorl %eax, %eax
callq 0x22a3
jmp 0x96f8
movq 0x40(%rbx), %rdx
movq 0x30(%r15), %rcx
leaq 0x706a(%rip), %rsi      # 0x1085c
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9911
leaq 0xc43d(%rip), %rcx      # 0x15c40
movq (%rcx,%rax,8), %rdx
leaq 0x71b7(%rip), %rsi      # 0x109c5
jmp 0x981b
movq 0x38(%rbx), %rdx
leaq 0x7109(%rip), %rsi      # 0x10924
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9911