// File: /workspace/github_c_makefile_star2_O2/mirth-lang[P]mirth/bin/mirth1.c
// Function: mw_mirth_type_Type_applyzesubst
static struct mirth_type_Type mw_mirth_type_Type_applyzesubst (struct mirth_mirth_zaMirth* in_zaMirth_1, struct std_list_List_1 in_Subst_2, struct mirth_type_Type in_Type_3, struct mirth_mirth_zaMirth* *out_zaMirth_4, struct std_list_List_1 *out_Subst_5) {
	struct mirth_mirth_zaMirth* branch_zaMirth_7;
	struct std_list_List_1 branch_Subst_8;
	struct mirth_type_Type branch_Type_9;
	switch ((in_Type_3).tag) {
		case mirth_type_Type_Error: {
			struct mirth_type_Type v10 = { .tag=mirth_type_Type_Error };
			branch_Type_9 = v10;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_Type_Ignore: {
			struct mirth_type_Type v11 = { .tag=mirth_type_Type_Ignore };
			branch_Type_9 = v11;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_Type_Prim: {
			enum mirth_type_PrimType v12 = mtp_mirth_type_Type_Prim(in_Type_3);
			struct mirth_type_Type v13 = mtw_mirth_type_Type_Prim(v12);
			branch_Type_9 = v13;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_Type_Meta: {
			uint64_t v14 = mtp_mirth_type_Type_Meta(in_Type_3);
			struct mirth_mirth_zaMirth* v15;
			struct std_maybe_Maybe_1 v16 = mw_mirth_type_MetaVar_typezy(in_zaMirth_1, v14, &v15);
			struct std_list_List_1 branch_Subst_17;
			struct mirth_mirth_zaMirth* branch_zaMirth_18;
			struct mirth_type_Type branch_Type_19;
			switch ((v16).tag) {
				case std_maybe_Maybe_1_None: {
					struct mirth_type_Type v20 = mtw_mirth_type_Type_Meta(v14);
					branch_Type_19 = v20;
					branch_zaMirth_18 = v15;
					branch_Subst_17 = in_Subst_2;
				} break;
				case std_maybe_Maybe_1_Some: {
					VAL v21 = mtp_std_maybe_Maybe_1_Some(v16);
					struct mirth_mirth_zaMirth* v22;
					struct mirth_type_Type v23 = mw_mirth_type_Type_expand(v15, V_mirth_type_Type(v21), &v22);
					incref(MK_mirth_type_Type(v23));
					struct std_maybe_Maybe_1 v24 = mtw_std_maybe_Maybe_1_Some(MK_mirth_type_Type(v23));
					struct mirth_mirth_zaMirth* v25;
					mw_mirth_type_MetaVar_typezyzx(v22, v24, v14, &v25);
					struct mirth_mirth_zaMirth* v26;
					struct std_list_List_1 v27;
					struct mirth_type_Type v28 = mw_mirth_type_Type_applyzesubst(v25, in_Subst_2, v23, &v26, &v27);
					branch_Type_19 = v28;
					branch_zaMirth_18 = v26;
					branch_Subst_17 = v27;
				} break;
				default: {
					do_panic(str_make("unexpected fallthrough in match\n", 32));
				}
			}
			branch_Type_9 = branch_Type_19;
			branch_Subst_8 = branch_Subst_17;
			branch_zaMirth_7 = branch_zaMirth_18;
		} break;
		case mirth_type_Type_Hole: {
			uint64_t v29 = mtp_mirth_type_Type_Hole(in_Type_3);
			struct mirth_type_Type v30 = mtw_mirth_type_Type_Hole(v29);
			branch_Type_9 = v30;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_Type_Var: {
			uint64_t v31 = mtp_mirth_type_Type_Var(in_Type_3);
			incref(MK_std_list_List_1(in_Subst_2));
			struct mirth_mirth_zaMirth* v32;
			struct std_maybe_Maybe_1 v33 = mw_mirth_type_Subst_lookupzevar(in_zaMirth_1, v31, in_Subst_2, &v32);
			struct mirth_type_Type branch_Type_34;
			switch ((v33).tag) {
				case std_maybe_Maybe_1_Some: {
					VAL v35 = mtp_std_maybe_Maybe_1_Some(v33);
					branch_Type_34 = V_mirth_type_Type(v35);
				} break;
				case std_maybe_Maybe_1_None: {
					struct mirth_type_Type v36 = mtw_mirth_type_Type_Var(v31);
					branch_Type_34 = v36;
				} break;
				default: {
					do_panic(str_make("unexpected fallthrough in match\n", 32));
				}
			}
			branch_Type_9 = branch_Type_34;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = v32;
		} break;
		case mirth_type_Type_Table: {
			uint64_t v37 = mtp_mirth_type_Type_Table(in_Type_3);
			struct mirth_type_Type v38 = mtw_mirth_type_Type_Table(v37);
			branch_Type_9 = v38;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_Type_Data: {
			uint64_t v39 = mtp_mirth_type_Type_Data(in_Type_3);
			struct mirth_type_Type v40 = mtw_mirth_type_Type_Data(v39);
			branch_Type_9 = v40;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_Type_DataPartial: {
			struct mirth_data_DataPartial* v41 = mtp_mirth_type_Type_DataPartial(in_Type_3);
			struct mirth_type_Type v42 = mtw_mirth_type_Type_DataPartial(v41);
			branch_Type_9 = v42;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_Type_Stack: {
			struct mirth_type_StackType v43 = mtp_mirth_type_Type_Stack(in_Type_3);
			struct mirth_mirth_zaMirth* v44;
			struct std_list_List_1 v45;
			struct mirth_type_StackType v46 = mw_mirth_type_StackType_applyzesubst(in_zaMirth_1, in_Subst_2, v43, &v44, &v45);
			struct mirth_type_Type v47 = mtw_mirth_type_Type_Stack(v46);
			branch_Type_9 = v47;
			branch_Subst_8 = v45;
			branch_zaMirth_7 = v44;
		} break;
		case mirth_type_Type_Arrow: {
			struct mirth_type_ArrowType* v48 = mtp_mirth_type_Type_Arrow(in_Type_3);
			struct mirth_mirth_zaMirth* v49;
			struct std_list_List_1 v50;
			struct mirth_type_ArrowType* v51 = mw_mirth_type_ArrowType_applyzesubst(in_zaMirth_1, in_Subst_2, v48, &v49, &v50);
			struct mirth_type_Type v52 = mtw_mirth_type_Type_Arrow(v51);
			branch_Type_9 = v52;
			branch_Subst_8 = v50;
			branch_zaMirth_7 = v49;
		} break;
		case mirth_type_Type_App: {
			struct mirth_type_Type v53;
			struct mirth_type_Type v54 = mtp_mirth_type_Type_App(in_Type_3, &v53);
			struct mirth_mirth_zaMirth* v55;
			struct std_list_List_1 v56;
			struct mirth_type_Type v57 = mw_mirth_type_Type_applyzesubst(in_zaMirth_1, in_Subst_2, v54, &v55, &v56);
			struct mirth_mirth_zaMirth* v58;
			struct std_list_List_1 v59;
			struct mirth_type_Type v60 = mw_mirth_type_Type_applyzesubst(v55, v56, v53, &v58, &v59);
			struct mirth_type_Type v61 = mtw_mirth_type_Type_App(v57, v60);
			branch_Type_9 = v61;
			branch_Subst_8 = v59;
			branch_zaMirth_7 = v58;
		} break;
		case mirth_type_Type_Mut: {
			struct mirth_type_Type v62 = mtp_mirth_type_Type_Mut(in_Type_3);
			struct mirth_mirth_zaMirth* v63;
			struct std_list_List_1 v64;
			struct mirth_type_Type v65 = mw_mirth_type_Type_applyzesubst(in_zaMirth_1, in_Subst_2, v62, &v63, &v64);
			struct mirth_type_Type v66 = mtw_mirth_type_Type_Mut(v65);
			branch_Type_9 = v66;
			branch_Subst_8 = v64;
			branch_zaMirth_7 = v63;
		} break;
		case mirth_type_Type_Value: {
			struct mirth_type_Value v67 = mtp_mirth_type_Type_Value(in_Type_3);
			struct mirth_mirth_zaMirth* v68;
			struct std_list_List_1 v69;
			struct mirth_type_Type v70 = mw_mirth_type_Value_applyzesubst(in_zaMirth_1, in_Subst_2, v67, &v68, &v69);
			branch_Type_9 = v70;
			branch_Subst_8 = v69;
			branch_zaMirth_7 = v68;
		} break;
		default: {
			do_panic(str_make("unexpected fallthrough in match\n", 32));
		}
	}
	*out_Subst_5 = branch_Subst_8;
	*out_zaMirth_4 = branch_zaMirth_7;
	return branch_Type_9;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
cmpl $0xd, %ecx
ja 0x3d372
movq %r9, %rbx
movl %ecx, %eax
movq %rdx, %r15
movl %esi, %r14d
movq %rdi, %r12
movl %ecx, %ecx
leaq 0x95cbb(%rip), %rdx     # 0xd2bbc
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %r13d, %r13d
jmp 0x3d34f
leaq -0x50(%rbp), %rsi
movq %r8, %rdi
callq 0x2ad00
movq %rdx, %r8
movq %rbx, -0x30(%rbp)
leaq -0x40(%rbp), %rbx
movq %rbx, (%rsp)
leaq -0x78(%rbp), %r13
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %r13, %r9
callq 0x3ced0
movl %eax, %r14d
movq %rdx, %r15
movq (%r13), %rdi
movl (%rbx), %esi
movq 0x8(%rbx), %rdx
leaq -0x50(%rbp), %rax
movl (%rax), %ecx
movq 0x8(%rax), %r8
leaq -0x68(%rbp), %r12
movq %r12, (%rsp)
leaq -0x70(%rbp), %rbx
movq %rbx, %r9
callq 0x3ced0
movq %rdx, %rcx
movl %r14d, %edi
movq %r15, %rsi
movl %eax, %edx
callq 0x1cff2
movq %rdx, %r13
movl (%r12), %r14d
movl 0x4(%r12), %ecx
movq 0x8(%r12), %r15
movq (%rbx), %r12
movq -0x30(%rbp), %rbx
pushq $0xb
jmp 0x3d1d8
movq %r8, %rdi
callq 0x2abd6
movq %rax, %rdi
callq 0x351c6
movq %rax, %r13
pushq $0x4
jmp 0x3d34e
movq %r8, %rdi
callq 0x2ad87
movq %rdx, %r8
movq %rbx, -0x30(%rbp)
leaq -0x50(%rbp), %rbx
movq %rbx, (%rsp)
leaq -0x40(%rbp), %r9
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %r9, %r12
callq 0x3ced0
movl %eax, %edi
movq %rdx, %rsi
callq 0x3a8f3
movq %rdx, %r13
movl (%rbx), %r14d
movl 0x4(%rbx), %ecx
movq 0x8(%rbx), %r15
movq -0x30(%rbp), %rbx
movq (%r12), %r12
pushq $0xc
jmp 0x3d1d8
movq %r8, %rdi
callq 0x2acc0
movq %rdx, %r8
movq %rbx, -0x30(%rbp)
leaq -0x50(%rbp), %rbx
movq %rbx, (%rsp)
leaq -0x40(%rbp), %r9
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %r9, %r12
callq 0x3dec6
movl %eax, %edi
movq %rdx, %rsi
callq 0x3a0fa
movq %rax, %r13
movl (%rbx), %r14d
movl 0x4(%rbx), %ecx
movq 0x8(%rbx), %r15
movq -0x30(%rbp), %rbx
movq (%r12), %r12
pushq $0x9
jmp 0x3d1d8
movq %r8, %rdi
callq 0x2aa5d
movl %eax, %edi
callq 0x1c77d
movq %rdx, %r13
pushq $0x2
jmp 0x3d34e
movq %r8, %rdi
callq 0x2aabf
movq %rax, %r13
leaq -0x40(%rbp), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x2aadc
cmpl $0x1, %eax
je 0x3d1f8
testl %eax, %eax
jne 0x3d372
movq %r13, %rdi
callq 0x2aeef
movq %rdx, %r13
pushq $0x3
popq %rax
movq -0x40(%rbp), %r12
jmp 0x3d34f
movq %r8, %rdi
callq 0x2ac2d
movq %rax, %rdi
callq 0x1e4a9
movq %rax, %r13
pushq $0x7
jmp 0x3d34e
movq %rbx, -0x30(%rbp)
movabsq $0xfffffffffffc, %r13   # imm = 0xFFFFFFFFFFFC
movq %r8, %rdi
callq 0x2abf3
movq %rax, %rbx
movq %r15, %rax
andq %r13, %rax
sete %cl
testb $0x3, %r15b
setne %dl
orb %cl, %dl
jne 0x3d107
incl (%rax)
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x3e3b5
testl %eax, %eax
je 0x3d2a4
cmpl $0x1, %eax
jne 0x3d372
movq %rdx, %rdi
callq 0xd491
andq %rax, %r13
shrq $0x30, %rax
jmp 0x3d2b2
movq %r8, %rdi
callq 0x2adc7
cmpl $0x3, %eax
ja 0x3d372
movl %eax, %eax
leaq 0x95aa0(%rip), %rcx     # 0xd2bf4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rdx, %rdi
callq 0x2af3e
movq %rax, %rdi
callq 0x3a72e
xorl %edi, %edi
jmp 0x3d341
movq %r8, %rdi
callq 0x2ac10
movq %rax, %rdi
callq 0x3a8aa
movq %rax, %r13
pushq $0x6
jmp 0x3d34e
movq %r8, %rdi
callq 0x2ac85
leaq -0x40(%rbp), %r8
movq %rbx, -0x30(%rbp)
leaq -0x50(%rbp), %rbx
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movq %rax, %rcx
movq %r8, %r12
movq %rbx, %r9
callq 0x3e2f8
movq %rax, %rdi
callq 0x3233d
movq %rdx, %r13
movl (%rbx), %r14d
movl 0x4(%rbx), %ecx
movq 0x8(%rbx), %r15
movq -0x30(%rbp), %rbx
movq (%r12), %r12
pushq $0xa
popq %rax
jmp 0x3d34f
movq %r8, %rdi
callq 0x2ac4a
movq %rax, %rdi
callq 0x3a85b
movq %rdx, %r13
pushq $0x8
jmp 0x3d34e
movq %rbx, -0x30(%rbp)
movq %rdx, %rdi
callq 0xd491
movq -0x40(%rbp), %rdi
movq %rax, %rsi
shrq $0x30, %rsi
movabsq $0xfffffffffffc, %rbx   # imm = 0xFFFFFFFFFFFC
andq %rbx, %rax
leaq -0x68(%rbp), %rcx
movq %rax, %rdx
callq 0x2ab4b
movq %rdx, %r12
movq %rax, -0x58(%rbp)
movq %rax, %rdi
shlq $0x30, %rdi
orq %rdx, %rdi
leaq 0xcb8a9(%rip), %rsi     # 0x108ae9
andq %rdx, %rbx
sete %al
testb $0x3, %r12b
setne %cl
orb %al, %cl
jne 0x3d253
incl (%rbx)
callq 0x8d0c
movq -0x68(%rbp), %rdi
leaq -0x78(%rbp), %rbx
movq %rdx, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x2ab8f
movq (%rbx), %rdi
leaq -0x50(%rbp), %rbx
movq %rbx, (%rsp)
leaq -0x70(%rbp), %r9
movl %r14d, %esi
movq %r15, %rdx
movq -0x58(%rbp), %rcx
movq %r12, %r8
movq %r9, %r14
callq 0x3ced0
movq %rdx, %r13
movq (%r14), %r12
movl (%rbx), %r14d
movl 0x4(%rbx), %ecx
movq 0x8(%rbx), %r15
jmp 0x3d2b2
movq %rbx, %rdi
callq 0x1cfa9
movq %rax, %r13
pushq $0x5
popq %rax
movq -0x30(%rbp), %rbx
jmp 0x3d34f
movq %rdx, %rdi
callq 0x2afa0
movq %rax, %rdi
callq 0x3a777
pushq $0x2
jmp 0x3d340
movq %rdx, %rdi
callq 0x2afdb
movq %rbx, -0x30(%rbp)
leaq -0x40(%rbp), %rbx
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x370ab
movq (%rbx), %rdi
leaq -0x68(%rbp), %rbx
leaq -0x50(%rbp), %r12
movl %r14d, %esi
movq %r15, %rdx
movq %rax, %rcx
movq %rbx, %r8
movq %r12, %r9
callq 0x3e2f8
movq %rax, %rdi
callq 0x3233d
movq %rdx, %r13
movl (%r12), %r14d
movl 0x4(%r12), %ecx
movq 0x8(%r12), %r15
movq (%rbx), %r12
movq -0x30(%rbp), %rbx
jmp 0x3d1d6
movq %rdx, %rdi
callq 0x2af79
callq 0x3a7c0
pushq $0x1
popq %rdi
movq %rax, %rsi
callq 0x34ac7
movq %rdx, %r13
pushq $0xd
popq %rax
movq 0x10(%rbp), %rdx
movl %r14d, (%rdx)
movl %ecx, 0x4(%rdx)
movq %r15, 0x8(%rdx)
movq %r12, (%rbx)
movq %r13, %rdx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x97494(%rip), %rdi     # 0xd480d
pushq $0x20
popq %rsi
callq 0x8a21
movq %rax, %rdi
callq 0x8cc6