// File: /workspace/github_c_makefile_star2_O2/mirth-lang[P]mirth/bin/mirth1.c
// Function: mw_mirth_type_StackType_applyzesubst
static struct mirth_type_StackType mw_mirth_type_StackType_applyzesubst (struct mirth_mirth_zaMirth* in_zaMirth_1, struct std_list_List_1 in_Subst_2, struct mirth_type_StackType in_StackType_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_StackType branch_StackType_9;
	switch ((in_StackType_3).tag) {
		case mirth_type_StackType_Error: {
			struct mirth_type_StackType v10 = { .tag=mirth_type_StackType_Error };
			branch_StackType_9 = v10;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_StackType_Ignore: {
			struct mirth_type_StackType v11 = { .tag=mirth_type_StackType_Ignore };
			branch_StackType_9 = v11;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_StackType_Unit: {
			struct mirth_type_StackType v12 = { .tag=mirth_type_StackType_Unit };
			branch_StackType_9 = v12;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = in_zaMirth_1;
		} break;
		case mirth_type_StackType_Meta: {
			uint64_t v13 = mtp_mirth_type_StackType_Meta(in_StackType_3);
			struct mirth_mirth_zaMirth* v14;
			struct std_maybe_Maybe_1 v15 = mw_mirth_type_MetaVar_typezy(in_zaMirth_1, v13, &v14);
			struct std_list_List_1 branch_Subst_16;
			struct mirth_mirth_zaMirth* branch_zaMirth_17;
			struct mirth_type_StackType branch_StackType_18;
			switch ((v15).tag) {
				case std_maybe_Maybe_1_None: {
					struct mirth_type_StackType v19 = mtw_mirth_type_StackType_Meta(v13);
					branch_StackType_18 = v19;
					branch_zaMirth_17 = v14;
					branch_Subst_16 = in_Subst_2;
				} break;
				case std_maybe_Maybe_1_Some: {
					VAL v20 = mtp_std_maybe_Maybe_1_Some(v15);
					struct mirth_mirth_zaMirth* v21;
					struct mirth_type_Type v22 = mw_mirth_type_Type_expand(v14, V_mirth_type_Type(v20), &v21);
					incref(MK_mirth_type_Type(v22));
					struct std_maybe_Maybe_1 v23 = mtw_std_maybe_Maybe_1_Some(MK_mirth_type_Type(v22));
					struct mirth_mirth_zaMirth* v24;
					mw_mirth_type_MetaVar_typezyzx(v21, v23, v13, &v24);
					struct mirth_type_StackType v25 = mw_mirth_type_Type_zgStackType(v22);
					struct mirth_mirth_zaMirth* v26;
					struct std_list_List_1 v27;
					struct mirth_type_StackType v28 = mw_mirth_type_StackType_applyzesubst(v24, in_Subst_2, v25, &v26, &v27);
					branch_StackType_18 = v28;
					branch_zaMirth_17 = v26;
					branch_Subst_16 = v27;
				} break;
				default: {
					do_panic(str_make("unexpected fallthrough in match\n", 32));
				}
			}
			branch_StackType_9 = branch_StackType_18;
			branch_Subst_8 = branch_Subst_16;
			branch_zaMirth_7 = branch_zaMirth_17;
		} break;
		case mirth_type_StackType_Var: {
			uint64_t v29 = mtp_mirth_type_StackType_Var(in_StackType_3);
			incref(MK_std_list_List_1(in_Subst_2));
			struct mirth_mirth_zaMirth* v30;
			struct std_maybe_Maybe_1 v31 = mw_mirth_type_Subst_lookupzevar(in_zaMirth_1, v29, in_Subst_2, &v30);
			struct mirth_type_StackType branch_StackType_32;
			switch ((v31).tag) {
				case std_maybe_Maybe_1_Some: {
					VAL v33 = mtp_std_maybe_Maybe_1_Some(v31);
					struct mirth_type_StackType v34 = mw_mirth_type_Type_zgStackType(V_mirth_type_Type(v33));
					branch_StackType_32 = v34;
				} break;
				case std_maybe_Maybe_1_None: {
					struct mirth_type_StackType v35 = mtw_mirth_type_StackType_Var(v29);
					branch_StackType_32 = v35;
				} break;
				default: {
					do_panic(str_make("unexpected fallthrough in match\n", 32));
				}
			}
			branch_StackType_9 = branch_StackType_32;
			branch_Subst_8 = in_Subst_2;
			branch_zaMirth_7 = v30;
		} break;
		case mirth_type_StackType_Cons: {
			struct mirth_type_Type v36;
			struct mirth_type_StackType v37 = mtp_mirth_type_StackType_Cons(in_StackType_3, &v36);
			struct mirth_mirth_zaMirth* v38;
			struct std_list_List_1 v39;
			struct mirth_type_StackType v40 = mw_mirth_type_StackType_applyzesubst(in_zaMirth_1, in_Subst_2, v37, &v38, &v39);
			struct mirth_mirth_zaMirth* v41;
			struct std_list_List_1 v42;
			struct mirth_type_Type v43 = mw_mirth_type_Type_applyzesubst(v38, v39, v36, &v41, &v42);
			struct mirth_type_StackType v44 = mtw_mirth_type_StackType_Cons(v40, v43);
			branch_StackType_9 = v44;
			branch_Subst_8 = v42;
			branch_zaMirth_7 = v41;
		} break;
		case mirth_type_StackType_With: {
			struct mirth_type_Type v45;
			struct mirth_type_StackType v46 = mtp_mirth_type_StackType_With(in_StackType_3, &v45);
			struct mirth_mirth_zaMirth* v47;
			struct std_list_List_1 v48;
			struct mirth_type_StackType v49 = mw_mirth_type_StackType_applyzesubst(in_zaMirth_1, in_Subst_2, v46, &v47, &v48);
			struct mirth_mirth_zaMirth* v50;
			struct std_list_List_1 v51;
			struct mirth_type_Type v52 = mw_mirth_type_Resource_applyzesubst(v47, v48, v45, &v50, &v51);
			struct mirth_type_StackType v53 = mtw_mirth_type_StackType_With(v49, v52);
			branch_StackType_9 = v53;
			branch_Subst_8 = v51;
			branch_zaMirth_7 = v50;
		} break;
		case mirth_type_StackType_ConsLabel: {
			struct mirth_type_Type v54;
			uint64_t v55;
			struct mirth_type_StackType v56 = mtp_mirth_type_StackType_ConsLabel(in_StackType_3, &v54, &v55);
			struct mirth_mirth_zaMirth* v57;
			struct std_list_List_1 v58;
			struct mirth_type_StackType v59 = mw_mirth_type_StackType_applyzesubst(in_zaMirth_1, in_Subst_2, v56, &v57, &v58);
			struct mirth_mirth_zaMirth* v60;
			struct std_list_List_1 v61;
			struct mirth_type_Type v62 = mw_mirth_type_Type_applyzesubst(v57, v58, v54, &v60, &v61);
			struct mirth_type_StackType v63 = mtw_mirth_type_StackType_ConsLabel(v59, v62, v55);
			branch_StackType_9 = v63;
			branch_Subst_8 = v61;
			branch_zaMirth_7 = v60;
		} break;
		case mirth_type_StackType_WithLabel: {
			struct mirth_type_Type v64;
			uint64_t v65;
			struct mirth_type_StackType v66 = mtp_mirth_type_StackType_WithLabel(in_StackType_3, &v64, &v65);
			struct mirth_mirth_zaMirth* v67;
			struct std_list_List_1 v68;
			struct mirth_type_StackType v69 = mw_mirth_type_StackType_applyzesubst(in_zaMirth_1, in_Subst_2, v66, &v67, &v68);
			struct mirth_mirth_zaMirth* v70;
			struct std_list_List_1 v71;
			struct mirth_type_Type v72 = mw_mirth_type_Resource_applyzesubst(v67, v68, v64, &v70, &v71);
			struct mirth_type_StackType v73 = mtw_mirth_type_StackType_WithLabel(v69, v72, v65);
			branch_StackType_9 = v73;
			branch_Subst_8 = v71;
			branch_zaMirth_7 = v70;
		} 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_StackType_9;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
cmpl $0x8, %ecx
ja 0x3e2e1
movq %r9, %rbx
movl %ecx, %eax
movq %rdx, %r15
movl %esi, %r14d
movq %rdi, %r12
movl %ecx, %ecx
leaq 0x94d41(%rip), %rdx     # 0xd2c38
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %edx, %edx
jmp 0x3e2c1
leaq -0x50(%rbp), %rsi
movq %r8, %rdi
callq 0x34f7f
movq %rdx, %r8
movq %rbx, -0x30(%rbp)
leaq -0x60(%rbp), %rbx
movq %rbx, (%rsp)
leaq -0x38(%rbp), %r13
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %r13, %r9
callq 0x3dec6
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 -0x70(%rbp), %r12
movq %r12, (%rsp)
leaq -0x40(%rbp), %rbx
movq %rbx, %r9
callq 0x3e670
movq %rdx, %rcx
movl %r14d, %edi
movq %r15, %rsi
movl %eax, %edx
callq 0x1e82b
movl (%r12), %r14d
movl 0x4(%r12), %ecx
movq 0x8(%r12), %r15
movq (%rbx), %r12
movq -0x30(%rbp), %rbx
pushq $0x7
jmp 0x3e148
leaq -0x50(%rbp), %rsi
movq %r8, %rdi
callq 0x34ef8
movq %rdx, %r8
movq %rbx, -0x30(%rbp)
leaq -0x60(%rbp), %rbx
movq %rbx, (%rsp)
leaq -0x38(%rbp), %r13
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %r13, %r9
callq 0x3dec6
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 -0x70(%rbp), %r12
movq %r12, (%rsp)
leaq -0x40(%rbp), %rbx
movq %rbx, %r9
callq 0x3ced0
movq %rdx, %rcx
movl %r14d, %edi
movq %r15, %rsi
movl %eax, %edx
callq 0x1e310
movl (%r12), %r14d
movl 0x4(%r12), %ecx
movq 0x8(%r12), %r15
movq (%rbx), %r12
movq -0x30(%rbp), %rbx
pushq $0x5
jmp 0x3e148
leaq -0x50(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movq %r8, %rdi
callq 0x3502f
movq %rdx, %r8
movq %rbx, -0x30(%rbp)
leaq -0x60(%rbp), %rbx
movq %rbx, (%rsp)
leaq -0x40(%rbp), %r13
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %r13, %r9
callq 0x3dec6
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 -0x70(%rbp), %r12
movq %r12, (%rsp)
leaq -0x80(%rbp), %rbx
movq %rbx, %r9
callq 0x3ced0
movq %rdx, %rcx
leaq -0x38(%rbp), %rdx
movq (%rdx), %r8
movl %r14d, %edi
movq %r15, %rsi
movl %eax, %edx
callq 0x393fa
movl (%r12), %r14d
movl 0x4(%r12), %ecx
movq 0x8(%r12), %r15
movq (%rbx), %r12
movq -0x30(%rbp), %rbx
pushq $0x6
jmp 0x3e148
leaq -0x50(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movq %r8, %rdi
callq 0x350d3
movq %rdx, %r8
movq %rbx, -0x30(%rbp)
leaq -0x60(%rbp), %rbx
movq %rbx, (%rsp)
leaq -0x40(%rbp), %r13
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %r13, %r9
callq 0x3dec6
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 -0x70(%rbp), %r12
movq %r12, (%rsp)
leaq -0x80(%rbp), %rbx
movq %rbx, %r9
callq 0x3e670
movq %rdx, %rcx
leaq -0x38(%rbp), %rdx
movq (%rdx), %r8
movl %r14d, %edi
movq %r15, %rsi
movl %eax, %edx
callq 0x39a7a
movl (%r12), %r14d
movl 0x4(%r12), %ecx
movq 0x8(%r12), %r15
movq (%rbx), %r12
movq -0x30(%rbp), %rbx
pushq $0x8
popq %rax
jmp 0x3e2c1
movq %r8, %rdi
callq 0x34e20
movq %rax, %r13
leaq -0x60(%rbp), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x2aadc
cmpl $0x1, %eax
je 0x3e1fa
testl %eax, %eax
jne 0x3e2e1
movq %r13, %rdi
callq 0x35177
pushq $0x4
popq %rax
movq -0x60(%rbp), %r12
jmp 0x3df02
movq %rbx, -0x30(%rbp)
movabsq $0xfffffffffffc, %r13   # imm = 0xFFFFFFFFFFFC
movq %r8, %rdi
callq 0x34edb
movq %rax, %rbx
movq %r15, %rax
andq %r13, %rax
sete %cl
testb $0x3, %r15b
setne %dl
orb %cl, %dl
jne 0x3e1bc
incl (%rax)
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x3e3b5
testl %eax, %eax
je 0x3e2af
cmpl $0x1, %eax
jne 0x3e2e1
movq %rdx, %rdi
callq 0xd491
andq %rax, %r13
movq %rax, %rdi
shrq $0x30, %rdi
movq %r13, %rsi
callq 0x34e3d
jmp 0x3e2bd
movq %rbx, -0x30(%rbp)
movq %rdx, %rdi
callq 0xd491
movq -0x60(%rbp), %rdi
movq %rax, %rsi
shrq $0x30, %rsi
movabsq $0xfffffffffffc, %rbx   # imm = 0xFFFFFFFFFFFC
andq %rbx, %rax
leaq -0x70(%rbp), %rcx
movq %rax, %rdx
callq 0x2ab4b
movq %rdx, %r12
movq %rax, -0x78(%rbp)
movq %rax, %rdi
shlq $0x30, %rdi
orq %rdx, %rdi
leaq 0xca8a7(%rip), %rsi     # 0x108ae9
andq %rdx, %rbx
sete %al
testb $0x3, %r12b
setne %cl
orb %al, %cl
jne 0x3e255
incl (%rbx)
callq 0x8d0c
movq -0x70(%rbp), %rdi
leaq -0x38(%rbp), %rbx
movq %rdx, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x2ab8f
movq -0x78(%rbp), %rdi
movq %r12, %rsi
callq 0x34e3d
movq %rdx, %r8
movq (%rbx), %rdi
leaq -0x50(%rbp), %r13
movq %r13, (%rsp)
leaq -0x40(%rbp), %rbx
movl %r14d, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %rbx, %r9
callq 0x3dec6
movq (%rbx), %r12
movl (%r13), %r14d
movl 0x4(%r13), %ecx
movq 0x8(%r13), %r15
jmp 0x3e2bd
movq %rbx, %rdi
callq 0x32c7c
movq %rax, %rdx
pushq $0x3
popq %rax
movq -0x30(%rbp), %rbx
movq 0x10(%rbp), %rsi
movl %r14d, (%rsi)
movl %ecx, 0x4(%rsi)
movq %r15, 0x8(%rsi)
movq %r12, (%rbx)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x96525(%rip), %rdi     # 0xd480d
pushq $0x20
popq %rsi
callq 0x8a21
movq %rax, %rdi
callq 0x8cc6